RefundResend.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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:20
  9. */
  10. namespace app\backend\modules\refund\services\operation;
  11. use app\common\events\order\AfterOrderRefundResendEvent;
  12. use app\common\models\refund\RefundProcessLog;
  13. use app\common\models\refund\ResendExpress;
  14. use app\common\repositories\ExpressCompany;
  15. class RefundResend extends RefundOperation
  16. {
  17. protected $statusAfterChanged = self::WAIT_RECEIVE_RESEND_GOODS;
  18. protected $name = '商家发货';
  19. protected $timeField = 'send_time';
  20. protected $resendExpress;
  21. protected function afterEventClass()
  22. {
  23. return new AfterOrderRefundResendEvent($this);
  24. }
  25. protected function updateBefore()
  26. {
  27. $expressData = $this->getRequest()->only('express_code', 'express_sn');
  28. $expressData['express_company_name'] = array_get(ExpressCompany::create()->where('value', $expressData['express_code'])->first(), 'name', '其他快递');
  29. $order_goods = $this->order->orderGoods;
  30. if ($order_goods) {
  31. foreach ($order_goods as $goods) {
  32. $refundGoods = $this->refundOrderGoods->where('order_goods_id', $goods['id'])->first();
  33. if ($refundGoods) {
  34. $expressData['pack_goods'][] = [
  35. 'order_goods_id' => $refundGoods->order_goods_id,
  36. 'title' => $refundGoods->goods_title,
  37. 'goods_option_title' => $refundGoods->goods_option_title,
  38. 'thumb' => $refundGoods->goods_thumb,
  39. 'total' => $refundGoods->total,
  40. ];
  41. $refundGoods->fill(['send_num'=> 0])->save();
  42. }
  43. }
  44. }
  45. $expressData['refund_id'] = $this->id;
  46. $this->resendExpress = ResendExpress::create($expressData);
  47. }
  48. protected function updateAfter()
  49. {
  50. }
  51. protected function writeLog()
  52. {
  53. $detail = [
  54. '快递公司:'.$this->resendExpress->express_company_name,
  55. '快递单号:'.$this->resendExpress->express_sn,
  56. ];
  57. $processLog = RefundProcessLog::logInstance($this, RefundProcessLog::OPERATOR_SHOP);
  58. $processLog->setAttribute('operate_type', RefundProcessLog::OPERATE_SHOP_RESEND);
  59. $processLog->saveLog($detail);
  60. }
  61. }