From 04be17ab2b0ffae6952d004f2e3e2b646a65601d Mon Sep 17 00:00:00 2001 From: shengchanzhe <179998674@qq.com> Date: Fri, 15 Dec 2023 19:00:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=94=B6=E8=8E=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/order/StoreOtherOrderRepository.php | 112 ++---------------- 1 file changed, 8 insertions(+), 104 deletions(-) diff --git a/app/common/repositories/store/order/StoreOtherOrderRepository.php b/app/common/repositories/store/order/StoreOtherOrderRepository.php index 2f0be4e8..7e366774 100644 --- a/app/common/repositories/store/order/StoreOtherOrderRepository.php +++ b/app/common/repositories/store/order/StoreOtherOrderRepository.php @@ -16,6 +16,7 @@ use app\common\dao\store\order\StoreOrderOtherDao; use app\common\model\store\order\StoreGroupOrderOther; use app\common\model\store\order\StoreOtherOrder; use app\common\model\store\order\StoreOrderInterestOther; +use app\common\model\store\order\StoreOrderOther; use app\common\model\store\order\StoreOtherOrderInterest; use app\common\model\store\order\StoreRefundOrder; use app\common\model\store\product\PurchaseRecord; @@ -680,15 +681,12 @@ class StoreOtherOrderRepository extends BaseRepository * @author xaboy * @day 2020/8/3 */ - public function takeAfter(StoreOrder $order, ?User $user) + public function takeAfter(StoreOrderOther $order, ?User $user) { Db::transaction(function () use ($user, $order) { - if ($user && $order->pay_type != StoreGroupOrder::PAY_TYPE_CREDIT_BUY) $this->computed($order, $user); Queue::push(SendSmsJob::class, ['tempId' => 'ORDER_TAKE_SUCCESS', 'id' => $order->order_id]); Queue::push(SendSmsJob::class, ['tempId' => 'ADMIN_TAKE_DELIVERY_CODE', 'id' => $order->order_id]); - if ($order->pay_type != StoreGroupOrder::PAY_TYPE_CREDIT_BUY) { - app()->make(MerchantRepository::class)->computedLockMoney($order); - } + if (!empty($order->interest) && $order->interest->status == StoreOrderInterestOther::STATUS_UNSETTLED) { $order->interest->start_time = date('Y-m-d H:i:s', strtotime("+{$order->interest->settle_cycle} days")); $order->interest->save(); @@ -724,7 +722,7 @@ class StoreOtherOrderRepository extends BaseRepository // } $order->status = 2; $order->verify_time = date('Y-m-d H:i:s'); - event('order.take.before', compact('order')); + // event('order.take.before', compact('order')); //订单记录 $storeOrderStatusRepository = app()->make(StoreOrderStatusOtherRepository::class); $orderStatus = [ @@ -1779,74 +1777,7 @@ class StoreOtherOrderRepository extends BaseRepository return $count - $count_ - $count__; } - /** - * 根据订单id查看是否全部退款 - * @Author:Qinii - * @Date: 2020/9/11 - * @param int $orderId - * @return bool - */ - public function checkRefundStatusById(int $orderId, int $refundId) - { - return Db::transaction(function () use ($orderId, $refundId) { - $res = $this->dao->search(['order_id' => $orderId])->with(['orderProduct'])->find(); - $refund = app()->make(StoreRefundOrderRepository::class)->getRefundCount($orderId, $refundId); - if ($refund) return false; - foreach ($res['orderProduct'] as $item) { - if ($item['refund_num'] !== 0) return false; - $item->is_refund = 3; - $item->save(); - } - $res->status = -1; - $res->save(); - $this->orderRefundAllAfter($res); - return true; - }); - } - - public function orderRefundAllAfter($order) - { - - if ($order->activity_type == 10) { - app()->make(StoreDiscountRepository::class)->incStock($order->orderProduct[0]['activity_id']); - } - $mainId = $order->main_id ?: $order->order_id; - $count = $this->query([])->where('status', '<>', -1)->where(function ($query) use ($mainId) { - $query->where('order_id', $mainId)->whereOr('main_id', $mainId); - })->count(); - //拆单后完全退完 - if (!$count) { - if ($order->main_id) { - $order = $this->query(['order_id' => $mainId])->find(); - } - $couponId = []; - if ($order->coupon_id) { - $couponId = explode(',', $order->coupon_id); - } - app()->make(MerchantRepository::class)->computedLockMoney($order); - //总单所有订单全部退完 - if (!$this->query([])->where('status', '<>', -1)->where('group_order_id', $order->group_order_id)->count()) { - if ($order->groupOrder->coupon_id) { - $couponId[] = $order->groupOrder->coupon_id; - } - } - if (count($couponId)) { - app()->make(StoreCouponUserRepository::class)->updates($couponId, ['status' => 0]); - } - } - //订单记录 - $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_REFUND_ALL, - ]; - $storeOrderStatusRepository->createSysLog($orderStatus); - - event('order.refundAll', compact('order')); - } + /** * @param $id @@ -2055,11 +1986,11 @@ class StoreOtherOrderRepository extends BaseRepository Db::startTrans(); try { $groupOrder = $groupOrderRepository->get($id); - if ($groupOrder->pay_type != StoreGroupOrder::PAY_TYPE_CREDIT_BUY) { + if ($groupOrder->pay_type != StoreGroupOrderOther::PAY_TYPE_CREDIT_BUY) { throw new Exception('订单类型错误'); } $order = $groupOrder->orderList[0]; - if ($order->status != StoreOrder::STATUS_WAIT_CONFIRM) { + if ($order->status != StoreOrderOther::STATUS_WAIT_CONFIRM) { throw new Exception('订单状态错误'); } if ($type == 2) { @@ -2076,7 +2007,7 @@ class StoreOtherOrderRepository extends BaseRepository $order->verify_code = $this->verifyCode(); } } - $order->status = StoreOtherOrder::STATUS_WAIT_PAY; + $order->status = StoreOrderOther::STATUS_WAIT_PAY; $groupOrder->paid = 1; $groupOrder->pay_time = date('Y-m-d H:i:s'); $order->paid = 1; @@ -2090,31 +2021,4 @@ class StoreOtherOrderRepository extends BaseRepository throw new Exception($e->getMessage()); } } - /** - * @param $orderId - * @param $orderSn - * 更新扫描发货状态 - */ - public function deliveryGoods($orderId, $orderSn, $logisticsCode = '') - { - if ($logisticsCode) { - $order = $this->dao->search([], null)->where('order_sn', $orderSn)->where('order_id', $orderId)->where('logistics_code', $logisticsCode)->where('StoreOrderOther.status', 1)->where('StoreOrderOther.is_del', 0)->find(); - } else { - $order = $this->dao->search([], null)->where('order_sn', $orderSn)->where('order_id', $orderId)->where('StoreOrderOther.status', 0)->where('StoreOrderOther.is_del', 0)->find(); - } - if (!$order) - throw new ValidateException('订单不存在或编码code错误'); - if ($order['order_type']) - throw new ValidateException('订单类型错误'); - - if ($logisticsCode) { - $order->status = 2; - $order->mark = '快递员已完成送货'; - } else { - $order->status = 1; - $order->mark = '快递员已扫描取件'; - event('product.delivery', compact('order')); - } - $order->save(); - } }