|
@@ -6,7 +6,6 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.izouma.jiashanxia.domain.*;
|
|
import com.izouma.jiashanxia.domain.*;
|
|
|
import com.izouma.jiashanxia.domain.Package;
|
|
import com.izouma.jiashanxia.domain.Package;
|
|
|
-import com.izouma.jiashanxia.dto.GoodsVO;
|
|
|
|
|
import com.izouma.jiashanxia.dto.OrderInfoVO;
|
|
import com.izouma.jiashanxia.dto.OrderInfoVO;
|
|
|
import com.izouma.jiashanxia.dto.PageQuery;
|
|
import com.izouma.jiashanxia.dto.PageQuery;
|
|
|
import com.izouma.jiashanxia.enums.OrderInfoStatus;
|
|
import com.izouma.jiashanxia.enums.OrderInfoStatus;
|
|
@@ -17,7 +16,6 @@ import com.izouma.jiashanxia.repo.*;
|
|
|
import com.izouma.jiashanxia.utils.JpaUtils;
|
|
import com.izouma.jiashanxia.utils.JpaUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.data.domain.PageImpl;
|
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -45,7 +43,6 @@ public class OrderInfoService {
|
|
|
private UserPackageService userPackageService;
|
|
private UserPackageService userPackageService;
|
|
|
private CompanyRepo companyRepo;
|
|
private CompanyRepo companyRepo;
|
|
|
private WithdrawService withdrawService;
|
|
private WithdrawService withdrawService;
|
|
|
- private GoodsInfoRepo goodsInfoRepo;
|
|
|
|
|
|
|
|
|
|
public Page<OrderInfo> all(PageQuery pageQuery) {
|
|
public Page<OrderInfo> all(PageQuery pageQuery) {
|
|
|
return orderInfoRepo.findAll(JpaUtils.toSpecification(pageQuery, OrderInfo.class), JpaUtils.toPageRequest(pageQuery));
|
|
return orderInfoRepo.findAll(JpaUtils.toSpecification(pageQuery, OrderInfo.class), JpaUtils.toPageRequest(pageQuery));
|
|
@@ -58,11 +55,6 @@ public class OrderInfoService {
|
|
|
return orderInfoRepo.findAll(((root, criteriaQuery, criteriaBuilder) -> {
|
|
return orderInfoRepo.findAll(((root, criteriaQuery, criteriaBuilder) -> {
|
|
|
List<Predicate> and = JpaUtils.toPredicates(pageQuery, OrderInfo.class, root, criteriaQuery, criteriaBuilder);
|
|
List<Predicate> and = JpaUtils.toPredicates(pageQuery, OrderInfo.class, root, criteriaQuery, criteriaBuilder);
|
|
|
if (StrUtil.isNotEmpty(pageQuery.getSearch())) {
|
|
if (StrUtil.isNotEmpty(pageQuery.getSearch())) {
|
|
|
- /* List<Predicate> or = new ArrayList<>();
|
|
|
|
|
- or.add(and.get(and.size() - 1));
|
|
|
|
|
- and.remove(and.get(and.size() - 1));
|
|
|
|
|
- or.add(criteriaBuilder.like(root.join("user").get("nickname"), "%" + pageQuery.getSearch() + "%"));
|
|
|
|
|
- and.add(criteriaBuilder.or(or.toArray(new Predicate[0])));*/
|
|
|
|
|
withdrawService.getNickname(pageQuery.getSearch(), and, root, criteriaBuilder);
|
|
withdrawService.getNickname(pageQuery.getSearch(), and, root, criteriaBuilder);
|
|
|
}
|
|
}
|
|
|
return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
@@ -103,12 +95,19 @@ public class OrderInfoService {
|
|
|
|
|
|
|
|
// 套餐内商品
|
|
// 套餐内商品
|
|
|
List<PackageGoods> setGoodsList = packageGoodsRepo.findAllByPackageId(order.getPackageId());
|
|
List<PackageGoods> setGoodsList = packageGoodsRepo.findAllByPackageId(order.getPackageId());
|
|
|
- // 加入套餐商品
|
|
|
|
|
|
|
+ // 用户
|
|
|
Long userId = order.getUserId();
|
|
Long userId = order.getUserId();
|
|
|
|
|
+ User user = userRepo.findById(userId).orElseThrow(new BusinessException("无用户"));
|
|
|
|
|
+ // 设置用户为vip
|
|
|
|
|
+ if (!user.getIsVip()) {
|
|
|
|
|
+ user.setIsVip(true);
|
|
|
|
|
+ userRepo.save(user);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 加入套餐商品
|
|
|
userPackageService.joinUserPackage(userId, setGoodsList);
|
|
userPackageService.joinUserPackage(userId, setGoodsList);
|
|
|
|
|
|
|
|
- User user = userRepo.findById(userId).orElseThrow(new BusinessException("无用户"));
|
|
|
|
|
- if (user.getParent() != null) {
|
|
|
|
|
|
|
+ // 用户id和上级id相同
|
|
|
|
|
+ if (user.getParent() != null && !userId.equals(user.getParent())) {
|
|
|
// 上级分销
|
|
// 上级分销
|
|
|
this.distribution(userId, user.getParent(), transactionId);
|
|
this.distribution(userId, user.getParent(), transactionId);
|
|
|
}
|
|
}
|
|
@@ -214,7 +213,6 @@ public class OrderInfoService {
|
|
|
}
|
|
}
|
|
|
return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
|
}), pageable).map(this::toVo);
|
|
}), pageable).map(this::toVo);
|
|
|
-// return new PageImpl<>(this.toVO(all), pageable, all.size());
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public OrderInfoVO toVo(OrderInfo orderInfo) {
|
|
public OrderInfoVO toVo(OrderInfo orderInfo) {
|
|
@@ -249,7 +247,6 @@ public class OrderInfoService {
|
|
|
// .build());
|
|
// .build());
|
|
|
// });
|
|
// });
|
|
|
vo.setGoods(packageGoods);
|
|
vo.setGoods(packageGoods);
|
|
|
-
|
|
|
|
|
orderInfoVOS.add(vo);
|
|
orderInfoVOS.add(vo);
|
|
|
});
|
|
});
|
|
|
return orderInfoVOS;
|
|
return orderInfoVOS;
|