package com.supersavedriving.user.modular.api; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.heredata.hos.model.bucket.Bucket; import com.sun.xml.internal.bind.v2.TODO; import com.supersavedriving.user.core.common.annotion.ServiceLog; import com.supersavedriving.user.core.util.ToolUtil; import com.supersavedriving.user.modular.system.model.*; import com.supersavedriving.user.modular.system.service.*; import com.supersavedriving.user.modular.system.util.*; 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.huawei.OBSUtil; import com.supersavedriving.user.modular.system.util.qianyuntong.NCOSSUtil; import com.supersavedriving.user.modular.system.util.qianyuntong.QianYunTongConfig; import com.supersavedriving.user.modular.system.util.qianyuntong.SMSUtil; import com.supersavedriving.user.modular.system.util.qianyuntong.model.SendSmsRequest; 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.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.InputStream; import java.io.PrintWriter; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * 用户控制器 */ @RestController @RequestMapping("") public class AppUserController { @Autowired private IAppUserService appUserService; @Autowired private IDriverService driverService; @Autowired private ISystemConfigService systemConfigService; @Autowired private IUserToCouponService userToCouponService; @Autowired private IAccountChangeDetailService accountChangeDetailService; @Autowired private IComplaintService complaintService; @Autowired private RedisUtil redisUtil; @Autowired private WeChatUtil weChatUtil; @Autowired private TUserCouponService userCouponService; @Autowired private TCheckCarActivityService checkCarActivityService; @Autowired private ITBranchOfficeAreaService branchOfficeAreaService; @Resource private QianYunTongConfig qianYunTongConfig; @ResponseBody @PostMapping("/base/appUser/getUrlLink") @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 getUrlLink(String path, String query){ try { String urlLink = weChatUtil.getUrlLink(path, query, "trial"); return ResponseWarpper.success(urlLink); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/base/appUser/appUserLogin") @ApiOperation(value = "微信登录", tags = {"用户端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "微信jscode", name = "jscode", required = true, dataType = "string"), }) public ResponseWarpper appUserLogin(String jscode,Integer userId){ if(ToolUtil.isEmpty(jscode)){ return ResponseWarpper.success(ResultUtil.paranErr("jscode")); } try { ResultUtil resultUtil = appUserService.appUserLogin(jscode); return ResponseWarpper.success(resultUtil); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/base/appUser/signInToRegister") @ApiOperation(value = "微信手机授权登录", tags = {"用户端-首页"}, notes = "") @ApiImplicitParams({ }) public ResponseWarpper signInToRegister(SignInToRegister signInToRegister){ try { ResultUtil resultUtil = appUserService.signInToRegister(signInToRegister); return ResponseWarpper.success(resultUtil); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/base/appUser/queryCaptcha") @ApiOperation(value = "发送短信验证码", tags = {"用户端-首页"}, notes = "") @ApiImplicitParams({ }) public ResponseWarpper queryCaptcha(String phone){ try { AppUserUtil.queryCaptcha(phone); return ResponseWarpper.success(); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/base/appUser/verificationCodeLogin") @ApiOperation(value = "手机验证码登录", tags = {"用户端-首页"}, notes = "") @ApiImplicitParams({ }) public ResponseWarpper verificationCodeLogin(VerificationCodeLogin verificationCodeLogin){ try { ResultUtil resultUtil = appUserService.verificationCodeLogin(verificationCodeLogin); return ResponseWarpper.success(resultUtil); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/base/appUser/queryNearbyDrivers") @ApiOperation(value = "获取附近的司机", tags = {"用户端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "经度", name = "lon", required = true, dataType = "string"), @ApiImplicitParam(value = "纬度", name = "lat", required = true, dataType = "string"), }) public ResponseWarpper> queryNearbyDrivers(String lon, String lat){ if(ToolUtil.isEmpty(lat)){ return ResponseWarpper.success(ResultUtil.paranErr("lat")); } if(ToolUtil.isEmpty(lon)){ return ResponseWarpper.success(ResultUtil.paranErr("lon")); } try { List list = driverService.queryDriverPosition(lon, lat, 5D); return ResponseWarpper.success(list); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/base/appUser/setEmergencyContact") @ApiOperation(value = "设置紧急联系人", tags = {"用户端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "姓名", name = "name", required = true, dataType = "string"), @ApiImplicitParam(value = "电话", name = "phone", required = true, dataType = "string"), @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper setEmergencyContact(String name, String phone){ if(ToolUtil.isEmpty(name)){ return ResponseWarpper.success(ResultUtil.paranErr("name")); } if(ToolUtil.isEmpty(phone)){ return ResponseWarpper.success(ResultUtil.paranErr("phone")); } try { Integer uid = appUserService.getUserByRequest(); if(null == uid){ return ResponseWarpper.success(ResultUtil.tokenErr()); } AppUser appUser = appUserService.selectById(uid); appUser.setEmergencyContact(name); appUser.setEmergencyPhone(phone); appUserService.updateById(appUser); return ResponseWarpper.success(); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/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 queryUserInfo(String lon, String lat){ try { Integer uid = appUserService.getUserByRequest(); if(null == uid){ return ResponseWarpper.success(ResultUtil.tokenErr()); } AppUser appUser = appUserService.selectById(uid); UserInfoWarpper userInfoWarpper = new UserInfoWarpper(); BeanUtils.copyProperties(appUser, userInfoWarpper); District geocode = MapUtil.geocode(lon, lat); TBranchOfficeArea branchOfficeArea = branchOfficeAreaService.selectOne(new EntityWrapper().eq("areaCode", geocode.getDistrictCode()) .last("LIMIT 1")); if(null == branchOfficeArea){ SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper().eq("type", 7)); if(null != systemConfig){ JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); userInfoWarpper.setServiceCell(jsonObject.getString("num1")); } }else{ SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper().eq("type", 8).eq("companyId", branchOfficeArea.getBranchOfficeId())); if(null != systemConfig){ JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); userInfoWarpper.setServiceCell(jsonObject.getString("num2")); } } return ResponseWarpper.success(userInfoWarpper); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/api/appUser/uploadImg") @ApiOperation(value = "上传头像图片", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "图片文件", name = "file", required = true, dataType = "file"), @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper uploadImg(MultipartFile file){ try { InputStream inputStream = file.getInputStream(); String name = file.getOriginalFilename(); name = UUIDUtil.getRandomCode() + name.substring(name.lastIndexOf(".")); // String s = OBSUtil.putObjectToBucket(inputStream, name); // String s = OssUploadUtil.ossUpload(file); String bucketName = qianYunTongConfig.getBucketName(); Bucket grjyTest = NCOSSUtil.getBucketInfo(bucketName); if (null == grjyTest) { //创建桶 Boolean bucket = NCOSSUtil.createBucket(bucketName); if (!bucket) { throw new RuntimeException("创建存储桶失败"); } //设置桶策略 String policyText = "{\"Version\":\"2025-06-23\",\"Statement\":[{\"Sid\":\"Stmt20250623\",\"Action\":[\"GetObject\"],\"Effect\":\"Allow\",\"Resource\":\"" + bucketName + "/*\",\"Principal\":\"*\"}]}"; Boolean bucketPolicy = NCOSSUtil.setBucketPolicy(bucketName, policyText); if (!bucketPolicy) { throw new RuntimeException("设置桶策略失败"); } } //上传对象 String key = "imgs/daijia/user/" + name; String object = NCOSSUtil.putObject(bucketName, key, inputStream); if (null == object) { throw new RuntimeException("上传图片失败"); } return ResponseWarpper.success("https://traffic.qytzt.cn/v1/AUTH_" + qianYunTongConfig.getAccount() + "/" + bucketName + "/" + key); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/api/appUser/updateUserInfo") @ApiOperation(value = "修改个人信息", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper updateUserInfo(UserInfo userInfo){ try { Integer uid = appUserService.getUserByRequest(); if(null == uid){ return ResponseWarpper.success(ResultUtil.tokenErr()); } ResultUtil resultUtil = appUserService.updateUserInfo(uid, userInfo); return ResponseWarpper.success(resultUtil); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/api/appUser/queryPriceRules") @ApiOperation(value = "获取价格表", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper queryPriceRules(@RequestParam("cityCode") String cityCode){ try { PriceRulesWarpper priceRulesWarpper = systemConfigService.queryPriceRules(cityCode); return ResponseWarpper.success(priceRulesWarpper); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/api/appUser/queryTopUpPrompt") @ApiOperation(value = "获取充值优惠提示", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper queryTopUpPrompt(){ try { SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper().eq("type", 6)); if(null != systemConfig){ JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); return ResponseWarpper.success("充值满" + jsonObject.getDouble("num2") + "元,下单享9.5折优惠!"); } return ResponseWarpper.success(); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/api/appUser/rechargeBalance") @ApiOperation(value = "充值操作", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "充值金额", name = "amount", required = true, dataType = "double"), @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper rechargeBalance(Double amount){ if(null == amount){ return ResponseWarpper.success(ResultUtil.paranErr("amount")); } try { Integer uid = appUserService.getUserByRequest(); if(null == uid){ return ResponseWarpper.success(ResultUtil.tokenErr()); } ResultUtil resultUtil = appUserService.rechargeBalance(uid, amount); return ResponseWarpper.success(resultUtil); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/base/appUser/rechargeBalanceCallback") public String rechargeBalanceCallback(@RequestBody JSONObject req){ try { System.err.println("充值回调"+req); // 验签 Map params = req.toJavaObject(Map.class); //验证异步通知请求签名 Boolean verify = StrUtil.verify(params, MiniAppPay.MD5_KEY); if (verify) { String code = (String) params.get("mchOrderNo"); String state = (String) params.get("state"); if (2 != Integer.parseInt(state)) { return "false"; } if (2 == Integer.parseInt(state)) { appUserService.rechargeBalanceCallback(code); return "success"; } // // 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("OK"); // out.flush(); // out.close(); } }catch (Exception e){ e.printStackTrace(); } return "false"; } @ResponseBody @PostMapping("/api/appUser/queryMyCouponsCheck") @ApiOperation(value = "获取车检优惠券列表", tags = {"用户端-个人中心(车检)"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "状态(1=未使用,2=已使用,3=已过期)", name = "state", required = true, dataType = "int"), @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), @ApiImplicitParam(value = "页条数", name = "pageSize", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper> queryMyCouponsCheck(Integer state, Integer pageNum, Integer pageSize){ if(null == state){ return ResponseWarpper.success(ResultUtil.paranErr("state")); } if(null == pageNum){ return ResponseWarpper.success(ResultUtil.paranErr("pageNum")); } if(null == pageSize){ return ResponseWarpper.success(ResultUtil.paranErr("pageSize")); } try { Integer uid = appUserService.getUserByRequest(); if(null == uid){ return ResponseWarpper.success(ResultUtil.tokenErr()); } List couponsWarppers = userCouponService.queryMyCoupons(uid, state, pageNum, pageSize); return ResponseWarpper.success(couponsWarppers); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/api/appUser/queryCheckUsedCouponNum") @ApiOperation(value = "获取已使用车检优惠券数量", tags = {"用户端-个人中心(车检)"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper queryCheckUsedCouponNum(){ try { Integer uid = appUserService.getUserByRequest(); if(null == uid){ return ResponseWarpper.success(ResultUtil.tokenErr()); } Integer integer = userCouponService.queryUsedCouponNum(uid); return ResponseWarpper.success(integer); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/api/appUser/queryMyCoupons") @ApiOperation(value = "获取优惠券列表", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "状态(1=未使用,2=已使用,3=已过期)", name = "state", required = true, dataType = "int"), @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), @ApiImplicitParam(value = "页条数", name = "pageSize", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper> queryMyCoupons(Integer state, Integer pageNum, Integer pageSize){ if(null == state){ return ResponseWarpper.success(ResultUtil.paranErr("state")); } if(null == pageNum){ return ResponseWarpper.success(ResultUtil.paranErr("pageNum")); } if(null == pageSize){ return ResponseWarpper.success(ResultUtil.paranErr("pageSize")); } try { Integer uid = appUserService.getUserByRequest(); if(null == uid){ return ResponseWarpper.success(ResultUtil.tokenErr()); } List couponsWarppers = userToCouponService.queryMyCoupons(uid, state, pageNum, pageSize); return ResponseWarpper.success(couponsWarppers); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/api/appUser/queryUsedCouponNum") @ApiOperation(value = "获取已使用优惠券数量", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper queryUsedCouponNum(){ try { Integer uid = appUserService.getUserByRequest(); if(null == uid){ return ResponseWarpper.success(ResultUtil.tokenErr()); } Integer integer = userToCouponService.queryUsedCouponNum(uid); return ResponseWarpper.success(integer); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/api/appUser/queryBalanceDetails") @ApiOperation(value = "获取余额明细", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "统计时间", name = "time", required = true, dataType = "string"), @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), @ApiImplicitParam(value = "页条数", name = "pageSize", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper> queryBalanceDetails(String time, Integer pageNum, Integer pageSize){ if(ToolUtil.isEmpty(time)){ return ResponseWarpper.success(ResultUtil.paranErr("time")); } if(null == pageNum){ return ResponseWarpper.success(ResultUtil.paranErr("pageNum")); } if(null == pageSize){ return ResponseWarpper.success(ResultUtil.paranErr("pageSize")); } try { Integer uid = appUserService.getUserByRequest(); if(null == uid){ return ResponseWarpper.success(ResultUtil.tokenErr()); } List balanceDetailsWarppers = accountChangeDetailService.queryBalanceDetails(uid, time, pageNum, pageSize); return ResponseWarpper.success(balanceDetailsWarppers); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/api/appUser/cancelAccount") @ApiOperation(value = "注销账号", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper cancelAccount(){ try { Integer uid = appUserService.getUserByRequest(); if(null == uid){ return ResponseWarpper.success(ResultUtil.tokenErr()); } AppUser appUser = appUserService.selectById(uid); appUser.setStatus(3); appUserService.updateById(appUser); return ResponseWarpper.success(); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/api/appUser/feedback") @ApiOperation(value = "投诉反馈", tags = {"用户端-首页", "用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = false, dataType = "int"), @ApiImplicitParam(value = "反馈内容", name = "content", required = true, dataType = "string"), @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper feedback(Integer orderId, String content){ if(null == content){ return ResponseWarpper.success(ResultUtil.paranErr("content")); } try { Integer uid = appUserService.getUserByRequest(); if(null == uid){ return ResponseWarpper.success(ResultUtil.tokenErr()); } complaintService.feedback(uid, orderId, content); return ResponseWarpper.success(); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @Autowired private ALiSendSms aLiSendSms; @ResponseBody @PostMapping("/base/appUser/getVerificationCode") @ApiOperation(value = "获取短信验证码", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "国家代码+86", name = "receiver", required = true, dataType = "string"), @ApiImplicitParam(value = "电话号码", name = "phone", required = true, dataType = "string"), }) public ResponseWarpper getVerificationCode(String receiver, String phone){ if(ToolUtil.isEmpty(receiver)){ return ResponseWarpper.success(ResultUtil.paranErr("receiver")); } if(ToolUtil.isEmpty(phone)){ return ResponseWarpper.success(ResultUtil.paranErr("phone")); } try { String numberRandom = UUIDUtil.getNumberRandom(4); SendSmsRequest request = new SendSmsRequest(); request.setDestAddress(phone); request.setTemplateId("TPL202410290001"); Map templateParams = new HashMap<>(); templateParams.put("code", numberRandom); request.setTemplateParams(templateParams); request.setCode("code"); request.setSpId("T8d5hdfg"); SMSUtil.sendSms(request); redisUtil.setStrValue(receiver + phone, numberRandom, 300);//5分钟有效期 return ResponseWarpper.success(ResultUtil.success()); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/base/appUser/verifySMSCode") @ApiOperation(value = "验证短信验证码", tags = {"用户端-个人中心"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "电话号码", name = "phone", required = true, dataType = "String"), @ApiImplicitParam(value = "验证码", name = "code", required = true, dataType = "String"), @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper verifySMSCode(String phone, String code){ if(ToolUtil.isEmpty(phone)){ return ResponseWarpper.success(ResultUtil.paranErr("phone")); } if(ToolUtil.isEmpty(phone)){ return ResponseWarpper.success(ResultUtil.paranErr("code")); } try { ResultUtil resultUtil = ResultUtil.success(); phone = phone.indexOf("+86") < 0 ? "+86" + phone : phone; String value = redisUtil.getValue(phone); if(ToolUtil.isEmpty(value) || !value.equals(code)){ return ResponseWarpper.success(ResultUtil.error("验证码无效")); } redisUtil.remove(phone); return ResponseWarpper.success(resultUtil); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } @ResponseBody @PostMapping("/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()); } } @ResponseBody @PostMapping("/api/user/getCheckCoupon") @ApiOperation(value = "用户获取车检优惠券", tags = {"用户端-首页(车检)"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(value = "活动id", name = "activityId", required = true, dataType = "Integer"), }) public ResponseWarpper getCheckCoupon(Integer activityId){ try { Integer uid = appUserService.getUserByRequest(); if(null == uid){ return ResponseWarpper.success(ResultUtil.tokenErr()); } GetCheckCouponWarpper warpper = new GetCheckCouponWarpper(); TCheckCarActivity tCheckCarActivity = checkCarActivityService.selectById(activityId); if(null == tCheckCarActivity){ return ResponseWarpper.success(ResultUtil.error("活动不存在")); } warpper.setExplainContent(tCheckCarActivity.getExplainContent()); int count = userCouponService.selectCount(new EntityWrapper().eq("userId", uid).eq("activityId", activityId)); if(count==0){ // 未领取 warpper.setState(0); }else { // 已领取 warpper.setState(1); } if(tCheckCarActivity.getStartTime().getTime()>System.currentTimeMillis() && tCheckCarActivity.getEndTime().getTime()System.currentTimeMillis()){ warpper.setActivityState(2); }else if(tCheckCarActivity.getEndTime().getTime()().eq("userId", uid).eq("activityId", activityId)); if(count>0){ return ResponseWarpper.success(ResultUtil.error("你已领取该优惠券")); } if(tCheckCarActivity.getStartTime().getTime()>System.currentTimeMillis()){ return ResponseWarpper.success(ResultUtil.error("活动未开始")); } if(tCheckCarActivity.getEndTime().getTime()System.currentTimeMillis() && tCheckCarActivity.getEndTime().getTime()