From 096e32d5814eff543d46b719a6d64c4a712644ce Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Sat, 18 Jul 2020 17:59:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E6=88=B7=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PaymentMerchantController.class.php | 524 ++++++++++++++++++ .../PromoteLimitRuleController.class.php | 9 +- .../View/PaymentMerchant/defaultForm.html | 160 ++++++ .../Admin/View/PaymentMerchant/form.html | 516 +++++++++++++++++ .../Admin/View/PaymentMerchant/list.html | 384 +++++++++++++ .../View/PaymentMerchant/ruleAddForm.html | 508 +++++++++++++++++ .../View/PaymentMerchant/ruleEditForm.html | 328 +++++++++++ .../Admin/View/PaymentMerchant/rules.html | 332 +++++++++++ .../Base/Service/GameService.class.php | 73 +++ .../Service/PaymentMerchantService.class.php | 112 ++++ .../Base/Service/PaymentRuleService.class.php | 39 ++ .../Service/PromoteCompanyService.class.php | 53 ++ Data/update.sql | 56 ++ 13 files changed, 3088 insertions(+), 6 deletions(-) create mode 100644 Application/Admin/Controller/PaymentMerchantController.class.php create mode 100644 Application/Admin/View/PaymentMerchant/defaultForm.html create mode 100644 Application/Admin/View/PaymentMerchant/form.html create mode 100644 Application/Admin/View/PaymentMerchant/list.html create mode 100644 Application/Admin/View/PaymentMerchant/ruleAddForm.html create mode 100644 Application/Admin/View/PaymentMerchant/ruleEditForm.html create mode 100644 Application/Admin/View/PaymentMerchant/rules.html create mode 100644 Application/Base/Service/PaymentMerchantService.class.php create mode 100644 Application/Base/Service/PaymentRuleService.class.php create mode 100644 Application/Base/Service/PromoteCompanyService.class.php diff --git a/Application/Admin/Controller/PaymentMerchantController.class.php b/Application/Admin/Controller/PaymentMerchantController.class.php new file mode 100644 index 000000000..7118e5268 --- /dev/null +++ b/Application/Admin/Controller/PaymentMerchantController.class.php @@ -0,0 +1,524 @@ +where($conditions); + $countQuery = clone $query; + + $items = $query->order('id desc')->page($page, $row)->select(); + $count = $countQuery->count(); + + $admins = M('ucenter_member', 'sys_')->field(['id', 'username'])->select(); + $admins = index_by_column('id', $admins); + + $records = []; + foreach ($items as $item) { + $records[] = [ + 'id' => $item['id'], + 'name' => $item['name'], + 'main_name' => $item['main_name'], + 'account' => $item['account'], + 'status' => $item['status'], + 'channel' => $item['channel'], + 'wayNames' => implode('、', $paymentMerchantService->getWaysName($item['ways'])), + 'status_text' => $paymentMerchantService->getStatusText($item['status']), + 'channel_text' => $paymentMerchantService->getChannelText($item['channel']), + 'admin_username' => $admins[$item['admin_id']]['username'], + 'update_time' => date('Y-m-d H:i:s', $item['update_time']), + ]; + } + + + $page = set_pagination($count, $row); + if($page) { + $this->assign('_page', $page); + } + + $aliDefaultMerchant = $paymentMerchantService->getDefault(PaymentMerchantService::WAY_ALIPAY); + $weixinDefaultMerchant = $paymentMerchantService->getDefault(PaymentMerchantService::WAY_WEIXIN); + $expressDefaultMerchant = $paymentMerchantService->getDefault(PaymentMerchantService::WAY_EXPRESS); + $this->assign('aliDefaultMerchant', $aliDefaultMerchant); + $this->assign('weixinDefaultMerchant', $weixinDefaultMerchant); + $this->assign('expressDefaultMerchant', $expressDefaultMerchant); + $this->assign('records', $records); + $this->assign('admins', $admins); + $this->assign('ways', PaymentMerchantService::$ways); + $this->assign('statusList', PaymentMerchantService::$statusList); + $this->assign('channels', PaymentMerchantService::$channels); + $this->display(); + } + + public function add() + { + $this->meta_title = '添加商户'; + $this->assign('channels', PaymentMerchantService::$channels); + $this->display('form'); + } + + public function changeStatus() + { + $id = I('id', 0); + $status = I('status', 0); + $merchant = M('payment_merchant', 'tab_')->where(['id' => $id])->find(); + if (is_null($merchant)) { + $this->ajaxReturn([ + 'status' => 0, + 'message' => '记录不存在', + ]); + } + if (!in_array($status, [0, 1])) { + $this->ajaxReturn([ + 'status' => 0, + 'message' => '状态值错误', + ]); + } + $statusText = $status == 0 ? '禁用' : '启用'; + M('payment_merchant', 'tab_')->where(['id' => $id])->save(['status' => $status]); + $this->ajaxReturn([ + 'status' => 1, + 'message' => $statusText . '成功', + ]); + } + + public function edit() + { + $this->meta_title = '编辑商户'; + $id = I('id', 0); + $merchant = M('payment_merchant', 'tab_')->where(['id' => $id])->find(); + if ($merchant == null) { + $this->error('支付商户不存在'); + } + $paymentMerchantService = new PaymentMerchantService(); + $config = $merchant['config'] ? json_decode($merchant['config'], true) : null; + $ways = $paymentMerchantService->getWaysRow($merchant['ways']); + $this->assign('channels', PaymentMerchantService::$channels); + $this->assign('record', $merchant); + $this->assign('config', $config); + $this->assign('ways', $ways); + $this->display('form'); + } + + public function save() + { + $id = I('id', 0); + $name = I('name', ''); + $identifier = I('identifier', ''); + $channel = I('channel', 0); + $status = I('status', 0); + $account = I('account', ''); + $config = I('config', []); + $ways = I('ways', []); + $mainName = I('main_name', ''); + + if ($name == '') { + $this->ajaxReturn([ + 'status' => 0, + 'message' => '请输入商户名称', + ]); + } + if ($mainName == '') { + $this->ajaxReturn([ + 'status' => 0, + 'message' => '请输入商户商户主体', + ]); + } + if ($account == '') { + $this->ajaxReturn([ + 'status' => 0, + 'message' => '请输入商户账号', + ]); + } + + $merchant = null; + if ($id > 0) { + $merchant = M('payment_merchant', 'tab_')->where(['id' => $id])->find(); + if ($merchant == null) { + $this->ajaxReturn([ + 'status' => 0, + 'message' => '支付商户不存在', + ]); + } + } + $paymentMerchantService = new PaymentMerchantService(); + $waysValue = $paymentMerchantService->getWaysValue($ways); + + $userAuth = session('user_auth'); + + $data = []; + $data['name'] = $name; + $data['account'] = $account; + $data['identifier'] = $identifier; + $data['type'] = 1; + $data['status'] = $status; + $data['ways'] = $waysValue; + $data['admin_id'] = $userAuth['uid']; + $data['config'] = json_encode($config); + $data['update_time'] = time(); + $data['main_name'] = $mainName; + if ($id == 0) { + $data['create_time'] = time(); + $data['channel'] = $channel; + M('payment_merchant', 'tab_')->add($data); + } else { + M('payment_merchant', 'tab_')->where(['id' => $id])->save($data); + } + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '保存成功' + ]); + } + + + + public function delete() + { + $id = I('id', 0); + M('payment_merchant', 'tab_')->where(['id' => $id])->delete(); + + addOperationLog([ + 'op_type' => 2, + 'key' => $id, + 'op_name' => '删除商户渠道', + 'url' => U('Market/delete', ['id' => $id]), + 'menu' => '推广员-推广员管理-市场换绑-删除商户渠道' + ]); + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '删除成功' + ]); + } + + public function editDefault() + { + $paymentMerchantService = new PaymentMerchantService(); + $aliMerchants = $paymentMerchantService->getMerchantsByWay(PaymentMerchantService::WAY_ALIPAY); + $weixinMerchants = $paymentMerchantService->getMerchantsByWay(PaymentMerchantService::WAY_WEIXIN); + $expressMerchants = $paymentMerchantService->getMerchantsByWay(PaymentMerchantService::WAY_EXPRESS); + $aliDefaultMerchant = $paymentMerchantService->getDefault(PaymentMerchantService::WAY_ALIPAY); + $weixinDefaultMerchant = $paymentMerchantService->getDefault(PaymentMerchantService::WAY_WEIXIN); + $expressDefaultMerchant = $paymentMerchantService->getDefault(PaymentMerchantService::WAY_EXPRESS); + + $this->assign('aliDefaultMerchant', $aliDefaultMerchant); + $this->assign('weixinDefaultMerchant', $weixinDefaultMerchant); + $this->assign('expressDefaultMerchant', $expressDefaultMerchant); + $this->assign('aliMerchants', $aliMerchants); + $this->assign('weixinMerchants', $weixinMerchants); + $this->assign('expressMerchants', $expressMerchants); + $this->display('defaultForm'); + } + + public function saveDefault() + { + $setting = I('setting', []); + + $paymentMerchantService = new PaymentMerchantService(); + + $model = new Model(); + $model->startTrans(); + + try { + foreach ($setting as $key => $value) { + if ($key == 'alipay') { + $paymentMerchantService->setDefault(PaymentMerchantService::WAY_ALIPAY, $value); + } elseif ($key == 'weixin') { + $paymentMerchantService->setDefault(PaymentMerchantService::WAY_WEIXIN, $value); + } elseif ($key == 'express') { + $paymentMerchantService->setDefault(PaymentMerchantService::WAY_EXPRESS, $value); + } + } + $model->commit(); + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '设置成功' + ]); + } catch (\Exception $e) { + $model->rollback(); + + $this->ajaxReturn([ + 'status' => 0, + 'message' => '设置失败,请联系管理员' + ]); + } + } + + public function rules() + { + $page = I('p', 1); + $row = I('row', 10); + $companyBelong = I('compnay_belong', -1); + $companyId = I('company_id', 0); + $gameTypeId = I('game_type_id', 0); + $gameId = I('game_id', 0); + $startedAt = I('started_at', ''); + $endedAt = I('ended_at', ''); + $alipayId = I('alipay_merchant_id', 0); + $weixinId = I('weixin_merchant_id', 0); + $expressId = I('express_merchant_id', 0); + + $conditions = []; + if ($companyBelong != -1) { + $conditions['company_belong'] = $companyBelong; + } + if ($companyId != 0) { + $conditions['company_id'] = $companyId; + } + if ($gameTypeId != 0) { + $conditions['game_type_id'] = $gameTypeId; + } + if ($gameId != 0) { + $conditions['game_id'] = $gameId; + } + if ($alipayId != 0) { + $conditions['alipay_merchant_id'] = $alipayId; + } + if ($weixinId != 0) { + $conditions['weixin_merchant_id'] = $weixinId; + } + if ($expressId != 0) { + $conditions['express_merchant_id'] = $expressId; + } + if ($startedAt != '') { + $conditions['update_time'] = ['egt', strtotime($startedAt . ' 00:00:00')]; + } + if ($endedAt != '') { + $conditions['update_time'] = ['elt', strtotime($endedAt . ' 23:59:59')]; + } + + $paymentRuleService = new PaymentRuleService(); + $gameService = new GameService(); + $paymentMerchantService = new PaymentMerchantService(); + $companyService = new PromoteCompanyService(); + + $query = M('payment_rule', 'tab_')->where($conditions); + $countQuery = clone $query; + + $items = $query->order('id desc')->page($page, $row)->select(); + $count = $countQuery->count(); + + $gameTypes = $gameService->getGameTypes(null, 'id,type_name'); + $games = $gameService->getBaseGames(null, 'id,name'); + $companies = $companyService->getCompanies(null, 'id,company_name'); + $companyTypes = PromoteCompanyService::$belongs; + $merchantIds = array_merge( + array_column($items, 'alipay_merchant_id'), + array_column($items, 'weixin_merchant_id'), + array_column($items, 'express_merchant_id') + ); + $merchants = $paymentMerchantService->getMerchantsByIds($merchantIds, 'id,channel,name,account'); + + $records = []; + foreach ($items as $item) { + $records[] = [ + 'id' => $item['id'], + 'company_type_name' => $companyTypes[$item['company_belong']] ?? '无', + 'company_name' => isset($companies[$item['company_id']]) ? $companies[$item['company_id']]['company_name'] : '--', + 'game_name' => isset($games[$item['game_id']]) ? $games[$item['game_id']]['name'] : '--', + 'game_type_name' => isset($gameTypes[$item['game_type_id']]) ? $gameTypes[$item['game_type_id']]['type_name'] : '--', + 'alipay_merchant_name' => isset($merchants[$item['alipay_merchant_id']]) ? $merchants[$item['alipay_merchant_id']]['name'] : '系统默认商户', + 'alipay_merchant_account' => isset($merchants[$item['alipay_merchant_id']]) ? $merchants[$item['alipay_merchant_id']]['account'] : '系统默认商户', + 'weixin_merchant_name' => isset($merchants[$item['weixin_merchant_id']]) ? $merchants[$item['weixin_merchant_id']]['name'] : '系统默认商户', + 'weixin_merchant_account' => isset($merchants[$item['weixin_merchant_id']]) ? $merchants[$item['weixin_merchant_id']]['account'] : '系统默认商户', + 'express_merchant_name' => isset($merchants[$item['express_merchant_id']]) ? $merchants[$item['express_merchant_id']]['name'] : '系统默认商户', + 'express_merchant_account' => isset($merchants[$item['express_merchant_id']]) ? $merchants[$item['express_merchant_id']]['account'] : '系统默认商户', + 'effective_time_display' => $paymentRuleService->getEffectiveTimeDisplay($item) + ]; + } + // var_dump($records);die(); + + $page = set_pagination($count, $row); + if($page) { + $this->assign('_page', $page); + } + + $aliMerchants = $paymentMerchantService->getMerchantsByWay(PaymentMerchantService::WAY_ALIPAY); + $weixinMerchants = $paymentMerchantService->getMerchantsByWay(PaymentMerchantService::WAY_WEIXIN); + $expressMerchants = $paymentMerchantService->getMerchantsByWay(PaymentMerchantService::WAY_EXPRESS); + + $this->assign('aliMerchants', $aliMerchants); + $this->assign('weixinMerchants', $weixinMerchants); + $this->assign('expressMerchants', $expressMerchants); + + $this->assign('records', $records); + $this->assign('games', $games); + $this->assign('gameTypes', $gameTypes); + $this->assign('companyTypes', $companyTypes); + $this->assign('companies', $companies); + $this->display(); + } + + public function addRule() + { + $gameService = new GameService(); + $gameTypes = $gameService->getGameTypes(null, 'id,type_name'); + $games = $gameService->getBaseGames(null, 'id,name'); + $companyBelongs = PromoteCompanyService::$belongs; + $companyService = new PromoteCompanyService(); + $paymentMerchantService = new PaymentMerchantService(); + $aliMerchants = $paymentMerchantService->getMerchantsByWay(PaymentMerchantService::WAY_ALIPAY); + $weixinMerchants = $paymentMerchantService->getMerchantsByWay(PaymentMerchantService::WAY_WEIXIN); + $expressMerchants = $paymentMerchantService->getMerchantsByWay(PaymentMerchantService::WAY_EXPRESS); + $companies = $companyService->getCompanies(null, 'id,company_name'); + $this->assign('aliMerchants', $aliMerchants); + $this->assign('weixinMerchants', $weixinMerchants); + $this->assign('expressMerchants', $expressMerchants); + $this->assign('games', $games); + $this->assign('gameTypes', $gameTypes); + $this->assign('companyBelongs', $companyBelongs); + $this->assign('companies', $companies); + $this->display('ruleAddForm'); + } + + public function saveRule() + { + $records = I('records', []); + if (count($records) == 0) { + $this->ajaxReturn([ + 'status' => 0, + 'message' => '未提交换绑数据' + ]); + } + + $status = true; + $message = ''; + + if (!$status) { + $this->ajaxReturn([ + 'status' => 0, + 'message' => $message + ]); + } + + foreach ($records as $record) { + $startTime = $record['start_time'] == '' ? 0 : strtotime($record['start_time'] . ' 00:00:00'); + $endTime = $record['end_time'] == '' ? 0 : strtotime($record['end_time'] . ' 23:59:59'); + $item = [ + 'company_belong' => $record['company_id'] > 0 ? -1 : $record['company_belong'], + 'company_id' => $record['company_id'], + 'game_type_id' => $record['game_id'] > 0 ? 0 :$record['game_type_id'], + 'game_id' => $record['game_id'], + 'alipay_merchant_id' => $record['alipay_merchant_id'], + 'weixin_merchant_id' => $record['weixin_merchant_id'], + 'express_merchant_id' => $record['express_merchant_id'], + 'start_time' => $startTime, + 'end_time' => $endTime, + 'create_time' => time(), + 'update_time' => time() + ]; + $id = M('payment_rule', 'tab_')->add($item); + } + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '添加成功' + ]); + } + + public function deleteRule() + { + $id = I('id', 0); + M('payment_rule', 'tab_')->where(['id' => $id])->delete(); + + addOperationLog([ + 'op_type' => 2, + 'key' => $id, + 'op_name' => '删除支付商户配置', + 'url' => U('PaymentMerchant/deleteRule', ['id' => $id]), + 'menu' => '推广员-推广员管理-市场换绑-删除支付商户配置' + ]); + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '删除成功' + ]); + } + + public function getCompaniesByBelong() + { + $belong = I('company_belong', ''); + if ($belong === '') { + $belong = null; + } + $promoteCompanyService = new PromoteCompanyService(); + $companies = $promoteCompanyService->getCompaniesByBelong($belong, 'id,company_name'); + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '获取成功', + 'data' => [ + 'companies' => $companies + ] + ]); + } + + public function getGamesByType() + { + $gameTypeId = I('game_type_id', 0); + $gameService = new GameService(); + $games = $gameService->getBaseGamesByType($gameTypeId, 'id,name'); + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '获取成功', + 'data' => [ + 'games' => $games + ] + ]); + } + + public function checkRules() + { + + } +} diff --git a/Application/Admin/Controller/PromoteLimitRuleController.class.php b/Application/Admin/Controller/PromoteLimitRuleController.class.php index 839704544..8246a553e 100644 --- a/Application/Admin/Controller/PromoteLimitRuleController.class.php +++ b/Application/Admin/Controller/PromoteLimitRuleController.class.php @@ -4,6 +4,7 @@ namespace Admin\Controller; use User\Api\UserApi as UserApi; use Base\Service\PresidentDepositService; +use Base\Service\PromoteCompanyService; /** * 推广限制 @@ -52,12 +53,8 @@ class PromoteLimitRuleController extends ThinkController $recordCompanys = index_by_column('id', $recordCompanys); } - $companyTypes = [ - 0 => '内团', - 1 => '外团', - 2 => '外团-分发联盟', - 3 => '无' - ]; + + $companyTypes = PromoteCompanyService::$belongs; $records = []; foreach ($rules as $rule) { diff --git a/Application/Admin/View/PaymentMerchant/defaultForm.html b/Application/Admin/View/PaymentMerchant/defaultForm.html new file mode 100644 index 000000000..056289ace --- /dev/null +++ b/Application/Admin/View/PaymentMerchant/defaultForm.html @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + + + + + + + + + + + + + + +
*支付宝支付配置: + +
*微信支付配置: + +
*快捷支付配置: + +
+
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/Application/Admin/View/PaymentMerchant/form.html b/Application/Admin/View/PaymentMerchant/form.html new file mode 100644 index 000000000..cec4bfdd8 --- /dev/null +++ b/Application/Admin/View/PaymentMerchant/form.html @@ -0,0 +1,516 @@ + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
*商户名称: + + +
*商户主体: + + +
*商户账号: + + +
*商户号: + + +
*启用状态 + + + + + +
*支付渠道: + + +
+
+
+ +
+ +
+ + + 返回 + +
+
+
+
+ + + + + +
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + \ No newline at end of file diff --git a/Application/Admin/View/PaymentMerchant/list.html b/Application/Admin/View/PaymentMerchant/list.html new file mode 100644 index 000000000..529d8f3e4 --- /dev/null +++ b/Application/Admin/View/PaymentMerchant/list.html @@ -0,0 +1,384 @@ + + + + + + + + + + + + + + + + + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + - +
+ + +
+
+ +
+
+
+
+
+
当前系统默认设置
+
+ 支付宝: +
+
+ 微信: +
+
+ 快捷支付: +
+
+ +
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
商户名称商户主体支付渠道商户账户支持支付方式状态操作管理员操作时间操作
aOh! 暂时还没有内容!
{$data.name}{$data.main_name}{$data.channel_text}{$data.account}{$data.wayNames} + + {$data.status_text} + + {$data.status_text} + + {$data.admin_username}{$data.update_time} +
+ 编辑 + + 启用 + + 禁用 + +
+
+
+
+
+ + + + {$_page|default=''} +
+ + +
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + + + + + + \ No newline at end of file diff --git a/Application/Admin/View/PaymentMerchant/ruleAddForm.html b/Application/Admin/View/PaymentMerchant/ruleAddForm.html new file mode 100644 index 000000000..b92ec54b8 --- /dev/null +++ b/Application/Admin/View/PaymentMerchant/ruleAddForm.html @@ -0,0 +1,508 @@ + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
*公司类型: + +
*推广公司: + +
*游戏类型: + +
*游戏: + +
*支付宝支付配置: + +
*微信支付配置: + +
*快捷支付配置: + +
生效时间(开始): + +
生效时间(结束): + +
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + +
公司类型推广公司游戏类型游戏产品支付宝支付配置微信支付配置快捷支付配置生效时间操作
+
+
+ +
+
+ + + +
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + \ No newline at end of file diff --git a/Application/Admin/View/PaymentMerchant/ruleEditForm.html b/Application/Admin/View/PaymentMerchant/ruleEditForm.html new file mode 100644 index 000000000..4603e9823 --- /dev/null +++ b/Application/Admin/View/PaymentMerchant/ruleEditForm.html @@ -0,0 +1,328 @@ + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
*公司类型: + +
*推广公司: + +
*游戏类型: + +
*游戏: + +
*支付宝支付配置: + +
*微信支付配置: + +
*快捷支付配置: + +
生效时间(开始): + +
生效时间(结束): + +
+
+
+ + + 返回 + +
+
+ +
+
+ + + +
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + \ No newline at end of file diff --git a/Application/Admin/View/PaymentMerchant/rules.html b/Application/Admin/View/PaymentMerchant/rules.html new file mode 100644 index 000000000..f77451cad --- /dev/null +++ b/Application/Admin/View/PaymentMerchant/rules.html @@ -0,0 +1,332 @@ + + + + + + + + + + + + + + + + + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + - +
+ + +
+
+
+
+ +
+
+ +
+
+ +
+ + +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
公司类型推广公司游戏类型游戏产品支付宝支付配置商户账号微信支付配置商户账号快捷支付配置商户账号生效时间操作
aOh! 暂时还没有内容!
{$data.company_type_name}{$data.company_name}{$data.game_type_name}{$data.game_name}{$data.alipay_merchant_name}{$data.alipay_merchant_account}{$data.weixin_merchant_name}{$data.weixin_merchant_account}{$data.express_merchant_name}{$data.express_merchant_account}{$data.effective_time_display} +
+ 编辑 + 删除 +
+
+
+
+
+ + + + {$_page|default=''} +
+ + +
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + + + + + \ No newline at end of file diff --git a/Application/Base/Service/GameService.class.php b/Application/Base/Service/GameService.class.php index 8b67cc552..9ecad566f 100644 --- a/Application/Base/Service/GameService.class.php +++ b/Application/Base/Service/GameService.class.php @@ -46,4 +46,77 @@ class GameService { return M('base_game', 'tab_')->where(['id' => $baseGame['id']])->save($data); } } + + public function getGames(array $ids = null, $fields = '*') + { + $map = []; + if (is_null($ids)) { + $map['_string'] = '1=1'; + } elseif (count($ids) == 0) { + return []; + } else { + $map['id'] = ['in', $ids]; + } + $rules = M('game', 'tab_')->field($fields)->where($map)->select(); + return index_by_column('id', $rules); + } + + public function getGameTypes(array $ids = null, $fields = '*') + { + $map = []; + if (is_null($ids)) { + $map['_string'] = '1=1'; + } elseif (count($ids) == 0) { + return []; + } else { + $map['id'] = ['in', $ids]; + } + $rules = M('game_type', 'tab_')->field($fields)->where($map)->select(); + return index_by_column('id', $rules); + } + + public function getBaseGames(array $ids = null, $fields = '*') + { + $map = []; + if (is_null($ids)) { + $map['_string'] = '1=1'; + } elseif (count($ids) == 0) { + return []; + } else { + $map['id'] = ['in', $ids]; + } + $games = M('base_game', 'tab_')->field($fields)->where($map)->select(); + return index_by_column('id', $games); + } + + public function getGamesByType($gameTypeId, $fields = '*') + { + $map = []; + if ($gameTypeId == 0) { + $map['_string'] = '1=1'; + } else { + $map['game_type_id'] = $gameTypeId; + } + $games = M('game', 'tab_')->field($fields)->where($map)->select(); + return index_by_column('id', $games); + } + + public function getBaseGamesByType($gameTypeId, $fields = '*') + { + $map = []; + if ($gameTypeId == 0) { + $map['_string'] = '1=1'; + } else { + $games = $this->getGamesByType($gameTypeId, 'id'); + if (count($games) == 0) { + return []; + } + $gameIds = array_column($games, 'id'); + $map['android_game_id'] = ['in', $gameIds]; + $map['ios_game_id'] = ['in', $gameIds]; + $map['_logic'] = 'or'; + } + $baseGames = M('base_game', 'tab_')->field($fields)->where($map)->select(); + return index_by_column('id', $baseGames); + } } \ No newline at end of file diff --git a/Application/Base/Service/PaymentMerchantService.class.php b/Application/Base/Service/PaymentMerchantService.class.php new file mode 100644 index 000000000..43a870056 --- /dev/null +++ b/Application/Base/Service/PaymentMerchantService.class.php @@ -0,0 +1,112 @@ + '禁用', + 1 => '启用', + ]; + + public static $channels = [ + 1 => '支付宝', + 2 => '微信支付', + 3 => '易宝支付', + 4 => '双乾支付', + 5 => '汇付宝支付', + ]; + + public static $ways = [ + self::WAY_ALIPAY => '支付宝', + self::WAY_WEIXIN => '微信', + self::WAY_EXPRESS => '快捷支付', + ]; + + public function getStatusText($status) + { + return self::$statusList[$status] ?? '未知'; + } + + public function getChannelText($channel) + { + return self::$channels[$channel] ?? '未知'; + } + + public function getMerchantsByIds(array $ids, $fields = '*') + { + if (count($ids) == 0) { + return []; + } + $rules = M('payment_merchant', 'tab_')->field($fields)->where(['in' => ['in', $ids]])->select(); + return index_by_column('id', $rules); + } + + public function getMerchantsByWay($way) + { + $conditions = []; + $conditions['_string'] = 'ways&' . $way . '=' . $way; + $conditions['status'] = self::STATUS_ACTIVE; + return M('payment_merchant', 'tab_')->where($conditions)->select(); + } + + public function getWaysValue($ways) + { + $waysValue = 0; + foreach ($ways as $way) { + $waysValue = $waysValue | $way; + } + return $waysValue; + } + + public function getWaysRow($waysValue) + { + $row = []; + foreach (self::$ways as $key => $name) { + if (($waysValue & $key) == $key) { + $row[] = $key; + } + } + return $row; + } + + public function getWaysName($waysValue) + { + $nameList = []; + $keys = $this->getWaysRow($waysValue); + foreach ($keys as $key) { + $nameList[] = self::$ways[$key] ?? '未知'; + } + return $nameList; + } + + public function setDefault($way, $merchantId) + { + $merchantBefore = $this->getDefault($way); + if ($merchantBefore && $merchantBefore['id'] == $merchantId) { + return; + } + $merchantAfter = M('payment_merchant', 'tab_')->where(['id' => $merchantId])->find(); + if ($merchantAfter) { + $afterData = ['is_default' => $merchantAfter['is_default'] | $way]; + M('payment_merchant', 'tab_')->where(['id' => $merchantId])->save($afterData); + } + if ($merchantBefore) { + $beforeData = ['is_default' => $merchantBefore['is_default'] ^ $way]; + M('payment_merchant', 'tab_')->where(['id' => $merchantBefore['id']])->save($beforeData); + } + } + + public function getDefault($way) + { + return M('payment_merchant', 'tab_')->where(['_string' => 'is_default&' . $way . '=' . $way])->find(); + } +} \ No newline at end of file diff --git a/Application/Base/Service/PaymentRuleService.class.php b/Application/Base/Service/PaymentRuleService.class.php new file mode 100644 index 000000000..4ab808e16 --- /dev/null +++ b/Application/Base/Service/PaymentRuleService.class.php @@ -0,0 +1,39 @@ +field($fields)->where($map)->select(); + return index_by_column('id', $rules); + } + + public function getEffectiveTimeDisplay($rule) + { + $startTime = $rule['start_time'] == 0 ? null : date('Y-m-d', $rule['start_time']); + $endTime = $rule['end_time'] == 0 ? null : date('Y-m-d', $rule['end_time']); + if ($startTime == null && $endTime == null) { + return '永久'; + } + if ($startTime != null && $endTime != null) { + return $startTime . ' 至 ' . $endTime; + } + if ($startTime == null && $endTime != null) { + return '从前 至 ' . $endTime; + } + if ($startTime != null && $endTime == null) { + return $startTime . ' 至 永久'; + } + } +} \ No newline at end of file diff --git a/Application/Base/Service/PromoteCompanyService.class.php b/Application/Base/Service/PromoteCompanyService.class.php new file mode 100644 index 000000000..2d15a60a6 --- /dev/null +++ b/Application/Base/Service/PromoteCompanyService.class.php @@ -0,0 +1,53 @@ + '内团', + 1 => '外团', + 2 => '外团-分发', + 3 => '无', + ]; + + public function getOutBelongs() + { + return [ + self::BELONG_OUTSIDE => self::$belongs[self::BELONG_OUTSIDE], + self::BELONG_OUTSIDE_SP => self::$belongs[self::BELONG_OUTSIDE_SP], + ]; + } + + public function getCompanies(array $ids = null, $fields = '*') + { + $map = []; + if (is_null($ids)) { + $map['_string'] = '1=1'; + } elseif (count($ids) == 0) { + return []; + } else { + $map['id'] = ['in', $ids]; + } + $rules = M('promote_company', 'tab_')->field($fields)->where($map)->select(); + return index_by_column('id', $rules); + } + + public function getCompaniesByBelong($belong = null, $fields = '*') + { + $map = []; + if (is_null($belong)) { + $map['_string'] = '1=1'; + } else { + $map['company_belong'] = $belong; + } + $rules = M('promote_company', 'tab_')->field($fields)->where($map)->select(); + return index_by_column('id', $rules); + } +} \ No newline at end of file diff --git a/Data/update.sql b/Data/update.sql index aa6d436fe..65156a95d 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -2165,4 +2165,60 @@ CREATE TABLE `tab_payment_member` ( INSERT INTO `tab_payment_member` (`id`, `real_name`, `mobile`, `last_login_time`) VALUES ('1', '胡歌', '18959188422', '0') +--20200715 elf +CREATE TABLE `tab_payment_merchant` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(150) not null COMMENT '商户名称', + `account` varchar(150) not null DEFAULT '' COMMENT '商户账号', + `identifier` varchar(50) not null DEFAULT '' COMMENT '标识', + `channel` tinyint(1) not null COMMENT '支付渠道 1 支付宝 2 微信 3 易宝支付 4 双乾支付 5 汇付宝支付', + `type` tinyint(1) not null COMMENT '支付渠道 1 收款 2 付款', + `status` tinyint(1) not null DEFAULT 0 COMMENT '状态 0 未启用 1 启用', + `config` text COMMENT '配置参数JSON', + `admin_id` int(11) not null DEFAULT 0 COMMENT '最后操作管理员ID', + `ways` tinyint(1) not null DEFAULT 0 COMMENT '支持支付方式(位) 1 支付宝 2 微信 4 快捷支付', + `is_default` tinyint(1) not null DEFAULT 0 COMMENT '是否默认支付 1 支付宝 2 微信 4 快捷支付', + `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间', + `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最后修改时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='付款/收款商户'; +CREATE TABLE `tab_payment_merchant_way` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `merchant_id` int(11) not null COMMENT '商户ID', + `way` tinyint(1) not null COMMENT '支付方式 1 支付宝 2 微信 3 快捷支付', + `is_default` tinyint(1) not null DEFAULT 0 COMMENT '是否默认 0 否 1 是', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='商户支付方式'; + +CREATE TABLE `tab_payment_rule` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `game_type_id` int(11) not null DEFAULT 0 COMMENT '游戏类型ID', + `game_id` int(11) not null DEFAULT 0 COMMENT '游戏ID', + `company_belong` tinyint(1) not null DEFAULT -1 COMMENT '-1 全部 0-内团;1-外团 2-分发联盟 3 无', + `company_id` int(11) not null DEFAULT 0 COMMENT '推广公司ID', + `alipay_merchant_id` int(11) not null DEFAULT 0 COMMENT '支付宝商户ID', + `weixin_merchant_id` int(11) not null DEFAULT 0 COMMENT '微信商户ID', + `express_merchant_id` int(11) not null DEFAULT 0 COMMENT '快捷支付商户ID', + `start_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '开始时间', + `end_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '结束时间', + `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间', + `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最后修改时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='基础商户规则配置'; + +alter table tab_payment_merchant add column `main_name` varchar(150) NOT NULL default '' comment '商户主体名称'; + +alter table tab_spend add column `merchant_id` int(11) unsigned NOT NULL default 0 comment '支付商户ID'; +alter table tab_deposit add column `merchant_id` int(11) unsigned NOT NULL default 0 comment '支付商户ID'; +alter table tab_game_supersign add column `merchant_id` int(11) unsigned NOT NULL default 0 comment '支付商户ID'; +alter table tab_coin_pay_order add column `merchant_id` int(11) unsigned NOT NULL default 0 comment '支付商户ID'; +alter table tab_test_order add column `merchant_id` int(11) unsigned NOT NULL default 0 comment '支付商户ID'; +alter table tab_bind_recharge add column `merchant_id` int(11) unsigned NOT NULL default 0 comment '支付商户ID' + +alter table tab_spend add column `merchant_way` tinyint(3) unsigned NOT NULL default 0 comment '商户支付方式'; +alter table tab_deposit add column `merchant_way` tinyint(3) unsigned NOT NULL default 0 comment '商户支付方式'; +alter table tab_game_supersign add column `merchant_way` tinyint(3) unsigned NOT NULL default 0 comment '商户支付方式'; +alter table tab_coin_pay_order add column `merchant_way` tinyint(3) unsigned NOT NULL default 0 comment '商户支付方式'; +alter table tab_test_order add column `merchant_way` tinyint(3) unsigned NOT NULL default 0 comment '商户支付方式'; +alter table tab_bind_recharge add column `merchant_way` tinyint(3) unsigned NOT NULL default 0 comment '商户支付方式' \ No newline at end of file