* @version : HUOSDK 8.0 */ namespace huo\logic\game; use huo\controller\game\GamePayShowCache; use huo\model\common\CommonModel; use huo\model\game\GamePayShowModel; use huolib\constant\OrderConst; class GamePayShowLogic extends CommonModel { public $base_field = [ 'app_id' => 'app_id', 'start_time' => 'start_time', 'end_time' => 'end_time', 'start_ip' => 'start_ip', 'end_ip' => 'end_ip', 'price' => 'price', 'is_domestic' => 'is_domestic', 'is_overseas' => 'is_overseas', 'no_show_version' => 'no_show_version', 'system' => 'system', 'combat_num_mini' => 'combat_num_mini', 'combat_num_max' => 'combat_num_max', 'level_mini' => 'level_mini', 'level_max' => 'level_max', 'login_day_mini' => 'login_day_mini', 'login_day_max' => 'login_day_max', 'ip_black' => 'ip_black', 'area' => 'area', 'mem_id' => 'mem_id', ]; public function getBaseField() { return $this->base_field; } /** * 切换规则列表 * * @param int $app_id * @param string $page * * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function getLists($app_id = 0, $page = '') { $_map = []; if (!empty($app_id)) { $_map['app_id'] = $app_id; } $_model = new GamePayShowModel(); $_count = $_model->where($_map)->count(); if ($_count <= 0) { $_rdata['count'] = 0; $_rdata['list'] = []; } else { $_field = $this->base_field; $_switch_lists = $_model ->with('game') ->field($_field) ->where($_map) ->page($page) ->select(); if (is_object($_switch_lists)) { $_switch_lists = $_switch_lists->toArray(); } $_lists = []; foreach ($_switch_lists as $_v) { $_data = []; foreach ($_field as $_value) { $_data[$_value] = $_v[$_value]; } $_data['game_name'] = ''; if (!empty($_v['game'])) { $_data['game_name'] = empty($_v['game']['game_name']) ? '' : $_v['game']['game_name']; } $_lists[] = $_data; } $_rdata = [ 'count' => $_count, 'list' => $_lists ]; } return $_rdata; } /*** * 添加切换规则 * * @param $param * * @return false|int */ public function addPayShow($param) { $_rs = (new GamePayShowModel())->allowField(true)->save($param); return $_rs; } /** * 获取规则信息 * * @param $app_id * * @return bool */ public function getInfoByAppId($app_id) { if (empty($app_id)) { return false; } $_map['app_id'] = $app_id; $_field = $this->base_field; $_rdata = (new GamePayShowModel())->field($_field)->where($_map)->find(); if (is_object($_rdata)) { $_rdata = $_rdata->toArray(); } return $_rdata; } /** * 更新规则信息 * * @param $param * @param $app_id * * @return GamePayShowModel */ public function updatePaySwitch($param, $app_id) { $_map['app_id'] = $app_id; $_rs = (new GamePayShowModel())->update($param, $_map, true); return $_rs; } /*** * 查找切换规则是否已存在 * * @param $app_id * * @return bool */ public function checkGame($app_id) { $_info = GamePayShowCache::ins()->getInfoByAppId($app_id); if (empty($_info)) { return false; } return true; } }