| | |
| | | package com.jilongda.applet.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.jilongda.applet.model.TAppUser; |
| | | import com.jilongda.applet.mapper.TAppUserMapper; |
| | | import com.jilongda.applet.service.TAppUserService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.jilongda.applet.utils.RptUtils; |
| | | import com.jilongda.applet.wx.pojo.AppletUserDecodeData; |
| | | import com.jilongda.common.exception.ServiceException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.core.token.TokenService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Service |
| | | public class TAppUserServiceImpl extends ServiceImpl<TAppUserMapper, TAppUser> implements TAppUserService { |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @Override |
| | | public void wxLogin(AppletUserDecodeData appletUserDecodeData) { |
| | | // 通过手机号查询用户,是否已存在手动导入用户,包含支付宝用户 |
| | | TAppUser appUser = this.getOne(Wrappers.lambdaQuery(TAppUser.class) |
| | | .eq(TAppUser::getOpenId, appletUserDecodeData.getOpenId()) |
| | | .last("LIMIT 1")); |
| | | if(Objects.isNull(appUser)){ |
| | | appUser = new TAppUser(); |
| | | appUser.setPhone(appletUserDecodeData.getPhoneNumber()); |
| | | appUser.setAvatar(StringUtils.hasLength(appUser.getAvatar())?appUser.getAvatar():""); |
| | | appUser.setName(StringUtils.hasLength(appUser.getName())?appUser.getName(): RptUtils.around(appletUserDecodeData.getPhoneNumber(),3,4)); |
| | | appUser.setOpenId(appletUserDecodeData.getOpenId()); |
| | | this.save(appUser); |
| | | }else { |
| | | if(appUser.getStatus()!=1){ |
| | | throw new ServiceException("账号被冻结,请联系管理员"); |
| | | } |
| | | } |
| | | } |
| | | } |