diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index 771cf52d1..c432bc5d5 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -126,9 +126,11 @@ class ConsoleController extends Think { public function testAggregate() { - $client = new AggregateClient(); + /* $client = new AggregateClient(); $result = $client->api('game-data', ['unique_codes' => ['w123'], 'started_at' => '2019-06-27', 'ended_at' => '2020-07-27']); - var_dump($result); + var_dump($result); */ + + echo M('game', 'tab_')->where('id>2')->field(['id', 'game_name'])->where('sdk_version=1')->select(false); } public function initMarketAdmin() diff --git a/Application/Admin/Controller/PartnerController.class.php b/Application/Admin/Controller/PartnerController.class.php index 6540bf3af..3ba81f8d1 100644 --- a/Application/Admin/Controller/PartnerController.class.php +++ b/Application/Admin/Controller/PartnerController.class.php @@ -337,6 +337,9 @@ class PartnerController extends ThinkController $this->error('保存失败'); } } else { + $selfCompanies = M('company_info', 'tab_')->field('id,partner company_name,link_man,link_phone')->where(['status' => 1])->select(); + + $this->assign('selfCompanies', $selfCompanies); $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Partner/add'])->find()); $this->meta_title = '新增上游CP公司'; $this->display(); diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index 942e2cbab..229982a94 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -7,6 +7,7 @@ use User\Api\UserApi as UserApi; use OSS\OssClient; use OSS\Core\OSsException; use Base\Service\PresidentDepositService; +use Base\Service\PromoteCompanyService; use Think\Controller; /** @@ -399,7 +400,24 @@ class PromoteCompanyController extends ThinkController if ($_POST) { $time = time(); $save = I('post.');//前端已经验证 + + $save['promotes'] = json_decode($save['promotes'], true); + $this->checkData($save); + + $presidentDepositService = new PresidentDepositService(); + $promoteCompanyService = new PromoteCompanyService(); + + try { + $presidentDepositService->checkBeforeSave($save['deposit'] ?? []); + $promoteCompanyService->checkPromotes($save['promotes'] ?? []); + } catch (\Exception $e) { + $this->ajaxReturn(array( + 'status' => 0, + 'info' => $e->getMessage() + )); + } + $save['create_time'] = $time; $save['turnover_ratio'] = $this->setTurnoverRatio($save); $res = D("PromoteCompanyVerify")->add_db($save); @@ -418,6 +436,9 @@ class PromoteCompanyController extends ThinkController )); } } else { + $selfCompanies = M('company_info', 'tab_')->field('id,partner company_name,link_man,link_phone')->where(['status' => 1])->select(); + + $this->assign('selfCompanies', $selfCompanies); $this->assign('payWays', PresidentDepositService::$payWays); $this->assign('payTypes', PresidentDepositService::$payTypes); $this->assign('serviceAgreements', M('service_agreement', 'tab_')->select()); @@ -974,14 +995,6 @@ class PromoteCompanyController extends ThinkController } } - if (I('pay_type', 0) == 0) { - $this->error('请选择押金付款方式'); - } - - if (I('pay_type', 0) != PresidentDepositService::PAY_TYPE_NONE && I('pay_way', 0) == 0) { - $this->error('请选择付款方式'); - } - // if(!empty(I("contact_phone")) && !checkPhone(I('contact_phone'))) { // $this->error('联系电话格式不正确'); // } diff --git a/Application/Admin/View/Partner/add.html b/Application/Admin/View/Partner/add.html index b0e4f67a6..c1e5b4ce2 100644 --- a/Application/Admin/View/Partner/add.html +++ b/Application/Admin/View/Partner/add.html @@ -19,6 +19,10 @@
@@ -52,164 +56,6 @@ - - 结算生效期限: - - - - - 结束时间不选默认永久 - - - - - - 渠道费率: - - % - - - - - - 开票税点: - - % - - - - 税费费率: - - % - - - - - 是否签署合同: - - - - - - - - - 公司性质: - - - - - - - 是否有游戏资质: - - - - - - - 联系人: - - - - - - - 联系电话: - - - - - - - 注册地址: - - - - - - 注册电话: - - - - - - - - 邮寄地址: - - - - - - - 公司税号: - - - - - - - 账户名: - - - - - - - 银行账号: - - - - - - - - 收款银行: - - - - - - - 支付宝真实姓名: - - - - - - - 支付宝登陆账号: - - - - - - - 备注: - - - - - *是否有预付款: @@ -285,6 +131,245 @@
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
*合作方式: + + +
*己方公司: + + +
*结算周期: + + +
*开票类型: + + +
开票内容: + +
是否有打款流程: + + + + + 选择否将不能进行线上打款 +
*收款方: + + +
结算生效期限: + + - + 结束时间不选默认永久 +
渠道费率: + % +
开票税点: + % +
税费费率: + % +
是否签署合同: + +
公司性质: + +
是否有游戏资质: + +
联系人: + +
联系电话: + +
注册地址: + +
注册电话: + +
邮寄地址: + +
公司税号: + +
账户名: + +
银行账号: + +
收款银行: + +
支付宝真实姓名: + +
支付宝登陆账号: + +
备注: + +
+
@@ -332,6 +417,7 @@ + + + + + + + + +
+ + + +
+
+ +
+ + +
+ 已添加添加至常用设置 +
+ + + + + + + + + + + + + diff --git a/Application/Admin/View/PromoteCompany/add.html b/Application/Admin/View/PromoteCompany/add.html index 90d22a34c..9c3c7815a 100644 --- a/Application/Admin/View/PromoteCompany/add.html +++ b/Application/Admin/View/PromoteCompany/add.html @@ -125,6 +125,10 @@ line-height: 25px; margin-bottom: 0px; } + .normal-table .normal-btn.delete-btn { + background: rgb(221, 10, 10); + margin-left: 5px; + } .layer-box .tabcon1711 input~.notice-text { width: auto; } @@ -234,7 +238,7 @@ *押金付款方式: - $name):?> @@ -244,10 +248,10 @@ - *押金付款方式: + *押金支付方式: - + $name):?> @@ -258,21 +262,21 @@ *押金金额: - + 押金付款人: - + 押金付款账号: - + @@ -355,6 +359,81 @@
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -758,6 +836,9 @@ } if(!flag) return false; senddata.push({"name":"game_ids", "value":ids.join(",")}); + + senddata.push({'name': 'promotes', 'value': JSON.stringify(getPromotes())}) + //添加 $.ajax({ url:"{:U('add')}", @@ -948,9 +1029,13 @@ content: $('#promote-box'), area: ['800px', '460px'], zIndex: 250, + cancel: function() { + clearPromoteBox() + } }) } }) + $('#confirm-promote').on({ click: function () { var box = $('#promote-box') @@ -962,36 +1047,108 @@ email: box.find('input[name=email]').val(), can_view_recharge: box.find('input[name=can_view_recharge]:checked').val(), } + if (promote.account == '') { + return layer.msg('请输入会长账号') + } + if (promote.password == '') { + return layer.msg('请输入登录密码') + } + if (promote.password.length < 6) { + return layer.msg('密码不能小于6位') + } + var canViewRecharge = promote.can_view_recharge == 1 ? '允许' : '禁止' - console.log(promote) - $('#promote-table').find('.no-record').remove() - var html = '' - + '' - + '' - + '' - + '' - + '' - + '' - console.log(html) - $('#promote-table').children('tbody').append(html) + + var editTr = $('#promote-table').find('.edit') + if (editTr.length > 0) { + editTr.attr('data-post', JSON.stringify(promote)) + var html = '' + + '' + + '' + + '' + + '' + + '' + editTr.html(html) + editTr.removeClass('edit') + } else { + $('#promote-table').find('.no-record').remove() + var html = '' + + '' + + '' + + '' + + '' + + '' + + '' + $('#promote-table').children('tbody').append(html) + } + layer.closeAll() + clearPromoteBox() } }) - $('#pay_type').change(function() { + function clearPromoteBox() { + var box = $('#promote-box') + box.find('input[name=account]').val('') + box.find('input[name=password]').val('') + box.find('input[name=realname]').val('') + box.find('input[name=mobile]').val('') + box.find('input[name=email]').val('') + box.find('.can_view_recharge[value=1]').click() + } + + function initPromoteBox(promote) { + var box = $('#promote-box') + box.find('input[name=account]').val(promote.account) + box.find('input[name=password]').val(promote.password) + box.find('input[name=realname]').val(promote.real_name) + box.find('input[name=mobile]').val(promote.mobile_phone) + box.find('input[name=email]').val(promote.email) + box.find('.can_view_recharge[value=' + promote.can_view_recharge + ']').click() + } + + $('#promote-table').on('click', '.delete-btn', function() { + $(this).parents('tr').eq(0).remove() + }) + + $('#promote-table').on('click', '.modify-btn', function() { + $(this).parents('tr').eq(0).addClass('edit') + var promote = JSON.parse($(this).parents('tr').eq(0).attr('data-post')) + layer.open({ + title: '编辑会长', + type: 1, + content: $('#promote-box'), + area: ['800px', '460px'], + zIndex: 250, + cancel: function() { + clearPromoteBox() + } + }) + initPromoteBox(promote) + }) + + function getPromotes() { + var promotes = [] + $('#promote-table tbody tr').each(function(index, elem) { + promotes.push(JSON.parse($(elem).attr('data-post'))) + }) + return promotes + } + + $('#deposit-pay-type').change(function() { var val = $(this).val() if (val == 2) { $('.need-amount').show(); - $("#pay_way option[value='4']").removeProp('disabled'); - $('#pay_way').val('4') - $('#pay_way').attr('disabled', 'disabled') + $("#deposit-pay-way option[value='4']").removeProp('disabled'); + $('#deposit-pay-way').val('4') + $('#deposit-pay-way').attr('disabled', 'disabled') } else if(val == 3) { $('.need-amount').hide(); } else { $('.need-amount').show(); - $('#pay_way').removeAttr('disabled'); - $("#pay_way option[value='4']").prop('disabled', true); - $('#pay_way').val('') + $('#deposit-pay-way').removeAttr('disabled'); + $("#deposit-pay-way option[value='4']").prop('disabled', true); + $('#deposit-pay-way').val('') } }) diff --git a/Application/Base/Service/PresidentDepositService.class.php b/Application/Base/Service/PresidentDepositService.class.php index 4e9c534f3..34b1f06bc 100644 --- a/Application/Base/Service/PresidentDepositService.class.php +++ b/Application/Base/Service/PresidentDepositService.class.php @@ -31,12 +31,39 @@ class PresidentDepositService 1 => '已收到', 2 => '已退款', ]; + + public function checkBeforeSave($params, $record = null) + { + if ($params['pay_type'] == 0) { + throw new \Exception('请选择押金付款方式'); + } + + if ($params['pay_type'] != 2 && $params['pay_way'] == 0) { + throw new \Exception('请选择付款方式'); + } + + if ($record && $params['amount'] === '') { + throw new \Exception('请输入金额'); + } - public function add($params) + if ($params['amount'] !== '') { + if (!is_numeric($params['amount'])) { + throw new \Exception('请输入正确金额'); + } + if ($params['amount'] <= 0) { + throw new \Exception('金额必须大于0'); + } + + if ($params['amount'] > 100000000) { + throw new \Exception('金额过高'); + } + } + } + + public function save($params, $company) { $payWay = $params['pay_way'] ?? 0; $payType = $params['pay_type'] ?? 0; - $promoteId = $params['id'] ?? 0; $payAccount = $params['pay_account'] ?? ''; $amount = $params['amount'] ?? ''; $payer = $params['payer'] ?? ''; @@ -46,68 +73,64 @@ class PresidentDepositService $payAcceptTime = $payAcceptTime ? strtotime($payAcceptTime) : 0; $refundTime = $refundTime ? strtotime($refundTime) : 0; + $record = M('president_deposit', 'tab_')->where(['company_id' => $company['id']])->find(); - $record = M('president_deposit', 'tab_')->where(['promote_id' => $promoteId])->find(); - - $promoteData = M('promote', 'tab_')->field('account')->where(['id' => $promoteId])->find(); - - // 市场部门无法操作押金退款和收到时间 - if ((($record['pay_accept_time'] != $payAcceptTime) || ($record['refund_time'] != $refundTime)) && isMarketAdmin()) { - throw new \Exception('无法操作记录'); - } - - if ($payType == 0) { - throw new \Exception('请选择押金付款方式'); - } - if ($payType == 3) { - return $this->handleNoDeposit($promoteId); - } - if ($payType != 2 && $payWay == 0) { - throw new \Exception('请选择付款方式'); - } + if ($params['pay_type'] == 3) { + return $this->handleNoDeposit($company, $record); + } + + if ($record) { + $this->update(); + addOperationLog(['op_type'=>1,'key'=>$company['company_name'].'/'.$params['amount'],'op_name'=>'编辑会长押金','url'=>U('PresidentDeposit/edit',['id'=>$company['id']]),'menu'=>'推广员-结算单管理-会长押金管理-编辑会长押金']); + } else { + $this->add(); + addOperationLog(['op_type'=>0,'key'=>$company['company_name'].'/'.$params['amount'],'op_name'=>'新增会长押金','url'=>U('PresidentDeposit/edit',['id'=>$company['id']]),'menu'=>'推广员-结算单管理-奖罚记录管理-新增会长押金']); + } + } - if (!$record) { - if ($amount !== '') { - if (!is_numeric($amount)) { - throw new \Exception('请输入正确金额'); - } - if ($amount <= 0) { - throw new \Exception('金额必须大于0'); - } - if ($amount > 100000000) { - throw new \Exception('金额过高'); - } - } + private function add($params, $company) + { + $data = []; + $data['pay_way'] = $params['pay_type'] == 2 ? 4 : $params['pay_way']; + $data['pay_type'] = $params['pay_type']; + $data['company_id'] = $company['id']; + $data['pay_account'] = $params['pay_account']; + $data['amount'] = floatval($params['amount']); + $data['payer'] = $params['payer']; + $data['create_time'] = time(); + $data['update_time'] = time(); + M('president_deposit', 'tab_')->add($data); + } - $data = []; + private function update($params, $company, $record) + { + $payAcceptTime = $params['pay_accept_time'] == '' ? 0 : strtotime($params['pay_accept_time']); + $refundTime = $params['refund_time'] == '' ? 0 : strtotime($params['pay_accept_time']); - // 填写押金到账时间后自动变为押金已确认到账状态,并且状态在待确认时候 - if ($record['pay_accept_time'] != $payAcceptTime && $record['status'] == 0) { - $data = ['status' => 1, - 'pay_confirm_time' => time()]; - } + $data = []; - $data['pay_way'] = $payType == 2 ? 4 : $payWay; - $data['pay_type'] = $payType; - $data['promote_id'] = $promoteId; - $data['pay_account'] = $payAccount; - $data['amount'] = floatval($amount); - $data['payer'] = $payer; - $data['create_time'] = time(); - $data['update_time'] = time(); + $status = null; + if ($payType != $record['pay_type']) { + $status = 0; + $data['refund_time'] = $data['pay_accept_time'] = $data['pay_confirm_time'] = 0; + } else { $data['pay_accept_time'] = $payAcceptTime; $data['refund_time'] = $refundTime; + } - M('president_deposit', 'tab_')->add($data); + $data['pay_way'] = $params['pay_type'] == 2 ? 4 : $params['pay_way']; + $data['pay_type'] = $params['pay_type']; + $data['pay_account'] = $params['pay_account']; + $data['amount'] = floatval($params['amount']); + $data['payer'] = $params['payer']; + $data['status'] = $status ?? $record['status']; + $data['update_time'] = time(); - addOperationLog(['op_type'=>0,'key'=>$promoteData['account'].'/'.$amount,'op_name'=>'新增会长押金','url'=>U('PresidentDeposit/edit',['id'=>$promoteId]),'menu'=>'推广员-结算单管理-奖罚记录管理-新增会长押金']); - } + M('president_deposit', 'tab_')->where(['id' => $record['id']])->save($data); } - public function handleNoDeposit($promoteId) - { - $record = M('president_deposit', 'tab_')->where(['promote_id' => $promoteId])->find(); - + public function handleNoDeposit($company, $record = null) + { $data = []; $data['pay_way'] = 0; $data['pay_type'] = self::PAY_TYPE_NONE; @@ -120,15 +143,90 @@ class PresidentDepositService $data['update_time'] = time(); $data['status'] = 1; $data['pay_accept_time'] = $data['refund_time'] = 0; - $data['promote_id'] = $promoteId; if (!$record) { + $data['company_id'] = $company['id']; M('president_deposit', 'tab_')->add($data); } else { - M('president_deposit', 'tab_')->where(['promote_id' => $promoteId])->save($data); + M('president_deposit', 'tab_')->where(['company_id' => $company['id']])->save($data); + } + addOperationLog(['op_type'=>1,'key'=>$company['company_name'],'op_name'=>'编辑无需押金','url'=>U('PresidentDeposit/records'),'menu'=>'推广员-结算单管理-会长押金管理-无需押金']); + } + + public function batchRefund(array $companyIds) + { + if (isMarketAdmin()) { + throw new \Exception('无法操作记录'); + } + + $companyIds = I('ids', []); + if (count($companyIds) == 0) { + throw new \Exception('无选中项'); + } + + $checkStatus = true; + $records = M('president_deposit', 'tab_')->where(['company_id' => ['in', $companyIds]])->select(); + foreach ($records as $record) { + if ($record['status'] != 1) { + $checkStatus = false; + break; + } + } + if (!$checkStatus) { + throw new \Exception('含有非已到账状态记录,不可批量操作'); + } + + M('president_deposit', 'tab_')->where(['company_id' => ['in', $companyIds]])->save([ + 'status' => 2, + 'refund_time' => time(), + 'update_time' => time(), + 'pay_accept_time' => 0 + ]); + + $companies = M('promote_company', 'tab_')->field(['company_name', 'id'])->where(['id' => ['in', $companyIds]])->select(); + $companies = index_by_column('id', $companies); + foreach ($records as $record) { + $company = $companies[$record['company_id']] ?? null; + if ($record['amount']) { + addOperationLog(['op_type'=>1,'key'=>$company['company_name'].'/'.$record['amount'],'op_name'=>'编辑押金已退款','url'=>U('PresidentDeposit/records'),'menu'=>'推广员-结算单管理-会长押金管理-押金已退款']); + } + } + } + + public function batchPayConfirm(array $companyIds) + { + if (isMarketAdmin()) { + throw new \Exception('无法操作记录'); + } + if (count($companyIds) == 0) { + throw new \Exception('无选中项'); + } + $checkStatus = true; + $records = M('president_deposit', 'tab_')->where(['promote_id' => ['in', $promoteIds]])->select(); + foreach ($records as $record) { + if ($record['status'] != 0) { + $checkStatus = false; + break; + } + } + if (!$checkStatus) { + throw new \Exception('含有非待确认状态记录,不可批量操作'); + } + + M('president_deposit', 'tab_')->where(['promote_id' => ['in', $promoteIds]])->save([ + 'status' => 1, + 'pay_confirm_time' => time(), + 'update_time' => time(), + 'pay_accept_time' => strtotime(I('accept_time')) + ]); + + $companies = M('promote_company', 'tab_')->field(['company_name', 'id'])->where(['id' => ['in', $companyIds]])->select(); + $companies = index_by_column('id', $companies); + foreach ($records as $record) { + $company = $companies[$record['company_id']] ?? null; + if ($record['amount']) { + addOperationLog(['op_type'=>1,'key'=>$company['company_name'].'/'.$record['amount'],'op_name'=>'编辑确认押金到账','url'=>U('PresidentDeposit/records'),'menu'=>'推广员-结算单管理-会长押金管理-确认押金到账']); + } } - - $promoteData = M('promote', 'tab_')->field('account')->where(['id' => $promoteId])->find(); - addOperationLog(['op_type'=>1,'key'=>$promoteData['account'],'op_name'=>'编辑无需押金','url'=>U('PresidentDeposit/records'),'menu'=>'推广员-结算单管理-会长押金管理-无需押金']); } } \ No newline at end of file diff --git a/Application/Base/Service/PromoteCompanyService.class.php b/Application/Base/Service/PromoteCompanyService.class.php index 2d15a60a6..7ed3b9e92 100644 --- a/Application/Base/Service/PromoteCompanyService.class.php +++ b/Application/Base/Service/PromoteCompanyService.class.php @@ -50,4 +50,203 @@ class PromoteCompanyService $rules = M('promote_company', 'tab_')->field($fields)->where($map)->select(); return index_by_column('id', $rules); } + + public function checkPromotes($promotes, $exceptId = 0) + { + foreach ($promotes as $promote) { + if (empty($promote['account'])) { + throw new \Exception('请输入会长账号'); + } + if (strlen($promote['account']) > 15 || strlen($promote['account']) < 6) { + throw new \Exception('会长账号长度为6-15个字符'); + } + + if (!preg_match("/^[a-zA-Z0-9_\.]+$/", $promote['account'])) { + throw new \Exception('会长账号只能为数字,字母和下划线'); + } + if (!empty($promote['mobile_phone'])) { + if (!preg_match("/^1[3456789]{1}\d{9}$/", $promote['mobile_phone'])) { + throw new \Exception('会长手机号格式错误'); + } + } + if (!empty($promote['real_name'])) { + if (mb_strlen($promote['real_name']) < 2 || mb_strlen($promote['real_name']) > 4) { + throw new \Exception('会长姓名只能为2-4个字符'); + } + } + } + + $accounts = array_column($promotes, 'account'); + $mobiles = array_column($promotes, 'mobile_phone'); + + if (count($accounts) != count(array_unique($accounts))) { + throw new \Exception('会长含有相同账号'); + } + + $mobiles = array_filter($mobiles, function ($key, $value) { + if ($value == '') { + return false; + } else { + return true; + } + }); + if (count($mobiles) != count(array_unique($mobiles))) { + throw new \Exception('会长含有相同手机号'); + } + $existPromote = M('promote', 'tab_')->field('id')->where(['account' => ['in', $accounts]])->find(); + if ($existPromote) { + throw new \Exception('会长账号已存在'); + } + if (count($mobiles) > 0) { + $existPromote = M('promote', 'tab_')->field('id')->where(['mobile_phone' => ['in', $mobiles]])->find(); + if ($existPromote) { + throw new \Exception('会长手机号已存在'); + } + } + $verifyingPromotes = $this->getVerifyingPromotes($exceptId); + if ($this->isExistVerifyingPromoteAccount($accounts, $verifyingPromotes)) { + throw new \Exception('会长账号已存在'); + } + if ($this->isExistVerifyingPromoteAccount($mobiles, $verifyingPromotes)) { + throw new \Exception('会长手机号已存在'); + } + } + + public function isExistVerifyingPromoteAccount($accounts, $verifyingPromotes) + { + $verifyingAccounts = array_column($verifyingPromotes, 'account'); + $sameAccounts = array_intersect($accounts, $verifyingAccounts); + return count($sameAccounts) > 0; + } + + public function isExistVerifyingPromoteMobile($mobiles, $verifyingPromotes) + { + $verifyingMobiles = array_unique(array_column($verifyingPromotes, 'mobile')); + $sameMobiles = array_intersect($mobiles, $verifyingMobiles); + return count($sameMobiles) > 0; + } + + public function getVerifyingPromotes($exceptId = 0) + { + $promotes = []; + $verifyCompanies = M('promote_company_verify', 'tab_')->field(['company_info'])->where(['status' => 0])->getField('company_info', true); + if ($verifyCompanies) { + foreach ($verifyCompanies as $item) { + $row = json_decode($item, true); + $promotes = array_merge($promotes, $row['promotes']); + } + } + return $promotes; + } + + public function adminAgree($application) + { + $adminInfo = $_SESSION['onethink_admin']['user_auth']; + $application['verify_log'] = json_decode($application['verify_log'],true); + $application['verify_log']['admin_user'] = $adminInfo["username"]; + $application['verify_log']['admin_time'] = date("Y-m-d H:i:s"); + $application['verify_log'] = json_encode($application['verify_log']); + $application['verify_status'] = 2; + $companyInfo = json_decode($application['company_info'], true); + + $deposit = $companyInfo['deposit']; + $bindRelation = $companyInfo['relation']; + $promotes = $companyInfo['promotes']; + unset($companyInfo['deposit']); + unset($companyInfo['relation']); + unset($companyInfo['promotes']); + + if($application['company_id'] == 0){ + //新增 + $application['company_id'] = M('promote_company', 'tab_')->add($companyInfo); + }else{ + //编辑 + M('promote_company', 'tab_')->save($companyInfo); + $this->changePromote($companyInfo); + } + + //业务逻辑 + M('PromoteCompanyVerify', 'tab_')->save($application); + addOperationLog(['op_type'=>1, 'key' => $application['id'], 'op_name'=>'管理员审核', 'url'=>U('index')]); + } + + protected function savePromoteCompanyRelation($company, $bindRelation) + { + $selfCompany = M('company_info', 'tab_')->where(['id' => $bindRelation['self_company_id']])->find(); + + $where = '(first_company_type=2 and first_company_id=' . $company['id'] . + ') or (second_company_type=2 and second_company_id=' . $company['id'] . ')'; + $relation = M('company_relation', 'tab_')->where($where)->find(); + + $data = []; + if ($bindRelation['collaborate_way'] == 1) { + $data['first_company_id'] = $company['id']; + $data['first_company_id'] = $company['company_name']; + $data['first_company_type'] = 2; + $data['second_company_id'] = $selfCompany['id']; + $data['second_company_name'] = $selfCompany['partner']; + $data['second_company_type'] = 0; + } else { + $data['first_company_id'] = $selfCompany['id']; + $data['first_company_id'] = $selfCompany['partner']; + $data['first_company_type'] = 2; + $data['second_company_id'] = $company['id']; + $data['second_company_name'] = $company['company_name']; + $data['second_company_type'] = 2; + } + + $data['settlement_type'] = $bindRelation['settlement_type']; + $data['invoice_type'] = $bindRelation['invoice_type']; + $data['collection'] = $bindRelation['collection']; + $data['is_payment'] = $bindRelation['is_payment']; + $data['invoice_content'] = $bindRelation['invoice_content']; + + if ($relation) { + M('company_relation', 'tab_')->where(['id' => $relation['id']])->save($data); + } else { + M('company_relation', 'tab_')->add($data); + } + } + + protected function changePromote($companyInfo){ + $isChangeBelong = false; + $isChangeRelation =false; + + if(empty($companyInfo['id'])){ + return; + } + + $companyId = $companyInfo['id']; + $oldInfo = M('promote_company', 'tab_')->field('company_belong,develop_type,game_ids')->where(['id' => $companyId])->find(); + + if(isset($companyInfo['company_belong']) && ($oldInfo['company_belong'] != $companyInfo['company_belong'])){ + $isChangeBelong = true; + } + + if(isset($companyInfo['develop_type']) && ($oldInfo['develop_type'] != $companyInfo['develop_type'])){ + $isChangeRelation = true; + } + //处理底下所有会长的公会属性 + if($isChangeBelong || $isChangeRelation ){ + + $data = array( + 'company_belong' => $save['company_belong'], + 'company_relation' => $save['develop_type'] + ); + M('promote', 'tab_')->where(['company_id' => $companyId])->save($data); + + // 权限跟随 + if($isChangeBelong){ + $authGroup = M('auth_group', 'sys_')->where(['title'=>'市场总监'])->find(); + $subPromoteIds = M('promote', 'tab_')->where(['level' => 1, 'company_id' => $companyId])->getField('id', true); + $dataPresident = explode(',', $authGroup['data_president']); + if ($save['company_belong'] == 1 || $save['company_belong'] == 2) { + $dataPresident = array_unique(array_merge($dataPresident, $subPromoteIds)); + } else { + $dataPresident = array_diff($dataPresident, $subPromoteIds); + } + M('auth_group', 'sys_')->where(['title' => '市场总监'])->save(['data_president' => implode(',', $dataPresident)]); + } + } + } } \ No newline at end of file
*合作方式: + + +
*己方公司: + + +
*结算周期: + + +
*开票类型: + + +
开票内容: + +
是否有打款流程: + + + + + 选择否将不能进行线上打款 +
*收款方: + + +
结算生效期限: @@ -364,7 +443,6 @@
支付宝真实姓名: @@ -573,10 +651,10 @@
' + promote.account + '' + promote.real_name + '' + promote.mobile_phone + '' + promote.email + '' + canViewRecharge + '
' + promote.account + '' + promote.real_name + '' + promote.mobile_phone + '' + promote.email + '' + canViewRecharge + '
' + promote.account + '' + promote.real_name + '' + promote.mobile_phone + '' + promote.email + '' + canViewRecharge + '