RefundConsensus.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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: 14:50
  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\AfterOrderRefundSuccessEvent;
  14. use app\common\models\refund\RefundProcessLog;
  15. /**
  16. * 手动退款
  17. * Class RefundConsensus
  18. * @package app\backend\modules\refund\services\operation
  19. */
  20. class RefundConsensus extends RefundOperation
  21. {
  22. protected $statusBeforeChange = [
  23. self::WAIT_CHECK,
  24. self::WAIT_RETURN_GOODS,
  25. self::WAIT_RECEIVE_RETURN_GOODS,
  26. self::WAIT_RESEND_GOODS,
  27. self::WAIT_RECEIVE_RESEND_GOODS,
  28. self::WAIT_REFUND,
  29. ];
  30. protected $statusAfterChanged = self::CONSENSUS;
  31. protected $name = '手动退款';
  32. protected $timeField = 'refund_time';
  33. protected function afterEventClass()
  34. {
  35. //event(new AfterOrderRefundedEvent($this->order));
  36. return new AfterOrderRefundSuccessEvent($this);
  37. }
  38. protected function updateBefore()
  39. {
  40. // TODO: Implement updateBefore() method.
  41. }
  42. protected function updateAfter()
  43. {
  44. $this->updateOrderGoodsRefundStatus();
  45. }
  46. //必须要触发完退款事件,才订单关闭
  47. protected function triggerEventAfter()
  48. {
  49. //更新订单支付记录状态
  50. if ($this->order->hasOneOrderPay) {
  51. $this->order->hasOneOrderPay->refund();
  52. }
  53. if ($this->isPartRefund()) {
  54. $this->cancelRefund();
  55. } else {
  56. $this->closeOrder();
  57. }
  58. }
  59. protected function writeLog()
  60. {
  61. $detail = [
  62. $this->getRefundTypeName()[$this->refund_type].'完成',
  63. ];
  64. $processLog = RefundProcessLog::logInstance($this, RefundProcessLog::OPERATOR_SHOP);
  65. $processLog->setAttribute('operate_type', RefundProcessLog::OPERATE_REFUND_CONSENSUS);
  66. $processLog->saveLog($detail);
  67. }
  68. protected function sendMessage()
  69. {
  70. RefundMessageService::passMessage($this);//通知买家
  71. if (app('plugins')->isEnabled('instation-message')) {
  72. event(new \Yunshop\InstationMessage\event\OrderRefundSuccessEvent($this));
  73. }
  74. }
  75. }