From 5049863033b3624dbdfa67b37f1486a99d0b222b Mon Sep 17 00:00:00 2001 From: lccsw <1127794702@qq.com> Date: Wed, 29 Sep 2021 15:53:15 +0800 Subject: [PATCH] edit-admin-srv_money --- admin/controllers/receiver/Orders.php | 14 +++++++++-- api/controllers/wxapp/licheb/Protocol.php | 2 +- common/libraries/receiver/Orders_entity.php | 8 +++--- sql/app/liche.sql | 28 +++++++++++++++++++++ 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/admin/controllers/receiver/Orders.php b/admin/controllers/receiver/Orders.php index a65adda6..4de6b73e 100644 --- a/admin/controllers/receiver/Orders.php +++ b/admin/controllers/receiver/Orders.php @@ -21,6 +21,8 @@ class Orders extends HD_Controller $this->load->model('auto/auto_attr_model'); $this->load->model('auto/auto_finance_model'); $this->load->model('sys/sys_finance_model'); + + $this->load->library('receiver/orders_entity'); } public function index() @@ -142,7 +144,15 @@ class Orders extends HD_Controller $loan['finance_rows'] = $this->sys_finance_model->select(['status' => 1],'',0,0,'id,title'); $loan['finance_rows_nums'] = $this->sys_finance_model->get_nums(); $loan['price_loan'] = $money_json['price_loan'] ? $money_json['price_loan'] : ''; - $loan['first_pay'] = $money_json['price_car'] - $money_json['price_loan']; + $loan['first_pay'] = 0; + if($money_json['price_loan']){ + $srv_money = $this->orders_entity->order_srv_money($row['id']); + if($srv_money>$row['deposit']){ + $loan['first_pay'] = $money_json['price_car']-$money_json['price_loan']; + }else{ + $loan['first_pay'] = $money_json['price_car']-$money_json['price_loan']-$row['deposit']; + } + } !$loan['num'] && $loan['num'] = 12; $loan['loan_time'] = $loan['loan_time']!='0000-00-00 00:00:00' ? date('Y-m-d',strtotime($loan['loan_time'])) : ''; @@ -659,7 +669,7 @@ class Orders extends HD_Controller 'o_id' => $params['id'], 'status' => 1, 'pid>' => 0, - 'total_price>' => 0 + 'pay_price>' => 0 ]; $count = $this->app_liche_orders_model->count($where); if($count){ diff --git a/api/controllers/wxapp/licheb/Protocol.php b/api/controllers/wxapp/licheb/Protocol.php index e8484902..4a28eeea 100644 --- a/api/controllers/wxapp/licheb/Protocol.php +++ b/api/controllers/wxapp/licheb/Protocol.php @@ -162,7 +162,7 @@ class Protocol extends CI_Controller{ $where = [ 'o_id' => $row['id'], 'status' => 1, - 'type in (1,2,4)' => null + 'type in (1,2,4,5)' => null ]; $pay = $this->app_liche_orders_model->sum('total_price',$where); //尾款 diff --git a/common/libraries/receiver/Orders_entity.php b/common/libraries/receiver/Orders_entity.php index f091aa4f..155eae18 100644 --- a/common/libraries/receiver/Orders_entity.php +++ b/common/libraries/receiver/Orders_entity.php @@ -399,10 +399,10 @@ class Orders_entity{ }else{ //分期 if($srv_money < $this->order_row['deposit']){ //服务费小于定金 $to_srv_price = $srv_money; - $to_com_price = $money_json['first_pay'] - $this->order_row['deposit']; + $to_com_price = $money_json['price_car']-$money_json['price_loan'] - $this->order_row['deposit']; $to_com_price = $to_com_price>0 ? $to_com_price : 0; }else{ - $to_com_price = $money_json['first_pay']; //给销售公司金额 + $to_com_price = $money_json['price_car']-$money_json['price_loan']; //给销售公司金额 $to_srv_price = $srv_money - $this->order_row['deposit']; //给服务公司的金额 服务费-定金 $to_srv_price = $to_srv_price>0 ? $to_srv_price : 0; } @@ -526,10 +526,10 @@ class Orders_entity{ }else{ //分期 if($srv_money < $this->order_row['deposit']){ //服务费小于定金 $to_srv_price = $srv_money; - $to_com_price = $money_json['first_pay'] - $this->order_row['deposit']; + $to_com_price = $money_json['price_car']-$money_json['price_loan'] - $this->order_row['deposit']; $to_com_price = $to_com_price>0 ? $to_com_price : 0; }else{ - $to_com_price = $money_json['first_pay']; //给销售公司金额 + $to_com_price = $money_json['price_car']-$money_json['price_loan']; //给销售公司金额 $to_srv_price = $srv_money - $this->order_row['deposit']; //给服务公司的金额 服务费-定金 $to_srv_price = $to_srv_price>0 ? $to_srv_price : 0; } diff --git a/sql/app/liche.sql b/sql/app/liche.sql index 183ae8a3..a0cd3a5d 100644 --- a/sql/app/liche.sql +++ b/sql/app/liche.sql @@ -66,3 +66,31 @@ create table lc_app_liche_udata ( primary key (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='狸车用户数据表'; alter table lc_app_liche_udata add app_uid int(10) unsigned not null default 0 comment '用户id' after cf_id; + +-- ---------------------------- +-- Title:用户购车订单 +-- Author:lcc +-- Table:lc_app_liche_orders +-- --------------------------- +create table lc_app_liche_orders ( + id int(10) unsigned not null auto_increment comment '自增id', + o_id int(10) unsigned not null default '0' comment '订单表id', + uid int(10) unsigned not null default '0' comment '用户id', + sid varchar(32) not null default '' comment '订单号', + mch_id varchar(30) not null default '' comment '支付商户号', + pid int(10) unsigned not null default '0' comment '父订单id', + brand_id int(10) not null default '0' comment '品牌id', + s_id int(10) unsigned not null default '0' comment '车系id', + v_id int(10) unsigned not null default '0' comment '车型号', + cor_id int(10) not null default '0' comment '车身颜色id', + incor_id int(10) unsigned not null default '0' comment '内饰颜色id', + total_price decimal(12,2) not null default '0.00' comment '订单价格', + pay_price decimal(12,2) not null default '0.00' comment '实付金额', + type tinyint(2) unsigned not null default '0' comment '订单类型 1定金 2服务费 3尾款 4意向金 5后台添加', + status tinyint(1) not null default '0' comment '支付状态 0未支付 1已支付', + pay_time timestamp not null default '0000-00-00 00:00:00' comment '付款时间', + c_time int(10) unsigned not null default '0' comment '创建时间', + u_time timestamp null default current_timestamp on update current_timestamp, + primary key (id) + +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户购车订单';