request->input('order_id'); $service = new FullRefundOrderService(); $service->orderId = $orderId; $service->reason = $this->request->input('reason',''); $service->type = RefundCode::FULL_GOOD_REFUND; $service->handle(); return $this->return->success(); }catch (Exception $e) { throw new ErrException($e->getMessage()); } } /** * @return array * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function refundPartial(): array { try { $orderId = (int)$this->request->input('order_id'); $orderGoodIds = $this->request->input('order_good_ids'); if (empty($orderGoodIds)) throw new ErrException('请选择商品再退款'); $service = new PartialRefundOrderService(); $service->orderId = $orderId; $service->reason = $this->request->input('reason',''); $service->orderGoodIds = $orderGoodIds; $service->type = RefundCode::PARTIAL_GOOD_REFUND; $service->handle(); return $this->return->success(); }catch (Exception $e) { throw new ErrException($e->getMessage()); } } use OrderChangeStatusTrait; /** * @var Order */ #[Inject] protected Order $orderModel; /** * @return array * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function refundBatch(): array { $kitchenId = $this->request->input('kitchen_id'); $cycleId = (int)$this->request->input('cycle_id'); $reason = $this->request->input('reason'); $orderIds = $this->orderModel ->where('kitchen_id', $kitchenId) ->where('cycle_id', $cycleId) ->where('status', OrderCode::FINISH) ->pluck('id') ->toArray(); if (empty($orderIds)) throw new ErrException('暂无数据'); foreach ($orderIds as $orderId) { $this->joinRefundQueue($orderId,RefundCode::FULL_GOOD_REFUND,$reason); } return $this->return->success(); } }