dataview 订单排行
This commit is contained in:
parent
0c3a7e2da7
commit
56771e3155
@ -36,6 +36,8 @@ class Order extends BaseController
|
|||||||
throw new ValidateException('请选择地区');
|
throw new ValidateException('请选择地区');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 今日订单
|
||||||
public function currOrderInfo()
|
public function currOrderInfo()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -116,4 +118,36 @@ class Order extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 镇级订单数排行榜
|
||||||
|
public function orderRanking()
|
||||||
|
{
|
||||||
|
|
||||||
|
$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(); // 镇/街道列表
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
unset($town);
|
||||||
|
// $orderRankingQuery = Db::name('product_order_log')->alias('op')
|
||||||
|
// ->leftJoin('geo_street s','op.street_code = s.street_code')
|
||||||
|
// ->field('op.street_code,COUNT(op.order_id) AS order_count,s.street_name')
|
||||||
|
// ->where('op.district_code',$this->areaCode)
|
||||||
|
// ->where('op.status',1);
|
||||||
|
//
|
||||||
|
// if ($type == 1) {
|
||||||
|
// $orderCountQuery->whereDay('create_time', 'today');
|
||||||
|
// }
|
||||||
|
// $orderRankingList = $orderRankingQuery->group('op.street_code')->order('order_count desc')->select();
|
||||||
|
$cmf_arr = array_column($townList, 'order_count');
|
||||||
|
array_multisort($cmf_arr, SORT_DESC, $townList);
|
||||||
|
return app('json')->success($townList);
|
||||||
|
}
|
||||||
}
|
}
|
@ -718,6 +718,7 @@ Route::group('api/', function () {
|
|||||||
Route::group('dataview', function () {
|
Route::group('dataview', function () {
|
||||||
// Route::post('cancel/:id', '/cancelGroupOrder');
|
// Route::post('cancel/:id', '/cancelGroupOrder');
|
||||||
Route::get('curr_order_info', 'Order/currOrderInfo');
|
Route::get('curr_order_info', 'Order/currOrderInfo');
|
||||||
|
Route::get('order_ranking', 'Order/orderRanking');
|
||||||
|
|
||||||
})->prefix('api.dataview.');
|
})->prefix('api.dataview.');
|
||||||
})->middleware(AllowOriginMiddleware::class)
|
})->middleware(AllowOriginMiddleware::class)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user