1
0
lhm vor 3 Jahren
Ursprung
Commit
53efca76c4

+ 16 - 8
kmall-admin/src/main/java/com/kmall/admin/service/impl/GoodsServiceImpl.java

@@ -42,6 +42,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
@@ -1596,7 +1597,15 @@ public class GoodsServiceImpl implements GoodsService {
                     log.error("调用库存系统接口出现错误!返回结果为空!");
                     throw new ServiceException("调用库存系统接口出现错误!");
                 }
-                wareQueryStockResponseDTO = JacksonUtil.fromStringJson(queryWarehouseStockResponse, WareQueryStockResponseDTO.class);
+                wareQueryStockResponseDTO = (WareQueryStockResponseDTO) XmlUtil.xmlStrToBean(queryWarehouseStockResponse, WareQueryStockResponseDTO.class);
+                if (Objects.isNull(wareQueryStockResponseDTO)) {
+                    log.error("解析一步达库存系统响应数据出现错误!请求响应结果:{}", queryWarehouseStockResponse);
+                    throw new ServiceException("解析一步达库存系统响应数据出现错误!");
+                }
+                if ("failure".equals(wareQueryStockResponseDTO.getFlag())) {
+                    log.error("请求一步达库存系统返回错误响应!响应数据:{}", queryWarehouseStockResponse);
+                    throw new ServiceException(String.format("请求一步达库存系统查询库存错误!响应数据:%s", wareQueryStockResponseDTO.getMessage()));
+                }
             } else {
                 wareQueryStockResponseDTO = new WareQueryStockResponseDTO();
                 wareQueryStockResponseDTO.setCode("0");
@@ -1611,14 +1620,13 @@ public class GoodsServiceImpl implements GoodsService {
                 wareQueryStockResponseDTO.setItems(wareQueryStockResponseItemDTOS);
             }
 
-
-            if (Objects.isNull(wareQueryStockResponseDTO)) {
-                log.error("解析一步达库存系统响应数据出现错误!请求响应结果:{}", queryWarehouseStockResponse);
-                throw new ServiceException("解析一步达库存系统响应数据出现错误!");
-            }
-
             // 校验库存
-            WareQueryStockResponseDTO.WareQueryStockResponseItemDTO itemDTO = wareQueryStockResponseDTO.getItems().get(0);
+            List<WareQueryStockResponseDTO.WareQueryStockResponseItemDTO> items = wareQueryStockResponseDTO.getItems();
+            if (CollectionUtils.isEmpty(items)) {
+                log.error("查询商品时:【{}】,仓库不存在该商品!", prodBarcode);
+                throw new ServiceException(String.format("查询商品时:【%s】,仓库不存在该商品!", prodBarcode));
+            }
+            WareQueryStockResponseDTO.WareQueryStockResponseItemDTO itemDTO = items.get(0);
             // 仓库可用库存
             wareQuantity = itemDTO.getQuantity();
             JedisUtil.hset(warehouseStockMapKey, wareStockNumberKey, String.valueOf(wareQuantity));

+ 2 - 2
kmall-admin/src/main/webapp/js/sale/sale.js

@@ -6,8 +6,8 @@ $(function () {
     queryAssistantInfo();
     var cwQrcode = new Image();
     var cwLogo2 = new Image();
-    cwQrcode.src = "http://8.135.102.238:8080/statics/img/cw_qrcode.png";
-    cwLogo2.src = "http://8.135.102.238:8080/statics/img/cw_logo2.png";
+    cwQrcode.src = "http://120.76.119.218:8080/statics/img/cw_qrcode.png";
+    cwLogo2.src = "http://120.76.119.218:8080/statics/img/cw_logo2.png";
     vm.queryGoods();
 });