From 5d7bee2db5396974866abed291f1de6b1a53d95f Mon Sep 17 00:00:00 2001 From: lccsw <1127794702@qq.com> Date: Thu, 18 Nov 2021 16:30:51 +0800 Subject: [PATCH] edit-admin-ck_pay --- admin/controllers/receiver/Orders.php | 15 +++++++++++++-- admin/libraries/OrdersList.php | 12 +++++++++++- admin/views/receiver/orders/paylog.php | 8 +++++--- common/libraries/receiver/Orders_entity.php | 21 +++++++++++++++++++++ 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/admin/controllers/receiver/Orders.php b/admin/controllers/receiver/Orders.php index f9434ea5..8c025d7d 100644 --- a/admin/controllers/receiver/Orders.php +++ b/admin/controllers/receiver/Orders.php @@ -623,6 +623,16 @@ class Orders extends HD_Controller if (!$bill['cardidA'] && !$bill['business_licence']) { return $this->show_json(SYS_CODE_FAIL, '未上传用户身份证或营业执照!'); } + $where = [ + 'o_id' => $oid, + 'status' => 1, + 'pay_price!=' => 0 + ]; + $sum = $this->app_liche_orders_model->sum('total_price',$where); //已收金额 + $need_price = $this->orders_entity->recevable_price($oid); //应收金额 + if($sum['total_price'] < $need_price){ + return $this->show_json(SYS_CODE_FAIL, '修改失败,已收金额小于应收金额!'); + } $this->order_bills_model->update(['status' => 2], ['o_id' => $oid]); $this->orders_model->update(['status' => 4], ['id' => $bill['o_id']]); if (!$this->order_agents_model->get(['o_id' => $oid])) { @@ -754,8 +764,9 @@ class Orders extends HD_Controller ]; } } - $sum = $this->app_liche_orders_model->sum('total_price', $where); - $this->data['total_price'] = $sum['total_price']; + $sum = $this->app_liche_orders_model->sum('total_price',$where); + $this->data['pay_price'] = $sum['total_price']; + $this->data['need_price'] = $this->orders_entity->recevable_price($params['id']); $this->data['list'] = $list; $hasNext = ceil($count / $size) > $page ? 1 : 0; $this->data['commonPage'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext); diff --git a/admin/libraries/OrdersList.php b/admin/libraries/OrdersList.php index 79c9c5c0..ab1ae7c7 100644 --- a/admin/libraries/OrdersList.php +++ b/admin/libraries/OrdersList.php @@ -28,7 +28,7 @@ class OrdersList !$params['qdjl_id'] && $params['qdjl_id'] = ''; !$params['cf_title'] && $params['cf_title'] = ''; !$params['cf_clues'] && $params['cf_clues'] = ''; - !$params['payway'] && $params['payway'] = ''; + !strlen($params['payway']) && $params['payway'] = ''; !$params['biz_type'] && $params['biz_type'] = ''; $fieldAry = $this->get_fields($status_pid); $show_info['cfTitleAry'] = $this->ci->mdCustomers->get_sdata('cfrom');//来源类型 @@ -986,6 +986,16 @@ class OrdersList $where["{$t1}.c_time <="] = strtotime($c_time[1] . ' 23:59:59'); } } + //开票时间 + if ($params['bill_time']) { + $bill_time = explode(' ~ ', $params['bill_time']); + if ($bill_time[0]) { + $where["bill_time >="] = $bill_time[0] . ' 00:00:00'; + } + if ($bill_time[1]) { + $where["bill_time <="] = $bill_time[1] . ' 23:59:59'; + } + } if ($params['brand_id']) {//品牌 $where["{$t2}.brand_id"] = $params['brand_id']; } else { diff --git a/admin/views/receiver/orders/paylog.php b/admin/views/receiver/orders/paylog.php index 922501d1..d4cf33ad 100644 --- a/admin/views/receiver/orders/paylog.php +++ b/admin/views/receiver/orders/paylog.php @@ -40,7 +40,7 @@ -
收款总额{{total_price}}
+
应收总额:{{need_price}},已收总额:{{pay_price}}  
@@ -52,7 +52,8 @@ id:, page: [], list:[], - total_price: '' + pay_price: '', + need_price: '', }, mounted: function () { this.getData(1); @@ -64,7 +65,8 @@ if(result.code){ that.list = result.data.list; that.page = result.data.commonPage; - that.total_price = result.data.total_price; + that.pay_price = result.data.pay_price; + that.need_price = result.data.need_price; } }); }, diff --git a/common/libraries/receiver/Orders_entity.php b/common/libraries/receiver/Orders_entity.php index ba71339c..2a566f8f 100644 --- a/common/libraries/receiver/Orders_entity.php +++ b/common/libraries/receiver/Orders_entity.php @@ -604,6 +604,27 @@ class Orders_entity{ } return $res; } + + /** + * 计算订单应收金额 + * @param $oid int 订单id + * return float + */ + public function recevable_price($oid){ + !$this->order_row && $this->order_row = $this->ci->orders_model->get(['id'=>$oid]); + if(!$this->order_row){ + return false; + } + $money_json = json_decode($this->order_row['money_json'],true); + $money_json['price_discount'] && $money_json['price_car'] = $money_json['price_car'] - $money_json['price_discount']; + $srv_money = $this->order_srv_money($oid); + + $recevable_price = $money_json['price_car'] + $srv_money; + if(!$this->order_row['payway']){ //分期 + $recevable_price -= $money_json['price_loan']; + } + return $recevable_price; + } } ?>