1.模板消息负值不推送问题修复

This commit is contained in:
SongZhang 2024-07-25 17:02:14 +08:00
parent 14f9f36ef5
commit 839a7fe3a6
3 changed files with 6 additions and 4 deletions

View File

@ -129,7 +129,7 @@ public class ConsMsgConsumer {
log.info("开始推送耗材模板消息rediskey{}", value);
if (Objects.isNull(value)) {
JSONObject jsonObject = wxAccountUtil.sendStockWarnMsg("耗材库存不足", tbConsInfo.getConName(),
tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()).setScale(2, BigDecimal.ROUND_DOWN).toPlainString(), tbUserShopMsg.getOpenId());
tbConsInfo.getStockNumber().subtract(tbConsInfo.getStockConsume()).toBigInteger().intValue(), tbUserShopMsg.getOpenId());
if (jsonObject != null) {
log.info("写入redis:{}",key);
redisUtil.saveMessage(key, "1", 10 * 60);

View File

@ -281,7 +281,7 @@ public class OrderService {
List<TbShopOpenId> shopOpenIds = shopOpenIdMapper.selectByShopId(Integer.valueOf(product.getShopId()));
shopOpenIds.forEach(item -> {
wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(),
product.getIsDistribute() == 1 ? String.valueOf(product.getStockNumber()-num) : String.valueOf(productSku.getStockNumber() - num), item.getOpenId());
product.getIsDistribute() == 1 ? product.getStockNumber()-num : (int) (productSku.getStockNumber() - num), item.getOpenId());
});
}
}

View File

@ -97,7 +97,9 @@ public class WxAccountUtil {
throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误"));
}
public JSONObject sendStockWarnMsg(String shopName, String productName, String stock, String toUserOpenId) {
public JSONObject sendStockWarnMsg(String shopName, String productName, Integer stock, String toUserOpenId) {
stock = stock < 0 ? 0 : stock;
Integer finalStock = stock;
Map<String, Object> data = new HashMap<String, Object>() {{
put("thing22", new HashMap<String, Object>(){{
put("value", shopName);
@ -106,7 +108,7 @@ public class WxAccountUtil {
put("value", productName);
}});
put("number5", new HashMap<String, Object>(){{
put("value", stock);
put("value", finalStock);
}});
}};
log.info("开始发送库存预警消息, 接收用户openId: {}, 消息数据: {}", toUserOpenId, data);