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;
|
}
|
|
|
}
|