MiniBuyerMessage.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace app\frontend\modules\order\services\message;
  3. use app\common\models\Member;
  4. use app\common\models\MemberShopInfo;
  5. use app\common\models\notice\MessageTemp;
  6. use app\common\models\notice\MinAppTemplateMessage;
  7. /**
  8. * Created by PhpStorm.
  9. * User: shenyang
  10. * Date: 2017/6/7
  11. * Time: 上午10:15
  12. */
  13. class MiniBuyerMessage extends Message
  14. {
  15. protected $goods_title;
  16. public function __construct($order,$formId = '',$type = 1,$title)
  17. {
  18. parent::__construct($order,$formId,$type,$title);
  19. $this->goods_title = $this->order->hasManyOrderGoods()->first()->title;
  20. $this->goods_title .= $this->order->hasManyOrderGoods()->first()->goods_option_title ?: '';
  21. }
  22. protected function sendToBuyer()
  23. {
  24. try {
  25. return $this->sendToMember($this->order->uid);
  26. } catch (\Exception $exception) {
  27. }
  28. }
  29. protected function sendToMember($uid)
  30. {
  31. if (empty($this->templateId)) {
  32. return;
  33. }
  34. \Log::debug('===============',[$uid,$this->formId]);
  35. $this->MiniNotice($this->templateId, $this->msg, $uid,'','',$this->formId);
  36. }
  37. private function transfer($temp_id, $params)
  38. {
  39. $this->msg = MessageTemp::getSendMsg($temp_id, $params);
  40. if (!$this->msg) {
  41. return;
  42. }
  43. $this->templateId = MessageTemp::$template_id;
  44. $this->sendToBuyer();
  45. }
  46. public function paymentSuccess($title){
  47. $is_open = MinAppTemplateMessage::getTitle($title);
  48. \Log::info("小程序通知测试-7",$is_open);
  49. if (!$is_open->is_open){
  50. return;
  51. }
  52. $this->msg = [
  53. 'keyword1'=>['value'=> $this->order->belongsToMember->nickname],//姓名
  54. 'keyword2'=>['value'=> $this->order->order_sn],//订单号码
  55. 'keyword3'=>['value'=> $this->order['create_time']->toDateTimeString()],//下单时间
  56. 'keyword4'=>['value'=> $this->order['price']],//订单金额
  57. 'keyword5'=>['value'=> $this->goods_title],// 商品名称
  58. 'keyword6'=>['value'=> $this->order->pay_type_name],//支付方式
  59. 'keyword7'=>['value'=> $this->order['pay_time']->toDateTimeString()],//支付时间
  60. ];
  61. $this->templateId = $is_open->template_id;
  62. $this->sendToBuyer();
  63. }
  64. //订单发货提醒
  65. public function delivery($title){
  66. $is_open = MinAppTemplateMessage::getTitle($title);
  67. if (!$is_open->is_open){
  68. return;
  69. }
  70. $this->msg = [
  71. 'keyword1'=>['value'=> $this->order->belongsToMember->nickname],// 用户
  72. 'keyword2'=>['value'=> $this->order->order_sn],//订单号
  73. 'keyword3'=>['value'=> $this->order['create_time']->toDateTimeString()],//下单时间
  74. 'keyword4'=>['value'=> $this->order['price']],// 订单金额
  75. 'keyword5'=>['value'=> $this->goods_title],//商品信息
  76. 'keyword6'=>['value'=> $this->order['send_time']->toDateTimeString()],//发货时间
  77. 'keyword7'=>['value'=> $this->order['express']['express_company_name'] ?: "暂无信息"],//快递公司
  78. 'keyword8'=>['value'=> $this->order['express']['express_sn'] ?: "暂无信息"],//快递单号
  79. ];
  80. $this->templateId = $is_open->template_id;
  81. $this->sendToBuyer();
  82. }
  83. public function canceled($title)
  84. {
  85. $is_open = MinAppTemplateMessage::getTitle($title);
  86. if (!$is_open->is_open){
  87. return;
  88. }
  89. $this->msg = [
  90. 'keyword1'=>['value'=> $this->order->belongsToMember->nickname],// 用户
  91. 'keyword2'=>['value'=> $this->order->order_sn],//订单号
  92. 'keyword3'=>['value'=> $this->order['create_time']->toDateTimeString()],//下单时间
  93. 'keyword4'=>['value'=> $this->order['price']],// 订单金额
  94. 'keyword5'=>['value'=> $this->order['dispatch_price']],//运费
  95. 'keyword6'=>['value'=> $this->goods_title],//商品详情
  96. 'keyword7'=>['value'=> $this->order['cancel_time']->toDateTimeString()],//取消时间
  97. ];
  98. $this->templateId = $is_open->template_id;
  99. $this->sendToBuyer();
  100. }
  101. }