| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515 | 
							- <?php
 
- /**
 
-  * GameController.php  UTF-8
 
-  * 游戏管理
 
-  *
 
-  * @date    : 2020/9/14 15:02
 
-  *
 
-  * @license 这不是一个自由软件,未经授权不许任何使用和传播。
 
-  * @author  : chenbingling <cbl@huosdk.com>
 
-  * @version : H5IOS 1.0
 
-  */
 
- namespace huosdk\h5ios\admin\controller;
 
- use cmf\view\Filter;
 
- use huolib\status\CommonStatus;
 
- use huolib\tool\Page;
 
- use huosdk\h5ios\admin\validate\GameValidate;
 
- use huosdk\h5ios\core\constant\CommonConst;
 
- use huosdk\h5ios\core\constant\GameConst;
 
- use huosdk\h5ios\core\constant\OrderConst;
 
- use huosdk\h5ios\core\logic\GameLogic;
 
- use huosdk\h5ios\core\logic\GamePriceLogic;
 
- use huosdk\h5ios\core\model\CpModel;
 
- use huosdk\h5ios\core\model\GameModel;
 
- use huosdk\h5ios\core\model\GamePriceModel;
 
- use huosdk\h5ios\core\model\GameversionModel;
 
- use menu\controller\Menu;
 
