|
|
@@ -4,22 +4,18 @@ import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
|
-import com.cyksj.common.constant.TaskTypeEnum;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
-import com.cyksj.mapper.market.task.TaskTypeMapper;
|
|
|
-import com.cyksj.mapper.market.task.UserBindPhoneMapper;
|
|
|
+import com.cyksj.mapper.market.task.UserBindDetailMapper;
|
|
|
import com.cyksj.model.entity.TaskFollowPlatVerify;
|
|
|
-import com.cyksj.model.entity.TaskType;
|
|
|
-import com.cyksj.model.entity.UserBindPhone;
|
|
|
+import com.cyksj.model.entity.UserBindDetail;
|
|
|
import com.cyksj.model.request.LoginPhoneReq;
|
|
|
import com.cyksj.model.request.TaskFollowReq;
|
|
|
import com.cyksj.model.views.TaskFrontView;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.market.MarketFrontService;
|
|
|
-import com.cyksj.service.market.task.TaskService;
|
|
|
-import com.cyksj.service.phone.PhoneCodeService;
|
|
|
+import com.cyksj.service.market.task.BindTaskService;
|
|
|
import com.cyksj.web.util.StpUserUtil;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.SearchResult;
|
|
|
@@ -49,16 +45,12 @@ public class TaskFrontController {
|
|
|
|
|
|
private final HttpServletRequest request;
|
|
|
|
|
|
- private final UserBindPhoneMapper userBindPhoneMapper;
|
|
|
-
|
|
|
- private final PhoneCodeService phoneCodeService;
|
|
|
-
|
|
|
- private final TaskService taskService;
|
|
|
-
|
|
|
- private final TaskTypeMapper taskTypeMapper;
|
|
|
+ private final UserBindDetailMapper UserBindDetailMapper;
|
|
|
|
|
|
private final RedisService redisService;
|
|
|
|
|
|
+ private final BindTaskService bindTaskService;
|
|
|
+
|
|
|
/**
|
|
|
* 任务列表
|
|
|
*/
|
|
|
@@ -90,33 +82,7 @@ public class TaskFrontController {
|
|
|
@NoSubmit
|
|
|
public Result<String> bindPhone(@RequestBody LoginPhoneReq phoneReq) {
|
|
|
Long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
- UserBindPhone other = userBindPhoneMapper.selectOne(Wrappers.lambdaQuery(UserBindPhone.class)
|
|
|
- .eq(UserBindPhone::getPhone, phoneReq.getPhone()).ne(UserBindPhone::getUserId, userId).select(UserBindPhone::getId).last("limit 1"));
|
|
|
- if (other != null) {
|
|
|
- throw BusinessRuntimeException.getInstance("该手机号已被绑定");
|
|
|
- }
|
|
|
- UserBindPhone bindPhone = Optional.ofNullable(userBindPhoneMapper.selectOne(Wrappers.lambdaQuery(UserBindPhone.class)
|
|
|
- .eq(UserBindPhone::getUserId, userId).last("limit 1"))).orElse(new UserBindPhone());
|
|
|
- if (StrUtil.isNotBlank(bindPhone.getPhone())) {
|
|
|
- throw BusinessRuntimeException.getInstance("您已绑定手机号");
|
|
|
- }
|
|
|
- //校验
|
|
|
- phoneCodeService.checkPhone(phoneReq.getPhone(), phoneReq.getCode());
|
|
|
- bindPhone.setUserId(userId);
|
|
|
- bindPhone.setPhone(phoneReq.getPhone());
|
|
|
- try {
|
|
|
- if (bindPhone.getId() == null) {
|
|
|
- userBindPhoneMapper.insert(bindPhone);
|
|
|
- }else {
|
|
|
- userBindPhoneMapper.updateById(bindPhone);
|
|
|
- }
|
|
|
- } catch (DuplicateKeyException e) {
|
|
|
-
|
|
|
- }
|
|
|
- TaskType taskType = taskTypeMapper.selectOne(Wrappers.lambdaQuery(TaskType.class)
|
|
|
- .eq(TaskType::getName, TaskTypeEnum.bind_phone.getDesc()).last("limit 1"));
|
|
|
- //完成任务
|
|
|
- taskService.completeTask(taskType, userId);
|
|
|
+ bindTaskService.bindPhone(userId, phoneReq.getPhone(), phoneReq.getCode(), true);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("绑定手机号成功");
|
|
|
}
|
|
|
|
|
|
@@ -129,13 +95,13 @@ public class TaskFrontController {
|
|
|
if (!Validator.isEmail(phoneReq.getEmail())) {
|
|
|
throw BusinessRuntimeException.getInstance("请输入正确的邮箱");
|
|
|
}
|
|
|
- UserBindPhone other = userBindPhoneMapper.selectOne(Wrappers.lambdaQuery(UserBindPhone.class)
|
|
|
- .eq(UserBindPhone::getEmail, phoneReq.getEmail()).ne(UserBindPhone::getUserId, userId).select(UserBindPhone::getId).last("limit 1"));
|
|
|
+ UserBindDetail other = UserBindDetailMapper.selectOne(Wrappers.lambdaQuery(UserBindDetail.class)
|
|
|
+ .eq(UserBindDetail::getEmail, phoneReq.getEmail()).ne(UserBindDetail::getUserId, userId).select(UserBindDetail::getId).last("limit 1"));
|
|
|
if (other != null) {
|
|
|
throw BusinessRuntimeException.getInstance("该邮箱已被绑定");
|
|
|
}
|
|
|
- UserBindPhone bindPhone = Optional.ofNullable(userBindPhoneMapper.selectOne(Wrappers.lambdaQuery(UserBindPhone.class)
|
|
|
- .eq(UserBindPhone::getUserId, userId).last("limit 1"))).orElse(new UserBindPhone());
|
|
|
+ UserBindDetail bindPhone = Optional.ofNullable(UserBindDetailMapper.selectOne(Wrappers.lambdaQuery(UserBindDetail.class)
|
|
|
+ .eq(UserBindDetail::getUserId, userId).last("limit 1"))).orElse(new UserBindDetail());
|
|
|
if (StrUtil.isNotBlank(bindPhone.getEmail())) {
|
|
|
throw BusinessRuntimeException.getInstance("您已绑定邮箱");
|
|
|
}
|
|
|
@@ -150,9 +116,9 @@ public class TaskFrontController {
|
|
|
bindPhone.setUserId(userId);
|
|
|
try {
|
|
|
if (bindPhone.getId() == null) {
|
|
|
- userBindPhoneMapper.insert(bindPhone);
|
|
|
+ UserBindDetailMapper.insert(bindPhone);
|
|
|
}else {
|
|
|
- userBindPhoneMapper.updateById(bindPhone);
|
|
|
+ UserBindDetailMapper.updateById(bindPhone);
|
|
|
}
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
|
|
|
@@ -168,19 +134,7 @@ public class TaskFrontController {
|
|
|
@PutMapping("/put/bind/phone")
|
|
|
public Result<String> updateBindPhone(@RequestBody LoginPhoneReq phoneReq) {
|
|
|
Long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
- UserBindPhone bindPhone = userBindPhoneMapper.selectOne(Wrappers.lambdaQuery(UserBindPhone.class)
|
|
|
- .eq(UserBindPhone::getUserId, userId).last("limit 1"));
|
|
|
- if (bindPhone == null || StrUtil.isEmpty(bindPhone.getPhone())) {
|
|
|
- throw BusinessRuntimeException.getInstance("您未绑定手机号");
|
|
|
- }
|
|
|
- UserBindPhone other = userBindPhoneMapper.selectOne(Wrappers.lambdaQuery(UserBindPhone.class)
|
|
|
- .eq(UserBindPhone::getPhone, phoneReq.getPhone()).ne(UserBindPhone::getUserId, userId).select(UserBindPhone::getId).last("limit 1"));
|
|
|
- if (other != null) {
|
|
|
- throw BusinessRuntimeException.getInstance("该手机号已被绑定");
|
|
|
- }
|
|
|
- phoneCodeService.checkPhone(phoneReq.getPhone(), phoneReq.getCode());
|
|
|
- bindPhone.setPhone(phoneReq.getPhone());
|
|
|
- userBindPhoneMapper.updateById(bindPhone);
|
|
|
+ bindTaskService.updateBindPhone(userId, phoneReq.getPhone(), phoneReq.getCode());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("更换手机号成功");
|
|
|
}
|
|
|
|