|
@@ -63,11 +63,13 @@ class OrderService extends BaseService
|
|
|
*/
|
|
*/
|
|
|
public function getDataList($params, $pageSize = 15)
|
|
public function getDataList($params, $pageSize = 15)
|
|
|
{
|
|
{
|
|
|
- $query = $this->model->where(['main_no'=>'','mark'=>1]);
|
|
|
|
|
|
|
+ $query = $this->model->from('orders as a')
|
|
|
|
|
+ ->leftHoin('member as b','b.id','=','a.user_id')
|
|
|
|
|
+ ->where(['a.main_no'=>'','b.mark'=>1,'a.mark'=>1]);
|
|
|
|
|
|
|
|
// 企业筛选
|
|
// 企业筛选
|
|
|
if (isset($params['type']) && $params['type'] > 0) {
|
|
if (isset($params['type']) && $params['type'] > 0) {
|
|
|
- $query->where('type', $params['type']);
|
|
|
|
|
|
|
+ $query->where('a.type', $params['type']);
|
|
|
|
|
|
|
|
if($params['type'] == 9){
|
|
if($params['type'] == 9){
|
|
|
$query->with(['subOrders']);
|
|
$query->with(['subOrders']);
|
|
@@ -76,25 +78,25 @@ class OrderService extends BaseService
|
|
|
|
|
|
|
|
// 企业筛选
|
|
// 企业筛选
|
|
|
if (isset($params['store_id']) && $params['store_id'] > 0) {
|
|
if (isset($params['store_id']) && $params['store_id'] > 0) {
|
|
|
- $query->where('store_id', $params['store_id']);
|
|
|
|
|
|
|
+ $query->where('a.store_id', $params['store_id']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 用户筛选
|
|
// 用户筛选
|
|
|
if (isset($params['user_id']) && $params['user_id'] > 0) {
|
|
if (isset($params['user_id']) && $params['user_id'] > 0) {
|
|
|
- $query->where('user_id', $params['user_id']);
|
|
|
|
|
|
|
+ $query->where('a.user_id', $params['user_id']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 状态筛选
|
|
// 状态筛选
|
|
|
if (isset($params['status']) && $params['status'] > 0) {
|
|
if (isset($params['status']) && $params['status'] > 0) {
|
|
|
- $query->where('status', $params['status']);
|
|
|
|
|
|
|
+ $query->where('a.status', $params['status']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 退款状态筛选
|
|
// 退款状态筛选
|
|
|
if (isset($params['refund_status']) && $params['refund_status'] >= 0) {
|
|
if (isset($params['refund_status']) && $params['refund_status'] >= 0) {
|
|
|
if($params['refund_status']>0){
|
|
if($params['refund_status']>0){
|
|
|
- $query->where('refund_status', $params['refund_status']);
|
|
|
|
|
|
|
+ $query->where('a.refund_status', $params['refund_status']);
|
|
|
}else{
|
|
}else{
|
|
|
- $query->where('refund_status','>',0);
|
|
|
|
|
|
|
+ $query->where('a.refund_status','>',0);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -102,8 +104,8 @@ class OrderService extends BaseService
|
|
|
if (isset($params['order_no']) && $params['order_no']) {
|
|
if (isset($params['order_no']) && $params['order_no']) {
|
|
|
$keyword = $params['order_no'];
|
|
$keyword = $params['order_no'];
|
|
|
$query->where(function ($q) use ($keyword) {
|
|
$query->where(function ($q) use ($keyword) {
|
|
|
- $q->where('order_no', 'like', '%' . $keyword . '%')
|
|
|
|
|
- ->orWhere('transaction_id', 'like', '%' . $keyword . '%');
|
|
|
|
|
|
|
+ $q->where('a.order_no', 'like', '%' . $keyword . '%')
|
|
|
|
|
+ ->orWhere('a.transaction_id', 'like', '%' . $keyword . '%');
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -113,12 +115,12 @@ class OrderService extends BaseService
|
|
|
$start = $date[0] ?? '';
|
|
$start = $date[0] ?? '';
|
|
|
$end = $date[1] ?? '';
|
|
$end = $date[1] ?? '';
|
|
|
if ($start) {
|
|
if ($start) {
|
|
|
- $query->where('create_time', '>=', strtotime($start));
|
|
|
|
|
|
|
+ $query->where('a.create_time', '>=', strtotime($start));
|
|
|
}
|
|
}
|
|
|
if ($end && $start < $end) {
|
|
if ($end && $start < $end) {
|
|
|
- $query->where('create_time', '<=', strtotime($end));
|
|
|
|
|
|
|
+ $query->where('a.create_time', '<=', strtotime($end));
|
|
|
}else if ($end && $start == $end) {
|
|
}else if ($end && $start == $end) {
|
|
|
- $query->where('create_time', '<', strtotime($end)+86400);
|
|
|
|
|
|
|
+ $query->where('a.create_time', '<', strtotime($end)+86400);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -126,13 +128,13 @@ class OrderService extends BaseService
|
|
|
if (isset($params['keyword']) && $params['keyword']) {
|
|
if (isset($params['keyword']) && $params['keyword']) {
|
|
|
$keyword = $params['keyword'];
|
|
$keyword = $params['keyword'];
|
|
|
$query->where(function ($q) use ($keyword) {
|
|
$query->where(function ($q) use ($keyword) {
|
|
|
- $q->where('receiver_name', 'like', '%' . $keyword . '%')
|
|
|
|
|
- ->orWhere('receiver_mobile', 'like', '%' . $keyword . '%')
|
|
|
|
|
|
|
+ $q->where('a.receiver_name', 'like', '%' . $keyword . '%')
|
|
|
|
|
+ ->orWhere('a.receiver_mobile', 'like', '%' . $keyword . '%')
|
|
|
->orWhereHas('user', function ($q1) use ($keyword) {
|
|
->orWhereHas('user', function ($q1) use ($keyword) {
|
|
|
- $q1->where('mobile', 'like', '%' . $keyword . '%');
|
|
|
|
|
|
|
+ $q1->where('a.mobile', 'like', '%' . $keyword . '%');
|
|
|
})
|
|
})
|
|
|
->orWhereHas('orderGoods', function ($q2) use ($keyword) {
|
|
->orWhereHas('orderGoods', function ($q2) use ($keyword) {
|
|
|
- $q2->where('goods_name', 'like', '%' . $keyword . '%');
|
|
|
|
|
|
|
+ $q2->where('a.goods_name', 'like', '%' . $keyword . '%');
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -142,15 +144,15 @@ class OrderService extends BaseService
|
|
|
$query3 = clone $query;
|
|
$query3 = clone $query;
|
|
|
$query4 = clone $query;
|
|
$query4 = clone $query;
|
|
|
$counts = [
|
|
$counts = [
|
|
|
- 'total' => $query1->count('id'),
|
|
|
|
|
- 'totalAmount' => $query2->whereIn('status',[1,2,3,4,5])->sum('pay_total'),
|
|
|
|
|
- 'pending' => $query3->whereIn('status',[1,2])->count('id'),
|
|
|
|
|
- 'complete' => $query4->whereIn('status',[4,5])->count('id'),
|
|
|
|
|
|
|
+ 'total' => $query1->count('a.id'),
|
|
|
|
|
+ 'totalAmount' => $query2->whereIn('a.status',[1,2,3,4,5])->sum('a.pay_total'),
|
|
|
|
|
+ 'pending' => $query3->whereIn('a.status',[1,2])->count('a.id'),
|
|
|
|
|
+ 'complete' => $query4->whereIn('a.status',[4,5])->count('a.id'),
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
$list = $query->with(['user', 'orderGoods', 'store','subOrders','commission'])
|
|
$list = $query->with(['user', 'orderGoods', 'store','subOrders','commission'])
|
|
|
- ->orderBy('create_time', 'desc')
|
|
|
|
|
- ->orderBy('id', 'desc')
|
|
|
|
|
|
|
+ ->orderBy('a.create_time', 'desc')
|
|
|
|
|
+ ->orderBy('a.id', 'desc')
|
|
|
->paginate($pageSize);
|
|
->paginate($pageSize);
|
|
|
|
|
|
|
|
$list = $list ? $list->toArray() : [];
|
|
$list = $list ? $list->toArray() : [];
|