|
@@ -51,6 +51,7 @@ class StatisticsController
|
|
|
// 今日收入
|
|
|
$statistics['todayRevenue'] = PayDetail::whereRaw('CAST(UNIX_TIMESTAMP(pay_paytimes) as SIGNED) >= ? ', [$todayTimeUnix])
|
|
|
->where('pay_status', 'SUCCESS')
|
|
|
+ ->where('pay_prepayid','<>', '')
|
|
|
->whereIn('pay_category', $orderCategory)
|
|
|
->when(in_array('RECHARGE', $orderCategory), function ($query) {
|
|
|
$query->whereNotIn('join_pay_order_id', ['COMBINE', 'PARTNER', 'REFERRER']);
|
|
@@ -59,12 +60,14 @@ class StatisticsController
|
|
|
$todayRevenueOrderNbrModel = Db::select("select count(1) as total from (select JSON_EXTRACT(join_pay_object_json,'$.order_id') as order_id from app_pay_detail where
|
|
|
CAST(UNIX_TIMESTAMP(pay_paytimes) as SIGNED) >= {$todayTimeUnix}
|
|
|
and pay_status = 'SUCCESS'
|
|
|
+ and pay_prepayid != ''
|
|
|
and pay_category in ({$orderCategoryStr}) {$where}
|
|
|
group by order_id) count");
|
|
|
$statistics['todayRevenueOrderNbr'] = $todayRevenueOrderNbrModel[0]->total;
|
|
|
// 昨日收入
|
|
|
$statistics['yesterdayRevenue'] = PayDetail::whereRaw('CAST(UNIX_TIMESTAMP(pay_paytimes) as SIGNED) >= ? and CAST(UNIX_TIMESTAMP(pay_paytimes) as SIGNED) <= ?', [$yesterdayStart, $yesterdayEnd])
|
|
|
->where('pay_status', 'SUCCESS')
|
|
|
+ ->where('pay_prepayid','<>', '')
|
|
|
->whereIn('pay_category', $orderCategory)
|
|
|
->when(in_array('RECHARGE', $orderCategory), function ($query) {
|
|
|
$query->whereNotIn('join_pay_order_id', ['COMBINE', 'PARTNER', 'REFERRER']);
|
|
@@ -73,6 +76,7 @@ class StatisticsController
|
|
|
$yesterdayRevenueOrderNbrModel = Db::select("select count(1) as total from (select JSON_EXTRACT(join_pay_object_json,'$.order_id') as order_id from app_pay_detail where
|
|
|
CAST(UNIX_TIMESTAMP(pay_paytimes) as SIGNED) >= {$yesterdayStart} and CAST(UNIX_TIMESTAMP(pay_paytimes) as SIGNED) <= {$yesterdayEnd}
|
|
|
and pay_status = 'SUCCESS'
|
|
|
+ and pay_prepayid != ''
|
|
|
and pay_category in ({$orderCategoryStr}) {$where}
|
|
|
group by order_id) count");
|
|
|
$statistics['yesterdayRevenueOrderNbr'] = $yesterdayRevenueOrderNbrModel[0]->total;
|
|
@@ -80,6 +84,7 @@ class StatisticsController
|
|
|
// 本月收入
|
|
|
$statistics['monthRevenue'] = PayDetail::whereRaw('CAST(UNIX_TIMESTAMP(pay_paytimes) as SIGNED) >= ? and CAST(UNIX_TIMESTAMP(pay_paytimes) as SIGNED) <= ?', [$monthStart, $monthEnd])
|
|
|
->where('pay_status', 'SUCCESS')
|
|
|
+ ->where('pay_prepayid','<>', '')
|
|
|
->whereIn('pay_category', $orderCategory)
|
|
|
->when(in_array('RECHARGE', $orderCategory), function ($query) {
|
|
|
$query->whereNotIn('join_pay_order_id', ['COMBINE', 'PARTNER', 'REFERRER']);
|
|
@@ -88,15 +93,18 @@ class StatisticsController
|
|
|
$monthRevenueOrderNbrModel = Db::select("select count(1) as total from (select JSON_EXTRACT(join_pay_object_json,'$.order_id') as order_id from app_pay_detail where
|
|
|
CAST(UNIX_TIMESTAMP(pay_paytimes) as SIGNED) >= {$monthStart} and CAST(UNIX_TIMESTAMP(pay_paytimes) as SIGNED) <= {$monthEnd}
|
|
|
and pay_status = 'SUCCESS'
|
|
|
+ and pay_prepayid != ''
|
|
|
and pay_category in ({$orderCategoryStr}) {$where}
|
|
|
group by order_id) count");
|
|
|
$statistics['monthRevenueOrderNbr'] = $monthRevenueOrderNbrModel[0]->total;
|
|
|
// 累计收入
|
|
|
$statistics['totalRevenue'] = PayDetail::where('pay_status', 'SUCCESS')
|
|
|
+ ->where('pay_prepayid','<>', '')
|
|
|
->whereIn('pay_category', $orderCategory)
|
|
|
->sum('pay_amount');
|
|
|
$totalRevenueOrderNbrModel = Db::select("select count(1) as total from (select JSON_EXTRACT(join_pay_object_json,'$.order_id') as order_id from app_pay_detail where
|
|
|
pay_status = 'SUCCESS'
|
|
|
+ and pay_prepayid != ''
|
|
|
and pay_category in ({$orderCategoryStr}) {$where}
|
|
|
group by order_id) count");
|
|
|
$statistics['totalRevenueOrderNbr'] = $totalRevenueOrderNbrModel[0]->total;
|