dataview 订单排行
This commit is contained in:
parent
2542a96919
commit
de459e01d2
@ -126,14 +126,16 @@ class Order extends BaseController
|
||||
|
||||
$type = $this->request->get('type',2); // 1今日 2总计
|
||||
$townList = Db::name('geo_street')->field('street_code,street_name')->where('area_code', $this->areaCode)->select()->toArray(); // 镇/街道列表
|
||||
$orderCount = 0;
|
||||
foreach ($townList as &$town) {
|
||||
// 查询订单数
|
||||
$orderCountQuery = Db::name('product_order_log')->where('street_code', $town['street_code'])->where('status', 1);
|
||||
if ($type == 1) {
|
||||
$orderCountQuery->whereDay('create_time', 'today');
|
||||
}
|
||||
$orderCount = $orderCountQuery->count();
|
||||
$town['order_count'] = $orderCount;
|
||||
$tempOrderCount = $orderCountQuery->count();
|
||||
$town['order_count'] = $tempOrderCount;
|
||||
$orderCount += $tempOrderCount;
|
||||
}
|
||||
unset($town);
|
||||
// $orderRankingQuery = Db::name('product_order_log')->alias('op')
|
||||
@ -149,6 +151,6 @@ class Order extends BaseController
|
||||
|
||||
$orderCountArr = array_column($townList, 'order_count');
|
||||
array_multisort($orderCountArr, SORT_DESC, $townList);
|
||||
return app('json')->success($townList);
|
||||
return app('json')->success(compact('orderCount', 'townList'));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user