edit-licheb-api
This commit is contained in:
@@ -50,7 +50,7 @@
|
||||
<label class="am-para-label">首付:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="text" name="first_pay" v-model="info.first_pay" style="width: 20%; display: inline"/>
|
||||
<span>万元</span>
|
||||
<span>元</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
<div class="coms-table-wrap">
|
||||
<div class="coms-table-hd clearfix no-border">
|
||||
<form action="/auto/cars/lists" class="form-search" onsubmit="return false">
|
||||
<form action="/auto/finance/lists" class="form-search" onsubmit="return false">
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label">状态:</label>
|
||||
@@ -27,7 +27,7 @@
|
||||
<th width="15%"><span>车型</span></th>
|
||||
<th width="15%"><span>金融产品</span></th>
|
||||
<th width="10%"><span>期数</span></th>
|
||||
<th width="15%"><span>首付/(万)</span></th>
|
||||
<th width="15%"><span>首付</span></th>
|
||||
<th width="15%"><span>月供</span></th>
|
||||
<th width="15%"><span>服务费</span></th>
|
||||
<th width=""><span>操作</span></th>
|
||||
|
||||
@@ -32,7 +32,14 @@ class Cusorder extends Wxapp{
|
||||
$this->load->model('auto/auto_series_model');
|
||||
$this->load->model('auto/auto_brand_model');
|
||||
$this->load->model('auto/auto_attr_model');
|
||||
$this->load->model('auto/auto_cars_model');
|
||||
$this->load->model('auto/auto_finance_model');
|
||||
|
||||
$this->load->model('apporder/order_purchase_model');
|
||||
|
||||
$this->load->model("biz/biz_model");
|
||||
$this->load->model('sys/sys_city_model');
|
||||
$this->load->model('sys/sys_finance_model');
|
||||
}
|
||||
|
||||
protected function get(){
|
||||
@@ -64,6 +71,7 @@ class Cusorder extends Wxapp{
|
||||
$address = $this->input_param('address');
|
||||
$cardid = $this->input_param('cardid');
|
||||
$delry_time = $this->input_param('delry_time');
|
||||
$fin_nums_id = $this->input_param('fin_nums_id');
|
||||
|
||||
$row = $this->customers_model->get(['id'=>$cus_id]);
|
||||
$series_row = $this->auto_series_model->get(['id'=>$car_id]);
|
||||
@@ -71,9 +79,21 @@ class Cusorder extends Wxapp{
|
||||
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
||||
}
|
||||
//判断是否存在未完成流程
|
||||
if($this->orders_model->get_step($row['mobile'])){
|
||||
$omobile = $mobile ? $mobile : $row['mobile'];
|
||||
if($this->orders_model->get_step($omobile)){
|
||||
throw new Exception('该手机号用户存在未完成订单', API_CODE_FAIL);
|
||||
}
|
||||
$car_row = $this->auto_cars_model->get(['brand_id'=>$series_row['brand_id'],'s_id'=>$series_row['id'],'v_id'=>$v_id,'cor_id'=>$color_id,'incor_id'=>$incolor_id]);
|
||||
if(!$car_row){
|
||||
throw new Exception('参数错误', API_CODE_FAIL);
|
||||
}
|
||||
if(!$payway){ //分期
|
||||
$finance_row = $this->auto_finance_model->get(['id'=>$fin_nums_id]);
|
||||
if(!$finance_row){
|
||||
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
$where = [
|
||||
"id in ($v_id,$color_id,$incolor_id)" => null
|
||||
];
|
||||
@@ -129,6 +149,29 @@ class Cusorder extends Wxapp{
|
||||
$cardid && $info_json['c_cardid'] = $cardid;
|
||||
$address && $info_json['c_address'] = $address;
|
||||
$info_json && $data['info_json'] = json_encode($info_json,JSON_UNESCAPED_UNICODE);
|
||||
$finance_row && $data['finance_id'] = $finance_row['id'];
|
||||
//获取金额json数据
|
||||
$money_json = [
|
||||
'price_car' => $car_row['price_car'],
|
||||
'price_book' => $car_row['price_book'],
|
||||
'price_insure' => $car_row['price_insure'],
|
||||
'price_fine' => $car_row['price_fine'],
|
||||
];
|
||||
//获取挂牌价
|
||||
if($series_row['brand_id']==3){ //狸车品牌写死挂牌费用0.01 测试用
|
||||
$money_json['fee_carno'] = 0.01;
|
||||
}else{
|
||||
$biz = $this->biz_model->get(['id'=>$row['biz_id']],'company_id,city_id');
|
||||
$city = $this->sys_city_model->get(['city_id'=>$biz['city_id']],'fee_carno');
|
||||
$money_json['fee_carno'] = $city['fee_carno'];
|
||||
}
|
||||
|
||||
if(!$payway){ //分期
|
||||
$money_json['price_finance'] = $finance_row['srv_pay'];
|
||||
$money_json['first_pay'] = $finance_row['first_pay'];
|
||||
$money_json['month_pay'] = $finance_row['month_pay'];
|
||||
}
|
||||
$data['money_json'] = json_encode($money_json,JSON_UNESCAPED_UNICODE);
|
||||
$o_id = $this->orders_model->add($data);
|
||||
if($o_id){
|
||||
$sign_data = [
|
||||
@@ -325,6 +368,15 @@ class Cusorder extends Wxapp{
|
||||
}
|
||||
$info_json['c_address'] && $car_data['地址'] = $info_json['c_address'];
|
||||
$info_json['c_cardid'] && $car_data['身份证号'] = $info_json['c_cardid'];
|
||||
if(!$row['payway']){
|
||||
$money_json = json_decode($row['money_json'],true);
|
||||
$auto_finance_row = $this->auto_finance_model->get(['id'=>$row['finance_id']],'fin_id,num');
|
||||
$finance_row = $this->sys_finance_model->get(['id'=>$auto_finance_row['fin_id']],'title');
|
||||
$car_data['金融产品'] = $finance_row['title'];
|
||||
$car_data['分期期数'] = $auto_finance_row['num'];
|
||||
$car_data['贷款金额'] = $money_json['price_car'] - $money_json['first_pay'];
|
||||
$car_data['月供'] = $money_json['month_pay'];
|
||||
}
|
||||
//开票信息
|
||||
$bill_status = 0;
|
||||
$bill_data = [];
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
defined('WXAPP_APP') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Created by Vim
|
||||
* User: lcc
|
||||
* Date: 2021/09/09
|
||||
* Time: 14:08
|
||||
*/
|
||||
require_once APPPATH.'controllers/wxapp/Wxapp.php';
|
||||
class Finance extends Wxapp{
|
||||
|
||||
public 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_series_model');
|
||||
$this->load->model('auto/auto_cars_model');
|
||||
$this->load->model('auto/auto_finance_model');
|
||||
$this->load->model('sys/sys_finance_model');
|
||||
}
|
||||
|
||||
protected function get(){
|
||||
$page = $this->input_param('page');
|
||||
$size = $this->input_param('size');
|
||||
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 10;
|
||||
|
||||
$where = [
|
||||
'status' => 1
|
||||
];
|
||||
$count = $this->sys_finance_model->count($where);
|
||||
$lists = [];
|
||||
if($count){
|
||||
$rows = $this->sys_finance_model->select($where,'id desc',$page,$size,'id,title');
|
||||
foreach($rows as $key => $val){
|
||||
$lists[] = $val;
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'list' => $lists,
|
||||
'total' => $count
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function get_nums(){
|
||||
$car_id = $this->input_param('car_id');
|
||||
$color_id = $this->input_param('color_id');
|
||||
$incolor_id = $this->input_param('incolor_id');
|
||||
$v_id = $this->input_param('v_id');
|
||||
$finance_id = $this->input_param('finance_id');
|
||||
$page = $this->input_param('page');
|
||||
$size = $this->input_param('size');
|
||||
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 10;
|
||||
|
||||
$series_row = $this->auto_series_model->get(['id'=>$car_id],'id,brand_id');
|
||||
$row = $this->auto_finance_model->get(['id'=>$finance_id],'id');
|
||||
if(!$series_row || !$row){
|
||||
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$car_row = $this->auto_cars_model->get(['brand_id'=>$series_row['brand_id'],'s_id'=>$series_row['id'],'v_id'=>$v_id,'cor_id'=>$color_id,'incor_id'=>$incolor_id],'id,price_car');
|
||||
|
||||
$where = [
|
||||
'car_id' => $car_row['id'],
|
||||
'fin_id' => $row['id'],
|
||||
'status' => 1
|
||||
];
|
||||
$count = $this->auto_finance_model->count($where);
|
||||
$lists = [];
|
||||
if($count){
|
||||
$rows = $this->auto_finance_model->select($where,'id desc',$page,$size,'id,num,first_pay,month_pay');
|
||||
foreach($rows as $key => $val){
|
||||
$loan_money = $car_row['price_car'] - $val['first_pay'];
|
||||
$lists[] = [
|
||||
'id' => $val['id'],
|
||||
'num' => $val['num'],
|
||||
'loan_money' => $loan_money,
|
||||
'month_pay' => $val['month_pay']
|
||||
];
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'list' => $lists,
|
||||
'total' => $count
|
||||
];
|
||||
return $data;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -79,33 +79,13 @@ class Protocol extends CI_Controller{
|
||||
$contract = $this->contracts_model->get(['o_id'=>$id,'type'=>1]);
|
||||
$total_price = 0;
|
||||
if($row){
|
||||
$money_json = json_decode($row['money_json'],true);
|
||||
//获取门店信息
|
||||
$biz = $this->biz_model->get(['id'=>$row['biz_id']]);
|
||||
$row['company'] = $this->sys_company_model->get(["title like '%服务%'"=>null,'status'=>1]);
|
||||
//获取服务包
|
||||
$packs = $this->package_model->get(['id'=>$row['pack_id']],'srv_ids');
|
||||
if($packs['srv_ids']){
|
||||
$row['services'] = $services = $this->services_model->select(["id in ({$packs['srv_ids']})"=>null],'','','','title,field_name');
|
||||
}
|
||||
$where_car = array(
|
||||
's_id'=>$row['s_id'],
|
||||
'v_id' => $row['v_id'],
|
||||
'cor_id' => $row['cor_id'],
|
||||
'incor_id' => $row['incor_id']
|
||||
);
|
||||
$car = $this->auto_cars_model->get($where_car);
|
||||
//获取挂牌价
|
||||
$this->load->model('sys/sys_city_model');
|
||||
$city = $this->sys_city_model->get(['city_id'=>$biz['city_id']],'fee_carno');
|
||||
$car['fee_carno'] = $city['fee_carno'];
|
||||
if($services){
|
||||
foreach($services as $key=>$val){
|
||||
$field_arr = explode('.',$val['field_name']);
|
||||
if($car[$field_arr[1]]){
|
||||
$total_price += $car[$field_arr[1]];
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->load->library('receiver/orders_entity');
|
||||
$srv_price = $this->orders_entity->order_srv_money($row['id']);
|
||||
$total_price = $srv_price + $money_json['price_insure'];
|
||||
}
|
||||
$row['total_price'] = $total_price;
|
||||
$row['info_json'] = json_decode($row['info_json'],true);
|
||||
@@ -158,6 +138,7 @@ class Protocol extends CI_Controller{
|
||||
$brand = $this->auto_brand_model->get(['id'=>$row['brand_id']],'name');
|
||||
$series = $this->auto_series_model->get(['id'=>$row['s_id']],'name');
|
||||
$car_json = json_decode($row['car_json'],true);
|
||||
$money_json = json_decode($row['money_json'],true);
|
||||
$row['info_json'] = $info_json = json_decode($row['info_json'],true);
|
||||
$row['color'] = isset($car_json['color']) ? $car_json['color']['title'] : '';
|
||||
$row['incolor'] = isset($car_json['incolor']) ? $car_json['incolor']['title'] : '';
|
||||
@@ -169,37 +150,15 @@ class Protocol extends CI_Controller{
|
||||
$biz = $this->biz_model->get(['id'=>$row['biz_id']]);
|
||||
$company = $this->sys_company_model->get(['id'=>$biz['company_id']]);
|
||||
$row['company'] = $company;
|
||||
//获取服务包
|
||||
$packs = $this->package_model->get(['id'=>$row['pack_id']],'srv_ids');
|
||||
if($packs['srv_ids']){
|
||||
$row['services'] = $services = $this->services_model->select(["id in ({$packs['srv_ids']})"=>null],'','','','title,field_name');
|
||||
}
|
||||
$where_car = array(
|
||||
's_id'=>$row['s_id'],
|
||||
'v_id' => $row['v_id'],
|
||||
'cor_id' => $row['cor_id'],
|
||||
'incor_id' => $row['incor_id']
|
||||
);
|
||||
$car = $this->auto_cars_model->get($where_car);
|
||||
//获取挂牌价
|
||||
$this->load->model('sys/sys_city_model');
|
||||
$city = $this->sys_city_model->get(['city_id'=>$biz['city_id']],'fee_carno');
|
||||
$car['fee_carno'] = $city['fee_carno'];
|
||||
if($services){
|
||||
foreach($services as $key=>$val){
|
||||
$field_arr = explode('.',$val['field_name']);
|
||||
if($car[$field_arr[1]]){
|
||||
$total_price += $car[$field_arr[1]];
|
||||
}
|
||||
}
|
||||
}
|
||||
$where = [
|
||||
'item_id' => $row['id'],
|
||||
'app_id' => 1,
|
||||
'status>' => 1
|
||||
];
|
||||
$pay = $this->purchase_model->sum('total_price',$where);
|
||||
$row['pay_price'] = $pay['total_price']+$car['price_insure'];
|
||||
$row['pay_price'] = $pay['total_price'];
|
||||
$this->load->library('receiver/orders_entity');
|
||||
$total_price = $this->orders_entity->order_srv_money($row['id']);
|
||||
}
|
||||
$row['total_price'] = $total_price;
|
||||
$row['agent'] = $agent;
|
||||
|
||||
@@ -7,9 +7,28 @@ class Orders_entity{
|
||||
|
||||
private $ci;
|
||||
const SRV_MCH_ID = '1612636924'; //收取服务费商户号 厦门狸车服务
|
||||
private $order_row;
|
||||
|
||||
public function __construct(){
|
||||
$this->ci = & get_instance();
|
||||
$this->ci->load->model('receiver/receiver_customers_model','customers_model');
|
||||
|
||||
$this->ci->load->model('receiver/order/receiver_orders_model','orders_model');
|
||||
$this->ci->load->model('receiver/order/receiver_order_signs_model','signs_model');
|
||||
$this->ci->load->model('receiver/order/receiver_order_contracts_model');
|
||||
|
||||
$this->ci->load->model('receiver/receiver_service_package_model','package_model');
|
||||
$this->ci->load->model('receiver/receiver_services_model','services_model');
|
||||
|
||||
$this->ci->load->model('sys/sys_city_model');
|
||||
$this->ci->load->model("sys/sys_company_model");
|
||||
|
||||
$this->ci->load->model('apporder/order_purchase_model');
|
||||
$this->ci->load->model('auto/auto_brand_model');
|
||||
$this->ci->load->model('auto/auto_series_model');
|
||||
$this->ci->load->model('auto/auto_cars_model');
|
||||
|
||||
$this->ci->load->model("biz/biz_model");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -52,15 +71,11 @@ class Orders_entity{
|
||||
* @param $userinfo array 小程序用户信息
|
||||
*/
|
||||
public function sign_after($oid,$app_id,$userinfo){
|
||||
$this->ci->load->model('receiver/order/receiver_orders_model','orders_model');
|
||||
$this->ci->load->model('receiver/order/receiver_order_signs_model','signs_model');
|
||||
$this->ci->load->model('receiver/receiver_customers_model','customers_model');
|
||||
$this->ci->load->model('apporder/order_purchase_model');
|
||||
$row = $this->ci->orders_model->get(['id'=>$oid]);
|
||||
if(!$row){
|
||||
$this->order_row = $this->ci->orders_model->get(['id'=>$oid]);
|
||||
if(!$this->order_row){
|
||||
return false;
|
||||
}
|
||||
$customers = $this->ci->customers_model->get(['id'=>$row['rid']],'rid');
|
||||
$customers = $this->ci->customers_model->get(['id'=>$this->order_row['rid']],'rid');
|
||||
$ifpay = false;
|
||||
$ifpay = $this->ci->order_purchase_model->count(['status>'=>1,'item_id'=>$oid,'app_id',$app_id,'app_uid'=>$userinfo['uid']]);
|
||||
if($customers['rid'] && !$ifpay){ //判断线索是否支付定金
|
||||
@@ -68,7 +83,7 @@ class Orders_entity{
|
||||
}
|
||||
if($ifpay){
|
||||
$this->ci->signs_model->update(['status'=>2],['o_id'=>$oid]);
|
||||
if($row['payway']){//全款
|
||||
if($this->order_row['payway']){//全款
|
||||
$status = 2;
|
||||
$this->ci->load->model('receiver/order/receiver_order_ckcars_model','next_model');
|
||||
}else{
|
||||
@@ -76,17 +91,26 @@ class Orders_entity{
|
||||
$this->ci->load->model('receiver/order/receiver_order_loans_model','next_model');
|
||||
}
|
||||
//判断下一步是否存在
|
||||
if(!$this->ci->next_model->get(['o_id'=>$row['id']])){
|
||||
$res = $this->ci->orders_model->update(['status'=>$status],['id'=>$row['id']]);
|
||||
if(!$this->ci->next_model->get(['o_id'=>$this->order_row['id']])){
|
||||
$res = $this->ci->orders_model->update(['status'=>$status],['id'=>$this->order_row['id']]);
|
||||
if($res){
|
||||
$this->ci->next_model->add(['o_id'=>$row['id'],'c_time'=>time()]);
|
||||
$this->ci->next_model->add(['o_id'=>$this->order_row['id'],'c_time'=>time()]);
|
||||
}
|
||||
}else{
|
||||
$res = $this->ci->orders_model->update(['status'=>2],['id'=>$row['id']]);
|
||||
}
|
||||
}else{
|
||||
$this->ci->signs_model->update(['status'=>1],['o_id'=>$row['id']]);
|
||||
$res = $this->c_order(self::SRV_MCH_ID,$row,$app_id,$userinfo);
|
||||
$this->ci->signs_model->update(['status'=>1],['o_id'=>$this->order_row['id']]);
|
||||
$srv_money = $this->order_srv_money($oid);
|
||||
if($srv_money < $this->order_row['deposit']){ //服务费小于定金 给销售公司
|
||||
//获取门店信息
|
||||
$biz = $this->ci->biz_model->get(['id'=>$this->order_row['biz_id']],'company_id');
|
||||
$company = $this->ci->sys_company_model->get(['id'=>$biz['company_id']],'wx_mchid');
|
||||
$mch_id = $company['wx_mchid'];
|
||||
}else{
|
||||
$mch_id = self::SRV_MCH_ID;
|
||||
}
|
||||
$res = $this->c_order($mch_id,$this->order_row,$app_id,$userinfo);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
@@ -99,9 +123,6 @@ class Orders_entity{
|
||||
* return boolean
|
||||
*/
|
||||
public function c_order($mch_id,$order,$app_id,$userinfo){
|
||||
$this->ci->load->model('apporder/order_purchase_model');
|
||||
$this->ci->load->model('auto/auto_series_model');
|
||||
$this->ci->load->model('auto/auto_brand_model');
|
||||
|
||||
$brand = $this->ci->auto_brand_model->get(['id'=>$order['brand_id']],'name');
|
||||
$series = $this->ci->auto_series_model->get(['id'=>$order['s_id']],'name');
|
||||
@@ -142,7 +163,6 @@ class Orders_entity{
|
||||
* @param $type array 类型
|
||||
*/
|
||||
public function get_sign_imgs($oid,$type){
|
||||
$this->ci->load->model('receiver/order/receiver_order_contracts_model');
|
||||
$where = [
|
||||
'o_id' => $oid,
|
||||
'status' => 1
|
||||
@@ -169,7 +189,6 @@ class Orders_entity{
|
||||
* @param $info array() 腾讯云识别返回参数
|
||||
*/
|
||||
public function up_info($oid,$info){
|
||||
$this->ci->load->model('receiver/order/receiver_orders_model','orders_model');
|
||||
$row = $this->ci->orders_model->get(['id'=>$oid]);
|
||||
if(!$row){
|
||||
return false;
|
||||
@@ -217,10 +236,7 @@ class Orders_entity{
|
||||
* return boolean
|
||||
*/
|
||||
public function finish_after($oid,$app_id){
|
||||
$this->ci->load->model('receiver/order/receiver_orders_model','orders_model');
|
||||
$this->ci->load->model('receiver/receiver_customers_model','customers_model');
|
||||
$this->ci->load->model('receiver/receiver_clues_model','clues_model');
|
||||
$this->ci->load->model('apporder/order_purchase_model');
|
||||
$row = $this->ci->orders_model->get(['id'=>$oid]);
|
||||
if(!$row){
|
||||
return false;
|
||||
@@ -258,24 +274,14 @@ class Orders_entity{
|
||||
|
||||
//确认车辆完成创建两个支付订单
|
||||
public function check_finish($oid,$app_id,$userinfo){
|
||||
$this->ci->load->model('receiver/order/receiver_orders_model','orders_model');
|
||||
$this->ci->load->model('apporder/order_purchase_model');
|
||||
$this->ci->load->model('auto/auto_series_model');
|
||||
$this->ci->load->model('auto/auto_brand_model');
|
||||
$this->ci->load->model('auto/auto_cars_model');
|
||||
$this->ci->load->model("biz/biz_model");
|
||||
$this->ci->load->model('receiver/receiver_service_package_model','package_model');
|
||||
$this->ci->load->model('receiver/receiver_services_model','services_model');
|
||||
$this->ci->load->model("sys/sys_company_model");
|
||||
$this->ci->load->model('sys/sys_city_model');
|
||||
|
||||
$row = $this->ci->orders_model->get(['id'=>$oid]);
|
||||
if(!$row){
|
||||
$this->order_row = $this->ci->orders_model->get(['id'=>$oid]);
|
||||
if(!$this->order_row){
|
||||
return false;
|
||||
}
|
||||
$brand = $this->ci->auto_brand_model->get(['id'=>$row['brand_id']],'name');
|
||||
$series = $this->ci->auto_series_model->get(['id'=>$row['s_id']],'name');
|
||||
$car_json = json_decode($row['car_json'],true);
|
||||
$brand = $this->ci->auto_brand_model->get(['id'=>$this->order_row['brand_id']],'name');
|
||||
$series = $this->ci->auto_series_model->get(['id'=>$this->order_row['s_id']],'name');
|
||||
$car_json = json_decode($this->order_row['car_json'],true);
|
||||
$color = isset($car_json['color']) ? $car_json['color'] : '';
|
||||
|
||||
$jsondata['car'] = $car_json;
|
||||
@@ -283,45 +289,31 @@ class Orders_entity{
|
||||
$jsondata['cover'] = $color['jsondata']['img'];
|
||||
}
|
||||
//获取门店信息
|
||||
$biz = $this->ci->biz_model->get(['id'=>$row['biz_id']],'company_id,city_id');
|
||||
$biz = $this->ci->biz_model->get(['id'=>$this->order_row['biz_id']],'company_id');
|
||||
$company = $this->ci->sys_company_model->get(['id'=>$biz['company_id']]);
|
||||
//获取服务包
|
||||
$packs = $this->ci->package_model->get(['id'=>$row['pack_id']],'srv_ids');
|
||||
$services = [];
|
||||
if($packs['srv_ids']){
|
||||
$services = $this->ci->services_model->select(["id in ({$packs['srv_ids']})"=>null],'','','','title,field_name');
|
||||
}
|
||||
$where_car = array(
|
||||
's_id'=>$row['s_id'],
|
||||
'v_id' => $row['v_id'],
|
||||
'cor_id' => $row['cor_id'],
|
||||
'incor_id' => $row['incor_id'],
|
||||
);
|
||||
$car = $this->ci->auto_cars_model->get($where_car);
|
||||
//获取挂牌价
|
||||
if($row['brand_id']==3){ //狸车品牌写死挂牌费用0.01 测试用
|
||||
$car['fee_carno'] = 0.01;
|
||||
}else{
|
||||
$city = $this->ci->sys_city_model->get(['city_id'=>$biz['city_id']],'fee_carno');
|
||||
$car['fee_carno'] = $city['fee_carno'];
|
||||
}
|
||||
$srv_price = 0;
|
||||
if($services){
|
||||
foreach($services as $key=>$val){
|
||||
$field_arr = explode('.',$val['field_name']);
|
||||
if($car[$field_arr[1]]){
|
||||
$srv_price += $car[$field_arr[1]];
|
||||
}
|
||||
|
||||
$srv_money = $this->order_srv_money($oid); //服务费
|
||||
$money_json = json_decode($this->order_row['money_json'],true);
|
||||
if($this->order_row['payway']){ //全款
|
||||
if($srv_money < $this->order_row['deposit']){ //服务费小于定金
|
||||
$to_srv_price = $srv_money;
|
||||
$to_com_price = $money_json['price_car'] - $this->order_row['deposit'];
|
||||
$to_com_price = $to_com_price>0 ? $to_com_price : 0;
|
||||
}else{
|
||||
$to_com_price = $money_json['price_car']; //给销售公司金额 裸车价格
|
||||
$to_srv_price = $srv_money - $this->order_row['deposit']; //给服务公司金额 裸车价格+服务费-给销售公司金额-定金
|
||||
$to_srv_price = $to_srv_price>0 ? $to_srv_price : 0;
|
||||
}
|
||||
}
|
||||
if($row['payway']){ //全款
|
||||
$to_com_price = $car['price_car']; //给销售公司金额 裸车价格
|
||||
$to_srv_price = $car['price_car'] + $srv_price - $to_com_price - $row['deposit'] - $car['price_insure']; //给服务公司金额 裸车价格+服务费-给销售公司金额-定金-保险
|
||||
$to_srv_price = $to_srv_price>0 ? $to_srv_price : 0;
|
||||
}else{ //分期
|
||||
$to_com_price = $car['first_pay']; //给销售公司金额
|
||||
$to_srv_price = $car['first_pay'] + $srv_price - $to_com_price - $row['deposit'] - $car['price_insure']; //给服务公司的金额 首付+服务费-给销售公司-定金-保险
|
||||
$to_srv_price = $to_srv_price>0 ? $to_srv_price : 0;
|
||||
if($srv_money < $this->order_row['deposit']){ //服务费小于定金
|
||||
$to_srv_price = $srv_money;
|
||||
$to_com_price = $money_json['first_pay'] - $this->order['deposit'];
|
||||
$to_com_price = $to_com_price>0 ? $to_com_price : 0;
|
||||
}else{
|
||||
$to_com_price = $money_json['first_pay']; //给销售公司金额
|
||||
$to_srv_price = $srv_money - $this->order_row['deposit']; //给服务公司的金额 服务费-定金
|
||||
$to_srv_price = $to_srv_price>0 ? $to_srv_price : 0;
|
||||
}
|
||||
}
|
||||
$add_data = [];
|
||||
if($to_srv_price>0){
|
||||
@@ -332,7 +324,7 @@ class Orders_entity{
|
||||
'app_uid' => $userinfo['uid'],
|
||||
'sid' => $sid,
|
||||
'mch_id' => self::SRV_MCH_ID,
|
||||
'item_id' => $row['id'],
|
||||
'item_id' => $this->order_row['id'],
|
||||
'item_title' => $brand['name'].$series['name'],
|
||||
'item_num' => 1,
|
||||
'type' => $order_type,
|
||||
@@ -345,7 +337,7 @@ class Orders_entity{
|
||||
'status_detail' => 11,
|
||||
'jsondata' => json_encode($jsondata,JSON_UNESCAPED_UNICODE),
|
||||
'c_time' => time(),
|
||||
'cf_id' => $row['id']
|
||||
'cf_id' => $this->order_row['id']
|
||||
];
|
||||
}
|
||||
if($to_com_price>0){
|
||||
@@ -356,7 +348,7 @@ class Orders_entity{
|
||||
'app_uid' => $userinfo['uid'],
|
||||
'sid' => $sid,
|
||||
'mch_id' => $company['wx_mchid'],
|
||||
'item_id' => $row['id'],
|
||||
'item_id' => $this->order_row['id'],
|
||||
'item_title' => $brand['name'].$series['name'],
|
||||
'item_num' => 1,
|
||||
'type' => $order_type,
|
||||
@@ -369,7 +361,7 @@ class Orders_entity{
|
||||
'status_detail' => 11,
|
||||
'jsondata' => json_encode($jsondata,JSON_UNESCAPED_UNICODE),
|
||||
'c_time' => time(),
|
||||
'cf_id' => $row['id']
|
||||
'cf_id' => $this->order_row['id']
|
||||
];
|
||||
}
|
||||
$result = false;
|
||||
@@ -378,6 +370,36 @@ class Orders_entity{
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取订单服务费
|
||||
* @param $oid int 订单id
|
||||
* return float
|
||||
*/
|
||||
public function order_srv_money($oid){
|
||||
if(!$this->order_row){
|
||||
$this->order_row = $this->ci->orders_model->get(['id'=>$oid]);
|
||||
}
|
||||
$money_json = json_decode($this->order_row['money_json'],true);
|
||||
|
||||
$packs = $this->ci->package_model->get(['id'=>$this->order_row['pack_id']],'srv_ids');
|
||||
$services = [];
|
||||
if($packs['srv_ids']){
|
||||
$services = $this->ci->services_model->select(["id in ({$packs['srv_ids']})"=>null],'','','','title,field_name');
|
||||
}
|
||||
$srv_price = 0;
|
||||
if($services){
|
||||
foreach($services as $key=>$val){
|
||||
$field_arr = explode('.',$val['field_name']);
|
||||
if($money_json[$field_arr[1]]){
|
||||
$srv_price += $money_json[$field_arr[1]];
|
||||
}
|
||||
}
|
||||
$srv_price = $srv_price - $money_json['price_insure']; //保险费用不收
|
||||
}
|
||||
return $srv_price;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+3
-3
@@ -111,9 +111,9 @@ create table lc_auto_car_finance (
|
||||
id int(10) unsigned not null auto_increment comment '自增id',
|
||||
car_id int(10) unsigned not null default '0' comment '车型库id',
|
||||
fin_id int(10) unsigned not null default '0' comment '金融产品id',
|
||||
first_pay decimal(12,2) not null default '0.00' comment '首付(万元)',
|
||||
mouth_pay decimal(12,2) not null default '0.00' comment '月供',
|
||||
srv_pay decimal(12,2) not null default '0.00' comment '服务费',
|
||||
first_pay decimal(12,2) not null default '0.00' comment '首付(元)',
|
||||
mouth_pay decimal(12,2) not null default '0.00' comment '月供(元)',
|
||||
srv_pay decimal(12,2) not null default '0.00' comment '服务费(元)',
|
||||
num int(3) unsigned not null default '0' comment '金融期数',
|
||||
status tinyint(1) not null default '1' comment '状态:-1删除,0关闭,1开启',
|
||||
c_time int(10) not null default '0' comment '创建时间',
|
||||
|
||||
@@ -185,3 +185,5 @@ alter table lc_receiver_orders add pack_id int(10) unsigned not null default 0 c
|
||||
alter table lc_receiver_orders add main_type tinyint(1) unsigned not null default 0 comment '购车主体(0个人 1公司)' after admin_id;
|
||||
alter table lc_receiver_orders add ifentrust tinyint(1) unsigned not null default 0 comment '是否委托代办' after main_type;
|
||||
alter table lc_receiver_orders add delry_time timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '期望交付时间' after status;
|
||||
alter table lc_receiver_orders add finance_id int(10) unsigned not null default 0 comment '车型金融信息id' after payway;
|
||||
alter table lc_receiver_orders add money_json json default null comment "格json数据" after info_json;
|
||||
|
||||
Reference in New Issue
Block a user