PromoteOrderPayedMinNotice.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: yunzhong
  5. * Date: 2020/6/22
  6. * Time: 14:57
  7. */
  8. namespace app\common\services\notice\applet\room;
  9. use app\common\services\notice\applet\AppletMessageNotice;
  10. use app\common\services\notice\BaseMessageBody;
  11. use app\common\services\notice\share\MiniNoticeTemplate;
  12. class PromoteOrderPayedMinNotice extends BaseMessageBody
  13. {
  14. use MiniNoticeTemplate;
  15. public $order;
  16. public $buyerMember;
  17. public $dividend;
  18. public $anchorMember;
  19. public function __construct($order,$buyermember,$anchorMember,$dividend)
  20. {
  21. $this->order = $order;
  22. $this->buyerMember = $buyermember;
  23. $this->anchorMember = $anchorMember;
  24. $this->dividend = $dividend;
  25. }
  26. public function organizeData()
  27. {
  28. // TODO: Implement organizeData() method.
  29. $this->data = [
  30. "time3" => ['value'=>date('Y-m-d H:i:s', time())],
  31. "thing1" => ['value'=>$this->checkDataLength($this->buyerMember->nickname,20)],
  32. "character_string5" => ['value'=>$this->checkDataLength($this->order->order_sn,32)],
  33. "amount2" => ['value'=>$this->order->price],
  34. "amount4" => ['value'=>$this->dividend]
  35. ];
  36. }
  37. public function sendMessage()
  38. {
  39. // TODO: Implement sendMessage() method.
  40. $this->getTemplate("粉丝下单通知");
  41. if (empty($this->temp_open)) {
  42. \Log::debug($this->temp_title."消息通知未开启");
  43. return ;
  44. }
  45. $this->organizeData();
  46. \Log::debug("新版小程序消息-粉丝下单1",$this->temp_id);
  47. \Log::debug("新版小程序消息-粉丝下单2",$this->anchorMember->hasOneMiniApp->openid);
  48. \Log::debug("新版小程序消息-粉丝下单3",$this->data);
  49. $result = (new AppletMessageNotice($this->temp_id,$this->anchorMember->hasOneMiniApp->openid,$this->data,[],2))->sendMessage();
  50. if ($result['status'] == 0) {
  51. \Log::debug($result['message']);
  52. }
  53. }
  54. }