From 897d625f6f7fafb68b3cbe21c375ded276754546 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Fri, 10 Sep 2021 17:42:17 +0800 Subject: [PATCH 1/3] =?UTF-8?q?'=E4=BF=AE=E5=A4=8D=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E9=97=AE=E9=A2=98'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cweb/controller/WechatController.java | 25 +++++++++++++------ .../com/hai/common/exception/ErrorCode.java | 2 +- .../impl/HighDiscountAgentRelServiceImpl.java | 2 +- 3 files changed, 19 insertions(+), 10 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 13338fc3..250a016b 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java @@ -17,6 +17,7 @@ import com.hai.common.exception.SysCode; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.HttpsUtils; +import com.hai.common.utils.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.HighUser; import com.hai.model.HighUserModel; @@ -48,6 +49,8 @@ public class WechatController { private static final Logger log = LoggerFactory.getLogger(WechatController.class); + private static final String WX_OPENID_SESSION_REDIS = "WX_OPENID_SESSION_REDIS"; + @Autowired private UserCenter userCenter; @@ -57,13 +60,15 @@ public class WechatController { @Resource private HighUserPayPasswordService highUserPayPasswordService; + @Resource + private RedisUtil redisUtil; + @RequestMapping(value = "/handleCode", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "小程序code解析") public ResponseData compairCode(@RequestParam(value = "code", required = true) String code, HttpServletRequest request, HttpServletResponse response) { try { - //校验code,openId不能同时为空 if (StringUtils.isEmpty(code)) { throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.REQ_PARAMS_ERROR, ""); @@ -72,7 +77,7 @@ public class WechatController { final WxMaService wxService = WxMaConfiguration.getMaService(); WxMaJscode2SessionResult session = wxService.jsCode2SessionInfo(code); //保存小程序用户登录的openId及sessionKey信息 - SessionKeyCache.setData(session.getOpenid(), session, -1); + redisUtil.hset(WX_OPENID_SESSION_REDIS,session.getOpenid(),session); JSONObject jo = new JSONObject(); jo.put("openId", session.getOpenid()); return ResponseMsgUtil.success(jo); @@ -87,7 +92,6 @@ public class WechatController { public ResponseData login(@RequestParam(value = "openId", required = true) String openId, HttpServletRequest request, HttpServletResponse response) { try { - //校验code,openId不能同时为空 if (StringUtils.isEmpty(openId)) { throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.REQ_PARAMS_ERROR, ""); @@ -130,10 +134,13 @@ public class WechatController { throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.REQ_PARAMS_ERROR, ""); } //请求微信api,获取用户session_key以及openId - WxMaJscode2SessionResult session = SessionKeyCache.getData(openId); + Object skObject = redisUtil.hget(WX_OPENID_SESSION_REDIS,openId); + if (skObject == null){ + throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_LOGIN_ERROR); + } + WxMaJscode2SessionResult session = (WxMaJscode2SessionResult)skObject; final WxMaService wxService = WxMaConfiguration.getMaService(); - WxMaPhoneNumberInfo phoneNoInfo = wxService.getUserService().getPhoneNoInfo(session.getSessionKey(), encryptedData, iv); if (phoneNoInfo == null || StringUtils.isEmpty(phoneNoInfo.getPurePhoneNumber())) { throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_DECRYPT_ERROR, "用户phoneNumber解析失败"); @@ -174,12 +181,14 @@ public class WechatController { throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.REQ_PARAMS_ERROR, ""); } //请求微信api,获取用户session_key以及openId - WxMaJscode2SessionResult session = SessionKeyCache.getData(openId); - System.out.println(JSONObject.toJSONString(session)); + Object skObject = redisUtil.hget(WX_OPENID_SESSION_REDIS,openId); + if (skObject == null){ + throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_LOGIN_ERROR); + } + WxMaJscode2SessionResult session = (WxMaJscode2SessionResult)skObject; final WxMaService wxService = WxMaConfiguration.getMaService(); WxMaUserInfo userInfo = wxService.getUserService().getUserInfo(session.getSessionKey(), encryptedData, iv); - if (userInfo == null) { throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_DECRYPT_ERROR, "用户phoneNumber解析失败"); } diff --git a/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java b/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java index b8b7ac01..32c3c93b 100644 --- a/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java +++ b/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java @@ -23,7 +23,7 @@ public enum ErrorCode { //////////////////APP/////////////// WECHAT_DECRYPT_ERROR("3001","微信解密错误->%s"), - WECHAT_LOGIN_ERROR("3002","当前微信用户不是学员,请联系老师"), + WECHAT_LOGIN_ERROR("3002","微信登录失败"), WECHAT_LOGIN_TEACHER_ERROR("3003","当前微信用户不是老师,请联系管理员"), //////////////////业务异常///////////// diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentRelServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentRelServiceImpl.java index 4c3c09a1..2fc5ce89 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentRelServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentRelServiceImpl.java @@ -42,7 +42,7 @@ public class HighDiscountAgentRelServiceImpl implements HighDiscountAgentRelServ private HighDiscountAgentCodeService highDiscountAgentCodeService; @Override - @Transactional(propagation= Propagation.REQUIRES_NEW) + @Transactional(propagation= Propagation.REQUIRED) public void insertDiscountAgentRel(HighDiscountAgentRel highDiscountAgentRel,Integer stockCount) throws Exception { if (highDiscountAgentRel.getId() != null) { highDiscountAgentRelMapper.updateByPrimaryKey(highDiscountAgentRel); From 9936341e062211f14f6630a45169a4d108aef6e2 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 13 Sep 2021 10:06:33 +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/resources/pre/commonConfig.properties | 10 +++++----- .../main/resources/prod-9401/commonConfig.properties | 8 ++++---- .../src/main/resources/prod/commonConfig.properties | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/hai-service/src/main/resources/pre/commonConfig.properties b/hai-service/src/main/resources/pre/commonConfig.properties index 66282e2f..38d2dccc 100644 --- a/hai-service/src/main/resources/pre/commonConfig.properties +++ b/hai-service/src/main/resources/pre/commonConfig.properties @@ -10,13 +10,13 @@ qinzhuPlatformId=10376 qinzhuSecret=ktxb49sh2jfhgn8g qianzhuOrderNotify=https://hsg.dctpay.com/crest/qianzhu/orderNotify -huiliantongUrl=https://gzapitest.deepermobile.com.cn:441 -huiliantongAppNo=guizhouhltcs -huiliantongAppkey=g%2BNnjR54YSUWM2iKg%2Fd82A9x9hg2kYV7 -huiliantongAppsecret=FA28E95ACABFA4B2B8E25857437B07F1 +huiliantongUrl=https://gzapi.deepermobile.com.cn +huiliantongAppNo=guizhouhuilt +huiliantongAppkey=e0ja2Ex%2BmQ2hIPF6x%2BHA%3D +huiliantongAppsecret=52662415DDCE55C7BA34223BCF53877A wx_cert=/home/project/wx_cert/ TelApiKey=2d01f6b520254b1a80f6b167832cea18 TelApiSecret=d11ee9b41e014a039f030e53ae6f5295 -TelMemberId=d13091df65d64aafbf0f35d2093157b7 \ No newline at end of file +TelMemberId=d13091df65d64aafbf0f35d2093157b7 diff --git a/hai-service/src/main/resources/prod-9401/commonConfig.properties b/hai-service/src/main/resources/prod-9401/commonConfig.properties index e786a840..67ef83f0 100644 --- a/hai-service/src/main/resources/prod-9401/commonConfig.properties +++ b/hai-service/src/main/resources/prod-9401/commonConfig.properties @@ -10,10 +10,10 @@ qinzhuPlatformId=10458 qinzhuSecret=nnl3gg4ss0pka11t qianzhuOrderNotify=https://hsg.dctpay.com/crest/qianzhu/orderNotify -huiliantongUrl=https://gzapitest.deepermobile.com.cn:441 -huiliantongAppNo=guizhouhltcs -huiliantongAppkey=g%2BNnjR54YSUWM2iKg%2Fd82A9x9hg2kYV7 -huiliantongAppsecret=FA28E95ACABFA4B2B8E25857437B07F1 +huiliantongUrl=https://gzapi.deepermobile.com.cn +huiliantongAppNo=guizhouhuilt +huiliantongAppkey=e0ja2Ex%2BmQ2hIPF6x%2BHA%3D +huiliantongAppsecret=52662415DDCE55C7BA34223BCF53877A wx_cert=/home/project/wx_cert/ diff --git a/hai-service/src/main/resources/prod/commonConfig.properties b/hai-service/src/main/resources/prod/commonConfig.properties index e786a840..67ef83f0 100644 --- a/hai-service/src/main/resources/prod/commonConfig.properties +++ b/hai-service/src/main/resources/prod/commonConfig.properties @@ -10,10 +10,10 @@ qinzhuPlatformId=10458 qinzhuSecret=nnl3gg4ss0pka11t qianzhuOrderNotify=https://hsg.dctpay.com/crest/qianzhu/orderNotify -huiliantongUrl=https://gzapitest.deepermobile.com.cn:441 -huiliantongAppNo=guizhouhltcs -huiliantongAppkey=g%2BNnjR54YSUWM2iKg%2Fd82A9x9hg2kYV7 -huiliantongAppsecret=FA28E95ACABFA4B2B8E25857437B07F1 +huiliantongUrl=https://gzapi.deepermobile.com.cn +huiliantongAppNo=guizhouhuilt +huiliantongAppkey=e0ja2Ex%2BmQ2hIPF6x%2BHA%3D +huiliantongAppsecret=52662415DDCE55C7BA34223BCF53877A wx_cert=/home/project/wx_cert/ From fe430eb040a3356e9053be7c8b4a093e1de0ff13 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 13 Sep 2021 10:38:35 +0800 Subject: [PATCH 3/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/resources/pre/application.yml | 2 +- .../src/main/resources/pre/application.yml | 4 ++-- .../resources/pre/commonConfig.properties | 20 +++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/hai-bweb/src/main/resources/pre/application.yml b/hai-bweb/src/main/resources/pre/application.yml index f446e073..4c2e5f66 100644 --- a/hai-bweb/src/main/resources/pre/application.yml +++ b/hai-bweb/src/main/resources/pre/application.yml @@ -28,7 +28,7 @@ spring: poolPreparedStatements: true maxOpenPreparedStatements: 20 redis: - database: 0 + database: 1 host: 139.159.177.244 port: 36379 password: HF123456.Redis diff --git a/hai-cweb/src/main/resources/pre/application.yml b/hai-cweb/src/main/resources/pre/application.yml index 2145d8a7..1012ea5c 100644 --- a/hai-cweb/src/main/resources/pre/application.yml +++ b/hai-cweb/src/main/resources/pre/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://122.9.135.148:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://139.159.177.244:3306/hsg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource @@ -28,7 +28,7 @@ spring: poolPreparedStatements: true maxOpenPreparedStatements: 20 redis: - database: 0 + database: 1 host: 139.159.177.244 port: 36379 password: HF123456.Redis diff --git a/hai-service/src/main/resources/pre/commonConfig.properties b/hai-service/src/main/resources/pre/commonConfig.properties index 38d2dccc..3453fac9 100644 --- a/hai-service/src/main/resources/pre/commonConfig.properties +++ b/hai-service/src/main/resources/pre/commonConfig.properties @@ -1,14 +1,14 @@ -tuanYouUrl=https://test02-motorcade-hcs.czb365.com -tuanYouAppKey=208241666939552 -tuanYouAppSecret=adecc3cff077834cb8632c8ab3bec0e6 -tuanYouDieselAccount=9b115eao4400 -tuanYouGasolineAccount=9b115e5g4400 +tuanYouUrl=https://hcs.czb365.com +tuanYouAppKey=210091174083104 +tuanYouAppSecret=f9811df6791d309bf48f4a8db9edaa45 +tuanYouDieselAccount=9hp52qgg4400 +tuanYouGasolineAccount=9hp52qf04400 -qinzhuUrl=https://live-test.qianzhu8.com -qinzhuHtmlUrl=https://m-test.qianzhu8.com -qinzhuPlatformId=10376 -qinzhuSecret=ktxb49sh2jfhgn8g -qianzhuOrderNotify=https://hsg.dctpay.com/crest/qianzhu/orderNotify +qinzhuUrl=https://live.qianzhu8.com +qinzhuHtmlUrl=https://qz.dctpay.com +qinzhuPlatformId=10458 +qinzhuSecret=nnl3gg4ss0pka11t +qianzhuOrderNotify=https://hsgcs.dctpay.com/crest/qianzhu/orderNotify huiliantongUrl=https://gzapi.deepermobile.com.cn huiliantongAppNo=guizhouhuilt