增加渠道商链接

master
bynt 1 year ago
parent 67d821789a
commit 7af5125356

@ -174,12 +174,19 @@
<artifactId>core</artifactId> <artifactId>core</artifactId>
<version>3.1.0</version> <version>3.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.zxing</groupId> <groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId> <artifactId>javase</artifactId>
<version>3.1.0</version> <version>3.1.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
</dependency>
</dependencies> </dependencies>
<!-- 配置插件 --> <!-- 配置插件 -->

@ -6,12 +6,15 @@ import com.baiye.modules.agent.entity.query.ChannelQuery;
import com.baiye.modules.agent.service.CustomManageService; import com.baiye.modules.agent.service.CustomManageService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Map;
/** /**
* @author wjt * @author wjt
* @date 2023/4/12 * @date 2023/4/12
@ -44,7 +47,14 @@ public class CustomManageController {
@GetMapping("/link") @GetMapping("/link")
@ApiOperation("生成链接") @ApiOperation("生成链接")
public CommonResponse<Object> addLink(@RequestParam("customId") Long customId, @RequestParam("type") Integer type) { public CommonResponse<Object> addLink(@RequestParam("customId") Long customId, @RequestParam("type") Integer type) {
String linkUrl = customManageService.createLinkUrl(customId, type);
return CommonResponse.createBySuccess(linkUrl);
}
return CommonResponse.createBySuccess(); @GetMapping("/linkList")
@ApiOperation("渠道商链接地址")
public CommonResponse<Map<Integer,String>> findCustomList(@RequestParam("customId") Long customId) {
return CommonResponse.createBySuccess(customManageService.findUrlByCustomId(customId));
} }
} }

@ -0,0 +1,63 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.baiye.modules.agent.entity;
import com.baiye.model.base.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
/**
* @website https://el-admin.vip
* @description /
* @author Enzo
* @date 2021-12-30
**/
@Entity
@Getter
@Setter
@Table(name="tb_channel_custom_tag")
@EntityListeners(AuditingEntityListener.class)
public class ChannelCustomTag extends BaseEntity implements Serializable {
private static final long serialVersionUID = -1582474376747148049L;
@Id
@Column(name = "id")
@ApiModelProperty(value = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "tag_type")
@ApiModelProperty(value = "标志类型")
private Integer tagType;
@Column(name = "tag_str")
@ApiModelProperty(value = "标志值")
private String tagStr;
@ApiModelProperty(value = "渠道商id")
@Column(name = "channel_id")
private Long channelId;
}

@ -1,4 +1,4 @@
package com.baiye.modules.agent.dao; package com.baiye.modules.agent.repository;
import com.baiye.modules.agent.entity.ChannelCustom; import com.baiye.modules.agent.entity.ChannelCustom;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
@ -15,7 +15,7 @@ import java.util.Set;
* @date 2023/4/12 * @date 2023/4/12
*/ */
@Repository @Repository
public interface ChannelCustomDao extends JpaRepository<ChannelCustom, Long>, JpaSpecificationExecutor<ChannelCustom> { public interface ChannelCustomRepository extends JpaRepository<ChannelCustom, Long>, JpaSpecificationExecutor<ChannelCustom> {
/** /**
* *
@ -52,4 +52,15 @@ public interface ChannelCustomDao extends JpaRepository<ChannelCustom, Long>, Jp
* @return * @return
*/ */
ChannelCustom findByUserId(Long userId); ChannelCustom findByUserId(Long userId);
/**
* id
*
* @param userId
* @param status
* @return
*/
@Query("from ChannelCustom where userId = ?1 and status = ?2")
ChannelCustom findByUserIdAndStatus(Long userId, Integer status);
} }

@ -0,0 +1,40 @@
package com.baiye.modules.agent.repository;
import com.baiye.modules.agent.entity.ChannelCustom;
import com.baiye.modules.agent.entity.ChannelCustomTag;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author Enzo
* @date 2023-4-20
*/
@Repository
public interface ChannelCustomTagRepository extends JpaRepository<ChannelCustomTag, Long>, JpaSpecificationExecutor<ChannelCustomTag> {
/**
*
* @param customId
* @return
*/
List<ChannelCustomTag> findByChannelId(Long customId);
/**
*
* @param customId
* @param type
* @return
*/
@Query("from ChannelCustomTag where channelId = ?1 and tagType = ?2")
ChannelCustomTag findByCustomIdAndType(Long customId, Integer type);
}

