This commit is contained in:
牛叉闪闪
2024-09-06 11:09:57 +08:00
parent b88c269a1a
commit 781570e2bf

View File

@@ -23,11 +23,11 @@ import java.util.Map;
@Component @Component
public class WxAccountUtil { public class WxAccountUtil {
@Value("${wx.ysk.appId}") @Value("${wx.ysk.appId}")
private static String appId = "wx212769170d2c6b2a"; private String appId = "wx212769170d2c6b2a";
@Value("${wx.ysk.secrete}") @Value("${wx.ysk.secrete}")
private static String secrete = "8492a7e8d55bbb1b57f5c8276ea1add0"; private String secrete = "8492a7e8d55bbb1b57f5c8276ea1add0";
@Value("${wx.ysk.warnMsgTmpId}") @Value("${wx.ysk.warnMsgTmpId}")
private static String msgTmpId = "C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0"; private String msgTmpId = "C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0";
private final TbShopMsgStateMapper shopMsgStateMapper; private final TbShopMsgStateMapper shopMsgStateMapper;
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>(); static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
@@ -49,7 +49,7 @@ public class WxAccountUtil {
// sendStockWarnMsg("13213", "31123", "234", "ojC-S6n2DDlpj52iVMoiLL0Ry4HI"); // sendStockWarnMsg("13213", "31123", "234", "ojC-S6n2DDlpj52iVMoiLL0Ry4HI");
} }
public static String getRadarQrCode(Integer shopId) { public String getRadarQrCode(Integer shopId) {
HashMap<String, Object> req = new HashMap<>(); HashMap<String, Object> req = new HashMap<>();
req.put("expire_seconds", 300); req.put("expire_seconds", 300);
req.put("action_name", "QR_STR_SCENE"); req.put("action_name", "QR_STR_SCENE");
@@ -70,7 +70,7 @@ public class WxAccountUtil {
} }
public static String getAccessToken() { public String getAccessToken() {
String resp = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", appId, secrete)); String resp = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", appId, secrete));
JSONObject respInfo = JSONObject.parseObject(resp); JSONObject respInfo = JSONObject.parseObject(resp);
if (!respInfo.containsKey("access_token")) { if (!respInfo.containsKey("access_token")) {
@@ -80,7 +80,7 @@ public class WxAccountUtil {
return respInfo.getString("access_token"); return respInfo.getString("access_token");
} }
public static JSONObject sendTemplateMsg(String templateId, String toUserOpenId, Map<String, Object> data) { public JSONObject sendTemplateMsg(String templateId, String toUserOpenId, Map<String, Object> data) {
log.info("开始发送微信模板消息, 接收用户openId: {}, 消息数据: {}", toUserOpenId, data); log.info("开始发送微信模板消息, 接收用户openId: {}, 消息数据: {}", toUserOpenId, data);
String accessToken = getAccessToken(); String accessToken = getAccessToken();