|
|
@@ -3,6 +3,7 @@ package com.ylx.massage.service.impl;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ylx.common.config.WechatAccountConfig;
|
|
|
+import com.ylx.massage.domain.TJs;
|
|
|
import com.ylx.massage.domain.TOrder;
|
|
|
import com.ylx.massage.domain.TXiangmu;
|
|
|
import com.ylx.massage.service.OrderNotificationService;
|
|
|
@@ -43,11 +44,7 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
private TJsService jsService;
|
|
|
|
|
|
/**
|
|
|
- * 订单待接单提醒(用户侧)
|
|
|
- * <p>
|
|
|
- * 消息模板ID:template1
|
|
|
- * 包含字段:订单号、项目名称、预约时间、用户电话、服务地址
|
|
|
- * </p>
|
|
|
+ * 订单待接单提醒(技师侧)
|
|
|
*
|
|
|
* @param order 订单信息
|
|
|
*/
|
|
|
@@ -55,7 +52,7 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
public void sendPendingRemindNotification(TOrder order) {
|
|
|
try {
|
|
|
cn.hutool.json.JSONObject param = buildPendingRemindParams(order);
|
|
|
- weChatUtil.notification(order.getcOpenId(), wxPayProperties.getTemplate1(), param);
|
|
|
+ weChatUtil.notification(order.getcOpenId(), wxPayProperties.getTechTemplate1(), param);
|
|
|
log.info("订单待接单提醒发送成功,订单号:{}", order.getOrderNo());
|
|
|
} catch (Exception e) {
|
|
|
log.error("订单待接单提醒发送失败,订单号:{}", order.getOrderNo(), e);
|
|
|
@@ -64,10 +61,6 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
|
|
|
/**
|
|
|
* 订单已接单通知(用户侧)
|
|
|
- * <p>
|
|
|
- * 消息模板ID:template1
|
|
|
- * 包含字段:订单号、项目名称、预约时间、用户电话、服务地址
|
|
|
- * </p>
|
|
|
*
|
|
|
* @param order 订单信息
|
|
|
*/
|
|
|
@@ -75,19 +68,16 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
public void sendReceivedNotification(TOrder order) {
|
|
|
try {
|
|
|
cn.hutool.json.JSONObject param = buildReceivedNotificationParams(order);
|
|
|
- weChatUtil.notification(order.getcOpenId(), wxPayProperties.getTemplate1(), param);
|
|
|
+ weChatUtil.notification(order.getcOpenId(), wxPayProperties.getUserTemplate1(), param);
|
|
|
log.info("订单已接单通知发送成功,订单号:{}", order.getOrderNo());
|
|
|
} catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
log.error("订单已接单通知发送失败,订单号:{}", order.getOrderNo(), e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 订单完成通知(用户侧)
|
|
|
- * <p>
|
|
|
- * 消息模板ID:template1
|
|
|
- * 包含字段:订单号、项目名称、完成时间
|
|
|
- * </p>
|
|
|
*
|
|
|
* @param order 订单信息
|
|
|
*/
|
|
|
@@ -95,7 +85,7 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
public void sendCompletedNotification(TOrder order) {
|
|
|
try {
|
|
|
cn.hutool.json.JSONObject param = buildCompletedNotificationParams(order);
|
|
|
- weChatUtil.notification(order.getcOpenId(), wxPayProperties.getTemplate1(), param);
|
|
|
+ weChatUtil.notification(order.getcOpenId(), wxPayProperties.getUserTemplate2(), param);
|
|
|
log.info("订单完成通知发送成功,订单号:{}", order.getOrderNo());
|
|
|
} catch (Exception e) {
|
|
|
log.error("订单完成通知发送失败,订单号:{}", order.getOrderNo(), e);
|
|
|
@@ -104,10 +94,6 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
|
|
|
/**
|
|
|
* 订单取消通知(用户侧)
|
|
|
- * <p>
|
|
|
- * 消息模板ID:template1
|
|
|
- * 包含字段:订单号、取消原因、项目名称
|
|
|
- * </p>
|
|
|
*
|
|
|
* @param order 订单信息
|
|
|
*/
|
|
|
@@ -115,7 +101,7 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
public void sendCancelledNotification(TOrder order) {
|
|
|
try {
|
|
|
cn.hutool.json.JSONObject param = buildCancelledNotificationParams(order);
|
|
|
- weChatUtil.notification(order.getcOpenId(), wxPayProperties.getTemplate1(), param);
|
|
|
+ weChatUtil.notification(order.getcOpenId(), wxPayProperties.getUserTemplate3(), param);
|
|
|
log.info("订单取消通知发送成功,订单号:{}", order.getOrderNo());
|
|
|
} catch (Exception e) {
|
|
|
log.error("订单取消通知发送失败,订单号:{}", order.getOrderNo(), e);
|
|
|
@@ -126,23 +112,23 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
* 构建待接单提醒消息参数
|
|
|
*
|
|
|
* @param order 订单信息
|
|
|
- * @return 消息参数
|
|
|
+ * @return JSONObject 消息参数
|
|
|
*/
|
|
|
private cn.hutool.json.JSONObject buildPendingRemindParams(TOrder order) {
|
|
|
cn.hutool.json.JSONObject param = JSONUtil.createObj();
|
|
|
// 订单号
|
|
|
param.set("character_string9", JSONUtil.createObj().set("value", order.getOrderNo()));
|
|
|
- // 项目名称
|
|
|
+ // 用户电话
|
|
|
+ param.set("phone_number3", JSONUtil.createObj().set("value", order.getcPhone()));
|
|
|
+ // 项目
|
|
|
String projectNames = getProjectNames(order);
|
|
|
param.set("thing10", JSONUtil.createObj().set("value", projectNames));
|
|
|
+ // 下单地址
|
|
|
+ param.set("thing13", JSONUtil.createObj().set("value", order.getAddress()));
|
|
|
// 预约时间
|
|
|
LocalDateTime startTime = order.getStartTime();
|
|
|
Date date = Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant());
|
|
|
param.set("time6", JSONUtil.createObj().set("value", DateTimeUtils.formatDate(date, "yyyy-MM-dd HH:mm")));
|
|
|
- // 用户电话
|
|
|
- param.set("phone_number3", JSONUtil.createObj().set("value", order.getcPhone()));
|
|
|
- // 服务地址
|
|
|
- param.set("thing13", JSONUtil.createObj().set("value", order.getAddress()));
|
|
|
return param;
|
|
|
}
|
|
|
|
|
|
@@ -150,7 +136,7 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
* 构建已接单通知消息参数
|
|
|
*
|
|
|
* @param order 订单信息
|
|
|
- * @return 消息参数
|
|
|
+ * @return JSONObject 消息参数
|
|
|
*/
|
|
|
private cn.hutool.json.JSONObject buildReceivedNotificationParams(TOrder order) {
|
|
|
cn.hutool.json.JSONObject param = JSONUtil.createObj();
|
|
|
@@ -159,22 +145,22 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
// 项目名称
|
|
|
String projectNames = getProjectNames(order);
|
|
|
param.set("thing4", JSONUtil.createObj().set("value", projectNames));
|
|
|
- // 预约时间
|
|
|
- LocalDateTime startTime = order.getStartTime();
|
|
|
- Date date = Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant());
|
|
|
- param.set("time3", JSONUtil.createObj().set("value", DateTimeUtils.formatDate(date, "yyyy-MM-dd HH:mm")));
|
|
|
- // 用户电话
|
|
|
- param.set("phone_number5", JSONUtil.createObj().set("value", order.getcPhone()));
|
|
|
- // 服务地址
|
|
|
- param.set("thing14", JSONUtil.createObj().set("value", order.getAddress()));
|
|
|
+
|
|
|
+ //根据技师ID查询技师姓名
|
|
|
+ TJs js = jsService.getById(order.getcJsId());
|
|
|
+ String jsName = js.getcName();
|
|
|
+ // 商家名称
|
|
|
+ param.set("thing9", JSONUtil.createObj().set("value", jsName));
|
|
|
+ // 联系电话
|
|
|
+ param.set("phone_number5", JSONUtil.createObj().set("value", js.getcPhone()));
|
|
|
return param;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 构建完成通知消息参数
|
|
|
+ * 构建完成通知消息参数(用户侧)
|
|
|
*
|
|
|
* @param order 订单信息
|
|
|
- * @return 消息参数
|
|
|
+ * @return JSONObject 消息参数
|
|
|
*/
|
|
|
private cn.hutool.json.JSONObject buildCompletedNotificationParams(TOrder order) {
|
|
|
cn.hutool.json.JSONObject param = JSONUtil.createObj();
|
|
|
@@ -194,7 +180,7 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
* 构建取消通知消息参数
|
|
|
*
|
|
|
* @param order 订单信息
|
|
|
- * @return 消息参数
|
|
|
+ * @return JSONObject 消息参数
|
|
|
*/
|
|
|
private cn.hutool.json.JSONObject buildCancelledNotificationParams(TOrder order) {
|
|
|
cn.hutool.json.JSONObject param = JSONUtil.createObj();
|
|
|
@@ -205,17 +191,19 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
// 项目名称
|
|
|
String projectNames = getProjectNames(order);
|
|
|
param.set("thing25", JSONUtil.createObj().set("value", projectNames));
|
|
|
+ //订单金额
|
|
|
+ param.set("amount23", JSONUtil.createObj().set("value", order.getTotalPrice().toString()));
|
|
|
return param;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 从订单中提取项目名称
|
|
|
+ * 从订单明细中提取项目名称
|
|
|
* <p>
|
|
|
* 解析订单的商品列表,将多个项目名称用逗号连接
|
|
|
* </p>
|
|
|
*
|
|
|
* @param order 订单信息
|
|
|
- * @return 项目名称字符串,多个项目用逗号分隔
|
|
|
+ * @return String 项目名称字符串,多个项目用逗号分隔
|
|
|
*/
|
|
|
private String getProjectNames(TOrder order) {
|
|
|
List<TXiangmu> list = JSONObject.parseArray(order.getcGoods().toJSONString(), TXiangmu.class);
|
|
|
@@ -232,10 +220,6 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
|
|
|
/**
|
|
|
* 订单已接单通知(技师侧)
|
|
|
- * <p>
|
|
|
- * 消息模板ID:templateId1
|
|
|
- * 包含字段:订单号、用户姓名、联系电话、服务地址、下单时间、项目名称
|
|
|
- * </p>
|
|
|
*
|
|
|
* @param order 订单信息
|
|
|
*/
|
|
|
@@ -259,10 +243,6 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
|
|
|
/**
|
|
|
* 订单取消通知(技师侧)
|
|
|
- * <p>
|
|
|
- * 消息模板ID:templateId1
|
|
|
- * 包含字段:订单号、取消原因、项目名称
|
|
|
- * </p>
|
|
|
*
|
|
|
* @param order 订单信息
|
|
|
*/
|
|
|
@@ -286,25 +266,25 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
|
|
|
/**
|
|
|
* 构建技师侧已接单通知消息参数
|
|
|
- * <p>
|
|
|
- * 参考原有的 newOrderNotification 方法实现
|
|
|
- * </p>
|
|
|
*
|
|
|
* @param order 订单信息
|
|
|
- * @return 消息参数
|
|
|
+ * @return JSONObject 消息参数
|
|
|
*/
|
|
|
private cn.hutool.json.JSONObject buildTechnicianReceivedNotificationParams(TOrder order) {
|
|
|
cn.hutool.json.JSONObject param = JSONUtil.createObj();
|
|
|
- // 订单号
|
|
|
- param.set("character_string9", JSONUtil.createObj().set("value", order.getOrderNo()));
|
|
|
- // 用户电话
|
|
|
- param.set("phone_number14", JSONUtil.createObj().set("value", order.getcPhone()));
|
|
|
- // 用户姓名
|
|
|
- param.set("thing18", JSONUtil.createObj().set("value", order.getcName()));
|
|
|
- // 下单时间
|
|
|
- param.set("time6", JSONUtil.createObj().set("value", DateTimeUtils.formatDate(new Date(), DateTimeUtils.DATE_NUMBER_YEAR_MONTH_FORMAT)));
|
|
|
- // 服务地址
|
|
|
- param.set("thing27", JSONUtil.createObj().set("value", order.getName()));
|
|
|
+ // 订单编号
|
|
|
+ param.set("character_string1", JSONUtil.createObj().set("value", order.getOrderNo()));
|
|
|
+ // 联系电话
|
|
|
+ param.set("phone_number5", JSONUtil.createObj().set("value", order.getcPhone()));
|
|
|
+ // 项目名称
|
|
|
+ String projectNames = getProjectNames(order);
|
|
|
+ param.set("thing4", JSONUtil.createObj().set("value", projectNames));
|
|
|
+ // 预约地址
|
|
|
+ param.set("thing14", JSONUtil.createObj().set("value", order.getAddress()));
|
|
|
+ // 预约时间
|
|
|
+ LocalDateTime dtCreateTime = order.getDtCreateTime();
|
|
|
+ Date createTime = Date.from(dtCreateTime.atZone(ZoneId.systemDefault()).toInstant());
|
|
|
+ param.set("time3", JSONUtil.createObj().set("value", DateTimeUtils.formatDate(createTime, "yyyy-MM-dd HH:mm")));
|
|
|
return param;
|
|
|
}
|
|
|
|
|
|
@@ -312,7 +292,7 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
* 构建技师侧取消通知消息参数
|
|
|
*
|
|
|
* @param order 订单信息
|
|
|
- * @return 消息参数
|
|
|
+ * @return JSONObject 消息参数
|
|
|
*/
|
|
|
private cn.hutool.json.JSONObject buildTechnicianCancelledNotificationParams(TOrder order) {
|
|
|
cn.hutool.json.JSONObject param = JSONUtil.createObj();
|
|
|
@@ -320,9 +300,8 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
param.set("character_string2", JSONUtil.createObj().set("value", order.getOrderNo()));
|
|
|
// 取消原因
|
|
|
param.set("thing5", JSONUtil.createObj().set("value", getCancelReason(order)));
|
|
|
- // 项目名称
|
|
|
- String projectNames = getProjectNames(order);
|
|
|
- param.set("thing25", JSONUtil.createObj().set("value", projectNames));
|
|
|
+ // 订单金额
|
|
|
+ param.set("amount23", JSONUtil.createObj().set("value", order.getTotalPrice().toString()));
|
|
|
return param;
|
|
|
}
|
|
|
|
|
|
@@ -330,7 +309,7 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
* 获取技师的 OpenId
|
|
|
*
|
|
|
* @param order 订单信息
|
|
|
- * @return 技师 OpenId,如果技师不存在则返回 null
|
|
|
+ * @return String 技师 OpenId,如果技师不存在则返回 null
|
|
|
*/
|
|
|
private String getTechnicianOpenId(TOrder order) {
|
|
|
if (order.getcJsId() == null) {
|
|
|
@@ -348,7 +327,7 @@ public class OrderNotificationServiceImpl implements OrderNotificationService {
|
|
|
* 获取订单取消原因
|
|
|
*
|
|
|
* @param order 订单信息
|
|
|
- * @return 取消原因描述
|
|
|
+ * @return String 取消原因描述
|
|
|
*/
|
|
|
private String getCancelReason(TOrder order) {
|
|
|
// 如果订单中有具体的取消原因,使用订单中的原因
|