| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- namespace app\common\dao\shared;
- use app\common\dao\BaseDao;
- use app\common\model\shared\SharedProsperityRecommendConfig;
- use app\entity\data\shared\SharedProsperityRecommendConfigEntity;
- class SharedProsperityRecommendConfigDao extends BaseDao
- {
- protected function getModel(): string
- {
- return SharedProsperityRecommendConfig::class;
- }
- /**
- * @return SharedProsperityRecommendConfigEntity[]
- * @author 史晨
- * @date 2026/2/5 14:43
- * 获取推荐配置
- */
- public function getConfigList($idEntity = true): array
- {
- $entityList = [];
- try {
- /** @var SharedProsperityRecommendConfig $model */
- $model = $this->getModel();
- $dataRes = $model::getDB()
- ->select()
- ->toArray();
- if (!empty($dataRes) && $idEntity) {
- $entityList = array_map(function ($data) {
- return SharedProsperityRecommendConfigEntity::newInstance($data);
- }, $dataRes);
- }else{
- $entityList = $dataRes;
- }
- } catch (\Exception $e) {
- }
- return $entityList;
- }
- /**
- * @param $id
- * @return mixed
- * @author 史晨
- * @date 2026/2/5 14:43
- * 获取推荐配置详情
- */
- public function getDetailById($id)
- {
- /** @var SharedProsperityRecommendConfig $model */
- $model = $this->getModel();
- return $model::getDB()
- ->where(['id' => $id])
- ->find();
- }
- /**
- * @param array $levelList
- * @return SharedProsperityRecommendConfigEntity[]
- */
- public function getSharedProsperityRecommendConfigEntityListByLevelList(array $levelList): array
- {
- $entityList = [];
- try {
- /** @var SharedProsperityRecommendConfig $model */
- $model = $this->getModel();
- $dataRes = $model::getDB()
- ->whereIn('level', $levelList)
- ->select()
- ->toArray();
- if (!empty($dataRes)) {
- $entityList = array_map(function ($data) {
- return SharedProsperityRecommendConfigEntity::newInstance($data);
- }, $dataRes);
- }
- } catch (\Exception $e) {
- }
- return $entityList;
- }
- /**
- * 获取 配置实体 根据 最大的 直推奖比例
- * @return SharedProsperityRecommendConfigEntity
- */
- public function getSharedProsperityRecommendConfigEntityByMaxRewardRatio(): SharedProsperityRecommendConfigEntity
- {
- $entity = SharedProsperityRecommendConfigEntity::newInstance();
- try {
- /** @var SharedProsperityRecommendConfig $model */
- $model = $this->getModel();
- $dataRes = $model::getDB()
- ->order('reward_ratio', 'desc')
- ->limit(1)
- ->select()
- ->toArray();
- if (!empty($dataRes)) {
- $entity = SharedProsperityRecommendConfigEntity::newInstance($dataRes[0]);
- }
- } catch (\Exception $e) {
- }
- return $entity;
- }
- }
|