Просмотр исходного кода

新增供应商付款类型字段,sku库存数量查询接口

fgd 1 год назад
Родитель
Сommit
556e16ddbd

+ 11 - 0
sd-business/src/main/java/com/sd/business/controller/sku/SkuSpecController.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
 
 /**
  * <p>
@@ -68,4 +69,14 @@ public class SkuSpecController {
         skuSpecService.delete(dto.getId());
     }
 
+    /**
+     * 获取sku的库存数
+     * @param dto
+     * @return
+     */
+    @PostMapping("/getSkuInventoryQuantity")
+    public BigDecimal getSkuInventoryQuantity(@RequestBody BaseSelectDto dto) {
+        return skuSpecService.getSkuInventoryQuantity(dto.getId());
+    }
+
 }

+ 5 - 0
sd-business/src/main/java/com/sd/business/entity/purchase/po/Purchase.java

@@ -122,6 +122,11 @@ public class Purchase extends BasePo {
     private BigDecimal advancePayment;
 
     /**
+     * 付款日期
+     */
+    private String paymentDate;
+
+    /**
      * 合同模板id
      */
     private Long contractTemplateId;

+ 11 - 0
sd-business/src/main/java/com/sd/business/entity/supplier/po/Supplier.java

@@ -54,6 +54,17 @@ public class Supplier extends BasePo {
     private String dutyNumber;
 
     /**
+     * 付款类型 0-现结,1-月结
+     */
+    private Integer paymentType;
+
+    /**
+     * 次月多少天内,结算费用
+     */
+    private Integer nextMonthDays;
+
+
+    /**
      * 联系人1
      */
     private String contactPerson1;

+ 0 - 14
sd-business/src/main/java/com/sd/business/service/order/impl/OrderServiceImpl.java

@@ -750,20 +750,6 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
                 throw new ServiceException("操作失败,品名为:" + bomSpecBo.getBomSpecName() + " 的bom库存不足,库存为:" +
                         (inventory == null ? BigDecimal.ZERO : inventory.getQuantity()));
             }
-
-            // 判断包材库存
-            for (OrderSkuBom orderSkuBom : orderSkuDto.getOrderSkuBomList()) {
-                BomSpec bomSpec = bomSpecService.getById(orderSkuBom.getBomSpecId());
-                if (bomSpec == null) {
-                    throw new ServiceException("未知bom规格id:" + orderSkuBom.getBomSpecId());
-                }
-                Inventory bomInventory = inventoryService.getOne(q -> q.eq(Inventory::getWarehouseId, WarehouseConstant.PACKAGING_MATERIAL)
-                        .eq(Inventory::getBomSpecId, orderSkuBom.getBomSpecId()));
-                if (bomInventory == null || bomInventory.getQuantity().compareTo(orderSkuBom.getQuantity()) < 0) {
-                    throw new ServiceException("操作失败,品名为:" + bomSpec.getName() + " 的bom库存不足,库存为:" +
-                            (bomInventory == null ? BigDecimal.ZERO : bomInventory.getQuantity()));
-                }
-            }
         }
     }
 

+ 7 - 0
sd-business/src/main/java/com/sd/business/service/sku/SkuSpecService.java

@@ -8,6 +8,7 @@ import com.sd.business.entity.sku.dto.SkuSpecSelectDto;
 import com.sd.business.entity.sku.po.SkuSpec;
 import com.sd.business.entity.sku.vo.SkuSpecVo;
 
+import java.math.BigDecimal;
 import java.util.Collection;
 import java.util.Map;
 
@@ -52,4 +53,10 @@ public interface SkuSpecService extends BaseService<SkuSpec> {
      */
     Map<Long, BomSpecBo> getBomSpecBoByIdList(Collection<Long> bomSpecIdList);
 
+    /**
+     * 获取sku的库存数量
+     * @param id
+     * @return
+     */
+    BigDecimal getSkuInventoryQuantity(Long id);
 }

+ 40 - 0
sd-business/src/main/java/com/sd/business/service/sku/impl/SkuSpecServiceImpl.java

@@ -5,16 +5,23 @@ import cn.hutool.core.util.ObjectUtil;
 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.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.sd.business.entity.bom.bo.BomSpecBo;
+import com.sd.business.entity.inventory.po.Inventory;
 import com.sd.business.entity.sku.dto.SkuSpecDto;
 import com.sd.business.entity.sku.dto.SkuSpecSelectDto;
 import com.sd.business.entity.sku.po.SkuSpec;
 import com.sd.business.entity.sku.vo.SkuSpecVo;
+import com.sd.business.entity.warehouse.constant.WarehouseConstant;
 import com.sd.business.mapper.sku.SkuSpecMapper;
+import com.sd.business.service.bom.BomSpecService;
+import com.sd.business.service.inventory.InventoryService;
 import com.sd.business.service.sku.SkuSpecService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -33,6 +40,11 @@ import java.util.stream.Collectors;
  */
 @Service
 public class SkuSpecServiceImpl extends ServiceImpl<SkuSpecMapper, SkuSpec> implements SkuSpecService {
+    @Autowired
+    private BomSpecService bomSpecService;
+
+    @Autowired
+    private InventoryService inventoryService;
 
     @Override
     public Page<SkuSpecVo> getPage(SkuSpecSelectDto dto) {
@@ -82,4 +94,32 @@ public class SkuSpecServiceImpl extends ServiceImpl<SkuSpecMapper, SkuSpec> impl
         return list.stream().collect(Collectors.toMap(BomSpecBo::getBomSpecId, Function.identity()));
     }
 
+    @Override
+    public BigDecimal getSkuInventoryQuantity(Long id) {
+        SkuSpec skuSpec = this.getById(id);
+        if (skuSpec == null) {
+            throw new ServiceException("没有找到sku信息");
+        }
+        Long bomSpecId = skuSpec.getBomSpecId();
+        if (ObjectUtil.isEmpty(bomSpecId)) {
+            return BigDecimal.ZERO;
+        }
+        Map<Long, BomSpecBo> bomSpecBoMap = this.getBomSpecBoByIdList(Collections.singleton(bomSpecId));
+        BomSpecBo bomSpecBo = bomSpecBoMap.get(bomSpecId);
+        if (bomSpecBo == null) {
+            throw new ServiceException("未知bom规格id:" + bomSpecId);
+        }
+        Long warehouseId;
+        // 主材
+        if (ObjectUtil.equals(bomSpecBo.getClassifyParentId(), 1L)) {
+            warehouseId = WarehouseConstant.SEMI_FINISHED_PRODUCT;
+        } else {
+            warehouseId = WarehouseConstant.PACKAGING_MATERIAL;
+        }
+        Inventory inventory = inventoryService.getOne(q -> q
+                .eq(Inventory::getWarehouseId, warehouseId)
+                .eq(Inventory::getBomSpecId, bomSpecId));
+        return inventory == null ? BigDecimal.ZERO : inventory.getQuantity();
+    }
+
 }

+ 2 - 0
sd-business/src/main/resources/mapper/supplier/SupplierMapper.xml

@@ -10,6 +10,8 @@
                s.city,
                s.detailed_address,
                s.duty_number,
+               s.payment_type,
+               s.next_month_days,
                s.contact_person1,
                s.contact_number1,
                s.contact_mailbox1,