orderv2 add zero_first_pay about

This commit is contained in:
qianhy
2023-03-29 13:47:24 +08:00
committed by lccsw
parent f5016bae10
commit f44f84aaa2
3 changed files with 50 additions and 6 deletions
+27 -5
View File
@@ -96,11 +96,13 @@ class CusorderV2 extends Wxapp
$pro = $this->input_param('pro'); //省市数组
$sa = $this->input_param('sa'); //补充协商
$if_local_bill = $this->input_param('if_local_bill');//是否需要开具本地发票
$if_zero_firstpay = $this->input_param('if_zero_firstpay');//$payway=0下是否0首付;0首付区分:payway==0 && money_json.price_book==0
//$if_zero_firstpay = 1; $deposit = 0; // 模拟0首付
$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) {
if (!$row || !$series_row || !$delry_time || !$name || !$mobile || !$business_row || !$if_zero_firstpay && !$deposit) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
if ($if_local_bill && !$car_city_id) {
@@ -125,7 +127,7 @@ class CusorderV2 extends Wxapp
// throw new Exception('一个客户只能享受一次国补,请联系管理员', ERR_PARAMS_ERROR);
// }
}
if ($deposit < 1000) {
if (!$if_zero_firstpay && $deposit < 1000) {
throw new Exception('定金不得少于1000', ERR_PARAMS_ERROR);
}
$biz = $this->biz_model->get(['id' => $row['biz_id']], 'id,city_id,type');
@@ -249,6 +251,10 @@ class CusorderV2 extends Wxapp
if ($payway) { //全款服务费和尾款订单
$this->orders_v2_entity->add_order($o_id, $userinfo['id']);
}
//0首付 - 已下定
if ($if_zero_firstpay){
$this->orders_status_entity->set_status($o_id,0,1);
}
//更新客户下单时间
$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);
@@ -364,6 +370,7 @@ class CusorderV2 extends Wxapp
$business_id = $this->input_param('business_id'); //商务政策id
$sa = $this->input_param('sa'); //补充协商
$if_local_bill = $this->input_param('if_local_bill');//是否需要开具本地发票
$if_zero_firstpay = $this->input_param('if_zero_firstpay');//$payway=0下是否0首付;0首付区分:payway==0 && money_json.price_book==0
$row = $this->orders_model->get(['id' => $id]);
$main_type = $row['main_type'];
@@ -395,7 +402,7 @@ class CusorderV2 extends Wxapp
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
if ($deposit < 1000) {
if (!$if_zero_firstpay && $deposit < 1000) {
throw new Exception('定金不得少于1000', ERR_PARAMS_ERROR);
}
if($biz['id']!=160){
@@ -499,6 +506,12 @@ class CusorderV2 extends Wxapp
$result = $this->orders_model->update($data, ['id' => $row['id']]);
if ($result) {
$this->orders_v2_entity->edit_order($data, $row, $this->session);
//0首付 - 已下定
if ($if_zero_firstpay){
$this->orders_status_entity->set_status($row['id'],0,1);
}
//补充协商
$sa && $this->order_datas_entity->up_data($row['id'], ['sa' => $sa]);
throw new Exception('修改成功', API_CODE_SUCCESS);
@@ -524,6 +537,9 @@ class CusorderV2 extends Wxapp
$version = $this->auto_attr_model->get(['id' => $row['v_id']], 'title');
$color = $color ? $color['title'] : '';
$version = $version ? $version['title'] : '';
$payway = $row['payway'];
$deposit = $money_json['price_book'];
$if_zero_firstpay = $payway == 0 && !$deposit ? 1 : 0;
$car_data = [];
if ($row['brand_id'] && $row['s_id'] && $row['v_id']) {
@@ -533,7 +549,8 @@ class CusorderV2 extends Wxapp
$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']);
$if_zero_firstpay && $car_data['0首付'] = '是';
!$if_zero_firstpay && $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['最终售价'] = [
@@ -609,6 +626,7 @@ class CusorderV2 extends Wxapp
'c_city_id' => $info_json['car_city_id'],
'if_local_bill' => $row['if_local_bill'],
];
$data['if_zero_firstpay'] = $if_zero_firstpay;
if ($row['main_type']) {
$info_json['c_credit'] && $data['credit'] = $info_json['c_credit'];
$info_json['c_company'] && $data['company'] = $info_json['c_company'];
@@ -849,9 +867,13 @@ class CusorderV2 extends Wxapp
$other_data['意向金金额'] = ['type' => 'text', 'value' => $price_book_text, 'bg_color' => ''];
}
if ($book_is_pay) {
$payway = $val['payway'];
$deposit = $money_json['price_book'];
$if_zero_firstpay = $payway == 0 && !$deposit ? 1 : 0;
$if_zero_firstpay && $other_data['0首付'] = ['type' => 'text', 'value' => '是', 'bg_color' => ''];
$book_is_pay_text = $book_is_pay['status'] ? '已支付' : '未支付';
$price_book_text = number_format($money_json['price_book'], 2) . "($book_is_pay_text)";
$other_data['定金金额'] = ['type' => 'text', 'value' => $price_book_text, 'bg_color' => ''];
!$if_zero_firstpay && $other_data['定金金额'] = ['type' => 'text', 'value' => $price_book_text, 'bg_color' => ''];
}
if ($ht_pay['total_price']) {
$ht_price = number_format($ht_pay['total_price'], 2);
+8
View File
@@ -505,6 +505,10 @@ class Qyrobot{
where o_id>=10000 and status=1 and pid!=0 and pay_price>0 and pay_time!='0000-00-00 00:00:00' and type <> 4 and pay_price>{$min_price} group by o_id order by o_id desc) as a
left join lc_receiver_orders_v2 as b on a.o_id=b.id
where a.pay_time>='{$today_s_time}' and a.pay_time<='{$today_e_time}' and b.brand_id!=12 group by b.brand_id";
$sql = "select brand_id,count(a.o_id) as total from (select o_id,min(pay_time) as pay_time from lc_app_liche_orders
where o_id>=10000 and status=1 and pid!=0 and (type=1 and pay_price=0 or pay_price>{$min_price}) and pay_time!='0000-00-00 00:00:00' and pay_time>='{$today_s_time}' and pay_time<='{$today_e_time}' and type <> 4 group by o_id order by o_id desc) as a
left join lc_receiver_orders_v2 as b on a.o_id=b.id
where b.brand_id!=12 group by b.brand_id";
$today_rows = $this->ci->db->query($sql)->result_array();
$today_count = 0;
$today_info = [];
@@ -522,6 +526,10 @@ class Qyrobot{
where o_id>=10000 and status=1 and pid!=0 and pay_price>0 and pay_time!='0000-00-00 00:00:00' and type <> 4 and pay_price>{$min_price} group by o_id order by o_id desc) as a
left join lc_receiver_orders_v2 as b on a.o_id=b.id
where a.pay_time>='{$month_s_time}' and a.pay_time<='{$month_e_time}' and b.brand_id!=12 group by b.brand_id";
$sql = "select brand_id,count(a.o_id) as total from (select o_id,min(pay_time) as pay_time from lc_app_liche_orders
where o_id>=10000 and status=1 and pid!=0 and (type=1 and pay_price=0 || pay_price>{$min_price}) and pay_time!='0000-00-00 00:00:00' and pay_time>='{$month_s_time}' and pay_time<='{$month_e_time}' and type <> 4 group by o_id order by o_id desc) as a
left join lc_receiver_orders_v2 as b on a.o_id=b.id
where b.brand_id!=12 group by b.brand_id";
$month_rows = $this->ci->db->query($sql)->result_array();
$month_count = 0;
$month_info = [];
+15 -1
View File
@@ -250,7 +250,12 @@ class Orders_v2_entity{
$deposit_count = $this->ci->app_liche_orders_model->count(['o_id'=>$oid,'type'=>1,'status'=>1]); //定金已支付
$need_pay_money = $money_json['price_book'] - $pay_money['total_price'] - $ht_money['pay_price'];
$res = false;
if($need_pay_money > 0 && !$deposit_count){
//if($need_pay_money > 0 && !$deposit_count){
$payway = $this->order_row['payway'];
$money_json = json_decode($this->order_row['money_json'], true);
$deposit = $money_json['price_book'];
$if_zero_firstpay = $payway == 0 && !$deposit ? 1 : 0;
if(($if_zero_firstpay || $need_pay_money > 0) && !$deposit_count){
$entrust_user = $this->entrust_user($this->order_row['id']);
$p_row = $this->ci->app_liche_orders_model->get(['o_id'=>$this->order_row['id'],'pid'=>0,'status>='=>0]);
if(!$p_row){
@@ -296,9 +301,18 @@ class Orders_v2_entity{
'total_price' => $need_pay_money,
'c_time' => time()
];
$if_zero_firstpay && $sub_data['status'] = 1; // 0首付强制为已支付
$if_zero_firstpay && $sub_data['pay_time'] = date('Y-m-d H:i:s'); // 0首付强制支付时间
$if_zero_firstpay && $sub_data['descrip'] = '0首付';
$entrust_user['id'] && $sub_data['entrust_uid'] = $entrust_user['id'];
$uid && $sub_data['uid'] = $uid;
$res = $this->ci->app_liche_orders_model->add($sub_data);
//0首付播报
if ($if_zero_firstpay && $res){
$this->ci->load->library('qyrobot');
$this->ci->qyrobot->deposit_notify_v3($oid);
}
}
}
return $res;