admin
2021-06-11 bc9d4bf3fddcb3107f8509159a250f7a5a5f8ae5
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
package com.yeshi.fanli.service.manger.goods.suning;
 
import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.entity.SystemPIDInfo;
import com.yeshi.fanli.exception.suning.SuningGoodsException;
import com.yeshi.fanli.service.manger.PIDManager;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.suning.SuningApiUtil;
import com.yeshi.fanli.util.suning.SuningUtil;
import com.yeshi.fanli.vo.suning.SuningConvertLinkResult;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
 
@Component
public class SuningConvertLinkManager {
 
    @Resource
    private PIDManager pidManager;
 
 
    /**
     * 商品转链
     *
     * @param concatGoodsId
     * @param uid
     * @param system
     * @param pidType
     * @return
     * @throws SuningGoodsException
     */
    public SuningConvertLinkResult convertGoods(String concatGoodsId, Long uid, SystemEnum system, SystemPIDInfo.PidType pidType) throws SuningGoodsException {
        String pid = pidManager.getPidCache(system, Constant.SOURCE_TYPE_SUNING, pidType);
        String[] sts = SuningUtil.getGoodsIdDetail(concatGoodsId);
        String supplierCode = sts[0];
        String goodsCode = sts[1];
 
        SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(goodsCode, supplierCode);
        if (goods == null) {
            throw new SuningGoodsException(1, "商品下架");
        }
 
        String quanUrl = null;
        if (!StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl()))
            quanUrl = goods.getCouponInfo().getCouponUrl();
        SuningConvertLinkResult link = SuningApiUtil.convertLinkNew(goodsCode, supplierCode,
                pid, uid + "");
 
        return link;
    }
 
 
}