Files
liche/api/controllers/wxapp/app/Business.php
T
2022-03-24 22:29:48 +08:00

80 lines
3.0 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");
}
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');
$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,
'year' => date('Y'),
'month' => intval(date('m'))
];
$row = $this->auto_business_model->get($where);
if(!$row){
throw new Exception('当前地区不支持销售该车型', API_CODE_FAIL);
}
$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;
$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)
];
return $data;
}
}