|
|
|
@ -141,6 +141,7 @@ class PromoteController extends ThinkController
|
|
|
|
|
//为数据权限添加
|
|
|
|
|
setPowerPromoteIds($map, 'id');
|
|
|
|
|
$list_data = D(self::model_name)->where($map)->order('id DESC')->page($p, $row)->select();
|
|
|
|
|
$list_data = D(self::model_name)->parseListData($list_data);
|
|
|
|
|
$oa_data = [];
|
|
|
|
|
if (I('oa_associated', -1) == -1) {
|
|
|
|
|
foreach ($list_data as $k => $v) {
|
|
|
|
@ -220,14 +221,29 @@ class PromoteController extends ThinkController
|
|
|
|
|
if ($this->accountExist($account)) {
|
|
|
|
|
$this->error('该账号已存在');
|
|
|
|
|
}
|
|
|
|
|
$data = array('account'=>$account,'password'=>$password,'second_pwd'=>$second_pwd,'real_name'=>$real_name,
|
|
|
|
|
'email'=>$email,'mobile_phone'=>$mobile_phone,'bank_name'=>$bank_name,'bank_card'=>$bank_card,
|
|
|
|
|
'admin_id'=>session('user_auth')['uid'],'status'=>$status,'ba_id'=>$ba_id, 'company_id' => $company_id);
|
|
|
|
|
$company_belong = $_REQUEST['company_belong'];
|
|
|
|
|
$company_relation = $_REQUEST['company_relation'];
|
|
|
|
|
$data = array(
|
|
|
|
|
'account'=>$account,
|
|
|
|
|
'password'=>$password,
|
|
|
|
|
'second_pwd'=>$second_pwd,
|
|
|
|
|
'real_name'=>$real_name,
|
|
|
|
|
'email'=>$email,
|
|
|
|
|
'mobile_phone'=>$mobile_phone,
|
|
|
|
|
'bank_name'=>$bank_name,
|
|
|
|
|
'bank_card'=>$bank_card,
|
|
|
|
|
'admin_id'=>session('user_auth')['uid'],
|
|
|
|
|
'status'=>$status,
|
|
|
|
|
'ba_id'=>$ba_id,
|
|
|
|
|
'company_id' => $company_id,
|
|
|
|
|
'company_belong' => $company_belong,
|
|
|
|
|
'company_relation' => $company_relation,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (preg_match('/^[a-zA-Z0-9]{6,15}$/', $account)==false) {
|
|
|
|
|
$this->error('账号只能是6-15位字母或数字');
|
|
|
|
|
}
|
|
|
|
|
if (empty($company_id)) {
|
|
|
|
|
if ($company_id < 0) {
|
|
|
|
|
$this->error('请选择推广公司');
|
|
|
|
|
}
|
|
|
|
|
$promoteService = new PromoteService();
|
|
|
|
@ -277,12 +293,16 @@ class PromoteController extends ThinkController
|
|
|
|
|
if (preg_match('/^[a-zA-Z0-9]{6,15}$/', I('post.account'))==false) {
|
|
|
|
|
$this->error('账号只能是6-15位字母或数字');
|
|
|
|
|
}
|
|
|
|
|
$promote = M("promote", "tab_")->where(array("id" => $_POST['id']))->field('id, level')->find();
|
|
|
|
|
$promote = M("promote", "tab_")
|
|
|
|
|
->where(array("id" => $_POST['id']))
|
|
|
|
|
->field('id, level, company_belong, company_relation, company_id')
|
|
|
|
|
->find();
|
|
|
|
|
$data['account'] = I('post.account');
|
|
|
|
|
if ($this->accountExist($data['account'], $_POST['id'])) {
|
|
|
|
|
$this->error('该账号已存在');
|
|
|
|
|
}
|
|
|
|
|
if (empty(I('company_id')) && $promote['level'] ==1) {
|
|
|
|
|
$company_id = I('company_id');
|
|
|
|
|
if ($company_id <0 && $promote['level'] ==1) {
|
|
|
|
|
$this->error('请选择推广公司');
|
|
|
|
|
}
|
|
|
|
|
empty(I('post.id')) ? : $data['id'] =I('post.id');
|
|
|
|
@ -310,15 +330,33 @@ class PromoteController extends ThinkController
|
|
|
|
|
$ba = new \Admin\Model\BusinessAffairsModel();
|
|
|
|
|
$ba->update_child($ba_id['ba_id'], $_REQUEST['ba_id'], $id);
|
|
|
|
|
}
|
|
|
|
|
if (!empty(I('company_id')) && $promote['level'] ==1) {
|
|
|
|
|
$data['company_id'] = I('company_id');
|
|
|
|
|
|
|
|
|
|
if ($promote['level'] ==1) {//如果是会长才能修改的选项
|
|
|
|
|
if (!is_null($company_id)) {
|
|
|
|
|
$data['company_id'] = $company_id;//推广公司
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data['company_belong'] = I('company_belong');//工会归属
|
|
|
|
|
$data['company_relation'] = I('company_relation');//工会关系
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$res = M("promote", "tab_")->where(array("id"=>$_POST['id']))->save($data);
|
|
|
|
|
if ($res !== false) {
|
|
|
|
|
if (!empty(I('company_id')) && $promote['level'] ==1) {//修改会长底下推广员的推广公司
|
|
|
|
|
M("promote", "tab_")->where("chain like '%/{$_POST['id']}/%'")->save([
|
|
|
|
|
'company_id' => I('company_id')
|
|
|
|
|
]);
|
|
|
|
|
if ($promote['level'] == 1) {//修改会长底下推广员的推广公司
|
|
|
|
|
$array = array();
|
|
|
|
|
if ($promote['company_id'] != $company_id) {
|
|
|
|
|
$array['company_id'] = I('company_id');
|
|
|
|
|
}
|
|
|
|
|
if ($promote['company_belong'] != I('company_belong')) {
|
|
|
|
|
$array['company_belong'] = I('company_belong');
|
|
|
|
|
}
|
|
|
|
|
if ($promote['company_relation'] != I('company_relation')) {
|
|
|
|
|
$array['company_relation'] = I('company_relation');
|
|
|
|
|
}
|
|
|
|
|
if ($array) {
|
|
|
|
|
$res = M("promote", "tab_")->where("chain like '%/{$_POST['id']}/%'")->save($array);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
$this->success("修改成功", U('lists'));
|
|
|
|
|
} else {
|
|
|
|
|