1
This commit is contained in:
@@ -212,11 +212,11 @@ public class JDUtils {
|
||||
long start = System.currentTimeMillis();
|
||||
int[] parm = {-1};
|
||||
List<OrderRow> orderRows = orderRowRepository.findByValidCodeNotInOrderByOrderTimeDesc(parm);
|
||||
if (!orderRows.isEmpty()) {
|
||||
for (OrderRow orderRow : orderRows) {
|
||||
orderToWx(orderRow, true);
|
||||
}
|
||||
|
||||
for (OrderRow orderRow : orderRows) {
|
||||
orderToWx(orderRow, true);
|
||||
}
|
||||
|
||||
logger.info("扫描订单发送到微信耗时:{} ms, 订单数:{} ", System.currentTimeMillis() - start, orderRows.size());
|
||||
|
||||
}
|
||||
@@ -274,25 +274,23 @@ public class JDUtils {
|
||||
* 手动调用 将订单发送到微信
|
||||
*/
|
||||
private void orderToWx(OrderRow orderRow, Boolean isAutoFlush) {
|
||||
// 查询订单状态
|
||||
// 获取订单当前状态
|
||||
Integer newValidCode = orderRow.getValidCode();
|
||||
String oldValidCode = redisTemplate.opsForValue().get(ORDER_ROW_KEY + orderRow.getId());
|
||||
Integer lastValidCode = 0;
|
||||
// 更新 Redis 状态
|
||||
redisTemplate.opsForValue().set(ORDER_ROW_KEY + orderRow.getId(), String.valueOf(orderRow.getValidCode()));
|
||||
|
||||
if (Util.isNotEmpty(oldValidCode)) {
|
||||
lastValidCode = Integer.valueOf(oldValidCode);
|
||||
}
|
||||
// 如果订单状态没变化,就不发送
|
||||
if (isAutoFlush && lastValidCode.equals(newValidCode)) {
|
||||
} else {
|
||||
String content;
|
||||
content = getFormattedOrderInfo(orderRow, Util.isEmpty(oldValidCode) ? -100 : Integer.parseInt(oldValidCode));
|
||||
// 推送
|
||||
// 检查Redis中是否有旧的状态码,没有的话赋予默认值
|
||||
Integer lastValidCode = oldValidCode != null ? Integer.parseInt(oldValidCode) : -100;
|
||||
|
||||
// 这里使用了逻辑非(!)操作符来简化条件判断
|
||||
if (!isAutoFlush || !lastValidCode.equals(newValidCode)) {
|
||||
// 当 isAutoFlush 为 false 或状态确实有变化时,进行消息发送
|
||||
String content = getFormattedOrderInfo(orderRow, lastValidCode);
|
||||
wxUtil.sendTextMessage(WXUtil.super_admin_wxid, content, 1, WXUtil.super_admin_wxid);
|
||||
}
|
||||
|
||||
// 更新 Redis 状态值
|
||||
redisTemplate.opsForValue().set(ORDER_ROW_KEY + orderRow.getId(), String.valueOf(orderRow.getValidCode()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user