修改订单列表
This commit is contained in:
parent
de3d6658d8
commit
a3e73c3e37
@ -28,7 +28,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['order_id', 'pay_type'],
|
||||
'=' => ['order_id', 'pay_type', 'status'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -44,13 +44,19 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return StoreOrder::with(['user', 'product' => function ($query) {
|
||||
return StoreOrder::with(['user', 'staff', 'product' => function ($query) {
|
||||
$query->field(['id', 'oid', 'product_id', 'cart_info']);
|
||||
}])->where($this->searchWhere)
|
||||
->when(!empty($this->params['start_time']), function ($query) {
|
||||
$query->whereTime('create_time', '>=', $this->params['start_time']);
|
||||
})
|
||||
->when(!empty($this->params['end_time']), function ($query) {
|
||||
$query->whereTime('create_time', '<=', $this->params['end_time']);
|
||||
})
|
||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||
$query->where('store_id', '=', $this->request->adminInfo['store_id']);
|
||||
})
|
||||
->field(['id', 'order_id', 'pay_price', 'pay_time', 'pay_type', 'status', 'uid'])
|
||||
->field(['id', 'store_id', 'staff_id', 'order_id', 'pay_price', 'pay_time', 'pay_type', 'status', 'uid'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($item){
|
||||
@ -76,6 +82,12 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||
$query->where('store_id', '=', $this->request->adminInfo['store_id']);
|
||||
})
|
||||
->when(!empty($this->params['start_time']), function ($query) {
|
||||
$query->whereTime('create_time', '>=', $this->params['start_time']);
|
||||
})
|
||||
->when(!empty($this->params['end_time']), function ($query) {
|
||||
$query->whereTime('create_time', '<=', $this->params['end_time']);
|
||||
})
|
||||
->count();
|
||||
}
|
||||
|
||||
|
15
app/common/logic/SystemStoreStaffLogic.php
Normal file
15
app/common/logic/SystemStoreStaffLogic.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\model\system_store\SystemStoreStaff;
|
||||
|
||||
class SystemStoreStaffLogic extends BaseLogic
|
||||
{
|
||||
|
||||
public function listByWhere($where, $field = '*')
|
||||
{
|
||||
return SystemStoreStaff::where($where)->field($field)->select()->toArray();
|
||||
}
|
||||
|
||||
}
|
@ -107,4 +107,10 @@ class StoreOrderLogic extends BaseLogic
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function storeOrderCount($storeId, $status)
|
||||
{
|
||||
return StoreOrder::where(['store_id' => $storeId, 'status' => $status, 'paid' => 1])->count();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ use app\common\enum\PayEnum;
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\system_store\SystemStoreStaff;
|
||||
use app\common\model\user\User;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
@ -50,4 +51,9 @@ class StoreOrder extends BaseModel
|
||||
return $this->hasMany(StoreOrderCartInfo::class, 'oid', 'id');
|
||||
}
|
||||
|
||||
public function staff()
|
||||
{
|
||||
return $this->hasOne(SystemStoreStaff::class, 'id', 'staff_id')->bind(['staff_name']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,10 @@ namespace app\store\controller\store_order;
|
||||
|
||||
use app\admin\lists\store_order\StoreOrderLists;
|
||||
use app\common\controller\Definitions;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\logic\SystemStoreStaffLogic;
|
||||
use app\store\controller\BaseAdminController;
|
||||
use app\store\logic\store_order\StoreOrderLogic;
|
||||
use app\common\logic\store_order\StoreOrderLogic;
|
||||
use app\store\validate\store_order\StoreOrderValidate;
|
||||
use hg\apidoc\annotation as ApiDoc;
|
||||
|
||||
@ -26,22 +28,31 @@ class StoreOrderController extends BaseAdminController
|
||||
ApiDoc\Method('GET'),
|
||||
ApiDoc\NotHeaders(),
|
||||
ApiDoc\Author('中国队长'),
|
||||
ApiDoc\Query(name: 'order_id', type: 'int', require: false, desc: '分类id'),
|
||||
ApiDoc\Query(name: 'pay_type', type: 'string', require: false, desc: '商品名称'),
|
||||
ApiDoc\Query(name: 'status', type: 'int', require: false, desc: '状态:1上架,2下架,3售罄,4库存告警'),
|
||||
ApiDoc\Query(name: 'order_id', type: 'string', require: false, desc: '订单编号'),
|
||||
ApiDoc\Query(name: 'pay_type', type: 'int', require: false, desc: '支付方式'),
|
||||
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\Header(ref: [Definitions::class, "token"]),
|
||||
ApiDoc\Query(ref: [Definitions::class, "page"]),
|
||||
ApiDoc\ResponseSuccess("data", type: "array", children: [
|
||||
['name' => 'id', 'desc' => 'ID', 'type' => 'int'],
|
||||
['name' => 'image', 'desc' => '图片', 'type' => 'string'],
|
||||
['name' => 'store_name', 'desc' => '商品名称', 'type' => 'string'],
|
||||
['name' => 'price', 'desc' => '零售价', 'type' => 'float'],
|
||||
['name' => 'cost', 'desc' => '成本价', 'type' => 'float'],
|
||||
['name' => 'sales', 'desc' => '销量', 'type' => 'int'],
|
||||
['name' => 'stock', 'desc' => '库存', 'type' => 'int'],
|
||||
['name' => 'unit_name', 'desc' => '单位', 'type' => 'string'],
|
||||
['name' => 'cate_name', 'desc' => '分类', 'type' => 'string'],
|
||||
['name' => 'status', 'desc' => '状态:1上架,0下架', 'type' => 'string'],
|
||||
['name' => 'order_id', 'desc' => '订单编号', 'type' => 'string'],
|
||||
['name' => 'pay_price', 'desc' => '支付金额', 'type' => 'string'],
|
||||
['name' => 'pay_time', 'desc' => '支付时间', 'type' => 'float'],
|
||||
['name' => 'pay_type_name', 'desc' => '支付方式', 'type' => 'float'],
|
||||
['name' => 'status_name', 'desc' => '状态', 'type' => 'int'],
|
||||
['name' => 'staff_name', 'desc' => '店员', 'type' => 'int'],
|
||||
['name' => 'nickname', 'desc' => '用户昵称', 'type' => 'string'],
|
||||
['name' => 'avatar', 'desc' => '用户头像', 'type' => 'string'],
|
||||
['name' => 'product', 'desc' => '商品信息', 'type' => 'array', 'children' => [
|
||||
['name' => 'cart_info', 'desc' => '商品信息', 'type' => 'array', 'children' => [
|
||||
['name' => 'name', 'desc' => '商品名称', 'type' => 'int'],
|
||||
['name' => 'image', 'desc' => '图片', 'type' => 'string'],
|
||||
['name' => 'cart_num', 'desc' => '购买数量', 'type' => 'string'],
|
||||
['name' => 'price', 'desc' => '单价', 'type' => 'string'],
|
||||
]],
|
||||
]],
|
||||
]),
|
||||
]
|
||||
public function lists()
|
||||
@ -49,6 +60,28 @@ class StoreOrderController extends BaseAdminController
|
||||
return $this->dataLists(new StoreOrderLists());
|
||||
}
|
||||
|
||||
#[
|
||||
ApiDoc\Title('订单统计'),
|
||||
ApiDoc\url('/store/store_order/storeOrder/title'),
|
||||
ApiDoc\Method('GET'),
|
||||
ApiDoc\NotHeaders(),
|
||||
ApiDoc\Author('中国队长'),
|
||||
ApiDoc\Header(ref: [Definitions::class, "token"]),
|
||||
ApiDoc\ResponseSuccess("data", type: "array"),
|
||||
]
|
||||
public function title(SystemStoreStaffLogic $staffLogic, StoreOrderLogic $orderLogic)
|
||||
{
|
||||
return $this->data([
|
||||
'staff' => $staffLogic->listByWhere(['store_id' => $this->request->adminInfo['store_id'], 'status' => 1], 'id,staff_name'),
|
||||
'pay_type' => PayEnum::getPaySceneDesc(),
|
||||
'order_status' => [
|
||||
'wait_send' => $orderLogic->storeOrderCount($this->request->adminInfo['store_id'], 0),
|
||||
'wait_receive' => $orderLogic->storeOrderCount($this->request->adminInfo['store_id'], 1),
|
||||
'finish' => $orderLogic->storeOrderCount($this->request->adminInfo['store_id'], 2),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
#[
|
||||
ApiDoc\Title('添加订单'),
|
||||
ApiDoc\url('/store/store_order/storeOrder/add'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user