|
|
|
@ -17,6 +17,7 @@ import com.baiye.modules.agent.entity.ChannelCustom;
|
|
|
|
|
import com.baiye.modules.agent.entity.ChannelCustomTag;
|
|
|
|
|
import com.baiye.modules.agent.entity.ChannelResourceAssign;
|
|
|
|
|
import com.baiye.modules.agent.entity.query.ChannelQuery;
|
|
|
|
|
import com.baiye.modules.agent.entity.vo.CreateLinkUrlVO;
|
|
|
|
|
import com.baiye.modules.agent.entity.vo.CustomReportVo;
|
|
|
|
|
import com.baiye.modules.agent.repository.ChannelCustomRepository;
|
|
|
|
|
import com.baiye.modules.agent.repository.ChannelCustomTagRepository;
|
|
|
|
@ -64,6 +65,9 @@ public class CustomManageServiceImpl implements CustomManageService {
|
|
|
|
|
private Long channelId;
|
|
|
|
|
private final PasswordEncoder passwordEncoder;
|
|
|
|
|
|
|
|
|
|
private final Integer[] TAG_TYPE = {1, 2, 4, 5};
|
|
|
|
|
private final String VPOINT_URL = "&vpoint=";
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public CommonResponse<Object> addCustom(ChannelCustom channelCustom) {
|
|
|
|
@ -220,37 +224,100 @@ public class CustomManageServiceImpl implements CustomManageService {
|
|
|
|
|
return CommonResponse.createBySuccess();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
// public String createLinkUrl(Long customId, Integer type) {
|
|
|
|
|
// ChannelCustomTag customTag = channelCustomTagRepository.findByCustomIdAndType(customId, type);
|
|
|
|
|
// // 已存在直接返回
|
|
|
|
|
// if (ObjectUtil.isNotNull(customTag)) {
|
|
|
|
|
// UrlLinkEnum linkEnum = UrlLinkEnum.find(type);
|
|
|
|
|
// if (ObjectUtil.isNotNull(linkEnum) && linkEnum.getUrl() != null) {
|
|
|
|
|
// return configurationUrl.concat(linkEnum.getUrl()).concat(customTag.getTagStr());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// ChannelCustom channelCustom = channelCustomRepository.findById(customId).orElseGet(ChannelCustom::new);
|
|
|
|
|
// if (StringUtils.isNotBlank(channelCustom.getChannelName())) {
|
|
|
|
|
// // 公司名字转小写 拼接平台
|
|
|
|
|
// String firstPinYin = FirstLetter.getFirstPinYin(channelCustom.getChannelName());
|
|
|
|
|
// UrlLinkEnum linkEnum = UrlLinkEnum.find(type);
|
|
|
|
|
// if (ObjectUtil.isNotNull(linkEnum) && linkEnum.getUrl() != null) {
|
|
|
|
|
// String tagUrl = linkEnum.name().toLowerCase().concat(StrPool.DASHED)
|
|
|
|
|
// .concat(firstPinYin.toLowerCase())
|
|
|
|
|
// .concat(StrPool.DASHED).concat(DateUtil.format(DateUtil.date(), "MMdd"))
|
|
|
|
|
// .concat(StrPool.DASHED).concat(RandomUtil.randomString
|
|
|
|
|
// (DefaultNumberConstants.FOUR_NUMBER));
|
|
|
|
|
// String fullLink = configurationUrl.concat(linkEnum.getUrl()).concat(tagUrl);
|
|
|
|
|
// ChannelCustomTag channelCustomTag = new ChannelCustomTag();
|
|
|
|
|
// channelCustomTag.setTagType(type);
|
|
|
|
|
// channelCustomTag.setTagStr(tagUrl);
|
|
|
|
|
// channelCustomTag.setChannelId(customId);
|
|
|
|
|
// channelCustomTagRepository.save(channelCustomTag);
|
|
|
|
|
// return fullLink;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// return CharSequenceUtil.EMPTY;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String createLinkUrl(Long customId, Integer type) {
|
|
|
|
|
public List<CreateLinkUrlVO> createLinkUrl(Long customId, Integer type, String vpoInt, String aKey, Integer version) {
|
|
|
|
|
if (Arrays.asList(TAG_TYPE).contains(type) && StringUtils.isBlank(vpoInt)) {
|
|
|
|
|
throw new BadRequestException("请选择链接检测方式");
|
|
|
|
|
}
|
|
|
|
|
List<CreateLinkUrlVO> returnList = new ArrayList<>();
|
|
|
|
|
List<String> vpoIntList = new ArrayList<>();
|
|
|
|
|
String tagUrl = "";
|
|
|
|
|
if (StringUtils.isNotBlank(vpoInt)) vpoIntList = Arrays.asList(vpoInt.split(","));
|
|
|
|
|
|
|
|
|
|
UrlLinkEnum linkEnum = UrlLinkEnum.find(type);
|
|
|
|
|
String url = linkEnum.getUrl();
|
|
|
|
|
//巨量v2版本处理,获取v2的url
|
|
|
|
|
if (type == DefaultNumberConstants.ONE_NUMBER && version != null && version == DefaultNumberConstants.TWO_NUMBER) {
|
|
|
|
|
url = UrlLinkEnum.find(DefaultNumberConstants.SEVEN_NUMBER).getUrl();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChannelCustomTag customTag = channelCustomTagRepository.findByCustomIdAndType(customId, type);
|
|
|
|
|
// 已存在直接返回
|
|
|
|
|
if (ObjectUtil.isNotNull(customTag)) {
|
|
|
|
|
UrlLinkEnum linkEnum = UrlLinkEnum.find(type);
|
|
|
|
|
if (ObjectUtil.isNotNull(linkEnum) && linkEnum.getUrl() != null) {
|
|
|
|
|
return configurationUrl.concat(linkEnum.getUrl()).concat(customTag.getTagStr());
|
|
|
|
|
tagUrl = customTag.getTagStr();
|
|
|
|
|
if (StringUtils.isNotBlank(customTag.getAKey())) aKey = customTag.getAKey();
|
|
|
|
|
} else {
|
|
|
|
|
ChannelCustom channelCustom = channelCustomRepository.findById(customId).orElseGet(ChannelCustom::new);
|
|
|
|
|
if (StringUtils.isNotBlank(channelCustom.getChannelName())) {
|
|
|
|
|
// 公司名字转小写 拼接平台
|
|
|
|
|
String firstPinYin = FirstLetter.getFirstPinYin(channelCustom.getChannelName());
|
|
|
|
|
if (ObjectUtil.isNotNull(linkEnum) && linkEnum.getUrl() != null) {
|
|
|
|
|
tagUrl = linkEnum.name().toLowerCase().concat(StrPool.DASHED)
|
|
|
|
|
.concat(firstPinYin.toLowerCase())
|
|
|
|
|
.concat(StrPool.DASHED).concat(DateUtil.format(DateUtil.date(), "MMdd"))
|
|
|
|
|
.concat(StrPool.DASHED).concat(RandomUtil.randomString
|
|
|
|
|
(DefaultNumberConstants.FOUR_NUMBER));
|
|
|
|
|
ChannelCustomTag channelCustomTag = new ChannelCustomTag();
|
|
|
|
|
channelCustomTag.setTagType(type);
|
|
|
|
|
channelCustomTag.setTagStr(tagUrl);
|
|
|
|
|
channelCustomTag.setChannelId(customId);
|
|
|
|
|
if (StringUtils.isNotBlank(aKey)) channelCustomTag.setAKey(aKey);
|
|
|
|
|
channelCustomTagRepository.save(channelCustomTag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ChannelCustom channelCustom = channelCustomRepository.findById(customId).orElseGet(ChannelCustom::new);
|
|
|
|
|
if (StringUtils.isNotBlank(channelCustom.getChannelName())) {
|
|
|
|
|
// 公司名字转小写 拼接平台
|
|
|
|
|
String firstPinYin = FirstLetter.getFirstPinYin(channelCustom.getChannelName());
|
|
|
|
|
UrlLinkEnum linkEnum = UrlLinkEnum.find(type);
|
|
|
|
|
if (ObjectUtil.isNotNull(linkEnum) && linkEnum.getUrl() != null) {
|
|
|
|
|
String tagUrl = linkEnum.name().toLowerCase().concat(StrPool.DASHED)
|
|
|
|
|
.concat(firstPinYin.toLowerCase())
|
|
|
|
|
.concat(StrPool.DASHED).concat(DateUtil.format(DateUtil.date(), "MMdd"))
|
|
|
|
|
.concat(StrPool.DASHED).concat(RandomUtil.randomString
|
|
|
|
|
(DefaultNumberConstants.FOUR_NUMBER));
|
|
|
|
|
String fullLink = configurationUrl.concat(linkEnum.getUrl()).concat(tagUrl);
|
|
|
|
|
ChannelCustomTag channelCustomTag = new ChannelCustomTag();
|
|
|
|
|
channelCustomTag.setTagType(type);
|
|
|
|
|
channelCustomTag.setTagStr(tagUrl);
|
|
|
|
|
channelCustomTag.setChannelId(customId);
|
|
|
|
|
channelCustomTagRepository.save(channelCustomTag);
|
|
|
|
|
return fullLink;
|
|
|
|
|
//巨量v2版本处理tag,最后位置追加标识
|
|
|
|
|
if (type == DefaultNumberConstants.ONE_NUMBER && version != null && version == DefaultNumberConstants.TWO_NUMBER) {
|
|
|
|
|
tagUrl = tagUrl.concat("-v2");
|
|
|
|
|
}
|
|
|
|
|
//生成链接
|
|
|
|
|
String fullLink = configurationUrl.concat(url).concat(tagUrl);
|
|
|
|
|
if (Arrays.asList(TAG_TYPE).contains(type) && CollUtil.isNotEmpty(vpoIntList)) {
|
|
|
|
|
for (String vpoIntStr : vpoIntList) {
|
|
|
|
|
String newUrl = fullLink.concat(VPOINT_URL).concat(vpoIntStr);
|
|
|
|
|
if (StringUtils.isNotBlank(aKey)) {
|
|
|
|
|
newUrl = newUrl.concat("&akey=").concat(aKey);
|
|
|
|
|
}
|
|
|
|
|
CreateLinkUrlVO createLinkUrlVO = new CreateLinkUrlVO(newUrl, type, vpoIntStr);
|
|
|
|
|
returnList.add(createLinkUrlVO);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
CreateLinkUrlVO createLinkUrlVO = new CreateLinkUrlVO(fullLink, type, "");
|
|
|
|
|
returnList.add(createLinkUrlVO);
|
|
|
|
|
}
|
|
|
|
|
return CharSequenceUtil.EMPTY;
|
|
|
|
|
return returnList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -272,6 +339,15 @@ public class CustomManageServiceImpl implements CustomManageService {
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> findAKey(Long customId) {
|
|
|
|
|
Map<String, Object> map = new HashMap<>(1);
|
|
|
|
|
map.put("aKey", "");
|
|
|
|
|
ChannelCustomTag tag = channelCustomTagRepository.findByChannelIdAndTagType(customId, DefaultNumberConstants.TWO_NUMBER);
|
|
|
|
|
if (tag != null && StringUtils.isNotBlank(tag.getAKey())) map.put("aKey", tag.getAKey());
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ChannelCustom findCustomByUserIdAndStatus(Long userId, Integer status) {
|
|
|
|
|
return channelCustomRepository.findByUserIdAndStatus(userId, status);
|
|
|
|
@ -411,7 +487,8 @@ public class CustomManageServiceImpl implements CustomManageService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void disableChannelById(ChannelCustom custom, List<ChannelCustom> channelCustoms, List<Integer> num, List<Integer> bill) {
|
|
|
|
|
private void disableChannelById(ChannelCustom
|
|
|
|
|
custom, List<ChannelCustom> channelCustoms, List<Integer> num, List<Integer> bill) {
|
|
|
|
|
num.add(custom.getSurplusNum());
|
|
|
|
|
bill.add(custom.getSurplusPhoneBill());
|
|
|
|
|
custom.setStatus(3);
|
|
|
|
@ -430,4 +507,27 @@ public class CustomManageServiceImpl implements CustomManageService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
// * 拼接参数 向returnList集合中add
|
|
|
|
|
// *
|
|
|
|
|
// * @param vpoIntList vpoint集合
|
|
|
|
|
// * @param aKey 百度需要的值
|
|
|
|
|
// * @param url 要拼接的路径
|
|
|
|
|
// */
|
|
|
|
|
// public List<Map<String, Object>> montageParameter(List<String> vpoIntList, String aKey, String url, Integer type) {
|
|
|
|
|
// List<Map<String, Object>> list = new ArrayList<>();
|
|
|
|
|
// for (String vpoIntStr : vpoIntList) {
|
|
|
|
|
// String newUrl = url.concat(VPOINT_URL).concat(vpoIntStr);
|
|
|
|
|
// if (StringUtils.isNotBlank(aKey)) {
|
|
|
|
|
// newUrl = newUrl.concat("&akey=").concat(aKey);
|
|
|
|
|
// }
|
|
|
|
|
// Map<String, Object> map = new HashMap<>();
|
|
|
|
|
// map.put("url", newUrl);
|
|
|
|
|
// map.put("type", type);
|
|
|
|
|
// map.put("vpoInt", vpoIntStr);
|
|
|
|
|
// list.add(map);
|
|
|
|
|
// }
|
|
|
|
|
// return list;
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|