123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?php
- /**
- * GamePayShowLogic.php UTF-8
- * 支付显示逻辑处理
- *
- * @date : 2019/8/27 20:02
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : dengcongshuai <dcs@huosdk.com>
- * @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;
- }
- }
|