115 lines
4.8 KiB
PHP
115 lines
4.8 KiB
PHP
<?php
|
|
defined('WXAPP_APP') OR exit('No direct script access allowed');
|
|
/**
|
|
* Created by vim
|
|
* User: lcc
|
|
* Desc: 商务政策
|
|
* Date: 2021/03/11
|
|
* Time: 10:22
|
|
*/
|
|
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
|
|
class Business extends Wxapp{
|
|
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->load->model('auto/auto_cars_model');
|
|
$this->load->model('auto/auto_business_model');
|
|
$this->load->model("biz/biz_model");
|
|
$this->load->model('receiver/order/receiver_orders_v2_model');
|
|
$this->load->model('app/liche/app_liche_orders_model');
|
|
$this->load->library('receiver/orders_v2_entity');
|
|
}
|
|
|
|
protected function get(){
|
|
$biz_id = $this->get_biz_id();
|
|
$s_id = $this->input_param('car_id');
|
|
$v_id = $this->input_param('v_id');
|
|
$color_id = $this->input_param('color_id');
|
|
$main_type = $this->input_param('main_type');
|
|
$oid = $this->input_param('oid');
|
|
$biz = $this->biz_model->get(['id'=>$biz_id],'city_id');
|
|
$city_id = $biz['city_id'];
|
|
$where = [
|
|
's_id'=>$s_id,
|
|
'v_id'=>$v_id,
|
|
'status'=>1,
|
|
'if_effect'=>1,
|
|
'city_id'=>$city_id,
|
|
];
|
|
$rows = $this->auto_business_model->select($where,'id desc',1,1);
|
|
$row = $rows[0];
|
|
if($oid){
|
|
$order = $this->receiver_orders_v2_model->get(['id'=>$oid]);
|
|
$info_json = json_decode($order['info_json'],true);
|
|
$business_id = $info_json['business_id'];
|
|
//存在已支付订单
|
|
//$if_pay = $this->app_liche_orders_model->count(['o_id'=>$oid,'status'=>1]);
|
|
if($order && $s_id==$order['s_id'] && $v_id==$order['v_id']){
|
|
$row = $this->auto_business_model->get(['id'=>$business_id]);
|
|
}else{
|
|
throw new Exception('当前地区不支持销售该车型', API_CODE_FAIL);
|
|
}
|
|
//修改商务政策id
|
|
if($s_id==$order['s_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'],
|
|
's_id' => $s_id,
|
|
'v_id' => $v_id,
|
|
's_effect_time>=' => $s_time,
|
|
's_effect_time<=' => $e_time,
|
|
];
|
|
$row = $this->auto_business_model->get($where);
|
|
}
|
|
}
|
|
}
|
|
$car['price_car'] = $row['price_car'];
|
|
$car['price_floor'] = $row['price_floor'];
|
|
$dis_money = $car['price_car'] - $car['price_floor'];
|
|
|
|
$where_car = array(
|
|
's_id'=>$s_id,
|
|
'v_id' => $v_id,
|
|
);
|
|
$v_id!=113 && $where_car['status'] = 1;//哪吒 U 2021款Pro400巡航版 不判断状态
|
|
$c_row = $this->auto_cars_model->get($where_car,'',$city_id);
|
|
$dis_fine_money = $c_row['price_fine_floor']>0 && $c_row['price_fine']-$c_row['price_fine_floor']>0 ? $c_row['price_fine']-$c_row['price_fine_floor'] : 0;
|
|
|
|
$dis_money_list = [500,1000,2000];
|
|
$dis_fine_money_list = [500,1000,1500];
|
|
$deposit_list = [2000,3000,5000];
|
|
$color_arr = json_decode($row['colors'],true);
|
|
$price_color = in_array($color_id,$color_arr) ? $row['price_color'] : 0;
|
|
$price_coplus = $main_type ? $row['price_coplus'] : 0;
|
|
|
|
$city_list = $this->orders_v2_entity->local_bill_citys;
|
|
$show_local_bill = false;
|
|
if(in_array($city_id,$city_list)){
|
|
$show_local_bill = true;
|
|
}
|
|
$data = [
|
|
'id' => $row['id'],
|
|
'price' => $car['price_car'] ? floatval($car['price_car']) : 0,
|
|
'dis_money' => $dis_money,
|
|
'dis_money_list' => $dis_money_list,
|
|
'fine_money' => floatval($car['price_fine']),
|
|
'dis_fine_money' => $dis_fine_money,
|
|
'dis_fine_money_list' => $dis_fine_money_list,
|
|
'deposit_list' => $deposit_list,
|
|
'price_color' => floatval($price_color),
|
|
'price_coplus' => floatval($price_coplus),
|
|
'show_local_bill' => $show_local_bill,
|
|
];
|
|
return $data;
|
|
|
|
}
|
|
}
|