RefundExchangeComplete.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Name: 芸众商城系统
  5. * Author: 广州市芸众信息科技有限公司
  6. * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
  7. * Date: 2021/12/22
  8. * Time: 15:30
  9. */
  10. namespace app\backend\modules\refund\services\operation;
  11. use app\common\events\order\AfterOrderRefundExchangeEvent;
  12. use app\common\models\Order;
  13. use app\common\models\refund\RefundProcessLog;
  14. use app\frontend\modules\order\services\OrderService;
  15. /**
  16. * 换货确认收货
  17. * Class RefundExchangeComplete
  18. * @package app\backend\modules\refund\services\operation
  19. */
  20. class RefundExchangeComplete extends RefundOperation
  21. {
  22. protected $statusBeforeChange = [self::WAIT_RECEIVE_RESEND_GOODS];
  23. protected $statusAfterChanged = self::COMPLETE;
  24. protected $name = '换货收货';
  25. protected $timeField = 'refund_time'; //用户退货时间
  26. protected function afterEventClass()
  27. {
  28. return new AfterOrderRefundExchangeEvent($this);
  29. }
  30. protected function updateBefore()
  31. {
  32. // TODO: Implement updateBefore() method.
  33. }
  34. /**
  35. * @throws \app\common\exceptions\AppException
  36. */
  37. protected function updateAfter()
  38. {
  39. if ($this->order->status == Order::WAIT_SEND) {
  40. OrderService::orderSend(['order_id' => $this->order_id]);
  41. OrderService::orderReceive(['order_id' => $this->order_id]);
  42. } else if ($this->order->status == Order::WAIT_RECEIVE) {
  43. OrderService::orderReceive(['order_id' => $this->order_id]);
  44. }
  45. $this->updateOrderGoodsRefundStatus();
  46. }
  47. //必须要触发完退款事件,才订单关闭
  48. protected function triggerEventAfter()
  49. {
  50. $this->cancelRefund();
  51. }
  52. protected function writeLog()
  53. {
  54. $detail = [
  55. $this->getRefundTypeName()[$this->refund_type].'完成',
  56. '用户确认收货'
  57. ];
  58. $processLog = RefundProcessLog::logInstance($this, RefundProcessLog::OPERATOR_MEMBER);
  59. $processLog->setAttribute('operate_type', RefundProcessLog::OPERATE_REFUND_COMPLETE);
  60. $processLog->saveLog($detail);
  61. }
  62. }