| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 | 
							- <?php
 
- /**
 
-  * GamePaySwitchLogic.php  UTF-8
 
-  * 支付切换逻辑处理
 
-  *
 
-  * @date    : 2018/6/6 22:10
 
-  *
 
-  * @license 这不是一个自由软件,未经授权不许任何使用和传播。
 
-  * @author  : chenbingling <cbl@huosdk.com>
 
-  * @version : HUOSDK 8.0
 
-  */
 
- namespace huo\logic\game;
 
- use ban\model\DeviceBanModel;
 
- use ban\model\IpBanModel;
 
- use huo\controller\game\GamePaySwitchCache;
 
- use huo\model\common\CommonModel;
 
- use huo\model\game\GamePaySwitchModel;
 
- use huo\model\member\MemberModel;
 
- use huolib\constant\OrderConst;
 
- class GamePaySwitchLogic extends CommonModel {
 
-     public $base_field
 
-         = [
 
-             'app_id'            => 'app_id',
 
-             'switch_app_id'     => 'switch_app_id',
 
-             'pages'             => 'pages',
 
-             'start_time'        => 'start_time',
 
-             'end_time'          => 'end_time',
 
-             'start_ip'          => 'start_ip',
 
-             'end_ip'            => 'end_ip',
 
-             'is_first'          => 'is_first',
 
-             'price'             => 'price',
 
-             'is_domestic'       => 'is_domestic',
 
-             'is_overseas'       => 'is_overseas',
 
-             'no_switch_version' => 'no_switch_version',
 
-             'system'            => 'system',
 
-             'pay_type'          => 'pay_type',
 
-             'combat_num_mini'   => 'combat_num_mini',
 
-             'combat_num_max'    => 'combat_num_max',
 
-             'ip_white'          => 'ip_white',
 
-             'area'              => 'area',
 
-             'money'             => 'money',
 
-             'active_days'       => 'active_days',
 
-             'mem_id'            => 'mem_id',
 
-             'sum_money'         => 'sum_money',
 
-         ];
 
-     public function getBaseField() {
 
-         return $this->base_field;
 
-     }
 
-     /**
 
-      * 切换规则列表
 
-      *
 
-      * @param int    $app_id
 
-      * @param string $page
 
-      *
 
-      * @return mixed
 
-      */
 
-     public function getLists($app_id = 0, $page = '') {
 
-         $_map = [];
 
-         if (!empty($app_id)) {
 
-             $_map['app_id'] = $app_id;
 
-         }
 
-         $_model = new GamePaySwitchModel();
 
-         $_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'] = '';
 
-                 $_data['pay_switch_text'] = '';
 
-                 if (!empty($_v['game'])) {
 
-                     $_data['game_name'] = empty($_v['game']['game_name']) ? '' : $_v['game']['game_name'];
 
-                     $_data['pay_switch_text'] = OrderConst::PAY_SWITCH_YES == $_v['game']['pay_switch'] ? lang('switch')
 
-                         : lang('not_switch');
 
-                 }
 
-                 $_lists[] = $_data;
 
-             }
 
-             $_rdata = [
 
-                 'count' => $_count,
 
-                 'list'  => $_lists
 
-             ];
 
-         }
 
-         return $_rdata;
 
-     }
 
-     /***
 
-      * 添加切换规则
 
-      *
 
-      * @param $param
 
-      *
 
-      * @return false|int
 
-      */
 
-     public function addPaySwitch($param) {
 
-         $_rs = (new GamePaySwitchModel())->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 GamePaySwitchModel())->field($_field)->where($_map)->find();
 
-         if (is_object($_rdata)) {
 
-             $_rdata = $_rdata->toArray();
 
-         }
 
-         return $_rdata;
 
-     }
 
-     /**
 
-      * 更新规则信息
 
-      *
 
-      * @param $param
 
-      * @param $app_id
 
-      *
 
-      * @return GamePaySwitchModel
 
-      */
 
-     public function updatePaySwitch($param, $app_id) {
 
-         $_map['app_id'] = $app_id;
 
-         $_rs = (new GamePaySwitchModel())->update($param, $_map, true);
 
-         return $_rs;
 
-     }
 
-     /***
 
-      * 查找切换规则是否已存在
 
-      *
 
-      * @param $app_id
 
-      *
 
-      * @return bool
 
-      */
 
-     public function checkGame($app_id) {
 
-         $_info = GamePaySwitchCache::ins()->getInfoByAppId($app_id);
 
-         if (empty($_info)) {
 
-             return false;
 
-         }
 
-         return true;
 
-     }
 
-     /**
 
-      * 获取IP白名单个数
 
-      *
 
-      * @return int
 
-      */
 
-     public function getIpWhiteCnt() {
 
-         $_map['pay_switch'] = OrderConst::PAY_SWITCH_YES;
 
-         return (new IpBanModel())->getCnt($_map);
 
-     }
 
-     /**
 
-      * 获取IP黑名单个数
 
-      *
 
-      * @return int
 
-      */
 
-     public function getIpBlackCnt() {
 
-         $_map['pay_switch'] = OrderConst::PAY_SWITCH_NO;
 
-         return (new IpBanModel())->getCnt($_map);
 
-     }
 
-     /**
 
-      * 获取玩家白名单个数
 
-      *
 
-      * @return int
 
-      */
 
-     public function getMemWhiteCnt() {
 
-         $_map['pay_switch'] = OrderConst::PAY_SWITCH_YES;
 
-         return (new MemberModel())->getCnt($_map);
 
-     }
 
-     /**
 
-      * 获取玩家黑名单个数
 
-      *
 
-      * @return int
 
-      */
 
-     public function getMemBlackCnt() {
 
-         $_map['pay_switch'] = OrderConst::PAY_SWITCH_NO;
 
-         return (new MemberModel())->getCnt($_map);
 
-     }
 
-     /**
 
-      * 获取IP切换状态
 
-      *
 
-      * @param string $ip IP地址
 
-      *
 
-      * @return int PAY_SWITCH_YES 1  切换  PAY_SWITCH_NO 2 不切换 PAY_SWITCH_NO_FOREVER 3 永不切换
 
-      */
 
-     public function getPaySwitchByIp($ip) {
 
-         if (empty($ip)) {
 
-             return OrderConst::PAY_SWITCH_NO;
 
-         }
 
-         return (new IpBanModel())->getPaySwitch($ip);
 
-     }
 
- }
 
 
  |