From d97403b389fc53fc1838597e9c6e4a9dc0d5370b Mon Sep 17 00:00:00 2001 From: lccsw <1127794702@qq.com> Date: Wed, 28 Jul 2021 20:13:44 +0800 Subject: [PATCH] edit-licheb --- admin/views/receiver/orders/loaninfo.php | 2 +- api/controllers/wxapp/liche/Car.php | 13 +++++++++++- api/controllers/wxapp/licheb/Cusorder.php | 3 ++- api/controllers/wxapp/licheb/Customers.php | 6 ++++-- api/controllers/wxapp/licheb/Employees.php | 5 +++-- api/controllers/wxapp/licheb/User.php | 21 +++++++++++-------- .../app/licheb/App_licheb_users_model.php | 4 ++++ common/services/apporder/Payment_service.php | 15 +++++++++++-- 8 files changed, 51 insertions(+), 18 deletions(-) diff --git a/admin/views/receiver/orders/loaninfo.php b/admin/views/receiver/orders/loaninfo.php index 372c5f50..008b698b 100644 --- a/admin/views/receiver/orders/loaninfo.php +++ b/admin/views/receiver/orders/loaninfo.php @@ -23,7 +23,7 @@
- +
diff --git a/api/controllers/wxapp/liche/Car.php b/api/controllers/wxapp/liche/Car.php index 54238874..e33be98f 100644 --- a/api/controllers/wxapp/liche/Car.php +++ b/api/controllers/wxapp/liche/Car.php @@ -21,7 +21,7 @@ class Car extends Wxapp{ $this->load->model('auto/auto_brand_model'); $this->load->model('auto/auto_series_model'); $this->load->model('auto/auto_attr_model'); - + $this->load->model('receiver/receiver_customers_model'); } protected function get(){ @@ -149,6 +149,17 @@ class Car extends Wxapp{ if(!$order_id){ throw new Exception('创建订单失败', API_CODE_INVILD_PARAM); } + //判断是否存在客户,存在时关联 + $where = [ + 'rid' => 0, + 'mobile' => $this->session['mobile'], + 'status>' => -1 + ]; + $rows = $this->receiver_customers_model->select($where,'','','','id'); + if($rows && count($rows)==1){ //不存在和大于1条不处理 + $cus = $rows[0]; + $this->receiver_customers_model->update(['rid'=>$id],['id'=>$cus['id']]); + } $this->clues_model->update(['out_id'=>$order_id],['id'=>$id]); $data['sid'] = $sid; return $data; diff --git a/api/controllers/wxapp/licheb/Cusorder.php b/api/controllers/wxapp/licheb/Cusorder.php index 485e13ec..636b4e98 100644 --- a/api/controllers/wxapp/licheb/Cusorder.php +++ b/api/controllers/wxapp/licheb/Cusorder.php @@ -167,12 +167,13 @@ class Cusorder extends Wxapp{ $biz_id = $this->session['biz_id']; $keyword = $this->input_param('keyword'); $status = $this->input_param('status'); + $ismy = $this->input_param('ismy'); //是否只显示自己 $where = [ 'biz_id' => $biz_id ]; - if($group_id==1){ //销售 + if($group_id==1 || $ismy){ //销售 $where ["admin_id"] = $uid; } diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index a949c266..9c10897e 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -138,6 +138,7 @@ class Customers extends Wxapp{ 'level' => $level, 'cf_title' => '自行到店', 'car_json' => json_encode($car_json,JSON_UNESCAPED_UNICODE), + 'cont_time' => date('Y-m-d H:i:s'), 'c_time' => time() ]; $buy_time && $add_data['buy_time'] = date('Y-m-d H:i:s',strtotime($buy_time)); @@ -261,6 +262,7 @@ class Customers extends Wxapp{ $istop = $this->input_param('istop'); $iscall = $this->input_param('iscall'); $unuse = $this->input_param('unuse'); //未派客户 + $ismy = $this->input_param('ismy'); //是否只显示自己 !$page && $page = 1; !$size && $size = 10; @@ -277,8 +279,8 @@ class Customers extends Wxapp{ 'biz_id' => $biz_id ]; - if($group_id==1){ //销售 - $where ["admin_id=$uid or admin_id=0"] = null; + if($group_id==1 || $ismy){ //销售 + $where ["admin_id"] = $uid; } if($s_time && $e_time){ $where['c_time >='] = strtotime($s_time); diff --git a/api/controllers/wxapp/licheb/Employees.php b/api/controllers/wxapp/licheb/Employees.php index 754d1c90..f29c4ccf 100644 --- a/api/controllers/wxapp/licheb/Employees.php +++ b/api/controllers/wxapp/licheb/Employees.php @@ -27,15 +27,16 @@ class Employees extends Wxapp{ !$page && $page = 1; !$size && $size = 10; $uid = $this->session['uid']; + $biz_id = $this->session['biz_id']; if($ifconf){ $where = [ - "(pid=$uid or id=$uid)" => null, + "(biz_id=$biz_id or id=$uid)" => null, 'status' => 1 ]; }else{ $where = [ - 'pid' => $this->session['uid'], + 'biz_id' => $biz_id, 'status>' => -1 ]; } diff --git a/api/controllers/wxapp/licheb/User.php b/api/controllers/wxapp/licheb/User.php index 4aef46e8..3e39fe4d 100644 --- a/api/controllers/wxapp/licheb/User.php +++ b/api/controllers/wxapp/licheb/User.php @@ -86,12 +86,15 @@ class User extends Wxapp{ //获取所属店铺字段 $this->load->model("biz/biz_model"); $biz = $this->biz_model->get(['id'=>$this->session['biz_id']],'biz_name'); + $group_arr = $this->app_user_model->get_group(); + $group_name = $group_arr[$user['group_id']] ? $group_arr[$user['group_id']] : ''; $data = array( 'uid' => $uid, 'uname' => $user['uname'], 'mobile' => $user['mobile'], 'group_id' => $user['group_id'], + 'group_name' => $group_name, 'biz_name' => $biz['biz_name'] ? $biz['biz_name'] : '' ); @@ -108,15 +111,15 @@ class User extends Wxapp{ $this->load->model('receiver/receiver_customers_model','customers_model'); $this->load->model('receiver/order/receiver_orders_model','orders_model'); $this->load->model('receiver/order/receiver_order_signs_model','order_signs_model'); - $wl_count = $this->customers_model->count(["cont_time = '0000-00-00 00:00:00'"=>null,'admin_id'=>$uid]); - $gz_count = $this->customers_model->count(['status>'=>-1,'is_top'=>1,'admin_id'=>$uid]); - $sign_count = $this->orders_model->count(['status'=>0,'admin_id'=>$uid]); - $loan_count = $this->orders_model->count(['status'=>1,'admin_id'=>$uid]); + $wl_count = $this->customers_model->count(["cont_time = '0000-00-00 00:00:00'"=>null,'admin_id'=>$uid,'biz_id'=>$biz_id]); + $gz_count = $this->customers_model->count(['status>'=>-1,'is_top'=>1,'admin_id'=>$uid,'biz_id'=>$biz_id]); + $sign_count = $this->orders_model->count(['status'=>0,'admin_id'=>$uid,'biz_id'=>$biz_id]); + $loan_count = $this->orders_model->count(['status'=>1,'admin_id'=>$uid,'biz_id'=>$biz_id]); //未派单客户 $unuse_count = $this->customers_model->count(['admin_id'=>0,'biz_id'=>$biz_id]); //为创建订单客户 - $uncre_count = $this->customers_model->count_order(['lc_receiver_orders.id is null'=>null,'lc_receiver_customers.admin_id'=>$uid]); + $uncre_count = $this->customers_model->count(['status'=>2,'admin_id'=>$uid,'biz_id'=>$biz_id]); $t1 = 'lc_receiver_order_signs'; $t2 = 'lc_receiver_orders'; $need_sign = $this->order_signs_model->count_order(["$t1.status"=>0,"$t2.admin_id"=>$uid]);//需要签名 @@ -125,10 +128,10 @@ class User extends Wxapp{ $del_count = $this->orders_model->count(['status'=>5,'admin_id'=>$uid]);//交付确认 $deallist = [ ['title'=>'需登记订单','icon'=>'icon-dengji','total'=>$uncre_count,'page'=>'/pages/order/register/index'], - ['title'=>'需邀请签名','icon'=>'icon-qianming1','total'=>$need_sign,'page'=>'/pages/order/filterList/index?key=0'], - ['title'=>'未选择分期','icon'=>'icon-fenpei','total'=>$loan_count,'page'=>'/pages/order/filterList/index?key=1'], - ['title'=>'开票相关','icon'=>'icon-kaipiao1','total'=>$bill_count,'page'=>'/pages/order/filterList/index?key=3'], - ['title'=>'交付确认','icon'=>'icon-jiaofu','total'=>$del_count,'page'=>'/pages/order/filterList/index?key=5'], + ['title'=>'需邀请签名','icon'=>'icon-qianming1','total'=>$need_sign,'page'=>'/pages/order/filterList/index?key=0&ismy=1'], + ['title'=>'未选择分期','icon'=>'icon-fenpei','total'=>$loan_count,'page'=>'/pages/order/filterList/index?key=1&ismy=1'], + ['title'=>'开票相关','icon'=>'icon-kaipiao1','total'=>$bill_count,'page'=>'/pages/order/filterList/index?key=3&ismy=1'], + ['title'=>'交付确认','icon'=>'icon-jiaofu','total'=>$del_count,'page'=>'/pages/order/filterList/index?key=5&ismy=1'], ]; $data = [ 'wl_count' => $wl_count, diff --git a/common/models/app/licheb/App_licheb_users_model.php b/common/models/app/licheb/App_licheb_users_model.php index 57afb0f1..35a91024 100755 --- a/common/models/app/licheb/App_licheb_users_model.php +++ b/common/models/app/licheb/App_licheb_users_model.php @@ -9,6 +9,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); class App_licheb_users_model extends HD_Model{ private $table_name = 'lc_app_licheb_users'; + private $group_arr = [ 1 => '销售',2 => '店长',3 => '老板']; public function __construct() { parent::__construct($this->table_name, 'default'); @@ -29,4 +30,7 @@ class App_licheb_users_model extends HD_Model{ } return $rows; } + public function get_group(){ + return $this->group_arr; + } } diff --git a/common/services/apporder/Payment_service.php b/common/services/apporder/Payment_service.php index c28b8b8c..dddb4b78 100644 --- a/common/services/apporder/Payment_service.php +++ b/common/services/apporder/Payment_service.php @@ -14,6 +14,11 @@ class Payment_service extends HD_Service{ } $this->log_file = __CLASS__."_app_id_".$this->app_id.'.log'; $this->load->model('apporder/order_purchase_model', 'purchase_model'); + $this->load->model('receiver/receiver_clues_model','clues_model'); + $this->load->model('receiver/receiver_customers_model','customers_model'); + + $this->load->model('receiver/order/receiver_orders_model','orders_model'); + $this->load->model('receiver/order/receiver_order_signs_model','order_signs_model'); } @@ -44,6 +49,14 @@ class Payment_service extends HD_Service{ $pay_price && $upd['pay_price'] = $pay_price; $res = $this->purchase_model->update($upd,array('id'=>$order['id'])); if($res){ + //判断客户是否存在 + $clues = $this->clues_model->get(['id'=>$order['cf_id']]); + if($clues){ + $cus = $this->customers_model->get(['rid'=>$clues['id']]); + if($cus){ + $this->customers_model->update(['status'=>2],['id'=>$cus['id']]); + } + } return array('code'=>1,'msg'=>'操作成功'); }else{ return array('code'=>0,'msg'=>'更新失败'); @@ -55,8 +68,6 @@ class Payment_service extends HD_Service{ $res = $this->purchase_model->update($upd,array('id'=>$order['id'])); if($res){ //更新订单状态 - $this->load->model('receiver/order/receiver_orders_model','orders_model'); - $this->load->model('receiver/order/receiver_order_signs_model','order_signs_model'); $row = $this->orders_model->get(['id'=>$order['item_id']]); if($row){ if($row['payway']){//全款