|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace app\admin\controller\order;
|
|
|
|
|
|
+use app\model\Order;
|
|
|
use app\model\PayDetail;
|
|
|
use support\Db;
|
|
|
use support\Request;
|
|
@@ -30,8 +31,10 @@ class StatisticsController
|
|
|
}
|
|
|
if ($orderCategory == 'SERVICE') {
|
|
|
$orderCategory = ['SERVICE', 'CHNMED', 'CHNNCD'];
|
|
|
- } else if ($orderCategory == 'ALL') {
|
|
|
- $orderCategory = ['SERVICE', 'CHNMED', 'CHNNCD', 'GOODS', 'PACKAGE', 'MEALS', 'RECHARGE', 'COMBINE', 'PARTNER', 'REFERRER','FRANCHISEE', 'VIP'];
|
|
|
+ } else if ($orderCategory == 'MEALS') {
|
|
|
+ $orderCategory = ['MEALS','DISHES'];
|
|
|
+ } else if ($orderCategory == 'ALL') {
|
|
|
+ $orderCategory = ['SERVICE', 'CHNMED', 'CHNNCD', 'GOODS', 'PACKAGE', 'MEALS','DISHES', 'RECHARGE', 'COMBINE', 'PARTNER', 'REFERRER','FRANCHISEE', 'VIP'];
|
|
|
} else {
|
|
|
$orderCategory = [$orderCategory];
|
|
|
}
|
|
@@ -117,12 +120,16 @@ class StatisticsController
|
|
|
$statistics['todayRefundNbr'] = $todayRefundItem[0]->total;
|
|
|
|
|
|
// 累计退款
|
|
|
- $totalRefundItem = Db::select("select SUM(d2.pay_amount) as amount,count(1) as total from app_pay_detail d1
|
|
|
- inner join app_pay_detail d2 ON d1.join_pay_order_id=d2.join_pay_order_id and d2.pay_category='REFUND'
|
|
|
- where d1.pay_category in ({$orderCategoryStr})
|
|
|
- ");
|
|
|
- $statistics['totalRefund'] = $totalRefundItem[0]->amount;
|
|
|
- $statistics['totalRefundNbr'] = $totalRefundItem[0]->total;
|
|
|
+// $totalRefundItem = Db::select("select SUM(d2.pay_amount) as amount,count(1) as total from app_pay_detail d1
|
|
|
+// inner join app_pay_detail d2 ON d1.join_pay_order_id=d2.join_pay_order_id and d2.pay_category='REFUND'
|
|
|
+// where d1.pay_category in ({$orderCategoryStr})
|
|
|
+// ");
|
|
|
+ $refundOrderIds = Order::where('order_category','RETURN')
|
|
|
+ ->whereIn('order_classify',$orderCategory)
|
|
|
+ ->pluck('order_groupby')
|
|
|
+ ->toArray();
|
|
|
+ $statistics['totalRefund'] = PayDetail::whereIn('join_pay_order_id',$refundOrderIds)->where('pay_status','SUCCESS')->sum('pay_amount');
|
|
|
+ $statistics['totalRefundNbr'] = count($refundOrderIds);
|
|
|
|
|
|
if (in_array('MEALS', $orderCategory)) {
|
|
|
// 挂账
|