|
@@ -6,12 +6,15 @@ import com.fdkankan.sale.entity.PriceList;
|
|
|
import com.fdkankan.sale.mapper.IPriceListMapper;
|
|
|
import com.fdkankan.sale.service.IPriceListService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.sale.vo.response.RepairInfoExportVo;
|
|
|
+import com.fdkankan.sale.vo.response.RepairerVo;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -32,6 +35,16 @@ public class PriceListServiceImpl extends ServiceImpl<IPriceListMapper, PriceLis
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public List<PriceList> getByRepairIds(List<String> repairIds) {
|
|
|
+ if(repairIds == null || repairIds.size() <=0){
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<PriceList> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(PriceList::getRepairId,repairIds);
|
|
|
+ return list(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public BigDecimal getAmountByRepairId(String repairId) {
|
|
|
BigDecimal amount = BigDecimal.ZERO;
|
|
|
List<PriceList> byRepairId = this.getByRepairIdAndStatus(repairId,1);
|
|
@@ -91,10 +104,44 @@ public class PriceListServiceImpl extends ServiceImpl<IPriceListMapper, PriceLis
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public List<PriceList> getCheckAmountByRepairIds(List<String> cancelIds) {
|
|
|
+ if(cancelIds != null && cancelIds.size() >0){
|
|
|
+ LambdaQueryWrapper<PriceList> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(PriceList::getRepairId,cancelIds);
|
|
|
+ wrapper.eq(PriceList::getLaborId,1);
|
|
|
+ return list(wrapper);
|
|
|
+ }
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public void delNoCm(String repairId) {
|
|
|
LambdaQueryWrapper<PriceList> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(PriceList::getRepairId,repairId);
|
|
|
this.remove(wrapper);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HashMap<String, BigDecimal> getAmountByRepairIds(List<RepairerVo> list) {
|
|
|
+ HashMap<String,BigDecimal> map = new HashMap<>();
|
|
|
+ List<String> cancelIds = list.stream().filter(e ->e.getCancelStatus() == 1).map(RepairerVo::getRepairId).collect(Collectors.toList());
|
|
|
+ List<String> repairIds = list.stream().filter(e ->e.getCancelStatus() == 0).map(RepairerVo::getRepairId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<PriceList> cancelPriceList = this.getCheckAmountByRepairIds(cancelIds);
|
|
|
+ List<PriceList> priceLists = this.getByRepairIds(repairIds);
|
|
|
+
|
|
|
+ setMapAmount(map,cancelPriceList);
|
|
|
+ setMapAmount(map,priceLists);
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ private void setMapAmount( HashMap<String,BigDecimal> map,List<PriceList> priceLists){
|
|
|
+ for (PriceList priceList : priceLists) {
|
|
|
+ map.putIfAbsent(priceList.getRepairId(), BigDecimal.ZERO);
|
|
|
+ BigDecimal payAmount = map.get(priceList.getRepairId());
|
|
|
+ BigDecimal price = priceList.getDiscount() == 1 ? priceList.getPriceDiscount() : priceList.getPrice();
|
|
|
+ payAmount = payAmount.add(price.multiply(new BigDecimal(priceList.getCount())));
|
|
|
+ map.put(priceList.getRepairId(),payAmount);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|