| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- namespace app\common\repositories\shared;
- use app\common\dao\shared\SharedProsperityRecommendConfigDao;
- use app\common\repositories\BaseRepository;
- use app\entity\data\shared\SharedProsperityRecommendConfigEntity;
- class SharedProsperityRecommendConfigRepository extends BaseRepository
- {
- protected $dao;
- /**
- * SharedProsperityUserRepository constructor.
- * @param SharedProsperityRecommendConfigDao $dao
- */
- public function __construct(SharedProsperityRecommendConfigDao $dao)
- {
- $this->dao = $dao;
- }
- public function create($data)
- {
- return $this->dao->create($data);
- }
- /**
- * @param SharedProsperityRecommendConfigEntity $sharedProsperityRecommendConfigEntity
- * @return SharedProsperityRecommendConfigEntity
- */
- public function createByEntity(SharedProsperityRecommendConfigEntity $sharedProsperityRecommendConfigEntity): SharedProsperityRecommendConfigEntity
- {
- $result = $this->create($sharedProsperityRecommendConfigEntity->toUnderlineArray())->toArray();
- /** @var SharedProsperityRecommendConfigEntity $entity */
- $entity = SharedProsperityRecommendConfigEntity::newInstance($result);
- return $entity;
- }
- /**
- * @return SharedProsperityRecommendConfigEntity[]
- * @author 史晨
- * @date 2026/2/5 14:12
- */
- public function getList(): array
- {
- return $this->dao->getConfigList();
- }
- /**
- * @param $id
- * @return array
- * @author 史晨
- * @date 2026/2/5 14:12
- */
- public function getDetail($id)
- {
- return $this->dao->getDetailById($id);
- }
- /**
- * @param $params
- * @return bool
- * @author 史晨
- * @date 2026/2/5 14:12
- */
- public function update($params)
- {
- $id = $params['id'];
- unset($params['id']);
- if (!is_numeric($params['consume']) || $params['consume'] == 0) {
- $params['consume'] = null;
- }
- if (!$this->dao->update($id, $params)) {
- return false;
- }
- return true;
- }
- /**
- * @param int $level
- * @return SharedProsperityRecommendConfigEntity
- */
- public function getSharedProsperityRecommendConfigEntityByLevel(int $level): SharedProsperityRecommendConfigEntity
- {
- $entityList = $this->getSharedProsperityRecommendConfigEntityListByLevelList([$level]);
- $entity = array_shift($entityList);
- if ($entity instanceof SharedProsperityRecommendConfigEntity) {
- return $entity;
- } else {
- /** @var SharedProsperityRecommendConfigEntity */
- return SharedProsperityRecommendConfigEntity::newInstance();
- }
- }
- /**
- * @param array $levelList
- * @return SharedProsperityRecommendConfigEntity[]
- */
- public function getSharedProsperityRecommendConfigEntityListByLevelList(array $levelList): array
- {
- return $this->dao->getSharedProsperityRecommendConfigEntityListByLevelList($levelList);
- }
- /**
- * 获取 最大 推荐奖励占比
- * @return SharedProsperityRecommendConfigEntity
- */
- public function getSharedProsperityRecommendConfigEntityByMaxRewardRatio(): SharedProsperityRecommendConfigEntity
- {
- return $this->dao->getSharedProsperityRecommendConfigEntityByMaxRewardRatio();
- }
- }
|