|
@@ -9,10 +9,12 @@ import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
|
|
import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
|
|
|
import com.cyksj.config.WeChatConfig;
|
|
import com.cyksj.config.WeChatConfig;
|
|
|
|
|
+import com.cyksj.enums.GatewayApiCode;
|
|
|
import com.cyksj.mapper.UserMapper;
|
|
import com.cyksj.mapper.UserMapper;
|
|
|
import com.cyksj.mapper.UserTransferLogMapper;
|
|
import com.cyksj.mapper.UserTransferLogMapper;
|
|
|
import com.cyksj.mapper.WxSyncLogMapper;
|
|
import com.cyksj.mapper.WxSyncLogMapper;
|
|
|
import com.cyksj.mapper.channel.ChannelPopularizeMapper;
|
|
import com.cyksj.mapper.channel.ChannelPopularizeMapper;
|
|
|
|
|
+import com.cyksj.mapper.market.task.UserBindPhoneMapper;
|
|
|
import com.cyksj.model.dto.GzhOAuth2UserInfo;
|
|
import com.cyksj.model.dto.GzhOAuth2UserInfo;
|
|
|
import com.cyksj.model.dto.UserWhoami;
|
|
import com.cyksj.model.dto.UserWhoami;
|
|
|
import com.cyksj.model.entity.*;
|
|
import com.cyksj.model.entity.*;
|
|
@@ -55,6 +57,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
|
|
|
|
|
private final RedisService redisService;
|
|
private final RedisService redisService;
|
|
|
|
|
|
|
|
|
|
+ private final UserBindPhoneMapper userBindPhoneMapper;
|
|
|
|
|
+
|
|
|
private static final GlobalThreadPoolTaskExecutor TASK_POOL = GlobalThreadPoolTaskExecutor.getInstance();
|
|
private static final GlobalThreadPoolTaskExecutor TASK_POOL = GlobalThreadPoolTaskExecutor.getInstance();
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -125,7 +129,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public UserWhoami whoami(long userId) {
|
|
public UserWhoami whoami(long userId) {
|
|
|
- User user = this.getById(userId);
|
|
|
|
|
|
|
+ User user = this.getWechatUserByRelation(userId);
|
|
|
Assert.notNull(user,"业务处理失败,请联系客服");
|
|
Assert.notNull(user,"业务处理失败,请联系客服");
|
|
|
UserWhoami userWhoami = new UserWhoami();
|
|
UserWhoami userWhoami = new UserWhoami();
|
|
|
|
|
|
|
@@ -197,4 +201,27 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
Constant.FIXED_CUSTOMER_COUPON_IDS.forEach(couponId -> couponCommonService.sendCouponToUser(userId, couponId, 0l, 0l, 0l, CouponUser.Channel.wxCorp));
|
|
Constant.FIXED_CUSTOMER_COUPON_IDS.forEach(couponId -> couponCommonService.sendCouponToUser(userId, couponId, 0l, 0l, 0l, CouponUser.Channel.wxCorp));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public User getWechatUserByRelation(Long userId) {
|
|
|
|
|
+ User user = this.getById(userId);
|
|
|
|
|
+ if (user == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.isNotBlank(user.getOpenId())) {
|
|
|
|
|
+ return user;
|
|
|
|
|
+ }
|
|
|
|
|
+ String phone = user.getPhone();
|
|
|
|
|
+ String email = user.getEmail();
|
|
|
|
|
+ //微信绑定手机号、邮箱
|
|
|
|
|
+ UserBindPhone userBindPhone = userBindPhoneMapper.selectOne(Wrappers.lambdaQuery(UserBindPhone.class)
|
|
|
|
|
+ .eq(StrUtil.isNotEmpty(phone), UserBindPhone::getPhone, phone)
|
|
|
|
|
+ .or()
|
|
|
|
|
+ .eq(StrUtil.isNotEmpty(email), UserBindPhone::getEmail, email).last("limit 1"));
|
|
|
|
|
+ if (userBindPhone == null) {
|
|
|
|
|
+ return user;
|
|
|
|
|
+ }
|
|
|
|
|
+ user = this.getById(userBindPhone.getUserId());
|
|
|
|
|
+ return user;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|