@ -1,4 +1,4 @@
package com.baiye.modules.agent.dao; package com.baiye.modules.agent.repository;
import com.baiye.modules.agent.entity.ChannelResourceAssign; import com.baiye.modules.agent.entity.ChannelResourceAssign;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
@ -10,5 +10,5 @@ import org.springframework.stereotype.Repository;
* @date 2023/4/13 * @date 2023/4/13
*/ */
@Repository @Repository
public interface ChannelResourceAssignDao extends JpaRepository<ChannelResourceAssign, Long>, JpaSpecificationExecutor<ChannelResourceAssign> { public interface ChannelResourceAssignRepository extends JpaRepository<ChannelResourceAssign, Long>, JpaSpecificationExecutor<ChannelResourceAssign> {
} }

@ -5,6 +5,8 @@ import com.baiye.modules.agent.entity.ChannelCustom;
import com.baiye.modules.agent.entity.query.ChannelQuery; import com.baiye.modules.agent.entity.query.ChannelQuery;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.Map;
/** /**
* @author wjt * @author wjt
* @date 2023/4/12 * @date 2023/4/12
@ -37,4 +39,28 @@ public interface CustomManageService {
*/ */
Object queryAll(ChannelQuery channelCustomQuery, Pageable pageable); Object queryAll(ChannelQuery channelCustomQuery, Pageable pageable);
/**
*
* @param customId
* @param type
* @return
*/
String createLinkUrl(Long customId, Integer type);
/**
* id
* @param customId
* @return
*/
Map<Integer, String> findUrlByCustomId(Long customId);
/**
* id
*
* @param userId
* @param status
* @return
*/
ChannelCustom findCustomByUserIdAndStatus(Long userId, Integer status);
} }

