2024-06-01 16:07:53 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\store\controller;
|
|
|
|
|
|
2024-06-07 17:28:02 +08:00
|
|
|
|
use app\common\controller\Definitions;
|
2024-06-17 15:50:05 +08:00
|
|
|
|
use app\common\model\dict\DictType;
|
2024-06-08 17:37:59 +08:00
|
|
|
|
use app\store\lists\store_order\StoreOrderLists;
|
2024-06-01 16:07:53 +08:00
|
|
|
|
use app\store\logic\WorkbenchLogic;
|
|
|
|
|
|
2024-06-14 15:53:47 +08:00
|
|
|
|
// #[ApiDoc\Title('工作台')]
|
2024-06-01 16:07:53 +08:00
|
|
|
|
class WorkbenchController extends BaseAdminController
|
|
|
|
|
{
|
2024-06-17 15:50:05 +08:00
|
|
|
|
public $notNeedLogin = ['recharge_statistics'];
|
2024-06-01 16:07:53 +08:00
|
|
|
|
|
2024-06-14 15:53:47 +08:00
|
|
|
|
// #[
|
|
|
|
|
// ApiDoc\Title('交易统计'),
|
|
|
|
|
// ApiDoc\url('/store/workbench/index'),
|
|
|
|
|
// ApiDoc\Method('GET'),
|
|
|
|
|
// ApiDoc\NotHeaders(),
|
|
|
|
|
// ApiDoc\Author('中国队长'),
|
|
|
|
|
// ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'),
|
|
|
|
|
// ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'),
|
|
|
|
|
// ApiDoc\Header(ref: [Definitions::class, "token"]),
|
|
|
|
|
// ApiDoc\ResponseSuccess("data", type: "array"),
|
|
|
|
|
// ]
|
2024-06-01 16:07:53 +08:00
|
|
|
|
public function index()
|
|
|
|
|
{
|
2024-06-07 17:28:02 +08:00
|
|
|
|
$params = $this->request->get();
|
|
|
|
|
$params['store_id'] = $this->request->adminInfo['store_id'];
|
|
|
|
|
$result = WorkbenchLogic::index($params);
|
2024-06-01 16:07:53 +08:00
|
|
|
|
return $this->data($result);
|
|
|
|
|
}
|
2024-06-07 17:28:02 +08:00
|
|
|
|
|
2024-06-14 15:53:47 +08:00
|
|
|
|
// #[
|
|
|
|
|
// ApiDoc\Title('商品统计(暂时不用)'),
|
|
|
|
|
// ApiDoc\url('/store/workbench/product'),
|
|
|
|
|
// ApiDoc\Method('GET'),
|
|
|
|
|
// ApiDoc\NotHeaders(),
|
|
|
|
|
// ApiDoc\Author('中国队长'),
|
|
|
|
|
// ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'),
|
|
|
|
|
// ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'),
|
|
|
|
|
// ApiDoc\Header(ref: [Definitions::class, "token"]),
|
|
|
|
|
// ApiDoc\ResponseSuccess("data", type: "array"),
|
|
|
|
|
// ]
|
2024-06-07 17:28:02 +08:00
|
|
|
|
public function product()
|
|
|
|
|
{
|
2024-06-08 16:53:08 +08:00
|
|
|
|
$params = $this->request->get();
|
|
|
|
|
$params['store_id'] = $this->request->adminInfo['store_id'];
|
|
|
|
|
$result = WorkbenchLogic::product($params);
|
2024-06-07 17:28:02 +08:00
|
|
|
|
return $this->data($result);
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-14 15:53:47 +08:00
|
|
|
|
// #[
|
|
|
|
|
// ApiDoc\Title('配送统计'),
|
|
|
|
|
// ApiDoc\url('/store/workbench/delivery'),
|
|
|
|
|
// ApiDoc\Method('GET'),
|
|
|
|
|
// ApiDoc\NotHeaders(),
|
|
|
|
|
// ApiDoc\Author('中国队长'),
|
|
|
|
|
// ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'),
|
|
|
|
|
// ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'),
|
|
|
|
|
// ApiDoc\Header(ref: [Definitions::class, "token"]),
|
|
|
|
|
// ApiDoc\ResponseSuccess("data", type: "array"),
|
|
|
|
|
// ]
|
2024-06-07 17:28:02 +08:00
|
|
|
|
public function delivery()
|
2024-06-08 16:53:08 +08:00
|
|
|
|
{
|
|
|
|
|
$params = $this->request->get();
|
|
|
|
|
$params['store_id'] = $this->request->adminInfo['store_id'];
|
2024-06-08 17:37:59 +08:00
|
|
|
|
$result = WorkbenchLogic::delivery($params);
|
|
|
|
|
return $this->data($result);
|
2024-06-08 16:53:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-14 15:53:47 +08:00
|
|
|
|
// #[
|
|
|
|
|
// ApiDoc\Title('配送订单统计'),
|
|
|
|
|
// ApiDoc\url('/store/workbench/deliveryOrder'),
|
|
|
|
|
// ApiDoc\Method('GET'),
|
|
|
|
|
// ApiDoc\NotHeaders(),
|
|
|
|
|
// ApiDoc\Author('中国队长'),
|
|
|
|
|
// ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'),
|
|
|
|
|
// ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'),
|
|
|
|
|
// ApiDoc\Header(ref: [Definitions::class, "token"]),
|
|
|
|
|
// ApiDoc\Query(ref: [Definitions::class, "page"]),
|
|
|
|
|
// ApiDoc\ResponseSuccess("data", type: "array"),
|
|
|
|
|
// ]
|
2024-06-08 17:37:59 +08:00
|
|
|
|
public function deliveryOrder()
|
2024-06-08 16:53:08 +08:00
|
|
|
|
{
|
|
|
|
|
$params = $this->request->get();
|
|
|
|
|
$params['store_id'] = $this->request->adminInfo['store_id'];
|
2024-06-08 17:37:59 +08:00
|
|
|
|
$result = WorkbenchLogic::deliveryOrder($params);
|
|
|
|
|
return $this->data($result);
|
2024-06-08 16:53:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-14 15:53:47 +08:00
|
|
|
|
// #[
|
|
|
|
|
// ApiDoc\Title('商品统计-概况'),
|
|
|
|
|
// ApiDoc\url('/store/workbench/get_basic'),
|
|
|
|
|
// ApiDoc\Method('GET'),
|
|
|
|
|
// ApiDoc\NotHeaders(),
|
|
|
|
|
// ApiDoc\Author('中国队长'),
|
|
|
|
|
// ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'),
|
|
|
|
|
// ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'),
|
|
|
|
|
// ApiDoc\Header(ref: [Definitions::class, "token"]),
|
|
|
|
|
// ApiDoc\ResponseSuccess("data", type: "array"),
|
|
|
|
|
// ]
|
2024-06-08 17:37:59 +08:00
|
|
|
|
public function get_basic(\app\admin\controller\WorkbenchController $workbench)
|
2024-06-08 16:53:08 +08:00
|
|
|
|
{
|
2024-06-20 14:05:35 +08:00
|
|
|
|
$dateRange = $this->request->get('date');
|
|
|
|
|
// 拆分日期范围
|
|
|
|
|
list($startDate, $endDate) = explode('-', $dateRange);
|
|
|
|
|
$startTime = str_replace('/', '-', $startDate);
|
|
|
|
|
$endTime = str_replace('/', '-', $endDate);
|
|
|
|
|
if (empty($startTime)) { //如果没有传开始时间,则默认获取最近7天的数据
|
|
|
|
|
$startTime = strtotime(date('Y-m-d'));
|
|
|
|
|
$endTime = $startTime + 86400;
|
|
|
|
|
}
|
|
|
|
|
$where = [
|
|
|
|
|
['create_time', 'between', [$startTime, $endTime]],
|
|
|
|
|
['store_id','=',$this->request->adminInfo['store_id']]
|
|
|
|
|
];
|
|
|
|
|
$data = \app\admin\logic\WorkbenchLogic::get_basic($where);
|
|
|
|
|
return $this->data($data);
|
2024-06-08 16:53:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-14 15:53:47 +08:00
|
|
|
|
// #[
|
|
|
|
|
// ApiDoc\Title('商品统计-图表'),
|
|
|
|
|
// ApiDoc\url('/store/workbench/get_trend'),
|
|
|
|
|
// ApiDoc\Method('GET'),
|
|
|
|
|
// ApiDoc\NotHeaders(),
|
|
|
|
|
// ApiDoc\Author('中国队长'),
|
|
|
|
|
// ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'),
|
|
|
|
|
// ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'),
|
|
|
|
|
// ApiDoc\Header(ref: [Definitions::class, "token"]),
|
|
|
|
|
// ApiDoc\ResponseSuccess("data", type: "array"),
|
|
|
|
|
// ]
|
2024-06-20 14:41:04 +08:00
|
|
|
|
public function get_trend()
|
2024-06-08 16:53:08 +08:00
|
|
|
|
{
|
2024-06-20 14:41:04 +08:00
|
|
|
|
// $params = $this->request->get();
|
|
|
|
|
$store_id = $this->request->adminInfo['store_id'];
|
|
|
|
|
$workbench = WorkbenchLogic::get_trend($store_id);
|
|
|
|
|
return $this->data($workbench);
|
2024-06-08 16:53:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-14 15:53:47 +08:00
|
|
|
|
// #[
|
|
|
|
|
// ApiDoc\Title('商品统计-排行'),
|
|
|
|
|
// ApiDoc\url('/store/workbench/get_product_ranking'),
|
|
|
|
|
// ApiDoc\Method('GET'),
|
|
|
|
|
// ApiDoc\NotHeaders(),
|
|
|
|
|
// ApiDoc\Author('中国队长'),
|
|
|
|
|
// ApiDoc\Query(name: 'start_time', type: 'string', require: true, desc: '开始时间'),
|
|
|
|
|
// ApiDoc\Query(name: 'end_time', type: 'string', require: true, desc: '结束时间'),
|
|
|
|
|
// ApiDoc\Header(ref: [Definitions::class, "token"]),
|
|
|
|
|
// ApiDoc\ResponseSuccess("data", type: "array"),
|
|
|
|
|
// ]
|
2024-06-20 14:41:04 +08:00
|
|
|
|
public function get_product_ranking()
|
2024-06-08 16:53:08 +08:00
|
|
|
|
{
|
2024-06-20 14:41:04 +08:00
|
|
|
|
$dateRange = $this->request->get('date');
|
2024-06-21 16:21:00 +08:00
|
|
|
|
$workbench = WorkbenchLogic::get_product_ranking(['create_time'=>$dateRange],$this->request->adminInfo['store_id']);
|
2024-06-20 14:41:04 +08:00
|
|
|
|
return $this->data($workbench);
|
2024-06-08 16:53:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-13 17:25:39 +08:00
|
|
|
|
|
2024-06-14 15:53:47 +08:00
|
|
|
|
// #[
|
|
|
|
|
// ApiDoc\Title('收银台数据统计'),
|
|
|
|
|
// ApiDoc\url('/store/workbench/business_statistics'),
|
|
|
|
|
// ApiDoc\Method('GET'),
|
|
|
|
|
// ApiDoc\NotHeaders(),
|
|
|
|
|
// ApiDoc\Author('中国队长'),
|
|
|
|
|
// ApiDoc\Query(),
|
|
|
|
|
// ApiDoc\Header(ref: [Definitions::class, "token"]),
|
|
|
|
|
// ApiDoc\ResponseSuccess("data", type: "array"),
|
|
|
|
|
// ]
|
2024-06-13 17:25:39 +08:00
|
|
|
|
public function business_statistics()
|
|
|
|
|
{
|
|
|
|
|
$params = $this->request->get();
|
|
|
|
|
$params['store_id'] = $this->request->adminInfo['store_id'];
|
|
|
|
|
$result = WorkbenchLogic::revenueStatistics($params);
|
|
|
|
|
return $this->data($result);
|
|
|
|
|
}
|
2024-06-17 15:50:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function recharge_statistics()
|
|
|
|
|
{
|
|
|
|
|
$params['store_id'] = DictType::where('type','store')->value('remark')??5;
|
|
|
|
|
$result = WorkbenchLogic::rechargeData($params);
|
|
|
|
|
return $this->data($result);
|
|
|
|
|
|
|
|
|
|
}
|
2024-06-01 16:07:53 +08:00
|
|
|
|
}
|