lyhzzz vor 2 Jahren
Ursprung
Commit
a38a47d296

+ 6 - 0
src/main/java/com/fdkankan/sale/entity/Repair.java

@@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
 import java.io.Serializable;
+import java.math.BigDecimal;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fdkankan.sale.typehandle.JsonArrayTypeHandler;
 import lombok.Getter;
 import lombok.Setter;
@@ -118,4 +120,8 @@ public class Repair implements Serializable {
 
     @TableField("cancel_remark")
     private String cancelRemark;
+
+    @TableField(exist = false)
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
+    private BigDecimal payAmount;
 }

+ 3 - 0
src/main/java/com/fdkankan/sale/service/IPriceListService.java

@@ -4,6 +4,7 @@ import com.fdkankan.sale.entity.PriceList;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.math.BigDecimal;
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -30,4 +31,6 @@ public interface IPriceListService extends IService<PriceList> {
     List<PriceList> getCheckAmountByRepairId(String repairId);
 
     void delNoCm(String repairId);
+
+    HashMap<String, BigDecimal> getAmountByRepairIds(List<String> repairIds);
 }

+ 29 - 0
src/main/java/com/fdkankan/sale/service/impl/PriceListServiceImpl.java

@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -45,6 +47,24 @@ public class PriceListServiceImpl extends ServiceImpl<IPriceListMapper, PriceLis
     }
 
     @Override
+    public HashMap<String, BigDecimal> getAmountByRepairIds(List<String> repairIds) {
+        HashMap<String, BigDecimal> map = new HashMap<>();
+        List<PriceList> byRepairId = this.getByRepairIdsAndStatus(repairIds,1);
+        for (PriceList priceList : byRepairId) {
+            map.putIfAbsent(priceList.getRepairId(), BigDecimal.ZERO);
+            BigDecimal amount = map.get(priceList.getRepairId());
+            if(priceList.getDiscount() == 0){
+                amount = amount.add(priceList.getPrice().multiply(new BigDecimal(priceList.getCount())));
+            }
+            if(priceList.getDiscount() == 1){
+                amount = amount.add(priceList.getPriceDiscount().multiply(new BigDecimal(priceList.getCount())));
+            }
+            map.put(priceList.getRepairId(),amount);
+        }
+        return map;
+    }
+
+    @Override
     public BigDecimal getRobAmountByRepairId(String repairId) {
         BigDecimal amount = BigDecimal.ZERO;
         List<PriceList> byRepairId = this.getCheckAmountByRepairId(repairId);
@@ -69,6 +89,15 @@ public class PriceListServiceImpl extends ServiceImpl<IPriceListMapper, PriceLis
         wrapper.eq(PriceList::getStatus,1);
         return list(wrapper);
     }
+    public List<PriceList> getByRepairIdsAndStatus(List<String> repairIds, Integer status) {
+        if(repairIds.size() >0){
+            LambdaQueryWrapper<PriceList> wrapper = new LambdaQueryWrapper<>();
+            wrapper.in(PriceList::getRepairId,repairIds);
+            wrapper.eq(PriceList::getStatus,1);
+            return list(wrapper);
+        }
+        return new ArrayList<>();
+    }
 
     @Override
     public List<PriceList> getCheckAmountByRepairId(String repairId) {

+ 7 - 1
src/main/java/com/fdkankan/sale/service/impl/RepairCustomerService.java

@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.util.HashMap;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -48,7 +49,12 @@ public class RepairCustomerService {
                 LambdaQueryWrapper<Repair> wrapper = new LambdaQueryWrapper<>();
                 wrapper.in(Repair::getRepairId,repairIds);
                 wrapper.orderByDesc(Repair::getCreateTime);
-                return repairService.list(wrapper);
+                List<Repair> repairList = repairService.list(wrapper);
+                HashMap<String,BigDecimal> amountMap = priceListService.getAmountByRepairIds(repairIds);
+                for (Repair repair : repairList) {
+                    repair.setPayAmount(amountMap.get(repair.getRepairId()));
+                }
+                return repairList;
             }
         }
         return null;