package com.matrix.system.shopXcx.mqTask.templateMsg; import com.matrix.component.tools.WxSubscribeDto; import com.matrix.component.tools.WxSubscribeValueDto; import com.matrix.component.tools.WxTempLateMsgUtil; import com.matrix.core.tools.DateUtil; import com.matrix.core.tools.StringUtils; import com.matrix.system.hive.bean.Onlinebooking; import com.matrix.system.hive.bean.SysShopInfo; import com.matrix.system.hive.dao.OnlinebookingDao; import com.matrix.system.hive.dao.SysShopInfoDao; import com.matrix.system.shopXcx.bean.ShopProduct; import com.matrix.system.shopXcx.bean.ShopWxtemplateMsg; import com.matrix.system.shopXcx.dao.ShopProductDao; import com.matrix.system.shopXcx.dao.ShopWxtemplateMsgDao; import com.matrix.system.shopXcx.shopEnum.TemplateMsgType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.HashMap; import java.util.Map; /** * 发送预约成功提醒消息 */ @Component public class AppointmentSuccess { @Autowired OnlinebookingDao onlinebookingDao; @Autowired SysShopInfoDao shopInfoDao; @Autowired ShopProductDao productDao; @Autowired ShopWxtemplateMsgDao wxtemplateMsgDao; public void sendTemplateMsg(String message) { String orderId = message; Onlinebooking onlinebooking = onlinebookingDao.selectById(Long.valueOf(orderId)); ShopProduct shopProduct = productDao.selectById(onlinebooking.getProductId()); onlinebooking.setShopProduct(shopProduct); SysShopInfo shopInfo = shopInfoDao.selectById(onlinebooking.getShopId()); //获取模板id ShopWxtemplateMsg wxtemplateMsg = wxtemplateMsgDao.selectByCode(TemplateMsgType.APPOINTMENT_SUCCESS.getCode()); String page = "pages/yuyue/yyInfo?id=" + orderId + "&model=1"; // 发送模板URL WxSubscribeDto temp = new WxSubscribeDto(); // 跳转地址 if (StringUtils.isNotBlank(page)) { temp.setPage(page); } temp.setTouser(onlinebooking.getBizUserId()); // 消息模版ID temp.setTemplate_id(wxtemplateMsg.getUuid()); Map tempLateMsgMap = new HashMap<>(); tempLateMsgMap.put("time2", new WxSubscribeValueDto(DateUtil.dateToString(onlinebooking.getTime(), DateUtil.DATE_FORMAT_MM))); tempLateMsgMap.put("thing8", new WxSubscribeValueDto(shopInfo.getShopName())); tempLateMsgMap.put("thing4", new WxSubscribeValueDto(shopInfo.getShopAddr())); tempLateMsgMap.put("thing7", new WxSubscribeValueDto(shopProduct.getTitle())); tempLateMsgMap.put("thing9", new WxSubscribeValueDto("客服电话:" + shopInfo.getShopTel())); temp.setData(tempLateMsgMap); //发送 WxTempLateMsgUtil.sendSubscribeMsg(temp); } }