|
@@ -7,8 +7,6 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.fjhx.account.entity.account.enums.PaymentStatusEnum;
|
|
|
-import com.fjhx.account.entity.account.po.AccountPayment;
|
|
|
import com.fjhx.account.entity.account.po.AccountRunningWater;
|
|
|
import com.fjhx.account.service.account.AccountPaymentService;
|
|
|
import com.fjhx.account.service.account.AccountRunningWaterService;
|
|
@@ -60,35 +58,45 @@ public class RefundServiceImpl extends ServiceImpl<RefundMapper, Refund> impleme
|
|
|
IWrapper<Refund> wrapper = getWrapper();
|
|
|
wrapper.orderByDesc("r", Refund::getCreateTime);
|
|
|
if(StringUtils.isNotEmpty(dto.getStatus())){
|
|
|
- wrapper.eq("p",Refund::getStatus,dto.getStatus());
|
|
|
+ wrapper.eq("r", Refund::getStatus, dto.getStatus());
|
|
|
}
|
|
|
if(StringUtils.isNotEmpty(dto.getRefundStatus())){
|
|
|
- wrapper.eq("p",Refund::getRefundStatus,dto.getRefundStatus());
|
|
|
+ wrapper.eq("r", Refund::getRefundStatus, dto.getRefundStatus());
|
|
|
}
|
|
|
if(StringUtils.isNotEmpty(dto.getKeyword())){
|
|
|
wrapper.keyword(dto.getKeyword(),new SqlField(Refund::getRefundName));
|
|
|
}
|
|
|
Page<RefundVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
List<RefundVo> list = page.getRecords();
|
|
|
- if(CollectionUtils.isNotEmpty(list)){
|
|
|
+ if(CollectionUtils.isNotEmpty(list)) {
|
|
|
//查询供应商
|
|
|
List<Long> supplyIds = list.stream().map(RefundVo::getSupplyId).collect(Collectors.toList());
|
|
|
- List<SupplierInfo> supplierInfoList = supplierInfoService.list(Wrappers.<SupplierInfo>query().lambda().in(SupplierInfo::getId,supplyIds));
|
|
|
- Map<Long,List<SupplierInfo>> supplyMap = supplierInfoList.stream().distinct().collect(Collectors.groupingBy(SupplierInfo::getId));
|
|
|
+ List<SupplierInfo> supplierInfoList = supplierInfoService.list(Wrappers.<SupplierInfo>query().lambda().in(SupplierInfo::getId, supplyIds));
|
|
|
+ Map<Long, List<SupplierInfo>> supplyMap = supplierInfoList.stream().distinct().collect(Collectors.groupingBy(SupplierInfo::getId));
|
|
|
//查询应退款金额
|
|
|
List<Long> ids = list.stream().map(RefundVo::getId).collect(Collectors.toList());
|
|
|
- List<AccountPayment> accountPaymentList = accountPaymentService.list(Wrappers.<AccountPayment>query().lambda().in(AccountPayment::getBusinessId,ids)
|
|
|
- .eq(AccountPayment::getStatus, PaymentStatusEnum.REJECT.getKey()));
|
|
|
- Map<Long,List<AccountPayment>> accMap = accountPaymentList.stream().collect(Collectors.groupingBy(AccountPayment::getBusinessId));
|
|
|
- for(RefundVo p:list){
|
|
|
- if(MapUtils.isNotEmpty(supplyMap)){//赋值供应商
|
|
|
- List<SupplierInfo> supplys = supplyMap.getOrDefault(p.getSupplyId(),null);
|
|
|
- p.setSupplyName(supplys==null?null:supplys.get(0).getName());
|
|
|
+// List<AccountPayment> accountPaymentList = accountPaymentService.list(Wrappers.<AccountPayment>query().lambda().in(AccountPayment::getBusinessId,ids)
|
|
|
+// .eq(AccountPayment::getStatus, PaymentStatusEnum.REJECT.getKey()));
|
|
|
+// Map<Long,List<AccountPayment>> accMap = accountPaymentList.stream().collect(Collectors.groupingBy(AccountPayment::getBusinessId));
|
|
|
+ List<AccountRunningWater> accountRunningWaters = accountRunningWaterService.list(Wrappers.<AccountRunningWater>query().lambda().in(AccountRunningWater::getBusinessId, ids));
|
|
|
+ Map<Long, List<AccountRunningWater>> arwMap = accountRunningWaters.stream().collect(Collectors.groupingBy(AccountRunningWater::getBusinessId));
|
|
|
+ for (RefundVo p : list) {
|
|
|
+ if (MapUtils.isNotEmpty(supplyMap)) {//赋值供应商
|
|
|
+ List<SupplierInfo> supplys = supplyMap.getOrDefault(p.getSupplyId(), null);
|
|
|
+ p.setSupplyName(supplys == null ? null : supplys.get(0).getName());
|
|
|
}
|
|
|
- if(MapUtils.isNotEmpty(accMap)){//赋值已退款总金额
|
|
|
- List<AccountPayment> sumList = accMap.getOrDefault(p.getId(),null);
|
|
|
- BigDecimal sum = sumList.stream().map(AccountPayment::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
|
|
|
- p.setSumRefundMoney(sum==null?BigDecimal.ZERO:sum);
|
|
|
+// if(MapUtils.isNotEmpty(accMap)){//赋值已退款总金额
|
|
|
+// List<AccountPayment> sumList = accMap.getOrDefault(p.getId(),null);
|
|
|
+// BigDecimal sum = sumList.stream().map(AccountPayment::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
|
|
|
+// p.setSumRefundMoney(sum==null?BigDecimal.ZERO:sum);
|
|
|
+// }
|
|
|
+ if (MapUtils.isNotEmpty(arwMap)) {//赋值已退款总金额
|
|
|
+ p.setSumRefundMoney(BigDecimal.ZERO);
|
|
|
+ List<AccountRunningWater> sumList = arwMap.getOrDefault(p.getId(), null);
|
|
|
+ if (ObjectUtils.isNotEmpty(sumList)) {
|
|
|
+ BigDecimal sum = sumList.stream().map(AccountRunningWater::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ p.setSumRefundMoney(sum);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|