OrderBuyerReceivedMinNotice.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2020/6/14
  6. * Time: 8:35
  7. */
  8. namespace app\common\services\notice\applet\buyer;
  9. use app\common\models\Order;
  10. use app\common\services\notice\applet\AppletMessageNotice;
  11. use app\common\services\notice\BaseMessageBody;
  12. use app\common\services\notice\share\MiniNoticeTemplate;
  13. use app\common\services\notice\share\OrderNoticeData;
  14. class OrderBuyerReceivedMinNotice extends BaseMessageBody
  15. {
  16. use MiniNoticeTemplate,OrderNoticeData;
  17. public $orderModel;
  18. public function __construct($order)
  19. {
  20. $this->orderModel = $order;
  21. }
  22. public function organizeData()
  23. {
  24. // TODO: Implement organizeData() method.
  25. $order_sn = $this->order->order_sn;
  26. // $order_sn = substr($this->order->order_sn,2);
  27. // $order_sn = preg_replace('|[a-zA-Z]+|','',$order_sn); //截取字母
  28. $this->data = [
  29. 'thing6'=>['value'=> $this->checkDataLength($this->goodsTitle,20)],// 商品名称
  30. 'thing4'=>['value'=> $this->checkDataLength((\Setting::get('shop.shop')['name']?:''),20)],//商户名称
  31. 'character_string8'=>['value'=> $this->checkDataLength($order_sn,32)],// 订单编码
  32. 'date7'=>['value'=> $this->timeData['finish_time']],// 收货时间
  33. 'phrase3'=>['value'=> "已收货"]// 订单状态xiao
  34. ];
  35. }
  36. public function sendMessage()
  37. {
  38. // TODO: Implement sendMessage() method.
  39. $this->processData($this->orderModel);
  40. $this->getTemplate("确认收货通知");
  41. $back = [];
  42. if (empty($this->temp_open)) {
  43. $back['message'] = $this->temp_title."消息通知未开启";
  44. \Log::debug($back['message']);
  45. return ;
  46. }
  47. $this->organizeData();
  48. \Log::debug("新版小程序消息-收货1",$this->temp_id);
  49. \Log::debug("新版小程序消息-收货2",$this->miniFans->openid);
  50. \Log::debug("新版小程序消息-收货3",$this->data);
  51. $result = (new AppletMessageNotice($this->temp_id,$this->miniFans->openid,$this->data,[],2))->sendMessage();
  52. if ($result['status'] == 0) {
  53. \Log::debug($result['message']);
  54. }
  55. }
  56. }