1.模板消息负值不推送
This commit is contained in:
@@ -483,7 +483,7 @@ public class CartService {
|
|||||||
String message = redisUtil.getMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId());
|
String message = redisUtil.getMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId());
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(),
|
wxAccountUtil.sendStockWarnMsg("商品库存不足", product.getName(),
|
||||||
product.getIsDistribute() == 1 ? String.valueOf(product.getStockNumber() - num) : String.valueOf(productSku.getStockNumber() - num)
|
product.getIsDistribute() == 1 ? product.getStockNumber() - num : (int) (productSku.getStockNumber() - num)
|
||||||
, item.getOpenId());
|
, item.getOpenId());
|
||||||
redisUtil.saveMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId(), product.getId().toString(), 60 * 30L);
|
redisUtil.saveMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId(), product.getId().toString(), 60 * 30L);
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class WxAccountUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
sendStockWarnMsg("13213", "31123", "234", "ojC-S6n2DDlpj52iVMoiLL0Ry4HI");
|
// sendStockWarnMsg("13213", "31123", "234", "ojC-S6n2DDlpj52iVMoiLL0Ry4HI");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRadarQrCode(Integer shopId) {
|
public static String getRadarQrCode(Integer shopId) {
|
||||||
@@ -98,7 +98,9 @@ public class WxAccountUtil {
|
|||||||
throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误"));
|
throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JSONObject sendStockWarnMsg(String shopName, String productName, String stock, String toUserOpenId) {
|
public static 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>() {{
|
Map<String, Object> data = new HashMap<String, Object>() {{
|
||||||
put("thing22", new HashMap<String, Object>(){{
|
put("thing22", new HashMap<String, Object>(){{
|
||||||
put("value", shopName);
|
put("value", shopName);
|
||||||
@@ -107,7 +109,7 @@ public class WxAccountUtil {
|
|||||||
put("value", productName);
|
put("value", productName);
|
||||||
}});
|
}});
|
||||||
put("number5", new HashMap<String, Object>(){{
|
put("number5", new HashMap<String, Object>(){{
|
||||||
put("value", stock);
|
put("value", finalStock);
|
||||||
}});
|
}});
|
||||||
}};
|
}};
|
||||||
log.info("开始发送库存预警消息, 接收用户openId: {}, 消息数据: {}", toUserOpenId, data);
|
log.info("开始发送库存预警消息, 接收用户openId: {}, 消息数据: {}", toUserOpenId, data);
|
||||||
|
|||||||
Reference in New Issue
Block a user