diff --git a/api/controllers/wxapp/licheb/CusorderV2.php b/api/controllers/wxapp/licheb/CusorderV2.php
index 71e661ed..8099118b 100644
--- a/api/controllers/wxapp/licheb/CusorderV2.php
+++ b/api/controllers/wxapp/licheb/CusorderV2.php
@@ -7,27 +7,30 @@ defined('WXAPP_APP') OR exit('No direct script access allowed');
* Date: 2021/07/09
* Time: 14:08
*/
-require_once APPPATH.'controllers/wxapp/Wxapp.php';
-class CusorderV2 extends Wxapp{
+require_once APPPATH . 'controllers/wxapp/Wxapp.php';
+
+class CusorderV2 extends Wxapp
+{
private $biz_id = '';
- function __construct($inputs, $app_key){
+ function __construct($inputs, $app_key)
+ {
parent::__construct($inputs, $app_key);
$this->login_white = array();//登录白名单
$this->check_status = array();//用户状态校验
$this->check_mobile = array();//需要手机号
- $this->check_headimg =array();//授权微信信息
+ $this->check_headimg = array();//授权微信信息
- $this->load->model('receiver/receiver_customers_model','customers_model');
+ $this->load->model('receiver/receiver_customers_model', 'customers_model');
$this->load->model('receiver/order/receiver_orders_model');
- $this->load->model('receiver/order/receiver_orders_v2_model','orders_model');
+ $this->load->model('receiver/order/receiver_orders_v2_model', 'orders_model');
$this->load->model('receiver/order/receiver_order_datas_model');
$this->load->model('receiver/order/receiver_order_status_model');
- $this->load->model('receiver/order/receiver_order_deliverys_model','order_deliverys_model');
+ $this->load->model('receiver/order/receiver_order_deliverys_model', 'order_deliverys_model');
$this->load->model('receiver/order/receiver_order_loans_model', 'order_loans_model');
- $this->load->model('receiver/order/receiver_order_bills_model','order_bills_model');
+ $this->load->model('receiver/order/receiver_order_bills_model', 'order_bills_model');
$this->load->model('auto/auto_series_model');
$this->load->model('auto/auto_attr_model');
@@ -50,17 +53,19 @@ class CusorderV2 extends Wxapp{
$this->biz_id = $this->get_biz_id();
}
- protected function get(){
+ protected function get()
+ {
$id = $this->input_param('id');
- if($id){
+ if ($id) {
return $this->detail($id);
- }else{
+ } else {
return $this->lists();
}
}
//创建订单
- protected function post(){
+ protected function post()
+ {
$cus_id = $this->input_param('cus_id');
$car_id = $this->input_param('car_id');
$color_id = $this->input_param('color_id');
@@ -91,22 +96,22 @@ class CusorderV2 extends Wxapp{
$sa = $this->input_param('sa'); //补充协商
$if_local_bill = $this->input_param('if_local_bill');//是否需要开具本地发票
- $row = $this->customers_model->get(['id'=>$cus_id]);
- $series_row = $this->auto_series_model->get(['id'=>$car_id]);
- $business_row = $this->auto_business_model->get(['id'=>$business_id]);
- if(!$row || !$series_row ||!$delry_time || !$name || !$mobile || !$business_row || !$deposit){
+ $row = $this->customers_model->get(['id' => $cus_id]);
+ $series_row = $this->auto_series_model->get(['id' => $car_id]);
+ $business_row = $this->auto_business_model->get(['id' => $business_id]);
+ if (!$row || !$series_row || !$delry_time || !$name || !$mobile || !$business_row || !$deposit) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
- if($if_local_bill && !$car_city_id){
+ if ($if_local_bill && !$car_city_id) {
throw new Exception('请填写上牌城市', ERR_PARAMS_ERROR);
}
- if($main_type){//公司
- if(!$company || !$c_credit){
+ if ($main_type) {//公司
+ if (!$company || !$c_credit) {
throw new Exception('请填写公司信息', ERR_PARAMS_ERROR);
}
$owner_name = $company;
- }else{ //个人
- if(!$cardid || !$owner_name || !$owner_mobile || !$owner_cardid){
+ } else { //个人
+ if (!$cardid || !$owner_name || !$owner_mobile || !$owner_cardid) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
//同个品牌一个身份证只能下一单
@@ -115,30 +120,30 @@ class CusorderV2 extends Wxapp{
"JSON_EXTRACT(info_json,'$.c_owner_cardid')='{$owner_cardid}'" => null,
'status>=' => 0
];
- if($this->orders_model->count($where)){
+ if ($this->orders_model->count($where)) {
throw new Exception('一个客户只能享受一次国补,请联系管理员', ERR_PARAMS_ERROR);
}
}
- if($deposit<1000){
+ if ($deposit < 1000) {
throw new Exception('定金不得少于1000', ERR_PARAMS_ERROR);
}
- $biz = $this->biz_model->get(['id'=>$row['biz_id']],'id,city_id,type');
+ $biz = $this->biz_model->get(['id' => $row['biz_id']], 'id,city_id,type');
- $car_row = $this->auto_cars_model->get(['brand_id'=>$series_row['brand_id'],'s_id'=>$series_row['id'],'v_id'=>$v_id],'',$biz['city_id']);
- if(!$car_row){
+ $car_row = $this->auto_cars_model->get(['brand_id' => $series_row['brand_id'], 's_id' => $series_row['id'], 'v_id' => $v_id], '', $biz['city_id']);
+ if (!$car_row) {
throw new Exception('参数错误', API_CODE_FAIL);
}
$can_dis_money = $business_row['price_car'] - $business_row['price_floor']; //可优惠金额
- if($can_dis_money>0){
- if($disc_money && $business_row['price_floor'] > $business_row['price_car']-$disc_money){
+ if ($can_dis_money > 0) {
+ if ($disc_money && $business_row['price_floor'] > $business_row['price_car'] - $disc_money) {
throw new Exception('车辆售价不得低于车辆底价,请重新填写优惠信息', API_CODE_FAIL);
}
- }else{
- if($disc_money) throw new Exception('当前车型没有优惠额度', API_CODE_FAIL);
+ } else {
+ if ($disc_money) throw new Exception('当前车型没有优惠额度', API_CODE_FAIL);
}
- if(!$payway && $finance_id){ //分期
- $finance_row = $this->sys_finance_model->get(['id'=>$finance_id,'status'=>1]);
- if(!$finance_row){
+ if (!$payway && $finance_id) { //分期
+ $finance_row = $this->sys_finance_model->get(['id' => $finance_id, 'status' => 1]);
+ if (!$finance_row) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
}
@@ -146,9 +151,9 @@ class CusorderV2 extends Wxapp{
//if($series_row['brand_id']==1 && $business_row['delivery_day']>10 && in_array($biz['type'],[1,2])){
// $business_row['delivery_day'] -= 10;
//}
- $over_time = date('Y-m-d H:i:s',time()+$business_row['delivery_day']*24*60*60); //交付截止时间
+ $over_time = date('Y-m-d H:i:s', time() + $business_row['delivery_day'] * 24 * 60 * 60); //交付截止时间
$data = [
- 'sid' => create_order_no(350200,$this->app_key),
+ 'sid' => create_order_no(350200, $this->app_key),
'customer_id' => $row['id'],
'name' => $name ? $name : $row['name'],
'mobile' => $mobile ? $mobile : $row['mobile'],
@@ -170,11 +175,11 @@ class CusorderV2 extends Wxapp{
$if_fine && $data['if_fine'] = 1;
$main_type && $data['main_type'] = 1;
$delry_time && $data['delry_time'] = $delry_time;
- $fines && $data['fines'] = json_encode($fines,JSON_UNESCAPED_UNICODE);
+ $fines && $data['fines'] = json_encode($fines, JSON_UNESCAPED_UNICODE);
$info_json = [];
- if($pro){
+ if ($pro) {
$info_json['pro'] = $pro;
- $address = implode(' ',$pro).$address;
+ $address = implode(' ', $pro) . $address;
}
$address && $info_json['c_address'] = $address;
$cardid && $info_json['c_cardid'] = $cardid;
@@ -183,14 +188,14 @@ class CusorderV2 extends Wxapp{
$company && $info_json['c_company'] = $company;
$business_id && $info_json['business_id'] = $business_id;
$car_city_id && $info_json['car_city_id'] = $car_city_id;
- $info_json && $data['info_json'] = json_encode($info_json,JSON_UNESCAPED_UNICODE);
+ $info_json && $data['info_json'] = json_encode($info_json, JSON_UNESCAPED_UNICODE);
$finance_row && $data['finance_id'] = $finance_row['id'];
$if_local_bill && $data['if_local_bill'] = 1;
//获取金额json数据
$orders_entity = new orders_v2_entity();
- $color_arr = json_decode($business_row['colors'],true);
- $price_color = in_array($color_id,$color_arr) ? $business_row['price_color'] : 0;
+ $color_arr = json_decode($business_row['colors'], true);
+ $price_color = in_array($color_id, $color_arr) ? $business_row['price_color'] : 0;
$price_coplus = $main_type ? $business_row['price_coplus'] : 0;
$money_json = [
@@ -198,53 +203,55 @@ class CusorderV2 extends Wxapp{
'price_book' => $deposit ? $deposit : 0,
'price_insure' => $car_row['price_insure'],
'price_fine' => $car_row['price_fine'],
- 'price_discount' =>$disc_money ? $disc_money : 0,
+ 'price_discount' => $disc_money ? $disc_money : 0,
'price_intention' => 0,
'price_fine_discount' => $disc_fine_money ? $disc_fine_money : 0,
'price_fine_select' => 0,
'price_color' => $price_color,
'price_coplus' => $price_coplus,
];
- if($srv_arr){
+ if ($srv_arr) {
foreach ($srv_arr as $item) {
$money_json[$item['key']] = $item['price'];
$item['id'] == 1 && $data['if_insure'] = 1;
$item['id'] == 2 && $data['if_num'] = 1;
}
}
- $data['srv_ids'] = $srv_arr ? json_encode($srv_arr,JSON_UNESCAPED_UNICODE) : "";
- if($fines){
+ $data['srv_ids'] = $srv_arr ? json_encode($srv_arr, JSON_UNESCAPED_UNICODE) : "";
+ if ($fines) {
foreach ($fines as $item) {
- if($item['price']){
+ if ($item['price']) {
$money_json['price_fine_select'] += $item['price'];
}
}
}
$car_json = $money_json;
$car_json['delivery_day'] = $business_row['delivery_day'];
- $data['money_json'] = json_encode($money_json,JSON_UNESCAPED_UNICODE);
- $data['car_json'] = json_encode($car_json,JSON_UNESCAPED_UNICODE);
- $this->ck_money($money_json,$srv_arr,$biz);
+ $data['money_json'] = json_encode($money_json, JSON_UNESCAPED_UNICODE);
+ $data['car_json'] = json_encode($car_json, JSON_UNESCAPED_UNICODE);
+ $this->ck_money($money_json, $srv_arr, $biz);
$o_id = $this->orders_model->add($data);
- if(is_numeric($o_id)){
- $userinfo = $this->app_liche_users_model->get(['mobile'=>$data['mobile']],'id');
- $this->orders_v2_entity->add_book_order($o_id,$userinfo['id']);
- if($payway){ //全款服务费和尾款订单
- $this->orders_v2_entity->add_order($o_id,$userinfo['id']);
+ if (is_numeric($o_id)) {
+ $userinfo = $this->app_liche_users_model->get(['mobile' => $data['mobile']], 'id');
+ $this->orders_v2_entity->add_book_order($o_id, $userinfo['id']);
+ if ($payway) { //全款服务费和尾款订单
+ $this->orders_v2_entity->add_order($o_id, $userinfo['id']);
}
//更新客户下单时间
- $this->customers_model->update(array('order_time' => date('Y-m-d H:i:s')),['id'=>$cus_id]);
+ $this->customers_model->update(array('order_time' => date('Y-m-d H:i:s')), ['id' => $cus_id]);
$this->customers_entity->add_log($cus_id, $this->session['uid'], $this->session['uname'], '生成订单', 6);
//补充协商
- $sa && $this->order_datas_entity->up_data($o_id,['sa'=>$sa]);
- return ['id'=>$o_id,'pay_img'=>$orders_entity->pay_img($o_id)];
- }else{
+ $sa && $this->order_datas_entity->up_data($o_id, ['sa' => $sa]);
+ return ['id' => $o_id, 'pay_img' => $orders_entity->pay_img($o_id)];
+ } else {
throw new Exception('创建失败', ERR_PARAMS_ERROR);
}
}
+
//创建意向金订单
- protected function post_inten(){
+ protected function post_inten()
+ {
$cus_id = $this->input_param('cus_id');
$name = $this->input_param('name');
$mobile = $this->input_param('mobile');
@@ -261,25 +268,25 @@ class CusorderV2 extends Wxapp{
$inten_money = floatval($this->input_param('inten_money'));//意向金
- if(!$name || !$mobile|| !$inten_money){
+ if (!$name || !$mobile || !$inten_money) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
- if($main_type){
- if(!$company || !$c_credit){
+ if ($main_type) {
+ if (!$company || !$c_credit) {
throw new Exception('请填写公司信息', ERR_PARAMS_ERROR);
}
- }else{
- if( !$cardid || !$owner_name || !$owner_mobile || !$owner_cardid){
+ } else {
+ if (!$cardid || !$owner_name || !$owner_mobile || !$owner_cardid) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
}
- $row = $this->customers_model->get(['id'=>$cus_id]);
- if($inten_money > 2000){
+ $row = $this->customers_model->get(['id' => $cus_id]);
+ if ($inten_money > 2000) {
throw new Exception('意向金不得高于2000', ERR_PARAMS_ERROR);
}
$data = [
'customer_id' => $cus_id,
- 'sid' => create_order_no(350200,$this->app_key),
+ 'sid' => create_order_no(350200, $this->app_key),
'name' => $name ? $name : $row['name'],
'mobile' => $mobile ? $mobile : $row['mobile'],
'biz_id' => $this->biz_id,
@@ -287,13 +294,13 @@ class CusorderV2 extends Wxapp{
'sale_id' => $this->session['uid'],
'c_time' => time()
];
- $main_type && $data['main_type'] = 1;
+ $main_type && $data['main_type'] = 1;
$owner_name && $data['owner_name'] = $owner_name;
$owner_mobile && $data['owner_mobile'] = $owner_mobile;
$info_json = [];
- if($pro){
+ if ($pro) {
$info_json['pro'] = $pro;
- $address = implode(' ',$pro).$address;
+ $address = implode(' ', $pro) . $address;
}
$address && $info_json['c_address'] = $address;
$cardid && $info_json['c_cardid'] = $cardid;
@@ -301,32 +308,33 @@ class CusorderV2 extends Wxapp{
$company && $info_json['c_company'] = $company;
$c_credit && $info_json['c_credit'] = $c_credit;
$car_city_id && $info_json['car_city_id'] = $car_city_id;
- $info_json && $data['info_json'] = json_encode($info_json,JSON_UNESCAPED_UNICODE);
+ $info_json && $data['info_json'] = json_encode($info_json, JSON_UNESCAPED_UNICODE);
$money_json['price_intention'] = $inten_money ? $inten_money : 0;
- $data['money_json'] = json_encode($money_json,JSON_UNESCAPED_UNICODE);
+ $data['money_json'] = json_encode($money_json, JSON_UNESCAPED_UNICODE);
$row['rid'] && $data['clue_id'] = $row['rid'];
$o_id = $this->orders_model->add($data);
- if(!$o_id){
+ if (!$o_id) {
throw new Exception('创建失败', ERR_PARAMS_ERROR);
}
//更新客户下单时间
- $this->customers_model->update(array('order_time' => date('Y-m-d H:i:s')),['id'=>$cus_id]);
+ $this->customers_model->update(array('order_time' => date('Y-m-d H:i:s')), ['id' => $cus_id]);
$this->customers_entity->add_log($cus_id, $this->session['uid'], $this->session['uname'], '生成订单', 6);
//意向金订单
$orders_entity = new orders_v2_entity();
- if($inten_money){
- $userinfo = $this->app_liche_users_model->get(['mobile'=>$data['mobile']],'id');
- $orders_entity->c_intention($o_id,$userinfo['id'],$inten_money);
+ if ($inten_money) {
+ $userinfo = $this->app_liche_users_model->get(['mobile' => $data['mobile']], 'id');
+ $orders_entity->c_intention($o_id, $userinfo['id'], $inten_money);
}
- return ['id'=>$o_id,'pay_img'=>$orders_entity->pay_img($o_id)];
+ return ['id' => $o_id, 'pay_img' => $orders_entity->pay_img($o_id)];
}
//修改订单信息
- protected function put(){
+ protected function put()
+ {
$id = $this->input_param('id');
$car_id = $this->input_param('car_id');
$color_id = $this->input_param('color_id');
@@ -345,19 +353,19 @@ class CusorderV2 extends Wxapp{
$sa = $this->input_param('sa'); //补充协商
$if_local_bill = $this->input_param('if_local_bill');//是否需要开具本地发票
- $row = $this->orders_model->get(['id'=>$id]);
+ $row = $this->orders_model->get(['id' => $id]);
$main_type = $row['main_type'];
- $series_row = $this->auto_series_model->get(['id'=>$car_id]);
- $biz = $this->biz_model->get(['id'=>$row['biz_id']],'id,type,city_id');
- $car_row = $this->auto_cars_model->get(['brand_id'=>$series_row['brand_id'],'s_id'=>$series_row['id'],'v_id'=>$v_id],'',$biz['city_id']);
+ $series_row = $this->auto_series_model->get(['id' => $car_id]);
+ $biz = $this->biz_model->get(['id' => $row['biz_id']], 'id,type,city_id');
+ $car_row = $this->auto_cars_model->get(['brand_id' => $series_row['brand_id'], 's_id' => $series_row['id'], 'v_id' => $v_id], '', $biz['city_id']);
- $info_json = json_decode($row['info_json'],true);
+ $info_json = json_decode($row['info_json'], true);
//修改商务政策id
- if($series_row['brand_id']==$row['brand_id'] && $v_id!=$row['v_id']){
- $old_business_row = $this->auto_business_model->get(['id'=>$info_json['business_id']]);
- if($old_business_row){
- $s_time = strtotime(date('Y-m-d 00:00:00',$old_business_row['s_effect_time']));
- $e_time = strtotime(date('Y-m-d 23:59:59',$old_business_row['s_effect_time']));
+ if ($series_row['brand_id'] == $row['brand_id'] && $v_id != $row['v_id']) {
+ $old_business_row = $this->auto_business_model->get(['id' => $info_json['business_id']]);
+ if ($old_business_row) {
+ $s_time = strtotime(date('Y-m-d 00:00:00', $old_business_row['s_effect_time']));
+ $e_time = strtotime(date('Y-m-d 23:59:59', $old_business_row['s_effect_time']));
$where = [
'city_id' => $old_business_row['city_id'],
'brand_id' => $old_business_row['brand_id'],
@@ -370,30 +378,30 @@ class CusorderV2 extends Wxapp{
$new_business_row && $business_id = $new_business_row['id'];
}
}
- $business_row = $this->auto_business_model->get(['id'=>$business_id]);
- if(!$row || !$series_row || !$car_row || !$business_row){
+ $business_row = $this->auto_business_model->get(['id' => $business_id]);
+ if (!$row || !$series_row || !$car_row || !$business_row) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
- if($deposit<1000){
+ if ($deposit < 1000) {
throw new Exception('定金不得少于1000', ERR_PARAMS_ERROR);
}
$can_dis_money = $business_row['price_car'] - $business_row['price_floor']; //可优惠金额
- if($can_dis_money>0){
- if($disc_money && $car_row['price_floor'] > $car_row['price_car']-$disc_money){
+ if ($can_dis_money > 0) {
+ if ($disc_money && $car_row['price_floor'] > $car_row['price_car'] - $disc_money) {
throw new Exception('车辆售价不得低于车辆底价,请重新填写优惠信息', API_CODE_FAIL);
}
- }else{
- if($disc_money) throw new Exception('当前车型没有优惠额度', API_CODE_FAIL);
+ } else {
+ if ($disc_money) throw new Exception('当前车型没有优惠额度', API_CODE_FAIL);
}
- if(!$payway && $finance_id){ //分期
- $finance_row = $this->sys_finance_model->get(['id'=>$finance_id,'status'=>1]);
- if(!$finance_row){
+ if (!$payway && $finance_id) { //分期
+ $finance_row = $this->sys_finance_model->get(['id' => $finance_id, 'status' => 1]);
+ if (!$finance_row) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
}
- if(!$main_type){//个人
+ if (!$main_type) {//个人
//同个品牌一个身份证只能下一单
$where = [
'brand_id' => $series_row['brand_id'],
@@ -401,7 +409,7 @@ class CusorderV2 extends Wxapp{
'status>=' => 0,
'id!=' => $id,
];
- if($this->orders_model->count($where)){
+ if ($this->orders_model->count($where)) {
throw new Exception('一个客户只能享受一次国补,请联系管理员', ERR_PARAMS_ERROR);
}
}
@@ -409,7 +417,7 @@ class CusorderV2 extends Wxapp{
//if($series_row['brand_id']==1 && $business_row['delivery_day']>10 && in_array($biz['type'],[1,2])){
// $business_row['delivery_day'] -= 10;
//}
- $over_time = date('Y-m-d H:i:s',time()+$business_row['delivery_day']*24*60*60); //交付截止时间
+ $over_time = date('Y-m-d H:i:s', time() + $business_row['delivery_day'] * 24 * 60 * 60); //交付截止时间
$data = [
'brand_id' => $series_row['brand_id'],
's_id' => $series_row['id'],
@@ -424,24 +432,24 @@ class CusorderV2 extends Wxapp{
];
$delry_time && $data['delry_time'] = $delry_time;
$finance_row && $data['finance_id'] = $finance_row['id'];
- $data['if_fine'] = $if_fine ? 1:0;
- $data['fines'] = json_encode($fines,JSON_UNESCAPED_UNICODE);
+ $data['if_fine'] = $if_fine ? 1 : 0;
+ $data['fines'] = json_encode($fines, JSON_UNESCAPED_UNICODE);
- $color_arr = json_decode($business_row['colors'],true);
+ $color_arr = json_decode($business_row['colors'], true);
//获取金额json数据
- $money_json = json_decode($row['money_json'],true);
+ $money_json = json_decode($row['money_json'], true);
$car_json = $money_json;
$car_json['delivery_day'] = $business_row['delivery_day'];
- $data['car_json'] = json_encode($car_json,JSON_UNESCAPED_UNICODE);
+ $data['car_json'] = json_encode($car_json, JSON_UNESCAPED_UNICODE);
$money_json['price_car'] = $business_row['price_car'];
$money_json['price_book'] = $deposit;
$money_json['price_insure'] = $car_row['price_insure'];
$money_json['price_fine'] = $car_row['price_fine'];
$money_json['price_discount'] = $disc_money;
$money_json['price_fine_discount'] = $disc_fine_money;
- $money_json['price_color'] = in_array($color_id,$color_arr) ? $business_row['price_color'] : 0;
+ $money_json['price_color'] = in_array($color_id, $color_arr) ? $business_row['price_color'] : 0;
$money_json['price_coplus'] = $main_type ? $business_row['price_coplus'] : 0;
- if($srv_arr){
+ if ($srv_arr) {
$money_json['price_finance'] = $money_json['fee_carno'] = 0;
foreach ($srv_arr as $item) {
$money_json[$item['key']] = floatval($item['price']);
@@ -449,101 +457,102 @@ class CusorderV2 extends Wxapp{
$item['id'] == 2 && $data['if_num'] = 1;
}
}
- $data['srv_ids'] = $srv_arr ? json_encode($srv_arr,JSON_UNESCAPED_UNICODE) : "";
+ $data['srv_ids'] = $srv_arr ? json_encode($srv_arr, JSON_UNESCAPED_UNICODE) : "";
$money_json['price_fine_select'] = 0;
- if($fines){
+ if ($fines) {
foreach ($fines as $item) {
- if($item['price']){
+ if ($item['price']) {
$money_json['price_fine_select'] += floatval($item['price']);
}
}
}
- if($row['c_time']>=strtotime('2022-04-08 14:43:00')){
- $this->ck_money($money_json,$srv_arr,$biz);
+ if ($row['c_time'] >= strtotime('2022-04-08 14:43:00')) {
+ $this->ck_money($money_json, $srv_arr, $biz);
}
- $data['money_json'] = json_encode($money_json,JSON_UNESCAPED_UNICODE);
+ $data['money_json'] = json_encode($money_json, JSON_UNESCAPED_UNICODE);
$info_json['business_id'] = $business_id;
- $data['info_json'] = json_encode($info_json,JSON_UNESCAPED_UNICODE);
- $result = $this->orders_model->update($data,['id'=>$row['id']]);
- if($result){
- $this->orders_v2_entity->edit_order($data,$row,$this->session);
+ $data['info_json'] = json_encode($info_json, JSON_UNESCAPED_UNICODE);
+ $result = $this->orders_model->update($data, ['id' => $row['id']]);
+ if ($result) {
+ $this->orders_v2_entity->edit_order($data, $row, $this->session);
//补充协商
- $sa && $this->order_datas_entity->up_data($row['id'],['sa'=>$sa]);
+ $sa && $this->order_datas_entity->up_data($row['id'], ['sa' => $sa]);
throw new Exception('修改成功', API_CODE_SUCCESS);
- }else{
+ } else {
throw new Exception('修改失败', ERR_PARAMS_ERROR);
}
}
- private function detail($id){
- $row = $this->orders_model->get(['id'=>$id]);
- if(!$row){
+ private function detail($id)
+ {
+ $row = $this->orders_model->get(['id' => $id]);
+ if (!$row) {
throw new Exception('订单不存在', ERR_PARAMS_ERROR);
}
$orders_entity = new Orders_v2_entity();
- $money_json = json_decode($row['money_json'],true);
- $info_json = json_decode($row['info_json'],true);
+ $money_json = json_decode($row['money_json'], true);
+ $info_json = json_decode($row['info_json'], true);
- $brand = $this->auto_brand_model->get(['id'=>$row['brand_id']],'name');
- $series = $this->auto_series_model->get(['id'=>$row['s_id']],'name');
- $color = $this->auto_attr_model->get(['id'=>$row['cor_id']],'title');
- $version = $this->auto_attr_model->get(['id'=>$row['v_id']],'title');
+ $brand = $this->auto_brand_model->get(['id' => $row['brand_id']], 'name');
+ $series = $this->auto_series_model->get(['id' => $row['s_id']], 'name');
+ $color = $this->auto_attr_model->get(['id' => $row['cor_id']], 'title');
+ $version = $this->auto_attr_model->get(['id' => $row['v_id']], 'title');
$color = $color ? $color['title'] : '';
$version = $version ? $version['title'] : '';
$car_data = [];
- if($row['brand_id'] && $row['s_id'] && $row['v_id']){
- $car_data['车辆名称'] = $brand['name'].$series['name'];
+ if ($row['brand_id'] && $row['s_id'] && $row['v_id']) {
+ $car_data['车辆名称'] = $brand['name'] . $series['name'];
$car_data['车辆级别'] = $version;
$car_data['车身颜色'] = $color;
$car_data['平台售价'] = $money_json['price_car'];
- $money_json['price_coplus'] && $car_data['公司加价'] = sprintf("%.2f",$money_json['price_coplus']);
- $money_json['price_color'] && $car_data['颜色加价'] = sprintf("%.2f",$money_json['price_color']);
- $car_data['定金'] = sprintf("%.2f",$money_json['price_book']);
+ $money_json['price_coplus'] && $car_data['公司加价'] = sprintf("%.2f", $money_json['price_coplus']);
+ $money_json['price_color'] && $car_data['颜色加价'] = sprintf("%.2f", $money_json['price_color']);
+ $car_data['定金'] = sprintf("%.2f", $money_json['price_book']);
$car_price_list = [];
- $money_json['price_discount'] && $car_price_list['优惠'] = sprintf("%.2f",$money_json['price_discount']);
- $car_data['最终售价'] =[
+ $money_json['price_discount'] && $car_price_list['优惠'] = sprintf("%.2f", $money_json['price_discount']);
+ $car_data['最终售价'] = [
'list' => $car_price_list,
- 'value' => sprintf("%.2f",$orders_entity->total_price($row['id']))
+ 'value' => sprintf("%.2f", $orders_entity->total_price($row['id']))
];
//服务费
- $srv_data = $orders_entity->order_srv_money($row['id'],1);
- if($srv_data['total']>0){
- $car_data['委托代办']['value'] = sprintf("%.2f",$srv_data['total']);
- foreach($srv_data['list'] as $val){
- $car_data['委托代办']['list'][$val['title']] = is_numeric($val['money']) ? sprintf("%.2f",$val['money']):'';
+ $srv_data = $orders_entity->order_srv_money($row['id'], 1);
+ if ($srv_data['total'] > 0) {
+ $car_data['委托代办']['value'] = sprintf("%.2f", $srv_data['total']);
+ foreach ($srv_data['list'] as $val) {
+ $car_data['委托代办']['list'][$val['title']] = is_numeric($val['money']) ? sprintf("%.2f", $val['money']) : '';
}
- $fines = json_decode($row['fines'],true);
- if($fines){
+ $fines = json_decode($row['fines'], true);
+ if ($fines) {
$fines_list = [];
foreach ($fines as $item) {
- $fines_list['list'][$item['txt']] = $item['price'] ? sprintf("%.2f",$item['price']) : '';
+ $fines_list['list'][$item['txt']] = $item['price'] ? sprintf("%.2f", $item['price']) : '';
}
- $fines_list['value'] = $money_json['price_fine_select'] ? sprintf("%.2f",$money_json['price_fine_select']) : 0.00;
+ $fines_list['value'] = $money_json['price_fine_select'] ? sprintf("%.2f", $money_json['price_fine_select']) : 0.00;
$car_data['委托代办']['list']['精品选装'] = $fines_list;
}
}
$car_data['需开具本地发票'] = $row['if_local_bill'] ? '需要' : '不需要';
}
- if(!$row['payway'] && $row['brand_id']){
- $finance_row = $this->sys_finance_model->get(['id'=>$row['finance_id']],'title');
- $car_data['按揭信息'] = $finance_row['title'] ? $finance_row['title']: '';
+ if (!$row['payway'] && $row['brand_id']) {
+ $finance_row = $this->sys_finance_model->get(['id' => $row['finance_id']], 'title');
+ $car_data['按揭信息'] = $finance_row['title'] ? $finance_row['title'] : '';
}
//是否存在意向金订单
- $inten_row = $this->app_liche_orders_model->get(['o_id'=>$row['id'],'type'=>4,'status>='=>0]);
+ $inten_row = $this->app_liche_orders_model->get(['o_id' => $row['id'], 'type' => 4, 'status>=' => 0]);
$pay_status = 0;
$inten_money = 0;
- if($inten_row && $inten_row['status']==0){
+ if ($inten_row && $inten_row['status'] == 0) {
$pay_status = 1;
}
- if($inten_row['status']==1){//已支付意向金
+ if ($inten_row['status'] == 1) {//已支付意向金
$inten_money = floatval($inten_row['total_price']);
}
- if($info_json['pro']){
- $pro_str = implode(" ",$info_json['pro']);
- $info_json['c_address'] = str_replace($pro_str," ",$info_json['c_address']);
+ if ($info_json['pro']) {
+ $pro_str = implode(" ", $info_json['pro']);
+ $info_json['c_address'] = str_replace($pro_str, " ", $info_json['c_address']);
}
$data = [
'id' => $id,
@@ -559,26 +568,26 @@ class CusorderV2 extends Wxapp{
'v_id' => $row['v_id'],
'color_id' => $row['cor_id'],
'incolor_id' => $row['incor_id'],
- 'delry_time' => $row['delry_time']!='0000-00-00 00:00:00' ? date('Y-m-d',strtotime($row['delry_time'])):'',
+ 'delry_time' => $row['delry_time'] != '0000-00-00 00:00:00' ? date('Y-m-d', strtotime($row['delry_time'])) : '',
'finance_id' => !$row['payway'] ? $row['finance_id'] : '',
- 'deposit' => $money_json['price_book'] ? sprintf("%.2f",$money_json['price_book']): 0,
- 'disc_money' => $money_json['price_discount'] ? sprintf("%.2f",$money_json['price_discount']) : '',
- 'disc_fine_money' => $money_json['price_fine_discount'] ? sprintf("%.2f",$money_json['price_fine_discount']) : 0,
- 'srv_arr' => $row['srv_ids'] ? json_decode($row['srv_ids'],true) : [],
+ 'deposit' => $money_json['price_book'] ? sprintf("%.2f", $money_json['price_book']) : 0,
+ 'disc_money' => $money_json['price_discount'] ? sprintf("%.2f", $money_json['price_discount']) : '',
+ 'disc_fine_money' => $money_json['price_fine_discount'] ? sprintf("%.2f", $money_json['price_fine_discount']) : 0,
+ 'srv_arr' => $row['srv_ids'] ? json_decode($row['srv_ids'], true) : [],
'cus_id' => $row['customer_id'],
'status' => $row['status'],
'if_fine' => $row['if_fine'] ? 1 : 0,
'main_type' => intval($row['main_type']),
- 'fines' => $row['fines'] ? json_decode($row['fines'],true) : [],
+ 'fines' => $row['fines'] ? json_decode($row['fines'], true) : [],
'address' => $info_json['c_address'] ? $info_json['c_address'] : '',
'pro' => $info_json['pro'] ? $info_json['pro'] : [],
'c_city_id' => $info_json['car_city_id'],
'if_local_bill' => $row['if_local_bill'],
];
- if($row['main_type']){
+ if ($row['main_type']) {
$info_json['c_credit'] && $data['credit'] = $info_json['c_credit'];
$info_json['c_company'] && $data['company'] = $info_json['c_company'];
- }else{
+ } else {
$data['owner_name'] = $row['owner_name'];
$data['owner_mobile'] = $row['owner_mobile'];
$data['owner_cardid'] = $info_json['c_owner_cardid'];
@@ -587,31 +596,31 @@ class CusorderV2 extends Wxapp{
$inten_money && $data['inten_money'] = $inten_money;
//开票文件
- $bill = $this->order_bills_model->get(['o_id'=>$row['id']],'file');
+ $bill = $this->order_bills_model->get(['o_id' => $row['id']], 'file');
$data['bill_img'] = $bill['file'] ? build_qiniu_image_url($bill['file']) : '';
//选择随车物品
$ckcar_status = 0;
- if($this->receiver_order_status_model->count(['o_id'=>$row['id'],'pid_status'=>3,'status'=>1]) && !$this->receiver_order_status_model->count(['o_id'=>$row['id'],'pid_status'=>4,'status'=>1])){
+ if ($this->receiver_order_status_model->count(['o_id' => $row['id'], 'pid_status' => 3, 'status' => 1]) && !$this->receiver_order_status_model->count(['o_id' => $row['id'], 'pid_status' => 4, 'status' => 1])) {
$ckcar_status = 1;
}
- $delivery = $this->order_deliverys_model->get(['o_id'=>$row['id']],'status,info,tool,remark');
+ $delivery = $this->order_deliverys_model->get(['o_id' => $row['id']], 'status,info,tool,remark');
$ckcar_data = [
- 'info' => $delivery['info'] ? explode(',',$delivery['info']) : [],
- 'tool' => $delivery['tool'] ? explode(',',$delivery['tool']) : [],
+ 'info' => $delivery['info'] ? explode(',', $delivery['info']) : [],
+ 'tool' => $delivery['tool'] ? explode(',', $delivery['tool']) : [],
'remark' => $delivery['remark'] ? $delivery['remark'] : ''
];
$data['ckcar_status'] = $ckcar_status;
$data['ckcar_data'] = $ckcar_data;
- $price_book = $this->app_liche_orders_model->count(['o_id'=>$row['id'],'type'=>1,'status'=>1]); //定金是否支付
+ $price_book = $this->app_liche_orders_model->count(['o_id' => $row['id'], 'type' => 1, 'status' => 1]); //定金是否支付
$data['price_book_status'] = $price_book ? true : false;
- $price_srv = $this->app_liche_orders_model->count(['o_id'=>$row['id'],'type'=>2,'status'=>1]); //服务费是否支付
+ $price_srv = $this->app_liche_orders_model->count(['o_id' => $row['id'], 'type' => 2, 'status' => 1]); //服务费是否支付
$data['price_srv_status'] = $price_srv ? true : false;
- $price_last = $this->app_liche_orders_model->count(['o_id'=>$row['id'],'type'=>3,'status'=>1]); //尾款是否支付
+ $price_last = $this->app_liche_orders_model->count(['o_id' => $row['id'], 'type' => 3, 'status' => 1]); //尾款是否支付
$data['price_last_status'] = $price_last ? true : false;
$data['edit_status'] = $price_last ? 0 : 1;
$data['loan_status'] = true;
- $loan_row = $this->order_loans_model->get(['o_id'=>$row['id']]);
+ $loan_row = $this->order_loans_model->get(['o_id' => $row['id']]);
$data['notify_file'] = [
'src' => $loan_row['notify_file'] ? build_qiniu_image_url($loan_row['notify_file']) : '',
'value' => $loan_row['notify_file'] ? $loan_row['notify_file'] : ''
@@ -623,12 +632,12 @@ class CusorderV2 extends Wxapp{
$data['price_loan'] = $money_json['price_loan'] ? $money_json['price_loan'] : 0.00;
$data['num'] = $loan_row['num'] ? $loan_row['num'] : 0;
$data['admin_name'] = '';
- if($row['sale_id']){
- $admin_row = $this->app_user_model->get(['id'=>$row['sale_id']],'uname');
+ if ($row['admin_id']) {
+ $admin_row = $this->app_user_model->get(['id' => $row['admin_id']], 'uname');
$data['admin_name'] = $admin_row['uname'];
}
//获取补充协议
- $order_data = $this->receiver_order_datas_model->get(['o_id'=>$row['id']],'sa');
+ $order_data = $this->receiver_order_datas_model->get(['o_id' => $row['id']], 'sa');
$data['sa'] = $order_data['sa'] ? $order_data['sa'] : '';
return $data;
}
@@ -653,7 +662,7 @@ class CusorderV2 extends Wxapp{
'biz_id' => $this->biz_id,
];
- $group_id == 1 && $where['sale_id'] = $uid;//销售
+ $group_id == 1 && $where['admin_id'] = $uid;//销售
if ($group_id == 4 && $this->biz_id != 1) {
$where['brand_id!='] = 3; //渠道经理过滤
}
@@ -688,15 +697,18 @@ class CusorderV2 extends Wxapp{
}
//下定时间
if ($order_s_time && $order_e_time) {
- $where["order_time >="] = date('Y-m-d 00:00:00',strtotime($order_s_time));
- $where["order_time <="] = date('Y-m-d 00:00:00',strtotime($order_e_time));
+ $where["order_time >="] = date('Y-m-d 00:00:00', strtotime($order_s_time));
+ $where["order_time <="] = date('Y-m-d 00:00:00', strtotime($order_e_time));
}
- $fileds = 'id,customer_id,name,mobile,brand_id,s_id,v_id,cor_id,incor_id,payway,
+ $fileds = 'id,customer_id,name,mobile,brand_id,s_id,v_id,cor_id,incor_id,payway,admin_id,
status,c_time,money_json,if_num,info_json,main_type,owner_name,owner_mobile,item_id,order_time,over_time';
$count = $this->orders_model->count($where);
- $lists = [];
+ $lists = $map_users = [];
if ($count) {
$rows = $this->orders_model->select($where, 'id desc', $page, $size, $fileds);
+ //销售顾问
+ $str_user_ids = implode(',', array_unique(array_column($rows, 'admin_id')));
+ $str_user_ids && $map_users = $this->app_user_model->map('id', 'uname', ["id in({$str_user_ids})" => null]);
//品牌车型
$brand_arr = array_unique(array_column($rows, 'brand_id'));
$brands = $this->auto_brand_model->get_map_by_ids($brand_arr, 'id,name');
@@ -732,6 +744,7 @@ class CusorderV2 extends Wxapp{
$order_datas = $this->receiver_order_datas_model->get_map_by_oids(array_column($rows, 'id'), 'id,o_id,cardida,business_licence,car_img,register_img,ins_img,other_img');
$status_arr = $this->orders_model->get_status();
$old_status_arr = $this->receiver_orders_model->get_status();
+ $allot = $this->get_allot();
foreach ($rows as $key => $val) {
$info_json = json_decode($val['info_json'], true);
if ($val['id'] >= Orders_v2_entity::V2_START_ID) {
@@ -805,8 +818,8 @@ class CusorderV2 extends Wxapp{
$other_data['交车合照'] = ['type' => 'text', 'value' => $img_status['other_img']['text'], 'bg_color' => $img_status['other_img']['color']];
$other_data['交付'] = ['type' => 'checkbox', 'value' => '', 'lists' => $ck_status, 'bg_color' => ''];
}
- $val['order_time']!='0000-00-00 00:00:00' && $other_data['下定时间'] = ['type' => 'text', 'value' => date('Y-m-d', strtotime($val['order_time'])), 'bg_color' => ''];
- $val['over_time']!='0000-00-00 00:00:00' && $other_data['截止交付'] = ['type' => 'text', 'value' => date('Y-m-d', strtotime($val['over_time'])), 'bg_color' => ''];
+ $val['order_time'] != '0000-00-00 00:00:00' && $other_data['下定时间'] = ['type' => 'text', 'value' => date('Y-m-d', strtotime($val['order_time'])), 'bg_color' => ''];
+ $val['over_time'] != '0000-00-00 00:00:00' && $other_data['截止交付'] = ['type' => 'text', 'value' => date('Y-m-d', strtotime($val['over_time'])), 'bg_color' => ''];
} else {
$price_intention = $money_json['price_intention'] ? $money_json['price_intention'] : '';
$other_data = [
@@ -814,6 +827,9 @@ class CusorderV2 extends Wxapp{
'订单日期' => ['type' => 'text', 'value' => date('Y-m-d', $val['c_time']), 'bg_color' => ''],
];
}
+ if ($map_users[$val['admin_id']]) {
+ $other_data['销售顾问'] = ['type' => 'text', 'value' => $map_users[$val['admin_id']], 'bg_color' => ''];
+ }
$lists[] = [
'id' => $val['id'],
'cus_id' => $val['customer_id'],
@@ -824,6 +840,7 @@ class CusorderV2 extends Wxapp{
'company' => $val['main_type'] ? $info_json['c_company'] : '',
'status_name' => $status_arr[$val['status']],
'other_data' => $other_data,
+ 'allot' => $allot,
];
} else {//旧订单
$status = $old_rows[$val['id']] ? $old_rows[$val['id']] : 0;
@@ -850,6 +867,9 @@ class CusorderV2 extends Wxapp{
'订单日期' => date('Y-m-d', $val['c_time']),
];
}
+ if ($map_users[$val['admin_id']]) {
+ $other_data['销售顾问'] = $map_users[$val['admin_id']];
+ }
$lists[] = [
'id' => $val['id'],
'cus_id' => $val['customer_id'],
@@ -860,7 +880,8 @@ class CusorderV2 extends Wxapp{
'company' => '',
'status_name' => $old_status_arr[$status],
'other_data' => $other_data,
- 'remark' => $this->orders_entity->get_remark($status)
+ 'remark' => $this->orders_entity->get_remark($status),
+ 'allot' => $allot,
];
}
}
@@ -873,7 +894,8 @@ class CusorderV2 extends Wxapp{
}
//获取客户订单
- protected function get_customer(){
+ protected function get_customer()
+ {
$customer_id = intval($this->input_param('customer_id'));
if (!$customer_id) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
@@ -914,18 +936,20 @@ class CusorderV2 extends Wxapp{
];
return $data;
}
+
//订单列表头部
- protected function get_tabs(){
+ protected function get_tabs()
+ {
$lists = [
- ['key' =>11 ,'name' => '进行中'],
- ['key' =>12 ,'name' => '已完成'],
+ ['key' => 11, 'name' => '进行中'],
+ ['key' => 12, 'name' => '已完成'],
];
$data['filters'] = [
'type' => [
- ['key' => 'fq','name' => '分期办理'],
- ['key' => 'pc','name' => '车辆匹配'],
- ['key' => 'kp','name' => '发票开具'],
- ['key' => 'jf','name' => '交付确认'],
+ ['key' => 'fq', 'name' => '分期办理'],
+ ['key' => 'pc', 'name' => '车辆匹配'],
+ ['key' => 'kp', 'name' => '发票开具'],
+ ['key' => 'jf', 'name' => '交付确认'],
],
];
$data['tabs'] = $lists;
@@ -933,7 +957,8 @@ class CusorderV2 extends Wxapp{
}
//修改用户基本信息
- protected function put_info(){
+ protected function put_info()
+ {
$id = $this->input_param('id');
$owner_name = trim($this->input_param('owner_name'));
$owner_mobile = trim($this->input_param('owner_mobile'));
@@ -944,123 +969,171 @@ class CusorderV2 extends Wxapp{
$car_city_id = $this->input_param('c_city_id');
$pro = $this->input_param('pro');
- $row = $this->orders_model->get(['id'=>$id]);
- if(!$row){
+ $row = $this->orders_model->get(['id' => $id]);
+ if (!$row) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
- if($row['main_type']==1){ //公司
+ if ($row['main_type'] == 1) { //公司
$owner_name = $company;
}
$data = [];
$owner_name && $data['owner_name'] = $owner_name;
$owner_mobile && $data['owner_mobile'] = $owner_mobile;
- $info_json = json_decode($row['info_json'],true);
+ $info_json = json_decode($row['info_json'], true);
$owner_cardid && $info_json['c_owner_cardid'] = $owner_cardid;
$c_credit && $info_json['c_credit'] = $c_credit;
$company && $info_json['c_company'] = $company;
- if($pro){
+ if ($pro) {
$info_json['pro'] = $pro;
- $address = implode(' ',$pro).$address;
+ $address = implode(' ', $pro) . $address;
}
$address && $info_json['c_address'] = $address;
$car_city_id && $info_json['car_city_id'] = $car_city_id;
- $info_json && $data['info_json'] = json_encode($info_json,JSON_UNESCAPED_UNICODE);
- $result = $this->orders_model->update($data,['id'=>$row['id']]);
- if($result){
- if($this->receiver_order_contracts_model->count(['o_id'=>$row['id'],'type in (0,1)'=>null])){
- $this->receiver_order_contracts_model->delete(['o_id'=>$row['id'],'type in (0,1)'=>null]);
+ $info_json && $data['info_json'] = json_encode($info_json, JSON_UNESCAPED_UNICODE);
+ $result = $this->orders_model->update($data, ['id' => $row['id']]);
+ if ($result) {
+ if ($this->receiver_order_contracts_model->count(['o_id' => $row['id'], 'type in (0,1)' => null])) {
+ $this->receiver_order_contracts_model->delete(['o_id' => $row['id'], 'type in (0,1)' => null]);
}
- $is_pay = $this->app_liche_orders_model->count(['o_id'=>$row['id'],'type!='=>4,'status'=>1]);
- if($is_pay){ //存在已支付订单并且修改信息 写日志
+ $is_pay = $this->app_liche_orders_model->count(['o_id' => $row['id'], 'type!=' => 4, 'status' => 1]);
+ if ($is_pay) { //存在已支付订单并且修改信息 写日志
$content = [];
- if($owner_name!=$row['owner_name']){
+ if ($owner_name != $row['owner_name']) {
$content[] = "车主姓名由 {$row['owner_name']} 变更为 {$owner_name}";
$owner_a = $row['owner_name'];
$owner_b = $owner_name;
}
- if($owner_mobile!=$row['owner_mobile']){
+ if ($owner_mobile != $row['owner_mobile']) {
$content[] = "车主手机号由 {$row['owner_mobile']} 变更为 {$owner_mobile}";
$owner_a = $row['owner_mobile'];
$owner_b = $owner_mobile;
}
- if($owner_cardid!=$info_json['c_owner_cardid']){
+ if ($owner_cardid != $info_json['c_owner_cardid']) {
$content[] = "车主身份证由 {$info_json['c_owner_cardid']} 变更为 {$owner_cardid}";
$owner_a = $info_json['c_owner_cardid'];
$owner_b = $owner_cardid;
}
- if($content){
- $log_content = implode("
",$content);
- $this->orders_entity->add_log($row['id'],$this->session['uid'],$this->session['uname'],$log_content);
+ if ($content) {
+ $log_content = implode("
", $content);
+ $this->orders_entity->add_log($row['id'], $this->session['uid'], $this->session['uname'], $log_content);
$params = [
- 'sid' => $row['sid']."({$owner_name})",
+ 'sid' => $row['sid'] . "({$owner_name})",
'owner_a' => $owner_a,
'owner_b' => $owner_b,
];
- $this->orders_v2_entity->send_msg('SMS_241360549',$params);
+ $this->orders_v2_entity->send_msg('SMS_241360549', $params);
}
}
throw new Exception('修改成功', API_CODE_SUCCESS);
- }else{
+ } else {
throw new Exception('修改失败', ERR_PARAMS_ERROR);
}
}
- protected function put_status(){
+ protected function put_status()
+ {
$id = $this->input_param('id');
- $row = $this->orders_model->get(['id'=>$id]);
- if(!$row){
+ $row = $this->orders_model->get(['id' => $id]);
+ if (!$row) {
throw new Exception('订单不存在', ERR_PARAMS_ERROR);
}
- $is_pay = $this->app_liche_orders_model->count(['o_id'=>$row['id'],'status'=>1]);
- if($is_pay){
+ $is_pay = $this->app_liche_orders_model->count(['o_id' => $row['id'], 'status' => 1]);
+ if ($is_pay) {
throw new Exception('修改失败', ERR_PARAMS_ERROR);
}
- $result = $this->orders_model->update(['status'=>-1],['id'=>$row['id']]);
- if($result){
- $this->app_liche_orders_model->update(['status'=>-1],['o_id'=>$row['id']]);
+ $result = $this->orders_model->update(['status' => -1], ['id' => $row['id']]);
+ if ($result) {
+ $this->app_liche_orders_model->update(['status' => -1], ['o_id' => $row['id']]);
//更新客户下单时间
- $this->customers_model->update(array('order_time' => '0000-00-00 00:00:00'),['id'=>$row['customer_id']]);
+ $this->customers_model->update(array('order_time' => '0000-00-00 00:00:00'), ['id' => $row['customer_id']]);
throw new Exception('修改成功', API_CODE_SUCCESS);
- }else{
+ } else {
throw new Exception('修改失败', ERR_PARAMS_ERROR);
}
}
+
//判断金额
- protected function ck_money($money_json,$srv_arr,$biz){
- if($biz['id']==70){
+ protected function ck_money($money_json, $srv_arr, $biz)
+ {
+ if ($biz['id'] == 70) {
$fee_carno_limit = 700;
$price_finance_limit = 1000;
- }elseif($biz['id']==63){
+ } elseif ($biz['id'] == 63) {
$fee_carno_limit = 600;
$price_finance_limit = 0;
- }else{
+ } else {
$fee_carno_limit = 1000;
$price_finance_limit = 1000;
}
- $total_limit = $fee_carno_limit+$price_finance_limit;
- if($biz['type']==1){ //直营店
- $srv_ids = array_column($srv_arr,'id');
- if(!in_array(1,$srv_ids)){
+ $total_limit = $fee_carno_limit + $price_finance_limit;
+ if ($biz['type'] == 1) { //直营店
+ $srv_ids = array_column($srv_arr, 'id');
+ if (!in_array(1, $srv_ids)) {
throw new Exception('保险必填', ERR_PARAMS_ERROR);
}
- if(!in_array(2,$srv_ids)){
+ if (!in_array(2, $srv_ids)) {
throw new Exception('上牌必填', ERR_PARAMS_ERROR);
}
- if($money_json['fee_carno'] && $money_json['price_finance']){//上牌和金融都有填写
+ if ($money_json['fee_carno'] && $money_json['price_finance']) {//上牌和金融都有填写
$ff_price = $money_json['fee_carno'] + $money_json['price_finance'];
- if($ff_price<$total_limit){
- throw new Exception('上牌和金融不得低于'.$total_limit, ERR_PARAMS_ERROR);
+ if ($ff_price < $total_limit) {
+ throw new Exception('上牌和金融不得低于' . $total_limit, ERR_PARAMS_ERROR);
}
- }elseif($money_json['fee_carno'] || $money_json['price_finance']){ //上牌和金融只填写一项
- if($money_json['fee_carno']<$fee_carno_limit && !$money_json['price_finance']){
- throw new Exception('上牌不得低于'.$fee_carno_limit, ERR_PARAMS_ERROR);
+ } elseif ($money_json['fee_carno'] || $money_json['price_finance']) { //上牌和金融只填写一项
+ if ($money_json['fee_carno'] < $fee_carno_limit && !$money_json['price_finance']) {
+ throw new Exception('上牌不得低于' . $fee_carno_limit, ERR_PARAMS_ERROR);
}
- if(!$money_json['fee_carno'] && $money_json['price_finance']<$price_finance_limit){
- throw new Exception('金融不得低于'.$price_finance_limit, ERR_PARAMS_ERROR);
+ if (!$money_json['fee_carno'] && $money_json['price_finance'] < $price_finance_limit) {
+ throw new Exception('金融不得低于' . $price_finance_limit, ERR_PARAMS_ERROR);
}
- }else{ //挂牌和金融都没填写
+ } else { //挂牌和金融都没填写
throw new Exception('上牌和金融不得低于1000', ERR_PARAMS_ERROR);
}
}
}
-}
+
+ /**
+ * Notes:分配订单
+ * Created on: 2022/7/27 14:35
+ * Created by: dengbw
+ * @throws Hd_exception
+ */
+ protected function put_admins()
+ {
+ $id_arr = $this->input_param('ids');
+ $admin_id = $this->input_param('admin_id');
+ if (!$id_arr || !$admin_id) {
+ throw new Hd_exception('参数错误', API_CODE_INVILD_PARAM);
+ }
+ $allot = $this->get_allot();
+ if ($allot == 0) {
+ throw new Hd_exception('无权限分配', API_CODE_INVILD_PARAM);
+ }
+ foreach ($id_arr as $v) {
+ $re = $this->orders_model->get(['id' => $v]);
+ if ($re['admin_id'] == $admin_id) {//同个销售跳出循环
+ continue;
+ }
+ $content = $re['admin_id'] ? '重新分配订单' : '分配订单';
+ $this->orders_model->update(['admin_id' => $admin_id], ['id' => $v]);
+ $this->orders_entity->add_log($v, $this->session['uid'], $this->session['uname'], $content);
+ }
+ throw new Exception('操作成功', API_CODE_SUCCESS);
+ }
+
+ /**
+ * Notes:判断分配客户权限
+ * Created on: 2022/7/27 10:02
+ * Created by: dengbw
+ * @return int
+ */
+ private function get_allot()
+ {
+ $allot = 1;
+ $group_id = $this->session['group_id'];
+ if ($group_id == 1) {//销售不可分配用户
+ $allot = 0;
+ }
+ return $allot;
+ }
+}
\ No newline at end of file
diff --git a/api/controllers/wxapp/licheb/Customerlogs.php b/api/controllers/wxapp/licheb/Customerlogs.php
index 76f2f845..e0bffab9 100644
--- a/api/controllers/wxapp/licheb/Customerlogs.php
+++ b/api/controllers/wxapp/licheb/Customerlogs.php
@@ -60,7 +60,7 @@ class Customerlogs extends Wxapp
$rec_row['duration'] && $second = intval($rec_row['duration'] / 1000);
}
$comments = [];
- $res = $this->mdComments->select(['pid' => $val['id'], 'status' => 1, 'type' => 0], 'id desc', 0, 0
+ $res = $this->mdComments->select(['pid' => $val['id'], 'status' => 1, 'type' => 0], 'id asc', 0, 0
, 'uname,content');
foreach ($res as $key2 => $val2) {
$comments[] = [
diff --git a/api/controllers/wxapp/licheb/Employees.php b/api/controllers/wxapp/licheb/Employees.php
index 9beac01a..10976cbb 100644
--- a/api/controllers/wxapp/licheb/Employees.php
+++ b/api/controllers/wxapp/licheb/Employees.php
@@ -34,7 +34,6 @@ class Employees extends Wxapp
public function get_leave()
{
$id = $this->input_param('id');
- $id = 21;
if (!$id) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
@@ -61,7 +60,7 @@ class Employees extends Wxapp
$out_id = $this->input_param('out_id');
$in_id = $this->input_param('in_id');
$transfer = $this->input_param('transfer');
- if (!$out_id || $in_id || !$transfer) {
+ if (!$out_id || !$in_id || !$transfer) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
$this->load->model('receiver/receiver_customers_model', 'mdCustomer');