123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- <?php
- /**
- * AgentGameLogic.php UTF-8
- * 渠道游戏逻辑处理
- *
- * @date : 2018/5/17 20:43
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace huomp\logic\game;
- use huo\controller\common\CommonFunc;
- use huo\model\agent\AgentGameModel;
- use huo\model\common\CommonModel;
- use huo\model\game\GamecategoryModel;
- use huo\model\game\GameModel;
- use huo\model\member\MemGameModel;
- use huolib\constant\CategoryConst;
- use huolib\constant\CommonConst;
- use huolib\constant\GameConst;
- use huolib\constant\OptionConst;
- use huolib\tool\Time;
- use huomp\logic\share\ShareLogic;
- class AgentGameListLogic extends CommonModel {
- /**
- * @param array $param
- *
- * @return array
- */
- protected function getWhere($param = []) {
- $_map = [];
- if (!empty($param['agent_id'])) {
- $_map['agent_game_model.agent_id'] = $param['agent_id'];
- }
- if (!empty($param['classify'])) {
- $_map['game.classify'] = $param['classify'];
- }
- if (!empty($param['app_id'])) {
- $_map['game.id'] = $param['app_id'];
- }
- $_map['agent_game_model.is_delete'] = CommonConst::CONST_NOT_DELETE;
- $_map['game.is_delete'] = CommonConst::CONST_NOT_DELETE;
- $_map['game.status'] = GameConst::GAME_STATUS_ON;
- return $_map;
- }
- /**
- * 获取渠道的游戏列表
- *
- * @param int $mem_id
- * @param array $where
- * @param string $page
- * @param string $order
- *
- * @return mixed
- */
- public function getAgentGames($mem_id, $where = [], $page = '1,10', $order = '-create_time') {
- $_map = $this->getWhere($where);
- $_ag_model = new AgentGameModel();
- $_count = $_ag_model->with('game')->where($_map)->count();
- if (empty($_count)) {
- return [
- 'count' => 0,
- 'list' => [],
- ];
- }
- $_order = $this->orderFilter($order);
- $_agent_games = $_ag_model
- ->with('gameext,game,gamemini,rate,gv')
- ->where($_map)
- ->order($_order)
- ->page($page)
- ->select();
- if (is_object($_agent_games)) {
- $_agent_games = $_agent_games->toArray();
- }
- if (empty($_agent_games)) {
- return [
- 'count' => $_count,
- 'list' => [],
- ];
- }
- $_list = [];
- $_share_logic = new ShareLogic();
- $_mg_model = new MemGameModel();
- $_gold_rmb_rate = CommonFunc::getGoldRmbRate();
- foreach ($_agent_games as $_k => $_agent_game) {
- $_share_setting = $_share_logic->getShareSetting($_agent_game['app_id']);
- // /* 判定是否获取过收益 */
- // $_integral = (new Income())->getOpenGain($mem_id, $_agent_game['app_id']);
- // $_has_open = false;
- // if (is_numeric($_integral)) {
- // $_has_open = true;
- // }
- $_has_open = true;
- //判断是否为试玩列表游戏
- $_rs = (new GamecategoryModel())->isGameExist(CategoryConst::CATE_CATE_RP, $_agent_game['app_id']);
- if ($_rs) {
- list($today_start, $today_end) = Time::today();
- $_mem_game_model = new MemGameModel();
- $_rs = $_mem_game_model->hasOpen($mem_id, $_agent_game['app_id'], $today_start);
- if (!$_rs) {
- $_has_open = false;
- }
- }
- $_need_popup = empty($_v['gamemini']['need_popup']) ? GameConst::RATE_MP_NEED_POPUP_NOT
- : $_v['gamemini']['need_popup'];
- $_entrance_image = '';
- if (GameConst::RATE_MP_NEED_POPUP == $_need_popup) {
- $_entrance_image = empty($_v['gamemini']['entrance_image']) ? '' : $_v['gamemini']['entrance_image'];
- }
- $_data = [
- 'ag_id' => $_agent_game['id'],
- 'game_id' => $_agent_game['app_id'],
- 'mini_app_id' => !empty($_agent_game['gamemini']) ? $_agent_game['gamemini']['mini_app_id'] : '',
- 'gamename' => !empty($_agent_game['game']) ? $_agent_game['game']['name'] : '',
- 'icon' => !empty($_agent_game['game']) ? $_agent_game['game']['icon'] : '',
- 'oneword' => !empty($_agent_game['game']) ? $_agent_game['game']['publicity'] : '',
- 'down_cnt' => !empty($_agent_game['gameext']) ? $_agent_game['gameext']['down_cnt'] : '',
- 'mem_agent_reward' => !empty($_agent_game['rate']) ? $_agent_game['rate']['mem_agent_reward'] : '',
- 'mem_reward' => !empty($_agent_game['rate']) ? $_agent_game['rate']['mem_reward'] : '',
- 'url' => !empty($_agent_game['gv']) ? $_agent_game['gv'][0]['package_url'] : '',
- 'is_play' => $_has_open ? CommonConst::CONST_TRUE : CommonConst::CONST_FALSE,
- 'need_popup' => $_need_popup,
- 'entrance_image' => cmf_get_image_preview_url($_entrance_image),
- 'player' => (new MemGameLogic())->getPlayer($mem_id, $_agent_game['app_id']),
- ];
- $_data['mem_agent_integral'] = intval($_data['mem_agent_reward'] * $_gold_rmb_rate);
- $_data['mem_integral'] = intval($_data['mem_reward'] * $_gold_rmb_rate);
- $_data['share_title'] = $_share_setting[OptionConst::SETTING_SHARE_TITLE]; /* 分享名称 */
- $_data['share_img'] = cmf_get_image_preview_url(
- $_share_setting[OptionConst::SETTING_SHARE_IMG_GAME]
- ); /* 分享群背景图 */
- $_data['share_background'] = cmf_get_image_preview_url(
- $_share_setting[OptionConst::SETTING_SHARE_IMG_MP]
- ); /* 朋友圈分享背景图 */
- $_list[] = $_data;
- }
- return [
- 'count' => $_count,
- 'list' => $_list,
- ];
- }
- /**
- * 获取有推广奖励的游戏
- *
- * @param int $limit 显示个数
- *
- * @return array
- */
- public function getRewardGame($limit = 3) {
- $_map = [
- 'status' => GameConst::GAME_STATUS_ON,
- 'mem_agent_reward' => ['neq', 0],
- ];
- $_game_ids = (new GameModel())->with('rate')->where($_map)->limit($limit)->column('game_model.id');
- return $_game_ids;
- }
- }
|