|
|
@@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.EnvCommonService;
|
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
|
-import com.cyksj.common.constant.TaskTypeEnum;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.snowflake.Sequence;
|
|
|
import com.cyksj.common.util.Codec;
|
|
|
@@ -22,24 +21,18 @@ import com.cyksj.config.wxlogin.WxOpenPlatYHLXLoginConfig;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.PhoneCodeMapper;
|
|
|
-import com.cyksj.mapper.WxAppMapper;
|
|
|
-import com.cyksj.mapper.manage.distribute.UserDistributeSharedMapper;
|
|
|
-import com.cyksj.mapper.market.task.TaskTypeMapper;
|
|
|
import com.cyksj.model.dto.AuthRedirect;
|
|
|
import com.cyksj.model.dto.AuthToken;
|
|
|
import com.cyksj.model.dto.GzhOAuth2UserInfo;
|
|
|
import com.cyksj.model.dto.JsSdkTicket;
|
|
|
import com.cyksj.model.entity.PhoneCode;
|
|
|
-import com.cyksj.model.entity.TaskType;
|
|
|
import com.cyksj.model.entity.User;
|
|
|
-import com.cyksj.model.entity.UserDistributeShared;
|
|
|
import com.cyksj.model.request.LoginPhoneReq;
|
|
|
import com.cyksj.model.response.LoginPhoneRep;
|
|
|
import com.cyksj.model.response.WxGzhQrCodeTicketRep;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.authorization.AuthorizationService;
|
|
|
-import com.cyksj.service.market.task.TaskService;
|
|
|
-import com.cyksj.service.order.OrderDonService;
|
|
|
+import com.cyksj.service.distribute.DistributeService;
|
|
|
import com.cyksj.service.template.TemplateCommonService;
|
|
|
import com.cyksj.service.user.UserService;
|
|
|
import com.cyksj.service.wechat.WeChatService;
|
|
|
@@ -48,7 +41,6 @@ import com.cyksj.web.util.StpUserUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -81,8 +73,6 @@ public class AuthorizationController {
|
|
|
|
|
|
private final WeChatService weChatService;
|
|
|
|
|
|
- private final WxAppMapper wxAppMapper;
|
|
|
-
|
|
|
private final WeChatConfig weChatConfig;
|
|
|
|
|
|
private final RedisService redisService;
|
|
|
@@ -91,20 +81,14 @@ public class AuthorizationController {
|
|
|
|
|
|
private final EnvCommonService envCommonService;
|
|
|
|
|
|
- private final OrderDonService orderDonService;
|
|
|
-
|
|
|
private final PhoneCodeMapper phoneCodeMapper;
|
|
|
|
|
|
- private final UserDistributeSharedMapper userDistributeSharedMapper;
|
|
|
-
|
|
|
- private final TaskService taskService;
|
|
|
-
|
|
|
- private final TaskTypeMapper taskTypeMapper;
|
|
|
-
|
|
|
private final MailService mailService;
|
|
|
|
|
|
private final TemplateCommonService templateCommonService;
|
|
|
|
|
|
+ private final DistributeService distributeService;
|
|
|
+
|
|
|
@GetMapping(value = "/weChat")
|
|
|
public void base(String url,Long sharedId, String authType, HttpServletResponse response) throws Exception {
|
|
|
|
|
|
@@ -262,9 +246,9 @@ public class AuthorizationController {
|
|
|
* 网页扫描微信公众号二维码 临时凭证ticket 关注后登录
|
|
|
*/
|
|
|
@GetMapping("/wx/gzh/login/qrCode")
|
|
|
- public Result<WxGzhQrCodeTicketRep> getWxGzhQrCode() throws Exception {
|
|
|
+ public Result<WxGzhQrCodeTicketRep> getWxGzhQrCode(Long sharedId) throws Exception {
|
|
|
//获取gzh带参数的二维码
|
|
|
- WxGzhQrCodeTicketRep result = weChatService.getWxGzhQrCode();
|
|
|
+ WxGzhQrCodeTicketRep result = weChatService.getWxGzhQrCode(sharedId);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(result);
|
|
|
}
|
|
|
|
|
|
@@ -274,10 +258,12 @@ public class AuthorizationController {
|
|
|
@GetMapping("/wx/gzh/sceneStr/checkQrCode")
|
|
|
public Result<String> checkQrCodeByGzhSceneStr(String sceneStr) throws Exception {
|
|
|
String key = RedisService.key.WX_GZH_QRCODE_LOGIN.getNameFormat(sceneStr);
|
|
|
- Long userId = (Long) redisService.get(key);
|
|
|
- if (userId == null) {
|
|
|
+ Object value = redisService.get(key);
|
|
|
+ if (value == null) {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().setMsg("用户未扫码").toResult();
|
|
|
}
|
|
|
+ Long userId = Long.parseLong(value.toString());
|
|
|
+
|
|
|
redisService.del(key);
|
|
|
User user = userService.getById(userId);
|
|
|
StpUserUtil.login(userId);
|
|
|
@@ -390,7 +376,6 @@ public class AuthorizationController {
|
|
|
}
|
|
|
//保存用户信息
|
|
|
User user = userService.getOne(wrapper);
|
|
|
- UserDistributeShared userDistributeShared = null;
|
|
|
Long sharedId = loginPhoneReq.getSharedId();
|
|
|
if (user == null) {
|
|
|
user = new User();
|
|
|
@@ -412,25 +397,12 @@ public class AuthorizationController {
|
|
|
userService.save(user);
|
|
|
//新用户分销
|
|
|
if (sharedId != null) {
|
|
|
- userDistributeShared = new UserDistributeShared();
|
|
|
- userDistributeShared.setSharedId(loginPhoneReq.getSharedId());
|
|
|
+ distributeService.saveDistributionInvitation(sharedId, user.getId());
|
|
|
}
|
|
|
}
|
|
|
//写回登陆信息
|
|
|
StpUserUtil.login(user.getId());
|
|
|
LoginPhoneRep loginPhoneRep = new LoginPhoneRep(StpUserUtil.getTokenValue(), user.getId(), user.getNickname(), user.getHeadimgurl());
|
|
|
- //存在分销
|
|
|
- if (userDistributeShared != null) {
|
|
|
- userDistributeShared.setUserId(user.getId());
|
|
|
- try {
|
|
|
- userDistributeSharedMapper.insert(userDistributeShared);
|
|
|
- TaskType taskType = taskTypeMapper.selectOne(Wrappers.lambdaQuery(TaskType.class)
|
|
|
- .eq(TaskType::getName, TaskTypeEnum.share.getDesc()).last("limit 1"));
|
|
|
- taskService.completeTask(taskType, sharedId);
|
|
|
- } catch (DuplicateKeyException e) {
|
|
|
- log.info("分销被邀请人重复插入");
|
|
|
- }
|
|
|
- }
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(loginPhoneRep);
|
|
|
}
|
|
|
}
|