|
|
@ -8,9 +8,15 @@ import com.hfkj.common.security.UserCenter; |
|
|
|
import com.hfkj.common.utils.MemberValidateUtil; |
|
|
|
import com.hfkj.common.utils.MemberValidateUtil; |
|
|
|
import com.hfkj.common.utils.RedisUtil; |
|
|
|
import com.hfkj.common.utils.RedisUtil; |
|
|
|
import com.hfkj.common.utils.ResponseMsgUtil; |
|
|
|
import com.hfkj.common.utils.ResponseMsgUtil; |
|
|
|
|
|
|
|
import com.hfkj.entity.BsUser; |
|
|
|
import com.hfkj.model.ResponseData; |
|
|
|
import com.hfkj.model.ResponseData; |
|
|
|
import com.hfkj.model.UserSessionObject; |
|
|
|
import com.hfkj.model.UserSessionObject; |
|
|
|
|
|
|
|
import com.hfkj.service.user.BsUserAccountRecordService; |
|
|
|
|
|
|
|
import com.hfkj.service.user.BsUserAccountService; |
|
|
|
|
|
|
|
import com.hfkj.service.user.BsUserGradeService; |
|
|
|
import com.hfkj.service.user.BsUserService; |
|
|
|
import com.hfkj.service.user.BsUserService; |
|
|
|
|
|
|
|
import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum; |
|
|
|
|
|
|
|
import com.hfkj.sysenum.user.UserGradeEnum; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@ -22,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
@ -34,185 +41,61 @@ import java.util.Map; |
|
|
|
@RequestMapping(value="/userGrade") |
|
|
|
@RequestMapping(value="/userGrade") |
|
|
|
@Api(value="客户端业务") |
|
|
|
@Api(value="客户端业务") |
|
|
|
public class UserGradeController { |
|
|
|
public class UserGradeController { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private UserCenter userCenter; |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private BsUserService userService; |
|
|
|
private BsUserService userService; |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private RedisUtil redisUtil; |
|
|
|
private BsUserGradeService userGradeService; |
|
|
|
@Autowired |
|
|
|
|
|
|
|
private UserCenter userCenter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getUser", method = RequestMethod.GET) |
|
|
|
@RequestMapping(value = "/payGrade2", method = RequestMethod.POST) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "查询用户信息") |
|
|
|
@ApiOperation(value = "购买【优淘会员】等级") |
|
|
|
public ResponseData getUser() { |
|
|
|
public ResponseData payGrade2() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
|
|
|
|
// 用户信息
|
|
|
|
|
|
|
|
param.put("user", userCenter.getSessionModel(UserSessionObject.class)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(param); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/updateWechat", method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "修改用户微信号") |
|
|
|
|
|
|
|
public ResponseData updateWechat(@RequestBody JSONObject body) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
if (body == null || StringUtils.isBlank(body.getString("wechatNum"))) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); |
|
|
|
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); |
|
|
|
userService.updateWechatNum(userSession.getUser().getId(), body.getString("wechatNum")); |
|
|
|
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
// 购买
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
userGradeService.payGrade2(userSession.getUser().getId()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/bindPhone", method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "绑定手机号") |
|
|
|
|
|
|
|
public ResponseData bindPhone(@RequestBody JSONObject body) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
if (body == null |
|
|
|
|
|
|
|
|| StringUtils.isBlank(body.getString("phone")) |
|
|
|
|
|
|
|
|| StringUtils.isBlank(body.getString("smsCode"))) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(userSession.getUser().getPhone())) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "手机号已绑定"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String phone = body.getString("phone"); |
|
|
|
|
|
|
|
// 校验手机号格式
|
|
|
|
|
|
|
|
if (!MemberValidateUtil.validatePhone(phone)) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isBlank(body.getString("smsCode"))) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入短信验证码"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (userService.getUser(phone) != null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "手机号已被绑定"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 手机号的验证码
|
|
|
|
|
|
|
|
Object phoneCodeObject = redisUtil.get("SMS_BIND_PHONE_CODE:" + phone); |
|
|
|
|
|
|
|
if (phoneCodeObject == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!body.getString("smsCode").equals(phoneCodeObject.toString())) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
redisUtil.del("SMS_BIND_PHONE_CODE:" + phone); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新手机号
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
userService.updatePhone(userSession.getUser().getId(), body.getString("phone")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(userCenter.getSessionModel(UserSessionObject.class)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/bindInviteUser", method = RequestMethod.POST) |
|
|
|
@RequestMapping(value = "/queryProgress", method = RequestMethod.GET) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "绑定邀请人Id") |
|
|
|
@ApiOperation(value = "查询升级条件进度") |
|
|
|
public ResponseData bindInviteUser(@RequestBody JSONObject body) { |
|
|
|
public ResponseData queryProgress() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (body == null || body.getLong("inviteUseId") == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); |
|
|
|
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); |
|
|
|
|
|
|
|
|
|
|
|
// 绑定邀请人
|
|
|
|
// 查询用户
|
|
|
|
userService.bindInviteUser(userSession.getUser().getId(), body.getLong("inviteUseId")); |
|
|
|
BsUser user = userService.getUser(userSession.getUser().getId()); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(userCenter.getSessionModel(UserSessionObject.class)); |
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
if (UserGradeEnum.grade1.getCode().equals(user.getGrade())) { |
|
|
|
|
|
|
|
// 晋升优淘会员
|
|
|
|
|
|
|
|
map = userGradeService.promoteGrade2Progress(user.getId()); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} else if (UserGradeEnum.grade2.getCode().equals(user.getGrade())) { |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
// 晋升团长渠道
|
|
|
|
} |
|
|
|
map = userGradeService.promoteGrade3Progress(user.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/verifyUpdPhoneSmsCode", method = RequestMethod.POST) |
|
|
|
} else if (UserGradeEnum.grade3.getCode().equals(user.getGrade())) { |
|
|
|
@ResponseBody |
|
|
|
// 晋升渠道进度
|
|
|
|
@ApiOperation(value = "验证修改手机号验证码") |
|
|
|
map = userGradeService.promoteGrade4Progress(user.getId()); |
|
|
|
public ResponseData verifyUpdPhoneSmsCode(@RequestBody JSONObject body) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
if (body == null |
|
|
|
|
|
|
|
|| StringUtils.isBlank(body.getString("phone")) |
|
|
|
|
|
|
|
|| StringUtils.isBlank(body.getString("smsCode"))) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String phone = body.getString("phone"); |
|
|
|
|
|
|
|
// 手机号的验证码
|
|
|
|
|
|
|
|
Object phoneCodeObject = redisUtil.get("SMS_UPDATE_PHONE_CODE:" + phone); |
|
|
|
|
|
|
|
if (phoneCodeObject == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误或已失效"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (!body.getString("smsCode").equals(phoneCodeObject.toString())) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误或已失效"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
redisUtil.del("SMS_UPDATE_PHONE_CODE:" + phone); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(true); |
|
|
|
map.put("currentUserGrade", user.getGrade()); |
|
|
|
|
|
|
|
return ResponseMsgUtil.success(map); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/updatePhone", method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "修改手机号") |
|
|
|
|
|
|
|
public ResponseData updatePhone(@RequestBody JSONObject body) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
if (body == null |
|
|
|
|
|
|
|
|| StringUtils.isBlank(body.getString("newPhone")) |
|
|
|
|
|
|
|
|| StringUtils.isBlank(body.getString("smsCode"))) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); |
|
|
|
|
|
|
|
if (StringUtils.isBlank(userSession.getUser().getPhone())) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户未绑定手机号"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String phone = body.getString("newPhone"); |
|
|
|
|
|
|
|
if (userSession.getUser().getPhone().equals(phone)) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "新手机号与现绑定手机号相同"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (userService.getUser(phone) != null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "手机号已被绑定"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 校验手机号格式
|
|
|
|
|
|
|
|
if (!MemberValidateUtil.validatePhone(phone)) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isBlank(body.getString("smsCode"))) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入短信验证码"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 手机号的验证码
|
|
|
|
|
|
|
|
Object phoneCodeObject = redisUtil.get("SMS_UPDATE_PHONE_CODE:" + phone); |
|
|
|
|
|
|
|
if (phoneCodeObject == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误或已失效"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!body.getString("smsCode").equals(phoneCodeObject.toString())) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误或已失效"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
redisUtil.del("SMS_UPDATE_PHONE_CODE:" + phone); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新手机号
|
|
|
|
|
|
|
|
userService.updatePhone(userSession.getUser().getId(), body.getString("newPhone")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(userCenter.getSessionModel(UserSessionObject.class)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|