OrderBuyerSendMinNotice.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2020/6/14
  6. * Time: 8:26
  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 OrderBuyerSendMinNotice extends BaseMessageBody
  15. {
  16. use OrderNoticeData,MiniNoticeTemplate;
  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. $this->data = [
  26. // 'keyword1'=>['value'=> $this->member->nickname],// 用户
  27. 'character_string7'=>['value'=> $this->checkDataLength($this->order->order_sn,32)],//订单号
  28. // 'keyword3'=>['value'=> $this->timeData['create_time']],//下单时间
  29. 'amount9'=>['value'=> $this->order['price']],// 订单金额
  30. 'thing5'=>['value'=> $this->checkDataLength($this->goodsTitle,20)],//商品信息
  31. 'date6'=>['value'=> $this->timeData['send_time']],//发货时间
  32. //'keyword7'=>['value'=> $this->order['express']['express_company_name'] ?: "暂无信息"],//快递公司
  33. 'character_string3'=>['value'=> $this->checkDataLength($this->order['express']['express_sn'] ?: "",32)],//快递单号
  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. }