RefundClose.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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:08
  9. */
  10. namespace app\backend\modules\refund\services\operation;
  11. use app\backend\modules\refund\services\RefundMessageService;
  12. use app\common\events\order\AfterOrderRefundedEvent;
  13. use app\common\events\order\AfterOrderRefundExchangeEvent;
  14. use app\common\events\order\AfterOrderRefundSuccessEvent;
  15. use app\common\models\Order;
  16. use app\common\models\refund\RefundProcessLog;
  17. use app\frontend\modules\order\services\OrderService;
  18. /**
  19. * 换货完成后台关闭
  20. * Class RefundClose
  21. * @package app\backend\modules\refund\services\operation
  22. */
  23. class RefundClose extends RefundOperation
  24. {
  25. protected $statusBeforeChange = [
  26. self::WAIT_CHECK,
  27. self::WAIT_RETURN_GOODS,
  28. self::WAIT_RECEIVE_RETURN_GOODS,
  29. self::WAIT_RESEND_GOODS,
  30. self::WAIT_RECEIVE_RESEND_GOODS,
  31. self::WAIT_REFUND,
  32. ];
  33. // protected $statusAfterChanged = self::CLOSE;
  34. protected $statusAfterChanged = self::COMPLETE;
  35. protected $name = '换货关闭';
  36. protected $timeField = 'refund_time';
  37. protected function afterEventClass()
  38. {
  39. return new AfterOrderRefundExchangeEvent($this);
  40. }
  41. protected function updateBefore()
  42. {
  43. // TODO: Implement updateBefore() method.
  44. }
  45. /**
  46. * @throws \app\common\exceptions\AppException
  47. */
  48. protected function updateAfter()
  49. {
  50. if ($this->order->status == Order::WAIT_SEND) {
  51. OrderService::orderSend(['order_id' => $this->order_id]);
  52. OrderService::orderReceive(['order_id' => $this->order_id]);
  53. } else if ($this->order->status == Order::WAIT_RECEIVE) {
  54. OrderService::orderReceive(['order_id' => $this->order_id]);
  55. }
  56. $this->updateOrderGoodsRefundStatus();
  57. }
  58. //必须要触发完退款事件,才订单关闭
  59. protected function triggerEventAfter()
  60. {
  61. $this->cancelRefund();
  62. }
  63. protected function writeLog()
  64. {
  65. $detail = [
  66. $this->getRefundTypeName()[$this->refund_type].'完成',
  67. '商家关闭换货',
  68. ];
  69. $processLog = RefundProcessLog::logInstance($this, RefundProcessLog::OPERATOR_SHOP);
  70. $processLog->setAttribute('operate_type', RefundProcessLog::OPERATE_REFUND_COMPLETE);
  71. $processLog->saveLog($detail);
  72. }
  73. protected function sendMessage()
  74. {
  75. RefundMessageService::passMessage($this);//通知买家
  76. if (app('plugins')->isEnabled('instation-message')) {
  77. event(new \Yunshop\InstationMessage\event\OrderRefundSuccessEvent($this));
  78. }
  79. }
  80. }