package com.yeshi.fanli.service.manger.goods.jd;
|
|
import com.ks.lib.common.exception.ParamsException;
|
import com.yeshi.fanli.entity.SystemEnum;
|
import com.yeshi.fanli.entity.SystemPIDInfo;
|
import com.yeshi.fanli.service.manger.PIDManager;
|
import com.yeshi.fanli.util.Constant;
|
import com.yeshi.fanli.util.StringUtil;
|
import com.yeshi.fanli.util.jd.JDApiUtil;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.Resource;
|
|
/**
|
* 京东转链管理
|
*/
|
@Component
|
public class JDConvertLinkManager {
|
|
@Resource
|
private PIDManager pidManager;
|
|
/**
|
* 转链短链接
|
*
|
* @param shortLink
|
* @param uid
|
* @param system
|
* @param pidType
|
* @return
|
* @throws ParamsException
|
*/
|
public String convertShortUrl(String shortLink, Long uid, SystemEnum system, SystemPIDInfo.PidType pidType) throws ParamsException {
|
if (StringUtil.isNullOrEmpty(shortLink)) {
|
throw new ParamsException(ParamsException.CODE_PARAMS_NOT_ENOUGH, "短链为空");
|
}
|
|
if (system == null) {
|
throw new ParamsException(ParamsException.CODE_PARAMS_NOT_ENOUGH, "system为空");
|
}
|
|
if (pidType == null) {
|
throw new ParamsException(ParamsException.CODE_PARAMS_NOT_ENOUGH, "推广位类型为空");
|
}
|
|
return JDApiUtil.convertLinkWithSubUnionId(shortLink, null, null, pidManager.getPidCache(system, Constant.SOURCE_TYPE_JD, pidType), uid + "");
|
}
|
|
|
/**
|
* 转链常规链接
|
*
|
* @param materialId
|
* @param couponUrl
|
* @param uid
|
* @param system
|
* @param pidType
|
* @return
|
* @throws ParamsException
|
*/
|
public String convertGoodsUrl(String materialId, String couponUrl, Long uid, SystemEnum system, SystemPIDInfo.PidType pidType) throws ParamsException {
|
if (StringUtil.isNullOrEmpty(materialId)) {
|
throw new ParamsException(ParamsException.CODE_PARAMS_NOT_ENOUGH, "materialId为空");
|
}
|
|
if (system == null) {
|
throw new ParamsException(ParamsException.CODE_PARAMS_NOT_ENOUGH, "system为空");
|
}
|
|
if (pidType == null) {
|
throw new ParamsException(ParamsException.CODE_PARAMS_NOT_ENOUGH, "推广位类型为空");
|
}
|
|
return JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(system, Constant.SOURCE_TYPE_JD, pidType), uid + "");
|
}
|
|
|
}
|