Authored by chenchao

fix

... ... @@ -62,6 +62,12 @@ public class SkupListService {
@Autowired
private SellerOrderGoodsViewMapper sellerOrderGoodsViewMapper;
@Autowired
private ProductProxyService productProxyService;
@Autowired
private SellerOrderPrepareProcessor sellerOrderPrepareProcessor;
static Integer getMinSkupId(String skupList){
Integer lastSkup = null;
if (StringUtils.isNotBlank(skupList)){
... ... @@ -202,7 +208,7 @@ public class SkupListService {
Integer status = SkupStatus.CAN_SELL.getCode();
Integer uid = request.getUid();
boolean isEntry = userProxyService.isEntryShop(request.getUid());
boolean isEntry = userProxyService.isEntryShop(uid);
if (!isEntry){
logger.warn("getEntryGoodsSizeList not entry seller, req {}", request);
return respBuilder.build();
... ... @@ -215,11 +221,12 @@ public class SkupListService {
sogCondition.setStatus(status);
//
int total = sellerOrderGoodsViewMapper.selectEntryCntByUidStatusGBSku(sogCondition);
respBuilder.total(total)
.pagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1));
respBuilder.total(total);
if (total == 0){
return respBuilder.build();
}
int pageTotal = (total % limit == 0) ? (total / limit) : (total / limit + 1);
respBuilder.pagetotal(pageTotal);
int offset = (request.getPage() - 1) * limit;
List<SellerOrderGoods> sogList = sellerOrderGoodsViewMapper.selectEntryListByUidStatusGBSku(sogCondition,
offset, limit);
... ... @@ -231,12 +238,12 @@ public class SkupListService {
final SellerType sellerType = SellerType.ENTRY;
List<OrderListInfo> orderListInfos = buildPrdSkuList(productId, sogList, sellerType);
respBuilder.data(orderListInfos);
ProductInfo productInfo = buildProductInfo(sogList);
ProductInfo productInfo = buildProductInfo(uid, status, sogList, pageTotal);
respBuilder.productInfo(productInfo);
return respBuilder.build();
}
ProductInfo buildProductInfo(List<SellerOrderGoods> sogList){
ProductInfo buildProductInfo(Integer uid, Integer status, List<SellerOrderGoods> sogList, int pageTotal){
ProductInfo productInfo = new ProductInfo();
SellerOrderGoods sog = sogList.get(0);
productInfo.setProductId(sog.getProductId());
... ... @@ -246,24 +253,49 @@ public class SkupListService {
String imageUrl = ImageUrlAssist.getAllProductPicUrl(sog.getImageUrl(), "goodsimg", "center", "d2hpdGU=");
productInfo.setImageUrl(imageUrl);
//
Set<Integer> sizeIds = new HashSet<>(sogList.size());
int storageNum = 0;
for(SellerOrderGoods csog : sogList){
storageNum += csog.getStorageNum();
Integer sizeId;
if (!sizeIds.contains(sizeId=csog.getSizeId())){
sizeIds.add(sizeId);
int storageNum = 0, sizeNum = 0;
if (pageTotal==1) {
Set<Integer> sizeIds = new HashSet<>(sogList.size());
for (SellerOrderGoods csog : sogList) {
storageNum += csog.getStorageNum();
Integer sizeId;
if (!sizeIds.contains(sizeId = csog.getSizeId())) {
sizeIds.add(sizeId);
}
}
sizeNum = sizeIds.size();
}
productInfo.setSizeNum(sizeIds.size());
if (pageTotal>1){
SellerOrderGoods psogOfMerge = fetchSellerOrderGoodsFromDB(uid, Arrays.asList(status), sog.getProductId());
if (psogOfMerge != null) {
storageNum = psogOfMerge.getStorageNum();
sizeNum = psogOfMerge.getSizeNum();
}
}
//fetch from db if page num larger than 1
productInfo.setSizeNum(sizeNum);
productInfo.setStorageNum(storageNum);
return productInfo;
}
@Autowired
private ProductProxyService productProxyService;
@Autowired
private SellerOrderPrepareProcessor sellerOrderPrepareProcessor;
/**
*
* @param uid
* @param statusList
* @param productId
* @return
*/
private SellerOrderGoods fetchSellerOrderGoodsFromDB(int uid,
List<Integer> statusList,
Integer productId){
SellerOrderGoods psogOfMerge = sellerOrderGoodsViewMapper.selectByUidStatusGBSkc(uid, statusList, productId);
logger.info("fetchSellerOrderGoodsFromDB uid {} statusList {} prd id {}", uid, statusList, productId);
return psogOfMerge;
}
public Map<String,String> buildOverPriceTipsMap(Collection<Integer> storageIds, List<SellerOrderGoods> sogList,
Map<Integer, StorageInfoResp> getStorageDataMap){
... ... @@ -380,7 +412,7 @@ public class SkupListService {
productInfo.setProductId(productId=sellerOrderGoods.getProductId());
productInfo.setEntryFlag(true);
//
SellerOrderGoods psogOfMerge = sellerOrderGoodsViewMapper.selectByUidStatusGBSkc(uid,statusList,productId);
SellerOrderGoods psogOfMerge = fetchSellerOrderGoodsFromDB(uid,statusList,productId);
if (psogOfMerge != null){
productInfo.setStorageNum(psogOfMerge.getStorageNum());
productInfo.setSizeNum(psogOfMerge.getSizeNum());
... ...