فهرست منبع

处理购物车添加问题

hulh 8 سال پیش
والد
کامیت
b47004169a

+ 3 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/GoodsServiceImpl.java

@@ -2626,8 +2626,9 @@ public class GoodsServiceImpl implements GoodsService {
      */
     @Override
     public ResultMap validGoodsIsChange(String batchCode, String storeuuid) {
+        Goods goods = null;
         if (StringUtils.hasText(batchCode) && StringUtils.hasText(storeuuid)) {
-            Goods goods = goodsDao.findByBatchCode(batchCode);
+            goods = goodsDao.findByBatchCode(batchCode);
             if (goods == null || goods.getStatus().intValue() != Status.AVAILABLE.value()) {
                 return new ResultMap(ResultMapType.GOODS_UNAVAILABLE.getCode(), ResultMapType.GOODS_UNAVAILABLE.getPhrase());
             } else {
@@ -2638,7 +2639,7 @@ public class GoodsServiceImpl implements GoodsService {
         } else {
             return new ResultMap(ResultMapType.NO_INFO.getCode(), "传入的信息丢失");
         }
-        return ResultMap.success(null);
+        return ResultMap.success(goods);
     }
 
 	/**

+ 6 - 10
src/main/java/com/uas/platform/b2c/trade/presale/facade/impl/CartFacadeImpl.java

@@ -1,6 +1,7 @@
 package com.uas.platform.b2c.trade.presale.facade.impl;
 
 import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.prod.commodity.model.Goods;
 import com.uas.platform.b2c.prod.commodity.service.GoodsService;
 import com.uas.platform.b2c.prod.product.component.modal.Component;
 import com.uas.platform.b2c.prod.product.component.service.ComponentService;
@@ -44,6 +45,7 @@ public class CartFacadeImpl implements CartFacade {
 		if (resultMap.getCode() == ResultMapType.NO_INFO.getCode() || resultMap.getCode() == ResultMapType.GOODS_UNAVAILABLE.getCode()) {
 			return resultMap;
 		}
+		Goods goods = (Goods) resultMap.getData();
 		// 获取买家用户UU和企业UU
 		Long userUU = SystemSession.getUser().getUserUU();
 		Long enUU =  SystemSession.getUser().getEnterprise() != null ? SystemSession.getUser().getEnterprise().getUu() : null;
@@ -58,16 +60,10 @@ public class CartFacadeImpl implements CartFacade {
 		if (cartService.addedSameGoods(cart.getBatchCode(), enUU, userUU)) {
 			return new ResultMap(CodeType.SAVED.code(), "商品记录已经添加");
 		}
-		// 设置器件信息
-		if (!StringUtils.isEmpty(cart.getUuid())) {
-			Component component = componentService.findByUuid(cart.getUuid());
-			if (component == null) {
-				return new ResultMap(CodeType.NOT_COMPLETE_INFO.code(), "器件信息不存在");
-			}
-			cart.setCode(component.getCode());
-			cart.setBrName(component.getBrand().getNameCn());
-			cart.setKiName(component.getKind().getNameCn());
-		}
+
+		cart.setCode(goods.getCode());
+		cart.setKiName(goods.getKindNameCn());
+		cart.setBrName(goods.getBrandNameEn());
 		cart.setUu(userUU);
 		cart.setEnuu(enUU);
 		ResultMap resultMap1 = cartService.saveCartRecord(cart);

+ 1 - 1
src/main/webapp/resources/view/usercenter/forstore/buyer_cart.html

@@ -618,7 +618,7 @@
 									<a href="store/{{store.arr[0].storeUuid}}/{{::cart.batchCode}}" target="_blank">
                                         <img ng-src="{{cart.img || 'static/img/store/common/default.png'}}" width="60" height="60"/></a>
 									<div class="car_pro_xq">
-									    <i class="text-hidden">类目:<a href="product/kind/{{cart.goods.kindUuid}}" target="_blank" ng-bind="::cart.kiName" title="{{::cart.kiName}}"></a></i>
+									    <i class="text-hidden">类目:<a href="product/kind/{{cart.goods.kindUuid}}" target="_blank" ng-bind="::cart.kiName || '-'" title="{{::cart.kiName}}"></a></i>
 									    <i class="text-hidden">型号:<a href="store/{{store.arr[0].storeUuid}}/{{::cart.batchCode}}" target="_blank" ng-bind="::cart.code" title="{{::cart.code}}"></a></i>
 									   <i class="text-hidden">品牌:<a href="product/brand/{{::cart.goods.branduuid}}/" target="_blank" ng-bind="::cart.goods.brandNameEn" title="{{::cart.goods.brandNameEn}}"></a></i>
 									</div>