Explorar o código

报价单修改

lyhzzz %!s(int64=2) %!d(string=hai) anos
pai
achega
985d7ad819

+ 2 - 0
src/main/java/com/fdkankan/sale/common/ResultCode.java

@@ -35,6 +35,8 @@ public enum ResultCode  {
     ORDER_NOt_PAY(60013, "该订单未支付"),
     ORDER_INVOICE_OPEN(60014, "该订单已开票"),
     PRICE_TYPE_NOT(60015, "报价类型为空"),
+    PART_ID_EMPTY(60016, "备件id为空"),
+    LABOR_ID_EMPTY(60017, "人工id为空"),
 
 
 

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

@@ -74,6 +74,12 @@ public class PriceList implements Serializable {
     @TableField("type")
     private Integer type;
 
+    @TableField("labor_id")
+    private Integer laborId;
+
+    @TableField("part_id")
+    private Integer partId;
+
 
 
 }

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

@@ -3,6 +3,8 @@ package com.fdkankan.sale.service;
 import com.fdkankan.sale.entity.LaborCost;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.HashMap;
+
 /**
  * <p>
  *  服务类
@@ -13,4 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface ILaborCostService extends IService<LaborCost> {
 
+    HashMap<Integer, LaborCost> getHashMap();
 }

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

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.sale.vo.request.PartParam;
 import com.fdkankan.sale.vo.response.RepairRegisterPartVo;
 
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -26,4 +27,6 @@ public interface IPartService extends IService<Part> {
     void outStock(Integer partId,Integer count,Long userId,String repairId);
 
     void recovery(Integer partId, Integer partCount, Long userId, String repairId);
+
+    HashMap<Integer, Part> getHashMap();
 }

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

@@ -27,4 +27,6 @@ public interface IPriceListService extends IService<PriceList> {
     BigDecimal getRobAmountByRepairId(String repairId);
 
     List<PriceList> getByRepairIdAndStatusAndType(String repairId, Integer type);
+
+    void delNoCm(String repairId);
 }

+ 10 - 0
src/main/java/com/fdkankan/sale/service/impl/LaborCostServiceImpl.java

@@ -6,6 +6,9 @@ import com.fdkankan.sale.service.ILaborCostService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
+import java.util.List;
+
 /**
  * <p>
  *  服务实现类
@@ -17,4 +20,11 @@ import org.springframework.stereotype.Service;
 @Service
 public class LaborCostServiceImpl extends ServiceImpl<ILaborCostMapper, LaborCost> implements ILaborCostService {
 
+    @Override
+    public HashMap<Integer, LaborCost> getHashMap() {
+        HashMap<Integer, LaborCost> map = new HashMap<>();
+        List<LaborCost> list = this.list();
+        list.forEach(entity -> map.put(entity.getLaborCostId(),entity));
+        return map;
+    }
 }

+ 9 - 0
src/main/java/com/fdkankan/sale/service/impl/PartServiceImpl.java

@@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -94,4 +95,12 @@ public class PartServiceImpl extends ServiceImpl<IPartMapper, Part> implements I
         partLogService.saveLog(partId,partCount,userId,2,repairId);
 
     }
+
+    @Override
+    public HashMap<Integer, Part> getHashMap() {
+        HashMap<Integer, Part> map = new HashMap<>();
+        List<Part> list = this.list();
+        list.forEach(entity -> map.put(entity.getPartId(),entity));
+        return map;
+    }
 }

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

@@ -72,4 +72,12 @@ public class PriceListServiceImpl extends ServiceImpl<IPriceListMapper, PriceLis
         wrapper.eq(PriceList::getType,1);
         return list(wrapper);
     }
+
+    @Override
+    public void delNoCm(String repairId) {
+        LambdaQueryWrapper<PriceList> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(PriceList::getRepairId,repairId);
+        wrapper.eq(PriceList::getStatus,0);
+        this.remove(wrapper);
+    }
 }

+ 30 - 3
src/main/java/com/fdkankan/sale/service/impl/RepairSaleService.java

@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -50,6 +51,10 @@ public class RepairSaleService {
     IPriceListService priceListService;
     @Autowired
     IRepairPayService repairPayService;
+    @Autowired
+    IPartService partService;
+    @Autowired
+    ILaborCostService laborCostService;
 
     /**
      * 售后工程师
@@ -136,14 +141,36 @@ public class RepairSaleService {
             throw new BusinessException(ResultCode.REPAIR_NOT_EXITS);
         }
 
-        List<PriceList> priceLists = param.getPriceLists();
-        for (PriceList priceList : priceLists) {
+
+        HashMap<Integer,Part> partMap = partService.getHashMap();
+        HashMap<Integer,LaborCost> laborMap = laborCostService.getHashMap();
+        priceListService.delNoCm(param.getRepairId());
+
+        for (PriceList priceList : param.getPriceLists()) {
             if(priceList.getType() == null){
                 throw new BusinessException(ResultCode.PRICE_TYPE_NOT);
             }
+            if(priceList.getType() == 0){
+                if(priceList.getPartId() == null ||  partMap.get(priceList.getPartId()) == null){
+                    throw new BusinessException(ResultCode.PART_ID_EMPTY);
+                }
+                Part part = partMap.get(priceList.getPartId());
+                priceList.setPrice(part.getPartPrice());
+                priceList.setName(part.getPartName());
+
+            }
+            if(priceList.getType() == 1){
+                if(priceList.getLaborId() == null || laborMap.get(priceList.getLaborId()) == null){
+                    throw new BusinessException(ResultCode.LABOR_ID_EMPTY);
+                }
+                LaborCost laborCost = laborMap.get(priceList.getLaborId());
+                priceList.setPrice(laborCost.getPrice());
+                priceList.setName(laborCost.getName());
+            }
+
             priceList.setRepairId(param.getRepairId());
         }
-        priceListService.saveOrUpdateBatch(priceLists);
+        priceListService.saveOrUpdateBatch(param.getPriceLists());
         repairLogService.saveBySysUser(userId,param.getRepairId(),3,"维修报价");
     }