From 955b922aa4278a0f79247ee240584d599efb795b Mon Sep 17 00:00:00 2001 From: = <=> Date: Tue, 1 Jun 2021 00:38:44 +0800 Subject: [PATCH 1/3] =?UTF-8?q?'=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/cweb/config/AuthConfig.java | 1 + .../com/cweb/controller/WechatController.java | 4 +++ .../cweb/controller/pay/OrderController.java | 27 ++++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java index 064875c4..b0c9c921 100644 --- a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -107,6 +107,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/user/login") .excludePathPatterns("/user/getUnionId") .excludePathPatterns("/order/orderToH5Pay") + .excludePathPatterns("/order/orderToPay") .excludePathPatterns("/wechat/*") ; } diff --git a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java index bef1c632..dbb373cb 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java @@ -271,6 +271,8 @@ public class WechatController { public ResponseData getH5UserInfo(@RequestParam(value = "code", required = true) String code, HttpServletRequest request, HttpServletResponse response) { try { + + System.out.println("--------------获取access_token-----------------------"); // 获取access_token Map params = new HashMap<>(); params.put("appid", SysConst.getSysConfig().getWxH5AppId()); @@ -278,6 +280,8 @@ public class WechatController { params.put("code", code); params.put("grant_type", "authorization_code"); JSONObject jsonObject = HttpsUtils.doGet("https://api.weixin.qq.com/sns/oauth2/access_token", params); + System.out.println(jsonObject.toJSONString()); + System.out.println("-----------------获取access_token--------------------"); String accessToken = jsonObject.getString("access_token"); String openid = jsonObject.getString("openid"); if (StringUtils.isBlank(accessToken) || StringUtils.isBlank(openid)) { diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java index 1ba43b8d..4d051a3f 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java @@ -240,6 +240,31 @@ public class OrderController { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); }*/ + //微信支付 + String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8"); + //int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue(); + int total_fee = MathUtils.objectConvertBigDecimal(1).multiply(new BigDecimal("100")).intValue(); + WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo(); + weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxMchAppId()); //公众号id + weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号 + weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId()); //商户号 + weChatPayReqInfo.setSub_mch_id(SysConst.getSysConfig().getWxSubMchId()); //子商户号 + + weChatPayReqInfo.setNonce_str(nonce_str); //随机字符串 + weChatPayReqInfo.setBody("购买商品"); //商品描述 + weChatPayReqInfo.setOut_trade_no(String.valueOf(new Date().getTime())); //商户订单号 + weChatPayReqInfo.setTotal_fee(total_fee); //总金额 + weChatPayReqInfo.setSpbill_create_ip("139.159.177.244"); //终端ip + weChatPayReqInfo.setNotify_url(SysConst.getSysConfig().getNotifyUrl()); //通知url + weChatPayReqInfo.setTrade_type("MWEB"); //交易类型 + //weChatPayReqInfo.setAttach(map.get("orderScene").toString()); //附加数据,区分订单类型 + Map payMap = new HashMap<>(); + payMap.put("app_id",SysConst.getSysConfig().getWxSubAppId()); + payMap.put("api_key",SysConst.getSysConfig().getWxApiKey()); + payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl()); + SortedMap sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap); + return ResponseMsgUtil.success(sortedMap); +/* Map param = new HashMap<>(); param.put("appid", SysConst.getSysConfig().getWxMchAppId()); param.put("mchid", SysConst.getSysConfig().getWxSubMchId()); @@ -266,7 +291,7 @@ public class OrderController { header.put("Authorization", "WECHATPAY2-SHA256-RSA2048 " + post); JSONObject object = HttpsUtils.doPost("https://api.mch.weixin.qq.com/v3/pay/transactions/h5", param, header); - return ResponseMsgUtil.success(object); + return ResponseMsgUtil.success(object);*/ } catch (Exception e) { log.error("orderToPay error!", e); return ResponseMsgUtil.exception(e); From 9bb30f4c537a66171bd770833f65ccd4595b980c Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 3 Jun 2021 20:57:20 +0800 Subject: [PATCH 2/3] =?UTF-8?q?'=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/cweb/controller/WechatController.java | 3 --- .../src/main/java/com/hai/schedule/SynchronizeCNPC.java | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java index dbb373cb..ed8f8b1a 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java @@ -272,7 +272,6 @@ public class WechatController { HttpServletRequest request, HttpServletResponse response) { try { - System.out.println("--------------获取access_token-----------------------"); // 获取access_token Map params = new HashMap<>(); params.put("appid", SysConst.getSysConfig().getWxH5AppId()); @@ -280,8 +279,6 @@ public class WechatController { params.put("code", code); params.put("grant_type", "authorization_code"); JSONObject jsonObject = HttpsUtils.doGet("https://api.weixin.qq.com/sns/oauth2/access_token", params); - System.out.println(jsonObject.toJSONString()); - System.out.println("-----------------获取access_token--------------------"); String accessToken = jsonObject.getString("access_token"); String openid = jsonObject.getString("openid"); if (StringUtils.isBlank(accessToken) || StringUtils.isBlank(openid)) { diff --git a/hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java b/hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java index acb28ed2..83bc9356 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java +++ b/hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java @@ -55,7 +55,7 @@ public class SynchronizeCNPC { String token = data.getString("token"); Calendar instance = Calendar.getInstance(); - instance.add(Calendar.MINUTE, -10); + instance.add(Calendar.MINUTE, -15); Map bodyMap = new HashMap<>(); bodyMap.put("appId", config.getAppId()); @@ -89,7 +89,6 @@ public class SynchronizeCNPC { } } } - log.error(object.toJSONString()); } } } From 19408e8ae599dfb080d3835119f0a60add27f3bd Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 7 Jun 2021 23:40:37 +0800 Subject: [PATCH 3/3] =?UTF-8?q?'=E4=BF=AE=E5=A4=8D=E5=B7=B2=E7=9F=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/cweb/controller/HighUserCommonController.java | 3 ++- .../com/hai/service/impl/HighCouponCodeServiceImpl.java | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighUserCommonController.java b/hai-cweb/src/main/java/com/cweb/controller/HighUserCommonController.java index f5a3e3a5..df26ce83 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighUserCommonController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighUserCommonController.java @@ -9,6 +9,7 @@ import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.*; +import com.hai.common.utils.IDGenerator; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.HighUser; import com.hai.model.HighUserModel; @@ -63,7 +64,7 @@ public class HighUserCommonController { HighUser user = highUserService.findByPhone(phone); if(user == null) { user = new HighUser(); - user.setName("用户" + System.currentTimeMillis()); + user.setName("用户" + IDGenerator.nextId(5)); user.setPhone(phone); user.setGold(0); user.setRegTime(new Date()); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java index 860b4254..cc457746 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java @@ -131,7 +131,7 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { userCoupon.setConsumeTime(new Date()); userCoupon.setStatus(2); // 状态 0:已过期 1:未使用 2:已使用 highUserCouponService.updateUserCoupon(userCoupon); - highOrderService.childOrderComplete(order.getId()); + //highOrderService.childOrderComplete(order.getId()); } } @@ -165,12 +165,12 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { userCoupon.setStatus(2); // 状态 0:已过期 1:未使用 2:已使用 highUserCouponService.updateUserCoupon(userCoupon); - HighChildOrderExample example = new HighChildOrderExample(); +/* HighChildOrderExample example = new HighChildOrderExample(); example.createCriteria().andMemIdEqualTo(userCoupon.getUserId()).andGoodsTypeEqualTo(1).andGoodsIdEqualTo(userCoupon.getCouponId()).andChildOrdeStatusEqualTo(2); List childOrderList = highChildOrderMapper.selectByExample(example); if (childOrderList.size() > 0) { highOrderService.childOrderComplete(childOrderList.get(0).getId()); - } + }*/ /*HighChildOrder order = highOrderService.getChildOrderByUserGoods(userCoupon.getUserId(), 1, userCoupon.getCouponId()); if (order == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单");