OrderAftersaleChangeBase.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <?php
  2. namespace addons\shopro\notification\order\aftersale;
  3. use addons\shopro\notification\Notification;
  4. use addons\shopro\notification\traits\Notification as NotificationTrait;
  5. /**
  6. * 售后结果通知
  7. */
  8. class OrderAftersaleChangeBase extends Notification
  9. {
  10. use NotificationTrait;
  11. // 队列延迟时间,必须继承 ShouldQueue 接口
  12. public $delay = 0;
  13. // 消息类型 Notification::$notificationType
  14. public $notification_type = 'shop';
  15. // 发送类型
  16. public $event = 'order_aftersale_change';
  17. // 额外数据
  18. public $data = [];
  19. public $template = [
  20. 'MessageDefaultContent' => '您的售后申请有新的变化,售后单号:{aftersale_sn},变动内容:{content},请及时处理',
  21. // 'WechatOfficialAccount' => [
  22. // 'temp_no' => 'OPENTM417005336',
  23. // 'fields' => [
  24. // // 'first' => '您的售后申请有新的变化',
  25. // // 'keyword1' => 'aftersale_sn', // 售后编号
  26. // // 'keyword2' => 'goods_title', // 商品名称
  27. // // 'keyword3' => 'aftersale_status_text', // 状态
  28. // // 'keyword4' => 'oper_date', // 时间
  29. // // 'remark' => '您的售后申请有新的变化,点击立即处理',
  30. // [
  31. // "template_field" => "first",
  32. // "value" => '您的售后申请有新的变化',
  33. // ],
  34. // [
  35. // "name" => "售后编号",
  36. // "field" => "aftersale_sn",
  37. // "template_field" => "keyword1",
  38. // ],
  39. // [
  40. // "name" => "商品名称",
  41. // "field" => "goods_title",
  42. // "template_field" => "keyword2",
  43. // ],
  44. // [
  45. // "name" => "状态",
  46. // "field" => "aftersale_status_text",
  47. // "template_field" => "keyword3",
  48. // ],
  49. // [
  50. // "name" => "时间",
  51. // "field" => "oper_date",
  52. // "template_field" => "keyword4",
  53. // ],
  54. // [
  55. // "template_field" => "remark",
  56. // "value" => '您的售后申请有新的变化,点击立即处理',
  57. // ]
  58. // ],
  59. // ],
  60. 'WechatOfficialAccount' => [
  61. 'temp_no' => '46232',
  62. 'keywords' => ['订单编号', '退款商品', '退款金额', '处理结果'],
  63. 'fields' => [
  64. [
  65. "name" => "订单编号",
  66. "field" => "order_sn",
  67. "template_field" => "character_string8",
  68. ],
  69. [
  70. "name" => "退款商品",
  71. "field" => "goods_title",
  72. "template_field" => "thing4",
  73. ],
  74. [
  75. "name" => "退款金额",
  76. "field" => "refund_fee",
  77. "template_field" => "amount5",
  78. ],
  79. [
  80. "name" => "处理结果",
  81. "field" => "aftersale_status_text",
  82. "template_field" => "thing6",
  83. ]
  84. ],
  85. ],
  86. 'WechatMiniProgram' => [
  87. 'category_id' => 670,
  88. 'tid' => '5334',
  89. 'kid' => [2,9,7,1,3], // 售后单号,订单编号,商品名称
  90. 'scene_desc' => '当售后状态改变时通知用户', // 申请模板场景描述
  91. 'fields' => [
  92. // 'character_string2' => 'aftersale_sn', // 售后单号
  93. // 'character_string9' => 'order_sn', // 订单编号
  94. // 'thing7' => 'goods_title', // 商品名称
  95. // 'phrase1' => 'aftersale_status_text', // 售后状态
  96. // 'date3' => 'apply_date', // 申请时间
  97. [
  98. "name" => "售后单号",
  99. "field" => "aftersale_sn",
  100. "template_field" => "character_string2",
  101. ],
  102. [
  103. "name" => "订单编号",
  104. "field" => "order_sn",
  105. "template_field" => "character_string9",
  106. ],
  107. [
  108. "name" => "商品名称",
  109. "field" => "goods_title",
  110. "template_field" => "thing7",
  111. ],
  112. [
  113. "name" => "售后状态",
  114. "field" => "aftersale_status_text",
  115. "template_field" => "phrase1",
  116. ],
  117. [
  118. "name" => "申请时间",
  119. "field" => "apply_date",
  120. "template_field" => "date3",
  121. ],
  122. ],
  123. ]
  124. ];
  125. // 返回的字段列表
  126. public $returnField = [
  127. 'name' => '售后结果通知',
  128. 'channels' => ['Sms', 'Email', 'WechatOfficialAccount', 'WechatMiniProgram'],
  129. 'fields' => [
  130. ['name' => '消息名称', 'field' => 'template'],
  131. ['name' => '售后单ID', 'field' => 'aftersale_id'],
  132. ['name' => '售后单号', 'field' => 'aftersale_sn'],
  133. ['name' => '申请时间', 'field' => 'apply_date'],
  134. ['name' => '订单ID', 'field' => 'order_id'],
  135. ['name' => '订单号', 'field' => 'order_sn'],
  136. ['name' => '订单金额', 'field' => 'order_amount'],
  137. ['name' => '下单时间', 'field' => 'create_date'],
  138. ['name' => '申请用户', 'field' => 'nickname'],
  139. ['name' => '用户手机', 'field' => 'mobile'],
  140. ['name' => '支付金额', 'field' => 'pay_fee'],
  141. ['name' => '售后类型', 'field' => 'aftersale_type'],
  142. ['name' => '联系电话', 'field' => 'aftersale_mobile'],
  143. ['name' => '商品名称', 'field' => 'goods_title'],
  144. ['name' => '商品规格', 'field' => 'goods_sku_text'],
  145. ['name' => '商品原价', 'field' => 'goods_original_price'],
  146. ['name' => '商品价格', 'field' => 'goods_price'],
  147. ['name' => '购买数量', 'field' => 'goods_num'],
  148. ['name' => '优惠金额', 'field' => 'discount_fee'],
  149. ['name' => '售后状态', 'field' => 'aftersale_status_text'],
  150. ['name' => '退款状态', 'field' => 'refund_status_text'],
  151. ['name' => '退款金额', 'field' => 'refund_fee'],
  152. ['name' => '变动内容', 'field' => 'content'],
  153. ['name' => '处理时间', 'field' => 'oper_date'],
  154. ]
  155. ];
  156. /**
  157. * 组合数据参数
  158. *
  159. * @param \think\Model $notifiable
  160. * @return array
  161. */
  162. protected function getData($notifiable)
  163. {
  164. $aftersale = $this->data['aftersale'];
  165. $order = $this->data['order'];
  166. $aftersaleLog = $this->data['aftersaleLog'];
  167. $data['template'] = $this->returnField['name']; // 模板名称
  168. $data['aftersale_id'] = $aftersale['id'];
  169. $data['aftersale_sn'] = $aftersale['aftersale_sn'];
  170. $data['apply_date'] = $aftersale['createtime'];
  171. $data['order_id'] = $order['id'];
  172. $data['order_sn'] = $order['order_sn'];
  173. $data['order_amount'] = '¥' . $order['order_amount'];
  174. $data['create_date'] = $order['createtime'];
  175. $data['nickname'] = $notifiable['nickname'];
  176. $data['mobile'] = $notifiable['mobile'];
  177. $data['pay_fee'] = '¥' . $order['pay_fee'];
  178. $data['aftersale_type'] = $aftersale['type_text'];
  179. $data['aftersale_mobile'] = $aftersale['mobile'];
  180. $data['goods_title'] = $aftersale['goods_title'];
  181. $data['goods_sku_text'] = $aftersale['goods_sku_text'];
  182. $data['goods_original_price'] = '¥' . $aftersale['goods_original_price'];
  183. $data['goods_price'] = '¥' . $aftersale['goods_price'];
  184. $data['goods_num'] = $aftersale['goods_num'];
  185. $data['discount_fee'] = '¥' . $aftersale['discount_fee'];
  186. $data['aftersale_status_text'] = $aftersale['aftersale_status_text'];
  187. $data['refund_status_text'] = $aftersale['refund_status_text'];
  188. if ($aftersale['refund_fee']) {
  189. $data['refund_fee'] = '¥' . $aftersale['refund_fee'];
  190. } else {
  191. $data['refund_fee'] = '暂未退款';
  192. }
  193. $data['content'] = $aftersaleLog['content'] ? strip_tags($aftersaleLog['content']) : '-';
  194. $data['oper_date'] = $aftersaleLog['createtime'];
  195. // 统一跳转地址
  196. $data['jump_url'] = "/pages/order/aftersale/detail?id=" . $aftersale['id'];
  197. return $data;
  198. }
  199. }