@ -3,7 +3,7 @@ package com.baiye.modules.agent.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.baiye.constant.DefaultNumberConstants; import com.baiye.constant.DefaultNumberConstants;
import com.baiye.http.CommonResponse; import com.baiye.http.CommonResponse;
import com.baiye.modules.agent.dao.ChannelCustomDao; import com.baiye.modules.agent.repository.ChannelCustomRepository;
import com.baiye.modules.agent.entity.ChannelCustom; import com.baiye.modules.agent.entity.ChannelCustom;
import com.baiye.modules.agent.entity.query.ChannelQuery; import com.baiye.modules.agent.entity.query.ChannelQuery;
import com.baiye.modules.agent.service.ChannelManageService; import com.baiye.modules.agent.service.ChannelManageService;
@ -29,12 +29,12 @@ import java.util.stream.Collectors;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class ChannelManageServiceImpl implements ChannelManageService { public class ChannelManageServiceImpl implements ChannelManageService {
private final ChannelCustomDao channelCustomDao; private final ChannelCustomRepository channelCustomRepository;
private final UserService userService; private final UserService userService;
@Override @Override
public CommonResponse<Object> addChannel(String channelName, String phone, Long userId) { public CommonResponse<Object> addChannel(String channelName, String phone, Long userId) {
channelCustomDao.save(new ChannelCustom().addChannel(channelName, phone, userId)); channelCustomRepository.save(new ChannelCustom().addChannel(channelName, phone, userId));
return CommonResponse.createBySuccess(); return CommonResponse.createBySuccess();
} }
@ -50,7 +50,7 @@ public class ChannelManageServiceImpl implements ChannelManageService {
} }
PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort); PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort);
Page<ChannelCustom> channelCustoms = channelCustomDao.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, channelQuery, criteriaBuilder), pageRequest); Page<ChannelCustom> channelCustoms = channelCustomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, channelQuery, criteriaBuilder), pageRequest);
List<ChannelCustom> content = new ArrayList<>(channelCustoms.getContent()); List<ChannelCustom> content = new ArrayList<>(channelCustoms.getContent());
if (CollUtil.isEmpty(content)) { if (CollUtil.isEmpty(content)) {
return channelCustoms; return channelCustoms;
@ -64,7 +64,7 @@ public class ChannelManageServiceImpl implements ChannelManageService {
} }
//查询出所有子集 //查询出所有子集
Set<Long> set = parentMap.keySet(); Set<Long> set = parentMap.keySet();
List<ChannelCustom> byParentId = channelCustomDao.findByParentId(set); List<ChannelCustom> byParentId = channelCustomRepository.findByParentId(set);
content.addAll(byParentId); content.addAll(byParentId);
//子集 //子集
Map<Long, List<ChannelCustom>> userMap = content.stream().filter(channelCustom -> channelCustom.getParentId() != null) Map<Long, List<ChannelCustom>> userMap = content.stream().filter(channelCustom -> channelCustom.getParentId() != null)
@ -77,7 +77,7 @@ public class ChannelManageServiceImpl implements ChannelManageService {
if (parentMap.containsKey(key)) { if (parentMap.containsKey(key)) {
channelCustom = parentMap.get(key); channelCustom = parentMap.get(key);
} else { } else {
channelCustom = channelCustomDao.findById(key).orElse(new ChannelCustom()); channelCustom = channelCustomRepository.findById(key).orElse(new ChannelCustom());
} }
List<ChannelCustom> children = userMap.get(key); List<ChannelCustom> children = userMap.get(key);
if (CollUtil.isNotEmpty(children)) { if (CollUtil.isNotEmpty(children)) {
@ -99,7 +99,7 @@ public class ChannelManageServiceImpl implements ChannelManageService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public CommonResponse<Object> active(Set<Long> ids) { public CommonResponse<Object> active(Set<Long> ids) {
List<ChannelCustom> channelCustoms = channelCustomDao.findAllById(ids); List<ChannelCustom> channelCustoms = channelCustomRepository.findAllById(ids);
for (ChannelCustom channelCustom : channelCustoms) { for (ChannelCustom channelCustom : channelCustoms) {
String channelName = channelCustom.getChannelName(); String channelName = channelCustom.getChannelName();
String phone = channelCustom.getPhone(); String phone = channelCustom.getPhone();
@ -110,14 +110,14 @@ public class ChannelManageServiceImpl implements ChannelManageService {
channelCustom.setUserId(userId); channelCustom.setUserId(userId);
channelCustom.setStatus(DefaultNumberConstants.ONE_NUMBER); channelCustom.setStatus(DefaultNumberConstants.ONE_NUMBER);
} }
channelCustomDao.saveAll(channelCustoms); channelCustomRepository.saveAll(channelCustoms);
return CommonResponse.createBySuccess(); return CommonResponse.createBySuccess();
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public CommonResponse<Object> forbidden(Set<Long> ids) { public CommonResponse<Object> forbidden(Set<Long> ids) {
channelCustomDao.updateCustomStatus(ids, 3); channelCustomRepository.updateCustomStatus(ids, 3);
userService.updateUserStatusByCompanyId(false, new ArrayList<>(ids)); userService.updateUserStatusByCompanyId(false, new ArrayList<>(ids));
return CommonResponse.createBySuccess(); return CommonResponse.createBySuccess();
} }

@ -1,8 +1,8 @@
package com.baiye.modules.agent.service.impl; package com.baiye.modules.agent.service.impl;
import com.baiye.http.CommonResponse; import com.baiye.http.CommonResponse;
import com.baiye.modules.agent.dao.ChannelCustomDao; import com.baiye.modules.agent.repository.ChannelCustomRepository;
import com.baiye.modules.agent.dao.ChannelResourceAssignDao; import com.baiye.modules.agent.repository.ChannelResourceAssignRepository;
import com.baiye.modules.agent.entity.ChannelCustom; import com.baiye.modules.agent.entity.ChannelCustom;
import com.baiye.modules.agent.entity.ChannelResourceAssign; import com.baiye.modules.agent.entity.ChannelResourceAssign;
import com.baiye.modules.agent.entity.query.ChannelQuery; import com.baiye.modules.agent.entity.query.ChannelQuery;
@ -25,8 +25,8 @@ import org.springframework.transaction.annotation.Transactional;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class ChannelResourceAssignServiceImpl implements ChannelResourceAssignService { public class ChannelResourceAssignServiceImpl implements ChannelResourceAssignService {
private final ChannelResourceAssignDao channelResourceAssignDao; private final ChannelResourceAssignRepository channelResourceAssignRepository;
private final ChannelCustomDao channelCustomDao; private final ChannelCustomRepository channelCustomRepository;
@Override @Override
public Object queryAll(ChannelQuery channelQuery, Pageable pageable) { public Object queryAll(ChannelQuery channelQuery, Pageable pageable) {
@ -40,24 +40,24 @@ public class ChannelResourceAssignServiceImpl implements ChannelResourceAssignSe
} }
channelQuery.setId(null); channelQuery.setId(null);
PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort); PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort);
Page<ChannelResourceAssign> channelCustoms = channelResourceAssignDao.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, channelQuery, criteriaBuilder), pageRequest); Page<ChannelResourceAssign> channelCustoms = channelResourceAssignRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, channelQuery, criteriaBuilder), pageRequest);
return PageUtil.toPage(channelCustoms); return PageUtil.toPage(channelCustoms);
} }
@Override @Override
public Object queryAssign(ResourceAssignInfoQuery resourceAssignInfoQuery, Pageable pageable) { public Object queryAssign(ResourceAssignInfoQuery resourceAssignInfoQuery, Pageable pageable) {
PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by(Sort.Direction.DESC, "create_time")); PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by(Sort.Direction.DESC, "create_time"));
return channelResourceAssignDao.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, resourceAssignInfoQuery, criteriaBuilder), pageRequest); return channelResourceAssignRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, resourceAssignInfoQuery, criteriaBuilder), pageRequest);
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public CommonResponse<Object> assignNum(Long customId, Integer assignNum) { public CommonResponse<Object> assignNum(Long customId, Integer assignNum) {
ChannelCustom channelCustom = channelCustomDao.findById(customId).orElse(new ChannelCustom()); ChannelCustom channelCustom = channelCustomRepository.findById(customId).orElse(new ChannelCustom());
//增加客户的总量和余量 //增加客户的总量和余量
channelCustom.setTotalNum(channelCustom.getTotalNum() + assignNum); channelCustom.setTotalNum(channelCustom.getTotalNum() + assignNum);
channelCustom.setSurplusNum(channelCustom.getSurplusNum() + assignNum); channelCustom.setSurplusNum(channelCustom.getSurplusNum() + assignNum);
channelCustomDao.save(channelCustom); channelCustomRepository.save(channelCustom);
return CommonResponse.createBySuccess(); return CommonResponse.createBySuccess();
} }
} }

