wangdy 8 лет назад
Родитель
Сommit
8e12b75b78

+ 20 - 4
src/main/java/com/uas/platform/b2c/common/search/service/impl/SearcherServiceImpl.java

@@ -8,6 +8,8 @@ import com.uas.platform.b2c.common.search.rpc.service.SearchService;
 import com.uas.platform.b2c.common.search.service.SearcherService;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.core.utils.FastjsonUtils;
+import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
+import com.uas.platform.b2c.prod.commodity.model.Goods;
 import com.uas.platform.b2c.prod.product.brand.dao.BrandDao;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentGoodsDao;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentInfoDao;
@@ -57,6 +59,9 @@ public class SearcherServiceImpl implements SearcherService {
 	@Autowired
 	private BrandDao brandDao;
 
+	@Autowired
+	private GoodsDao goodsDao;
+
 	@Autowired
 	private SearchHistoryDao searchHistoryDao;
 
@@ -201,11 +206,22 @@ public class SearcherServiceImpl implements SearcherService {
 		List<ComponentGoods> components = new ArrayList<>();
 		if (!CollectionUtils.isEmpty(componentIds)) {
 			for (int i = 0 ;i < componentIds.size() ; i++){
-				Long cid = Long.valueOf(componentIds.get(i).toString());
+				Long cid = null;
+				if(!StringUtils.isEmpty
+						(componentIds.get(i)))  {
+					cid = Long.valueOf(componentIds.get(i).toString());
+				}
 				Long gid = goodsIds.get(i) == null ? 0L : Long.valueOf(goodsIds.get(i).toString());
-				ComponentGoods componentGoods = componentGoodsDao.findByCmpIdAndGoId(cid, gid);
-				if (componentGoods != null){
-					components.add(componentGoods);
+				if((cid == null) && (gid != 0L)) {
+					Goods goods = goodsDao.findOne(gid);
+					if(goods != null) {
+						components.add(new ComponentGoods(goods));
+					}
+				}else if(cid != null){
+					ComponentGoods componentGoods = componentGoodsDao.findByCmpIdAndGoId(cid, gid);
+					if (componentGoods != null){
+						components.add(componentGoods);
+					}
 				}
 			}
 			map.put("components", components);// 当前页器件内容