录单+价保
This commit is contained in:
@@ -262,6 +262,7 @@ public class JDUtil {
|
||||
content.append("七日订单\r");
|
||||
content.append("刷新7天\r");
|
||||
|
||||
|
||||
contents.add(content);
|
||||
content = new StringBuilder();
|
||||
|
||||
@@ -279,10 +280,25 @@ public class JDUtil {
|
||||
//
|
||||
//contents.add(content);
|
||||
break;
|
||||
case "测试指令": {
|
||||
//test01();
|
||||
case "价保": {
|
||||
// 获取过去30天内的订单
|
||||
List<OrderRow> last30DaysOrders = filterOrdersByDate(orderRows, 30);
|
||||
|
||||
// 过滤出 proPriceAmount 大于 0 的订单
|
||||
List<OrderRow> priceProtectedOrders = last30DaysOrders.stream().filter(orderRow -> orderRow.getProPriceAmount() > 0).collect(Collectors.toList());
|
||||
|
||||
if (!priceProtectedOrders.isEmpty()) {
|
||||
//调用 orderUtil.orderToWx(orderRow, true);
|
||||
|
||||
// 可选:发送具体的订单信息给用户
|
||||
orderUtil.orderToWxBatch(priceProtectedOrders);
|
||||
} else {
|
||||
wxUtil.sendTextMessage(fromWxid, "没有找到符合条件的价保订单。", 1, fromWxid, false);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case "今日统计": {
|
||||
// 订单总数,已付款,已取消,佣金总计
|
||||
List<OrderRow> todayOrders = filterOrdersByDate(orderRows, 0);
|
||||
@@ -1345,13 +1361,13 @@ public class JDUtil {
|
||||
* 因为在这里转链返回,没有什么意义,后面走转链不转链,会重新发方案
|
||||
* */
|
||||
StringBuilder wenan = new StringBuilder();
|
||||
if (isCj){
|
||||
if (isCj) {
|
||||
// 完成转链后替换链接为u.jd.com链接
|
||||
for (HashMap<String, String> stringStringHashMap : resultList) {
|
||||
String transferUrl = transfer(stringStringHashMap.get("materialUrl"), null);
|
||||
wenan = new StringBuilder(message.replace(stringStringHashMap.get("url"), transferUrl));
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
wenan = new StringBuilder().append(format).append(FANAN_COMMON).append(message);
|
||||
}
|
||||
|
||||
@@ -1614,9 +1630,7 @@ public class JDUtil {
|
||||
wxUtil.sendTextMessage(fromWxid, "添加型号格式错误,请输入正确的格式:添加型号-型号名称-型号SKU", 1, fromWxid, false);
|
||||
}
|
||||
return;
|
||||
}else if (
|
||||
order.startsWith("删除型号")
|
||||
){
|
||||
} else if (order.startsWith("删除型号")) {
|
||||
String replace = order.replace("删除型号-", "");
|
||||
String[] split = replace.split("-");
|
||||
if (split.length == 1) {
|
||||
@@ -1655,9 +1669,7 @@ public class JDUtil {
|
||||
productTypeMap.put(entry.getKey().toString(), entry.getValue().toString());
|
||||
}
|
||||
// 排序
|
||||
productTypeMap = productTypeMap.entrySet().stream()
|
||||
.sorted(Map.Entry.comparingByKey())
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
|
||||
productTypeMap = productTypeMap.entrySet().stream().sorted(Map.Entry.comparingByKey()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
|
||||
} else {
|
||||
logger.warn("Redis 中未找到键为 {} 的 Hash 数据", PRODUCT_TYPE_MAP_PREFIX);
|
||||
}
|
||||
@@ -1666,6 +1678,7 @@ public class JDUtil {
|
||||
public void addProductTypeMap(String key, String value) {
|
||||
redisTemplate.opsForHash().put(PRODUCT_TYPE_MAP_PREFIX, key, value);
|
||||
}
|
||||
|
||||
public void delProductTypeMap(String key) {
|
||||
redisTemplate.opsForHash().delete(PRODUCT_TYPE_MAP_PREFIX, key);
|
||||
}
|
||||
@@ -1894,15 +1907,18 @@ public class JDUtil {
|
||||
}
|
||||
|
||||
public void LD(String input, String fromWxid) {
|
||||
JDOrder jdOrder = parseOrderFromText(input.trim());
|
||||
if (jdOrder.getOrderId() == null){
|
||||
JDOrder jdOrder = parseOrderFromText(input.trim().replace("元", ""));
|
||||
if (jdOrder.getOrderId() == null) {
|
||||
return;
|
||||
}
|
||||
if (Util.isAnyEmpty(jdOrder.getOrderId(), jdOrder.getBuyer(), jdOrder.getOrderTime(), jdOrder.getPaymentAmount(), jdOrder.getRebateAmount(), jdOrder.getAddress(), jdOrder.getLogisticsLink(), jdOrder.getModelNumber(), jdOrder.getLink(), jdOrder.getOrderId(), jdOrder.getBuyer())) {
|
||||
return;
|
||||
}
|
||||
JDOrder byOrderId = jdOrderRepository.findByOrderId(jdOrder.getOrderId());
|
||||
if (byOrderId != null){
|
||||
if (byOrderId != null) {
|
||||
logger.info("订单已存在:{}", byOrderId);
|
||||
jdOrder.setId(byOrderId.getId());
|
||||
}else {
|
||||
} else {
|
||||
logger.info("订单不存在,新增:{}", jdOrder);
|
||||
}
|
||||
jdOrderRepository.save(jdOrder);
|
||||
@@ -1912,19 +1928,21 @@ public class JDUtil {
|
||||
// 从jdOrder中获取转化
|
||||
String distributionMark = jdOrder.getDistributionMark();
|
||||
String distributionMark2 = "";
|
||||
if (distributionMark != null){
|
||||
if (distributionMark.startsWith("H")){
|
||||
if (distributionMark != null) {
|
||||
if (distributionMark.startsWith("H")) {
|
||||
distributionMark2 = "鸿";
|
||||
} else if (distributionMark.startsWith("F")) {
|
||||
distributionMark2 = "凡";
|
||||
}
|
||||
}
|
||||
sb.append(jdOrder.getRemark()).append(" ").append(jdOrder.getOrderId()).append(" ").append(jdOrder.getModelNumber()).append(" ")
|
||||
.append(jdOrder.getAddress()).append(" ").append(jdOrder.getLogisticsLink()).append(" ")
|
||||
.append(jdOrder.getBuyer()).append(" ").append(jdOrder.getPaymentAmount()).append(" ")
|
||||
.append(distributionMark2);
|
||||
sb.append(jdOrder.getRemark()).append(" ").append(jdOrder.getOrderId()).append(" ").append(jdOrder.getModelNumber()).append(" ").append(jdOrder.getAddress()).append(" ").append(jdOrder.getLogisticsLink()).append(" ").append(jdOrder.getBuyer()).append(" ").append(jdOrder.getPaymentAmount()).append(" ").append(distributionMark2);
|
||||
logger.info("订单信息:{}", sb);
|
||||
wxUtil.sendTextMessage(WX_BASE_URL, sb.toString(), 1, fromWxid, false);
|
||||
if (fromWxid.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
wxUtil.sendTextMessage(fromWxid, "解析成功", 1, null, true);
|
||||
wxUtil.sendTextMessage(fromWxid, sb.toString(), 1, null, true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class OrderUtil {
|
||||
* 手动调用 将订单发送到微信
|
||||
*/
|
||||
@Async("threadPoolTaskExecutor")
|
||||
public void orderToWx(OrderRow orderRow, Boolean isAutoFlush) {
|
||||
public void orderToWx(OrderRow orderRow, Boolean isAutoFlush, Boolean isAutoFlushJB) {
|
||||
try {
|
||||
// 获取订单当前状态
|
||||
Integer newValidCode = orderRow.getValidCode();
|
||||
@@ -68,7 +68,7 @@ public class OrderUtil {
|
||||
|
||||
if (Util.isNotEmpty(wxId)) {
|
||||
wxUtil.sendTextMessage(wxId, content, 1, wxId, true);
|
||||
if (newValidCode != 17){
|
||||
if (newValidCode != 17) {
|
||||
// 发送今日统计信息
|
||||
sendDailyStats(wxId);
|
||||
}
|
||||
@@ -89,6 +89,9 @@ public class OrderUtil {
|
||||
// 判断是否需要发送通知:金额不为零且金额变化了或者未发送过通知
|
||||
boolean shouldNotify = newProPriceAmount.compareTo(BigDecimal.ZERO) > 0 && (newProPriceAmount.compareTo(oldProPriceAmount) != 0 || !hasNotified);
|
||||
|
||||
if (isAutoFlushJB) {
|
||||
shouldNotify = true;
|
||||
}
|
||||
if (shouldNotify) {
|
||||
String wxId = getWxidFromJdid(orderRow.getUnionId().toString());
|
||||
if (Util.isNotEmpty(wxId)) {
|
||||
@@ -100,8 +103,10 @@ public class OrderUtil {
|
||||
wxUtil.sendTextMessage(wxId, alertMsg, 1, wxId, true);
|
||||
|
||||
// 通知成功后更新Redis,格式为 "金额:true"
|
||||
String newRedisValue = newProPriceAmount + ":true";
|
||||
redisTemplate.opsForValue().set(redisKey, newRedisValue);
|
||||
if (!isAutoFlushJB) {
|
||||
String newRedisValue = newProPriceAmount + ":true";
|
||||
redisTemplate.opsForValue().set(redisKey, newRedisValue);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("发送价保通知失败: {}", e.getMessage(), e);
|
||||
// 通知失败,不更新Redis,下次继续尝试
|
||||
@@ -208,6 +213,7 @@ public class OrderUtil {
|
||||
|
||||
return orderInfo.toString();
|
||||
}
|
||||
|
||||
// 价保
|
||||
public String getFormattedOrderInfoForJB(OrderRow orderRow) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
@@ -225,8 +231,7 @@ public class OrderUtil {
|
||||
|
||||
orderInfo
|
||||
//+ "订单+sku:" + orderRow.getId() + "\r"
|
||||
.append("京粉:").append(remarkFromJdid).append("\r").append("订单:").append(orderRow.getOrderId()).append(" (").append(orderRow.getPlus() == 1 ? "plus" : "非plus").append(")\r").append("名称:").append(orderRow.getSkuName()).append("\r").append("\r")
|
||||
.append("下单:").append(formatter.format(orderRow.getOrderTime())).append("\r").append("完成:").append(orderRow.getFinishTime() != null ? formatter.format(orderRow.getFinishTime()) : "未完成");
|
||||
.append("京粉:").append(remarkFromJdid).append("\r").append("订单:").append(orderRow.getOrderId()).append(" (").append(orderRow.getPlus() == 1 ? "plus" : "非plus").append(")\r").append("名称:").append(orderRow.getSkuName()).append("\r").append("\r").append("下单:").append(formatter.format(orderRow.getOrderTime())).append("\r").append("完成:").append(orderRow.getFinishTime() != null ? formatter.format(orderRow.getFinishTime()) : "未完成");
|
||||
|
||||
return orderInfo.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user