diff --git a/Application/Admin/Controller/PartnerController.class.php b/Application/Admin/Controller/PartnerController.class.php index 0fec4cbcc..969b58911 100644 --- a/Application/Admin/Controller/PartnerController.class.php +++ b/Application/Admin/Controller/PartnerController.class.php @@ -4,6 +4,7 @@ namespace Admin\Controller; use User\Api\UserApi as UserApi; use Think\Controller; +use Base\Service\PartnerService; /** * 后台首页控制器 @@ -316,6 +317,17 @@ class PartnerController extends ThinkController if ($_POST) { $save = I("post."); $this->checkData($save); + + try { + $partnerService = new PartnerService(); + $partnerService->checkRelation($save['relation'] ?? []); + } catch (\Exception $e) { + $this->ajaxReturn(array( + 'status' => 0, + 'info' => $e->getMessage() + )); + } + $save['uid'] = UID; $save['create_time'] = time(); @@ -518,31 +530,13 @@ class PartnerController extends ThinkController if(!isset($_REQUEST['ids'])) $this->error("参数错误"); $ids = $_REQUEST['ids']; - $Partner = M("partner", 'tab_'); - $PartnerVerify = M("partner_verify", 'tab_'); - $dbres =$PartnerVerify->field("*")->where("id in ({$ids})")->select(); - foreach($dbres as $k=>&$v){ - if($v['verify_status'] != 0) continue; - $v['verify_log'] = json_decode($v['verify_log'],true); - $v['verify_log']['verify_user']=$this->admininfo["username"]; - $v['verify_log']['verify_time']=date("Y-m-d H:i:s"); - $v['verify_log'] = json_encode($v['verify_log']); - $v['verify_status']=1; - $v["create_time"]=time(); - $partner_info = json_decode($v['partner_info'],true); - if($v['partner_id'] == 0){ - //新增 - $v['partner_id'] = $Partner->add($partner_info); - }else{ - //编辑 - $Partner->save($partner_info); - } - //修改自身 - $PartnerVerify->save($v); - M("partner_verify", 'tab_')->save($v); - - addOperationLog(['op_type'=>1,'key'=>$v['partner_id'],"op_name"=>"管理员审核",'url'=>U('index')]); + $records = M('partner_verify', 'tab_')->field("*")->where("id in ({$ids})")->select(); + + $service = new PartnerService(); + foreach($records as $record) { + $service->adminAgree($record); } + $this->ajaxReturn(array( 'status' => 1, "info"=>"管理员审核通过成功" diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index a169f52e0..9d75c82f0 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -588,6 +588,8 @@ class PromoteCompanyController extends ThinkController $this->checkData($save); try { + $presidentDepositService = new PresidentDepositService(); + $promoteCompanyService = new PromoteCompanyService(); if (in_array($save['company_belong'], [1, 2])) { $presidentDepositService->checkBeforeSave($save['deposit'] ?? []); } diff --git a/Application/Base/Service/PartnerService.class.php b/Application/Base/Service/PartnerService.class.php new file mode 100644 index 000000000..322e1186b --- /dev/null +++ b/Application/Base/Service/PartnerService.class.php @@ -0,0 +1,78 @@ +add($partnerInfo); + }else{ + //编辑 + M('partner', 'tab_')->save($partnerInfo); + } + + $this->saveRelation($relation, $partnerInfo); + + M('partner_verify', 'tab_')->save($application); + addOperationLog(['op_type' => 1, 'key'=>$application['partner_id'], "op_name"=>"管理员审核", 'url'=>U('index')]); + } + + protected function saveRelation($relation, $company) + { + $selfCompany = M('company_info', 'tab_')->where(['id' => $relation['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 ($relation['collaborate_way'] == 1) { + $data['first_company_id'] = $company['id']; + $data['first_company_name'] = $company['partner']; + $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_name'] = $selfCompany['partner']; + $data['first_company_type'] = 0; + $data['second_company_id'] = $company['id']; + $data['second_company_name'] = $company['partner']; + $data['second_company_type'] = 2; + } + + $data['settlement_type'] = $relation['settlement_type']; + $data['invoice_type'] = $relation['invoice_type']; + $data['collection'] = $relation['collection']; + $data['is_payment'] = $relation['is_payment']; + $data['invoice_content'] = $relation['invoice_content']; + if ($relation) { + M('company_relation', 'tab_')->where(['id' => $relation['id']])->save($data); + } else { + M('company_relation', 'tab_')->add($data); + } + } +} \ No newline at end of file