添加退款订单
This commit is contained in:
parent
a648821407
commit
2cb062c39b
@ -95,6 +95,10 @@ class OrderEnum
|
|||||||
const SUPPLIER = 3;
|
const SUPPLIER = 3;
|
||||||
const SYSTEM = 4;
|
const SYSTEM = 4;
|
||||||
|
|
||||||
|
const REFUND_STATUS_NO = 0;
|
||||||
|
const REFUND_STATUS_YES = 1;
|
||||||
|
const REFUND_STATUS_FINISH = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 获取支付类型
|
* @notes 获取支付类型
|
||||||
* @param bool $value
|
* @param bool $value
|
||||||
@ -140,4 +144,39 @@ class OrderEnum
|
|||||||
}
|
}
|
||||||
return $data[$value] ?? '';
|
return $data[$value] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取订单状态类型
|
||||||
|
*/
|
||||||
|
public static function refundStatus($value = true)
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
self::REFUND_STATUS_NO => '未退款',
|
||||||
|
self::REFUND_STATUS_YES => '退款中',
|
||||||
|
self::REFUND_STATUS_FINISH => '已退款',
|
||||||
|
];
|
||||||
|
if ($value === true) {
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
return $data[$value] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取订单状态类型
|
||||||
|
*/
|
||||||
|
public static function refundType($value = true)
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
1 => '仅退款',
|
||||||
|
2 => '退款退货',
|
||||||
|
3 => '拒绝退款',
|
||||||
|
4 => '商品待退货',
|
||||||
|
5 => '退货待收货',
|
||||||
|
6 => '已退款',
|
||||||
|
];
|
||||||
|
if ($value === true) {
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
return $data[$value] ?? '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
88
app/common/lists/order/StoreRefundOrderLists.php
Normal file
88
app/common/lists/order/StoreRefundOrderLists.php
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\lists\order;
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\enum\OrderEnum;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\store_order\StoreOrder;
|
||||||
|
|
||||||
|
class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/05/31 16:02
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'=' => ['order_id', 'refund_type'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取订单列表列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/05/31 16:02
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
return StoreOrder::with(['user', 'staff', 'product' => function ($query) {
|
||||||
|
$query->field(['id', 'oid', 'product_id', 'cart_info']);
|
||||||
|
}])
|
||||||
|
->where($this->searchWhere)
|
||||||
|
->where('refund_status', '>', 0)
|
||||||
|
->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('refund_reason_time', '>=', $this->params['start_time']);
|
||||||
|
})
|
||||||
|
->when(!empty($this->params['end_time']), function ($query) {
|
||||||
|
$query->whereTime('refund_reason_time', '<=', $this->params['end_time']);
|
||||||
|
})
|
||||||
|
->field(['id', 'store_id', 'staff_id', 'order_id', 'pay_price', 'pay_time', 'pay_type', 'status', 'uid', 'refund_status', 'refund_type', 'refund_reason_wap', 'refund_reason_time', 'refund_reason_wap_explain', 'refund_reason_wap_img'])
|
||||||
|
->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['refund_status_name'] = OrderEnum::refundStatus($item['refund_status']) ?? '';
|
||||||
|
$item['refund_type_name'] = OrderEnum::refundType($item['refund_type']) ?? '';
|
||||||
|
return $item;
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取订单列表数量
|
||||||
|
* @return int
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/05/31 16:02
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return StoreOrder::where($this->searchWhere)
|
||||||
|
->where('refund_status', '>', 0)
|
||||||
|
->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('refund_reason_time', '>=', $this->params['start_time']);
|
||||||
|
})
|
||||||
|
->when(!empty($this->params['end_time']), function ($query) {
|
||||||
|
$query->whereTime('refund_reason_time', '<=', $this->params['end_time']);
|
||||||
|
})
|
||||||
|
->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -126,6 +126,8 @@ class StoreOrderLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
$order['pay_time'] = $order['pay_time'] > 0 ? date('Y-m-d H:i:s', $order['pay_time']) : '';
|
$order['pay_time'] = $order['pay_time'] > 0 ? date('Y-m-d H:i:s', $order['pay_time']) : '';
|
||||||
$order['status_name'] = OrderEnum::getOrderType($order['status']) ?? '';
|
$order['status_name'] = OrderEnum::getOrderType($order['status']) ?? '';
|
||||||
|
$order['refund_status_name'] = OrderEnum::refundStatus($order['refund_status']) ?? '';
|
||||||
|
$order['refund_type_name'] = OrderEnum::refundType($order['refund_type']) ?? '';
|
||||||
return $order->toArray();
|
return $order->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,98 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\store\controller\store_order;
|
||||||
|
|
||||||
|
use app\common\controller\Definitions;
|
||||||
|
use app\common\lists\order\StoreRefundOrderLists;
|
||||||
|
use app\store\controller\BaseAdminController;
|
||||||
|
use app\common\logic\store_order\StoreOrderLogic;
|
||||||
|
use app\store\validate\store_order\StoreOrderValidate;
|
||||||
|
use hg\apidoc\annotation as ApiDoc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单列表控制器
|
||||||
|
* Class StoreOrderController
|
||||||
|
* @package app\store\controller\store_order
|
||||||
|
*/
|
||||||
|
#[ApiDoc\title('退款订单')]
|
||||||
|
class StoreRefundOrderController extends BaseAdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
#[
|
||||||
|
ApiDoc\Title('订单列表'),
|
||||||
|
ApiDoc\url('/store/store_order/storeRefundOrder/lists'),
|
||||||
|
ApiDoc\Method('GET'),
|
||||||
|
ApiDoc\NotHeaders(),
|
||||||
|
ApiDoc\Author('中国队长'),
|
||||||
|
ApiDoc\Query(name: 'order_id', type: 'string', require: false, desc: '订单编号'),
|
||||||
|
ApiDoc\Query(name: 'start_time', type: 'string', require: false, desc: '开始时间', mock: "@datetime('yyyy-MM-dd')"),
|
||||||
|
ApiDoc\Query(name: 'end_time', type: 'string', require: false, desc: '结束时间', mock: "@datetime('yyyy-MM-dd')"),
|
||||||
|
ApiDoc\Query(name: 'refund_type', type: 'int', require: false, desc: '状态:1仅退款,2退款退货,3拒绝退款,4商品待退货,5退货待收货,6已退款', mock: "@integer(1, 6)"),
|
||||||
|
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' => 'order_id', 'desc' => '订单编号', 'type' => 'string'],
|
||||||
|
['name' => 'pay_price', 'desc' => '支付金额', 'type' => 'string'],
|
||||||
|
['name' => 'pay_time', 'desc' => '支付时间', 'type' => 'float'],
|
||||||
|
['name' => 'pay_type', 'desc' => '支付方式', 'type' => 'float'],
|
||||||
|
['name' => 'status_name', 'desc' => '状态', 'type' => 'int'],
|
||||||
|
['name' => 'refund_status_name', 'desc' => '退款状态', 'type' => 'string'],
|
||||||
|
['name' => 'refund_type_name', 'desc' => '退款类型', 'type' => 'string'],
|
||||||
|
['name' => 'refund_reason_time', '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()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new StoreRefundOrderLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[
|
||||||
|
ApiDoc\Title('编辑订单'),
|
||||||
|
ApiDoc\url('/store/store_order/storeRefundOrder/edit'),
|
||||||
|
ApiDoc\Method('POST'),
|
||||||
|
ApiDoc\NotHeaders(),
|
||||||
|
ApiDoc\Author('中国队长'),
|
||||||
|
ApiDoc\Header(ref: [Definitions::class, "token"]),
|
||||||
|
ApiDoc\ResponseSuccess("data", type: "array"),
|
||||||
|
]
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$params = (new StoreOrderValidate())->post()->goCheck('edit');
|
||||||
|
$result = StoreOrderLogic::edit($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(StoreOrderLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[
|
||||||
|
ApiDoc\Title('订单详情'),
|
||||||
|
ApiDoc\url('/store/store_order/storeRefundOrder/detail'),
|
||||||
|
ApiDoc\Method('GET'),
|
||||||
|
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(StoreOrderLogic $orderLogic)
|
||||||
|
{
|
||||||
|
$params = (new StoreOrderValidate())->goCheck('detail');
|
||||||
|
$result = $orderLogic->detail($params);
|
||||||
|
return $this->data($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user