渠道商

master
wjt 1 year ago
parent 7af5125356
commit 9800fa342f

@ -38,7 +38,7 @@ public class ChannelResourceAssignController {
}
@GetMapping("/assign")
@ApiOperation("配量")
public CommonResponse<Object> assignNum(@RequestParam("channelId") Long channelId, @RequestParam("customId") Integer assignNum) {
public CommonResponse<Object> assignNum(@RequestParam("channelId") Long channelId, @RequestParam("assignNum") Integer assignNum) {
return channelResourceAssignService.assignNum(channelId, assignNum);
}

@ -4,15 +4,17 @@ import com.baiye.http.CommonResponse;
import com.baiye.modules.agent.entity.ChannelCustom;
import com.baiye.modules.agent.entity.query.ChannelQuery;
import com.baiye.modules.agent.service.CustomManageService;
import com.baiye.valid.AddGroup;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
@ -28,13 +30,13 @@ public class CustomManageController {
@PostMapping("/add")
@ApiOperation("新增账号")
public CommonResponse<Object> addCustom(@RequestBody ChannelCustom channelCustom) {
public CommonResponse<Object> addCustom(@RequestBody @Validated({AddGroup.class}) ChannelCustom channelCustom) {
return customManageService.addCustom(channelCustom);
}
@GetMapping("/assign")
@ApiOperation("配量")
public CommonResponse<Object> assignNum(@RequestParam("customId") Long customId, @RequestParam("customId") Integer assignNum) {
public CommonResponse<Object> assignNum(@RequestParam("customId") Long customId, @RequestParam("assignNum") Integer assignNum) {
return customManageService.assignNum(customId, assignNum);
}
@ -44,6 +46,12 @@ public class CustomManageController {
return new ResponseEntity<>(customManageService.queryAll(channelCustomQuery, pageable), HttpStatus.OK);
}
@GetMapping("/dmpLimitNum")
@ApiOperation("修改dmp投送数量")
public CommonResponse<Object> updateDmpLimitNum(@RequestParam("customId") Long customId, @RequestParam("dmpLimitNum") Integer dmpLimitNum) {
return customManageService.updateDmpLimitNum(customId, dmpLimitNum);
}
@GetMapping("/link")
@ApiOperation("生成链接")
public CommonResponse<Object> addLink(@RequestParam("customId") Long customId, @RequestParam("type") Integer type) {
@ -51,10 +59,9 @@ public class CustomManageController {
return CommonResponse.createBySuccess(linkUrl);
}
@GetMapping("/linkList")
@ApiOperation("渠道商链接地址")
public CommonResponse<Map<Integer,String>> findCustomList(@RequestParam("customId") Long customId) {
public CommonResponse<List<Map<String, Object>>> findCustomList(@RequestParam("customId") Long customId) {
return CommonResponse.createBySuccess(customManageService.findUrlByCustomId(customId));
}
}

@ -33,6 +33,7 @@ public class ChannelCustom implements Serializable {
@ApiModelProperty(value = "手机")
@Column(name = "phone")
@NotNull(groups = AddGroup.class)
private String phone;
@ApiModelProperty(value = "名称")
@ -47,11 +48,15 @@ public class ChannelCustom implements Serializable {
@ApiModelProperty(value = "总分配量")
@Column(name = "total_num")
private Integer totalNum;
private Integer totalNum = 0;
@ApiModelProperty(value = "dmp每日数量")
@Column(name = "dmp_limit_num")
private Integer dmpLimitNum = 100;
@ApiModelProperty(value = "分配余量")
@Column(name = "surplus_num")
private Integer surplusNum;
private Integer surplusNum = 0;
@ApiModelProperty(value = "用户状态 1 正常 2-待开通-3 禁用")
@Column(name = "status")
@ -71,15 +76,21 @@ public class ChannelCustom implements Serializable {
@ApiModelProperty(value = "父id")
@Column(name = "parent_id")
@NotNull(groups = AddGroup.class)
private Long parentId;
@ApiModelProperty(value = "子账号")
@Transient
private List<ChannelCustom> children;
@ApiModelProperty(value = "所有子账号数量")
@Transient
private Integer allCustomNum;
@ApiModelProperty(value = "已开通的子账号数")
@Transient
private Integer normalNum;
@ApiModelProperty(value = "待开通的子账号数")
@Transient
private Integer waitNum;

@ -1,5 +1,6 @@
package com.baiye.modules.agent.entity;
import cn.hutool.core.date.DateUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
@ -48,6 +49,7 @@ public class ChannelResourceAssign implements Serializable {
this.setAssignNum(assignNum);
this.setAssignBy(assignBy);
this.setAssignName(assignName);
this.setCreateTime(DateUtil.date());
return this;
}
}

@ -15,14 +15,11 @@ public class ChannelQuery {
@Query(type = Query.Type.INNER_LIKE)
private String channelName;
@ApiModelProperty(value = "默认排序为0 1-总量排序 2-余量排序")
private Integer sort = 0;
@ApiModelProperty(value = "客户类型 1-渠道商 2-直客")
@Query(type = Query.Type.EQUAL)
private Integer type;
@ApiModelProperty(value = "父id")
@Query(propName = "parentId", type = Query.Type.EQUAL)
private Long id;
}

@ -14,7 +14,7 @@ import java.util.List;
public class ResourceAssignInfoQuery {
@Query
private Long id;
private Long channelId;
@Query(type = Query.Type.BETWEEN)
private List<Timestamp> createTime;

@ -45,6 +45,17 @@ public interface ChannelCustomRepository extends JpaRepository<ChannelCustom, Lo
@Query("UPDATE ChannelCustom set status = ?2 where id in ?1")
int updateCustomStatus(Set<Long> ids, Integer status);
/**
* dmp
*
* @param customId
* @param dmpLimitNum
* @return
*/
@Modifying
@Query("UPDATE ChannelCustom set dmpLimitNum = ?2 where id = ?1")
int updateDmpLimitNum(Long customId, Integer dmpLimitNum);
/**
* id
*

@ -4,7 +4,9 @@ import com.baiye.http.CommonResponse;
import com.baiye.modules.agent.entity.ChannelCustom;
import com.baiye.modules.agent.entity.query.ChannelQuery;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
/**
@ -39,8 +41,18 @@ public interface CustomManageService {
*/
Object queryAll(ChannelQuery channelCustomQuery, Pageable pageable);
/**
* dmp
*
* @param customId
* @param dmpLimitNum
* @return
*/
CommonResponse<Object> updateDmpLimitNum(Long customId, Integer dmpLimitNum);
/**
*
*
* @param customId
* @param type
* @return
@ -49,10 +61,11 @@ public interface CustomManageService {
/**
* id
*
* @param customId
* @return
*/
Map<Integer, String> findUrlByCustomId(Long customId);
List<Map<String, Object>> findUrlByCustomId(Long customId);
/**

@ -3,9 +3,9 @@ package com.baiye.modules.agent.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.http.CommonResponse;
import com.baiye.modules.agent.repository.ChannelCustomRepository;
import com.baiye.modules.agent.entity.ChannelCustom;
import com.baiye.modules.agent.entity.query.ChannelQuery;
import com.baiye.modules.agent.repository.ChannelCustomRepository;
import com.baiye.modules.agent.service.ChannelManageService;
import com.baiye.modules.platform.service.dto.CreateUserDTO;
import com.baiye.modules.system.service.UserService;
@ -40,16 +40,7 @@ public class ChannelManageServiceImpl implements ChannelManageService {
@Override
public Object queryAll(ChannelQuery channelQuery, Pageable pageable) {
Sort sort;
if (channelQuery.getSort() != null && channelQuery.getSort() == 1) {
sort = Sort.by(Sort.Direction.DESC, "totalNum");
} else if (channelQuery.getSort() != null && channelQuery.getSort() == 2) {
sort = Sort.by(Sort.Direction.DESC, "surplusNum");
} else {
sort = Sort.by(Sort.Direction.DESC, "createTime");
}
PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort);
PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by(Sort.Direction.DESC, "createTime"));
Page<ChannelCustom> channelCustoms = channelCustomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, channelQuery, criteriaBuilder), pageRequest);
List<ChannelCustom> content = new ArrayList<>(channelCustoms.getContent());
if (CollUtil.isEmpty(content)) {
@ -58,17 +49,25 @@ public class ChannelManageServiceImpl implements ChannelManageService {
//父级
Map<Long, ChannelCustom> parentMap = new HashMap<>(8);
for (ChannelCustom channelCustom : content) {
if (channelCustom.getParentId() == null) {
Long parentId = channelCustom.getParentId();
if (parentId == null) {
parentMap.put(channelCustom.getId(), channelCustom);
}
}
//查询出所有子集
Set<Long> set = parentMap.keySet();
List<ChannelCustom> byParentId = channelCustomRepository.findByParentId(set);
content.addAll(byParentId);
List<ChannelCustom> byParentId = new ArrayList<>();
if (CollUtil.isNotEmpty(set)) {
byParentId = channelCustomRepository.findByParentId(set);
}
List<ChannelCustom> childrenList = content.stream().filter(channelCustom -> channelCustom.getParentId() != null).collect(Collectors.toList());
byParentId.addAll(childrenList);
//根据id去重
byParentId = byParentId.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(
() -> new TreeSet<>(Comparator.comparing(ChannelCustom::getId))), ArrayList::new));
//子集
Map<Long, List<ChannelCustom>> userMap = content.stream().filter(channelCustom -> channelCustom.getParentId() != null)
.collect(Collectors.groupingBy(ChannelCustom::getParentId));
Map<Long, List<ChannelCustom>> userMap = byParentId.stream().collect(Collectors.groupingBy(ChannelCustom::getParentId));
int allCustomNum = 0;
int normalNum = 0;
int waitNum = 0;
@ -81,8 +80,8 @@ public class ChannelManageServiceImpl implements ChannelManageService {
}
List<ChannelCustom> children = userMap.get(key);
if (CollUtil.isNotEmpty(children)) {
List<ChannelCustom> normalNums = children.stream().filter(c -> c.getStatus() == 1).collect(Collectors.toList());
List<ChannelCustom> waitNums = children.stream().filter(c -> c.getStatus() == 2).collect(Collectors.toList());
List<ChannelCustom> normalNums = children.stream().filter(c -> c.getStatus() == DefaultNumberConstants.ONE_NUMBER).collect(Collectors.toList());
List<ChannelCustom> waitNums = children.stream().filter(c -> c.getStatus() == DefaultNumberConstants.TWO_NUMBER).collect(Collectors.toList());
normalNum = normalNums.size();
waitNum = waitNums.size();
}

@ -1,12 +1,13 @@
package com.baiye.modules.agent.service.impl;
import cn.hutool.core.date.DateUtil;
import com.baiye.http.CommonResponse;
import com.baiye.modules.agent.repository.ChannelCustomRepository;
import com.baiye.modules.agent.repository.ChannelResourceAssignRepository;
import com.baiye.modules.agent.entity.ChannelCustom;
import com.baiye.modules.agent.entity.ChannelResourceAssign;
import com.baiye.modules.agent.entity.query.ChannelQuery;
import com.baiye.modules.agent.entity.query.ResourceAssignInfoQuery;
import com.baiye.modules.agent.repository.ChannelCustomRepository;
import com.baiye.modules.agent.repository.ChannelResourceAssignRepository;
import com.baiye.modules.agent.service.ChannelResourceAssignService;
import com.baiye.util.PageUtil;
import com.baiye.util.QueryHelp;
@ -30,24 +31,17 @@ public class ChannelResourceAssignServiceImpl implements ChannelResourceAssignSe
@Override
public Object queryAll(ChannelQuery channelQuery, Pageable pageable) {
Sort sort;
if (channelQuery.getSort() != null && channelQuery.getSort() == 1) {
sort = Sort.by(Sort.Direction.DESC, "totalNum");
} else if (channelQuery.getSort() != null && channelQuery.getSort() == 2) {
sort = Sort.by(Sort.Direction.DESC, "surplusNum");
} else {
sort = Sort.by(Sort.Direction.DESC, "createTime");
}
channelQuery.setId(null);
PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort);
Page<ChannelResourceAssign> channelCustoms = channelResourceAssignRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, channelQuery, criteriaBuilder), pageRequest);
PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by(Sort.Direction.DESC, "createTime"));
Page<ChannelCustom> channelCustoms = channelCustomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, channelQuery, criteriaBuilder), pageRequest);
return PageUtil.toPage(channelCustoms);
}
@Override
public Object queryAssign(ResourceAssignInfoQuery resourceAssignInfoQuery, Pageable pageable) {
PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by(Sort.Direction.DESC, "create_time"));
return channelResourceAssignRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, resourceAssignInfoQuery, criteriaBuilder), pageRequest);
PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by(Sort.Direction.DESC, "createTime"));
Page<ChannelResourceAssign> all = channelResourceAssignRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, resourceAssignInfoQuery, criteriaBuilder), pageRequest);
return PageUtil.toPage(all);
}
@Override
@ -58,6 +52,8 @@ public class ChannelResourceAssignServiceImpl implements ChannelResourceAssignSe
channelCustom.setTotalNum(channelCustom.getTotalNum() + assignNum);
channelCustom.setSurplusNum(channelCustom.getSurplusNum() + assignNum);
channelCustomRepository.save(channelCustom);
channelCustom.setPurchaseTime(DateUtil.date());
channelCustomRepository.save(channelCustom);
return CommonResponse.createBySuccess();
}
}

@ -1,13 +1,16 @@
package com.baiye.modules.agent.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.exception.BadRequestException;
import com.baiye.http.CommonResponse;
import com.baiye.model.enums.ResponseCode;
import com.baiye.model.enums.UrlLinkEnum;
import com.baiye.modules.agent.entity.ChannelCustom;
import com.baiye.modules.agent.entity.ChannelCustomTag;
@ -21,11 +24,13 @@ import com.baiye.modules.platform.service.dto.CreateUserDTO;
import com.baiye.modules.system.domain.Role;
import com.baiye.modules.system.domain.User;
import com.baiye.modules.system.service.impl.UserServiceImpl;
import com.baiye.util.MobileUtil;
import com.baiye.util.FirstLetter;
import com.baiye.util.PageUtil;
import com.baiye.util.QueryHelp;
import com.baiye.util.SecurityUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
@ -36,10 +41,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.DecimalFormat;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -48,6 +50,7 @@ import java.util.stream.Collectors;
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class CustomManageServiceImpl implements CustomManageService {
private final ChannelCustomRepository channelCustomRepository;
@ -69,37 +72,44 @@ public class CustomManageServiceImpl implements CustomManageService {
if (ObjectUtil.isNotEmpty(byAndChannelName)) {
return CommonResponse.createByErrorMessage("名称重复");
}
if (!MobileUtil.checkPhone(channelCustom.getPhone())) {
return CommonResponse.createByErrorMessage(ResponseCode.PHONE_NUMBER_IS_INCORRECT.getDesc());
}
//新建账号状态为2 待开通
channelCustom.setStatus(DefaultNumberConstants.TWO_NUMBER);
//获取父账号的总量
ChannelCustom parent = getChannelCustomByUserId();
//设置分配
if (channelCustom.getTotalNum() != null && channelCustom.getTotalNum() > 0) {
if (channelCustom.getType() == DefaultNumberConstants.ONE_NUMBER) {
if (channelCustom.getTotalNum() != null) {
if (channelCustom.getTotalNum() < DefaultNumberConstants.TEN_THOUSAND) {
return CommonResponse.createByErrorMessage("渠道商账号最低分配1万");
}
}
} else {
if (channelCustom.getTotalNum() != null) {
if (channelCustom.getTotalNum() < DefaultNumberConstants.ONE_THOUSAND) {
return CommonResponse.createByErrorMessage("直客账号最低分配1000");
}
}
}
//获取父账号的总量
ChannelCustom parent = channelCustomRepository.findById(channelCustom.getParentId()).orElse(new ChannelCustom());
if (parent.getSurplusNum() == null || parent.getSurplusNum() < channelCustom.getTotalNum()) {
return CommonResponse.createByErrorMessage("可分配的余量不足");
}
channelCustom.setSurplusNum(channelCustom.getTotalNum());
//减掉渠道商余量
parent.setSurplusNum(parent.getTotalNum() - channelCustom.getTotalNum());
parent.setCreateTime(DateUtil.date());
channelCustomRepository.save(parent);
//分配记录
ChannelResourceAssign channelResourceAssign = new ChannelResourceAssign().addChannelResourceAssign(parent.getId(), channelCustom.getTotalNum(), channelCustom.getId(), channelCustom.getChannelName());
channelResourceAssignRepository.save(channelResourceAssign);
}
//激活码
String activeCode = "by" + getFourNum(channelCustom.getParentId().intValue()) + DateUtil.format(DateUtil.date(), "MMdd") + RandomUtil.randomString(4);
String activeCode = "by" + getFourNum(parent.getId().intValue()) + DateUtil.format(DateUtil.date(), "MMdd") + RandomUtil.randomString(4);
channelCustom.setActivationCode(activeCode);
channelCustom.setParentId(parent.getId());
channelCustomRepository.save(channelCustom);
channelCustomRepository.save(parent);
//这里如果是代理商 直接同步
if (channelCustom.getType() == DefaultNumberConstants.ONE_NUMBER) {
CreateUserDTO createUserDTO = new CreateUserDTO().addCreateUserDTO(channelCustom.getChannelName(), channelCustom.getPhone());
User user = new User();
BeanUtil.copyProperties(createUserDTO, user);
@ -111,10 +121,12 @@ public class CustomManageServiceImpl implements CustomManageService {
role.setId(14L);
roles.add(role);
user.setRoles(roles);
userServiceImpl.create(user);
//分配记录
ChannelResourceAssign channelResourceAssign = new ChannelResourceAssign().addChannelResourceAssign(parent.getParentId(), channelCustom.getTotalNum(), channelCustom.getId(), channelCustom.getChannelName());
channelResourceAssignRepository.save(channelResourceAssign);
Long userId = userServiceImpl.create(user).getId();
channelCustom.setUserId(userId);
channelCustom.setStatus(1);
}
channelCustomRepository.save(channelCustom);
return CommonResponse.createBySuccess();
}
@ -123,8 +135,7 @@ public class CustomManageServiceImpl implements CustomManageService {
public CommonResponse<Object> assignNum(Long customId, Integer assignNum) {
ChannelCustom channelCustom = channelCustomRepository.findById(customId).orElse(new ChannelCustom());
ChannelCustom parent = channelCustomRepository.findById(channelCustom.getParentId()).orElse(new ChannelCustom());
int parentTotalNum = parent.getTotalNum();
int parentSurplusNum = parent.getSurplusNum();
if (channelCustom.getType() == DefaultNumberConstants.ONE_NUMBER) {
if (assignNum < DefaultNumberConstants.TEN_THOUSAND) {
return CommonResponse.createByErrorMessage("渠道商账号最低分配1万");
@ -134,42 +145,40 @@ public class CustomManageServiceImpl implements CustomManageService {
return CommonResponse.createByErrorMessage("直客账号最低分配1000");
}
}
if (parentTotalNum < assignNum) {
if (parentSurplusNum < assignNum) {
return CommonResponse.createByErrorMessage("可分配的余量不足");
}
//扣减父级渠道商的余量
parent.setSurplusNum(parent.getSurplusNum() - assignNum);
parent.setSurplusNum(parentSurplusNum - assignNum);
//增加客户的总量和余量
channelCustom.setTotalNum(channelCustom.getTotalNum() + assignNum);
channelCustom.setSurplusNum(channelCustom.getSurplusNum() + assignNum);
channelCustomRepository.save(parent);
channelCustomRepository.save(channelCustom);
channelCustom.setPurchaseTime(DateUtil.date());
//添加分配记录
ChannelResourceAssign channelResourceAssign = new ChannelResourceAssign().addChannelResourceAssign(parent.getParentId(), assignNum, channelCustom.getId(), channelCustom.getChannelName());
ChannelResourceAssign channelResourceAssign = new ChannelResourceAssign().addChannelResourceAssign(parent.getParentId(), assignNum, customId, channelCustom.getChannelName());
channelResourceAssignRepository.save(channelResourceAssign);
channelCustomRepository.save(parent);
channelCustomRepository.save(channelCustom);
return CommonResponse.createBySuccess();
}
@Override
public Object queryAll(ChannelQuery channelCustomQuery, Pageable pageable) {
Sort sort;
if (channelCustomQuery.getSort() != null && channelCustomQuery.getSort() == 1) {
sort = Sort.by(Sort.Direction.DESC, "totalNum");
} else if (channelCustomQuery.getSort() != null && channelCustomQuery.getSort() == 2) {
sort = Sort.by(Sort.Direction.DESC, "surplusNum");
} else {
sort = Sort.by(Sort.Direction.DESC, "createTime");
}
//这里的id 是userId;
Long id = SecurityUtils.getCurrentUserId();
ChannelCustom byUserId = channelCustomRepository.findByUserId(id);
channelCustomQuery.setId(byUserId.getId());
PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort);
Long customId = getChannelCustomByUserId().getId();
channelCustomQuery.setId(customId);
PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by(Sort.Direction.DESC, "createTime"));
Page<ChannelCustom> channelCustoms = channelCustomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, channelCustomQuery, criteriaBuilder), pageRequest);
return PageUtil.toPage(channelCustoms);
}
@Override
@Transactional(rollbackFor = Exception.class)
public CommonResponse<Object> updateDmpLimitNum(Long customId, Integer dmpLimitNum) {
channelCustomRepository.updateDmpLimitNum(customId, dmpLimitNum);
return CommonResponse.createBySuccess();
}
@Override
public String createLinkUrl(Long customId, Integer type) {
ChannelCustomTag customTag = channelCustomTagRepository.findByCustomIdAndType(customId, type);
@ -204,14 +213,22 @@ public class CustomManageServiceImpl implements CustomManageService {
}
@Override
public Map<Integer, String> findUrlByCustomId(Long customId) {
public List<Map<String, Object>> findUrlByCustomId(Long customId) {
List<ChannelCustomTag> byChannelId = channelCustomTagRepository.findByChannelId(customId);
return byChannelId.stream().collect(Collectors.toMap(ChannelCustomTag::getTagType, tag -> {
String tagStr = tag.getTagStr();
List<Map<String, Object>> list = new ArrayList<>();
if (CollUtil.isNotEmpty(byChannelId)) {
for (ChannelCustomTag tag : byChannelId) {
Integer tagType = tag.getTagType();
String tagStr = tag.getTagStr();
UrlLinkEnum linkEnum = UrlLinkEnum.find(tagType);
return configurationUrl.concat(linkEnum.getUrl()).concat(tagStr);
}));
String concat = configurationUrl.concat(linkEnum.getUrl()).concat(tagStr);
Map<String, Object> map = new HashMap<>(2);
map.put("type", tagType);
map.put("link", concat);
list.add(map);
}
}
return list;
}
@Override
@ -223,4 +240,14 @@ public class CustomManageServiceImpl implements CustomManageService {
DecimalFormat decimalFormat = new DecimalFormat("0000");
return decimalFormat.format(num);
}
private ChannelCustom getChannelCustomByUserId() {
Long id = SecurityUtils.getCurrentUserId();
ChannelCustom byUserId = channelCustomRepository.findByUserId(id);
if (ObjectUtil.isNull(byUserId)) {
log.info("系统账号id={}", id);
throw new BadRequestException("账号异常,请联系管理员");
}
return byUserId;
}
}

@ -8,6 +8,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
@ -34,7 +35,7 @@ public class CustomTest {
@Test
public void customList() {
Map<Integer, String> urlByCustomId = customManageService.findUrlByCustomId(1L);
List<Map<String, Object>> urlByCustomId = customManageService.findUrlByCustomId(1L);
System.out.println(urlByCustomId);
}

@ -57,7 +57,7 @@ public class ClueJpa {
public List<ClueDto> getClueList(ClueQueryCriteria clueQueryCriteria, Pageable pageable) {
StringBuilder sql = new StringBuilder();
sql.append("select c.id as id,c.name as name,c.nid as nid,c.wx as wx,c.origin as origin,c.collect_time as collectTime,c.address as address,c.record_id as recordId," +
"c.create_time as createTime,c.amount as amount,c.platform as platform,c.tag as tag,c.audio_url as audioUrl,c.cast_info as castInfo,c.is_encryption as isEncryption, cm.remark as remark,cm.member_status as memberStatus,cm.organize_id as organizeId,cm.member_id as memberId," +
"cm.create_time as createTime,c.amount as amount,c.platform as platform,c.tag as tag,c.audio_url as audioUrl,c.cast_info as castInfo,c.is_encryption as isEncryption, cm.remark as remark,cm.member_status as memberStatus,cm.organize_id as organizeId,cm.member_id as memberId," +
"cm.optimistic_version as optimisticVersion,cm.source_label as sourceLabel,cm.task_id as taskId,cm.clue_stage as clueStage,cm.clue_call_status as clueCallStatus," +
"cm.newest_call_time as newestCallTime ,cm.turnover_amount as turnoverAmount ,cm.clue_type as clueType " +
"from tb_clue as c LEFT JOIN tb_clue_middle as cm on c.id = cm.clue_id where 1=1 ");
@ -71,7 +71,7 @@ public class ClueJpa {
public List<ClueDto> getTalkClueList(ClueQueryCriteria clueQueryCriteria, Pageable pageable) {
StringBuilder sql = new StringBuilder();
sql.append("select c.id as id,c.name as name,c.nid as nid,c.wx as wx,c.origin as origin,c.collect_time as collectTime,c.address as address,c.record_id as recordId," +
"c.create_time as createTime,c.amount as amount,c.platform as platform,c.tag as tag,c.audio_url as audioUrl,c.cast_info as castInfo,c.is_encryption as isEncryption, cm.remark as remark,cm.member_status as memberStatus,cm.organize_id as organizeId,cm.member_id as memberId," +
"cm.create_time as createTime,c.amount as amount,c.platform as platform,c.tag as tag,c.audio_url as audioUrl,c.cast_info as castInfo,c.is_encryption as isEncryption, cm.remark as remark,cm.member_status as memberStatus,cm.organize_id as organizeId,cm.member_id as memberId," +
"cm.optimistic_version as optimisticVersion,cm.source_label as sourceLabel,cm.task_id as taskId,cm.clue_stage as clueStage,cm.clue_call_status as clueCallStatus," +
"cm.newest_call_time as newestCallTime ,cm.turnover_amount as turnoverAmount ,cm.clue_type as clueType " +
"from tb_clue as c LEFT JOIN tb_clue_talk as cm on c.id = cm.clue_id where 1=1 ");

Loading…
Cancel
Save