|
|
@@ -692,14 +692,20 @@ class OrderService extends BaseService
|
|
|
public function getStatistics($storeId = 0)
|
|
|
{
|
|
|
// 总订单数
|
|
|
- $total = $this->model->where('mark', 1)
|
|
|
+ $params = request()->all();
|
|
|
+ $userId = isset($params['user_id'])?$params['user_id']:0;
|
|
|
+ $where = ['user_id'=>$userId,'mark'=>1];
|
|
|
+ if($userId<=0){
|
|
|
+ unset($where['user_id']);
|
|
|
+ }
|
|
|
+ $total = $this->model->where($where)
|
|
|
->when($storeId > 0, function ($query) use ($storeId) {
|
|
|
return $query->where('store_id', $storeId);
|
|
|
})
|
|
|
->count();
|
|
|
|
|
|
// 总交易额(已完成订单)
|
|
|
- $totalAmount = $this->model->where('mark', 1)
|
|
|
+ $totalAmount = $this->model->where($where)
|
|
|
->where('status', 4)
|
|
|
->when($storeId > 0, function ($query) use ($storeId) {
|
|
|
return $query->where('store_id', $storeId);
|
|
|
@@ -707,7 +713,7 @@ class OrderService extends BaseService
|
|
|
->sum('pay_total');
|
|
|
|
|
|
// 待处理订单(待付款 + 已付款)
|
|
|
- $pending = $this->model->where('mark', 1)
|
|
|
+ $pending = $this->model->where($where)
|
|
|
->whereIn('status', [1, 2])
|
|
|
->when($storeId > 0, function ($query) use ($storeId) {
|
|
|
return $query->where('store_id', $storeId);
|
|
|
@@ -715,7 +721,7 @@ class OrderService extends BaseService
|
|
|
->count();
|
|
|
|
|
|
// 待退款订单
|
|
|
- $refunding = $this->model->where('mark', 1)
|
|
|
+ $refunding = $this->model->where($where)
|
|
|
->where('refund_status', 3)
|
|
|
->when($storeId > 0, function ($query) use ($storeId) {
|
|
|
return $query->where('store_id', $storeId);
|