From f938ddb895cdcdfc925cfaa268c0ed8638f3b2a3 Mon Sep 17 00:00:00 2001
From: liujie <liujie>
Date: 星期四, 17 八月 2023 11:39:25 +0800
Subject: [PATCH] update
---
user/guns-admin/src/main/java/com/supersavedriving/user/modular/api/AppUserController.java | 417 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 409 insertions(+), 8 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 4215feb..f22e50a 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
@@ -1,28 +1,37 @@
package com.supersavedriving.user.modular.api;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
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.service.IAppUserService;
-import com.supersavedriving.user.modular.system.service.IDriverService;
+import com.supersavedriving.user.modular.system.model.SystemConfig;
+import com.supersavedriving.user.modular.system.service.*;
+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;
+import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
+import java.io.PrintWriter;
import java.util.List;
+import java.util.Map;
/**
* 用户控制器
@@ -37,6 +46,46 @@
@Autowired
private IDriverService driverService;
+ @Autowired
+ private ISystemConfigService systemConfigService;
+
+ @Autowired
+ private PayMoneyUtil payMoneyUtil;
+
+ @Autowired
+ private IUserToCouponService userToCouponService;
+
+ @Autowired
+ private IAccountChangeDetailService accountChangeDetailService;
+
+ @Autowired
+ private IComplaintService complaintService;
+
+ @Autowired
+ private RedisUtil redisUtil;
+
+ @Autowired
+ private WeChatUtil weChatUtil;
+
+
+
+ @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());
+ }
+ }
@@ -83,7 +132,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"),
@@ -155,6 +204,11 @@
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"));
+ }
return ResponseWarpper.success(userInfoWarpper);
}catch (Exception e){
e.printStackTrace();
@@ -174,7 +228,7 @@
public ResponseWarpper<String> uploadImg(MultipartFile file){
try {
InputStream inputStream = file.getInputStream();
- String name = file.getName();
+ String name = file.getOriginalFilename();
name = UUIDUtil.getRandomCode() + name.substring(name.lastIndexOf("."));
String s = OBSUtil.putObjectToBucket(inputStream, name);
return ResponseWarpper.success(s);
@@ -183,4 +237,351 @@
return new ResponseWarpper(500, e.getMessage());
}
}
+
+
+
+ @ResponseBody
+ @PostMapping("/api/appUser/updateUserInfo")
+// @ServiceLog(name = "修改个人信息", url = "/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")
+// @ServiceLog(name = "获取价格表", url = "/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<PriceRulesWarpper> queryPriceRules(){
+ try {
+ PriceRulesWarpper priceRulesWarpper = systemConfigService.queryPriceRules();
+ return ResponseWarpper.success(priceRulesWarpper);
+ }catch (Exception e){
+ e.printStackTrace();
+ return new ResponseWarpper(500, e.getMessage());
+ }
+ }
+
+
+ @ResponseBody
+ @PostMapping("/api/appUser/queryTopUpPrompt")
+// @ServiceLog(name = "获取充值优惠提示", url = "/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<String> queryTopUpPrompt(){
+ try {
+ 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.5折优惠!");
+ }
+ return ResponseWarpper.success();
+ }catch (Exception e){
+ e.printStackTrace();
+ return new ResponseWarpper(500, e.getMessage());
+ }
+ }
+
+
+ @ResponseBody
+ @PostMapping("/api/appUser/rechargeBalance")
+// @ServiceLog(name = "充值操作", url = "/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")
+// @ServiceLog(name = "余额充值回调", url = "/base/appUser/rechargeBalanceCallback")
+ public void rechargeBalanceCallback(@RequestBody InterfaceResponse interfaceResponse, HttpServletResponse response){
+ try {
+ // 验签
+ 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("OK");
+ out.flush();
+ out.close();
+ } else {//验签失败业务处理逻辑
+ System.err.println("支付回调验签失败");
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+
+
+ @ResponseBody
+ @PostMapping("/api/appUser/queryMyCoupons")
+// @ServiceLog(name = "获取优惠券列表", url = "/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<List<CouponsWarpper>> 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<CouponsWarpper> 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")
+// @ServiceLog(name = "获取已使用优惠券数量", url = "/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<Integer> 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")
+// @ServiceLog(name = "获取余额明细", url = "/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<List<BalanceDetailsWarpper>> 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<BalanceDetailsWarpper> 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")
+// @ServiceLog(name = "注销账号", url = "/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")
+// @ServiceLog(name = "投诉反馈", url = "/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());
+ }
+ }
+
+
+
+ @ResponseBody
+ @PostMapping("/base/appUser/getVerificationCode")
+// @ServiceLog(name = "获取短信验证码", url = "/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(5);
+ SMSUtil.send(phone, "1d0f0cbe5b214b0d8efa891730eb532a", "[\"" + numberRandom + "\"]");
+ 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")
+// @ServiceLog(name = "验证短信验证码", url = "/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")
+// @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