OrderRefundSuccessMinNotice.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2020/6/14
  6. * Time: 9:42
  7. */
  8. namespace app\common\services\notice\applet\refund;
  9. use app\common\models\Order;
  10. use app\common\models\refund\RefundApply;
  11. use app\common\services\notice\applet\AppletMessageNotice;
  12. use app\common\services\notice\BaseMessageBody;
  13. use app\common\services\notice\share\MiniNoticeTemplate;
  14. use app\common\services\notice\share\OrderNoticeData;
  15. class OrderRefundSuccessMinNotice extends BaseMessageBody
  16. {
  17. use OrderNoticeData,MiniNoticeTemplate;
  18. public $refund;
  19. public $orderModel;
  20. public function __construct($refund,$order)
  21. {
  22. $this->refund = $refund;
  23. $this->orderModel = $order;
  24. }
  25. public function organizeData()
  26. {
  27. // TODO: Implement organizeData() method.
  28. $this->data = [
  29. //'keyword1'=>['value'=> $this->order->nickname],// 退款人
  30. //'keyword2'=>['value'=> $this->refund->refund_sn],//退款单号
  31. //'keyword4'=>['value'=> $this->order->pay_type_name],// 退款方式
  32. //'keyword6'=>['value'=> $this->refund->reason],// 退款原因,
  33. 'amount2'=>['value'=> $this->refund->price],// 退款金额
  34. 'character_string1'=>['value'=> $this->checkDataLength($this->order->order_sn,32)],
  35. 'thing4'=>['value'=>$this->checkDataLength($this->refund->reason,20)],
  36. 'time3' => ['value'=> $this->refund->create_time->toDateTimeString()],
  37. 'phrase5' => ['value'=>'退款成功']
  38. ];
  39. }
  40. public function sendMessage()
  41. {
  42. // TODO: Implement sendMessage() method.
  43. $this->processData($this->orderModel);
  44. $this->getTemplate("订单退款通知");
  45. if (empty($this->temp_open)) {
  46. \Log::debug($this->temp_title."消息通知未开启");
  47. return ;
  48. }
  49. $this->organizeData();
  50. \Log::debug("新版小程序消息-退款1",$this->temp_id);
  51. \Log::debug("新版小程序消息-退款2",$this->miniFans->openid);
  52. \Log::debug("新版小程序消息-退款3",$this->data);
  53. $result = (new AppletMessageNotice($this->temp_id,$this->miniFans->openid,$this->data,[],2))->sendMessage();
  54. if ($result['status'] == 0) {
  55. \Log::debug($result['message']);
  56. }
  57. }
  58. }