RefundService.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace backend\modules\mall\services;
  3. use common\enums\RefundStatusEnum;
  4. use common\logic\order\OrderRefundLogic;
  5. use common\models\order\OrderRefund;
  6. /**
  7. * 售后Service
  8. * @package backend\modules\mall\services
  9. */
  10. class RefundService extends BaseService
  11. {
  12. /**
  13. * 订单撤销售后申请
  14. *
  15. * @param integer $id
  16. * @param array $otherData 其他数据
  17. * @return boolean
  18. */
  19. public function revoceRefund(int $id, array $otherData = [])
  20. {
  21. /**
  22. * @var OrderRefund|null
  23. */
  24. $refund = OrderRefund::find()->where(['mall_id' => $this->mall_id, 'id' => $id])->one();
  25. if (empty($refund)) return $this->error('售后单不存在');
  26. // 是否超时
  27. if (!$refund->isReturnTimeoutOfRefund()) return $this->error('当前订单还不能撤单');
  28. // 拒绝售后
  29. return ($logic = new OrderRefundLogic())->execute($this->mall_id, [
  30. 'id' => $refund->id,
  31. 'step_status' => RefundStatusEnum::STEP_NEGATIVE_1,
  32. 'address' => [
  33. 'address' => '',
  34. 'consignee' => '',
  35. 'mobile' => '',
  36. ],
  37. 'refund_reason' => '退货超期,拒绝售后',
  38. 'is_expired' => '1', // 是否是售后期限关闭的售后订单
  39. 'is_admin' => (int)!empty($otherData['is_admin']),
  40. 'is_store' => (int)!empty($otherData['is_store']),
  41. 'operator_id' => $otherData['operator_id'] ?? 0,
  42. ]) ? true : $this->error($logic->getError());
  43. }
  44. }