From ef04ce57881e6a338b10d596c5eb76b2220598bf Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期四, 31 八月 2023 11:16:49 +0800 Subject: [PATCH] 更新版本 --- user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java | 115 +++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 94 insertions(+), 21 deletions(-) diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java index facf287..77fea37 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java @@ -6,24 +6,27 @@ import com.supersavedriving.user.core.common.annotion.ServiceLog; import com.supersavedriving.user.core.util.ToolUtil; import com.supersavedriving.user.modular.system.model.AppUser; +import com.supersavedriving.user.modular.system.model.BranchOffice; import com.supersavedriving.user.modular.system.model.SystemConfig; import com.supersavedriving.user.modular.system.service.*; +import com.supersavedriving.user.modular.system.util.GaoDe.MapUtil; +import com.supersavedriving.user.modular.system.util.GaoDe.model.District; +import com.supersavedriving.user.modular.system.util.MallBook.model.InterfaceResponse; +import com.supersavedriving.user.modular.system.util.MallBook.util.RSASignature; import com.supersavedriving.user.modular.system.util.PayMoneyUtil; import com.supersavedriving.user.modular.system.util.RedisUtil; import com.supersavedriving.user.modular.system.util.ResultUtil; import com.supersavedriving.user.modular.system.util.UUIDUtil; import com.supersavedriving.user.modular.system.util.huawei.OBSUtil; import com.supersavedriving.user.modular.system.util.huawei.SMSUtil; +import com.supersavedriving.user.modular.system.util.weChat.WeChatUtil; import com.supersavedriving.user.modular.system.warpper.*; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; @@ -64,6 +67,33 @@ @Autowired private RedisUtil redisUtil; + @Autowired + private WeChatUtil weChatUtil; + + @Autowired + private IBranchOfficeService branchOfficeService; + + + + + + @ResponseBody + @PostMapping("/base/appUser/getUrlLink") +// @ServiceLog(name = "获取跳转微信url_link", url = "/base/appUser/appUserLogin") + @ApiOperation(value = "获取跳转微信url_link", tags = {"用户端-首页"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(value = "跳转小程序路径", name = "path", required = true, dataType = "string"), + @ApiImplicitParam(value = "跳转的附带参数", name = "query", required = false, dataType = "string"), + }) + public ResponseWarpper<String> getUrlLink(String path, String query){ + try { + String urlLink = weChatUtil.getUrlLink(path, query, "release"); + return ResponseWarpper.success(urlLink); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } @@ -110,7 +140,7 @@ @ResponseBody @PostMapping("/base/appUser/queryNearbyDrivers") -// @ServiceLog(name = "获取附近的司机", url = "/base/appUser/queryNearbyDrivers") + @ServiceLog(name = "获取附近的司机", url = "/base/appUser/queryNearbyDrivers") @ApiOperation(value = "获取附近的司机", tags = {"用户端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "经度", name = "lon", required = true, dataType = "string"), @@ -171,9 +201,11 @@ // @ServiceLog(name = "获取个人信息", url = "/api/appUser/queryUserInfo") @ApiOperation(value = "获取个人信息", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ + @ApiImplicitParam(value = "经度", name = "lon", required = true, dataType = "string"), + @ApiImplicitParam(value = "纬度", name = "lat", required = true, dataType = "string"), @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) - public ResponseWarpper<UserInfoWarpper> queryUserInfo(){ + public ResponseWarpper<UserInfoWarpper> queryUserInfo(String lon, String lat){ try { Integer uid = appUserService.getUserByRequest(); if(null == uid){ @@ -182,10 +214,21 @@ AppUser appUser = appUserService.selectById(uid); UserInfoWarpper userInfoWarpper = new UserInfoWarpper(); BeanUtils.copyProperties(appUser, userInfoWarpper); - SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 7)); - if(null != systemConfig){ - JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); - userInfoWarpper.setServiceCell(jsonObject.getString("num1")); + + District geocode = MapUtil.geocode(lon, lat); + BranchOffice branchOffice = branchOfficeService.selectOne(new EntityWrapper<BranchOffice>().eq("districtCode", geocode.getDistrictCode()).eq("status", 1)); + if(null == branchOffice){ + SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 7)); + if(null != systemConfig){ + JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); + userInfoWarpper.setServiceCell(jsonObject.getString("num1")); + } + }else{ + SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 8).eq("companyId", branchOffice.getId())); + if(null != systemConfig){ + JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); + userInfoWarpper.setServiceCell(jsonObject.getString("num2")); + } } return ResponseWarpper.success(userInfoWarpper); }catch (Exception e){ @@ -272,7 +315,7 @@ SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 6)); if(null != systemConfig){ JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); - return ResponseWarpper.success("充值满" + jsonObject.getDouble("num2") + "元,下单享9折优惠!"); + return ResponseWarpper.success("充值满" + jsonObject.getDouble("num2") + "元,下单享9.5折优惠!"); } return ResponseWarpper.success(); }catch (Exception e){ @@ -312,19 +355,26 @@ @ResponseBody @PostMapping("/base/appUser/rechargeBalanceCallback") // @ServiceLog(name = "余额充值回调", url = "/base/appUser/rechargeBalanceCallback") - public void rechargeBalanceCallback(HttpServletRequest request, HttpServletResponse response){ + public void rechargeBalanceCallback(@RequestBody InterfaceResponse interfaceResponse, HttpServletResponse response){ try { - Map<String, String> map = payMoneyUtil.weixinpayCallback(request); - if(null != map){ - String out_trade_no = map.get("out_trade_no"); - String transaction_id = map.get("transaction_id"); - String result = map.get("result"); - String orderId = out_trade_no.substring(17); - appUserService.rechargeBalanceCallback(out_trade_no, transaction_id); + // 验签 + boolean verify = RSASignature.validate(interfaceResponse.content(), interfaceResponse.getSign()); + if (verify) {//验签成功业务处理逻辑 + if(!"0000".equals(interfaceResponse.getCode())){ + System.err.println("充值回调异常:" + interfaceResponse.getMsg()); + return; + } + JSONObject jsonObject = JSON.parseObject(interfaceResponse.getResult()); + String merOrderId = jsonObject.getString("merOrderId"); + String orderId = jsonObject.getString("parameter1"); + appUserService.rechargeBalanceCallback(orderId, merOrderId); + response.setStatus(200); PrintWriter out = response.getWriter(); - out.print(result); + out.print("OK"); out.flush(); out.close(); + } else {//验签失败业务处理逻辑 + System.err.println("支付回调验签失败"); } }catch (Exception e){ e.printStackTrace(); @@ -522,7 +572,7 @@ phone = phone.indexOf("+86") < 0 ? "+86" + phone : phone; String value = redisUtil.getValue(phone); if(ToolUtil.isEmpty(value) || !value.equals(code)){ - resultUtil = ResultUtil.error("验证码无效"); + return ResponseWarpper.success(ResultUtil.error("验证码无效")); } redisUtil.remove(phone); return ResponseWarpper.success(resultUtil); @@ -532,4 +582,27 @@ } } + + + @ResponseBody + @PostMapping("/api/user/driverRegister") +// @ServiceLog(name = "注册司机", url = "/api/user/driverRegister") + @ApiOperation(value = "注册司机", tags = {"用户端-登录注册"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResponseWarpper driverRegister(DriverRegisterWarpper driverRegisterWarpper){ + try { + Integer uid = appUserService.getUserByRequest(); + if(null == uid){ + return ResponseWarpper.success(ResultUtil.tokenErr()); + } + ResultUtil resultUtil = driverService.driverRegister(uid, driverRegisterWarpper); + return ResponseWarpper.success(resultUtil); + }catch (Exception e){ + e.printStackTrace(); + return new ResponseWarpper(500, e.getMessage()); + } + } + } -- Gitblit v1.7.1