修改订单详情
This commit is contained in:
parent
337873c199
commit
d1c52d222a
@ -28,7 +28,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['order_id', 'pay_type', 'status'],
|
||||
'=' => ['order_id', 'pay_type', 'status', 'staff_id'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -60,7 +60,6 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
$item['pay_type_name']=PayEnum::getPaySceneDesc($item['pay_type']);
|
||||
$item['pay_time'] = $item['pay_time'] > 0 ? date('Y-m-d H:i:s', $item['pay_time']) : '';
|
||||
$item['status_name'] = OrderEnum::getOrderType($item['status']) ?? '';
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic\store_order;
|
||||
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\model\order\Cart;
|
||||
@ -14,6 +16,7 @@ use think\facade\Db;
|
||||
class StoreOrderLogic extends BaseLogic
|
||||
{
|
||||
public static $total;
|
||||
|
||||
/**
|
||||
* @notes 获取购物车商品信息
|
||||
* @param $params
|
||||
@ -108,6 +111,31 @@ class StoreOrderLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
* @param $params
|
||||
* @return array
|
||||
*/
|
||||
public function detail($params)
|
||||
{
|
||||
$order = StoreOrder::with(['user', 'staff', 'product' => function ($query) {
|
||||
$query->field(['id', 'oid', 'product_id', 'cart_info']);
|
||||
}])->where($params)->find();
|
||||
if (empty($order)) {
|
||||
throw new \Exception('订单不存在');
|
||||
}
|
||||
$order['pay_time'] = $order['pay_time'] > 0 ? date('Y-m-d H:i:s', $order['pay_time']) : '';
|
||||
$order['status_name'] = OrderEnum::getOrderType($order['status']) ?? '';
|
||||
return $order->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单统计
|
||||
* @param $storeId
|
||||
* @param $status
|
||||
* @return int|\think\db\Query
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function storeOrderCount($storeId, $status)
|
||||
{
|
||||
return StoreOrder::where(['store_id' => $storeId, 'status' => $status, 'paid' => 1])->count();
|
||||
|
@ -43,7 +43,7 @@ class StoreOrder extends BaseModel
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->hasOne(User::class, 'id', 'uid')->bind(['nickname', 'avatar']);
|
||||
return $this->hasOne(User::class, 'id', 'uid')->bind(['nickname', 'avatar', 'mobile']);
|
||||
}
|
||||
|
||||
public function product()
|
||||
|
@ -7,6 +7,7 @@ use app\admin\lists\store_order\StoreOrderLists;
|
||||
use app\common\controller\Definitions;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\logic\SystemStoreStaffLogic;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\store\controller\BaseAdminController;
|
||||
use app\common\logic\store_order\StoreOrderLogic;
|
||||
use app\store\validate\store_order\StoreOrderValidate;
|
||||
@ -29,6 +30,7 @@ class StoreOrderController extends BaseAdminController
|
||||
ApiDoc\NotHeaders(),
|
||||
ApiDoc\Author('中国队长'),
|
||||
ApiDoc\Query(name: 'order_id', type: 'string', require: false, desc: '订单编号'),
|
||||
ApiDoc\Query(name: 'staff_id', type: 'int', require: false, desc: '店员id'),
|
||||
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: '结束时间'),
|
||||
@ -40,7 +42,7 @@ class StoreOrderController extends BaseAdminController
|
||||
['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' => 'pay_type', 'desc' => '支付方式', 'type' => 'float'],
|
||||
['name' => 'status_name', 'desc' => '状态', 'type' => 'int'],
|
||||
['name' => 'staff_name', 'desc' => '店员', 'type' => 'int'],
|
||||
['name' => 'nickname', 'desc' => '用户昵称', 'type' => 'string'],
|
||||
@ -120,22 +122,6 @@ class StoreOrderController extends BaseAdminController
|
||||
return $this->fail(StoreOrderLogic::getError());
|
||||
}
|
||||
|
||||
#[
|
||||
ApiDoc\Title('删除订单'),
|
||||
ApiDoc\url('/store/store_order/storeOrder/delete'),
|
||||
ApiDoc\Method('POST'),
|
||||
ApiDoc\NotHeaders(),
|
||||
ApiDoc\Author('中国队长'),
|
||||
ApiDoc\Header(ref: [Definitions::class, "token"]),
|
||||
ApiDoc\ResponseSuccess("data", type: "array"),
|
||||
]
|
||||
public function delete()
|
||||
{
|
||||
$params = (new StoreOrderValidate())->post()->goCheck('delete');
|
||||
StoreOrderLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
#[
|
||||
ApiDoc\Title('订单详情'),
|
||||
ApiDoc\url('/store/store_order/storeOrder/detail'),
|
||||
@ -143,12 +129,13 @@ class StoreOrderController extends BaseAdminController
|
||||
ApiDoc\NotHeaders(),
|
||||
ApiDoc\Author('中国队长'),
|
||||
ApiDoc\Header(ref: [Definitions::class, "token"]),
|
||||
ApiDoc\Query(name: 'id', type: 'int', require: true, desc: '订单id'),
|
||||
ApiDoc\ResponseSuccess("data", type: "array"),
|
||||
]
|
||||
public function detail()
|
||||
public function detail(StoreOrderLogic $orderLogic)
|
||||
{
|
||||
$params = (new StoreOrderValidate())->goCheck('detail');
|
||||
$result = StoreOrderLogic::detail($params);
|
||||
$result = $orderLogic->detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user