@ -2,24 +2,32 @@ package com.baiye.modules.agent.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil; 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.ObjectUtil;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import com.baiye.constant.DefaultNumberConstants; import com.baiye.constant.DefaultNumberConstants;
import com.baiye.http.CommonResponse; import com.baiye.http.CommonResponse;
import com.baiye.modules.agent.dao.ChannelCustomDao; import com.baiye.model.enums.UrlLinkEnum;
import com.baiye.modules.agent.dao.ChannelResourceAssignDao;
import com.baiye.modules.agent.entity.ChannelCustom; 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.ChannelResourceAssign;
import com.baiye.modules.agent.entity.query.ChannelQuery; import com.baiye.modules.agent.entity.query.ChannelQuery;
import com.baiye.modules.agent.repository.ChannelCustomRepository;
import com.baiye.modules.agent.repository.ChannelCustomTagRepository;
import com.baiye.modules.agent.repository.ChannelResourceAssignRepository;
import com.baiye.modules.agent.service.CustomManageService; import com.baiye.modules.agent.service.CustomManageService;
import com.baiye.modules.platform.service.dto.CreateUserDTO; import com.baiye.modules.platform.service.dto.CreateUserDTO;
import com.baiye.modules.system.domain.Role; import com.baiye.modules.system.domain.Role;
import com.baiye.modules.system.domain.User; import com.baiye.modules.system.domain.User;
import com.baiye.modules.system.service.impl.UserServiceImpl; import com.baiye.modules.system.service.impl.UserServiceImpl;
import com.baiye.util.FirstLetter;
import com.baiye.util.PageUtil; import com.baiye.util.PageUtil;
import com.baiye.util.QueryHelp; import com.baiye.util.QueryHelp;
import com.baiye.util.SecurityUtils; import com.baiye.util.SecurityUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@ -29,7 +37,10 @@ import org.springframework.transaction.annotation.Transactional;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
/** /**
* @author wjt * @author wjt
@ -38,15 +49,23 @@ import java.util.Set;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class CustomManageServiceImpl implements CustomManageService { public class CustomManageServiceImpl implements CustomManageService {
private final ChannelCustomDao channelCustomDao; private final ChannelCustomRepository channelCustomRepository;
private final ChannelResourceAssignDao channelResourceAssignDao;
private final ChannelCustomTagRepository channelCustomTagRepository;
private final ChannelResourceAssignRepository channelResourceAssignRepository;
private final UserServiceImpl userServiceImpl; private final UserServiceImpl userServiceImpl;
@Value("${generate.url}")
private String configurationUrl;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public CommonResponse<Object> addCustom(ChannelCustom channelCustom) { public CommonResponse<Object> addCustom(ChannelCustom channelCustom) {
//验证重复 //验证重复
ChannelCustom byAndChannelName = channelCustomDao.findByAndChannelName(channelCustom.getChannelName()); ChannelCustom byAndChannelName = channelCustomRepository.findByAndChannelName(channelCustom.getChannelName());
if (ObjectUtil.isNotEmpty(byAndChannelName)) { if (ObjectUtil.isNotEmpty(byAndChannelName)) {
return CommonResponse.createByErrorMessage("名称重复"); return CommonResponse.createByErrorMessage("名称重复");
} }
@ -67,7 +86,7 @@ public class CustomManageServiceImpl implements CustomManageService {
} }
} }
//获取父账号的总量 //获取父账号的总量
ChannelCustom parent = channelCustomDao.findById(channelCustom.getParentId()).orElse(new ChannelCustom()); ChannelCustom parent = channelCustomRepository.findById(channelCustom.getParentId()).orElse(new ChannelCustom());
if (parent.getSurplusNum() == null || parent.getSurplusNum() < channelCustom.getTotalNum()) { if (parent.getSurplusNum() == null || parent.getSurplusNum() < channelCustom.getTotalNum()) {
return CommonResponse.createByErrorMessage("可分配的余量不足"); return CommonResponse.createByErrorMessage("可分配的余量不足");
} }
@ -78,8 +97,8 @@ public class CustomManageServiceImpl implements CustomManageService {
String activeCode = "by" + getFourNum(channelCustom.getParentId().intValue()) + DateUtil.format(DateUtil.date(), "MMdd") + RandomUtil.randomString(4); String activeCode = "by" + getFourNum(channelCustom.getParentId().intValue()) + DateUtil.format(DateUtil.date(), "MMdd") + RandomUtil.randomString(4);
channelCustom.setActivationCode(activeCode); channelCustom.setActivationCode(activeCode);
channelCustomDao.save(channelCustom); channelCustomRepository.save(channelCustom);
channelCustomDao.save(parent); channelCustomRepository.save(parent);
//这里如果是代理商 直接同步 //这里如果是代理商 直接同步
CreateUserDTO createUserDTO = new CreateUserDTO().addCreateUserDTO(channelCustom.getChannelName(), channelCustom.getPhone()); CreateUserDTO createUserDTO = new CreateUserDTO().addCreateUserDTO(channelCustom.getChannelName(), channelCustom.getPhone());
User user = new User(); User user = new User();
@ -95,15 +114,15 @@ public class CustomManageServiceImpl implements CustomManageService {
userServiceImpl.create(user); userServiceImpl.create(user);
//分配记录 //分配记录
ChannelResourceAssign channelResourceAssign = new ChannelResourceAssign().addChannelResourceAssign(parent.getParentId(), channelCustom.getTotalNum(), channelCustom.getId(), channelCustom.getChannelName()); ChannelResourceAssign channelResourceAssign = new ChannelResourceAssign().addChannelResourceAssign(parent.getParentId(), channelCustom.getTotalNum(), channelCustom.getId(), channelCustom.getChannelName());
channelResourceAssignDao.save(channelResourceAssign); channelResourceAssignRepository.save(channelResourceAssign);
return CommonResponse.createBySuccess(); return CommonResponse.createBySuccess();
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public CommonResponse<Object> assignNum(Long customId, Integer assignNum) { public CommonResponse<Object> assignNum(Long customId, Integer assignNum) {
ChannelCustom channelCustom = channelCustomDao.findById(customId).orElse(new ChannelCustom()); ChannelCustom channelCustom = channelCustomRepository.findById(customId).orElse(new ChannelCustom());
ChannelCustom parent = channelCustomDao.findById(channelCustom.getParentId()).orElse(new ChannelCustom()); ChannelCustom parent = channelCustomRepository.findById(channelCustom.getParentId()).orElse(new ChannelCustom());
int parentTotalNum = parent.getTotalNum(); int parentTotalNum = parent.getTotalNum();
if (channelCustom.getType() == DefaultNumberConstants.ONE_NUMBER) { if (channelCustom.getType() == DefaultNumberConstants.ONE_NUMBER) {
@ -123,11 +142,11 @@ public class CustomManageServiceImpl implements CustomManageService {
//增加客户的总量和余量 //增加客户的总量和余量
channelCustom.setTotalNum(channelCustom.getTotalNum() + assignNum); channelCustom.setTotalNum(channelCustom.getTotalNum() + assignNum);
channelCustom.setSurplusNum(channelCustom.getSurplusNum() + assignNum); channelCustom.setSurplusNum(channelCustom.getSurplusNum() + assignNum);
channelCustomDao.save(parent); channelCustomRepository.save(parent);
channelCustomDao.save(channelCustom); channelCustomRepository.save(channelCustom);
//添加分配记录 //添加分配记录
ChannelResourceAssign channelResourceAssign = new ChannelResourceAssign().addChannelResourceAssign(parent.getParentId(), assignNum, channelCustom.getId(), channelCustom.getChannelName()); ChannelResourceAssign channelResourceAssign = new ChannelResourceAssign().addChannelResourceAssign(parent.getParentId(), assignNum, channelCustom.getId(), channelCustom.getChannelName());
channelResourceAssignDao.save(channelResourceAssign); channelResourceAssignRepository.save(channelResourceAssign);
return CommonResponse.createBySuccess(); return CommonResponse.createBySuccess();
} }
@ -143,14 +162,63 @@ public class CustomManageServiceImpl implements CustomManageService {
} }
//这里的id 是userId; //这里的id 是userId;
Long id = SecurityUtils.getCurrentUserId(); Long id = SecurityUtils.getCurrentUserId();
ChannelCustom byUserId = channelCustomDao.findByUserId(id); ChannelCustom byUserId = channelCustomRepository.findByUserId(id);
channelCustomQuery.setId(byUserId.getId()); channelCustomQuery.setId(byUserId.getId());
PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort); PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort);
Page<ChannelCustom> channelCustoms = channelCustomDao.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, channelCustomQuery, criteriaBuilder), pageRequest); Page<ChannelCustom> channelCustoms = channelCustomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, channelCustomQuery, criteriaBuilder), pageRequest);
return PageUtil.toPage(channelCustoms); return PageUtil.toPage(channelCustoms);
} }
@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 Map<Integer, String> findUrlByCustomId(Long customId) {
List<ChannelCustomTag> byChannelId = channelCustomTagRepository.findByChannelId(customId);
return byChannelId.stream().collect(Collectors.toMap(ChannelCustomTag::getTagType, tag -> {
String tagStr = tag.getTagStr();
Integer tagType = tag.getTagType();
UrlLinkEnum linkEnum = UrlLinkEnum.find(tagType);
return configurationUrl.concat(linkEnum.getUrl()).concat(tagStr);
}));
}
@Override
public ChannelCustom findCustomByUserIdAndStatus(Long userId, Integer status) {
return channelCustomRepository.findByUserIdAndStatus(userId, status);
}
private String getFourNum(Integer num) { private String getFourNum(Integer num) {
DecimalFormat decimalFormat = new DecimalFormat("0000"); DecimalFormat decimalFormat = new DecimalFormat("0000");
return decimalFormat.format(num); return decimalFormat.format(num);

@ -31,7 +31,6 @@ public class Agent extends BaseEntity implements Serializable {
@Column(name = "agency_name") @Column(name = "agency_name")
private String agencyName; private String agencyName;
@ApiModelProperty("邀请码") @ApiModelProperty("邀请码")
@Column(name = "invitation_code") @Column(name = "invitation_code")
private Integer invitationCode; private Integer invitationCode;

@ -35,7 +35,7 @@ import com.baiye.feign.IRemoteAuthService;
import com.baiye.feign.SourceClueClient; import com.baiye.feign.SourceClueClient;
import com.baiye.model.dto.*; import com.baiye.model.dto.*;
import com.baiye.model.enums.ResponseCode; import com.baiye.model.enums.ResponseCode;
import com.baiye.modules.agent.dao.ChannelCustomDao; import com.baiye.modules.agent.repository.ChannelCustomRepository;
import com.baiye.modules.agent.entity.ChannelCustom; import com.baiye.modules.agent.entity.ChannelCustom;
import com.baiye.modules.platform.domain.*; import com.baiye.modules.platform.domain.*;
import com.baiye.modules.platform.repository.*; import com.baiye.modules.platform.repository.*;
@ -61,7 +61,6 @@ import com.google.common.collect.Sets;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
@ -134,7 +133,7 @@ public class UserServiceImpl implements UserService {
private final ExtensionNumberService extensionNumberService; private final ExtensionNumberService extensionNumberService;
private final TaskImeiService taskImeiService; private final TaskImeiService taskImeiService;
private final TaskTagRepository taskTagRepository; private final TaskTagRepository taskTagRepository;
private final ChannelCustomDao channelCustomDao; private final ChannelCustomRepository channelCustomRepository;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -246,7 +245,7 @@ public class UserServiceImpl implements UserService {
user.setIsReview(Boolean.FALSE); user.setIsReview(Boolean.FALSE);
create(user); create(user);
//同步渠道商信息 //同步渠道商信息
channelCustomDao.save(new ChannelCustom().addChannel(userDTO.getUsername(), userDTO.getPhone(), userId)); channelCustomRepository.save(new ChannelCustom().addChannel(userDTO.getUsername(), userDTO.getPhone(), userId));
return Collections.singletonList(user.getId()); return Collections.singletonList(user.getId());
} }
} }

@ -44,7 +44,7 @@ public class CSVFileUtil {
} }
public static void main(String[] args) { public static void main(String[] args) {
File file = new File("C:\\Users\\a\\Desktop\\BY_20230326_1_dest.csv"); File file = new File("C:\\Users\\a\\Desktop\\jl-tztb1-xsxt2-010.csv");
List<String> phoneList = Lists.newArrayList(); List<String> phoneList = Lists.newArrayList();
List<String> tagStr = Lists.newArrayList(); List<String> tagStr = Lists.newArrayList();
CsvReader reader = CsvUtil.getReader(); CsvReader reader = CsvUtil.getReader();
@ -58,14 +58,14 @@ public class CSVFileUtil {
// csv通配 // csv通配
data.getRows().forEach(clue -> { data.getRows().forEach(clue -> {
phoneList.add(clue.size() == DefaultNumberConstants.THREE_NUMBER phoneList.add(clue.size() == DefaultNumberConstants.THREE_NUMBER
? clue.get(DefaultNumberConstants.TWO_NUMBER) : clue.get(DefaultNumberConstants.THREE_NUMBER)); ? clue.get(DefaultNumberConstants.TWO_NUMBER) : clue.get(DefaultNumberConstants.ZERO_NUMBER));
tagStr.add(tag); tagStr.add(tag);
}); });
// 去除重复 // 去除重复
List<String> phoneSets = Lists.newArrayList(Sets.newHashSet(phoneList)); List<String> phoneSets = Lists.newArrayList(Sets.newHashSet(phoneList));
File csvFile = new File("C:\\Users\\a\\Desktop\\2023-3-17-dmp.csv"); File csvFile = new File("C:\\Users\\a\\Desktop\\2023420-jl-tztb1-xsxt2-010.csv");
//导入HuTool中CSV工具包的CsvWriter类 //导入HuTool中CSV工具包的CsvWriter类
//设置导出字符类型, CHARSET_UTF_8 //设置导出字符类型, CHARSET_UTF_8
CsvWriter writer = CsvUtil.getWriter(csvFile, CharsetUtil.CHARSET_UTF_8); CsvWriter writer = CsvUtil.getWriter(csvFile, CharsetUtil.CHARSET_UTF_8);

@ -0,0 +1,37 @@
package com.baiye.util;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
/**
* @author Enzo
* @date : 2023/4/20
*/
public class FirstLetter {
private FirstLetter(){}
public static String getFirstPinYin(String chinese) {
HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
format.setCaseType(HanyuPinyinCaseType.UPPERCASE);
format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
StringBuilder firstPinyin = new StringBuilder();
char[] chineseArr = chinese.trim().toCharArray();
try {
for (char c : chineseArr) {
if (Character.toString(c).matches("[\\u4E00-\\u9FA5]+")) {
String[] pys = PinyinHelper.toHanyuPinyinStringArray(c, format);
firstPinyin.append(pys[0].charAt(0));
} else {
firstPinyin.append(c);
}
}
} catch (BadHanyuPinyinOutputFormatCombination badHanyuPinyinOutputFormatCombination) {
badHanyuPinyinOutputFormatCombination.printStackTrace();
}
return firstPinyin.toString();
}
}

