GamRateLogic.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * GamRateLogic.php UTF-8
  4. * 推广游戏逻辑
  5. *
  6. * @date : 2018/5/19 16:46
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : linjiebin <ljb@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\logic\game;
  13. use huo\model\common\CommonModel;
  14. use huo\model\game\GameModel;
  15. use huo\model\rate\GameRateModel;
  16. use huolib\constant\GameConst;
  17. class GamRateLogic extends CommonModel {
  18. /**
  19. * 获取推广游戏列表
  20. *
  21. * @param $where
  22. *
  23. * @return \think\Paginator
  24. */
  25. public function getAgentGameList($where) {
  26. $_map = [];
  27. if (!empty($where['app_id'])) {
  28. $_map['app_id'] = $where['app_id'];
  29. }
  30. if (!empty($where['classify'])) {
  31. $_map['classify'] = $where['classify'];
  32. }
  33. $_map['is_sdk'] = GameConst::GAME_IS_SDK; //只有sdk游戏才可推广
  34. $_map['status'] = GameConst::GAME_STATUS_ON; //只有上线游戏才可推广
  35. $_field['app_id'] = 'app_id';
  36. $_field['classify'] = 'classify_label';
  37. $_field['agent_benefit_type'] = 'agent_benefit_type';
  38. $_field['agent_reward'] = 'agent_reward';
  39. $_field['sub_agent_reward'] = 'sub_agent_reward';
  40. $_field['agent_rebate'] = 'agent_rebate';
  41. $_field['sub_agent_rebate'] = 'sub_agent_rebate';
  42. $_item = (new GameModel())->with('rate,mini')->where($_map)->order('create_time desc')->field($_field)
  43. ->paginate();
  44. $this->getGameRateExt($_item);
  45. return $_item;
  46. }
  47. /**
  48. * 获取游戏折扣
  49. *
  50. * @param $items
  51. */
  52. private function getGameRateExt(&$items) {
  53. $_gr_model = new GameRateModel();
  54. foreach ($items as $key => $value) {
  55. $items[$key]['agent_benefit_type_text'] = $_gr_model->getAgentBenefitTypeTextAttr($value['agent_benefit_type']);
  56. $items[$key]['mini_app_id'] = empty($value['mini']['mini_app_id']) ? '' : $value['mini']['mini_app_id'];
  57. }
  58. }
  59. }