价保
This commit is contained in:
@@ -12,7 +12,6 @@ import cn.van.business.util.ds.GPTClientUtil;
|
|||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONArray;
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.alibaba.fastjson2.TypeReference;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.jd.open.api.sdk.DefaultJdClient;
|
import com.jd.open.api.sdk.DefaultJdClient;
|
||||||
import com.jd.open.api.sdk.JdClient;
|
import com.jd.open.api.sdk.JdClient;
|
||||||
@@ -477,7 +476,7 @@ public class JDUtil {
|
|||||||
if (!orderRowList.isEmpty()) {
|
if (!orderRowList.isEmpty()) {
|
||||||
OrderRow orderRow = orderRowList.get(0);
|
OrderRow orderRow = orderRowList.get(0);
|
||||||
if (unionIds.contains(orderRow.getUnionId())) {
|
if (unionIds.contains(orderRow.getUnionId())) {
|
||||||
content.append(orderUtil.getFormattedOrderInfo(orderRow, orderRow.getValidCode()));
|
content.append(orderUtil.getFormattedOrderInfo(orderRow));
|
||||||
} else {
|
} else {
|
||||||
content.append("订单不属于你,无法查询\r");
|
content.append("订单不属于你,无法查询\r");
|
||||||
}
|
}
|
||||||
@@ -499,7 +498,7 @@ public class JDUtil {
|
|||||||
List<OrderRow> subList = bySkuIdAndUnionId.subList(i, Math.min(i + 20, size));
|
List<OrderRow> subList = bySkuIdAndUnionId.subList(i, Math.min(i + 20, size));
|
||||||
content.append("第").append(i / 20 + 1).append("页:\r");
|
content.append("第").append(i / 20 + 1).append("页:\r");
|
||||||
for (OrderRow orderRow : subList) {
|
for (OrderRow orderRow : subList) {
|
||||||
content.append(orderUtil.getFormattedOrderInfo(orderRow, orderRow.getValidCode()));
|
content.append(orderUtil.getFormattedOrderInfo(orderRow));
|
||||||
contents.add(content);
|
contents.add(content);
|
||||||
content = new StringBuilder();
|
content = new StringBuilder();
|
||||||
}
|
}
|
||||||
@@ -1651,10 +1650,6 @@ public class JDUtil {
|
|||||||
logger.info("handleCommentInteraction 处理生成评论流程中的用户交互 - 用户: {},message: {}", fromWxid, message);
|
logger.info("handleCommentInteraction 处理生成评论流程中的用户交互 - 用户: {},message: {}", fromWxid, message);
|
||||||
try {
|
try {
|
||||||
getProductTypeMap();
|
getProductTypeMap();
|
||||||
if (productTypeMap == null) {
|
|
||||||
wxUtil.sendTextMessage(fromWxid, "productTypeMap 为空 ", 1, fromWxid, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (productTypeMap.containsKey(message)) {
|
if (productTypeMap.containsKey(message)) {
|
||||||
generateComment(fromWxid, message);
|
generateComment(fromWxid, message);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public class OrderUtil {
|
|||||||
|
|
||||||
//标记唯一订单行:订单+sku维度的唯一标识
|
//标记唯一订单行:订单+sku维度的唯一标识
|
||||||
private static final String ORDER_ROW_KEY = "jd:order:row:";
|
private static final String ORDER_ROW_KEY = "jd:order:row:";
|
||||||
|
private static final String ORDER_ROW_JB_KEY = "jd:order:row:jb:";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手动调用 将订单发送到微信
|
* 手动调用 将订单发送到微信
|
||||||
@@ -50,14 +51,18 @@ public class OrderUtil {
|
|||||||
// 获取订单当前状态
|
// 获取订单当前状态
|
||||||
Integer newValidCode = orderRow.getValidCode();
|
Integer newValidCode = orderRow.getValidCode();
|
||||||
String oldValidCode = redisTemplate.opsForValue().get(ORDER_ROW_KEY + orderRow.getId());
|
String oldValidCode = redisTemplate.opsForValue().get(ORDER_ROW_KEY + orderRow.getId());
|
||||||
|
// 价保
|
||||||
|
Double newProPriceAmount = orderRow.getProPriceAmount();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 检查Redis中是否有旧的状态码,没有的话赋予默认值
|
// 检查Redis中是否有旧的状态码,没有的话赋予默认值
|
||||||
Integer lastValidCode = oldValidCode != null ? Integer.parseInt(oldValidCode) : -100;
|
Integer lastValidCode = oldValidCode != null ? Integer.parseInt(oldValidCode) : -100;
|
||||||
|
|
||||||
// 这里使用了逻辑非(!)操作符来简化条件判断
|
// 订单变化
|
||||||
if (!isAutoFlush || !lastValidCode.equals(newValidCode)) {
|
if (!isAutoFlush || !lastValidCode.equals(newValidCode)) {
|
||||||
// 当 isAutoFlush 为 false 或状态确实有变化时,进行消息发送
|
// 当 isAutoFlush 为 false 或状态确实有变化时,进行消息发送
|
||||||
String content = getFormattedOrderInfo(orderRow, lastValidCode);
|
String content = getFormattedOrderInfo(orderRow);
|
||||||
String wxId = getWxidFromJdid(orderRow.getUnionId().toString());
|
String wxId = getWxidFromJdid(orderRow.getUnionId().toString());
|
||||||
if (Util.isNotEmpty(wxId)) {
|
if (Util.isNotEmpty(wxId)) {
|
||||||
wxUtil.sendTextMessage(wxId, content, 1, wxId, true);
|
wxUtil.sendTextMessage(wxId, content, 1, wxId, true);
|
||||||
@@ -100,10 +105,24 @@ public class OrderUtil {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新 Redis 状态值
|
// 更新 Redis 状态值
|
||||||
redisTemplate.opsForValue().set(ORDER_ROW_KEY + orderRow.getId(), String.valueOf(orderRow.getValidCode()));
|
redisTemplate.opsForValue().set(ORDER_ROW_KEY + orderRow.getId(), String.valueOf(orderRow.getValidCode()));
|
||||||
//logger.info("订单状态:{} 订单号:{} sku:{}", orderRow.getValidCode(), orderRow.getOrderId(), orderRow.getSkuName());
|
|
||||||
|
if (!newProPriceAmount.equals(0.0)){
|
||||||
|
String oldProPriceAmount = redisTemplate.opsForValue().get(ORDER_ROW_JB_KEY + orderRow.getId());
|
||||||
|
if (Util.isNotEmpty(oldProPriceAmount)) {
|
||||||
|
if (!oldProPriceAmount.equals(newProPriceAmount.toString())) {
|
||||||
|
String wxId = getWxidFromJdid(orderRow.getUnionId().toString());
|
||||||
|
if (Util.isNotEmpty(wxId)) {
|
||||||
|
String content = getFormattedOrderInfo(orderRow);
|
||||||
|
wxUtil.sendTextMessage(wxId, "[Broken] [Broken] [Broken] 价保提醒 [Broken] [Broken] [Broken] " + newProPriceAmount + "\n" + content, 1, wxId, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 不管价保与否,都要写入redis
|
||||||
|
redisTemplate.opsForValue().set(ORDER_ROW_JB_KEY + orderRow.getId(), "0.0");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +157,7 @@ public class OrderUtil {
|
|||||||
/**
|
/**
|
||||||
* 将数据库订单转化成微信所需要文本
|
* 将数据库订单转化成微信所需要文本
|
||||||
*/
|
*/
|
||||||
public String getFormattedOrderInfo(OrderRow orderRow, Integer oldValidCode) {
|
public String getFormattedOrderInfo(OrderRow orderRow) {
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
ValidCodeConverter converter = new ValidCodeConverter();
|
ValidCodeConverter converter = new ValidCodeConverter();
|
||||||
Long unionId = orderRow.getUnionId();
|
Long unionId = orderRow.getUnionId();
|
||||||
|
|||||||
Reference in New Issue
Block a user