...
|
...
|
@@ -6,9 +6,14 @@ import com.yohobuy.ufo.model.order.bo.ProductBo; |
|
|
import com.yohobuy.ufo.model.order.vo.GoodsVo;
|
|
|
import com.yohobuy.ufo.model.order.vo.ProductVo;
|
|
|
import com.yohobuy.ufo.model.response.StorageDataResp;
|
|
|
import com.yohoufo.common.helper.ImageUrlAssist;
|
|
|
import com.yohoufo.common.helper.ImagesHelper;
|
|
|
import com.yohoufo.dal.order.model.AppraiseOrderGoods;
|
|
|
import com.yohoufo.dal.order.model.AppraiseOrderStorage;
|
|
|
import com.yohoufo.order.convert.ProductConvertor;
|
|
|
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
|
|
|
import lombok.Builder;
|
|
|
import lombok.Data;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
...
|
...
|
@@ -17,13 +22,30 @@ import java.util.Map; |
|
|
|
|
|
public class SellerDepositOrderSupport <P, S>{
|
|
|
|
|
|
|
|
|
@Data
|
|
|
@Builder
|
|
|
static class SummaryNode<P>{
|
|
|
int total;
|
|
|
BigDecimal earnestMoney;
|
|
|
List<P> list;
|
|
|
}
|
|
|
private static abstract class RefNode{};
|
|
|
@Builder
|
|
|
private static class SonNode extends RefNode{
|
|
|
GoodsBo goodsBo;
|
|
|
StorageDataResp storageDataResp;
|
|
|
SellerOrderComputeResult socr;
|
|
|
long orderCode;
|
|
|
}
|
|
|
|
|
|
@Builder
|
|
|
private static class ParentNode<S> extends RefNode{
|
|
|
ProductInfo productInfo;
|
|
|
List<S> goodsList;
|
|
|
ProductBo productBo;
|
|
|
int totalOfOneSkn;
|
|
|
long orderCode;
|
|
|
}
|
|
|
|
|
|
public SummaryNode buildList(SellerDepositOrderPrepareService.DTNode dtNode,
|
|
|
TypeRef<P> parentTypeRef,
|
...
|
...
|
@@ -33,6 +55,8 @@ public class SellerDepositOrderSupport <P, S>{ |
|
|
//storage id map
|
|
|
Map<Integer, SellerOrderComputeResult> storageIdSOCRMap = dtNode.getStorageIdSOCRMap();
|
|
|
Map<Integer, StorageDataResp> storageIdSDRMap = dtNode.getStorageIdSDRMap();
|
|
|
long orderCode = dtNode.getOrderCode();
|
|
|
//
|
|
|
List<P> productList = new ArrayList<>(idProductMap.size());
|
|
|
int total = 0;
|
|
|
BigDecimal earnestMoney = BigDecimal.ZERO;
|
...
|
...
|
@@ -40,22 +64,35 @@ public class SellerDepositOrderSupport <P, S>{ |
|
|
ProductBo productBo = prdEntry.getValue();
|
|
|
List<GoodsBo> goodsBoList = productBo.getGoodsList();
|
|
|
List<S> goodsList = new ArrayList<>(goodsBoList.size());
|
|
|
int totalOfOneSkn = 0;
|
|
|
for (GoodsBo goodsBo : goodsBoList){
|
|
|
Integer storageId = goodsBo.getStorageId();
|
|
|
StorageDataResp storageDataResp = storageIdSDRMap.get(storageId);
|
|
|
SellerOrderComputeResult socr = storageIdSOCRMap.get(storageId);
|
|
|
int num = goodsBo.getNum();
|
|
|
total += num;
|
|
|
totalOfOneSkn += num;
|
|
|
BigDecimal singleEM = socr.getEarnestMoney().getEarnestMoney();
|
|
|
SonNode sonNode = SonNode.builder().goodsBo(goodsBo)
|
|
|
.storageDataResp(storageDataResp)
|
|
|
.socr(socr)
|
|
|
.orderCode(orderCode).build();
|
|
|
//
|
|
|
S son = sonTypeRef.convert(goodsBo, storageDataResp, socr);
|
|
|
S son = sonTypeRef.convert(sonNode);
|
|
|
earnestMoney = earnestMoney.add(singleEM.multiply(new BigDecimal(num)));
|
|
|
goodsList.add(son);
|
|
|
}
|
|
|
//build product
|
|
|
Integer productId = prdEntry.getKey();
|
|
|
ProductInfo productInfo = idProductInfoMap.get(productId);
|
|
|
P p = parentTypeRef.convert(productInfo, goodsList);
|
|
|
ParentNode.ParentNodeBuilder parentNodeBuilder = ParentNode.builder();
|
|
|
ParentNode parentNode = parentNodeBuilder.goodsList(goodsList)
|
|
|
.orderCode(orderCode)
|
|
|
.totalOfOneSkn(totalOfOneSkn)
|
|
|
.productBo(productBo)
|
|
|
.productInfo(productInfo)
|
|
|
.build();
|
|
|
P p = parentTypeRef.convert(parentNode);
|
|
|
productList.add(p);
|
|
|
}
|
|
|
SummaryNode.SummaryNodeBuilder<P> builder = SummaryNode.builder();
|
...
|
...
|
@@ -68,10 +105,11 @@ public class SellerDepositOrderSupport <P, S>{ |
|
|
public static TypeRef<GoodsVo> buildgoodsVoTypeRef(){
|
|
|
TypeRef<GoodsVo> goodsVoTypeRef = new TypeRef<GoodsVo>() {
|
|
|
@Override
|
|
|
public GoodsVo convert(Object... objects) {
|
|
|
GoodsBo goodsBo = (GoodsBo)objects[0];
|
|
|
StorageDataResp storageDataResp = (StorageDataResp) objects[1];
|
|
|
SellerOrderComputeResult socr = (SellerOrderComputeResult) objects[2];
|
|
|
public GoodsVo convert(RefNode refNode) {
|
|
|
SonNode sonNode = (SonNode) refNode;
|
|
|
GoodsBo goodsBo = sonNode.goodsBo;
|
|
|
StorageDataResp storageDataResp = sonNode.storageDataResp;
|
|
|
SellerOrderComputeResult socr = sonNode.socr;
|
|
|
BigDecimal singleEM = socr.getEarnestMoney().getEarnestMoney();
|
|
|
//
|
|
|
GoodsVo goodsVo = ProductConvertor.convertGoodsVo(goodsBo, storageDataResp, singleEM);
|
...
|
...
|
@@ -83,16 +121,17 @@ public class SellerDepositOrderSupport <P, S>{ |
|
|
|
|
|
public static TypeRef<ProductVo> buildProductVoTypeRef() {
|
|
|
TypeRef<ProductVo> productVoTypeRef = new TypeRef<ProductVo>() {
|
|
|
@Override
|
|
|
public ProductVo convert(Object... objects) {
|
|
|
ProductInfo productInfo = (ProductInfo) objects[0];
|
|
|
List<GoodsVo> goodsList = (List<GoodsVo>) objects[1];
|
|
|
|
|
|
@Override
|
|
|
public ProductVo convert(RefNode refNode) {
|
|
|
ParentNode<GoodsVo> parentNode = (ParentNode<GoodsVo>)refNode;
|
|
|
ProductInfo productInfo = parentNode.productInfo;
|
|
|
List<GoodsVo> goodsList = parentNode.goodsList;
|
|
|
ProductVo productVo = ProductVo.builder()
|
|
|
.productId(productInfo.getProductId())
|
|
|
.productCode(productInfo.getProductCode())
|
|
|
.productName(productInfo.getProductName())
|
|
|
.imgUrl(productInfo.getColorImage())
|
|
|
.imgUrl(ImageUrlAssist.getAllProductPicUrl(productInfo.getColorImage(), "goodsimg", "center", "d2hpdGU="))
|
|
|
.goodsList(goodsList)
|
|
|
.build();
|
|
|
return productVo;
|
...
|
...
|
@@ -103,8 +142,48 @@ public class SellerDepositOrderSupport <P, S>{ |
|
|
|
|
|
}
|
|
|
|
|
|
public static TypeRef<AppraiseOrderGoods> buildAppraiseOrderGoodsTypeRef(){
|
|
|
return ( refNode) -> {
|
|
|
ParentNode<AppraiseOrderStorage> parentNode = (ParentNode<AppraiseOrderStorage>) refNode;
|
|
|
ProductInfo productInfo = parentNode.productInfo;
|
|
|
List<AppraiseOrderStorage> goodsList = parentNode.goodsList;
|
|
|
ProductBo productBo = parentNode.productBo;
|
|
|
int totalOfOneSkn = parentNode.totalOfOneSkn;
|
|
|
long orderCode = parentNode.orderCode;
|
|
|
//
|
|
|
AppraiseOrderGoods paog = new AppraiseOrderGoods();
|
|
|
paog.setOrderCode(orderCode);
|
|
|
paog.setProductId(productInfo.getProductId());
|
|
|
paog.setProductName(productInfo.getProductName());
|
|
|
paog.setProductCode(productInfo.getProductCode());
|
|
|
paog.setImageUrl(productInfo.getColorImage());
|
|
|
paog.setAppraiseOrderStorageList(goodsList);
|
|
|
paog.setNum(totalOfOneSkn);
|
|
|
paog.setOrderBy(productBo.getOrderBy());
|
|
|
return paog;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
public static TypeRef<AppraiseOrderStorage> buildAppraiseOrderStorageTypeRef(){
|
|
|
TypeRef<AppraiseOrderStorage> goodsVoTypeRef = new TypeRef<AppraiseOrderStorage>() {
|
|
|
@Override
|
|
|
public AppraiseOrderStorage convert(RefNode refNode) {
|
|
|
|
|
|
SonNode sonNode = (SonNode) refNode;
|
|
|
GoodsBo goodsBo = sonNode.goodsBo;
|
|
|
StorageDataResp storageDataResp = sonNode.storageDataResp;
|
|
|
long orderCode = sonNode.orderCode;
|
|
|
//
|
|
|
AppraiseOrderStorage goodsVo = ProductConvertor.convertAppraiseOrderStorage(orderCode, goodsBo,
|
|
|
storageDataResp);
|
|
|
return goodsVo;
|
|
|
}
|
|
|
};
|
|
|
return goodsVoTypeRef;
|
|
|
}
|
|
|
|
|
|
interface TypeRef<T>{
|
|
|
T convert(Object... objects);
|
|
|
T convert(RefNode refNode);
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|