|
@@ -8,8 +8,10 @@ import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.izouma.jiashanxia.config.Constants;
|
|
import com.izouma.jiashanxia.config.Constants;
|
|
|
import com.izouma.jiashanxia.domain.User;
|
|
import com.izouma.jiashanxia.domain.User;
|
|
|
|
|
+import com.izouma.jiashanxia.dto.UserDTO;
|
|
|
import com.izouma.jiashanxia.enums.Member;
|
|
import com.izouma.jiashanxia.enums.Member;
|
|
|
import com.izouma.jiashanxia.dto.PageQuery;
|
|
import com.izouma.jiashanxia.dto.PageQuery;
|
|
|
import com.izouma.jiashanxia.dto.PromotionDTO;
|
|
import com.izouma.jiashanxia.dto.PromotionDTO;
|
|
@@ -28,14 +30,12 @@ import com.izouma.jiashanxia.service.storage.StorageService;
|
|
|
import com.izouma.jiashanxia.utils.JpaUtils;
|
|
import com.izouma.jiashanxia.utils.JpaUtils;
|
|
|
import com.izouma.jiashanxia.utils.SecurityUtils;
|
|
import com.izouma.jiashanxia.utils.SecurityUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
-import lombok.SneakyThrows;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
import me.chanjar.weixin.mp.api.WxMpService;
|
|
import me.chanjar.weixin.mp.api.WxMpService;
|
|
|
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
|
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
|
|
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
|
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
|
|
import net.coobird.thumbnailator.Thumbnails;
|
|
import net.coobird.thumbnailator.Thumbnails;
|
|
|
-import org.apache.commons.io.IOUtils;
|
|
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -68,7 +68,6 @@ public class UserService {
|
|
|
private final CaptchaService captchaService;
|
|
private final CaptchaService captchaService;
|
|
|
private final OrderInfoRepo orderInfoRepo;
|
|
private final OrderInfoRepo orderInfoRepo;
|
|
|
private final CommissionRecordRepo commissionRecordRepo;
|
|
private final CommissionRecordRepo commissionRecordRepo;
|
|
|
- private final SysConfigService sysConfigService;
|
|
|
|
|
|
|
|
|
|
public Page<User> all(PageQuery pageQuery) {
|
|
public Page<User> all(PageQuery pageQuery) {
|
|
|
pageQuery.setSort("createdAt,desc");
|
|
pageQuery.setSort("createdAt,desc");
|
|
@@ -193,9 +192,7 @@ public class UserService {
|
|
|
// 传过来的上级
|
|
// 传过来的上级
|
|
|
User user1 = userRepo.findById(parent).orElse(null);
|
|
User user1 = userRepo.findById(parent).orElse(null);
|
|
|
|
|
|
|
|
- if (ObjectUtil.isNotNull(user1) && !Member.NORMAL.equals(user1.getMember())) {
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return ObjectUtil.isNotNull(user1) && !Member.NORMAL.equals(user1.getMember());
|
|
|
}
|
|
}
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
@@ -238,8 +235,6 @@ public class UserService {
|
|
|
.teamFounder(false)
|
|
.teamFounder(false)
|
|
|
.wxAuthorized(true)
|
|
.wxAuthorized(true)
|
|
|
.member(Member.NORMAL)
|
|
.member(Member.NORMAL)
|
|
|
-// .promote(BigDecimal.ZERO)
|
|
|
|
|
-// .maker(BigDecimal.ZERO)
|
|
|
|
|
.withdraw(BigDecimal.ZERO)
|
|
.withdraw(BigDecimal.ZERO)
|
|
|
.cacheAmount(BigDecimal.ZERO)
|
|
.cacheAmount(BigDecimal.ZERO)
|
|
|
.build();
|
|
.build();
|
|
@@ -265,7 +260,9 @@ public class UserService {
|
|
|
User user = userRepo.findById(SecurityUtils.getAuthenticatedUser().getId())
|
|
User user = userRepo.findById(SecurityUtils.getAuthenticatedUser().getId())
|
|
|
.orElseThrow(new BusinessException("用户不存在"));
|
|
.orElseThrow(new BusinessException("用户不存在"));
|
|
|
user.setPhone(phoneNoInfo.getPhoneNumber());
|
|
user.setPhone(phoneNoInfo.getPhoneNumber());
|
|
|
- user.setUsername(phoneNoInfo.getPhoneNumber());
|
|
|
|
|
|
|
+ if (StrUtil.isNotBlank(phoneNoInfo.getPhoneNumber())){
|
|
|
|
|
+ user.setUsername(phoneNoInfo.getPhoneNumber());
|
|
|
|
|
+ }
|
|
|
user = userRepo.save(user);
|
|
user = userRepo.save(user);
|
|
|
String token = jwtTokenUtil.generateToken(JwtUserFactory.create(user));
|
|
String token = jwtTokenUtil.generateToken(JwtUserFactory.create(user));
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
@@ -320,19 +317,6 @@ public class UserService {
|
|
|
移除员工:推广列表下员工的推广就会没有
|
|
移除员工:推广列表下员工的推广就会没有
|
|
|
*/
|
|
*/
|
|
|
public Page<PromotionDTO> myPromotion(PageQuery pageQuery, Long userId) {
|
|
public Page<PromotionDTO> myPromotion(PageQuery pageQuery, Long userId) {
|
|
|
-// User parent = userRepo.findById(userId).orElseThrow(new BusinessException("无用户"));
|
|
|
|
|
-// return userRepo.findAll(((root, criteriaQuery, criteriaBuilder) -> {
|
|
|
|
|
-// List<Predicate> and = JpaUtils.toPredicates(pageQuery, User.class, root, criteriaQuery, criteriaBuilder);
|
|
|
|
|
-// if (parent.getTeamFounder()) {
|
|
|
|
|
-// List<User> employees = userRepo.findAllByCompanyIdAndDelFalse(parent.getCompanyId());
|
|
|
|
|
-// List<Long> collect = employees.stream().map(User::getId).collect(Collectors.toList());
|
|
|
|
|
-// and.add(root.get("parent").in(collect));
|
|
|
|
|
-// } else {
|
|
|
|
|
-// and.add(criteriaBuilder.equal(root.get("parent"), userId));
|
|
|
|
|
-// }
|
|
|
|
|
-// return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
|
|
|
-// }), JpaUtils.toPageRequest(pageQuery));
|
|
|
|
|
-
|
|
|
|
|
User parent = userRepo.findById(userId).orElseThrow(new BusinessException("无用户"));
|
|
User parent = userRepo.findById(userId).orElseThrow(new BusinessException("无用户"));
|
|
|
if (parent.getTeamFounder()) {
|
|
if (parent.getTeamFounder()) {
|
|
|
List<User> employees = userRepo.findAllByCompanyIdAndDelFalse(parent.getCompanyId());
|
|
List<User> employees = userRepo.findAllByCompanyIdAndDelFalse(parent.getCompanyId());
|