修改订单列表查询
This commit is contained in:
parent
0bb1f36e87
commit
a91cf005e3
@ -29,6 +29,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['order_id', 'pay_type', 'staff_id', 'shipping_type', 'delivery_id'],
|
'=' => ['order_id', 'pay_type', 'staff_id', 'shipping_type', 'delivery_id'],
|
||||||
|
'between_time' => 'create_time'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,17 +48,8 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
return StoreOrder::with(['user', 'staff', 'product' => function ($query) {
|
return StoreOrder::with(['user', 'staff', 'product' => function ($query) {
|
||||||
$query->field(['id', 'oid', 'product_id', 'cart_info']);
|
$query->field(['id', 'oid', 'product_id', 'cart_info']);
|
||||||
}])->where($this->searchWhere)
|
}])->where($this->searchWhere)
|
||||||
->when(!empty($this->params['start_time']), function ($query) {
|
|
||||||
$query->whereTime('create_time', '>=', $this->params['start_time']);
|
|
||||||
})
|
|
||||||
->when(!empty($this->params['end_time']), function ($query) {
|
|
||||||
if ($this->params['end_time'] == $this->params['start_time']) {
|
|
||||||
$this->params['end_time'] = strtotime($this->params['end_time']) + 86399;
|
|
||||||
}
|
|
||||||
$query->whereTime('create_time', '<=', $this->params['end_time']);
|
|
||||||
})
|
|
||||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||||
$query->where('store_id', '=', $this->request->adminInfo['store_id']);
|
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||||
})
|
})
|
||||||
->when(!empty($this->params['status']), function ($query) {
|
->when(!empty($this->params['status']), function ($query) {
|
||||||
if ($this->params['status'] == -1) {
|
if ($this->params['status'] == -1) {
|
||||||
@ -97,17 +89,8 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
public function count(): int
|
public function count(): int
|
||||||
{
|
{
|
||||||
return StoreOrder::where($this->searchWhere)
|
return StoreOrder::where($this->searchWhere)
|
||||||
->when(!empty($this->params['start_time']), function ($query) {
|
|
||||||
$query->whereTime('create_time', '>=', $this->params['start_time']);
|
|
||||||
})
|
|
||||||
->when(!empty($this->params['end_time']), function ($query) {
|
|
||||||
if ($this->params['end_time'] == $this->params['start_time']) {
|
|
||||||
$this->params['end_time'] = strtotime($this->params['end_time']) + 86399;
|
|
||||||
}
|
|
||||||
$query->whereTime('create_time', '<=', $this->params['end_time']);
|
|
||||||
})
|
|
||||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||||
$query->where('store_id', '=', $this->request->adminInfo['store_id']);
|
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||||
})
|
})
|
||||||
->when(!empty($this->params['status']), function ($query) {
|
->when(!empty($this->params['status']), function ($query) {
|
||||||
if ($this->params['status'] == -1) {
|
if ($this->params['status'] == -1) {
|
||||||
|
@ -105,6 +105,9 @@ abstract class BaseDataLists implements ListsInterface
|
|||||||
$endTime = $this->request->get('end_time');
|
$endTime = $this->request->get('end_time');
|
||||||
if($endTime){
|
if($endTime){
|
||||||
$this->endTime = strtotime($endTime);
|
$this->endTime = strtotime($endTime);
|
||||||
|
if ($startTime == $endTime) {
|
||||||
|
$this->endTime = strtotime($endTime) + 86399;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->start = $this->request->get('start');
|
$this->start = $this->request->get('start');
|
||||||
$this->end = $this->request->get('end');
|
$this->end = $this->request->get('end');
|
||||||
|
@ -14,6 +14,7 @@ class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface,
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'between_time' => 'create_time'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,18 +22,10 @@ class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface,
|
|||||||
{
|
{
|
||||||
$this->params['type'] = !empty($this->params['type']) ? $this->params['type'] : 1;
|
$this->params['type'] = !empty($this->params['type']) ? $this->params['type'] : 1;
|
||||||
return StoreFinanceFlow::with(['user', 'staff'])
|
return StoreFinanceFlow::with(['user', 'staff'])
|
||||||
|
->where($this->searchWhere)
|
||||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||||
$query->where('store_id', $this->request->adminInfo['store_id']);
|
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||||
})
|
})
|
||||||
->when(!empty($this->params['start_time']), function ($query) {
|
|
||||||
$query->whereTime('create_time', '>=', $this->params['start_time']);
|
|
||||||
})
|
|
||||||
->when(!empty($this->params['end_time']), function ($query) {
|
|
||||||
if ($this->params['end_time'] == $this->params['start_time']) {
|
|
||||||
$this->params['end_time'] = strtotime($this->params['end_time']) + 86399;
|
|
||||||
}
|
|
||||||
$query->whereTime('create_time', '<=', $this->params['end_time']);
|
|
||||||
})
|
|
||||||
->when(!empty($this->params['type']), function (Query $query) {
|
->when(!empty($this->params['type']), function (Query $query) {
|
||||||
$income = 1;
|
$income = 1;
|
||||||
$expense = 0;
|
$expense = 0;
|
||||||
@ -70,18 +63,10 @@ class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface,
|
|||||||
public function count(): int
|
public function count(): int
|
||||||
{
|
{
|
||||||
return StoreFinanceFlow::where('1=1')
|
return StoreFinanceFlow::where('1=1')
|
||||||
|
->where($this->searchWhere)
|
||||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||||
$query->where('store_id', $this->request->adminInfo['store_id']);
|
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||||
})
|
})
|
||||||
->when(!empty($this->params['start_time']), function ($query) {
|
|
||||||
$query->whereTime('create_time', '>=', $this->params['start_time']);
|
|
||||||
})
|
|
||||||
->when(!empty($this->params['end_time']), function ($query) {
|
|
||||||
if ($this->params['end_time'] == $this->params['start_time']) {
|
|
||||||
$this->params['end_time'] = strtotime($this->params['end_time']) + 86399;
|
|
||||||
}
|
|
||||||
$query->whereTime('create_time', '<=', $this->params['end_time']);
|
|
||||||
})
|
|
||||||
->when(!empty($this->params['type']), function (Query $query) {
|
->when(!empty($this->params['type']), function (Query $query) {
|
||||||
$income = 1;
|
$income = 1;
|
||||||
$expense = 0;
|
$expense = 0;
|
||||||
|
@ -21,6 +21,7 @@ class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInt
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['order_id', 'refund_type'],
|
'=' => ['order_id', 'refund_type'],
|
||||||
|
'between_time' => 'refund_reason_time'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,16 +43,7 @@ class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInt
|
|||||||
->where($this->searchWhere)
|
->where($this->searchWhere)
|
||||||
->where('refund_status', '>', 0)
|
->where('refund_status', '>', 0)
|
||||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||||
$query->where('store_id', '=', $this->request->adminInfo['store_id']);
|
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||||
})
|
|
||||||
->when(!empty($this->params['start_time']), function ($query) {
|
|
||||||
$query->whereTime('refund_reason_time', '>=', $this->params['start_time']);
|
|
||||||
})
|
|
||||||
->when(!empty($this->params['end_time']), function ($query) {
|
|
||||||
if ($this->params['end_time'] == $this->params['start_time']) {
|
|
||||||
$this->params['end_time'] = strtotime($this->params['end_time']) + 86399;
|
|
||||||
}
|
|
||||||
$query->whereTime('refund_reason_time', '<=', $this->params['end_time']);
|
|
||||||
})
|
})
|
||||||
->field(['id', 'store_id', 'staff_id', 'order_id', 'pay_price', 'pay_time', 'pay_type', 'status', 'uid', 'refund_status', 'refund_type', 'refund_reason_wap', 'refund_reason_time', 'refund_reason_wap_explain', 'refund_reason_wap_img', 'refund_reason'])
|
->field(['id', 'store_id', 'staff_id', 'order_id', 'pay_price', 'pay_time', 'pay_type', 'status', 'uid', 'refund_status', 'refund_type', 'refund_reason_wap', 'refund_reason_time', 'refund_reason_wap_explain', 'refund_reason_wap_img', 'refund_reason'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
@ -77,16 +69,7 @@ class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInt
|
|||||||
return StoreOrder::where($this->searchWhere)
|
return StoreOrder::where($this->searchWhere)
|
||||||
->where('refund_status', '>', 0)
|
->where('refund_status', '>', 0)
|
||||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||||
$query->where('store_id', '=', $this->request->adminInfo['store_id']);
|
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||||
})
|
|
||||||
->when(!empty($this->params['start_time']), function ($query) {
|
|
||||||
$query->whereTime('refund_reason_time', '>=', $this->params['start_time']);
|
|
||||||
})
|
|
||||||
->when(!empty($this->params['end_time']), function ($query) {
|
|
||||||
if ($this->params['end_time'] == $this->params['start_time']) {
|
|
||||||
$this->params['end_time'] = strtotime($this->params['end_time']) + 86399;
|
|
||||||
}
|
|
||||||
$query->whereTime('refund_reason_time', '<=', $this->params['end_time']);
|
|
||||||
})
|
})
|
||||||
->count();
|
->count();
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,6 @@ class WorkbenchLogic extends BaseLogic
|
|||||||
$endTime = $params['end_time'];
|
$endTime = $params['end_time'];
|
||||||
$endTime = date('Y-m-d', strtotime($endTime) + 86400);
|
$endTime = date('Y-m-d', strtotime($endTime) + 86400);
|
||||||
$dateDiff = (new \DateTime($endTime))->diff(new \DateTime($startTime));
|
$dateDiff = (new \DateTime($endTime))->diff(new \DateTime($startTime));
|
||||||
if ($dateDiff->days > 366) {
|
|
||||||
throw new \Exception('时间范围不能超过一年');
|
|
||||||
}
|
|
||||||
$orderLogic = new StoreOrderLogic();
|
$orderLogic = new StoreOrderLogic();
|
||||||
//订单总金额
|
//订单总金额
|
||||||
$data['order_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime);
|
$data['order_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime);
|
||||||
@ -78,7 +75,17 @@ class WorkbenchLogic extends BaseLogic
|
|||||||
} else {
|
} else {
|
||||||
$group = 'MONTH(pay_time)';
|
$group = 'MONTH(pay_time)';
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i <= $dateDiff->m) {
|
$month = 0;
|
||||||
|
if ($dateDiff->y > 0) {
|
||||||
|
$month = $dateDiff->y * 12;
|
||||||
|
}
|
||||||
|
if ($dateDiff->m > 0) {
|
||||||
|
$month += $dateDiff->m;
|
||||||
|
}
|
||||||
|
if ($dateDiff->d > 0) {
|
||||||
|
$month += 1;
|
||||||
|
}
|
||||||
|
while ($i < $month) {
|
||||||
$timeRange[] = date('Y-m', strtotime("+$i months", strtotime($startTime)));
|
$timeRange[] = date('Y-m', strtotime("+$i months", strtotime($startTime)));
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user