|
|
@ -18,6 +18,8 @@ import com.hai.service.HighUserCouponService; |
|
|
|
import com.hai.service.HighUserService; |
|
|
|
import com.hai.service.HighUserService; |
|
|
|
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.poi.util.StringUtil; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -29,6 +31,7 @@ import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @Auther: 袁野 |
|
|
|
* @Auther: 袁野 |
|
|
@ -79,37 +82,34 @@ public class HighUserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/updateUserPhone", method = RequestMethod.GET) |
|
|
|
@RequestMapping(value = "/bindUserPhone", method = RequestMethod.GET) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "修改用户手机号") |
|
|
|
@ApiOperation(value = "绑定用户手机号") |
|
|
|
public ResponseData updateUserPhone(@RequestParam(value = "phone", required = true) String phone, |
|
|
|
public ResponseData bindUserPhone(@RequestParam(value = "phone", required = true) String phone, |
|
|
|
@RequestParam(value = "code", required = true) String code, |
|
|
|
@RequestParam(value = "code", required = true) String code, |
|
|
|
HttpServletRequest request) { |
|
|
|
HttpServletRequest request, HttpServletResponse response) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
VerifyCode verifyCode = VerifyCodeStorage.getDate(phone); |
|
|
|
VerifyCode verifyCode = VerifyCodeStorage.getDate(phone); |
|
|
|
if(verifyCode == null) { |
|
|
|
if(verifyCode == null) { |
|
|
|
log.error("HighUserController --> updateUserPhone() error!", "验证码错误"); |
|
|
|
log.error("HighUserController --> bindUserPhone() error!", "验证码错误"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "验证码错误"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "验证码错误"); |
|
|
|
} |
|
|
|
} |
|
|
|
if(!verifyCode.getObject().equals(code)) { |
|
|
|
if(!verifyCode.getObject().equals(code)) { |
|
|
|
log.error("HighUserController --> updateUserPhone() error!", "验证码错误"); |
|
|
|
log.error("HighUserController --> bindUserPhone() error!", "验证码错误"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "验证码错误"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "验证码错误"); |
|
|
|
} |
|
|
|
} |
|
|
|
// 用户
|
|
|
|
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
HighUser highUser = highUserService.bindUserPhone(phone, request); |
|
|
|
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); |
|
|
|
|
|
|
|
HighUser highUser = highUserService.findByUserId(userInfoModel.getHighUser().getId()); |
|
|
|
HighUserModel highUserModel = new HighUserModel(); |
|
|
|
if (highUser == null) { |
|
|
|
highUser.setPassword(null); |
|
|
|
log.error("HighUserController --> updateUserPhone() error!", "未找到用户"); |
|
|
|
highUserModel.setHighUser(highUser); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户"); |
|
|
|
SessionObject so = new SessionObject(highUser.getOpenId(), 1 , highUserModel); |
|
|
|
} |
|
|
|
userCenter.save(request, response, so); |
|
|
|
highUser.setPhone(phone); |
|
|
|
return ResponseMsgUtil.success(so); |
|
|
|
highUserService.updateUser(highUser); |
|
|
|
|
|
|
|
return ResponseMsgUtil.success("修改成功"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("HighUserController --> updateUserPhone() error!", e); |
|
|
|
log.error("HighUserController --> bindUserPhone() error!", e); |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|