dataview-今日订单接口
This commit is contained in:
parent
865b2acc8f
commit
be5ba9ab3f
@ -39,22 +39,55 @@ class Order extends BaseController
|
|||||||
public function currOrderInfo()
|
public function currOrderInfo()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// 今日订单数
|
$day = '2023-11-29'; // today
|
||||||
$currOrderCountQuery = Db::name('store_order')->alias('o')
|
$currOrderCountQuery = Db::name('store_order')->alias('o')
|
||||||
->field(['o.order_sn', 'o.real_name', 'o.user_phone', 'o.user_address', 'o.user_address_code', 'p.store_name', 'm.mer_name', 'o.create_time', 'o.status'])
|
->field(['o.order_sn', 'o.real_name', 'o.user_phone', 'o.user_address', 'o.user_address_code', 'p.store_name', 'm.mer_name', 'o.create_time', 'o.status'])
|
||||||
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
|
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
|
||||||
->leftJoin('merchant m', 'o.mer_id = m.mer_id')
|
->leftJoin('merchant m', 'o.mer_id = m.mer_id')
|
||||||
->leftJoin('store_order_product op', 'o.order_id = op.order_id')
|
->leftJoin('store_order_product op', 'o.order_id = op.order_id')
|
||||||
->leftJoin('product_library p', 'op.product_id = p.id')
|
->leftJoin('product_library p', 'op.product_id = p.id')
|
||||||
->whereDay('og.create_time', '2023-11-29')
|
->whereDay('og.create_time', $day)
|
||||||
->where('o.paid', 1)
|
->where('o.paid', 1)
|
||||||
->whereNotNull('o.pay_time');
|
->whereNotNull('o.pay_time');
|
||||||
|
|
||||||
|
// 待取货订单数统计query 订单待发货
|
||||||
|
$pendingPickupOrderCountQuery = Db::name('store_order')->alias('o')
|
||||||
|
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
|
||||||
|
->whereDay('og.create_time', $day)
|
||||||
|
->where('o.status', 0)
|
||||||
|
->where('o.paid', 1)
|
||||||
|
->whereNotNull('o.pay_time');;
|
||||||
|
|
||||||
|
// 未配送订单数统计query 订单待收货
|
||||||
|
$undeliveredOrderCountQuery = Db::name('store_order')->alias('o')
|
||||||
|
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
|
||||||
|
->whereDay('og.create_time', $day)
|
||||||
|
->where('o.status', 1)
|
||||||
|
->where('o.paid', 1)
|
||||||
|
->whereNotNull('o.pay_time');;
|
||||||
|
|
||||||
|
// 已完成订单数统计query 订单已完成
|
||||||
|
$doneOrderCountQuery = Db::name('store_order')->alias('o')
|
||||||
|
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
|
||||||
|
->whereDay('og.create_time', $day)
|
||||||
|
->whereIn('o.status', [2,3])
|
||||||
|
->where('o.paid', 1)
|
||||||
|
->whereNotNull('o.pay_time');
|
||||||
|
|
||||||
if ($this->areaCode != '') {
|
if ($this->areaCode != '') {
|
||||||
$currOrderCountQuery->where('og.district_code', $this->areaCode);
|
$currOrderCountQuery->where('og.district_code', $this->areaCode);
|
||||||
|
$pendingPickupOrderCountQuery->where('og.district_code', $this->areaCode);
|
||||||
|
$undeliveredOrderCountQuery->where('og.district_code', $this->areaCode);
|
||||||
|
$doneOrderCountQuery->where('og.district_code', $this->areaCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->streetCode != '') {
|
if ($this->streetCode != '') {
|
||||||
$currOrderCountQuery->where('og.street_code', $this->streetCode);
|
$currOrderCountQuery->where('og.street_code', $this->streetCode);
|
||||||
|
$pendingPickupOrderCountQuery->where('og.street_code', $this->streetCode);
|
||||||
|
$undeliveredOrderCountQuery->where('og.street_code', $this->streetCode);
|
||||||
|
$doneOrderCountQuery->where('og.street_code', $this->streetCode);
|
||||||
}
|
}
|
||||||
|
// 今日订单数
|
||||||
$currOrderCount = $currOrderCountQuery->count();
|
$currOrderCount = $currOrderCountQuery->count();
|
||||||
|
|
||||||
[$page, $limit] = $this->getPage();
|
[$page, $limit] = $this->getPage();
|
||||||
@ -69,7 +102,14 @@ class Order extends BaseController
|
|||||||
$currOrderList[$k]['courier'] = $courierData['data']['courier_name'];
|
$currOrderList[$k]['courier'] = $courierData['data']['courier_name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return app('json')->success(compact('currOrderCount', 'currOrderList'));
|
// 待取货订单数
|
||||||
|
$pendingOrderCount = $pendingPickupOrderCountQuery->count();
|
||||||
|
// 未配送订单数
|
||||||
|
$undeliveredOrderCount = $undeliveredOrderCountQuery->count();
|
||||||
|
// 已完成订单数
|
||||||
|
$doneOrderCountQuery = $doneOrderCountQuery->count();
|
||||||
|
|
||||||
|
return app('json')->success(compact('currOrderCount', 'pendingOrderCount', 'undeliveredOrderCount', 'doneOrderCountQuery', 'currOrderList'));
|
||||||
|
|
||||||
} catch (ValidateException $e) {
|
} catch (ValidateException $e) {
|
||||||
throw new ValidateException($e->getMessage());
|
throw new ValidateException($e->getMessage());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user