|
|
@@ -1,11 +1,13 @@
|
|
|
package com.uas.platform.b2c.prod.store.facade.impl;
|
|
|
|
|
|
import com.uas.platform.b2c.core.config.SysConf;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.GoodsService;
|
|
|
import com.uas.platform.b2c.prod.product.kind.model.KindInfo;
|
|
|
import com.uas.platform.b2c.prod.product.kind.service.KindService;
|
|
|
import com.uas.platform.b2c.prod.store.facade.CommodityFacade;
|
|
|
import com.uas.platform.b2c.prod.store.service.CommodityService;
|
|
|
+import com.uas.platform.core.model.Constant;
|
|
|
import java.util.Collections;
|
|
|
import java.util.LinkedHashSet;
|
|
|
import java.util.List;
|
|
|
@@ -32,17 +34,21 @@ public class CommodityFacadeImpl implements CommodityFacade {
|
|
|
|
|
|
private final SysConf sysConf;
|
|
|
|
|
|
+ private final GoodsDao goodsDao;
|
|
|
+
|
|
|
@Autowired
|
|
|
- public CommodityFacadeImpl(CommodityService commodityService, KindService kindService, GoodsService goodsService,SysConf sysConf) {
|
|
|
+ public CommodityFacadeImpl(CommodityService commodityService, KindService kindService, GoodsService goodsService,SysConf sysConf, GoodsDao goodsDao) {
|
|
|
this.commodityService = commodityService;
|
|
|
this.kindService = kindService;
|
|
|
this.goodsService = goodsService;
|
|
|
this.sysConf = sysConf;
|
|
|
+ this.goodsDao = goodsDao;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<KindInfo> getAllKindsInfoByStoreUuid(String storeUuid) {
|
|
|
final KindInfo allKind = KindInfo.getAllKind(); //外层所有类目包裹
|
|
|
+ allKind.setCount(goodsDao.countByStoreid(storeUuid));
|
|
|
Set<KindInfo> children = new LinkedHashSet<>();
|
|
|
if (StringUtils.hasText(storeUuid)) {
|
|
|
Set<Long> kindUuidSet = commodityService.findAllKindsByStoreUuid(storeUuid);
|
|
|
@@ -51,10 +57,6 @@ public class CommodityFacadeImpl implements CommodityFacade {
|
|
|
children.addAll(kindList);
|
|
|
}
|
|
|
}
|
|
|
- // 补充该店铺各类目下商品数量
|
|
|
- for (KindInfo kindInfo : children) {
|
|
|
- kindInfo.setCount(commodityService.CountCommodityByKindAndStore(kindInfo.getId(), storeUuid));
|
|
|
- }
|
|
|
int count = goodsService.getNonstandardGoodsCount(storeUuid); //有效的在售非标数
|
|
|
if (!sysConf.getStoreid().equals(storeUuid)) {
|
|
|
Long enUU = goodsService.findenUUByStoreid(storeUuid);
|
|
|
@@ -66,6 +68,22 @@ public class CommodityFacadeImpl implements CommodityFacade {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 补充该店铺各类目下商品数量
|
|
|
+ for (KindInfo kindInfo : children) {
|
|
|
+ kindInfo.setCount(commodityService.countCommodityByKindAndStore(kindInfo, storeUuid));
|
|
|
+ if (kindInfo.getIsLeaf().equals(Constant.NO) && !CollectionUtils.isEmpty(kindInfo.getChildren())) {
|
|
|
+ for (KindInfo child : kindInfo.getChildren()) {
|
|
|
+ child.setCount(commodityService.countCommodityByKindAndStore(child, storeUuid));
|
|
|
+ if (child.getIsLeaf().equals(Constant.NO) && !CollectionUtils.isEmpty(kindInfo.getChildren())) {
|
|
|
+ for (KindInfo childKind : child.getChildren()) {
|
|
|
+ childKind.setCount(commodityService.countCommodityByKindAndStore(childKind, storeUuid));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (count != 0){ //存在非标则添加其他类目
|
|
|
KindInfo kindInfo = KindInfo.getOtherKind();
|
|
|
kindInfo.setCount(count);
|