فهرست منبع

检查产品库存

xdd 2 هفته پیش
والد
کامیت
ea9025efae

+ 7 - 2
fs-service-system/src/main/java/com/fs/erp/service/impl/WdtErpGoodsServiceImpl.java

@@ -12,6 +12,7 @@ import com.fs.erp.service.IErpGoodsService;
 import com.hc.openapi.tool.util.ObjectUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.http.util.Asserts;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Service;
@@ -38,8 +39,10 @@ public class WdtErpGoodsServiceImpl implements IErpGoodsService {
     public ErpGoodsQueryResponse getGoods(ErpGoodsQueryRequert param) {
         Map<String,String> map = new HashMap<>();
         map.put("spec_no",param.getCode());
+        Asserts.notBlank(param.getCode(),"barcode不能为空!");
+
         try {
-            String response = client.execute("trade_push.php", map);
+            String response = client.execute("goods_query.php", map);
             ParserConfig config = new ParserConfig();
             config.propertyNamingStrategy = PropertyNamingStrategy.CamelCase;
             ErpWdtBaseResponseDTO erpWdtBaseResponseDTO =
@@ -82,10 +85,12 @@ public class WdtErpGoodsServiceImpl implements IErpGoodsService {
     @Override
     public ErpGoodsStockQueryResponse getGoodsStock(ErpGoodsStockQueryRequert param) {
         String barcode = param.getBarcode();
+        Asserts.notBlank(barcode,"barcode不能为空!");
+
         Map<String,String> map = new HashMap<>();
         map.put("spec_no",barcode);
         try {
-            String response = client.execute("trade_push.php", map);
+            String response = client.execute("stock_query.php", map);
             ParserConfig config = new ParserConfig();
             config.propertyNamingStrategy = PropertyNamingStrategy.CamelCase;
             ErpWdtStockRespDTO erpWdtStockRespDTO = JSON.parseObject(response, ErpWdtStockRespDTO.class,config);

+ 6 - 3
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreCartServiceImpl.java

@@ -22,6 +22,7 @@ import com.fs.store.param.FsStoreCartDelParam;
 import com.fs.store.param.FsStoreCartNumParam;
 import com.fs.store.param.FsStoreCartParam;
 import com.fs.store.vo.FsStoreCartVO;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.fs.store.domain.FsStoreCart;
@@ -34,6 +35,7 @@ import com.fs.store.service.IFsStoreCartService;
  * @date 2022-03-21
  */
 @Service
+@Slf4j
 public class FsStoreCartServiceImpl implements IFsStoreCartService
 {
     @Autowired
@@ -135,7 +137,7 @@ public class FsStoreCartServiceImpl implements IFsStoreCartService
                     .isBuy(cartParam.getIsBuy())
                     .build();
             storeCart.setCreateTime(new Date());
-//            checkProductStock(cartParam.getProductId(),storeCart.getProductAttrValueId());
+            checkProductStock(cartParam.getProductId(),storeCart.getProductAttrValueId());
             fsStoreCartMapper.insertFsStoreCart(storeCart);
             return R.ok().put("id",storeCart.getId());
 
@@ -161,7 +163,7 @@ public class FsStoreCartServiceImpl implements IFsStoreCartService
                         .isBuy(0)
                         .build();
                 storeCart.setCreateTime(new Date());
-//                checkProductStock(cartParam.getProductId(),storeCart.getProductAttrValueId());
+                checkProductStock(cartParam.getProductId(),storeCart.getProductAttrValueId());
                 fsStoreCartMapper.insertFsStoreCart(storeCart);
                 return R.ok().put("id",storeCart.getId());
             }
@@ -169,7 +171,7 @@ public class FsStoreCartServiceImpl implements IFsStoreCartService
                 storeCart=cart.get(0);
                 storeCart.setCartNum(cartParam.getCartNum() + cart.get(0).getCartNum());
                 storeCart.setUpdateTime(new Date());
-//                checkProductStock(cartParam.getProductId(),storeCart.getProductAttrValueId());
+                checkProductStock(cartParam.getProductId(),storeCart.getProductAttrValueId());
                 fsStoreCartMapper.updateFsStoreCart(storeCart);
                 return R.ok().put("id",storeCart.getId());
             }
@@ -200,6 +202,7 @@ public class FsStoreCartServiceImpl implements IFsStoreCartService
 
     @Override
     public void checkProductStock(Long productId, Long productAttrValueId) {
+        log.info("检查库存 {} {}",productId,productAttrValueId);
         FsStoreProductAttrValue productAttrValue=valueMapper.selectFsStoreProductAttrValueById(productAttrValueId);
         if(StringUtils.isEmpty(productAttrValue.getGroupBarCode())){
             //单品