From fd91c0556c4d186a44e095170a9e6e37674e1fa4 Mon Sep 17 00:00:00 2001 From: lccsw <1127794702@qq.com> Date: Thu, 22 Jul 2021 11:04:33 +0800 Subject: [PATCH] edit-api-sign --- admin/controllers/receiver/order/Agent.php | 1 + admin/controllers/receiver/order/Bill.php | 1 + admin/controllers/receiver/order/Ckcar.php | 1 + admin/controllers/receiver/order/Delivery.php | 1 + admin/controllers/receiver/order/Loan.php | 1 + admin/controllers/receiver/order/Sign.php | 4 +- api/controllers/wxapp/liche/Contract.php | 12 ++-- api/controllers/wxapp/liche/User.php | 2 +- api/controllers/wxapp/licheb/Cusorder.php | 4 ++ api/controllers/wxapp/licheb/Customers.php | 14 +++-- common/libraries/receiver/Orders_entity.php | 61 +++++++++++++++---- common/libraries/receiver/Sign_entity.php | 2 +- .../app/licheb/App_licheb_users_model.php | 1 + common/models/auto/Auto_attr_model.php | 2 +- common/models/auto/Auto_brand_model.php | 2 +- common/models/auto/Auto_series_model.php | 2 +- .../receiver/Receiver_clues_cfrom_model.php | 2 +- .../receiver/Receiver_customers_model.php | 2 +- 18 files changed, 82 insertions(+), 33 deletions(-) diff --git a/admin/controllers/receiver/order/Agent.php b/admin/controllers/receiver/order/Agent.php index b1ef5ac4..d1ec1fcc 100644 --- a/admin/controllers/receiver/order/Agent.php +++ b/admin/controllers/receiver/order/Agent.php @@ -27,6 +27,7 @@ class Agent extends HD_Controller{ $t1 = 'lc_receiver_order_agents'; $t2 = 'lc_receiver_orders'; $where = [ + "$t2.id>" => 0, ]; strlen($params['status']) && $where["$t1.status"] = $params['status']; diff --git a/admin/controllers/receiver/order/Bill.php b/admin/controllers/receiver/order/Bill.php index be6d4265..7ec92ab6 100644 --- a/admin/controllers/receiver/order/Bill.php +++ b/admin/controllers/receiver/order/Bill.php @@ -27,6 +27,7 @@ class Bill extends HD_Controller{ $t1 = 'lc_receiver_order_bills'; $t2 = 'lc_receiver_orders'; $where = [ + "$t2.id>" => 0, ]; strlen($params['status']) && $where["$t1.status"] = $params['status']; diff --git a/admin/controllers/receiver/order/Ckcar.php b/admin/controllers/receiver/order/Ckcar.php index 2be21d8a..2e4623f3 100644 --- a/admin/controllers/receiver/order/Ckcar.php +++ b/admin/controllers/receiver/order/Ckcar.php @@ -27,6 +27,7 @@ class Ckcar extends HD_Controller{ $t1 = 'lc_receiver_order_ckcars'; $t2 = 'lc_receiver_orders'; $where = [ + "$t2.id>" => 0, ]; strlen($params['status']) && $where["$t1.status"] = $params['status']; diff --git a/admin/controllers/receiver/order/Delivery.php b/admin/controllers/receiver/order/Delivery.php index 6085db68..1f624bdf 100644 --- a/admin/controllers/receiver/order/Delivery.php +++ b/admin/controllers/receiver/order/Delivery.php @@ -27,6 +27,7 @@ class Delivery extends HD_Controller{ $t1 = 'lc_receiver_order_deliverys'; $t2 = 'lc_receiver_orders'; $where = [ + "$t2.id>" => 0, ]; strlen($params['status']) && $where["$t1.status"] = $params['status']; diff --git a/admin/controllers/receiver/order/Loan.php b/admin/controllers/receiver/order/Loan.php index d8eddfe1..e1245b89 100644 --- a/admin/controllers/receiver/order/Loan.php +++ b/admin/controllers/receiver/order/Loan.php @@ -24,6 +24,7 @@ class Loan extends HD_Controller{ $t1 = 'lc_receiver_order_loans'; $t2 = 'lc_receiver_orders'; $where = [ + "$t2.id>" => 0, ]; strlen($params['status']) && $where["$t1.status"] = $params['status']; diff --git a/admin/controllers/receiver/order/Sign.php b/admin/controllers/receiver/order/Sign.php index ee0f3566..05845ca0 100644 --- a/admin/controllers/receiver/order/Sign.php +++ b/admin/controllers/receiver/order/Sign.php @@ -24,9 +24,11 @@ class Sign extends HD_Controller{ $page = $params['page'] = $params['page'] ? intval($params['page']) : 1; $size = $params['size'] = $params['size'] ? intval($params['size']) : 20; - $where = []; $t1 = 'lc_receiver_order_signs'; $t2 = 'lc_receiver_orders'; + $where = [ + "$t2.id>" => 0, + ]; strlen($params['status']) && $where["$t1.status"] = $params['status']; diff --git a/api/controllers/wxapp/liche/Contract.php b/api/controllers/wxapp/liche/Contract.php index 6f3137c4..c4b84715 100644 --- a/api/controllers/wxapp/liche/Contract.php +++ b/api/controllers/wxapp/liche/Contract.php @@ -22,7 +22,7 @@ class Contract extends Wxapp{ $this->load->model('receiver/order/receiver_order_contracts_model','contracts_model'); $this->load->model('receiver/order/receiver_order_ckcars_model','ckcars_model'); $this->load->model('receiver/order/receiver_order_bills_model','bills_model'); - $this->load->model('receiver/order/receiver_order_deliverys_model','deliverys_model'); + $this->load->model('receiver/order/receiver_order_deliverys_model','deliverys_model'); } protected function get(){ @@ -111,7 +111,7 @@ class Contract extends Wxapp{ switch($type){ case 0: //整车 $sign_img = array_pop($imgs); - $res = $this->sign_entity->merge($sign_img,$img,1050,200,300); + $res = $this->sign_entity->merge($sign_img,$img,1050,230,300); if(!$res){ throw new Exception('签名失败', API_CODE_INVILD_PARAM); } @@ -131,7 +131,7 @@ class Contract extends Wxapp{ break; case 1: //协议 $sign_img = array_pop($imgs); - $res = $this->sign_entity->merge($sign_img,$img,1050,1550,300); + $res = $this->sign_entity->merge($sign_img,$img,1050,1600,300); if(!$res){ throw new Exception('签名失败', API_CODE_INVILD_PARAM); } @@ -144,10 +144,8 @@ class Contract extends Wxapp{ ]; $result = $this->contracts_model->update($update,['id'=>$row['id']]); if($result){ - $this->signs_model->update(['status'=>1],['o_id'=>$id]); - //生成定金订单 $this->load->library('receiver/orders_entity'); - $this->orders_entity->c_order($id,$this->app_id,$this->session); + $this->orders_entity->sign_after($id,$this->app_id,$this->session); throw new Exception('签名成功', API_CODE_SUCCESS); }else{ throw new Exception('签名失败', API_CODE_INVILD_PARAM); @@ -155,7 +153,7 @@ class Contract extends Wxapp{ break; case 2: //确认信息 $sign_img = array_pop($imgs); - $res = $this->sign_entity->merge($sign_img,$img,1050,400,300); + $res = $this->sign_entity->merge($sign_img,$img,1050,430,300); if(!$res){ throw new Exception('签名失败', API_CODE_INVILD_PARAM); } diff --git a/api/controllers/wxapp/liche/User.php b/api/controllers/wxapp/liche/User.php index 8dbbfdf7..73ddc344 100644 --- a/api/controllers/wxapp/liche/User.php +++ b/api/controllers/wxapp/liche/User.php @@ -332,7 +332,7 @@ class User extends Wxapp{ 'progress' => $progress, 'about' => [ ['title'=>'我的爱车','icon'=>'https://qs.haodian.cn/wechat_app/liche/mine/list-icon-1.png','url'=>'/pages/mine/myCar/index'], - ['title'=>'联系阿狸','icon'=>'https://qs.haodian.cn/wechat_app/liche/mine/list-icon-3.png'] + ['title'=>'联系小狸','icon'=>'https://qs.haodian.cn/wechat_app/liche/mine/list-icon-3.png'] ], 'order' => [ ['title' => '全部订单', 'icon' => 'https://qs.haodian.cn/wechat_app/liche/mine/order-icon-1.png', 'url' => '/pages/order/index?typeId=0'], diff --git a/api/controllers/wxapp/licheb/Cusorder.php b/api/controllers/wxapp/licheb/Cusorder.php index b5f3370e..492b6b10 100644 --- a/api/controllers/wxapp/licheb/Cusorder.php +++ b/api/controllers/wxapp/licheb/Cusorder.php @@ -53,6 +53,10 @@ class Cusorder extends Wxapp{ if(!$row || !$series_row){ throw new Exception('参数错误', ERR_PARAMS_ERROR); } + //判断是否存在未完成流程 + if($this->orders_model->get_step($row['mobile'])){ + throw new Exception('该手机号用户存在未完成订单', API_CODE_FAIL); + } $where = [ "id in ($v_id,$color_id,$incolor_id)" => null ]; diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index 9a0fd496..55ccdfae 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -101,6 +101,9 @@ class Customers extends Wxapp{ if(!$name || !$car_id || !$v_id || !$color_id){ throw new Exception('参数错误', ERR_PARAMS_ERROR); } + if($this->customers_model->count(['biz_id'=>$biz_id,'mobile'=>$mobile])){ + throw new Exception('客户已存在', API_CODE_FAIL); + } $row = $this->auto_series_model->get(['id'=>$car_id]); $where = [ "id in ($v_id,$color_id)" => null @@ -352,14 +355,14 @@ class Customers extends Wxapp{ $admin_id = $this->input_param('admin_id'); $admin = $this->app_user_model->get(['id'=>$admin_id,'status'=>1]); - if (!$ids || !$admin) { + if (!$id_arr || !$admin) { throw new Hd_exception('参数错误', API_CODE_INVILD_PARAM); } $ids = implode(',', $id_arr); $ret = $this->customers_model->update(['admin_id' => $admin_id], ["id in ({$ids})" => null]); if (is_bool($ret)) { - debug_log("[error]# " . $this->orders_model->db->last_query(), __FUNCTION__, $this->log_dir); + debug_log("[error]# " . $this->customers_model->db->last_query(), __FUNCTION__, $this->log_dir); throw new Exception('分派失败', API_CODE_FAIL); } //写日志 @@ -367,10 +370,11 @@ class Customers extends Wxapp{ $this->load->library('receiver/customers_entity'); $customers = $this->customers_model->get_map_by_ids ($id_arr,'id,rid'); foreach($id_arr as $val){ - if($customers[$val]['rid']){ //更新线索跟进人 - $this->clues_model->update(['admin_id'=>$admin_id,'status'=>2],['id'=>$customers[$val]['rid']]); + $rid = $customers[$val][0]['rid']; //线索id + if($rid){ //更新线索跟进人 + $this->clues_model->update(['admin_id'=>$admin_id,'status'=>2],['id'=>$rid]); } - $log = "【$uname】分配客户"; + $log = "【{$uname}】分配客户"; $this->customers_entity->add_log($val,$uid,$uname,$log); } throw new Exception('分配成功', API_CODE_SUCCESS); diff --git a/common/libraries/receiver/Orders_entity.php b/common/libraries/receiver/Orders_entity.php index 0d69aa54..4a5458ef 100644 --- a/common/libraries/receiver/Orders_entity.php +++ b/common/libraries/receiver/Orders_entity.php @@ -45,22 +45,57 @@ class Orders_entity{ } /** - * 创建定金消费订单 - * @param $oid int 订单id - * return boolean + * 签完成协议后操作 + * @param $oid int 订单id + * @param $app_id int 小程序id + * @param $userinfo array() 小程序用户信息 */ - public function c_order($oid,$app_id,$userinfo){ + public function sign_after($oid,$app_id,$userinfo){ $this->ci->load->model('receiver/order/receiver_orders_model','orders_model'); + $this->ci->load->model('receiver/order/receiver_order_signs_model','signs_model'); + $this->ci->load->model('receiver/receiver_customers_model','customers_model'); $this->ci->load->model('apporder/order_purchase_model'); - $this->ci->load->model('auto/auto_series_model'); - $this->ci->load->model('auto/auto_brand_model'); $row = $this->ci->orders_model->get(['id'=>$oid]); if(!$row){ return false; } - $brand = $this->ci->auto_brand_model->get(['id'=>$row['brand_id']],'name'); - $series = $this->ci->auto_series_model->get(['id'=>$row['s_id']],'name'); - $car_json = json_decode($row['car_json'],true); + $customers = $this->ci->customers_model->get(['id'=>$row['rid']],'rid'); + $ifpay = false; + if($customers['rid']){ //判断线索是否支付定金 + $ifpay = $this->ci->order_purchase_model->count(['type'=>3,'status'=>2,'cf_id'=>$customers['rid'],'app_id'=>$app_id,'app_uid'=>$userinfo['uid']]); + } + if($ifpay){ + $this->ci->signs_model->update(['status'=>2],['o_id'=>$oid]); + if($row['payway']){//全款 + $status = 2; + $this->ci->load->model('receiver/order/receiver_order_ckcars_model','next_model'); + }else{ + $status = 1; + $this->ci->load->model('receiver/order/receiver_order_loans_model','next_model'); + } + $res = $this->ci->orders_model->update(['status'=>$status],['id'=>$row['id']]); + if($res){ + $this->ci->next_model->add(['o_id'=>$row['id'],'c_time'=>time()]); + } + }else{ + $this->ci->signs_model->update(['status'=>1],['o_id'=>$row['id']]); + $res = $this->c_order($row,$app_id,$userinfo); + } + return $res; + } + /** + * 创建定金消费订单 + * @param $oder array 订单数据 + * return boolean + */ + public function c_order($order,$app_id,$userinfo){ + $this->ci->load->model('apporder/order_purchase_model'); + $this->ci->load->model('auto/auto_series_model'); + $this->ci->load->model('auto/auto_brand_model'); + + $brand = $this->ci->auto_brand_model->get(['id'=>$order['brand_id']],'name'); + $series = $this->ci->auto_series_model->get(['id'=>$order['s_id']],'name'); + $car_json = json_decode($order['car_json'],true); $color = isset($car_json['color']) ? $car_json['color'] : ''; $sid = create_order_no(350200,'liche',1,2); @@ -72,12 +107,12 @@ class Orders_entity{ 'app_id' => $app_id, 'app_uid' => $userinfo['uid'], 'sid' => $sid, - 'item_id' => $row['id'], + 'item_id' => $order['id'], 'item_title' => $brand['name'].$series['name'], 'item_num' => 1, 'type' => 4, - 'item_price' => $row['deposit'], - 'total_price' => $row['deposit'], + 'item_price' => $order['deposit'], + 'total_price' => $order['deposit'], 'uname' => $userinfo['nickname'], 'mobile' => $userinfo['mobile'], 'payway' => 1, @@ -85,7 +120,7 @@ class Orders_entity{ 'status_detail' => 11, 'jsondata' => json_encode($jsondata,JSON_UNESCAPED_UNICODE), 'c_time' => time(), - 'cf_id' => $oid + 'cf_id' => $order['id'] ]; $result = $this->ci->order_purchase_model->add($add_data); return $result; diff --git a/common/libraries/receiver/Sign_entity.php b/common/libraries/receiver/Sign_entity.php index e6748870..6119aea4 100644 --- a/common/libraries/receiver/Sign_entity.php +++ b/common/libraries/receiver/Sign_entity.php @@ -42,7 +42,7 @@ class Sign_entity{ !$s_path && $s_path = FCPATH.'temp/'.md5('sign'.$file_name).'.jpg'; $yhdata = file_get_contents($user_file,false,stream_context_create($arrContextOptions)); - $yh_image = Image::fromData($yhdata)->cropResize(150,150)->rotate(-90); + $yh_image = Image::fromData($yhdata)->cropResize(150,150)->rotate(90); //原始签名文件 diff --git a/common/models/app/licheb/App_licheb_users_model.php b/common/models/app/licheb/App_licheb_users_model.php index 668eac5f..57afb0f1 100755 --- a/common/models/app/licheb/App_licheb_users_model.php +++ b/common/models/app/licheb/App_licheb_users_model.php @@ -19,6 +19,7 @@ class App_licheb_users_model extends HD_Model{ */ public function get_map_by_ids($ids,$fileds=''){ $rows = []; + $ids = array_filter($ids); if($ids){ $cf_ids = implode(',',$ids); $where = [ diff --git a/common/models/auto/Auto_attr_model.php b/common/models/auto/Auto_attr_model.php index 1a34f645..02d45529 100644 --- a/common/models/auto/Auto_attr_model.php +++ b/common/models/auto/Auto_attr_model.php @@ -25,8 +25,8 @@ class Auto_attr_model extends HD_Model{ public function get_map_by_ids($ids, $fileds = '') { $rows = []; + $ids = array_filter($ids); if ($ids) { - $ids = array_filter($ids); $cf_ids = implode(',', $ids); $where = [ "id in ($cf_ids)" => null diff --git a/common/models/auto/Auto_brand_model.php b/common/models/auto/Auto_brand_model.php index 444841e4..c19850bd 100644 --- a/common/models/auto/Auto_brand_model.php +++ b/common/models/auto/Auto_brand_model.php @@ -27,8 +27,8 @@ class Auto_brand_model extends HD_Model public function get_map_by_ids($ids, $fileds = '') { $rows = []; + $ids = array_filter($ids); if ($ids) { - $ids = array_filter($ids); $cf_ids = implode(',', $ids); $where = [ "id in ($cf_ids)" => null diff --git a/common/models/auto/Auto_series_model.php b/common/models/auto/Auto_series_model.php index 2bb28663..218a3708 100644 --- a/common/models/auto/Auto_series_model.php +++ b/common/models/auto/Auto_series_model.php @@ -25,8 +25,8 @@ class Auto_series_model extends HD_Model{ public function get_map_by_ids($ids, $fileds = '') { $rows = []; + $ids = array_filter($ids); if ($ids) { - $ids = array_filter($ids); $cf_ids = implode(',', $ids); $where = [ "id in ($cf_ids)" => null diff --git a/common/models/receiver/Receiver_clues_cfrom_model.php b/common/models/receiver/Receiver_clues_cfrom_model.php index 66d9bc41..df094e7f 100644 --- a/common/models/receiver/Receiver_clues_cfrom_model.php +++ b/common/models/receiver/Receiver_clues_cfrom_model.php @@ -23,8 +23,8 @@ class Receiver_clues_cfrom_model extends HD_Model */ public function get_map_by_ids($ids,$fileds=''){ $rows = []; + $ids = array_filter($ids); if($ids){ - $ids = array_filter($ids); if($ids){ $cf_ids = implode(',',$ids); $where = [ diff --git a/common/models/receiver/Receiver_customers_model.php b/common/models/receiver/Receiver_customers_model.php index 1bba1a7b..e121708c 100644 --- a/common/models/receiver/Receiver_customers_model.php +++ b/common/models/receiver/Receiver_customers_model.php @@ -27,8 +27,8 @@ class Receiver_customers_model extends HD_Model public function get_map_by_ids($ids, $fileds = '') { $rows = []; + $ids = array_filter($ids); if ($ids) { - $ids = array_filter($ids); $cf_ids = implode(',', $ids); $where = [ "id in ($cf_ids)" => null