From 06bdfacbe567007c724d3fb1ac880089c7610fd2 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Sat, 8 Jun 2024 09:43:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=94=AE=E5=90=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/OrderController.php | 52 ++++++++++++++++++++ app/api/logic/order/OrderLogic.php | 13 +++++ app/common/enum/OrderEnum.php | 10 ++++ 3 files changed, 75 insertions(+) diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index 431c3568..fc7a1bf7 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -7,8 +7,10 @@ use app\api\controller\BaseApiController; use app\api\lists\order\OrderList; use app\api\validate\OrderValidate; use app\common\enum\PayEnum; +use app\common\enum\YesNoEnum; use app\common\logic\PaymentLogic; use app\common\logic\PayNotifyLogic; +use app\common\model\dict\DictData; use app\common\model\store_order\StoreOrder; use app\common\model\system_store\SystemStoreStaff; use app\common\model\user\UserAddress; @@ -18,6 +20,7 @@ use hg\apidoc\annotation as ApiDoc; #[ApiDoc\title('订单')] class OrderController extends BaseApiController { + public $notNeedLogin = ['refund_reason']; /** * 订单列表 @@ -350,6 +353,15 @@ class OrderController extends BaseApiController return $this->fail('支付失败'); } + + #[ + ApiDoc\Title('订单详情'), + ApiDoc\url('/api/order/order/detail'), + ApiDoc\Method('GET'), + ApiDoc\Param(name: "order_id", type: "int", require: true, desc: "订单id"), + ApiDoc\NotHeaders(), + ApiDoc\ResponseSuccess("data", type: "array"), + ] public function detail() { $order_id = (int)$this->request->get('order_id'); @@ -496,6 +508,46 @@ class OrderController extends BaseApiController OrderLogic::dealRefund($uid,$params); return $this->success('申请成功'); } + + #[ + ApiDoc\Title('订单退款原因'), + ApiDoc\url('/api/order/order/refund_reason'), + ApiDoc\Method('GET'), + ApiDoc\Param(), + ApiDoc\NotHeaders(), + ApiDoc\ResponseSuccess("data", type: "array"), + ] + public function refund_reason() + { + return DictData::where('type_value','reason')->where('status',YesNoEnum::YES) + ->select()->toArray(); + + } + + + #[ + ApiDoc\Title('取消售后'), + ApiDoc\url('/api/order/order/cancel_sale'), + ApiDoc\Method('GET'), + ApiDoc\Param(name: "order_id", type: "int", require: true, desc: "订单id"), + ApiDoc\NotHeaders(), + ApiDoc\ResponseSuccess("data", type: "array"), + ] + public function cancel_sale() + { + $order_id = (int)$this->request->get('order_id'); + $where = [ + 'id' => $order_id, + 'uid' => $this->userId, + ]; + $order = OrderLogic::cancelSell($where); + if ($order) { + return $this->success(); + } else { + return $this->fail('取消失败'); + } + + } diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 42e288ea..259efe60 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -445,6 +445,19 @@ class OrderLogic extends BaseLogic return $find; } + //取消售后 + public static function cancelSell($where) + { + return StoreOrder::where($where)->update( + [ + 'refund_status'=>OrderEnum::CANCEL_SALE, + 'status'=>OrderEnum::CANCEL_ORDER, + ] + ); + + + } + //核销 diff --git a/app/common/enum/OrderEnum.php b/app/common/enum/OrderEnum.php index 1234e32e..747e3ae5 100644 --- a/app/common/enum/OrderEnum.php +++ b/app/common/enum/OrderEnum.php @@ -95,9 +95,19 @@ class OrderEnum const SUPPLIER = 3; const SYSTEM = 4; + + + /** + * 订单状态 + * @CANCEL_ORDER 取消售后 + */ + const CANCEL_ORDER = 5; + + //退款状态 const REFUND_STATUS_NO = 0; const REFUND_STATUS_YES = 1; const REFUND_STATUS_FINISH = 2; + const CANCEL_SALE = 3; /** * @notes 获取支付类型