MiniShopMessage.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace app\frontend\modules\order\services\message;
  3. use app\common\models\Notice;
  4. use app\common\models\notice\MessageTemp;
  5. use app\common\models\notice\MinAppTemplateMessage;
  6. /**
  7. * Created by PhpStorm.
  8. * User: shenyang
  9. * Date: 2017/6/7
  10. * Time: 上午10:15
  11. */
  12. class MiniShopMessage extends Message
  13. {
  14. protected $goods_title;
  15. public function __construct($order,$formId = '',$type = 1,$title)
  16. {
  17. parent::__construct($order,$formId = '',$type = 1,$title);
  18. $this->goods_title = $this->order->hasManyOrderGoods()->first()->title;
  19. $this->goods_title .= $this->order->hasManyOrderGoods()->first()->goods_option_title ? '['.$this->order->hasManyOrderGoods()->first()->goods_option_title.']': '';
  20. }
  21. private function sendToShops()
  22. {
  23. if (empty($this->templateId)) {
  24. return;
  25. }
  26. //客服发送消息通知
  27. $this->notice($this->templateId, $this->msg, $this->order->uid);
  28. }
  29. public function miniSendToShops($templateId,$msg){
  30. if (empty($templateId)) {
  31. return;
  32. }
  33. //客服发送消息通知
  34. $this->MiniNotice($templateId, $msg, $this->order->uid);
  35. }
  36. public function paymentRemind($title){
  37. $is_open = MinAppTemplateMessage::getTitle($title);
  38. \Log::info("小程序通知测试-8",$is_open);
  39. if (!$is_open->is_open){
  40. return;
  41. }
  42. $address = $this->order['address'];
  43. $this->msg = [
  44. 'keyword1'=>['value'=> $this->order->belongsToMember->nickname],// 用户
  45. 'keyword2'=>['value'=> $this->order->order_sn],//订单号
  46. 'keyword3'=>['value'=> $this->goods_title],//商品名称
  47. 'keyword4'=>['value'=> $this->order->pay_type_name],// 支付方式
  48. 'keyword5'=>['value'=> $this->order['price']],// 支付金额
  49. 'keyword6'=>['value'=> $address['realname']],//收貨人
  50. 'keyword7'=>['value'=> $address['province'] . ' ' . $address['city'] . ' ' . $address['area'] . ' ' . $address['address']],//收貨地址
  51. ];
  52. $this->templateId = $is_open->template_id;
  53. $this->sendToShops();
  54. }
  55. /**
  56. * @name 获取商品名
  57. * @author
  58. * @param $goods
  59. * @return string
  60. */
  61. private function getGoodsTitle($goods)
  62. {
  63. $goods_title = $goods->title;
  64. if ($goods->goods_option_title) {
  65. $goods_title .= '[' . $goods->goods_option_title . ']';
  66. }
  67. return $goods_title;
  68. }
  69. }