admin
2019-06-21 7f943e54f259c7ff69c7591dbd6803171126b01e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.yeshi.fanli.util.factory;
 
import java.math.BigDecimal;
import java.util.Date;
 
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.order.CommonOrderGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
 
public class CommonOrderGoodsFactory {
 
    public static CommonOrderGoods create(TaoBaoGoodsBrief goods) {
        if (goods == null)
            return null;
        CommonOrderGoods orderGoods = new CommonOrderGoods();
        orderGoods.setGoodsId(goods.getAuctionId() + "");
        orderGoods.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
        orderGoods.setPicture(goods.getPictUrl());
        orderGoods.setPrice(goods.getZkPrice());
        orderGoods.setShopId(goods.getSellerId());
        orderGoods.setShopName(goods.getShopTitle());
        if (goods.getUserType() == 0)
            orderGoods.setShopType(CommonOrderGoods.TYPE_TAOBAO);
        else
            orderGoods.setShopType(CommonOrderGoods.TYPE_TMALL);
        orderGoods.setTitle(goods.getTitle());
        return orderGoods;
    }
 
    public static CommonOrderGoods create(PDDGoodsDetail detail) {
        CommonOrderGoods goods = new CommonOrderGoods();
        goods.setGoodsId(detail.getGoodsId() + "");
        goods.setCreateTime(new Date());
        goods.setGoodsType(Constant.SOURCE_TYPE_PDD);
        goods.setPicture(detail.getGoodsImageUrl());
        goods.setPrice(MoneyBigDecimalUtil.div(new BigDecimal(detail.getMinNormalPrice()), new BigDecimal(100)));
        goods.setShopId(detail.getMallId());
        goods.setShopName(detail.getMallName());
        goods.setShopType(detail.getMerchantType() + "");
        goods.setState(0);
        goods.setTitle(detail.getGoodsName());
        return goods;
    }
 
    public static CommonOrderGoods create(JDGoods jdGoods) {
        CommonOrderGoods goods = new CommonOrderGoods();
        goods.setGoodsId(jdGoods.getSkuId() + "");
        goods.setCreateTime(new Date());
        goods.setGoodsType(Constant.SOURCE_TYPE_JD);
        if (jdGoods.getImageList() != null && jdGoods.getImageList().size() > 0)
            goods.setPicture(jdGoods.getImageList().get(0));
        goods.setPrice(jdGoods.getPrice());
        goods.setShopId((long) jdGoods.getShopInfo().getShopId());
        goods.setShopName(jdGoods.getShopInfo().getShopName());
        goods.setShopType(jdGoods.getOwner());
        goods.setState(0);
        goods.setTitle(jdGoods.getSkuName());
        return goods;
    }
 
}