| | |
| | | package com.stylefeng.guns.modular.api; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.stylefeng.guns.core.common.constant.JwtConstants; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.model.Invite; |
| | | import com.stylefeng.guns.modular.system.model.UserInfo; |
| | | import com.stylefeng.guns.modular.system.service.IInviteService; |
| | | import com.stylefeng.guns.modular.system.service.ISmsrecordService; |
| | | import com.stylefeng.guns.modular.system.service.IUserInfoService; |
| | | import com.stylefeng.guns.modular.system.service.IVerifiedService; |
| | |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private WeChatUtil weChatUtil; |
| | | @Autowired |
| | | private IInviteService inviteService; |
| | | |
| | | |
| | | /** |
| | | * 获取用户邀请二维码 |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/user/getCode") |
| | | @ApiOperation(value = "获取用户邀请二维码", tags = {"用户端-2.0新增"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<Map<String,String>> getCode(HttpServletRequest request){ |
| | | try { |
| | | Integer uid = userInfoService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | UserInfo userInfo = userInfoService.selectById(uid); |
| | | if (userInfo.getCode()==null){ |
| | | userInfo = userInfoService.generateCode(userInfo); |
| | | } |
| | | Map<String, String> res = new HashMap<>(); |
| | | res.put("code",userInfo.getCode()); |
| | | int i = inviteService.selectCount(new EntityWrapper<Invite>() |
| | | .eq("inviteUserId", uid) |
| | | .eq("userType", 1)); |
| | | |
| | | res.put("inviteNumber",i+""); |
| | | return ResultUtil.success(res); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | /** |
| | | * 获取用户邀请二维码 |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/user/inviteList") |
| | | @ApiOperation(value = "获取用户邀请记录", tags = {"用户端-2.0新增"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "开始时间 yyyy-MM-dd", name = "startTime", required = false, dataType = "String"), |
| | | @ApiImplicitParam(value = "结束时间 yyyy-MM-dd", name = "endTime", required = false, dataType = "String"), |
| | | @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<List<Invite>> inviteList(String startTime,String endTime,Integer pageNum,Integer size,HttpServletRequest request){ |
| | | try { |
| | | Integer uid = userInfoService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | if (StringUtils.hasLength(startTime)){ |
| | | startTime = startTime + " 00:00:00"; |
| | | endTime = endTime + " 23:59:59"; |
| | | } |
| | | pageNum = (pageNum - 1) * size; |
| | | List<Invite> invites = inviteService.inviteList(uid,startTime,endTime,pageNum,size); |
| | | for (Invite invite : invites) { |
| | | // 将手机号phone中间四位替换为* |
| | | String phone = invite.getPhone(); |
| | | if (phone != null && phone.length() > 4) { |
| | | phone = phone.substring(0, 3) + "****" + phone.substring(7); |
| | | invite.setPhone(phone); |
| | | } |
| | | } |
| | | return ResultUtil.success(invites); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | @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 = "分享人用户id-扫码分享传 ", name = "uid", required = false, dataType = "int"), |
| | | @ApiImplicitParam(value = "分享人类型1用户2司机-扫码分享传 ", name = "userType", required = false, dataType = "int"), |
| | | @ApiImplicitParam(value = "登录端口-小程序传Applets", name = "loginType", required = false, dataType = "String"), |
| | | @ApiImplicitParam(value = "当前定位区县行政编号", name = "registAreaCode", required = false, dataType = "String") |
| | | }) |
| | | public ResultUtil<LoginWarpper> captchaLogin(String phone, String code, String registIp, String registAreaCode,String loginType){ |
| | | public ResultUtil<LoginWarpper> captchaLogin(String phone, String code, String registIp, String registAreaCode,String loginType |
| | | ,Integer uid,Integer userType){ |
| | | try { |
| | | return userInfoService.captchaLogin(phone, code, registIp, registAreaCode,loginType); |
| | | return userInfoService.captchaLogin(phone, code, registIp, registAreaCode,loginType,uid,userType); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "登录端口(1:APP,2:小程序)", name = "type", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "微信openid(APP登录上传)", name = "openid", required = false, dataType = "String"), |
| | | @ApiImplicitParam(value = "分享人用户id-扫码分享传 ", name = "uid", required = false, dataType = "int"), |
| | | @ApiImplicitParam(value = "分享人类型1用户2司机-扫码分享传 ", name = "userType", required = false, dataType = "int"), |
| | | @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 = "avatar", required = false, dataType = "String"), |
| | | @ApiImplicitParam(value = "昵称", name = "nickName", required = false, dataType = "String"), |
| | | @ApiImplicitParam(value = "登录端口-小程序传Applets", name = "loginType", required = false, dataType = "String"), |
| | | @ApiImplicitParam(value = "性别(1=男,2=女)", name = "sex", required = false, dataType = "int") |
| | | @ApiImplicitParam(value = "性别(1=男,2=女)", name = "sex", required = false, dataType = "int"), |
| | | @ApiImplicitParam(value = "手机号 获取微信号用", name = "phone", required = false, dataType = "String") |
| | | |
| | | }) |
| | | public ResultUtil<LoginWarpper> wxLogin(Integer type, String openid, String unionid, String jscode, String registIp, String registAreaCode, Integer sex, String nickName, String avatar,String loginType){ |
| | | public ResultUtil<LoginWarpper> wxLogin(Integer type, String openid, String unionid, String jscode, String registIp, String registAreaCode, Integer sex, String nickName, String avatar,String loginType |
| | | ,Integer uid,Integer userType,String phone){ |
| | | try { |
| | | return userInfoService.wxLogin(type, openid, unionid, jscode, registIp, registAreaCode, sex, nickName, avatar,loginType); |
| | | return userInfoService.wxLogin(type, openid, unionid, jscode, registIp, registAreaCode, sex, nickName, avatar,loginType,uid,userType,phone); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |