From d662c89b7e865da2a5e87eebc6529ad26b095c89 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Fri, 17 Jul 2020 14:29:54 +0800 Subject: [PATCH] zancun --- .../PromoteCompanyController.class.php | 85 ++++---- .../Model/PromoteCompanyVerifyModel.class.php | 64 ++++++ .../Admin/View/PromoteCompany/add.html | 193 +++++++++++++++++- Data/update.sql | 20 +- 4 files changed, 313 insertions(+), 49 deletions(-) create mode 100644 Application/Admin/Model/PromoteCompanyVerifyModel.class.php diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index 2d4a2a70b..8002060cf 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -239,12 +239,12 @@ class PromoteCompanyController extends ThinkController $this->checkData($save); $save['create_time'] = $time; $save['turnover_ratio'] = $this->setTurnoverRatio($save); - $res = M("promote_company","tab_")->add($save); + $res = D("PromoteCompanyVerify")->add_db($save); if ($res) { addOperationLog(['op_type'=>0,'key'=>$save['company_name'],'op_name'=>'新增推广公司','url'=>U('PromoteCompany/lists')]); \Think\Log::actionLog('PromoteCompany/add', 'partner', $res); $array=array( - "info"=>"添加成功", + "info"=>"添加成功,请联系管理员尽快审核", "status"=>1 ); $this->ajaxReturn($array); @@ -298,49 +298,15 @@ class PromoteCompanyController extends ThinkController //编辑 public function edit() { - $model = M($this->modelName, 'tab_'); - if ($_POST) { $save = I('post.');//前端已经验证 $this->checkData($save); $save['turnover_ratio'] = $this->setTurnoverRatio($save); - // dd($save); - - //判断内外团是否修改 - $is_change_belong = false; - $company_id = $save['id']; - $y_belong = $model->field("company_belong")->where("id = {$save['id']}")->find()['company_belong']; - if(isset($save['company_belong']) && ($y_belong != $save['company_belong'])){ - $is_change_belong = true; - } - if(empty($save['contact_phone'])){ - $save['contact_phone'] = 0; - } - $res = M("promote_company","tab_")->save($save); + $res = D("PromoteCompanyVerify")->edit_db($save); if ($res) { - //处理底下所有会长的公会属性 - if($is_change_belong){ - $savedata = array( - "company_belong"=>$save['company_belong'] - ); - - // 权限跟随 - $authGroup = M('sys_auth_group')->where(['title'=>'市场总监'])->find(); - $subPromoteIds = M('promote', 'tab_')->where(['level' => 1, 'company_id' => $company_id])->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('sys_auth_group')->where(['title'=>'市场总监'])->save(['data_president'=>implode(',', $dataPresident)]); - - M("Promote","tab_")->where("company_id = '{$company_id}'")->save($savedata); - } addOperationLog(['op_type'=>1,'key'=>$_POST['company_name'],'op_name'=>'编辑推广公司','url'=>U('PromoteCompany/lists'),'menu'=>'推广员-推广员管理-推广公司管理-编辑推广公司']); - $array=array( - "info"=>"修改成功", + "info"=>"修改成功,请联系管理员尽快审核", "status"=>1 ); $this->ajaxReturn($array); @@ -351,6 +317,7 @@ class PromoteCompanyController extends ThinkController )); } } else { + $model = M($this->modelName, 'tab_'); $id = $_REQUEST['id'] ?: 0; $map['id'] = $id; $data = $model->field('*')->find($id); @@ -808,6 +775,48 @@ class PromoteCompanyController extends ThinkController $save['validity_end_time'] = strtotime($save['validity_end_time']); $save['last_up_time'] = $time; } + /** + * 由于修改公司信息引起的会长信息修改 + * @param [type] $save + * @return void + */ + protected function changePromote(&$save){ + $is_change_belong = false; + $is_change_relation =false; + if(empty($save['id'])){ + return false; + } + $company_id = $save['id']; + $old_info = M("PromoteCompany","tab_")->field("company_belong,develop_type")->where("id = {$save['id']}")->find(); + if(isset($save['company_belong']) && ($old_info['company_belong'] != $save['company_belong'])){ + $is_change_belong = true; + } + if(isset($save['develop_type']) && ($old_info['develop_type'] != $save['develop_type'])){ + $is_change_relation = true; + } + + //处理底下所有会长的公会属性 + if($is_change_belong || $is_change_relation){ + $savedata = array( + "company_belong"=>$save['company_belong'], + "company_relation"=>$save['develop_type'] + ); + M("Promote","tab_")->where("company_id = '{$company_id}'")->save($savedata); + + // 权限跟随 + if($is_change_belong){ + $authGroup = M('auth_group',"sys_")->where(['title'=>'市场总监'])->find(); + $subPromoteIds = M('promote', 'tab_')->where(['level' => 1, 'company_id' => $company_id])->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)]); + } + } + } } diff --git a/Application/Admin/Model/PromoteCompanyVerifyModel.class.php b/Application/Admin/Model/PromoteCompanyVerifyModel.class.php new file mode 100644 index 000000000..60bd9a9d9 --- /dev/null +++ b/Application/Admin/Model/PromoteCompanyVerifyModel.class.php @@ -0,0 +1,64 @@ +"审核拒绝", + "0"=>"未审核", + "1"=>"审核通过" + ]; + /** + * 新增 + * @param [array]] $info 公司信息 + * @return void + */ + public function add_db($info) + { + $verifydata = [ + "company_id"=>0, + "company_name"=>$info['company_name'], + "verify_status"=>0, + "create_time"=>time(), + 'verify_log'=>json_encode(["create_user"=>$_SESSION['onethink_admin']['user_auth']['username'],"create_time"=>date("Y-m-d H:i:s")]) + ]; + if(isset($info['instanceof'])) unset($info['instanceof']); + if(isset($info['turnover'])) unset($info['turnover']); + $verifydata['company_info'] = json_encode($info,JSON_UNESCAPED_UNICODE); + return $this->add($verifydata); + } + public function edit_db($info) + { + if(!isset($info['id'])){ + return false; + } + $p_id = $info['id']; + + $verifydata = [ + "company_id"=>$p_id, + "company_name"=>$info['partner'], + "verify_status"=>0, + "create_time"=>time(), + 'verify_log'=>json_encode(["create_user"=>$_SESSION['onethink_admin']['user_auth']['username'],"create_time"=>date("Y-m-d H:i:s")]) + ]; + if(isset($info['instanceof'])) unset($info['instanceof']); + if(isset($info['turnover'])) unset($info['turnover']); + $verifydata['company_info'] = json_encode($info,JSON_UNESCAPED_UNICODE); + + //判断是否存在 + $has = $this->where("company_id = {$p_id}")->find(); + if($has){ + //存在 + $verifydata['id'] = $has['id']; + $res = $this->save($verifydata); + }else{ + $res = $this->add($verifydata); + } + return $res; + } + +} \ No newline at end of file diff --git a/Application/Admin/View/PromoteCompany/add.html b/Application/Admin/View/PromoteCompany/add.html index e3abbc8e0..462b70634 100644 --- a/Application/Admin/View/PromoteCompany/add.html +++ b/Application/Admin/View/PromoteCompany/add.html @@ -3,6 +3,7 @@ +