修改订单列表查询
This commit is contained in:
parent
a1443d7a52
commit
128ad0cc1e
@ -60,19 +60,26 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
$query->where('store_id', '=', $this->request->adminInfo['store_id']);
|
||||
})
|
||||
->when(!empty($this->params['status']), function ($query) {
|
||||
$status = explode(',', $this->params['status']);
|
||||
$query->whereIn('status', $status);
|
||||
if ($this->params['status'] == -1) {
|
||||
$query->where('status', 0)->where('paid', 0);
|
||||
} else {
|
||||
$status = explode(',', $this->params['status']);
|
||||
$query->whereIn('status', $status);
|
||||
}
|
||||
})
|
||||
->field(['id', 'store_id', 'staff_id', 'order_id', 'pay_price', 'pay_time', 'pay_type', 'status', 'uid'])
|
||||
->field(['id', 'store_id', 'staff_id', 'order_id', 'paid', 'pay_price', 'pay_time', 'pay_type', 'status', 'uid'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
$item['pay_time'] = $item['pay_time'] > 0 ? date('Y-m-d H:i:s', $item['pay_time']) : '';
|
||||
$item['status_name'] = OrderEnum::getOrderType($item['status']) ?? '';
|
||||
for($i=0;$i<count($item['product'])&&$i<3;$i++){
|
||||
$find= StoreBranchProduct::where('id',$item['product'][$i]['product_id'])->field('store_name,image')->find();
|
||||
$item['product'][$i]['store_name']=$find['store_name'];
|
||||
$item['product'][$i]['image']=$find['image'];
|
||||
if ($item['paid'] == 0) {
|
||||
$item['status_name'] = '待支付';
|
||||
}
|
||||
for ($i = 0; $i < count($item['product']) && $i < 3; $i++) {
|
||||
$find = StoreBranchProduct::where('id', $item['product'][$i]['product_id'])->field('store_name,image')->find();
|
||||
$item['product'][$i]['store_name'] = $find['store_name'];
|
||||
$item['product'][$i]['image'] = $find['image'];
|
||||
}
|
||||
|
||||
return $item;
|
||||
@ -103,8 +110,12 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
$query->where('store_id', '=', $this->request->adminInfo['store_id']);
|
||||
})
|
||||
->when(!empty($this->params['status']), function ($query) {
|
||||
$status = explode(',', $this->params['status']);
|
||||
$query->whereIn('status', $status);
|
||||
if ($this->params['status'] == -1) {
|
||||
$query->where('status', 0)->where('paid', 0);
|
||||
} else {
|
||||
$status = explode(',', $this->params['status']);
|
||||
$query->whereIn('status', $status);
|
||||
}
|
||||
})
|
||||
->count();
|
||||
}
|
||||
|
@ -138,9 +138,9 @@ class StoreOrderLogic extends BaseLogic
|
||||
* @return int|\think\db\Query
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function storeOrderCount($storeId, $status)
|
||||
public function storeOrderCount($storeId, $status, $paid = 1)
|
||||
{
|
||||
return StoreOrder::where(['store_id' => $storeId, 'status' => $status])->count();
|
||||
return StoreOrder::where(['store_id' => $storeId, 'status' => $status, 'paid' => $paid])->count();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,39 +1,68 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\store\controller;
|
||||
|
||||
use app\common\controller\Definitions;
|
||||
use app\store\logic\WorkbenchLogic;
|
||||
use hg\apidoc\annotation as ApiDoc;
|
||||
#[ApiDoc\NotParse()]
|
||||
|
||||
/**
|
||||
* 工作台
|
||||
* Class WorkbenchCotroller
|
||||
* @package app\store\controller
|
||||
*/
|
||||
#[ApiDoc\Title('工作台')]
|
||||
class WorkbenchController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 工作台
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 17:01
|
||||
*/
|
||||
#[
|
||||
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"),
|
||||
]
|
||||
public function index()
|
||||
{
|
||||
$result = WorkbenchLogic::index();
|
||||
$params = $this->request->get();
|
||||
$params['store_id'] = $this->request->adminInfo['store_id'];
|
||||
$result = WorkbenchLogic::index($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
#[
|
||||
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"),
|
||||
]
|
||||
public function product()
|
||||
{
|
||||
$storeId = $this->request->adminInfo['store_id'];
|
||||
$result = WorkbenchLogic::index($storeId);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
#[
|
||||
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"),
|
||||
]
|
||||
public function delivery()
|
||||
{
|
||||
$storeId = $this->request->adminInfo['store_id'];
|
||||
$result = WorkbenchLogic::index($storeId);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class StoreOrderController extends BaseAdminController
|
||||
ApiDoc\Query(name: 'shipping_type', type: 'int', require: false, desc: '订单配送方式:1配送订单,2核销订单,3收银台订单'),
|
||||
ApiDoc\Query(name: 'start_time', type: 'string', require: false, desc: '开始时间'),
|
||||
ApiDoc\Query(name: 'end_time', type: 'string', require: false, desc: '结束时间'),
|
||||
ApiDoc\Query(name: 'status', type: 'int', require: false, desc: '状态:0待发货,1待收货,2已完成'),
|
||||
ApiDoc\Query(name: 'status', type: 'int', require: false, desc: '状态:-1待支付,0待发货,1待收货,2已完成'),
|
||||
ApiDoc\Header(ref: [Definitions::class, "token"]),
|
||||
ApiDoc\Query(ref: [Definitions::class, "page"]),
|
||||
ApiDoc\ResponseSuccess("data", type: "array", children: [
|
||||
@ -78,6 +78,7 @@ class StoreOrderController extends BaseAdminController
|
||||
'pay_type' => PayEnum::getPaySceneDesc(),
|
||||
'order_status' => [
|
||||
'wait_send' => $orderLogic->storeOrderCount($this->request->adminInfo['store_id'], 0),
|
||||
'to_be_paid' => $orderLogic->storeOrderCount($this->request->adminInfo['store_id'], 0, 0),
|
||||
'wait_receive' => $orderLogic->storeOrderCount($this->request->adminInfo['store_id'], 1),
|
||||
'finish' => $orderLogic->storeOrderCount($this->request->adminInfo['store_id'], 2),
|
||||
],
|
||||
|
@ -16,6 +16,8 @@ namespace app\store\logic;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\logic\store_order\StoreOrderLogic;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
|
||||
@ -34,20 +36,54 @@ class WorkbenchLogic extends BaseLogic
|
||||
* @author 乔峰
|
||||
* @date 2021/12/29 15:58
|
||||
*/
|
||||
public static function index()
|
||||
public static function index($params)
|
||||
{
|
||||
return [
|
||||
// 版本信息
|
||||
'version' => self::versionInfo(),
|
||||
// 今日数据
|
||||
'today' => self::today(),
|
||||
// 常用功能
|
||||
'menu' => self::menu(),
|
||||
// 近15日访客数
|
||||
'visitor' => self::visitor(),
|
||||
// 服务支持
|
||||
'support' => self::support()
|
||||
];
|
||||
$data = [];
|
||||
$orderLogic = new StoreOrderLogic();
|
||||
$data['order_amount'] = $orderLogic->storeOrderSumByWhere([
|
||||
'store_id' => $params['store_id'],
|
||||
'paid' => 1,
|
||||
]);
|
||||
$data['cashier_amount'] = $orderLogic->storeOrderSumByWhere([
|
||||
'store_id' => $params['store_id'],
|
||||
'paid' => 1,
|
||||
'shipping_type' => 3,
|
||||
]);
|
||||
$data['delivery_amount'] = $orderLogic->storeOrderSumByWhere([
|
||||
'store_id' => $params['store_id'],
|
||||
'paid' => 1,
|
||||
'shipping_type' => 1,
|
||||
]);
|
||||
$data['verify_amount'] = $orderLogic->storeOrderSumByWhere([
|
||||
'store_id' => $params['store_id'],
|
||||
'paid' => 1,
|
||||
'shipping_type' => 2,
|
||||
]);
|
||||
$startTime = $params['start_time'];
|
||||
$endTime = $params['end_time'];
|
||||
$days = (new \DateTime($endTime))->diff(new \DateTime($startTime))->days;
|
||||
$days += 1;
|
||||
if ($days == 1) {
|
||||
$group = 'HOUR(pay_time)';
|
||||
$timeRange = [0, 23];
|
||||
$endTime = date('Y-m-d H:i:s', strtotime($endTime) + 86400);
|
||||
$field = 'from_unixtime(pay_time,"%H") as pay_time,sum(pay_price) as pay_price';
|
||||
} elseif ($days <= 31) {
|
||||
$group = 'DAY(pay_time)';
|
||||
$timeRange = [1, $days];
|
||||
$field = 'from_unixtime(pay_time,"%m-%d") as pay_time,sum(pay_price) as pay_price';
|
||||
} else {
|
||||
$group = 'MONTH(pay_time)';
|
||||
$timeRange = [1, (int)date('n')];
|
||||
$field = 'from_unixtime(pay_time,"%Y-%m") as pay_time,sum(pay_price) as pay_price';
|
||||
}
|
||||
$data['order_list'] = StoreOrder::field($field)
|
||||
->where('store_id', $params['store_id'])
|
||||
->where('paid', 1)
|
||||
->whereBetweenTime('pay_time', $startTime, $endTime)
|
||||
->group($group)
|
||||
->select();
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user