修改订单列表查询
This commit is contained in:
parent
0bb1f36e87
commit
a91cf005e3
@ -29,6 +29,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
return [
|
||||
'=' => ['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) {
|
||||
$query->field(['id', 'oid', 'product_id', 'cart_info']);
|
||||
}])->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) {
|
||||
$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) {
|
||||
if ($this->params['status'] == -1) {
|
||||
@ -97,17 +89,8 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function count(): int
|
||||
{
|
||||
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) {
|
||||
$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) {
|
||||
if ($this->params['status'] == -1) {
|
||||
|
@ -105,6 +105,9 @@ abstract class BaseDataLists implements ListsInterface
|
||||
$endTime = $this->request->get('end_time');
|
||||
if($endTime){
|
||||
$this->endTime = strtotime($endTime);
|
||||
if ($startTime == $endTime) {
|
||||
$this->endTime = strtotime($endTime) + 86399;
|
||||
}
|
||||
}
|
||||
$this->start = $this->request->get('start');
|
||||
$this->end = $this->request->get('end');
|
||||
@ -180,4 +183,4 @@ abstract class BaseDataLists implements ListsInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface,
|
||||
public function setSearch(): array
|
||||
{
|
||||
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;
|
||||
return StoreFinanceFlow::with(['user', 'staff'])
|
||||
->where($this->searchWhere)
|
||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||
$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) {
|
||||
$income = 1;
|
||||
$expense = 0;
|
||||
@ -70,18 +63,10 @@ class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface,
|
||||
public function count(): int
|
||||
{
|
||||
return StoreFinanceFlow::where('1=1')
|
||||
->where($this->searchWhere)
|
||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||
$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) {
|
||||
$income = 1;
|
||||
$expense = 0;
|
||||
|
@ -21,6 +21,7 @@ class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
{
|
||||
return [
|
||||
'=' => ['order_id', 'refund_type'],
|
||||
'between_time' => 'refund_reason_time'
|
||||
];
|
||||
}
|
||||
|
||||
@ -42,16 +43,7 @@ class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
->where($this->searchWhere)
|
||||
->where('refund_status', '>', 0)
|
||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||
$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']);
|
||||
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||
})
|
||||
->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)
|
||||
@ -77,16 +69,7 @@ class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
return StoreOrder::where($this->searchWhere)
|
||||
->where('refund_status', '>', 0)
|
||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||
$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']);
|
||||
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||
})
|
||||
->count();
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ use app\common\service\FileService;
|
||||
*/
|
||||
class WorkbenchLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
public static function index($params)
|
||||
{
|
||||
$data = [];
|
||||
@ -39,9 +39,6 @@ class WorkbenchLogic extends BaseLogic
|
||||
$endTime = $params['end_time'];
|
||||
$endTime = date('Y-m-d', strtotime($endTime) + 86400);
|
||||
$dateDiff = (new \DateTime($endTime))->diff(new \DateTime($startTime));
|
||||
if ($dateDiff->days > 366) {
|
||||
throw new \Exception('时间范围不能超过一年');
|
||||
}
|
||||
$orderLogic = new StoreOrderLogic();
|
||||
//订单总金额
|
||||
$data['order_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime);
|
||||
@ -78,7 +75,17 @@ class WorkbenchLogic extends BaseLogic
|
||||
} else {
|
||||
$group = 'MONTH(pay_time)';
|
||||
$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)));
|
||||
$i++;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user