|
@@ -47,7 +47,15 @@ class PayDetailController extends Curd
|
|
|
$where['pay_addtimes'][1] = !empty($where['pay_addtimes'][1]) ? strtotime($where['pay_addtimes'][1]) : '';
|
|
|
}
|
|
|
if (!empty($request->get('premises_id'))) {
|
|
|
- $payIds = PayDetail::whereJsonContains('pay_extend_json->remark->premises_id', intval($request->get('premises_id')))
|
|
|
+ $orderIds = Order::whereJsonContains('order_extend_json->dept_id', intval($request->get('premises_id')))
|
|
|
+ ->whereIn('order_classify', ['RECHARGE', 'COMBINE', 'PARTNER', 'RECHARGE'])
|
|
|
+ ->where('order_status_payment', 'SUCCESS')
|
|
|
+ ->orWhereJsonContains('order_extend_json->referee_dept_id', intval($request->get('premises_id')))
|
|
|
+ ->pluck('order_id')
|
|
|
+ ->toArray();
|
|
|
+ $orderIdsStr = "'" . implode("','", $orderIds) . "'";
|
|
|
+ $payIds = PayDetail::whereRaw("JSON_UNQUOTE(JSON_EXTRACT(join_pay_object_json,'$.order_id')) in ({$orderIdsStr})")
|
|
|
+ ->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(join_pay_object_json,'$.recharge_order_id')) in ({$orderIdsStr})")
|
|
|
->pluck('pay_id')
|
|
|
->toArray();
|
|
|
$where['pay_id'] = '';
|
|
@@ -55,12 +63,6 @@ class PayDetailController extends Curd
|
|
|
$where['pay_id'] = ['in', $payIds];
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
$query = $this->doSelect($where, $field, $order, $request->get());
|
|
|
return $this->doFormat($query, $format, $limit);
|
|
|
}
|
|
@@ -288,6 +290,89 @@ class PayDetailController extends Curd
|
|
|
return $items;
|
|
|
}
|
|
|
|
|
|
+ public function statistics(Request $request)
|
|
|
+ {
|
|
|
+ $type = $request->get('type');
|
|
|
+ $orderType = $request->get('order_type');
|
|
|
+ $premisesId = $request->get('premises_id');
|
|
|
+ $memberId = $request->get('join_pay_member_id');
|
|
|
+ $payAddtimes = $request->get('pay_addtimes');
|
|
|
+
|
|
|
+ if (!empty($payAddtimes)) {
|
|
|
+ $payAddtimes[0] = strtotime($payAddtimes[0]);
|
|
|
+ $payAddtimes[1] = strtotime($payAddtimes[1]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $payDetailModel = PayDetail::where('pay_status', 'SUCCESS')
|
|
|
+ ->where('pay_category', 'RECHARGE')
|
|
|
+ ->select(Db::raw("SUM(CASE WHEN join_pay_order_id='COMBINE' THEN 1000 ELSE pay_amount END) as amount, COUNT(pay_id) as total"));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $totalModel = clone $payDetailModel;
|
|
|
+ $total = $totalModel->first()->toArray();
|
|
|
+ $todayUnixStart = strtotime(date('Y-m-d'));
|
|
|
+ $todayUnixEnd = strtotime(date('Y-m-d 23:59:59'));
|
|
|
+ $todayTotalModel = clone $payDetailModel;
|
|
|
+ $todayTotal = $todayTotalModel->whereBetween('pay_addtimes', [$todayUnixStart, $todayUnixEnd])
|
|
|
+ ->first()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ $yesterdayStart = strtotime(date('Y-m-d', strtotime("-1 days")));
|
|
|
+ $yesterdayEnd = strtotime(date('Y-m-d 23:59:59', strtotime("-1 days")));
|
|
|
+ $yesterdayTotalModel = clone $payDetailModel;
|
|
|
+ $yesterdayTotal = $yesterdayTotalModel->whereBetween('pay_addtimes', [$yesterdayStart, $yesterdayEnd])
|
|
|
+ ->first()
|
|
|
+ ->toArray();
|
|
|
+ $monthStart = strtotime(date('Y-m-01'));
|
|
|
+ $monthEnd = strtotime(date('Y-m-t 23:59:59'));
|
|
|
+ $monthTotalModel = clone $payDetailModel;
|
|
|
+ $monthTotal = $monthTotalModel->whereBetween('pay_addtimes', [$monthStart, $monthEnd])
|
|
|
+ ->first()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ return json_success('success', [
|
|
|
+ 'total' => $total,
|
|
|
+ 'todayTotal' => $todayTotal,
|
|
|
+ 'yesterdayTotal' => $yesterdayTotal,
|
|
|
+ 'monthTotal' => $monthTotal
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* @Desc 产品订单
|
|
|
* @Author Gorden
|
|
@@ -376,7 +461,7 @@ class PayDetailController extends Curd
|
|
|
if ($detail['join_pay_order_id'] == 'PARTNER') {
|
|
|
$order['added_amount'] = sprintf('%.2f', $payObjectJson['recharge_config']['nbr']);
|
|
|
} else {
|
|
|
- $order['added_amount'] = sprintf('%.2f', round($detail['pay_amount'] * $payObjectJson['recharge_config']['nbr'],2));
|
|
|
+ $order['added_amount'] = sprintf('%.2f', round($detail['pay_amount'] * $payObjectJson['recharge_config']['nbr'], 2));
|
|
|
}
|
|
|
|
|
|
}
|