RefundEditApply.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Name: 芸众商城系统
  5. * Author: 广州市芸众信息科技有限公司
  6. * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
  7. * Date: 2021/12/24
  8. * Time: 18:28
  9. */
  10. namespace app\frontend\modules\refund\services\operation;
  11. use app\backend\modules\refund\services\operation\RefundOperation;
  12. use app\common\events\order\BeforeOrderRefundChangeEvent;
  13. use app\common\events\order\OrderRefundApplyEditEvent;
  14. use app\common\models\refund\RefundProcessLog;
  15. class RefundEditApply extends RefundOperation
  16. {
  17. // protected $statusAfterChanged = self::WAIT_CHECK;
  18. protected $name = '修改申请';
  19. protected $editData;
  20. protected function afterEventClass()
  21. {
  22. return new OrderRefundApplyEditEvent($this);
  23. }
  24. protected function updateBefore()
  25. {
  26. $refundApplyData = $this->getRequest()->only([
  27. 'reason', 'content', 'refund_type','receive_status','refund_way_type','freight_price','other_price',
  28. ]);
  29. event(new BeforeOrderRefundChangeEvent($this,$refundApplyData));
  30. if (is_array($this->getRequest()->input('images'))) {
  31. $refundApplyData['images'] = $this->getRequest()->input('images');
  32. } else {
  33. $refundApplyData['images'] = $this->getRequest()->input('images') ? json_decode($this->getRequest()->input('images'), true):[];
  34. }
  35. if (isset($refundApplyData['freight_price'])) {
  36. $this->freight_price = $refundApplyData['freight_price'];
  37. }
  38. if (isset($refundApplyData['other_price'])) {
  39. $this->other_price = $refundApplyData['other_price'];
  40. }
  41. //退款总金额,换货售后退款金额为0
  42. $price = bcadd($this->apply_price, ($this->other_price + $this->freight_price),2);
  43. $this->price = min($this->order->price, $price);
  44. $this->editData = $refundApplyData;
  45. $this->fill($refundApplyData);
  46. $this->backWay()->init($this); //走退货方式验证
  47. }
  48. protected function updateAfter()
  49. {
  50. $this->setBackWay(); //保存退货方式内容
  51. }
  52. protected function writeLog()
  53. {
  54. $detail = [
  55. '售后类型:'. $this->getRefundTypeName()[$this->refund_type],
  56. $this->refund_type == static::REFUND_TYPE_EXCHANGE_GOODS ? '': '退款金额:'.$this->price,
  57. $this->editData['freight_price']?'修改运费:'.$this->editData['freight_price'] :'',
  58. $this->editData['other_price']?'修改其他费用:'.$this->editData['other_price'] :'',
  59. '售后原因:'.$this->reason,
  60. '说明:'.$this->content,
  61. ];
  62. $processLog = RefundProcessLog::logInstance($this, RefundProcessLog::OPERATOR_MEMBER);
  63. $processLog->setAttribute('operate_type', RefundProcessLog::OPERATE_CHANGE_APPLY);
  64. $processLog->saveLog($detail);
  65. }
  66. }