解决微信推送服务器配置问题

This commit is contained in:
liyj 2025-09-20 10:15:36 +08:00
parent 338758884c
commit 8f4c981cb5
3 changed files with 9 additions and 14 deletions

View File

@ -145,22 +145,16 @@ public class WeiXinController extends BaseControllerImpl {
@ApiOperation(value = "小程序回调", notes = "小程序回调")
@RequestMapping(value = "/xcxCallBack", method = RequestMethod.GET)
public CommonResult 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 = "nonce",required = false) String nonce,
@RequestParam(value = "echostr",required = false) String echostr) {
if(StringUtils.isEmpty(signature) || StringUtils.isEmpty(timestamp) || StringUtils.isEmpty(nonce) || StringUtils.isEmpty(echostr) ) {
return CommonResult.success("校验成功");//todo 配置好消息链接改回来腾讯服务器测试提交没有发送参数导致报错
}
boolean checked=weiXinService.checkSignature(timestamp, nonce, signature);
if(checked){
return CommonResult.success("校验成功");
accountUserBindConnectService.bindTmplId(echostr);
return echostr;
}
if(!checked){
return CommonResult.failed("校验失败");
}
accountUserBindConnectService.bindTmplId(echostr);
return CommonResult.success("小程序订阅消息模板绑定成功");
return "fail";
}
}

View File

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

View File

@ -25,6 +25,7 @@ import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -526,12 +527,13 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
}
@Override
public boolean bindTmplId(String jsonObjectStr) {
@Async
public void bindTmplId(String jsonObjectStr) {
JSONObject jsonObject= null;
try {
jsonObject= JSONUtil.parseObj(jsonObjectStr);
}catch (RuntimeException e) {
throw new ApiException("非json数据");
log.info("错误信息--{}",e.getMessage());
}
String openId=jsonObject.getStr("FromUserName");//用户openid
QueryWrapper<AccountUserBindConnect> queryWrapper = new QueryWrapper<>();
@ -552,7 +554,6 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
}
}
}
return true;
}