|
@@ -8,6 +8,7 @@ use app\model\AccountCompany;
|
|
|
use think\Exception;
|
|
|
use think\facade\Db;
|
|
|
use think\facade\Validate;
|
|
|
+use think\facade\Cache;
|
|
|
|
|
|
//【公司汇总】
|
|
|
class Headquarters extends BaseController
|
|
@@ -88,11 +89,11 @@ class Headquarters extends BaseController
|
|
|
'addtime' => date('Y-m-d H:i:s'),
|
|
|
'updater' => $post['updater'],
|
|
|
'updaterid' => $post['updaterid'],
|
|
|
- 'updater' => date('Y-m-d H:i:s'),
|
|
|
+ 'updatetime' => date('Y-m-d H:i:s'),
|
|
|
]);
|
|
|
|
|
|
Db::commit();
|
|
|
-
|
|
|
+ Cache::store("redis")->handler()->lpush("companycopy",$post);
|
|
|
return json_show(0, '添加成功');
|
|
|
|
|
|
} catch (Exception $e) {
|
|
@@ -138,11 +139,11 @@ class Headquarters extends BaseController
|
|
|
'remark' => $post['remark'],
|
|
|
'updater' => $post['updater'],
|
|
|
'updaterid' => $post['updaterid'],
|
|
|
- 'updater' => date('Y-m-d H:i:s'),
|
|
|
+ 'updatetime' => date('Y-m-d H:i:s'),
|
|
|
]);
|
|
|
|
|
|
Db::commit();
|
|
|
-
|
|
|
+ Cache::store("redis")->handler()->lpush("companycopy",json_encode($post,JSON_UNESCAPED_UNICODE));
|
|
|
return json_show(0, '修改成功');
|
|
|
|
|
|
} catch (Exception $e) {
|
|
@@ -457,6 +458,8 @@ class Headquarters extends BaseController
|
|
|
]);
|
|
|
|
|
|
Db::commit();
|
|
|
+ $param['type']=1;
|
|
|
+ Cache::store("redis")->handler()->lpush("companycopy",json_encode($param,JSON_UNESCAPED_UNICODE));
|
|
|
return json_show(0, '添加成功');
|
|
|
} catch (Exception $exception) {
|
|
|
Db::rollback();
|
|
@@ -510,6 +513,8 @@ class Headquarters extends BaseController
|
|
|
]);
|
|
|
|
|
|
Db::commit();
|
|
|
+ $param['type']=1;
|
|
|
+ Cache::store("redis")->handler()->lpush("companycopy",json_encode($param,JSON_UNESCAPED_UNICODE));
|
|
|
return json_show(0, '修改成功');
|
|
|
} catch (Exception $exception) {
|
|
|
Db::rollback();
|
|
@@ -625,6 +630,8 @@ class Headquarters extends BaseController
|
|
|
]);
|
|
|
|
|
|
Db::commit();
|
|
|
+ $param['data']['type']=3;
|
|
|
+ Cache::store("redis")->handler()->lpush("companycopy",json_encode($param['data'],JSON_UNESCAPED_UNICODE));
|
|
|
return json_show(0, '添加成功', ['id' => $id]);
|
|
|
} catch (Exception $exception) {
|
|
|
Db::rollback();
|
|
@@ -702,6 +709,8 @@ class Headquarters extends BaseController
|
|
|
]);
|
|
|
|
|
|
Db::commit();
|
|
|
+ $param['data']['type']=3;
|
|
|
+ Cache::store("redis")->handler()->lpush("companycopy",json_encode($param['data'],JSON_UNESCAPED_UNICODE));
|
|
|
return json_show(0, '修改成功', ['id' => $id]);
|
|
|
} catch (Exception $exception) {
|
|
|
Db::rollback();
|
|
@@ -751,7 +760,7 @@ class Headquarters extends BaseController
|
|
|
|
|
|
$item = Db::name('customer_info')
|
|
|
->where($where)
|
|
|
- ->field("id,companyNo,companyName,LENGTH(companyName) as weight")
|
|
|
+ ->field("id,companyNo,companyName,area,LENGTH(companyName) as weight")
|
|
|
->order(['weight' => 'asc', 'id' => 'desc'])
|
|
|
->page($param['page'], $param['size'])
|
|
|
->select()
|
|
@@ -763,27 +772,29 @@ class Headquarters extends BaseController
|
|
|
|
|
|
public function cCreate()
|
|
|
{
|
|
|
- $param = $this->request->only(['companyName', 'parent' => 0, 'customer_member', 'uid', 'uname'], 'post', 'trim');
|
|
|
+ $param = $this->request->only([
|
|
|
+ 'companyName',
|
|
|
+ 'parent' => 0,
|
|
|
+ 'customer_member',
|
|
|
+ 'uid',
|
|
|
+ 'uname',
|
|
|
+ 'branch',
|
|
|
+ 'middle',
|
|
|
+ 'area',
|
|
|
+ ], 'post', 'trim');
|
|
|
|
|
|
$val = Validate::rule([
|
|
|
- 'companyName' => 'require',
|
|
|
- 'customer_member' => 'require|array|max:100',
|
|
|
+ 'companyName|客户名称' => 'require',
|
|
|
+ 'customer_member|联系方式' => 'require|array|max:100',
|
|
|
'uid' => 'require|number|gt:0',
|
|
|
- 'uname' => 'require',
|
|
|
+ 'uname|创建人' => 'require',
|
|
|
+ 'branch|省级' => 'require',
|
|
|
+ 'middle|市级' => 'require',
|
|
|
+ 'area|区域' => 'require',
|
|
|
]);
|
|
|
|
|
|
if ($val->check($param) == false) return json_show(1004, $val->getError());
|
|
|
-
|
|
|
-// $token = isset($this->post['token']) && $this->post['token'] != '' ? trim($this->post['token']) : "";
|
|
|
-// if ($token == '') {
|
|
|
-// return json_show(1005, "参数token不能为空");
|
|
|
-// }
|
|
|
$companyNo = makeNo("KH");
|
|
|
-// $companyName = isset($this->post['companyName']) && $this->post['companyName'] !== "" ? $this->post['companyName'] : "";
|
|
|
-// if ($companyName == "") {
|
|
|
-// return json_show(1002, "参数companyName不能为空");
|
|
|
-// }
|
|
|
-// $parent = isset($this->post['parent']) && $this->post['parent'] !== "" ? intval($this->post['parent'] ) : "";
|
|
|
$rename = Db::name('customer_org1')
|
|
|
->field('id')
|
|
|
->where(['is_del' => 0, 'id' => $param['parent']])
|
|
@@ -794,23 +805,6 @@ class Headquarters extends BaseController
|
|
|
->findOrEmpty();
|
|
|
|
|
|
if (!empty($item)) return json_show(1002, "公司名称已存在");
|
|
|
-
|
|
|
-// if ($parent === "") {
|
|
|
-// return json_show(1002, "参数parent不能为空");
|
|
|
-// }
|
|
|
- //$itemid = isset($this->post['itemid']) && $this->post['itemid'] !== "" ? intval($this->post['itemid'] ) : "";
|
|
|
-// $customer_member = isset($this->post['customer_member']) && $this->post['customer_member'] !== "" ? $this->post['customer_member'] : "";
|
|
|
-// if ($customer_member == "") {
|
|
|
-// return json_show(1002, "参数customer_member不能为空");
|
|
|
-// }
|
|
|
-// $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']):"";
|
|
|
-// if($status==""){
|
|
|
-// return json_show(1002,"参数status不能为空");
|
|
|
-// }
|
|
|
-// $user = GetUserInfo($token);
|
|
|
-// if (empty($user) || $user['code'] != 0) {
|
|
|
-// return json_show(102, "创建人数据不存在");
|
|
|
-// }
|
|
|
$createrid = $param['uid'];//isset($user["data"]['id']) ? $user["data"]['id'] : "";
|
|
|
$creater = $param['uname'];//isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
|
|
|
Db::startTrans();
|
|
@@ -823,31 +817,13 @@ class Headquarters extends BaseController
|
|
|
"companyName" => $param['companyName'],
|
|
|
"parent" => $param['parent'],
|
|
|
"itemid" => $param['parent'],
|
|
|
- "area" => "",
|
|
|
- "comdepart" => "",
|
|
|
- "commobile" => "",
|
|
|
- "comtel" => "",
|
|
|
- "contactor" => "",
|
|
|
- "depart" => "",
|
|
|
- "mobile" => "",
|
|
|
- "invoice_title" => "",
|
|
|
- "invoice_people" => "",
|
|
|
- "invoice_addr" => "",
|
|
|
- "invoice_mobile" => "",
|
|
|
- "invoice_code" => "",
|
|
|
- "invoice_bank" => "",
|
|
|
- "invoice_bankNo" => "",
|
|
|
- "companyCode" => "",
|
|
|
+ "area" =>$param['area'],
|
|
|
"status" => 0,
|
|
|
- "sales_name" => "",
|
|
|
- "sales_depart" => "",
|
|
|
- "branch" => "",
|
|
|
- "middle" => "",
|
|
|
- "country" => "",
|
|
|
+ "branch" =>$param['branch'],
|
|
|
+ "middle" =>$param['middle'],
|
|
|
"is_del" => 0,
|
|
|
"createrid" => $createrid,
|
|
|
"creater" => $creater,
|
|
|
- "modifier" => "",
|
|
|
"addtime" => $date,
|
|
|
"updatetime" => $date,
|
|
|
];
|
|
@@ -893,6 +869,8 @@ class Headquarters extends BaseController
|
|
|
]);
|
|
|
|
|
|
Db::commit();
|
|
|
+ $data['type']=2;
|
|
|
+ Cache::store("redis")->handler()->lpush("companycopy",json_encode($data,JSON_UNESCAPED_UNICODE));
|
|
|
return json_show(0, "新建成功");
|
|
|
} else throw new Exception('新建失败');
|
|
|
} catch (Exception $e) {
|
|
@@ -904,23 +882,17 @@ class Headquarters extends BaseController
|
|
|
public function cList()
|
|
|
{
|
|
|
$param = $this->request->only(['page' => 1, 'size' => 10, 'companyName' => '', 'status' => '', 'creater' => '', 'start' => '', 'end' => ''], 'post', 'trim');
|
|
|
-
|
|
|
-// $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
|
|
|
-// $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
|
|
|
$where = [["a.is_del", "=", 0]];
|
|
|
-// $companyName = isset($this->post['companyName']) && $this->post['companyName'] !== "" ? trim($this->post['companyName']) : "";
|
|
|
+
|
|
|
if ($param['companyName'] != "") $where[] = ['b.companyName', "like", '%' . $param['companyName'] . '%'];
|
|
|
|
|
|
-// $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"";
|
|
|
+
|
|
|
if ($param['status'] !== "") $where[] = ['status', "=", $param['status']];
|
|
|
|
|
|
-// $creater = isset($this->post['creater']) && $this->post['creater'] !== "" ? intval($this->post['creater']) : "";
|
|
|
if ($param['creater'] != "") $where[] = ['a.creater', "like", '%' . $param['creater'] . '%'];
|
|
|
|
|
|
-// $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
|
|
|
if ($param['start'] !== "") $where[] = ['a.addtime', ">=", date('Y-m-d H:i:s', strtotime($param['start']))];
|
|
|
|
|
|
-// $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
|
|
|
if ($param['end'] !== "") $where[] = ['a.addtime', "<", date('Y-m-d H:i:s', strtotime($param['end']) + 24 * 3600)];
|
|
|
|
|
|
$count = Db::name('customer_member')
|
|
@@ -936,7 +908,7 @@ class Headquarters extends BaseController
|
|
|
->where($where)
|
|
|
->page($page, $param['size'])
|
|
|
->order("addtime desc")
|
|
|
- ->field("a.*,b.companyName,b.parent")
|
|
|
+ ->field("a.*,b.companyName,b.parent,b.area")
|
|
|
->select()
|
|
|
->toArray();
|
|
|
return json_show(0, "获取成功", ['list' => $list, 'count' => $count]);
|
|
@@ -944,15 +916,29 @@ class Headquarters extends BaseController
|
|
|
|
|
|
public function cEdit()
|
|
|
{
|
|
|
- $param = $this->request->only(['id', 'companyName', 'parent', 'customer_member', 'uid', 'uname'], 'post', 'trim');
|
|
|
+ $param = $this->request->only([
|
|
|
+ 'id',
|
|
|
+ 'companyName',
|
|
|
+ 'parent',
|
|
|
+ 'customer_member',
|
|
|
+ 'uid',
|
|
|
+ 'uname',
|
|
|
+ 'branch',
|
|
|
+ 'middle',
|
|
|
+ 'area',
|
|
|
+ ], 'post', 'trim');
|
|
|
|
|
|
$val = Validate::rule([
|
|
|
'id' => 'require|number|gt:0',
|
|
|
- 'companyName' => 'require',
|
|
|
+ 'companyName|客户名称' => 'require',
|
|
|
'parent' => 'require',
|
|
|
- 'customer_member' => 'require|array|max:100',
|
|
|
+ 'customer_member|联系方式' => 'require|array|max:100',
|
|
|
'uid' => 'require|number|gt:0',
|
|
|
- 'uname' => 'require',]);
|
|
|
+ 'uname|修改人' => 'require',
|
|
|
+ 'branch|省级'=> 'require',
|
|
|
+ 'middle|市级'=> 'require',
|
|
|
+ 'area|区域'=> 'require',
|
|
|
+ ]);
|
|
|
|
|
|
if ($val->check($param) == false) return json_show(1004, $val->getError());
|
|
|
|
|
@@ -983,7 +969,9 @@ class Headquarters extends BaseController
|
|
|
$data = [
|
|
|
"id" => $param['id'],
|
|
|
"companyName" => $param['companyName'],
|
|
|
- //"companyNo" => $companyNo,
|
|
|
+ "area" =>$param['area'],
|
|
|
+ "branch" =>$param['branch'],
|
|
|
+ "middle" =>$param['middle'],
|
|
|
"parent" => $param['parent'],
|
|
|
"updatetime" => $date,
|
|
|
];
|
|
@@ -992,18 +980,10 @@ class Headquarters extends BaseController
|
|
|
if ($datainfo) {
|
|
|
|
|
|
foreach ($param['customer_member'] as $value) {
|
|
|
-// $to = GetInfoById($token, ['id' => $value['ownerid']]);
|
|
|
-//
|
|
|
-// if (empty($to) || $to['code'] != 0) {
|
|
|
-// return json_show(1002, "数据拥有者信息不存在");
|
|
|
-// }
|
|
|
+
|
|
|
$item = [];
|
|
|
-// $info = $to['data'];
|
|
|
-// $item['owner'] = $info['nickname'];
|
|
|
-// $item['ownerid'] = $info['id'];
|
|
|
$item['commobile'] = isset($value['commobile']) ? $value['commobile'] : "";
|
|
|
$item['comtel'] = "";
|
|
|
- // $item['id'] =isset($value['id']) ? $value['id'] : "";
|
|
|
isset($value['id']) && $value['id'] !== "" ? $item['id'] = $value['id'] : '';
|
|
|
$item['contactor'] = isset($value['contactor']) ? $value['contactor'] : "";
|
|
|
$item['position'] = isset($value['position']) ? $value['position'] : "";
|
|
@@ -1011,7 +991,6 @@ class Headquarters extends BaseController
|
|
|
$item['qqaccount'] = isset($value['qqaccount']) ? $value['qqaccount'] : "";
|
|
|
$item['email'] = isset($value['email']) ? $value['email'] : "";
|
|
|
$item['comdepart'] = isset($value['comdepart']) ? $value['comdepart'] : "";
|
|
|
- // $item['is_private'] = isset($value['is_private']) ? $value['is_private'] : "";
|
|
|
$item['status'] = $value['status'];
|
|
|
$item['createrid'] = $createrid;
|
|
|
$item['creater'] = $creater;
|
|
@@ -1019,15 +998,8 @@ class Headquarters extends BaseController
|
|
|
$item['is_del'] = 0;
|
|
|
$item['addtime'] = $date;
|
|
|
$item['updatetime'] = $date;
|
|
|
- // $var[]=$item;
|
|
|
-
|
|
|
$vp = Db::name('customer_member')->save($item);
|
|
|
-
|
|
|
-// var_dump(Db::name('customer_member')->getLastSql());
|
|
|
-// $var = array_diff($customer_member,$item);
|
|
|
-// $jsn = json_encode($var);
|
|
|
if ($vp == false) throw new Exception('更新失败');
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//更新汇总表
|
|
@@ -1039,7 +1011,6 @@ class Headquarters extends BaseController
|
|
|
'updaterid' => $param['uid'],
|
|
|
"updatetime" => $date,
|
|
|
]);
|
|
|
-
|
|
|
Db::commit();
|
|
|
return json_show(0, "更新成功");
|
|
|
} else throw new Exception("更新失败");
|