package com.stylefeng.guns.modular.api;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.serializer.BigDecimalCodec;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.google.code.kaptcha.Constants;
|
import com.stylefeng.guns.core.common.constant.JwtConstants;
|
import com.stylefeng.guns.core.common.exception.InvalidKaptchaException;
|
import com.stylefeng.guns.core.shiro.ShiroKit;
|
import com.stylefeng.guns.core.support.HttpKit;
|
import com.stylefeng.guns.core.util.ToolUtil;
|
import com.stylefeng.guns.modular.system.model.BankCard;
|
import com.stylefeng.guns.modular.system.model.TEmail;
|
import com.stylefeng.guns.modular.system.model.UserInfo;
|
import com.stylefeng.guns.modular.system.service.*;
|
import com.stylefeng.guns.modular.system.util.*;
|
import com.stylefeng.guns.modular.system.util.GoogleMap.FleetEngineUtil;
|
import com.stylefeng.guns.modular.system.util.itextpdf.HtmlToPdfUtils;
|
import com.stylefeng.guns.modular.system.warpper.*;
|
import com.stylefeng.guns.modular.taxi.model.TransactionDetails;
|
import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService;
|
import com.stylefeng.guns.modular.taxi.service.ITransactionDetailsService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import org.jsoup.Jsoup;
|
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Element;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.http.MediaType;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
import javax.servlet.ServletOutputStream;
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpSession;
|
import java.io.*;
|
import java.math.BigDecimal;
|
import java.text.SimpleDateFormat;
|
import java.util.*;
|
|
/**
|
* 用户控制器
|
*/
|
@Api
|
@CrossOrigin
|
@RestController
|
@RequestMapping("")
|
public class UserInfoController {
|
|
Logger log = LoggerFactory.getLogger(UserInfoController.class);
|
|
@Autowired
|
private IUserInfoService userInfoService;
|
|
@Autowired
|
private IVerifiedService verifiedService;
|
|
@Autowired
|
private ISmsrecordService smsrecordService;
|
|
@Autowired
|
private RedisUtil redisUtil;
|
|
@Autowired
|
private IReportLossService reportLossService;
|
|
@Autowired
|
private IBankCardService bankCardService;
|
|
@Autowired
|
private IOrderService orderService;
|
|
@Value("${spring.mail.template-path}")
|
private String templatePath;
|
|
@Autowired
|
private TEmailService emailService;
|
@Autowired
|
private ITransactionDetailsService transactionDetailsService;
|
@Autowired
|
private IPaymentRecordService paymentRecordService;
|
|
@Autowired
|
private FleetEngineUtil fleetEngineUtil;
|
|
private String salt = "&a.s";
|
|
|
|
|
@ResponseBody
|
@PostMapping("/base/isEnterEmergencyContact")
|
@ApiOperation(value = "是否输入紧急联系人", tags = {"用户端-登录"}, notes = "")
|
public ResultUtil isEnterEmergencyContact(){
|
try {
|
Integer type = userInfoService.getAppOpenInfo(2);
|
Map<String,Object> map = new HashMap<>();
|
map.put("isEnterEmergencyContact",type==1);
|
return ResultUtil.success(map);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 获取短信验证码
|
* @param phone
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/base/authentication")
|
@ApiOperation(value = "实名认证", tags = {"用户端-登录"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "身份证号", name = "idCard", required = true, dataType = "String")
|
})
|
public ResultUtil authentication(String phone, String idCard){
|
if(ToolUtil.isNotEmpty(phone)){
|
try {
|
//return ResultUtil.success(aLiApiUtil.authentication(phone,idCard));
|
return ResultUtil.success(true);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}else{
|
return ResultUtil.paranErr();
|
}
|
}
|
|
/**
|
* 获取短信验证码
|
* @param phone
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/base/queryCaptcha")
|
@ApiOperation(value = "获取短信验证码", tags = {"用户端-登录"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "图片验证码", name = "kaptcha", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "场景类型(1=身份验证,2=登录确认,3=用户注册,4=修改密码)", name = "type", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "语言", name = "language", required = true, dataType = "int")
|
})
|
public ResultUtil queryCaptcha(HttpServletRequest request,String phone, Integer type,String kaptcha, Integer language){
|
if(ToolUtil.isNotEmpty(phone)){
|
try {
|
/* HttpSession session = request.getSession();
|
String code = (String)session.getAttribute(Constants.KAPTCHA_SESSION_KEY);*/
|
String substring = phone.substring(0, 1);
|
if("0".equals(substring)){
|
phone = "233" + phone.substring(1);
|
}
|
if(phone.indexOf("233") < 0){
|
phone = "233" + phone;
|
}
|
String code = redisUtil.getValue(phone+"_Code");
|
System.out.println("缓存中验证码为:"+code);
|
if (ToolUtil.isEmpty(kaptcha) || !kaptcha.equalsIgnoreCase(code)) {
|
return ResultUtil.error(language == 1 ? "图形验证码错误" : language == 2 ? "Wrong CAPTCHA" : "CAPTCHA erroné");
|
}
|
return userInfoService.queryCaptcha(phone, type, language);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}else{
|
return ResultUtil.paranErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/base/queryCaptcha1")
|
@ApiOperation(value = "获取短信验证码", tags = {"用户端-登录"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "场景类型(1=身份验证,2=登录确认,3=用户注册,4=修改密码)", name = "type", required = true, dataType = "String")
|
})
|
public ResultUtil queryCaptcha1(String phone, Integer type, Integer language){
|
if(ToolUtil.isNotEmpty(phone)){
|
try {
|
String substring = phone.substring(0, 1);
|
if("0".equals(substring)){
|
phone = "233" + phone.substring(1);
|
}
|
if(phone.indexOf("233") < 0){
|
phone = "233" + phone;
|
}
|
return userInfoService.queryCaptcha(phone, type, language);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}else{
|
return ResultUtil.paranErr();
|
}
|
}
|
|
|
/**
|
* 短信回调通知
|
* @param request
|
*/
|
@ResponseBody
|
@PostMapping("/base/sendCellulantMessageCallback")
|
public void sendCellulantMessageCallback(HttpServletRequest request){
|
try {
|
StringBuilder sb = new StringBuilder();
|
InputStream inputStream = request.getInputStream();
|
String s;
|
BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
|
while ((s = in.readLine()) != null) {
|
sb.append(s);
|
}
|
in.close();
|
inputStream.close();
|
log.info("短信通知回调:" + sb.toString());
|
}catch (Exception e){
|
e.printStackTrace();
|
}
|
}
|
|
|
@ResponseBody
|
@PostMapping("/base/sedEmail")
|
@ApiOperation(value = "获取邮箱验证码【1.0】", tags = {"用户端-登录"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "邮箱地址", name = "email", required = true, dataType = "String")
|
})
|
public ResultUtil sedEmail(String email, Integer language, HttpServletRequest request){
|
try {
|
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
|
if(ToolUtil.isEmpty(email)){
|
return ResultUtil.error(language == 1 ? "邮箱不能为空" : language == 2 ? "E-mail address cannot be empty." : "L’adresse e-mail ne peut pas être vide.");
|
}
|
|
Random random = new Random();
|
|
StringBuffer sb = new StringBuffer();
|
|
for(int i = 0; i < 4; i++){
|
sb.append((int) (random.nextDouble() * 10));
|
}
|
|
String authCode = sb.toString();
|
|
redisUtil.setStrValue(email, authCode, 5 * 60);
|
|
UserInfo userInfo = userInfoService.selectById(uid);
|
|
String nickName = "";
|
|
if(null != userInfo){
|
|
nickName = userInfo.getNickName();
|
|
}
|
|
if(ToolUtil.isNotEmpty(email)){
|
String path = templatePath + "user/mainbox.html";
|
Document document = Jsoup.parse(new File(path), "UTF-8");
|
if(1 == language){
|
document.getElementById("english").remove();
|
document.getElementById("french").remove();
|
document.getElementsByTag("title").get(0).text("邮箱验证");
|
Element user_chinese = document.getElementById("user_chinese");
|
user_chinese.text("您好 " + nickName + ",");
|
Element content_chinese = document.getElementById("content_chinese");
|
content_chinese.text(authCode);
|
}
|
if(2 == language){
|
document.getElementById("chinese").remove();
|
document.getElementById("french").remove();
|
document.getElementsByTag("title").get(0).text("Verification code");
|
Element user_chinese = document.getElementById("user_english");
|
user_chinese.text("Hello " + nickName + ",");
|
Element content_english = document.getElementById("content_english");
|
content_english.text(authCode);
|
}
|
if(3 == language){
|
document.getElementById("chinese").remove();
|
document.getElementById("english").remove();
|
document.getElementsByTag("title").get(0).text("Code de validation");
|
Element user_french = document.getElementById("user_french");
|
user_french.text("Bonjour " + nickName + ",");
|
Element content_french = document.getElementById("content_french");
|
content_french.text(authCode);
|
}
|
EmailUtil.send(email, language == 1 ? "邮箱验证" : language == 2 ? "Verification code" : "Code de validation", document.html());
|
|
//开始生成pdf收据和html收据
|
File file = new File("/home/igotechgh/nginx/html/files/html/");
|
if(!file.exists()){
|
file.mkdirs();
|
}
|
String randomString = ToolUtil.getRandomString(10);
|
file = new File("/home/igotechgh/nginx/html/files/html/mainbox_" + randomString + ".html");
|
if(!file.exists()){
|
file.createNewFile();
|
}
|
FileWriter fileWriter = new FileWriter(file);
|
fileWriter.write(document.html());
|
fileWriter.flush();
|
fileWriter.close();
|
|
String link ="https://igo.i-go.group/files/html/mainbox_" + randomString + ".html";
|
TEmail tEmail = new TEmail();
|
tEmail.setLink(link);
|
tEmail.setUserId(uid);
|
tEmail.setType(1);
|
tEmail.setName(language == 1 ? "邮箱验证" : language == 2 ? "Verification code" : "Code de validation");
|
tEmail.setCreateTime(new Date());
|
int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1;
|
tEmail.setWeek(EmailUtil.getWeek(language,i));
|
boolean am = cn.hutool.core.date.DateUtil.isAM(new Date());
|
if(am){
|
tEmail.setAmOrPm(language==1?"上午":language==2?"morning":"matin");
|
}else {
|
tEmail.setAmOrPm(language==1?"下午":language==2?"afternoon":"après-midi");
|
}
|
emailService.insert(tEmail);
|
}
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 手机验证码登录
|
* @param phone
|
* @param code
|
* @param registIp
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/base/user/captchaLogin")
|
@ApiOperation(value = "手机验证码登录【1.1】", tags = {"用户端-登录"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "手机号运营商(GH-MTN-B2C、GH-TIGO-B2C、GH-VODAFONE-B2C、GH-AIRTEL-B2C)", name = "phoneOperator", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "短信验证码", name = "code", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "ip地址", name = "registIp", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "纬度", name = "lat", required = false, dataType = "double"),
|
@ApiImplicitParam(value = "经度", name = "lng", required = false, dataType = "double")
|
})
|
public ResultUtil<LoginWarpper> captchaLogin(String phoneOperator, String phone, String code, String registIp, Double lat, Double lng, Integer language){
|
try {
|
String substring = phone.substring(0, 1);
|
if("0".equals(substring)){
|
phone = "233" + phone.substring(1);
|
}
|
if(phone.indexOf("233") < 0){
|
phone = "233" + phone;
|
}
|
switch (phoneOperator){
|
case "MTN":
|
phoneOperator = "GH-MTN-B2C";
|
break;
|
case "TIGO":
|
phoneOperator = "GH-TIGO-B2C";
|
break;
|
case "VODAFONE":
|
phoneOperator = "GH-VODAFONE-B2C";
|
break;
|
case "AIRTEL":
|
phoneOperator = "GH-AIRTEL-B2C";
|
break;
|
}
|
return userInfoService.captchaLogin(phoneOperator, phone, code, registIp, lat, lng,null,null,null,language);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 手机验证码登录
|
* @param phone
|
* @param code
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/base/user/captchaLogin_")
|
@ApiOperation(value = "手机验证码登录【1.1】", tags = {"分享专用"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "手机号运营商(GH-MTN-B2C、GH-TIGO-B2C、GH-VODAFONE-B2C、GH-AIRTEL-B2C)", name = "phoneOperator", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "短信验证码", name = "code", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "分享的用户id", name = "uid", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "用户类型(1=用户,2=司机)", name = "type", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "注册类型(1=司机注册,2=用户注册)", name = "userType", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "语言", name = "language", required = true, dataType = "int")
|
})
|
public ResultUtil<LoginWarpper> captchaLogin_(String phoneOperator, String phone, String code, Integer uid, Integer type, Integer userType, Integer language){
|
try {
|
String substring = phone.substring(0, 1);
|
if("0".equals(substring)){
|
phone = "233" + phone.substring(1);
|
}
|
if(phone.indexOf("233") < 0){
|
phone = "233" + phone;
|
}
|
switch (phoneOperator){
|
case "MTN":
|
phoneOperator = "GH-MTN-B2C";
|
break;
|
case "TIGO":
|
phoneOperator = "GH-TIGO-B2C";
|
break;
|
case "VODAFONE":
|
phoneOperator = "GH-VODAFONE-B2C";
|
break;
|
case "AIRTEL":
|
phoneOperator = "GH-AIRTEL-B2C";
|
break;
|
}
|
return userInfoService.captchaLogin(phoneOperator, phone, code, uid, type, userType, language);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 账号密码登录
|
* @param phone
|
* @param password
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/base/user/userLogin")
|
@ApiOperation(value = "账号密码登录", tags = {"用户端-登录"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "登录密码", name = "password", required = true, dataType = "String")
|
})
|
public ResultUtil<LoginWarpper> userLogin(String phone, String password, Integer language){
|
if(ToolUtil.isNotEmpty(phone) && ToolUtil.isNotEmpty(password)){
|
try {
|
String substring = phone.substring(0, 1);
|
if("0".equals(substring)){
|
phone = "233" + phone.substring(1);
|
}
|
if(phone.indexOf("233") < 0){
|
phone = "233" + phone;
|
}
|
return userInfoService.userLogin(phone, password, language);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}else{
|
return ResultUtil.paranErr();
|
}
|
}
|
|
/**
|
* 忘记密码
|
* @param phone
|
* @param code
|
* @param password
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/base/user/forgetPassword")
|
@ApiOperation(value = "忘记密码操作", tags = {"用户端-登录"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "验证码", name = "code", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "新密码", name = "password", required = true, dataType = "String")
|
})
|
public ResultUtil forgetPassword(String phone, String code, String password, Integer language){
|
if(ToolUtil.isNotEmpty(phone) && ToolUtil.isNotEmpty(code) && ToolUtil.isNotEmpty(password)){
|
try {
|
String substring = phone.substring(0, 1);
|
if("0".equals(substring)){
|
phone = "233" + phone.substring(1);
|
}
|
if(phone.indexOf("233") < 0){
|
phone = "233" + phone;
|
}
|
return userInfoService.forgetPassword(phone, code, password, language);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}else{
|
return ResultUtil.paranErr();
|
}
|
}
|
|
/**
|
* 微信授权登录
|
* @param type 登录端口(1:APP登录,2:小程序)
|
* @param openid 微信openid
|
* @param unionid 微信unionid
|
* @param jscode 小程序登录时的jscode临时凭证
|
* @param registIp ip地址
|
* @param registAreaCode 当前定位区县行政编号(6位)
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/base/user/wxLogin")
|
@ApiOperation(value = "微信授权登录", tags = {"用户端-登录"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "登录端口(1:APP,2:小程序)", name = "type", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "微信openid(APP登录上传)", name = "openid", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "encryptedData", name = "encryptedData", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "iv", name = "iv", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "微信unionid(APP登录上传)", name = "unionid", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "微信jscode(小程序登录上传)", name = "jscode", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "ip地址", name = "registIp", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "当前定位区县行政编号", name = "registAreaCode", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "头像", name = "avatar", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "昵称", name = "nickName", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "登录端口-小程序传Applets", name = "loginType", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "分享的用户id", name = "uid", required = false, dataType = "int"),
|
@ApiImplicitParam(value = "性别(1=男,2=女)", name = "sex", required = false, dataType = "int")
|
})
|
public ResultUtil<LoginWarpper> wxLogin(Integer uid,String encryptedData, String iv,Integer type, String openid, String unionid, String jscode, String registIp,
|
String registAreaCode, Integer sex, String nickName, String avatar,String loginType, Integer language){
|
try {
|
return userInfoService.wxLogin(type, openid, unionid, jscode, registIp, registAreaCode, sex, nickName, avatar,loginType,encryptedData,iv,uid,language);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/base/user/wxIsLogin")
|
@ApiOperation(value = "微信小程序是否登录", tags = {"用户端-登录"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "微信jscode(小程序登录上传)", name = "jscode", required = false, dataType = "String")
|
})
|
public ResultUtil<LoginWarpper> wxIsLogin(Integer language, String jscode){
|
try {
|
return userInfoService.wxIsLogin(language, jscode);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/base/user/facebookLogin")
|
@ApiOperation(value = "FaceBook授权登录【1.0】", tags = {"用户端-登录"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "FaceBook用户id", name = "id", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "FaceBook用户名称", name = "name", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "FaceBook绑定的email", name = "email", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "头像", name = "avatar", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "性别(1=男,2=女)", name = "sex", required = false, dataType = "int"),
|
@ApiImplicitParam(value = "纬度", name = "lat", required = false, dataType = "double"),
|
@ApiImplicitParam(value = "经度", name = "lng", required = false, dataType = "double"),
|
@ApiImplicitParam(value = "分享的用户id", name = "uid", required = false, dataType = "int"),
|
})
|
public ResultUtil facebookLogin(String id, String name, String email, Double lat, Double lng, Integer uid, Integer language){
|
try {
|
return userInfoService.facebookLogin(id, name, email, lat, lng, uid, language,1);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
@ResponseBody
|
@PostMapping("/base/user/twitterLogin")
|
@ApiOperation(value = "twitter授权登录【1.0】", tags = {"用户端-登录"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "twitter用户id", name = "id", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "twitter用户名称", name = "name", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "twitter绑定的email", name = "email", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "头像", name = "avatar", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "性别(1=男,2=女)", name = "sex", required = false, dataType = "int"),
|
@ApiImplicitParam(value = "纬度", name = "lat", required = false, dataType = "double"),
|
@ApiImplicitParam(value = "经度", name = "lng", required = false, dataType = "double"),
|
@ApiImplicitParam(value = "分享的用户id", name = "uid", required = false, dataType = "int"),
|
})
|
public ResultUtil twitterLogin(String id, String name, String email, Double lat, Double lng, Integer uid, Integer language){
|
try {
|
return userInfoService.facebookLogin(id, name, email, lat, lng, uid, language,2);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 设置电话号码
|
* @param phone
|
* @param code
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/user/bindingPhone")
|
@ApiOperation(value = "设置电话号码【1.1】", tags = {"用户端-登录"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "手机号运营商(GH-MTN-B2C、GH-TIGO-B2C、GH-VODAFONE-B2C、GH-AIRTEL-B2C)", name = "phoneOperator", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "电话号码", name = "phone", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "验证码", name = "code", required = false, dataType = "String"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<LoginWarpper> bindingPhone(String phoneOperator, String phone, String code, Integer language, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
String substring = phone.substring(0, 1);
|
if("0".equals(substring)){
|
phone = "233" + phone.substring(1);
|
}
|
if(phone.indexOf("233") < 0){
|
phone = "233" + phone;
|
}
|
switch (phoneOperator){
|
case "MTN":
|
phoneOperator = "GH-MTN-B2C";
|
break;
|
case "TIGO":
|
phoneOperator = "GH-TIGO-B2C";
|
break;
|
case "VODAFONE":
|
phoneOperator = "GH-VODAFONE-B2C";
|
break;
|
case "AIRTEL":
|
phoneOperator = "GH-AIRTEL-B2C";
|
break;
|
}
|
return userInfoService.bindingPhone(uid, phoneOperator, phone, code, language);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/api/user/bindingEmail")
|
@ApiOperation(value = "设置邮箱地址【1.0】", tags = {"用户端-登录"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "绑定类型(1=注册账号绑定,2=个人中心绑定)", name = "type", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "邮箱地址", name = "email", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "验证码", name = "code", required = true, dataType = "String"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<LoginWarpper> bindingEmail(Integer type, String email, String code, Integer language, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
return userInfoService.bindingEmail(uid, type, email, code, language);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/api/user/getEmailList")
|
@ApiOperation(value = "获取邮箱信息", tags = {"用户端-获取邮箱信息"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<List<EmailWarpper>> getEmailList(Integer language, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
List<TEmail> tEmails = emailService.selectList(new EntityWrapper<TEmail>().eq("userId", uid).eq("type", 1).orderBy("createTime", false));
|
List<EmailWarpper> list = new ArrayList<>();
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
for (TEmail tEmail : tEmails) {
|
EmailWarpper warpper = new EmailWarpper();
|
BeanUtils.copyProperties(tEmail, warpper);
|
warpper.setCreateTime(DateUtil.conversionFormat(language, sdf.format(tEmail.getCreateTime())));
|
int i = cn.hutool.core.date.DateUtil.dayOfWeek(tEmail.getCreateTime())-1;
|
warpper.setWeek(EmailUtil.getWeek(language,i));
|
list.add(warpper);
|
}
|
return ResultUtil.success(list);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 获取用户个人信息
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/user/queryUserInfo")
|
@ApiOperation(value = "获取用户详情【1.1】", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<UserInfoWarpper> queryUserInfo(Integer language, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
Map<String, Object> map = userInfoService.queryUserInfo(language, uid);
|
return ResultUtil.success(UserInfoWarpper.getUserInfoWarpper(map));
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 手机号码获取用户
|
* @param phone
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/user/queryUser")
|
@ApiOperation(value = "手机号码获取用户", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "电话号码", name = "phone", required = true, dataType = "String"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<Object> queryUser(Integer language, String phone){
|
try {
|
String substring = phone.substring(0, 1);
|
if("0".equals(substring)){
|
phone = "233" + phone.substring(1);
|
}
|
if(phone.indexOf("233") < 0){
|
phone = "233" + phone;
|
}
|
Map<String, Object> map = userInfoService.queryUser(language, phone);
|
if(null != map){
|
return ResultUtil.success(UserInfoWarpper.getUserInfoWarpper(map));
|
}else{
|
return ResultUtil.error(language == 1 ? "此账号不存在" : language == 2 ? "The account does not exist" : "Ce compte n’existe pas");
|
}
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 实名认证操作
|
* @param verifiedWarpper
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/user/verified")
|
@ApiOperation(value = "实名认证操作", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil verified(VerifiedWarpper verifiedWarpper, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
return verifiedService.verified(VerifiedWarpper.getVerified(verifiedWarpper), uid);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 设置紧急联系人
|
* @param name
|
* @param phone
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/user/setUrgentUser")
|
@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 = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil setUrgentUser(String name, String phone, Integer language, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
UserInfo userInfo = userInfoService.selectById(uid);
|
if(ToolUtil.isEmpty(userInfo.getPhone())){
|
return ResultUtil.error(language == 1 ? "请先绑定手机号码" : language == 2 ? "Please bind your mobile phone number first." : "Veuillez d’abord vous inscrire en liant votre numéro de téléphone portable.");
|
}
|
String substring = phone.substring(0, 1);
|
if("0".equals(substring)){
|
phone = "233" + phone.substring(1);
|
}
|
if(phone.indexOf("233") < 0){
|
phone = "233" + phone;
|
}
|
userInfoService.setUrgentUser(name, phone, uid);
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 用户充值余额
|
* @param payType
|
* @param money
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/user/depositBalance")
|
@ApiOperation(value = "余额充值【1.1】", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "支付方式(1=手机充值,2=银行卡充值)", name = "payType", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "银行卡id", name = "bankCardId", required = false, dataType = "int"),
|
@ApiImplicitParam(value = "充值金额", name = "money", required = true, dataType = "double"),
|
@ApiImplicitParam(value = "支付端(1=用户APP端,2=司机APP端,3=用户小程序端)", name = "type", required = false, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil depositBalance(Integer payType, String bankCardId, Double money, Integer type, Integer language, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
return userInfoService.depositBalance(payType, bankCardId, money, uid, type, language);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 修改手机号码
|
* @param code
|
* @param phone
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/user/updatePhone")
|
@ApiOperation(value = "修改手机号码【1.1】", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "验证码", name = "code", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "手机号运营商(GH-MTN-B2C、GH-TIGO-B2C、GH-VODAFONE-B2C、GH-AIRTEL-B2C)", name = "phoneOperator", required = true, dataType = "String"),
|
@ApiImplicitParam(value = "新手机号", name = "phone", required = true, dataType = "string"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil updatePhone(String code, String phoneOperator, String phone, Integer language, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
String substring = phone.substring(0, 1);
|
if("0".equals(substring)){
|
phone = "233" + phone.substring(1);
|
}
|
if(phone.indexOf("233") < 0){
|
phone = "233" + phone;
|
}
|
switch (phoneOperator){
|
case "MTN":
|
phoneOperator = "GH-MTN-B2C";
|
break;
|
case "TIGO":
|
phoneOperator = "GH-TIGO-B2C";
|
break;
|
case "VODAFONE":
|
phoneOperator = "GH-VODAFONE-B2C";
|
break;
|
case "AIRTEL":
|
phoneOperator = "GH-AIRTEL-B2C";
|
break;
|
}
|
return userInfoService.updatePhone(code, phoneOperator, phone, uid, language);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/api/user/checkCaptcha")
|
@ApiOperation(value = "验证短信验证码", tags = {"用户端-个人中心"}, notes = "1=正确,0=错误")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "电话号码", name = "phone", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "短信验证码", name = "code", required = true, dataType = "string"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil checkCaptcha(String phone, String code, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
String substring = phone.substring(0, 1);
|
if("0".equals(substring)){
|
phone = "233" + phone.substring(1);
|
}
|
if(phone.indexOf("233") < 0){
|
phone = "233" + phone;
|
}
|
UserInfo userInfo = userInfoService.selectById(uid);
|
boolean b = userInfoService.checkCaptcha(phone, code);
|
Map<String, Object> map = new HashMap<>();
|
map.put("ok", b ? 1 : 0);
|
return ResultUtil.success(map);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 修改登录密码
|
* @param password
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/user/updatePassword")
|
@ApiOperation(value = "修改登录密码", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "新密码", name = "password", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "语言", name = "language", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil updatePassword(String password, Integer language, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
return userInfoService.updatePass(password, uid, language);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 修改个人信息
|
* @param avatar
|
* @param nickname
|
* @param sex
|
* @param birthday
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/user/updateInfo")
|
@ApiOperation(value = "修改个人信息【1.1】", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "头像", name = "avatar", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "昵称", name = "nickname", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "性别(1=男,2=女)", name = "sex", required = false, dataType = "int"),
|
@ApiImplicitParam(value = "生日(2020-06-15)", name = "birthday", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "邮箱", name = "email", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "邮箱验证码", name = "code", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "姓氏", name = "lastName", required = false, dataType = "string"),
|
@ApiImplicitParam(value = "名字", name = "firstName", required = false, dataType = "string"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil updateInfo(String avatar, String nickname, Integer sex, Date birthday, String email, String code, String lastName, String firstName, Integer language, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
return userInfoService.updateInfo(avatar, nickname, sex, birthday, email, code, lastName, firstName, uid, language);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/api/user/queryRealName")
|
@ApiOperation(value = "获取实名认证的数据", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil queryRealName(HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
Map<String, Object> map = userInfoService.queryRealName(uid);
|
return ResultUtil.success(null != map ? map : new HashMap<>());
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 后台调用禁用用户
|
* @param uid
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/base/user/freeze")
|
public ResultUtil freeze(Integer uid){
|
try {
|
UserInfo userInfo = userInfoService.selectById(uid);
|
String value = redisUtil.getValue(userInfo.getPhone());
|
redisUtil.remove(value);
|
redisUtil.remove(userInfo.getPhone());
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 仿socket接口(单点登录)
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/user/comparisonToken")
|
@ApiOperation(value = "单点登录", tags = {"用户端-仿socket接口"}, notes = "match=1(匹配),match=2(不匹配)")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil comparisonToken(HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
String requestHeader = request.getHeader(JwtConstants.AUTH_HEADER);
|
requestHeader = requestHeader.substring(requestHeader.indexOf(" ") + 1);
|
String value = redisUtil.getValue("USER_" + uid);
|
Map<String, Object> map = new HashMap<>();
|
map.put("match", requestHeader.equals(value) ? 1 : 2);
|
return ResultUtil.success(map);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 注销账号
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/user/cancellation")
|
@ApiOperation(value = "注销账号", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil cancellation(HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
UserInfo userInfo = userInfoService.selectById(uid);
|
userInfo.setState(2);
|
userInfoService.updateById(userInfo);
|
//开始验证当前账号是否在别处登录
|
String value = redisUtil.getValue("USER_" + uid);
|
if(ToolUtil.isNotEmpty(value)){//将另外设备上的强迫下线
|
//开始清除redis中无效的数据
|
String key = redisUtil.getValue("USER_" + userInfo.getPhone());
|
redisUtil.remove(key);//删除个人信息数据
|
redisUtil.remove("USER_" + userInfo.getPhone());//删除后台冻结相关缓存
|
redisUtil.remove("USER_" + uid);//清除存储的token
|
}
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/api/user/getInviteList")
|
@ApiOperation(value = "获取邀请司机/乘客列表", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "类型[1:乘客,2:司机]", name = "type", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil getInviteList(Integer type,Integer pageNum, Integer size, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
List<Map<String,Object>> list = userInfoService.queryMyInviteList(type,uid, pageNum, size);
|
return ResultUtil.success(UserInviteInfoWarpper.getDriverInviteInfoWarpper(list));
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/api/user/editLanguage")
|
@ApiOperation(value = "修改多语言配置", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "1=中文,2=英文,3=法语", name = "language", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil editLanguage(Integer language, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
UserInfo userInfo = userInfoService.selectById(uid);
|
userInfo.setLanguage(language);
|
userInfoService.updateById(userInfo);
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/base/user/addReportLoss")
|
@ApiOperation(value = "提交报失", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城出行,4=同城小件物流,5=跨城小件物流)", name = "orderType", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "提交内容", name = "remark", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "提交图片", name = "image", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "1=中文,2=英文,3=法语", name = "language", required = true, dataType = "int"),
|
})
|
public ResultUtil addReportLoss(Integer orderType, Integer orderId, String remark, String image, Integer language){
|
try {
|
reportLossService.addReportLoss(orderType, orderId, remark, image, language);
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/base/user/queryOrderLicensePlate")
|
@ApiOperation(value = "获取报失也车牌等信息", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=跨城出行,4=同城小件物流,5=跨城小件物流)", name = "orderType", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
|
})
|
public ResultUtil queryOrderLicensePlate(Integer orderType, Integer orderId){
|
try {
|
Map<String, Object> map = orderService.queryOrderLicensePlate(orderType, orderId);
|
return ResultUtil.success(map);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@RequestMapping("/base/user/image")
|
public ResultUtil image(@RequestPart("file") MultipartFile file) {
|
try {
|
String pictureName = GoogleCloudStorageUtil.upload(file);
|
return ResultUtil.success(pictureName);
|
} catch (Exception e1) {
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/api/user/queryBankCardList")
|
@ApiOperation(value = "获取银行卡列表【1.1】", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<List<BankCardWarpper>> queryBankCardList(HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
List<BankCard> bankCards = bankCardService.selectList(new EntityWrapper<BankCard>().eq("userType", 1).eq("userId", uid));
|
List<BankCardWarpper> list = new ArrayList<>();
|
for (BankCard bankCard : bankCards) {
|
BankCardWarpper bankCardWarpper = new BankCardWarpper();
|
bankCardWarpper.setId(bankCard.getId());
|
bankCardWarpper.setBankName(bankCard.getBank());
|
bankCardWarpper.setCode(bankCard.getCode());
|
list.add(bankCardWarpper);
|
}
|
return ResultUtil.success(list);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/api/user/addBankCard")
|
@ApiOperation(value = "添加银行卡【1.1】", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "银行", name = "bank", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "姓", name = "lastName", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "名", name = "firstName", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "卡号", name = "code", required = true, dataType = "string"),
|
@ApiImplicitParam(value = "1=中文,2=英文,3=法语", name = "language", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil addBankCard(String bank, String lastName, String firstName, String code, Integer language, HttpServletRequest request) {
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
UserInfo userInfo = userInfoService.selectById(uid);
|
if(ToolUtil.isEmpty(userInfo.getPhone())){
|
return ResultUtil.error(language == 1 ? "请先绑定手机号码" : language == 2 ? "Please bind your mobile phone number first." : "Veuillez d’abord vous inscrire en liant votre numéro de téléphone portable.");
|
}
|
BigDecimal bigDecimal = new BigDecimal(code);
|
long max = Long.MAX_VALUE;
|
if(bigDecimal.compareTo(new BigDecimal(max)) >= 0){
|
return ResultUtil.error(language == 1 ? "银行卡号格式错误" : language == 2 ? "Format error of bank card" : "Erreur de format de la carte bancaire");
|
}
|
BankCard bankCard = bankCardService.selectOne(new EntityWrapper<BankCard>().eq("code", code));
|
if(null != bankCard){
|
return ResultUtil.error(language == 1 ? "银行卡重复" : language == 2 ? "Reduplication of bank card" : "Reduplication de la carte bancaire");
|
}
|
bankCard = new BankCard();
|
bankCard.setUserId(uid);
|
bankCard.setUserType(1);
|
bankCard.setCode(code);
|
bankCard.setBank(bank);
|
bankCard.setFirstName(firstName);
|
bankCard.setLastName(lastName);
|
bankCard.setInsertTime(new Date());
|
bankCardService.insert(bankCard);
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/api/user/delBankCard")
|
@ApiOperation(value = "删除银行卡【1.1】", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "银行卡id", name = "id", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil delBankCard(Integer id){
|
try {
|
bankCardService.deleteById(id);
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 用户查询充值记录
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@PostMapping("/api/user/queryRechargeRecord")
|
@ApiOperation(value = "用户查询充值记录", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "语言", name = "language", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil queryRechargeRecord(Integer pageNum, Integer size,Integer language,HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
RechargeRecordWarpper rechargeRecordWarpper = new RechargeRecordWarpper();
|
List<Map<String,Object>> paymentRecord = paymentRecordService.queryRechargeRecord(uid, pageNum, size);
|
for (Map<String, Object> map : paymentRecord) {
|
if(null != map.get("insertTime")){
|
String time = map.get("insertTime").toString();
|
map.put("insertTime", DateUtil.conversionFormat(language, time));
|
}
|
}
|
// 分装返回充值记录实体
|
List<TransactionDetailsWarpper> transactionDetailsWarpper = TransactionDetailsWarpper.getTransactionDetailsWarpper(paymentRecord);
|
|
// 查询充值金额总和
|
double sum = paymentRecordService.queryRechargeMoneySum(uid);
|
rechargeRecordWarpper.setSum(sum);
|
rechargeRecordWarpper.setTransactionDetailsWarpper(transactionDetailsWarpper);
|
return ResultUtil.success(rechargeRecordWarpper);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 下载pdf
|
* @param orderId
|
* @param orderType
|
* @param response
|
*/
|
@ResponseBody
|
@GetMapping("/base/order/uploadReceiptPdf")
|
public void uploadReceiptPdf(Integer orderId, Integer orderType, HttpServletResponse response){
|
FileInputStream fileInputStream = null;
|
ServletOutputStream outputStream = null;
|
try {
|
if(orderType == 1){
|
fileInputStream = new FileInputStream(new File("/home/igotechgh/nginx/html/files/pdf/ride_receipt_" + orderId + ".pdf"));
|
}
|
if(orderType == 4){
|
fileInputStream = new FileInputStream(new File("/home/igotechgh/nginx/html/files/pdf/parcel_receipt_" + orderId + ".pdf"));
|
}
|
BufferedInputStream bf = new BufferedInputStream(fileInputStream);
|
outputStream = response.getOutputStream();
|
response.setContentType(MediaType.APPLICATION_PDF_VALUE);
|
response.setHeader("content-Disposition","attachment;filename=" + (orderId + "_" + orderType + ".pdf"));
|
byte[] b = new byte[bf.available() + 1000];
|
int i;
|
while((i=bf.read(b))!=-1){
|
outputStream.write(b,0, i);
|
}
|
outputStream.flush();
|
outputStream.close();
|
fileInputStream.close();
|
}catch (Exception e){
|
e.printStackTrace();
|
}finally {
|
try {
|
if(null != outputStream){
|
outputStream.close();
|
}
|
if(null != fileInputStream){
|
fileInputStream.close();
|
}
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/user/getFleetEngineAuth")
|
@ApiOperation(value = "获取google地图授权token", tags = {"用户端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "行程id", name = "tripId", required = true, dataType = "string"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<Map<String, Object>> getFleetEngineAuth(String tripId, HttpServletRequest request){
|
try {
|
Integer uid = userInfoService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
Map<String, Object> s = fleetEngineUtil.fleetEngineAuth(1, tripId);
|
return ResultUtil.success(s);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
@ResponseBody
|
@PostMapping("/base/user/textToSpeech")
|
public String textToSpeech(String languageCode, String text, String fileName){
|
try {
|
String s = TextToSpeechUtil.create(languageCode, text, fileName + ".mp3");
|
//定时任务删除语音文件
|
new Timer().schedule(new TimerTask() {
|
@Override
|
public void run() {
|
try {
|
// 使用Runtime执行命令
|
Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName + ".mp3");
|
// 读取命令的输出
|
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
String line;
|
while ((line = reader.readLine()) != null) {
|
System.out.println(line);
|
}
|
// 等待命令执行完成
|
process.waitFor();
|
// 关闭流
|
reader.close();
|
} catch (IOException | InterruptedException e) {
|
e.printStackTrace();
|
}
|
}
|
}, 30000);
|
return s;
|
} catch (Exception e) {
|
throw new RuntimeException(e);
|
}
|
}
|
|
|
|
@PostMapping("/base/user/delUserInfo")
|
public ResultUtil delUserInfo(String username, String password){
|
UserInfo userInfo = userInfoService.selectOne(new EntityWrapper<UserInfo>().eq("phone", username)
|
.ne("flag", 3));
|
if(null == userInfo){
|
return ResultUtil.error("Invalid account");
|
}
|
if(!ShiroKit.md5(password, salt).equals(userInfo.getPassWord())){
|
return ResultUtil.error("Wrong password");
|
}
|
userInfo.setFlag(3);
|
userInfoService.updateById(userInfo);
|
return ResultUtil.success();
|
}
|
}
|