jyy
2021-01-09 30f2f276ca35cae2bde763c58719f05c572f415b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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(), 17L);
 
 
        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<String, WxSubscribeValueDto> 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);
    }
 
}