From 70f737851fe74805eb1f32e23d5fe57ef1817098 Mon Sep 17 00:00:00 2001 From: dengbw Date: Tue, 26 Jul 2022 14:02:56 +0800 Subject: [PATCH] persona_726 --- api/controllers/wxapp/licheb/Customers.php | 1 + api/controllers/wxapp/licheb/Employees.php | 80 +++++++++++++++++----- home/controllers/h5/Persona.php | 14 ++++ 3 files changed, 78 insertions(+), 17 deletions(-) diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index 619441ca..bc4f04ac 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -256,6 +256,7 @@ class Customers extends Wxapp 'mobile' => $mobile, 'biz_id' => $this->biz_id, 'admin_id' => $this->session['uid'], + 'sales_id' => $this->session['uid'], 'level' => $level, 'cf_title' => '自有资源', 'cont_time' => $time, diff --git a/api/controllers/wxapp/licheb/Employees.php b/api/controllers/wxapp/licheb/Employees.php index 0d4bc86b..f1df64ef 100644 --- a/api/controllers/wxapp/licheb/Employees.php +++ b/api/controllers/wxapp/licheb/Employees.php @@ -11,6 +11,7 @@ require_once APPPATH . 'controllers/wxapp/Wxapp.php'; class Employees extends Wxapp { + private $biz_id; function __construct($inputs, $app_key) { @@ -20,6 +21,61 @@ class Employees extends Wxapp $this->check_status = array();//用户状态校验 $this->check_mobile = array();//需要手机号 $this->check_headimg = array();//授权微信信息 + $this->biz_id = $this->get_biz_id(); + } + + /** + * Notes:获取离职 + * Created on: 2022/7/25 16:30 + * Created by: dengbw + * @return mixed + * @throws Exception + */ + public function get_leave() + { + $id = $this->input_param('id'); + $id = 21; + if (!$id) { + throw new Exception('参数错误', ERR_PARAMS_ERROR); + } + $this->load->model('receiver/receiver_customers_model', 'mdCustomer'); + $this->load->model('receiver/order/receiver_orders_v2_model', 'mdOrders'); + $count_1 = $this->mdCustomer->count(['biz_id' => $this->biz_id, 'admin_id' => $id]); + $count_2 = $this->mdOrders->count(['biz_id' => $this->biz_id, 'sale_id' => $id]); + $data['transfer'] = ['title' => '移交', 'list' => [['key' => 1, 'name' => "客户($count_1)"], ['key' => 2, 'name' => "订单($count_2)"]]]; + $where = ['status' => 1, 'id<>' => $id, 'biz_id' => $this->biz_id]; + $res = $this->app_user_model->select($where, 'id desc', 0, 0, 'id,uname as name'); + $data['adviser'] = ['title' => '顾问', 'list' => $res ? $res : []]; + return $data; + } + + /** + * Notes:提交离职 + * Created on: 2022/7/25 16:58 + * Created by: dengbw + * @throws Exception + */ + public function put_leave() + { + $out_id = $this->input_param('out_id'); + $in_id = $this->input_param('in_id'); + $keys = $this->input_param('keys'); + if (!$out_id || $in_id) { + throw new Exception('参数错误', ERR_PARAMS_ERROR); + } + if (!$keys) { + throw new Exception('请选择移交项', ERR_PARAMS_ERROR); + } + $this->load->model('receiver/receiver_customers_model', 'mdCustomer'); + $this->load->model('receiver/order/receiver_orders_v2_model', 'mdOrders'); + foreach ($keys as $k) { + if ($k == 1) {//移交客户 + $this->mdCustomer->update(['admin_id' => $in_id], ['biz_id' => $this->biz_id, 'admin_id' => $out_id]); + } else if ($k == 2) {//移交订单 + $this->mdOrders->update(['admin_id' => $in_id], ['biz_id' => $this->biz_id, 'admin_id' => $out_id]); + } + } + throw new Exception('操作成功', API_CODE_SUCCESS); } public function get() @@ -27,34 +83,29 @@ class Employees extends Wxapp $ifconf = $this->input_param('ifconf'); $page = $this->input_param('page'); $size = $this->input_param('size'); - !$page && $page = 1; !$size && $size = 10; $uid = $this->session['uid']; - $biz_id = $this->get_biz_id(); - if ($ifconf) { $where = [ - "(biz_id=$biz_id or id=$uid)" => null, + "(biz_id=$this->biz_id or id=$uid)" => null, 'status' => 1 ]; } else { $where = [ - 'biz_id' => $biz_id, + 'biz_id' => $this->biz_id, 'status>' => -1 ]; } - $count = $this->app_user_model->count($where); - $lists = []; + $lists = $tabs = $bizs = []; if ($count) { $fileds = 'id,uname,mobile,status'; $rows = $this->app_user_model->select($where, 'id desc', $page, $size, $fileds); $lists = $rows; } $this->load->model("biz/biz_model"); - $tabs = $bizs = []; - $re_biz = $this->biz_model->get(['id' => $biz_id, 'status' => 1]); + $re_biz = $this->biz_model->get(['id' => $this->biz_id, 'status' => 1]); if ($re_biz['type'] == 1) {//品牌店 $tabs = [['id' => 1, 'name' => '本店'], ['id' => 2, 'name' => '其它门店']]; $bizs = $this->biz_model->select(['type' => 1, 'status' => 1], 'id desc', 0, 0, 'id, biz_name as name'); @@ -70,7 +121,6 @@ class Employees extends Wxapp protected function post() { - $biz_id = $this->get_biz_id(); $group_id = $this->session['group_id']; $name = $this->input_param('name'); $mobile = $this->input_param('mobile'); @@ -90,7 +140,7 @@ class Employees extends Wxapp 'mobile' => $mobile, 'uname' => $name, 'group_id' => 1, - 'biz_id' => $biz_id, + 'biz_id' => $this->biz_id, 'c_time' => time() ]; $result = $this->app_user_model->add($data); @@ -105,10 +155,8 @@ class Employees extends Wxapp { $id = $this->input_param('id'); $status = $this->input_param('status'); - $biz_id = $this->get_biz_id(); $where = [ - //'pid' => $this->session['uid'], - 'biz_id' => $biz_id, + 'biz_id' => $this->biz_id, 'id' => $id ]; $row = $this->app_user_model->get($where); @@ -126,10 +174,8 @@ class Employees extends Wxapp protected function delete() { $id = $this->input_param('id'); - $biz_id = $this->get_biz_id(); $where = [ - //'pid' => $this->session['uid'], - 'biz_id' => $biz_id, + 'biz_id' => $this->biz_id, 'id' => $id ]; $row = $this->app_user_model->get($where); diff --git a/home/controllers/h5/Persona.php b/home/controllers/h5/Persona.php index 4ac49550..b0e70821 100644 --- a/home/controllers/h5/Persona.php +++ b/home/controllers/h5/Persona.php @@ -240,6 +240,12 @@ class Persona extends CI_Controller if (!$re_cus2) { $this->show_json(200, '客户不存在'); } + if ($params['of_id'] == 1 && ($re_cus2['dt_time'] == '0000-00-00 00:00:00')) {//自然到店,变更为到店客户 + $up_data['status'] = 1; + $up_data['a_num'] = 1; + $up_data['dt_time'] = date('Y-m-d H:i:s'); + $this->customers_entity->add_log($c_id, $uid, $uname, "客户到店", 4); + } $re_cus2['wxqy'] != 1 && $up_data['wxqy'] = 1; !$re_cus2['unionid'] && $up_data['unionid'] = $userInfo['unionid']; $result = $this->mdCustomers->update($up_data, ['id' => $c_id]); @@ -275,6 +281,11 @@ class Persona extends CI_Controller 'p_time' => $date,//分配时间 'c_time' => time() ]; + if ($add_data['of_id'] == 1) {//自然到店,变更为到店客户 + $add_data['status'] = 1; + $add_data['a_num'] = 1; + $add_data['dt_time'] = date('Y-m-d H:i:s'); + } $c_id = $this->mdCustomers->add($add_data); if ($c_id) {//加日志 $result = true; @@ -287,6 +298,9 @@ class Persona extends CI_Controller } } $this->customers_entity->add_log($c_id, $uid, $uname, '创建客户档案', 3); + if ($add_data['status'] == 1) {//到店客户加日志 + $this->customers_entity->add_log($c_id, $uid, $uname, "客户到店", 4); + } } } }