Authored by chenchao

complete deposit order submit

... ... @@ -3,13 +3,15 @@ package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.AppraiseOrderGoods;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
public interface AppraiseOrderGoodsMapper {
int insert(AppraiseOrderGoods record);
int insertSelective(AppraiseOrderGoods record);
int insertBatch(@Param("list") Collection<AppraiseOrderGoods> appraiseOrderGoodsList);
AppraiseOrderGoods selectByOrderCode(Long orderCode);
... ...
package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.AppraiseOrderStorage;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
public interface AppraiseOrderStorageMapper {
int deleteByPrimaryKey(Integer id);
int insert(AppraiseOrderStorage record);
int insertBatch(@Param("list") Collection<AppraiseOrderStorage> records);
int insertSelective(AppraiseOrderStorage record);
AppraiseOrderStorage selectByPrimaryKey(Integer id);
... ...
... ... @@ -5,6 +5,8 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@Builder
@AllArgsConstructor@NoArgsConstructor
... ... @@ -25,4 +27,8 @@ public class AppraiseOrderGoods {
private Integer num;
private Integer orderBy;
private transient List<AppraiseOrderStorage> appraiseOrderStorageList;
}
\ No newline at end of file
... ...
... ... @@ -10,9 +10,10 @@
<result column="image_url" jdbcType="VARCHAR" property="imageUrl" />
<result column="depot_no" jdbcType="INTEGER" property="depotNo" />
<result column="num" jdbcType="INTEGER" property="num" />
<result column="order_by" jdbcType="INTEGER" property="orderBy" />
</resultMap>
<sql id="Base_Column_List">
id, order_code, product_id, product_name, product_code, image_url, depot_no, num
id, order_code, product_id, product_name, product_code, image_url, depot_no, num, order_by
</sql>
<select id="selectByOrderCode" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
... ... @@ -24,61 +25,33 @@
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.AppraiseOrderGoods" useGeneratedKeys="true">
insert into appraise_order_goods (order_code, product_id, product_name,
product_code, image_url, depot_no,
num)
num,order_by)
values (#{orderCode,jdbcType=BIGINT}, #{productId,jdbcType=INTEGER}, #{productName,jdbcType=VARCHAR},
#{productCode,jdbcType=VARCHAR}, #{imageUrl,jdbcType=VARCHAR}, #{depotNo,jdbcType=INTEGER},
#{num,jdbcType=INTEGER})
#{num,jdbcType=INTEGER},#{orderBy,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.AppraiseOrderGoods" useGeneratedKeys="true">
insert into appraise_order_goods
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderCode != null">
order_code,
</if>
<if test="productId != null">
product_id,
</if>
<if test="productName != null">
product_name,
</if>
<if test="productCode != null">
product_code,
</if>
<if test="imageUrl != null">
image_url,
</if>
<if test="depotNo != null">
depot_no,
</if>
<if test="num != null">
num,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderCode != null">
#{orderCode,jdbcType=BIGINT},
</if>
<if test="productId != null">
#{productId,jdbcType=INTEGER},
</if>
<if test="productName != null">
#{productName,jdbcType=VARCHAR},
</if>
<if test="productCode != null">
#{productCode,jdbcType=VARCHAR},
</if>
<if test="imageUrl != null">
#{imageUrl,jdbcType=VARCHAR},
</if>
<if test="depotNo != null">
#{depotNo,jdbcType=INTEGER},
</if>
<if test="num != null">
#{num,jdbcType=INTEGER},
</if>
</trim>
<insert id="insertBatch">
insert into appraise_order_goods (order_code, product_id, product_name,
product_code, image_url, depot_no,
num,order_by)
values
<foreach collection="list" item="aog" separator=",">
(
#{aog.orderCode,jdbcType=BIGINT},
#{aog.productId,jdbcType=INTEGER},
#{aog.productName,jdbcType=VARCHAR},
#{aog.productCode,jdbcType=VARCHAR},
#{aog.imageUrl,jdbcType=VARCHAR},
#{aog.depotNo,jdbcType=INTEGER},
#{aog.num,jdbcType=INTEGER},
#{aog.orderBy,jdbcType=INTEGER}
)
</foreach>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.AppraiseOrderGoods">
update appraise_order_goods
<set>
... ...
... ... @@ -32,6 +32,27 @@
#{storageId,jdbcType=INTEGER}, #{num,jdbcType=INTEGER})
</insert>
<insert id="insertBatch" >
insert into appraise_order_storage (order_code, product_id, size_id,
size_name, color_id, color_name,
storage_id, num)
values
<foreach collection="list" separator="," item="aos">
(
#{aos.orderCode,jdbcType=BIGINT},
#{aos.productId,jdbcType=INTEGER},
#{aos.sizeId,jdbcType=INTEGER},
#{aos.sizeName,jdbcType=VARCHAR},
#{aos.colorId,jdbcType=INTEGER},
#{aos.colorName,jdbcType=VARCHAR},
#{aos.storageId,jdbcType=INTEGER},
#{aos.num,jdbcType=INTEGER}
)
</foreach>
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.AppraiseOrderStorage" useGeneratedKeys="true">
insert into appraise_order_storage
<trim prefix="(" suffix=")" suffixOverrides=",">
... ...
package com.yohoufo.order.convert;
import com.yohobuy.ufo.model.order.bo.GoodsBo;
import com.yohobuy.ufo.model.order.bo.ProductBo;
import com.yohobuy.ufo.model.order.vo.GoodsVo;
import com.yohobuy.ufo.model.response.StorageDataResp;
import com.yohoufo.dal.order.model.AppraiseOrderStorage;
import java.math.BigDecimal;
... ... @@ -23,4 +25,20 @@ public final class ProductConvertor {
.earnestMoney(SellerOrderConvertor.formatFee(totalEM))
.build();
}
public static AppraiseOrderStorage convertAppraiseOrderStorage(long orderCode,
GoodsBo goodsBo,
StorageDataResp storageDataResp){
AppraiseOrderStorage aosc = new AppraiseOrderStorage();
aosc.setOrderCode(orderCode);
aosc.setProductId(storageDataResp.getProductId());
aosc.setColorId(Integer.valueOf(storageDataResp.getColorId()));
aosc.setColorName(storageDataResp.getColorName());
aosc.setSizeId(storageDataResp.getSize().getSizeId());
aosc.setSizeName(storageDataResp.getSize().getSizeName());
aosc.setStorageId(storageDataResp.getStorageId());
aosc.setNum(goodsBo.getNum());
return aosc;
}
}
... ...
... ... @@ -4,12 +4,14 @@ import com.yohobuy.ufo.model.ProductInfo;
import com.yohobuy.ufo.model.order.bo.ProductBo;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.response.StorageDataResp;
import com.yohoufo.dal.order.model.AppraiseOrderGoods;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@Data
... ... @@ -21,7 +23,6 @@ public class SellerDepositOrderContext {
private long orderCode;
private Integer clientType;
private String channelNo;
... ... @@ -31,13 +32,10 @@ public class SellerDepositOrderContext {
private BigDecimal earnestMoney;
private Map<Integer, ProductBo> idProductMap;
private Map<Integer, ProductInfo> idProductInfoMap;
private Map<Integer, SellerOrderComputeResult> storageIdSOCRMap;
private Map<Integer, StorageDataResp> storageIdSDRMap;
private OrderAttributes orderAttributes;
private List<AppraiseOrderGoods> appraiseOrderGoodsList;
}
... ...
... ... @@ -13,10 +13,12 @@ import com.yohoufo.dal.order.AppraiseOrderStorageMapper;
import com.yohoufo.dal.order.model.AppraiseOrder;
import com.yohoufo.dal.order.model.AppraiseOrderGoods;
import com.yohoufo.dal.order.model.AppraiseOrderMeta;
import com.yohoufo.dal.order.model.AppraiseOrderStorage;
import com.yohoufo.order.common.DelStatus;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.model.dto.AppraiseOrderContext;
import com.yohoufo.order.model.dto.SellerDepositOrderContext;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.utils.LoggerUtils;
import lombok.Builder;
import lombok.Data;
... ... @@ -28,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
public class AppraiseOrderCreateService {
... ... @@ -87,7 +90,7 @@ public class AppraiseOrderCreateService {
paog.setProductCode(aogb.getProductCode());
paog.setImageUrl(aogb.getImageUrl());
paog.setNum(1);
appraiseOrderGoodsMapper.insertSelective(paog);
appraiseOrderGoodsMapper.insert(paog);
//meta
AddressInfo noHiddenBackAddress = ctx.getBackAddress(),
... ... @@ -113,28 +116,14 @@ public class AppraiseOrderCreateService {
return SubmitResult.builder().appraiseOrder(pao).appraiseOrderGoods(paog).build();
}
void convertDO(SellerDepositOrderContext ctx){
long orderCode = ctx.getOrderCode();
List<AppraiseOrderGoods> aogList = new ArrayList<>();
/*
AppraiseOrderGoods paog = new AppraiseOrderGoods();
paog.setOrderCode(orderCode);
paog.setProductId(aogb.getProductId());
paog.setProductName(aogb.getProductName());
paog.setProductCode(aogb.getProductCode());
paog.setImageUrl(aogb.getImageUrl());
paog.setNum(1);
appraiseOrderGoodsMapper.insertSelective(paog);
*/
}
/**
* 待支付的寄存订单
* @param ctx
*/
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Database(ForceMaster=true, DataSource="ufo_order")
public void createSellerDepoistOrder(SellerDepositOrderContext ctx){
int uid = ctx.getUid();
long orderCode = ctx.getOrderCode();
... ... @@ -143,7 +132,7 @@ public class AppraiseOrderCreateService {
AppraiseOrder pao = new AppraiseOrder();
pao.setUid(ctx.getUid());
pao.setOrderCode(orderCode);
//pao.setAmount(ctx.getFee());
pao.setAmount(ctx.getEarnestMoney());
int cdt = DateUtil.getCurrentTimeSecond();
pao.setCreateTime(cdt);
... ... @@ -155,6 +144,31 @@ public class AppraiseOrderCreateService {
pao.setClientType(ctx.getClientType());
pao.setAttributes(ctx.getOrderAttributes().getCode());
appraiseOrderMapper.insertSelective(pao);
List<AppraiseOrderGoods> appraiseOrderGoodsList = ctx.getAppraiseOrderGoodsList();
//skn
appraiseOrderGoodsMapper.insertBatch(appraiseOrderGoodsList);
Map<Integer, SellerOrderComputeResult> storageIdSOCRMap = ctx.getStorageIdSOCRMap();
//fee of sku
for(AppraiseOrderGoods aog : appraiseOrderGoodsList){
List<AppraiseOrderStorage> aosList ;
appraiseOrderStorageMapper.insertBatch(aosList=aog.getAppraiseOrderStorageList());
List<AppraiseOrderMeta> feeAOMList = new ArrayList<>(aosList.size());
for(AppraiseOrderStorage aos : aosList){
Integer storageId = aos.getStorageId();
AppraiseOrderMeta feeAOM = new AppraiseOrderMeta();
feeAOM.setUid(uid);
feeAOM.setOrderCode(orderCode);
feeAOM.setStorageId(storageId);
feeAOM.setMetaKey(MetaKey.SELLER_FEE);
feeAOM.setMetaValue(JSONObject.toJSONString(storageIdSOCRMap.get(storageId)));
feeAOMList.add(feeAOM);
}
appraiseOrderMetaMapper.insertBatch(feeAOMList);
}
}
/**
... ...
... ... @@ -103,7 +103,7 @@ public abstract class AbsSellerOrderComputeHandler implements OrderComputeHandle
// earnestMoney.rate 动态可配
EarnestMoney emc = metaConfigService.getSellerEarnestMoney(getSkupType());
BigDecimal rate = (emc==null || Objects.isNull(rate = emc.getRate())) ? new BigDecimal(0.08D) : rate;
earnestMoney.setRate(rate);
earnestMoney.setRate(rate.setScale(4,BigDecimal.ROUND_HALF_UP));
EarnestMoney defaultEM = getDefaultEarnestMoney();
BigDecimal real = halfUp(prdPrice.multiply(rate));
... ...
... ... @@ -24,6 +24,7 @@ public class DepositOrderComputeHandler extends AbsSellerOrderComputeHandler imp
BigDecimal min = new BigDecimal(31);
EarnestMoney earnestMoney = new EarnestMoney();
earnestMoney.setEarnestMoney(min);
earnestMoney.setRate(new BigDecimal(0.02D));
earnestMoney.setMin(min);
earnestMoney.setMax(new BigDecimal(200));
return earnestMoney;
... ...
... ... @@ -5,7 +5,6 @@ import com.alibaba.fastjson.TypeReference;
import com.yohobuy.ufo.model.ProductInfo;
import com.yohobuy.ufo.model.order.bo.GoodsBo;
import com.yohobuy.ufo.model.order.bo.ProductBo;
import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
import com.yohobuy.ufo.model.order.req.SellerDepositOrderComputeReq;
import com.yohobuy.ufo.model.response.StorageDataResp;
import com.yohoufo.common.exception.UfoServiceException;
... ... @@ -118,6 +117,7 @@ public class SellerDepositOrderPrepareService {
DTNode node = DTNode.builder()
.uid(uid)
.idProductMap(idProductMap)
.storageIdSOCRMap(storageIdSOCRMap)
.idProductInfoMap(idProductInfoMap)
... ... @@ -127,7 +127,7 @@ public class SellerDepositOrderPrepareService {
}
DTNode checkGoods(int uid, List<GoodsBo> goodsList){
logger.info("in {}.checkGoods uid {} goodsList", getClass().getSimpleName(), uid, goodsList);
Map<Integer, SellerOrderComputeResult> storageIdSOCRMap = new HashMap<>(goodsList.size());
List<Integer> storageIds = new ArrayList<>(goodsList.size());
for(GoodsBo goodsBo : goodsList){
... ... @@ -148,10 +148,13 @@ public class SellerDepositOrderPrepareService {
}
Map<Integer, StorageDataResp> storageIdSDRMap = sdrs.stream()
.collect(Collectors.toMap(StorageDataResp::getStorageId, Function.identity()));
logger.info("in {}.checkGoods productProxyService.getStorageList uid {} storageIds {} ,StorageDataResp list {} ",
getClass().getSimpleName(), uid, storageIds, sdrs);
for (Integer storageId : storageIds) {
BigDecimal avgPrice = calAvgPrdPrice(storageId);
SellerOrderComputeResult socr = depositOrderComputeHandler.compute(avgPrice, null);
logger.info("in {}.checkGoods depositOrderComputeHandler.compute uid {} storageId {} avgPrice {} SellerOrderComputeResult {}",
getClass().getSimpleName(), uid, storageId, avgPrice, socr);
storageIdSOCRMap.put(storageId, socr);
}
... ... @@ -163,7 +166,8 @@ public class SellerDepositOrderPrepareService {
@Data
@Builder
static class DTNode{
private int uid;
private long orderCode;
private Map<Integer, ProductBo> idProductMap;
private Map<Integer, ProductInfo> idProductInfoMap;
private Map<Integer, SellerOrderComputeResult> storageIdSOCRMap;
... ...
... ... @@ -8,6 +8,8 @@ import com.yohobuy.ufo.model.order.vo.GoodsVo;
import com.yohobuy.ufo.model.order.vo.ProductVo;
import com.yohoufo.dal.order.AppraiseOrderGoodsMapper;
import com.yohoufo.dal.order.AppraiseOrderMapper;
import com.yohoufo.dal.order.model.AppraiseOrderGoods;
import com.yohoufo.dal.order.model.AppraiseOrderStorage;
import com.yohoufo.order.common.ClientType;
import com.yohoufo.order.convert.SellerOrderConvertor;
import com.yohoufo.order.model.dto.SellerDepositOrderContext;
... ... @@ -18,6 +20,9 @@ import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class SellerDepositOrderService {
private final Logger logger = LoggerUtils.getSellerOrderLogger();
... ... @@ -64,18 +69,19 @@ public class SellerDepositOrderService {
.uid(req.getUid()).goodsList(req.getGoodsList()).build();
SellerDepositOrderPrepareService.DTNode dtNode = sellerDepositOrderPrepareService.checkAndAckquire(sdocr);
long orderCode = orderCodeGenerator.generate(OrderCodeType.SELLER_TYPE);
long orderCode = orderCodeGenerator.generate(OrderCodeType.BUYER_TYPE);
logger.info("SellerDepositOrder.submit req {} ,generate new orderCode:{}", req, orderCode);
dtNode.setOrderCode(orderCode);
SellerDepositOrderSupport.SummaryNode<AppraiseOrderGoods> summaryNode = convertDO(dtNode);
SellerDepositOrderContext context = SellerDepositOrderContext.builder()
.uid(req.getUid())
.orderCode(orderCode)
.earnestMoney(summaryNode.earnestMoney)
.appraiseOrderGoodsList(summaryNode.list)
.channelNo(req.getChannelNo())
.clientType(ClientType.getClientType(req.getClientType()))
.idProductInfoMap(dtNode.getIdProductInfoMap())
.idProductMap(dtNode.getIdProductMap())
.storageIdSOCRMap(dtNode.getStorageIdSOCRMap())
.storageIdSDRMap(dtNode.getStorageIdSDRMap())
.orderAttributes(getOrderAttributes())
.build();
appraiseOrderCreateService.createSellerDepoistOrder(context);
... ... @@ -84,6 +90,15 @@ public class SellerDepositOrderService {
return SellerDepositOrderSubmitResp.builder().orderCode(orderCode).build();
}
SellerDepositOrderSupport.SummaryNode<AppraiseOrderGoods> convertDO(SellerDepositOrderPrepareService.DTNode dtNode){
SellerDepositOrderSupport<AppraiseOrderGoods,AppraiseOrderStorage> sdos = new SellerDepositOrderSupport<>();
SellerDepositOrderSupport.SummaryNode<AppraiseOrderGoods> summaryNode = sdos.buildList(dtNode,
SellerDepositOrderSupport.buildAppraiseOrderGoodsTypeRef(),
SellerDepositOrderSupport.buildAppraiseOrderStorageTypeRef());
return summaryNode;
}
public PageResp<SellerDepositOrderListResp> getOrderList(SellerDepositOrderListReq req ){
... ...
... ... @@ -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);
}
... ...
... ... @@ -100,7 +100,7 @@ public class ProductPriceService implements ApplicationContextAware{
public PriceTrendBO getAveragePriceOfMonthly(int storageId){
LOG.warn("in getAveragePriceOfMonthly, storageId {}", storageId);
LOG.info("in getAveragePriceOfMonthly, storageId {}", storageId);
Storage storage = storageMapper.selectByPrimaryKey(storageId);
if (storage == null){
... ... @@ -128,6 +128,7 @@ public class ProductPriceService implements ApplicationContextAware{
BigDecimal average = total.divide(new BigDecimal(cnt),2, BigDecimal.ROUND_HALF_UP);
PriceTrendBO priceTrendBO = new PriceTrendBO();
priceTrendBO.setPrice(average.toPlainString());
LOG.info("in getAveragePriceOfMonthly, storageId {} average {}", storageId, average);
return priceTrendBO;
}
}
... ...