|
@@ -1,6 +1,7 @@
|
|
|
package com.izouma.jiashanxia.service;
|
|
package com.izouma.jiashanxia.service;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.izouma.jiashanxia.domain.*;
|
|
import com.izouma.jiashanxia.domain.*;
|
|
|
import com.izouma.jiashanxia.dto.PageQuery;
|
|
import com.izouma.jiashanxia.dto.PageQuery;
|
|
|
import com.izouma.jiashanxia.enums.OrderInfoStatus;
|
|
import com.izouma.jiashanxia.enums.OrderInfoStatus;
|
|
@@ -23,14 +24,14 @@ import java.util.List;
|
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
|
public class OrderInfoService {
|
|
public class OrderInfoService {
|
|
|
|
|
|
|
|
- private OrderInfoRepo orderInfoRepo;
|
|
|
|
|
- private SetMealRepo setMealRepo;
|
|
|
|
|
- private SetGoodsRepo setGoodsRepo;
|
|
|
|
|
- private UserSetRepo userSetRepo;
|
|
|
|
|
- private UserRepo userRepo;
|
|
|
|
|
- private SysConfigService sysConfigService;
|
|
|
|
|
|
|
+ private OrderInfoRepo orderInfoRepo;
|
|
|
|
|
+ private SetMealRepo setMealRepo;
|
|
|
|
|
+ private SetGoodsRepo setGoodsRepo;
|
|
|
|
|
+ private UserSetRepo userSetRepo;
|
|
|
|
|
+ private UserRepo userRepo;
|
|
|
|
|
+ private SysConfigService sysConfigService;
|
|
|
private CommissionRecordRepo commissionRecordRepo;
|
|
private CommissionRecordRepo commissionRecordRepo;
|
|
|
- private UserSetService userSetService;
|
|
|
|
|
|
|
+ private UserSetService userSetService;
|
|
|
|
|
|
|
|
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));
|
|
@@ -80,12 +81,24 @@ public class OrderInfoService {
|
|
|
分销
|
|
分销
|
|
|
*/
|
|
*/
|
|
|
public void distribution(Long userId, Long parent, String transactionId) {
|
|
public void distribution(Long userId, Long parent, String transactionId) {
|
|
|
- List<UserSet> parentSets = userSetRepo.findAllByUserId(parent);
|
|
|
|
|
- if (CollUtil.isEmpty(parentSets)) {
|
|
|
|
|
|
|
+ User user = userRepo.findById(parent).orElseThrow(new BusinessException("无用户"));
|
|
|
|
|
+ // 判断是否可分享
|
|
|
|
|
+ boolean flag = true;
|
|
|
|
|
+ // 是否公司员工
|
|
|
|
|
+ if (ObjectUtil.isEmpty(user.getCompanyId())) {
|
|
|
|
|
+ flag = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (flag) {
|
|
|
|
|
+ // 是否购买了套餐
|
|
|
|
|
+ List<UserSet> parentSets = userSetRepo.findAllByUserId(parent);
|
|
|
|
|
+ if (CollUtil.isEmpty(parentSets)) {
|
|
|
|
|
+ flag = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!flag) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- User user = userRepo.findById(parent).orElseThrow(new BusinessException("无用户"));
|
|
|
|
|
BigDecimal personalAmount = sysConfigService.getBigDecimal("PERSONAL_AMOUNT");
|
|
BigDecimal personalAmount = sysConfigService.getBigDecimal("PERSONAL_AMOUNT");
|
|
|
user.setAmount(user.getAmount().add(personalAmount));
|
|
user.setAmount(user.getAmount().add(personalAmount));
|
|
|
|
|
|
|
@@ -99,6 +112,5 @@ public class OrderInfoService {
|
|
|
.transactionId(transactionId)
|
|
.transactionId(transactionId)
|
|
|
.build());
|
|
.build());
|
|
|
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|