微信小程序订阅消息回调支持body回传

This commit is contained in:
liyj 2025-09-23 17:21:59 +08:00
parent 0ac51a5119
commit a2cda4e494
3 changed files with 14 additions and 10 deletions

View File

@ -148,10 +148,13 @@ public class WeiXinController extends BaseControllerImpl {
public String xcxCallBack(@RequestParam(value = "signature",required = false) String signature, public String xcxCallBack(@RequestParam(value = "signature",required = false) String signature,
@RequestParam(value = "timestamp",required = false) String timestamp, @RequestParam(value = "timestamp",required = false) String timestamp,
@RequestParam(value = "nonce",required = false) String nonce, @RequestParam(value = "nonce",required = false) String nonce,
@RequestParam(value = "echostr",required = false) String echostr) { @RequestParam(value = "echostr",required = false) String echostr,
@RequestBody JSONObject jsonObject) {
boolean checked=weiXinService.checkSignature(timestamp, nonce, signature); boolean checked=weiXinService.checkSignature(timestamp, nonce, signature);
if(checked){ if(checked){
accountUserBindConnectService.bindTmplId(echostr); if(null!=jsonObject){
accountUserBindConnectService.bindTmplId(jsonObject);
}
return echostr; return echostr;
} }
return "fail"; return "fail";

View File

@ -93,5 +93,5 @@ public interface AccountUserBindConnectService extends IBaseService<AccountUserB
long getAllBindCount(Integer bind_type,String bindTmpl); long getAllBindCount(Integer bind_type,String bindTmpl);
void bindTmplId(String jsonObjectStr); void bindTmplId(JSONObject jsonObject);
} }

View File

@ -528,13 +528,14 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
@Override @Override
@Async @Async
public void bindTmplId(String jsonObjectStr) { public void bindTmplId(JSONObject jsonObject) {
JSONObject jsonObject= null; // JSONObject jsonObject= null;
try { // try {
jsonObject= JSONUtil.parseObj(jsonObjectStr); // jsonObject= JSONUtil.parseObj(jsonObjectStr);
}catch (RuntimeException e) { // }catch (RuntimeException e) {
log.info("错误信息--{}",e.getMessage()); // log.info("错误信息--{}",e.getMessage());
} // }
log.info("jsonObject:{}", jsonObject);
String openId=jsonObject.getStr("FromUserName");//用户openid String openId=jsonObject.getStr("FromUserName");//用户openid
QueryWrapper<AccountUserBindConnect> queryWrapper = new QueryWrapper<>(); QueryWrapper<AccountUserBindConnect> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("bind_id",openId) queryWrapper.eq("bind_id",openId)