| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- /**
- * Created by PhpStorm.
- * Name: 芸众商城系统
- * Author: 广州市芸众信息科技有限公司
- * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
- * Date: 2021/12/22
- * Time: 15:16
- */
- namespace app\backend\modules\refund\services\operation;
- use app\backend\modules\refund\services\RefundMessageService;
- use app\common\events\order\AfterOrderRefundedEvent;
- use app\common\events\order\AfterOrderRefundSuccessEvent;
- use app\common\models\refund\RefundProcessLog;
- /**
- * 确认退款
- * Class RefundComplete
- * @package app\backend\modules\refund\services\operation
- */
- class RefundComplete extends RefundOperation
- {
- protected $statusBeforeChange = [
- self::WAIT_CHECK,
- self::WAIT_RETURN_GOODS,
- self::WAIT_RECEIVE_RETURN_GOODS,
- self::WAIT_RESEND_GOODS,
- self::WAIT_RECEIVE_RESEND_GOODS,
- self::WAIT_REFUND,
- ];
- protected $statusAfterChanged = self::COMPLETE;
- protected $name = '退款完成';
- protected $timeField = 'refund_time';
- protected function afterEventClass()
- {
- //event(new AfterOrderRefundedEvent($this->order));
- return new AfterOrderRefundSuccessEvent($this);
- }
- protected function updateBefore()
- {
- $this->price = $this->getRequest()->input('refund_custom_money')?:$this->price;
- }
- protected function updateAfter()
- {
- $this->updateOrderGoodsRefundStatus();
- }
- //必须要触发完退款事件,才订单关闭
- protected function triggerEventAfter()
- {
- //更新订单支付记录状态
- if ($this->order->hasOneOrderPay) {
- $this->order->hasOneOrderPay->refund();
- }
- if ($this->isPartRefund()) {
- $this->cancelRefund();
- } else {
- $this->closeOrder();
- }
- }
- protected function writeLog()
- {
- $detail = [
- $this->getRefundTypeName()[$this->refund_type].'完成',
- $this->refund_type == self::REFUND_TYPE_REFUND_MONEY ? '商家确认退款':'商家确认收货',
- ];
- $processLog = RefundProcessLog::logInstance($this, RefundProcessLog::OPERATOR_SHOP);
- $processLog->setAttribute('operate_type', RefundProcessLog::OPERATE_REFUND_COMPLETE);
- $processLog->saveLog($detail);
- }
- protected function sendMessage()
- {
- RefundMessageService::passMessage($this);//通知买家
- if (app('plugins')->isEnabled('instation-message')) {
- event(new \Yunshop\InstationMessage\event\OrderRefundSuccessEvent($this));
- }
- }
- }
|