admin
2021-05-14 ae2294be876ac4595d7b31b36c0057726d12354f
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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.dto.suning.SuningGoodsInfo;
import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.order.CommonOrderGoods;
import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.util.Constant;
import org.yeshi.utils.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
 
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.getGoodsThumbnailUrl());
        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());
        if (jdGoods.getShopInfo() != null) {
            goods.setShopId((long) jdGoods.getShopInfo().getShopId());
            goods.setShopName(jdGoods.getShopInfo().getShopName());
        }
        goods.setShopType(jdGoods.getOwner());
        goods.setState(0);
        goods.setTitle(jdGoods.getSkuName());
        return goods;
    }
 
    public static CommonOrderGoods create(VIPGoodsInfo vipGoods) {
        CommonOrderGoods goods = new CommonOrderGoods();
        goods.setGoodsId(vipGoods.getGoodsId() + "");
        goods.setCreateTime(new Date());
        goods.setGoodsType(Constant.SOURCE_TYPE_VIP);
        goods.setPicture(vipGoods.getGoodsMainPicture());
        goods.setPrice(new BigDecimal(vipGoods.getVipPrice()));
        if (vipGoods.getBrandId() != null) {
            goods.setShopId(vipGoods.getBrandId());
            goods.setShopName(vipGoods.getBrandName());
        }
        goods.setShopType("唯品会");
        goods.setState(0);
        goods.setTitle(vipGoods.getGoodsName());
        return goods;
    }
 
    public static CommonOrderGoods create(SuningGoodsInfo suningGoods) {
        CommonOrderGoods goods = new CommonOrderGoods();
        goods.setGoodsId(suningGoods.getCommodityInfo().getCommodityCode());
        goods.setCreateTime(new Date());
        goods.setGoodsType(Constant.SOURCE_TYPE_SUNING);
        if (suningGoods.getCommodityInfo().getPictureUrl().size() > 0)
            goods.setPicture(suningGoods.getCommodityInfo().getPictureUrl().get(0).getPicUrl());
        
        String commodityPrice = suningGoods.getCommodityInfo().getCommodityPrice();
        if (StringUtil.isNullOrEmpty(commodityPrice)) {
            commodityPrice = suningGoods.getCommodityInfo().getSnPrice();
        }
        goods.setPrice(new BigDecimal(commodityPrice));
        goods.setShopId(Long.parseLong(suningGoods.getCommodityInfo().getSupplierCode()));
        goods.setShopName(suningGoods.getCommodityInfo().getSupplierName());
        goods.setShopType("苏宁");
        goods.setState(0);
        goods.setTitle(suningGoods.getCommodityInfo().getCommodityName());
        return goods;
    }
 
}