@ -9,7 +9,7 @@ spring:
freemarker: freemarker:
check-template-location: false check-template-location: false
profiles: profiles:
active: prod active: dev
jackson: jackson:
time-zone: GMT+8 time-zone: GMT+8
data: data:
@ -106,4 +106,5 @@ payTemplate:
wechat: wechat:
gatewayHost: byqw.wework.uat.robot.ecofanli.com gatewayHost: byqw.wework.uat.robot.ecofanli.com
generate:
url: https://cb.tuoz.net

@ -0,0 +1,42 @@
package com.baiye;
import com.baiye.modules.agent.service.CustomManageService;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Map;
/**
* @author Enzo
* @date : 2022/9/16
*/
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = AdPlatformManagementApplication.class,
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class CustomTest {
@Resource
private CustomManageService customManageService;
@Test
public void getSetting() {
for (int i = 1; i < 7; i++) {
String linkUrl = customManageService.createLinkUrl(1L, i);
System.out.println(linkUrl);
}
}
@Test
public void customList() {
Map<Integer, String> urlByCustomId = customManageService.findUrlByCustomId(1L);
System.out.println(urlByCustomId);
}
}

@ -0,0 +1,59 @@
package com.baiye.model.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author Enzo
* @date : 2023/4/19
*/
@Getter
@AllArgsConstructor
public enum UrlLinkEnum {
/**
*
*/
JL(1, "/api/jl/monitor?aid=__AID__&cid=__CID__&ctype=__CTYPE__&csite=__CSITE__&imei=__IMEI__&idfa=__IDFA__&oaid=__OAID__&os=__OS__&mac=__MAC__&mac1=__MAC1__&ip=__IP__&geo=__GEO__&TIMESTAMP=__TS__&callback_url=__CALLBACK_URL__&model=__MODEL__&caid1=__CAID1__&tag="),
/**
* BD
*/
BD(2, "/api/bd/monitor?userid=__USER_ID__&aid=__IDEA_ID__&pid=__PLAN_ID__&uid=__UNIT_ID__&callback_url=__CALLBACK_URL__&click_id=__CLICK_ID__&idfa=__IDFA__&imei_md5=__IMEI__&oaid=__OAID__&mac=__MAC__&ip=__IP__&os=__OS__&ts=__TS__&device_info=__DEVICE_INFO__&tag="),
/**
* UC
*/
UC(3, "/api/uc/monitor?imei={IMEI_SUM1}&oaid={OAID}&time={TS}&callback={CALLBACK_URL}&androidid={ANDROIDID_SUM1}&mac={MAC_SUM2}&ip={IP}&ua={UA}&acid={ACID}&gid={GID}&aid={AID}&cid={CID}&model={MODEL1}&idfa={IDFA1}&tag="),
/**
* 广
*/
GDT(4, "/api/gdt/monitor?click_id=__CLICK_ID__&click_time=__CLICK_TIME__&campaign_id=_CAMPAIGN_ID__&adgroup_id=__ADGROUP_ID__&ad_id=__AD_ID__&muid=__MUID__&hash_android_id=__HASH_ANDROID_ID__&oaid=__OAID__&hash_oaid=__HASH_OAID__&ip=__IP__&user_agent=__USER_AGENT__&account_id=__ACCOUNT_ID__&promoted_object_type=__PROMOTED_OBJECT_TYPE__&device_os_type=__DEVICE_OS_TYPE__&callback=__CALLBACK__&qz_gdt=__QZ_GDT__&model=__MODEL__&tag="),
/**
*
*/
KS(5, "/api/ks/monitor?&accountid=__ACCOUNTID__&aid=__AID__&cid=__CID__&did=__DID__&dname=__DNAME__&imeiMD5=__IMEI2__&oaid=__OAID__&mac=__MAC2__&androidid=__ANDROIDID2__&os=__OS__&ts=__TS__&ip=__IP__&ua=__UA__&csite=__CSITE__&model=__MODEL__&ac_creative=__AC_CREATIVE__&idfa=__IDFA2__&tag="),
/**
* vivo
*/
VIVO(6, "/api/vivo/monitor?os=__OS__&imei=__IMEI__&ip=__IP__&oaid=__OAID__&oaidPlain=__OAIDPLAIN__&ua=__UA__&androidId=__ANDROIDID__&location=__LOCATION__&requestId=__REQUESTID__&requestTime=__REQUESTTIME__&advertiserId=__ADVERTISERID__&adName=__ADNAME__&creativeId=__CREATIVEID__&osVersion=__OSVERSION__&model=__MODEL__&lang=__LANG__&resolution=__RESOLUTION__&netType=__NETTYPE__&ts=__TS__&tag=");
private final int type;
private final String url;
public static UrlLinkEnum find(int val) {
for (UrlLinkEnum dataScopeEnum : UrlLinkEnum.values()) {
if (dataScopeEnum.getType() == val) {
return dataScopeEnum;
}
}
return null;
}
}

@ -52,6 +52,7 @@
<swagger2.version>2.9.2</swagger2.version> <swagger2.version>2.9.2</swagger2.version>
<dysmsapi.version>2.2.1</dysmsapi.version> <dysmsapi.version>2.2.1</dysmsapi.version>
<lionsoul.version>1.7.2</lionsoul.version> <lionsoul.version>1.7.2</lionsoul.version>
<pinyin4j.version>2.5.0</pinyin4j.version>
<redisson.version>3.11.1</redisson.version> <redisson.version>3.11.1</redisson.version>
<easyexcel.version>2.2.7</easyexcel.version> <easyexcel.version>2.2.7</easyexcel.version>
<ip2region.version>2.5.6</ip2region.version> <ip2region.version>2.5.6</ip2region.version>
@ -273,6 +274,13 @@
<version>${mybatis-plus-boot-stater.version}</version> <version>${mybatis-plus-boot-stater.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>${pinyin4j.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>

Loading…
Cancel
Save