OrderCreateNotice.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2020/6/7
  6. * Time: 20:01
  7. */
  8. namespace app\common\services\notice\official;
  9. use app\common\models\Order;
  10. use app\common\services\notice\BaseMessageBody;
  11. use app\common\services\notice\share\BackstageNoticeMember;
  12. use app\common\services\notice\share\OfficialNoticeTemplate;
  13. use app\common\services\notice\share\OrderNoticeData;
  14. class OrderCreateNotice extends BaseMessageBody
  15. {
  16. public $orderModel;
  17. protected $orderStatus;//订单状态
  18. use OrderNoticeData,OfficialNoticeTemplate,BackstageNoticeMember;
  19. public function __construct($order, $status)
  20. {
  21. $this->orderModel = $order;
  22. $this->orderStatus = $status;
  23. }
  24. public function organizeData()
  25. {
  26. // TODO: Implement organizeData() method.
  27. $this->data = [
  28. ['name' => '商城名称', 'value' => \Setting::get('shop.shop')['name']],
  29. ['name' => '粉丝昵称', 'value' => $this->member->nickname],
  30. ['name' => '订单号', 'value' => $this->order->order_sn],
  31. ['name' => '下单时间', 'value' => $this->timeData['create_time']],
  32. ['name' => '订单金额', 'value' => $this->order['price']],
  33. ['name' => '运费', 'value' => $this->order['dispatch_price']],
  34. ['name' => '商品详情(含规格)', 'value' => $this->goodsTitle],
  35. ];
  36. }
  37. public function sendMessage()
  38. {
  39. // TODO: Implement sendMessage() method.
  40. $this->processData($this->orderModel);
  41. $this->getTemplate('seller_order_create');
  42. $this->getBackMember();
  43. $this->organizeData();
  44. // 卖家创建消息验证
  45. if(
  46. (empty(\Setting::get('shop.notice')['notice_enable']['created']) && $this->orderStatus == 1) ||
  47. (empty(\Setting::get('shop.notice')['notice_enable']['paid']) && $this->orderStatus == 2) ||
  48. (empty(\Setting::get('shop.notice')['notice_enable']['received']) && $this->orderStatus == 3)
  49. ){
  50. return;
  51. }
  52. \Log::debug("新版公众号消息-卖家创建1",$this->template_id);
  53. \Log::debug("新版公众号消息-卖家创建2",$this->openids);
  54. \Log::debug("新版公众号消息-卖家创建3",$this->data);
  55. $result = (new OfficialMessageNotice($this->temp_id,0,$this->data,$this->openids,1,$this->url))->sendMessage();
  56. if ($result['status'] == 0) {
  57. \Log::debug($result['message']);
  58. }
  59. }
  60. }