Authored by chenchao

入驻后skn维度的越价提示

package com.yohoufo.order.model.dto;
import lombok.Getter;
import lombok.Setter;
/**
* Created by chao.chen on 2019/1/28.
*/
public class PrdOverPriceDTO {
@Getter
@Setter
private Integer productId;
@Getter
@Setter
private Integer storageTotal;
private String tipsModule = "该商品有%d个库存出价超出建议售价,请及时调整售价。";
public String getTipsModule(){
if (storageTotal==null || storageTotal <= 0){
return "";
}
return String.format(tipsModule, storageTotal);
}
}
... ...
... ... @@ -4,7 +4,6 @@ import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.bo.ProductInfo;
import com.yohobuy.ufo.model.order.common.ButtonShow;
import com.yohobuy.ufo.model.order.common.SellerOrderListType;
... ... @@ -15,10 +14,12 @@ import com.yohobuy.ufo.model.order.req.SellerGoodsRequest;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohobuy.ufo.model.order.resp.SellerGoodsPageResp;
import com.yohobuy.ufo.model.response.StorageInfoResp;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.SellerOrderGoodsViewMapper;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.model.dto.PrdOverPriceDTO;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.SellerGoodsListRequest;
import com.yohoufo.order.service.impl.processor.SellerOrderPrepareProcessor;
... ... @@ -26,8 +27,9 @@ import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.OrderAssist;
import com.yohobuy.ufo.model.response.StorageInfoResp;
import com.yohoufo.order.utils.SellerGoodsHelper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -130,23 +132,30 @@ public class SkupListService {
respBuilder = PageResp.builder()
.page(request.getPage())
.pageSize(limit);
Integer uid = request.getUid();
boolean isEntry = userProxyService.isEntryShop(uid);
if (!isEntry){
logger.warn("getEntryGoodsList user is not entry, req {}", request);
return respBuilder.build();
}
int type;
if ((type=request.getType()) == SellerOrderListType.IN_SALE.getType()) {
List<Integer> statusList = Arrays.asList(SkupStatus.CAN_SELL.getCode());
int total = sellerOrderGoodsViewMapper.selectEntryCntByUidStatusGBSkc(request.getUid(), statusList);
SkupStatus viewableStatus = SkupStatus.CAN_SELL;
List<Integer> statusList = Arrays.asList(viewableStatus.getCode());
int total = sellerOrderGoodsViewMapper.selectEntryCntByUidStatusGBSkc(uid, statusList);
respBuilder.total(total)
.pagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1));
if (total == 0){
return respBuilder.build();
}
int offset = (request.getPage() - 1) * limit;
List<SellerOrderGoods> sogList = sellerOrderGoodsViewMapper.selectEntryListByUidStatusGBSkc(request.getUid(),
List<SellerOrderGoods> sogList = sellerOrderGoodsViewMapper.selectEntryListByUidStatusGBSkc(uid,
statusList, offset , limit);
if (CollectionUtils.isEmpty(sogList)){
logger.warn("seller get entry order list SellerOrderGoods is empty,req {}", request);
return respBuilder.build();
}
List<OrderListInfo> data = buildProductList(sogList, statusList);
List<OrderListInfo> data = buildProductList(sogList, viewableStatus);
respBuilder.data(data);
}
... ... @@ -294,6 +303,57 @@ public class SkupListService {
return psogOfMerge;
}
private PrdOverPriceDTO getPrdOverPriceDTO(Integer uid,
Integer productId, SkupStatus skupStatus){
PrdOverPriceDTO popDTO = new PrdOverPriceDTO();
popDTO.setProductId(productId);
Integer status = skupStatus.getCode();
SellerOrderGoods sogCondition = new SellerOrderGoods();
sogCondition.setProductId(productId);
sogCondition.setUid(uid);
sogCondition.setStatus(status);
//
int total = sellerOrderGoodsViewMapper.selectEntryCntByUidStatusGBSku(sogCondition);
if (total == 0){
return popDTO;
}
int offset = 0, limit = total;
List<SellerOrderGoods> sogList = sellerOrderGoodsViewMapper.selectEntryListByUidStatusGBSku(sogCondition,
offset, limit);
if (CollectionUtils.isEmpty(sogList)){
logger.warn("seller getPrdOverPriceDTO use SellerOrderGoods is empty,uid {} productId {}", uid, productId);
return popDTO;
}
Set<Integer> storageIds = sogList.parallelStream().map(SellerOrderGoods::getStorageId)
.collect(Collectors.toSet());
Map<Integer, StorageInfoResp> storageDataMap = productProxyService.getStorageDataMap(storageIds);
Integer st = findPrdOverPriceDTO(sogList, storageDataMap);
popDTO.setStorageTotal(st);
return popDTO;
}
private Integer findPrdOverPriceDTO(List<SellerOrderGoods> sogList, Map<Integer, StorageInfoResp> storageDataMap ){
int total = 0;
if (MapUtils.isEmpty(storageDataMap)){
return total;
}
for (SellerOrderGoods sog : sogList){
BigDecimal salePrice = sog.getGoodsPrice();
Integer storageId = sog.getStorageId();
StorageInfoResp sir;
if (Objects.nonNull(sir=storageDataMap.get(storageId))
&& SellerGoodsHelper.isOverSuggestMaxPrice(sir.getSuggestHighPrice(), salePrice)){
total += sog.getStorageNum();
}
}
return total;
}
... ... @@ -354,11 +414,18 @@ public class SkupListService {
}
public List<OrderListInfo> buildProductList(List<SellerOrderGoods> sogList, List<Integer> statusList){
public List<OrderListInfo> buildProductList(List<SellerOrderGoods> sogList,SkupStatus viewableStatus){
List<Integer> statusList = Arrays.asList(viewableStatus.getCode());
List<OrderListInfo> data ;
data = sogList.parallelStream()
.map(sog -> buildEntryOrderListInfo(sog, statusList))
.map(sog -> {
OrderListInfo oli = buildEntryOrderListInfo(sog, statusList);
Integer uid = sog.getUid();
Integer productId= sog.getProductId();
PrdOverPriceDTO pop = getPrdOverPriceDTO(uid, productId, viewableStatus);
oli.setTips(pop.getTipsModule());
return oli;
})
.filter(oli -> Objects.nonNull(oli))
.collect(Collectors.toList());
return data;
... ...
package com.yohoufo.order.utils;
import java.math.BigDecimal;
import java.util.Objects;
/**
* Created by chao.chen on 2019/1/28.
*/
public final class SellerGoodsHelper {
public static boolean isOverSuggestMaxPrice(BigDecimal suggestMaxPrice, BigDecimal prdPrice){
return Objects.nonNull(suggestMaxPrice) && prdPrice.compareTo(suggestMaxPrice) > 0;
}
}
... ...