diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index b146960..0f03308 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -1897,6 +1897,16 @@ public class PayService { public Result createOrder(String ip,String userId,String payType,String shopId,BigDecimal amount) throws JsonProcessingException { + if(ObjectUtil.isNull(userId)||ObjectUtil.isEmpty(userId)||ObjectUtil.isEmpty(payType)||ObjectUtil.isNull(payType) + + ||ObjectUtil.isNull(shopId)||ObjectUtil.isEmpty(shopId)||ObjectUtil.isNull(shopId)||ObjectUtil.isNull(amount)||ObjectUtil.isEmpty(amount) + ){ + return Result.fail(CodeEnum.PARAM); + } + + if(!"WECHAT".equals(payType)||!"ALIPAY".equals(payType)){ + return Result.fail(CodeEnum.PARAM); + } TbShopInfo shopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId)); if(ObjectUtil.isNull(shopInfo)){ diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/WechatUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/WechatUtil.java index 2a389ce..6bb4a48 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/WechatUtil.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/WechatUtil.java @@ -104,7 +104,7 @@ public class WechatUtil { public static JSONObject getSessionKeyOrOpenId(String code, String appId, String secrete) { - String requestUrl = "https://api.weixin.qq.com/sns/jscode2session"; + String requestUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?"; Map requestUrlParam = new HashMap<>(); // https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN //小程序appId @@ -112,10 +112,11 @@ public class WechatUtil { //小程序secret requestUrlParam.put("secret", secrete); //小程序端返回的code - requestUrlParam.put("js_code", code); + requestUrlParam.put("code", code); //默认参数 requestUrlParam.put("grant_type", "authorization_code"); //发送post请求读取调用微信接口获取openid用户唯一标识 + log.info("请求参数:{}",JSONUtil.toJSONString(requestUrlParam)); JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doPost(requestUrl,requestUrlParam)); return jsonObject; }