master
parent
8b249f37a0
commit
835417024c
|
|
@ -32,8 +32,8 @@ public class WechatTemplateMessageController {
|
||||||
* key
|
* key
|
||||||
*/
|
*/
|
||||||
@GetMapping("/key")
|
@GetMapping("/key")
|
||||||
public R<?> key() {
|
public R<?> key(@RequestParam String code) {
|
||||||
return R.success(wechatTemplateMessageService.key());
|
return R.success(wechatTemplateMessageService.key(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/send-order-notice")
|
@PostMapping("/send-order-notice")
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ public interface WechatTemplateMessageService {
|
||||||
|
|
||||||
void bind(String code);
|
void bind(String code);
|
||||||
|
|
||||||
Map<String, Object> key();
|
Map<String, Object> key(String code);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送消息
|
* 发送消息
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ public class WechatTemplateMessageServiceImpl implements WechatTemplateMessageSe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> key() {
|
public Map<String, Object> key(String code) {
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
// 1. 获取Access Token
|
// 1. 获取Access Token
|
||||||
String accessToken = getAccessToken();
|
String accessToken = getAccessToken();
|
||||||
|
|
@ -91,7 +91,9 @@ public class WechatTemplateMessageServiceImpl implements WechatTemplateMessageSe
|
||||||
String timestamp = Long.toString(System.currentTimeMillis() / 1000); // 必填,生成签名的时间戳
|
String timestamp = Long.toString(System.currentTimeMillis() / 1000); // 必填,生成签名的时间戳
|
||||||
String nonceStr = UUID.randomUUID().toString().replaceAll("-", ""); // 必填,生成签名的随机串
|
String nonceStr = UUID.randomUUID().toString().replaceAll("-", ""); // 必填,生成签名的随机串
|
||||||
// 注意这里参数名必须全部小写,且必须有序
|
// 注意这里参数名必须全部小写,且必须有序
|
||||||
String signature = getSignature(jsapi_ticket, timestamp, nonceStr, WxApiConfig.REDIRECT_URI);
|
String url = WxApiConfig.REDIRECT_URI + "?code=" + code + "&state=STATE";
|
||||||
|
log.info("url: " + url);
|
||||||
|
String signature = getSignature(jsapi_ticket, timestamp, nonceStr, url);
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("appId", WxApiConfig.APP_ID);
|
map.put("appId", WxApiConfig.APP_ID);
|
||||||
map.put("timestamp", timestamp);
|
map.put("timestamp", timestamp);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue