diff --git a/application/admin/dao/PaymentOrderDao.php b/application/admin/dao/PaymentOrderDao.php
index 703e279..2b5e1e7 100644
--- a/application/admin/dao/PaymentOrderDao.php
+++ b/application/admin/dao/PaymentOrderDao.php
@@ -123,20 +123,39 @@ class PaymentOrderDao
if ($param['status']."" != 'all') {
$where["a.status"] = $param['status'];
}
+ $having = [];
+ if(!empty($param['startCost']) && !empty($param['endCost'])) {
+ $having[] = " (itemMoney >= {$param['startCost']} and itemMoney <= {$param['endCost']} ) or (hotelMoney >= {$param['startCost']} and hotelMoney <= {$param['endCost']} ) ";
+ }
+ if(!empty($param['startCost']) && empty($param['endCost'])) {
+ $having[] = " (itemMoney >= {$param['startCost']} ) or (hotelMoney >= {$param['startCost']} ) ";
+ }
+ if(empty($param['startCost']) && !empty($param['endCost'])) {
+ $having[] = " (itemMoney <= {$param['endCost']} ) or (hotelMoney <= {$param['endCost']} ) ";
+ }
$offset = ($param['pageNum'] - 1) * $param['pageSize'];
$receiptOrder = new PaymentOrder();
$total = $receiptOrder
->alias("a")
+ ->field("a.*,
+ (SELECT ifnull( sum( total_cost ), 0 ) from hbp_order_item where payment_order_id = a.id) 'itemMoney',
+ (SELECT ifnull( sum( total_cost ), 0 ) from hbp_order_hotel where payment_order_id = a.id) 'hotelMoney'
+ ")
->group("a.id")
- ->where($where)->count();
+ ->where($where)
+ ->having(join("and", $having))
+ ->count();
$list = $receiptOrder
->alias("a")
->field("a.*,
(SELECT concat('订单:',ifnull( GROUP_CONCAT( id ORDER BY id DESC ), '-' ), '成本:',ifnull( sum( total_cost ), '-' )) from hbp_order_item where payment_order_id = a.id) 'item',
- (SELECT concat('订单:',ifnull( GROUP_CONCAT( id ORDER BY id DESC ), '-' ), '成本:',ifnull( sum( total_cost ), '-' )) from hbp_order_hotel where payment_order_id = a.id) 'hotel'
+ (SELECT concat('订单:',ifnull( GROUP_CONCAT( id ORDER BY id DESC ), '-' ), '成本:',ifnull( sum( total_cost ), '-' )) from hbp_order_hotel where payment_order_id = a.id) 'hotel',
+ (SELECT ifnull( sum( total_cost ), 0 ) from hbp_order_item where payment_order_id = a.id) 'itemMoney',
+ (SELECT ifnull( sum( total_cost ), 0 ) from hbp_order_hotel where payment_order_id = a.id) 'hotelMoney'
")
->group("a.id")
->where($where)
+ ->having(join("and", $having))
->limit($offset, $param['pageSize'])
->order("a.id","DESC")->select();
diff --git a/application/admin/dao/ReceiptOrderDao.php b/application/admin/dao/ReceiptOrderDao.php
index 377258a..9d5de0d 100644
--- a/application/admin/dao/ReceiptOrderDao.php
+++ b/application/admin/dao/ReceiptOrderDao.php
@@ -124,6 +124,16 @@ class ReceiptOrderDao
if ($param['status']."" != 'all') {
$where["a.status"] = $param['status'];
}
+ $having = "";
+ if(!empty($param['startMoney']) && !empty($param['endMoney'])) {
+ $having = " total_amount >= {$param['startMoney']} and total_amount <= {$param['endMoney']} ";
+ }
+ if(!empty($param['startMoney']) && empty($param['endMoney'])) {
+ $having = " total_amount >= {$param['startMoney']} ";
+ }
+ if(empty($param['startMoney']) && !empty($param['endMoney'])) {
+ $having = " total_amount <= {$param['endMoney']} ";
+ }
$offset = ($param['pageNum'] - 1) * $param['pageSize'];
$receiptOrder = new ReceiptOrder();
$total = $receiptOrder
@@ -131,7 +141,9 @@ class ReceiptOrderDao
->join('hbp_order_main b', 'a.id = b.receipt_order_id', 'left')
->field("a.*,GROUP_CONCAT(b.id) order_ids,sum(b.total_amount) total_amount")
->group("a.id")
- ->where($where)->count();
+ ->where($where)
+ ->having($having)
+ ->count();
$list = $receiptOrder
->alias("a")
@@ -139,6 +151,7 @@ class ReceiptOrderDao
->field("a.*,GROUP_CONCAT(b.id ORDER BY b.id DESC) order_ids,sum(b.total_amount) total_amount")
->group("a.id")
->where($where)
+ ->having($having)
->limit($offset, $param['pageSize'])
->order("id","DESC")->select();
$data = ["total" => $total, "list" => $list->toArray()];
diff --git a/application/admin/view/payment_order/index.html b/application/admin/view/payment_order/index.html
index 74c3ce3..6923940 100755
--- a/application/admin/view/payment_order/index.html
+++ b/application/admin/view/payment_order/index.html
@@ -20,6 +20,10 @@
:value="item.id">
+ 成本
+
+ ~
+
搜索
新增付款单
@@ -285,6 +289,8 @@
search: {
name: "",
status: "all",
+ startCost:"",
+ endCost:"",
pageSize: 10,
pageNum: 1
},
diff --git a/application/admin/view/receipt_order/index.html b/application/admin/view/receipt_order/index.html
index d7d5208..4fa57fd 100755
--- a/application/admin/view/receipt_order/index.html
+++ b/application/admin/view/receipt_order/index.html
@@ -20,6 +20,10 @@
:value="item.id">
+ 成本
+
+ ~
+
搜索
新增收款单
@@ -252,6 +256,8 @@
search: {
name: "",
status: "all",
+ startMoney:0,
+ endMoney:0,
pageSize: 10,
pageNum: 1
},