From b7a242df930cb29de8fc7d982f1fd2fa81664dd4 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Thu, 10 Aug 2023 16:21:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=A2=E5=8D=95=E5=8F=91?= =?UTF-8?q?=E8=B4=A7=E7=8A=B6=E6=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/order/StoreOrderRepository.php | 38 +++++++++++++++++++ app/controller/api/Auth.php | 10 +++++ route/api.php | 1 + 3 files changed, 49 insertions(+) diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index cecfe251..b3203fac 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -785,6 +785,44 @@ class StoreOrderRepository extends BaseRepository event('order.take', compact('order')); } + /** + * @param $id + * @param User $user + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException + * @author xaboy + * @day 2020/6/17 + */ + public function takeGoods($id, $orderSn) + { + $order = $this->dao->search([], null)->where('order_sn', $orderSn)->where('order_id', $id)->where('StoreOrder.is_del', 0)->find(); + if (!$order) + throw new ValidateException('订单不存在'); + if ($order['status'] != 1 || $order['order_type']) + throw new ValidateException('订单状态有误'); + $func = 'createUserLog'; + $user = $order->user; + $order->status = 2; + $order->verify_time = date('Y-m-d H:i:s'); + event('order.take.before', compact('order')); + //订单记录 + $storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class); + $orderStatus = [ + 'order_id' => $order->order_id, + 'order_sn' => $order->order_sn, + 'type' => $storeOrderStatusRepository::TYPE_ORDER, + 'change_message' => '已收货', + 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_TAKE, + ]; + Db::transaction(function () use ($order, $user,$storeOrderStatusRepository,$orderStatus,$func) { + $this->takeAfter($order, $user); + $order->save(); + $storeOrderStatusRepository->{$func}($orderStatus); + }); + event('order.take', compact('order')); + } + /** * 获取订单列表头部统计数据 diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index a4adc669..a58ee5ad 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -72,6 +72,16 @@ class Auth extends BaseController return app('json')->success($logisticsInfo); } + public function takeGoods($id) + { + $orderSn = $this->request->param('order_sn'); + if (empty($orderSn)) { + return app('json')->fail('参数order_sn不能为空'); + } + app()->make(StoreOrderRepository::class)->takeGoods($id, $orderSn); + return app('json')->success('确认收货成功'); + } + public function test() { $type = $this->request->param('type'); diff --git a/route/api.php b/route/api.php index 2b799c24..095c57dc 100644 --- a/route/api.php +++ b/route/api.php @@ -22,6 +22,7 @@ use think\facade\Route; Route::group('api/', function () { Route::any('test', 'api.Auth/test'); Route::any('dotest', 'api.Auth/dotest'); + Route::post('goods/take/:id', 'api.Auth/takeGoods'); Route::resource('upload', 'api.Upload'); Route::post('articleCatch', 'api.Upload/article'); //强制登录