- class GameController extends CommonController {
 
-     protected $classify            = GameConst::GAME_IOS_SWITCH_H5;
 
-     protected $model_class_name    = GameModel::class;
 
-     protected $logic_class_name    = GameLogic::class;
 
-     protected $validate_class_name = GameValidate::class;
 
-     protected $is_delete           = CommonConst::CONST_NOT_DELETE;
 
-     protected $class_name          = 'game';
 
-     protected $order               = '+id';
 
-     protected $app_ids             = [];
 
-     function _initialize() {
 
-         $_url = $this->base_url.$this->class_name;
 
-         $_game_price_url = $_url.'/gamePrice';
 
-         $this->assign('game_price_url', $_game_price_url);
 
-         $_param_url = $_url.'/param';
 
-         $this->assign('param_url', $_param_url);
 
-         $_edit_field_url = $_url.'/editField';
 
-         $this->assign('edit_field_url', $_edit_field_url);
 
-         $_edit_cp_url = $_url.'/cp';
 
-         $this->assign('edit_cp_url', $_edit_cp_url);
 
-         $_set_status_url = $_url.'/setStatus';
 
-         $this->assign('set_status_url', $_set_status_url);
 
-         parent::_initialize();
 
-     }
 
-     /**
 
-      *  安卓游戏列表
 
-      * adminh5ios/game/index
 
-      *
 
-      * @param string $template
 
-      *
 
-      * @return mixed
 
-      */
 
-     public function index($template = 'index') {
 
-         return parent::index('game/index');
 
-     }
 
-     /**
 
-      * 添加
 
-      * adminh5ios/game/add
 
-      *
 
-      * @param string $template 模板文件
 
-      *
 
-      * @return mixed
 
-      */
 
-     public function add($template = 'add') {
 
-         $this->_cps();
 
-         $this->_games(
 
-             0, 0, CommonConst::CONST_NOT_DELETE, GameConst::GAME_IS_SDK, GameConst::GAME_H5
 
-         );
 
-         return parent::add('game/add');
 
-     }
 
-     /**
 
-      * 添加操作函数
 
-      * adminh5ios/game/addPost
 
-      */
 
-     public function addPost() {
 
-         if ($this->request->isPost()) {
 
-             /* 校验参数 */
 
-             $_param = $this->request->param();
 
-             /*校验参数*/
 
-             $_validate = new $this->validate_class_name('add');
 
-             if (!$_validate->check($_param)) {
 
-                 $this->adminError($_validate->getError());
 
-             }
 
-             /* 逻辑处理 */
 
-             /* 转换 传入的H5游戏id */
 
-             $_param['parent_id'] = get_val($_param, 'app_id', 0);
 
-             $_param['classify'] = $this->classify;
 
-             unset($_param['app_id']);
 
-             $_rs = (new $this->model_class_name())->addData($_param);
 
-             if (false === $_rs) {
 
-                 return $this->adminError(lang('ADD_FAILED'));
 
-             }
 
-             return $this->adminSuccess(lang('ADD_SUCCESS'));
 
-         } else {
 
-             $_code = CommonStatus::INVALID_PARAMS;
 
-             return $this->adminError(CommonStatus::getMsg($_code));
 
-         }
 
-     }
 
-     /**
 
-      * 添加操作函数
 
-      * adminh5ios/game/edit
 
-      *
 
-      * @param string $template 模板文件
 
-      *
 
-      * @return mixed
 
-      */
 
-     public function edit($template = 'edit') {
 
-         return parent::edit($template);
 
-     }
 
-     /**
 
-      * 编辑操作函数
 
-      * adminh5ios/game/editPost
 
-      */
 
-     public function editPost() {
 
-         return parent::editPost();
 
-     }
 
-     /**
 
-      * 删除
 
-      * adminh5ios/game/delete
 
-      */
 
-     public function delete() {
 
-         return parent::delete();
 
-     }
 
-     /**
 
-      * 排序 排序字段为list_orders数组 POST 排序字段为:list_order
 
-      * adminh5ios/game/listOrders
 
-      *
 
-      * @param        $model
 
-      * @param string $field
 
-      */
 
-     public function listOrders($model = null, $field = 'list_order') {
 
-         parent::listOrders($model, $field);
 
-     }
 
-     /**
 
-      * 单个设置状态
 
-      * adminh5ios/game/setStatus
 
-      */
 
-     public function setStatus() {
 
-         parent::setStatus();
 
-     }
 
-     /**
 
-      * 编辑字段值
 
-      * adminh5ios/game/editField
 
-      */
 
-     public function editField() {
 
-         $_field = $this->request->param('field/s', '');
 
-         $_app_id = $this->request->param('id/d', 0);
 
-         if (empty($_field) || empty($_app_id)) {
 
-             $_code = CommonStatus::INVALID_PARAMS;
 
-             return $this->adminError(CommonStatus::getMsg($_code));
 
-         }
 
-         $_data = (new GameModel())->getInfoById($_app_id);
 
-         $this->assign('data', $_data);
 
-         $this->assign('field', $_field);
 
-         if ('parent_id' == $_field) {
 
-             $this->_games(
 
-                 $_data['parent_id'], 0, CommonConst::CONST_NOT_DELETE, GameConst::GAME_IS_SDK, GameConst::GAME_H5
 
-             );
 
-         }
 
-         return $this->fetch('game/edit_field');
 
-     }
 
-     /**
 
-      * 编辑字段值提交
 
-      * adminh5ios/game/editFieldPost
 
-      */
 
-     public function editFieldPost() {
 
-         if ($this->request->isPost()) {
 
-             /* 校验参数 */
 
-             $_param = $this->request->param();
 
-             $_field = $this->request->param('field/s', '');
 
-             switch ($_field) {
 
-                 case 'apple_id':
 
-                     $_scene = 'editAppleId';
 
-                     break;
 
-                 case 'name':
 
-                     $_scene = 'editName';
 
-                     break;
 
-                 case 'cp_payback_url':
 
-                     $_scene = 'editCpPaybackUrl';
 
-                     break;
 
-                 case 'parent_id':
 
-                     $_scene = 'link_h5_game';
 
-                     $_param['parent_id'] = $this->request->param('app_id/d', 0);
 
-                     unset($_param['app_id']);
 
-                     break;
 
-                 default:
 
-                     $_code = CommonStatus::INVALID_PARAMS;
 
-                     return $this->adminError(CommonStatus::getMsg($_code));
 
-             }
 
-             /*校验参数*/
 
-             $_validate = new GameValidate($_scene);
 
-             if (!$_validate->check($_param)) {
 
-                 return $this->adminError($_validate->getError());
 
-             }
 
-             unset($_param['field']);
 
-             /* 逻辑处理 */
 
-             $_rs = (new GameModel())->updateData($_param, $_param['id']);
 
-             if (false === $_rs) {
 
-                 return $this->adminError(lang('EDIT_FAILED'));
 
-             }
 
-             return $this->adminSuccess(lang('EDIT_SUCCESS'));
 
-         } else {
 
-             $_code = CommonStatus::INVALID_PARAMS;
 
-             return $this->adminError(CommonStatus::getMsg($_code));
 
-         }
 
-     }
 
-     /**
 
-      * 编辑CP处理
 
-      * adminh5ios/game/cp
 
-      */
 
-     public function cp() {
 
-         $_app_id = $this->request->param('id/d', 0);
 
-         if (empty($_app_id)) {
 
-             $_code = CommonStatus::INVALID_PARAMS;
 
-             return $this->adminError(CommonStatus::getMsg($_code));
 
-         }
 
-         $_data = (new GameModel())->getInfoById($_app_id);
 
-         $this->assign('data', $_data);
 
-         $this->_cps($_data['cp_id']);
 
-         return $this->fetch('game/cp');
 
-     }
 
-     /**
 
-      * 编辑CP提交
 
-      * adminh5ios/game/cpPost
 
-      */
 
-     public function cpPost() {
 
-         if ($this->request->isPost()) {
 
-             /* 校验参数 */
 
-             $_param = $this->request->param();
 
-             /*校验参数*/
 
-             $_validate = new GameValidate('cp');
 
-             if (!$_validate->check($_param)) {
 
-                 return $this->adminError($_validate->getError());
 
-             }
 
-             /* 逻辑处理 */
 
-             $_data['cp_id'] = $_param['cp_id'];
 
-             $_rs = (new GameModel())->updateData($_data, $_param['id']);
 
-             if (false === $_rs) {
 
-                 return $this->adminError(lang('EDIT_FAILED'));
 
-             }
 
-             return $this->adminSuccess(lang('EDIT_SUCCESS'));
 
-         } else {
 
-             $_code = CommonStatus::INVALID_PARAMS;
 
-             return $this->adminError(CommonStatus::getMsg($_code));
 
-         }
 
-     }
 
-     /**
 
-      * 获取对接参数
 
-      * adminh5ios/game/param
 
-      */
 
-     public function param() {
 
-         $_app_id = $this->request->param('id/d', 0);
 
-         if (empty($_app_id)) {
 
-             $this->adminError(lang('PARAM_ERROR'));
 
-         }
 
-         $_game_data = (new $this->model_class_name())->getInfoById($_app_id);
 
-         $_gv_data = (new GameversionModel())->getDefaultInfoByAppId($_app_id);
 
-         $this->assign('game', $_game_data);
 
-         $this->assign('gv', $_gv_data);
 
-         return $this->fetch('game/param');
 
-     }
 
-     /**
 
-      * 计费点设置列表
 
-      * adminh5ios/game/gamePrice
 
-      */
 
-     public function gamePrice() {
 
-         $_app_id = $this->request->param('id/d', 0);
 
-         if (empty($_app_id)) {
 
-             $_code = CommonStatus::INVALID_PARAMS;
 
-             $this->adminError(CommonStatus::getMsg($_code));
 
-         }
 
-         $_game_data = (new GameModel())->getInfoById($_app_id);
 
-         $this->assign('game', $_game_data);
 
-         $_map['app_id'] = $_app_id;
 
-         $_data = (new GamePriceLogic())->getAdminList($_map, '1,'.CommonConst::CONST_MAX_INT);
 
-         $_items = (new Page())->paginate($_data['count'], $_data['list'], 1, CommonConst::CONST_MAX_INT);
 
-         $this->assign('page', $_items->render());
 
-         $this->assign('items', $_items->items());
 
-         $this->assign('app_id', $_app_id);
 
-         $this->assign('new_frame', 0);
 
-         return $this->fetch('game/game_price');
 
-     }
 
-     /**
 
-      * 计费点编辑
 
-      * adminh5ios/game/gamePricePost
 
-      */
 
-     public function gamePricePost() {
 
-         if ($this->request->isPost()) {
 
-             $_param = $this->request->param();
 
-             if (empty($_param['app_id'])
 
-                 || empty($_param['product_name'])
 
-                 || empty($_param['product_code'])
 
-                 || empty($_param['ch_product_code'])
 
-                 || empty($_param['product_price'])) {
 
-                 $_code = CommonStatus::INVALID_PARAMS;
 
-                 $this->adminError(CommonStatus::getMsg($_code));
 
-             }
 
-             $_data = [];
 
-             foreach ($_param['product_code'] as $_k => $_v) {
 
-                 if (empty($_v) || empty($_param['product_price'][$_k]) || empty($_param['product_name'][$_k])) {
 
-                     continue;
 
-                 }
 
-                 $_data[] = [
 
-                     'app_id'          => $_param['app_id'],
 
-                     'product_code'    => $_v,
 
-                     'ch_product_code' => $_param['ch_product_code'][$_k],
 
-                     'product_price'   => $_param['product_price'][$_k],
 
-                     'product_name'    => $_param['product_name'][$_k],
 
-                 ];
 
-             }
 
-             if (empty($_data)) {
 
-                 $_code = CommonStatus::INVALID_PARAMS;
 
-                 $this->adminError(CommonStatus::getMsg($_code));
 
-             }
 
-             /* 先删除原有计费点 */
 
-             $_gp_model = new GamePriceModel();
 
-             $_rs = $_gp_model->deleteDataByAppId($_param['app_id']);
 
-             if (true == $_rs) {
 
-                 $_rs = (new GamePriceModel())->addDatas($_data);
 
-             }
 
-             if (false === $_rs) {
 
-                 $this->adminError(lang('ADD_FAILED'));
 
-             }
 
-             return $this->adminSuccess(lang('EDIT_SUCCESS'));
 
-         } else {
 
-             return $this->adminError(lang('PARAM_ERROR'));
 
-         }
 
-     }
 
-     /**
 
-      * 搜索参数
 
-      * return array
 
-      */
 
-     protected function getSearchParam() {
 
-         $_param = parent::getSearchParam();
 
-         $_param['is_delete'] = $this->is_delete;
 
-         /* 游戏搜索 */
 
-         $_param['id'] = $this->request->param('app_id/d', 0);
 
-         $this->_games(
 
-             $_param['id'],
 
-             0,
 
-             $this->is_delete,
 
-             0,
 
-             $this->classify,
 
-             false,
 
-             true
 
-         );
 
-         /* 游戏状态搜索 */
 
-         $_param['status'] = $this->request->param('status/d', 0);
 
-         $this->_gameStatus();
 
-         /* CP搜索 */
 
-         $_param['cp_id'] = $this->request->param('cp_id/d', 0);
 
-         $this->_cps($_param['cp_id']);
 
-         /* 支付切换搜索 */
 
-         $_param['pay_switch'] = $this->request->param('pay_switch/d', 0);
 
-         $this->_paySwitch($_param['pay_switch']);
 
-         /* 支付切换搜索 */
 
-         $_param['classify'] = $this->request->param('classify/d', $this->classify);
 
-         $this->_gameClassifies($_param['classify']);
 
-         return $_param;
 
-     }
 
-     /**
 
-      * 游戏状态
 
-      */
 
-     protected function _gameStatus() {
 
-         $_game_status = [
 
-             GameConst::GAME_STATUS_ACCESS => lang('GAME_STATUS_ACCESS'),
 
-             GameConst::GAME_STATUS_ON     => lang('GAME_STATUS_ON'),
 
-             GameConst::GAME_STATUS_OFF    => lang('GAME_STATUS_OFF'),
 
-         ];
 
-         $_game_status_select = Filter::selectCommon($_game_status, 'status', $this->request->get('status/d', 0));
 
-         $this->assign('game_status', $_game_status);
 
-         $this->assign('game_status_select', $_game_status_select);
 
-         return $_game_status;
 
-     }
 
-     /**
 
-      * 关联公司名称
 
-      *
 
-      * @param int $cp_id
 
-      *
 
-      * @return array
 
-      */
 
-     protected function _cps($cp_id = 0) {
 
-         $_cps = (new CpModel())->getIdNames();
 
-         $_cps_select = Filter::selectCommon($_cps, 'cp_id', $cp_id);
 
-         $this->assign('cps_select', $_cps_select);
 
-         $this->assign('cps', $_cps);
 
-         return $_cps;
 
-     }
 
-     /**
 
-      * 支付切换选择
 
-      *
 
-      * @param int $pay_switch 默认
 
-      *
 
-      * @return array
 
-      */
 
-     protected function _paySwitch($pay_switch = 0) {
 
-         $_pay_switch_arr = [
 
-             OrderConst::PAY_SWITCH_YES => lang('PAY_SWITCH_YES'),
 
-             OrderConst::PAY_SWITCH_NO  => lang('PAY_SWITCH_NO')
 
-         ];
 
-         $this->assign('pay_switch', $_pay_switch_arr);
 
-         $_is_pay_switch = Filter::radioCommon($_pay_switch_arr, 'pay_switch', $pay_switch);
 
-         $this->assign('is_pay_switch_radio', $_is_pay_switch);
 
-         $_pay_switch_select = Filter::selectCommon($_pay_switch_arr, 'pay_switch', $pay_switch);
 
-         $this->assign('pay_switch_select', $_pay_switch_select);
 
-         return $_pay_switch_arr;
 
-     }
 
-     /**
 
-      * 添加菜单
 
-      * adminh5ios/game/addMenu
 
-      *
 
-      * @param int $parent_id
 
-      * @param int $list_order
 
-      *
 
-      * @return int
 
-      */
 
-     public function addMenu($parent_id = 0, $list_order = 0) {
 
-         $_controller = 'game';/* 控制器名 */
 
-         $_name = 'IOS马甲'; /* 菜单名称 */
 
-         $_en_name = 'Ios Vb'; /* 菜单英文名称 */
 
-         $_icon = 'apple'; /* 菜单图标 */
 
-         $_app = $this->app; /* 应用名 */
 
-         $_menu_class = new Menu();
 
-         $_menu_class->setApp($_app);
 
-         /* 删除原有菜单 */
 
-         $_menu_class->deleteMenu($_controller, $_app);
 
-         /* 添加菜单入口 */
 
-         $_manage_id = $_menu_class->addManage($_controller, $parent_id, $list_order, $_name, $_en_name, $_icon);
 
-         /* 默认菜单 */
 
-         $_index_id = $_menu_class->addDefaultMenu($_controller, $_manage_id, 1000, $_name, $_en_name, $_icon, 1, 1);
 
-         {
 
-             /* 修改字段 */
 
-             $_menu_class->addTop(
 
-                 $_controller, $_index_id, 900, '修改字段', 'editField', '', 'editField', '', 1, 0
 
-             );
 
-             /* 修改字段提交 */
 
-             $_menu_class->addTop(
 
-                 $_controller, $_index_id, 900, '修改字段提交', 'editFieldPost', '', 'editFieldPost', '', 1, 0
 
-             );
 
-             /* 修改CP */
 
-             $_menu_class->addTop(
 
-                 $_controller, $_index_id, 800, '修改CP', 'cp', '', 'cp', '', 1, 0
 
-             );
 
-             /* 修改字段提交 */
 
-             $_menu_class->addTop(
 
-                 $_controller, $_index_id, 800, '修改CP提交', 'cpPost', '', 'cpPost', '', 1, 0
 
-             );
 
-             /* 获取对接参数 */
 
-             $_menu_class->addTop(
 
-                 $_controller, $_index_id, 700, '获取对接参数', 'Get Param', '', 'param', '', 1, 0
 
-             );
 
-             /* 计费点 */
 
-             $_menu_class->addTop(
 
-                 $_controller, $_index_id, 600, '计费点', 'gamePrice', '', 'gamePrice', '', 1, 0
 
-             );
 
-             /* 计费点提交 */
 
-             $_menu_class->addTop(
 
-                 $_controller, $_index_id, 600, '计费点提交', 'gamePricePost', '', 'gamePricePost', '', 1, 0
 
-             );
 
-         }
 
-         (new PaySwitchController())->addMenu($_index_id, 500);
 
-         /* 语言包 */
 
-         (new \admin\admin\controller\MenuController())->exportMenuLang();
 
-         return $_manage_id;
 
-     }
 
- }
 
 
  |