OrderServiceImpl.java
4.82 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package com.glsx.task.service.impl;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.glsx.common.feign.client.OderWechatMsgClient;
import com.glsx.common.pojo.SysOrderWechatMsg;
import com.glsx.common.utils.DateUtil;
import com.glsx.common.utils.PropertiesUtil;
import com.glsx.common.utils.wehcat.MiniProgram;
import com.glsx.common.utils.wehcat.TemplateData;
import com.glsx.common.utils.wehcat.WechatTemplate;
import com.glsx.common.utils.wehcat.WechatUtils;
import com.glsx.task.constants.Constants;
import com.glsx.task.mapper.SysCarOcrMapper;
import com.glsx.task.mapper.SysOrderMapper;
import com.glsx.task.pojo.SysCarOcr;
import com.glsx.task.pojo.SysOrder;
import com.glsx.task.service.IOrderService;
/**
*
* @Title OrderServiceImpl.java
* @Package com.glsx.task.service.impl
* @Description TODO 订单service实现
* @author zhanghj
* @date 2019年4月26日 上午11:35:31
* @version 1.0.0
*/
@Service
public class OrderServiceImpl implements IOrderService {
private Logger logger = LoggerFactory.getLogger(OrderServiceImpl.class);
@Autowired
private SysOrderMapper orderDao;
@Autowired
private SysCarOcrMapper carOcrDao;
@Autowired
private WechatUtils wechatUtils;
@Autowired
private OderWechatMsgClient oderWechatMsgClient;
@Override
public List<SysOrder> getTimeoutOrderList() {
// TODO Auto-generated method stub
return orderDao.getTimeoutOrderList();
}
@Override
public void sendOrderTimeoutRemindMsg() {
// TODO Auto-generated method stub
List<SysOrder> orders = getTimeoutOrderList();
String templateId = PropertiesUtil.getProperty("wechat_bhg_public_order_timeout_templateid");
String pagePath = PropertiesUtil.getProperty(com.glsx.common.constants.Constants.WECHAT_MINI_ORDER_DETAIL_PAGE);
String miniAppId = PropertiesUtil.getProperty(com.glsx.common.constants.Constants.WECHAT_MINI_MECHANIC_APPID);
for (SysOrder order : orders) {
try {
String orderSn = order.getOrderSn();
String carOwner = order.getCarOwner() == null ? "" : order.getCarOwner();
if (order.getOrderType() == 6) {
carOwner = order.getMerchantName() == null ? "" : order.getMerchantName();
}
String carOwnerPhone = order.getCarOwnerPhone() == null ? "--" : order.getCarOwnerPhone();
Date creatTime = order.getCreateTime();
String createTimeStr = DateUtil.formatDate(creatTime);
String publicOpenId = order.getPublicOpenId();
logger.info("发送订单超时提醒:orderSn="+ orderSn + "publicOpenId="
+ publicOpenId + "createTimeStr=" + createTimeStr + "carOwner=" + carOwner + "carOwnerPhone=" + carOwnerPhone);
WechatTemplate wechatTemplate = new WechatTemplate();
wechatTemplate.setTemplate_id(templateId);
wechatTemplate.setTouser(publicOpenId);
MiniProgram miniprogram = new MiniProgram();
miniprogram.setAppid(miniAppId);
miniprogram.setPagepath(pagePath);
wechatTemplate.setMiniprogram(miniprogram);
Map<String, TemplateData> data = new HashMap<String, TemplateData>();
data.put("first", new TemplateData("你有一个订单已超时\r\n", ""));
data.put("keyword1", new TemplateData(orderSn, ""));
data.put("keyword2", new TemplateData(carOwner, ""));
data.put("keyword3", new TemplateData(carOwnerPhone, ""));
data.put("keyword4", new TemplateData(createTimeStr + "\r\n", ""));
data.put("remark", new TemplateData("点击查看详情", com.glsx.common.constants.Constants.WECHAT_BHG_PUBLIC_ORDER_REMARK_COLOR));
wechatTemplate.setData(data);
wechatUtils.sendTemplateMessage(wechatTemplate);
Byte msgType = Constants.ORDER_TIME_OUT_REMIND;
insertSysOrderWechatMsg(order, msgType);
} catch (Exception e) {
logger.error("发送订单超时提醒失败", e);
}
}
}
/**
* 同步微信消息成功记录
*/
private void insertSysOrderWechatMsg(SysOrder sysOrder, Byte msgType){
Date now = new Date();
Integer mechanic = sysOrder.getMechanicId();
SysOrderWechatMsg sysOrderWechatMsg=new SysOrderWechatMsg();
sysOrderWechatMsg.setOrderId(sysOrder.getId());
sysOrderWechatMsg.setMsgType(msgType);
sysOrderWechatMsg.setRecevier(mechanic);
sysOrderWechatMsg.setCreateBy(-1);
sysOrderWechatMsg.setCreateTime(now);
oderWechatMsgClient.insert(sysOrderWechatMsg);
}
/*
* (non-Javadoc)
*
* @see com.glsx.task.service.IOrderService#getYesterdayCarOcrResult()
*/
@Override
public List<SysCarOcr> getYesterdayCarOcrResult() {
return carOcrDao.getYesterdayCarOcrResult();
}
}