diff --git a/api/controllers/wxapp/licheb/CusorderV2.php b/api/controllers/wxapp/licheb/CusorderV2.php index 4755a650..78b531f5 100644 --- a/api/controllers/wxapp/licheb/CusorderV2.php +++ b/api/controllers/wxapp/licheb/CusorderV2.php @@ -182,7 +182,6 @@ class CusorderV2 extends Wxapp{ 'price_fine' => $car_row['price_fine'], 'price_discount' =>$disc_money ? $disc_money : 0, 'price_intention' => $inten_money ? $inten_money : 0, - 'price_finance' => $series_row['brand_id'] == 4 ? $orders_entity::PRICE_FINANCE_NZ : $orders_entity::PRICE_FINANCE, 'price_fine_discount' => $disc_fine_money ? $disc_fine_money : 0, 'price_fine_select' => 0, 'price_color' => $price_color, @@ -204,9 +203,8 @@ class CusorderV2 extends Wxapp{ } } $data['car_json'] = $data['money_json'] = json_encode($money_json,JSON_UNESCAPED_UNICODE); - - if(in_array($row['biz_id'],[63,70]) && $biz['type']==1){ //判断金额 - + if($biz['type']==1){ + $this->ck_money($money_json,$srv_arr); } $o_id = $this->orders_model->add($data); @@ -278,11 +276,7 @@ class CusorderV2 extends Wxapp{ $company && $info_json['c_company'] = $company; $c_credit && $info_json['c_credit'] = $c_credit; $info_json && $data['info_json'] = json_encode($info_json,JSON_UNESCAPED_UNICODE); - //获取挂牌价 - $biz = $this->biz_model->get(['id'=>$row['biz_id']],'city_id'); - $city = $this->sys_city_model->get(['city_id'=>$biz['city_id']],'fee_carno'); - $money_json['fee_carno'] = $city['fee_carno']; $money_json['price_intention'] = $inten_money ? $inten_money : 0; $data['money_json'] = json_encode($money_json,JSON_UNESCAPED_UNICODE); @@ -328,6 +322,11 @@ class CusorderV2 extends Wxapp{ $series_row = $this->auto_series_model->get(['id'=>$car_id]); $biz = $this->biz_model->get(['id'=>$row['biz_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); + if($v_id==$row['v_id']){ //修改不同车型才修改商务政策id + $business_id = $info_json['business_id']; + } $business_row = $this->auto_business_model->get(['id'=>$business_id]); if(!$row || !$series_row || !$car_row || !$business_row){ throw new Exception('参数错误', ERR_PARAMS_ERROR); @@ -350,7 +349,6 @@ class CusorderV2 extends Wxapp{ } } - $info_json = json_decode($row['info_json'],true); if(!$main_type){//个人 //同个品牌一个身份证只能下一单 $where = [ @@ -384,17 +382,16 @@ class CusorderV2 extends Wxapp{ //获取金额json数据 $money_json = json_decode($row['money_json'],true); $data['car_json'] = json_encode($money_json,JSON_UNESCAPED_UNICODE); - $money_json['price_car'] = $car_row['price_car']; + $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_finance'] = $series_row['brand_id'] == 4 ? Orders_v2_entity::PRICE_FINANCE_NZ : Orders_v2_entity::PRICE_FINANCE; $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){ + $money_json['price_finance'] = $money_json['fee_carno'] = 0; foreach ($srv_arr as $item) { $money_json[$item['key']] = $item['price']; $item['id'] == 1 && $data['if_insure'] = 1; @@ -410,11 +407,13 @@ class CusorderV2 extends Wxapp{ } } } - $data['money_json'] = json_encode($money_json,JSON_UNESCAPED_UNICODE); - if($v_id!=$row['v_id']){ //修改不同车型才修改商务政策id - $info_json['business_id'] = $business_id; - $data['info_json'] = json_encode($info_json,JSON_UNESCAPED_UNICODE); + if($biz['type']==1 && $row['c_time']>=strtotime('2022-04-08 14:43:00')){ + $this->ck_money($money_json,$srv_arr); } + + $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); @@ -806,4 +805,29 @@ class CusorderV2 extends Wxapp{ throw new Exception('修改失败', ERR_PARAMS_ERROR); } } + //判断金额 + protected function ck_money($money_json,$srv_arr){ + $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)){ + throw new Exception('上牌必填', ERR_PARAMS_ERROR); + } + if($money_json['fee_carno'] && $money_json['price_finance']){//上牌和金融都有填写 + $ff_price = $money_json['fee_carno'] + $money_json['price_finance']; + if($ff_price<2000){ + throw new Exception('上牌和金融不得低于2000', ERR_PARAMS_ERROR); + } + }elseif($money_json['fee_carno'] || $money_json['price_finance']){ //上牌和金融只填写一项 + if($money_json['fee_carno']<1000 && !$money_json['price_finance']){ + throw new Exception('上牌不得低于1000', ERR_PARAMS_ERROR); + } + if(!$money_json['fee_carno'] && $money_json['price_finance']<1000){ + throw new Exception('金融不得低于1000', ERR_PARAMS_ERROR); + } + }else{ //挂牌和金融都没填写 + throw new Exception('上牌和金融不得低于100', ERR_PARAMS_ERROR); + } + } }