diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/feign/SourceClueClient.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/feign/SourceClueClient.java index ea33ddb6..a0350781 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/feign/SourceClueClient.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/feign/SourceClueClient.java @@ -1,6 +1,5 @@ package com.baiye.feign; -import com.baiye.annotation.Inner; import com.baiye.feign.callback.SourceClueClientFallback; import com.baiye.http.CommonResponse; import com.baiye.model.dto.ClueQueryCriteria; @@ -100,5 +99,10 @@ public interface SourceClueClient { @ApiOperation("根据组员互换所属组") @PostMapping(API_PREFIX + "/updateClueOrganize") ResponseEntity updateClueOrganize(@RequestBody Map map); + + + @ApiOperation("修改拓客和投流线索的冻结状态") + @GetMapping(API_PREFIX + "/updateTalkClueFreeze") + void updateTalkClueFreeze(@RequestParam("clueId") Long clueId, @RequestParam("isFreeze") Boolean isFreeze); } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/feign/callback/SourceClueClientFallback.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/feign/callback/SourceClueClientFallback.java index 256edd10..cf4e2c1c 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/feign/callback/SourceClueClientFallback.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/feign/callback/SourceClueClientFallback.java @@ -102,4 +102,8 @@ public class SourceClueClientFallback implements SourceClueClient { public ResponseEntity updateClueOrganize(Map map) { return null; } + + @Override + public void updateTalkClueFreeze(Long clueId, Boolean isFreeze) { + } } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/controller/ChannelManageController.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/controller/ChannelManageController.java index 7a769d78..e3fa23e5 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/controller/ChannelManageController.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/controller/ChannelManageController.java @@ -2,6 +2,7 @@ package com.baiye.modules.agent.controller; import com.baiye.annotation.Inner; 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.ChannelManageService; import com.baiye.util.SecurityUtils; @@ -12,6 +13,7 @@ import lombok.extern.slf4j.Slf4j; 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.Set; @@ -55,5 +57,10 @@ public class ChannelManageController { return channelManageService.forbidden(ids); } - + @ApiOperation("配置开通账号") + @PostMapping("/update") + public CommonResponse update(@RequestBody @Validated ChannelCustom channelCustom) { + channelManageService.update(channelCustom); + return CommonResponse.createBySuccess(); + } } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/controller/ChannelResourceAssignController.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/controller/ChannelResourceAssignController.java index c34960fb..3069f803 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/controller/ChannelResourceAssignController.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/controller/ChannelResourceAssignController.java @@ -1,7 +1,6 @@ package com.baiye.modules.agent.controller; import com.baiye.http.CommonResponse; -import com.baiye.modules.agent.entity.query.ChannelQuery; import com.baiye.modules.agent.entity.query.ResourceAssignInfoQuery; import com.baiye.modules.agent.entity.query.ResourceChannelQuery; import com.baiye.modules.agent.service.ChannelResourceAssignService; diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/controller/CustomManageController.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/controller/CustomManageController.java index 3e866f82..5480b106 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/controller/CustomManageController.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/controller/CustomManageController.java @@ -76,7 +76,6 @@ public class CustomManageController { return CommonResponse.createBySuccess(); } - @GetMapping("/report") @ApiOperation("统计") public CommonResponse report() { diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/entity/ChannelCustom.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/entity/ChannelCustom.java index 1ed4e26f..0fd1cf48 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/entity/ChannelCustom.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/entity/ChannelCustom.java @@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.RandomUtil; import com.baiye.util.NumUtil; import com.baiye.valid.AddGroup; +import com.baiye.valid.UpdateGroup; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @@ -27,6 +28,7 @@ public class ChannelCustom implements Serializable { @Id @Column(name = "id") @GeneratedValue(strategy = GenerationType.IDENTITY) + @NotNull(message = "修改时id不能为空", groups = {UpdateGroup.class}) private Long id; @ApiModelProperty(value = "系统用户id") @@ -79,6 +81,22 @@ public class ChannelCustom implements Serializable { @Column(name = "parent_id") private Long parentId; + @ApiModelProperty(value = "创建代理商账号数量") + @Column(name = "channel_limit_num") + private Integer channelLimitNum; + + @ApiModelProperty(value = "创建直客账号数量") + @Column(name = "custom_limit_num") + private Integer customLimitNum; + +// @ApiModelProperty(value = "总话费") +// @Column(name = "total_phone_bill") +// private Integer totalPhoneBill; +// +// @ApiModelProperty(value = "剩余话费") +// @Column(name = "surplus_phone_bill") +// private Integer surplusPhoneBill; + @ApiModelProperty(value = "子账号") @Transient private List children; @@ -101,6 +119,8 @@ public class ChannelCustom implements Serializable { this.setType(1); this.setTotalNum(0); this.setSurplusNum(0); +// this.setTotalPhoneBill(0); +// this.setSurplusPhoneBill(0); this.setStatus(1); this.setActivationCode(null); this.setCreateTime(DateUtil.date()); @@ -108,6 +128,8 @@ public class ChannelCustom implements Serializable { this.setParentId(null); this.setUserId(userId); this.setPhone(phone); + this.setCustomLimitNum(100); + this.setChannelLimitNum(1); return this; } @@ -116,6 +138,8 @@ public class ChannelCustom implements Serializable { this.setType(2); this.setTotalNum(0); this.setSurplusNum(0); +// this.setTotalPhoneBill(0); +// this.setSurplusPhoneBill(0); this.setStatus(1); String activeCode = "by" + NumUtil.getFourNum(parentId.intValue()) + DateUtil.format(DateUtil.date(), "MMdd") + RandomUtil.randomString(4); this.setActivationCode(activeCode); diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/repository/ChannelCustomRepository.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/repository/ChannelCustomRepository.java index e5c4c5e8..b6b7fb22 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/repository/ChannelCustomRepository.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/repository/ChannelCustomRepository.java @@ -44,6 +44,16 @@ public interface ChannelCustomRepository extends JpaRepository findByParentId(Long parentId); + /** + * 统计子项数量 + * + * @param parentId + * @param type + * @return + */ + @Query(value = "select count(*) from tb_channel_custom where parent_id = ?1 and type = ?2", nativeQuery = true) + Integer countByParentIdAndType(Long parentId, Integer type); + /** * 修改客户的状态 * @@ -112,6 +122,16 @@ public interface ChannelCustomRepository extends JpaRepository report(); + /** * 激活开通账号 * @@ -51,4 +53,11 @@ public interface ChannelManageService { * @return 成功状态 */ CommonResponse forbidden(Set ids); + + /** + * 修改 + * + * @param channelCustom + */ + void update(ChannelCustom channelCustom); } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/service/CustomManageService.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/service/CustomManageService.java index 73510574..553fd9bb 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/service/CustomManageService.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/service/CustomManageService.java @@ -4,7 +4,6 @@ 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; diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/service/impl/ChannelManageServiceImpl.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/service/impl/ChannelManageServiceImpl.java index 658e29a4..2c17c84f 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/service/impl/ChannelManageServiceImpl.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/service/impl/ChannelManageServiceImpl.java @@ -144,9 +144,11 @@ public class ChannelManageServiceImpl implements ChannelManageService { if (channelCustom.getType() == 1) { continue; } + //返回量 int num = channelCustom.getSurplusNum(); channelCustom.setStatus(3); channelCustom.setSurplusNum(0); + //返回话费 list.add(channelCustom); if (channelCustom.getParentId() != null) { channelCustomRepository.updateSurplusNum(channelCustom.getParentId(), num); @@ -161,6 +163,18 @@ public class ChannelManageServiceImpl implements ChannelManageService { return CommonResponse.createBySuccess(); } + @Override + public void update(ChannelCustom channelCustom) { + ChannelCustom channelCustomNew = channelCustomRepository.findById(channelCustom.getId()).orElseGet(ChannelCustom::new); + if (channelCustom.getChannelLimitNum() != null) { + channelCustomNew.setChannelLimitNum(channelCustom.getChannelLimitNum()); + } + if (channelCustom.getCustomLimitNum() != null) { + channelCustomNew.setCustomLimitNum(channelCustom.getCustomLimitNum()); + } + channelCustomRepository.save(channelCustomNew); + } + /** * 可以禁用渠道商的方法 * diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/service/impl/CustomManageServiceImpl.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/service/impl/CustomManageServiceImpl.java index c6cd7ee7..73d5d53a 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/service/impl/CustomManageServiceImpl.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/service/impl/CustomManageServiceImpl.java @@ -72,6 +72,16 @@ public class CustomManageServiceImpl implements CustomManageService { if (ObjectUtil.isNotEmpty(byAndChannelName)) { return CommonResponse.createByErrorMessage("名称重复"); } + //获取父账号信息 + ChannelCustom parent = getChannelCustomByUserId(); + //验证开通数量 + Integer limitNum = channelCustomRepository.countByParentIdAndType(parent.getId(), channelCustom.getType()); + if (channelCustom.getType() == 1 && parent.getChannelLimitNum() <= limitNum) { + return CommonResponse.createByErrorMessage("最多创建渠道商" + parent.getChannelLimitNum() + "个"); + } + if (channelCustom.getType() == 2 && parent.getCustomLimitNum() <= limitNum) { + return CommonResponse.createByErrorMessage("最多创建直客" + parent.getCustomLimitNum() + "个"); + } if (!MobileUtil.checkPhone(channelCustom.getPhone())) { return CommonResponse.createByErrorMessage(ResponseCode.PHONE_NUMBER_IS_INCORRECT.getDesc()); } @@ -81,8 +91,7 @@ public class CustomManageServiceImpl implements CustomManageService { } //新建账号状态为2 待开通 channelCustom.setStatus(DefaultNumberConstants.TWO_NUMBER); - //获取父账号的总量 - ChannelCustom parent = getChannelCustomByUserId(); + //设置分配 if (channelCustom.getTotalNum() != null && channelCustom.getTotalNum() > 0) { // if (channelCustom.getType() == DefaultNumberConstants.ONE_NUMBER) { @@ -129,6 +138,8 @@ public class CustomManageServiceImpl implements CustomManageService { Long userId = create(user).getId(); channelCustom.setUserId(userId); channelCustom.setStatus(1); + channelCustom.setChannelLimitNum(1); + channelCustom.setCustomLimitNum(100); } channelCustom.setCreateTime(DateUtil.date()); channelCustomRepository.save(channelCustom); diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/domain/ExcellentCases.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/domain/ExcellentCases.java index 7137d854..fa4e17d0 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/domain/ExcellentCases.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/domain/ExcellentCases.java @@ -41,6 +41,9 @@ public class ExcellentCases implements Serializable { @Column(name = "create_by") private Long createBy; + @Column(name = "create_name") + private String createName; + @Column(name = "operate_id") @ApiModelProperty(value = "拨打人id") private Long operateId; diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/ExcellentCasesRepository.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/ExcellentCasesRepository.java index 7baf0cec..d32a0d59 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/ExcellentCasesRepository.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/ExcellentCasesRepository.java @@ -9,4 +9,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; * @date 2023/5/11 */ public interface ExcellentCasesRepository extends JpaRepository, JpaSpecificationExecutor { + + ExcellentCases findBySessionId(String sessionId); } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/OrganizeUserRepository.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/OrganizeUserRepository.java index 349a6674..e9a35c9e 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/OrganizeUserRepository.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/OrganizeUserRepository.java @@ -112,5 +112,14 @@ public interface OrganizeUserRepository extends JpaRepository findByCreateByOrUserId(Long createBy,Long userId); + List findByCreateByOrUserId(Long createBy, Long userId); + + /** + * 查询组长id + * + * @param userId + * @return + */ + @Query(value = "select ou.user_id from tb_organize_user as ou where ou.organize_id =(select u.organize_id from tb_organize_user as u where u.user_id =?1) and ou.is_leader =true", nativeQuery = true) + Long findUserIdAndIsLeader(Long userId); } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/ScriptOrganizeRepository.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/ScriptOrganizeRepository.java index 2de797b1..d07c67a3 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/ScriptOrganizeRepository.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/ScriptOrganizeRepository.java @@ -12,5 +12,5 @@ import java.util.List; */ public interface ScriptOrganizeRepository extends JpaRepository, JpaSpecificationExecutor { - List findByCreateBy(Long userId); + List findByCreateByAndStatus(Long userId, Boolean status); } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/ExcellentCasesController.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/ExcellentCasesController.java index feb9b131..5f567cc1 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/ExcellentCasesController.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/ExcellentCasesController.java @@ -30,8 +30,20 @@ public class ExcellentCasesController { return CommonResponse.createBySuccess(); } + @DeleteMapping("/delete/{id}") + @ApiOperation("删除") + public CommonResponse delete(@PathVariable("id") Long id) { + excellentCasesService.delete(id); + return CommonResponse.createBySuccess(); + } + @GetMapping("/queryAll") public ResponseEntity query(ExcellentCasesQueryCriteria excellentCasesQueryCriteria, Pageable pageable) { return new ResponseEntity<>(excellentCasesService.queryAll(excellentCasesQueryCriteria, pageable), HttpStatus.OK); } + + @GetMapping("/querySession") + public CommonResponse queryBySessionId(@RequestParam("sessionId") String sessionId) { + return CommonResponse.createBySuccess(excellentCasesService.queryBySessionId(sessionId)); + } } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/ExcellentCasesService.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/ExcellentCasesService.java index 2575bd80..73cf38e9 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/ExcellentCasesService.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/ExcellentCasesService.java @@ -13,4 +13,8 @@ public interface ExcellentCasesService { void addExcellentCases(ExcellentCases excellentCases); Object queryAll(ExcellentCasesQueryCriteria excellentCasesQueryCriteria, Pageable pageable); + + void delete(Long id); + + ExcellentCases queryBySessionId(String sessionId); } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/ExcellentCasesQueryCriteria.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/ExcellentCasesQueryCriteria.java index ac2963b0..68784be3 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/ExcellentCasesQueryCriteria.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/ExcellentCasesQueryCriteria.java @@ -16,6 +16,5 @@ public class ExcellentCasesQueryCriteria { private String operateName; @Query(type = Query.Type.EQUAL) - @NotNull(message = "组长id不能为空") private Long createBy; } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/CompanyServiceImpl.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/CompanyServiceImpl.java index 0ee6a0e2..0885e281 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/CompanyServiceImpl.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/CompanyServiceImpl.java @@ -176,6 +176,7 @@ public class CompanyServiceImpl implements CompanyService { @Override @Transactional(rollbackFor = Exception.class) + @CacheEvict(cacheNames = "companyCache", key = "#companyId") public int updateBalanceOptimistic(Double deduct, Long companyId, Integer version) { return companyRepository.updateBalanceOptimistic(deduct, companyId, version); } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/ExcellentCasesServiceImpl.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/ExcellentCasesServiceImpl.java index eec436c7..aab25297 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/ExcellentCasesServiceImpl.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/ExcellentCasesServiceImpl.java @@ -1,6 +1,7 @@ package com.baiye.modules.platform.service.impl; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.URLUtil; @@ -8,6 +9,7 @@ import com.baiye.config.properties.FileProperties; import com.baiye.exception.BadRequestException; import com.baiye.modules.platform.domain.ExcellentCases; import com.baiye.modules.platform.repository.ExcellentCasesRepository; +import com.baiye.modules.platform.repository.OrganizeUserRepository; import com.baiye.modules.platform.service.ExcellentCasesService; import com.baiye.modules.platform.service.dto.ExcellentCasesQueryCriteria; import com.baiye.util.PageUtil; @@ -35,13 +37,23 @@ public class ExcellentCasesServiceImpl implements ExcellentCasesService { private final ExcellentCasesRepository excellentCasesRepository; + private final OrganizeUserRepository organizeUserRepository; private final FileProperties fileProperties; @Override public void addExcellentCases(ExcellentCases excellentCases) { + String sessionId = excellentCases.getSessionId(); + ExcellentCases bySessionId = excellentCasesRepository.findBySessionId(sessionId); + if (ObjectUtil.isNotEmpty(bySessionId)) { + if (excellentCases.getRemark() != null) { + bySessionId.setRemark(excellentCases.getRemark()); + excellentCasesRepository.save(bySessionId); + return; + } + } excellentCases.setCreateBy(SecurityUtils.getCurrentUserId()); excellentCases.setCreateTime(DateUtil.date()); - + excellentCases.setCreateName(SecurityUtils.getCurrentUsername()); URL url1 = URLUtil.url(excellentCases.getUrl()); BufferedInputStream inputStream; String url; @@ -81,11 +93,20 @@ public class ExcellentCasesServiceImpl implements ExcellentCasesService { @Override public Object queryAll(ExcellentCasesQueryCriteria excellentCasesQueryCriteria, Pageable pageable) { - if (excellentCasesQueryCriteria.getCreateBy() == null) { - throw new BadRequestException("组长id不能为空"); - } + Long userIdAndIsLeader = organizeUserRepository.findUserIdAndIsLeader(SecurityUtils.getCurrentUserId()); + excellentCasesQueryCriteria.setCreateBy(userIdAndIsLeader); PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by(Sort.Direction.DESC, "createTime")); Page all = excellentCasesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, excellentCasesQueryCriteria, criteriaBuilder), pageRequest); return PageUtil.toPage(all); } + + @Override + public void delete(Long id) { + excellentCasesRepository.deleteById(id); + } + + @Override + public ExcellentCases queryBySessionId(String sessionId) { + return excellentCasesRepository.findBySessionId(sessionId); + } } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/ScriptOrganizeServiceImpl.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/ScriptOrganizeServiceImpl.java index 3f4b0078..e674e1cb 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/ScriptOrganizeServiceImpl.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/ScriptOrganizeServiceImpl.java @@ -95,6 +95,6 @@ public class ScriptOrganizeServiceImpl implements ScriptOrganizeService { @Override public List queryOrganize(Long userId) { - return scriptOrganizeRepository.findByCreateBy(userId); + return scriptOrganizeRepository.findByCreateByAndStatus(userId, true); } } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/ClueBoostController.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/ClueBoostController.java new file mode 100644 index 00000000..cd7f7bbc --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/ClueBoostController.java @@ -0,0 +1,39 @@ +package com.baiye.modules.telemarkting.api; + +import com.baiye.http.CommonResponse; +import com.baiye.modules.telemarkting.entity.dto.ClueBoostQueryCriteria; +import com.baiye.modules.telemarkting.service.ClueBoostService; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.Set; + +/** + * @author wjt + * @date 2023/5/16 + */ +@Slf4j +@RestController +@RequestMapping("/api/boost") +@RequiredArgsConstructor +public class ClueBoostController { + private final ClueBoostService clueBoostService; + + @GetMapping("/queryAll") + public ResponseEntity query(ClueBoostQueryCriteria clueBoostQueryCriteria, Pageable pageable) { + return new ResponseEntity<>(clueBoostService.queryAll(clueBoostQueryCriteria, pageable), HttpStatus.OK); + } + + @ApiOperation("赔付") + @PostMapping("/compensate") + public CommonResponse compensate(@RequestBody Set ids) { + clueBoostService.compensate(ids); + return CommonResponse.createBySuccess(); + } + +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/ExtensionNumberController.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/ExtensionNumberController.java index f300a5da..4367a114 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/ExtensionNumberController.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/ExtensionNumberController.java @@ -2,7 +2,6 @@ package com.baiye.modules.telemarkting.api; import com.baiye.annotation.Inner; import com.baiye.http.CommonResponse; -import com.baiye.modules.telemarkting.entity.ExtensionNumber; import com.baiye.modules.telemarkting.entity.dto.ExtensionNumberCriteria; import com.baiye.modules.telemarkting.service.ExtensionNumberService; import io.swagger.annotations.Api; @@ -15,7 +14,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import java.util.Map; /** * @author wujingtao diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/dao/ClueBoostRecordRepository.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/dao/ClueBoostRecordRepository.java new file mode 100644 index 00000000..d46624d9 --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/dao/ClueBoostRecordRepository.java @@ -0,0 +1,12 @@ +package com.baiye.modules.telemarkting.dao; + +import com.baiye.modules.telemarkting.entity.ClueBoostRecord; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** + * @author wjt + * @date 2023/5/17 + */ +public interface ClueBoostRecordRepository extends JpaRepository, JpaSpecificationExecutor { +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/dao/ClueBoostRepository.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/dao/ClueBoostRepository.java new file mode 100644 index 00000000..2d5ffbe1 --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/dao/ClueBoostRepository.java @@ -0,0 +1,20 @@ +package com.baiye.modules.telemarkting.dao; + +import com.baiye.modules.telemarkting.entity.ClueBoost; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; + +import java.util.Set; + +/** + * @author wjt + * @date 2023/5/17 + */ +public interface ClueBoostRepository extends JpaRepository, JpaSpecificationExecutor { + + @Modifying + @Query("UPDATE ClueBoost set status = ?1 where id in ?2") + Integer updateStatusByIds(Boolean status, Set ids); +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/ClueBoost.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/ClueBoost.java new file mode 100644 index 00000000..623db55a --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/ClueBoost.java @@ -0,0 +1,62 @@ +package com.baiye.modules.telemarkting.entity; + +import cn.hutool.core.date.DateUtil; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import javax.persistence.*; +import java.util.Date; + +/** + * @author wjt + * @date 2023/5/16 + */ +@Getter +@Setter +@Entity +@Table(name = "tb_clue_boost") +@EntityListeners(AuditingEntityListener.class) +public class ClueBoost { + + @Id + @ApiModelProperty(value = "主键id(自动递增)") + @Column(name = "id") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "clue_id") + @ApiModelProperty(value = "线索id") + private Long clueId; + + @Column(name = "member_id") + @ApiModelProperty(value = "所属人id") + private Long memberId; + + @Column(name = "clue_type") + @ApiModelProperty(value = " 类型 1-表单推送 2-个人上传 3-抖音 4-投流 5-拓客 6-拓客回流 7-投流回流") + private Integer clueType; + + @Column(name = "which_user_id") + @ApiModelProperty(value = "管理员id") + private Long whichUserId; + + @Column(name = "status") + @ApiModelProperty(value = "是否赔付") + private Boolean status; + + @Column(name = "create_time") + @ApiModelProperty(value = "创建时间") + private Date createTime; + + public ClueBoost addClueBoost(Long clueId, Long memberId, Integer clueType, Long whichUserId) { + this.setClueId(clueId); + this.setMemberId(memberId); + this.setClueType(clueType); + this.setCreateTime(DateUtil.date()); + this.setWhichUserId(whichUserId); + this.setStatus(false); + return this; + } +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/ClueBoostRecord.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/ClueBoostRecord.java new file mode 100644 index 00000000..2a113eaa --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/ClueBoostRecord.java @@ -0,0 +1,34 @@ +package com.baiye.modules.telemarkting.entity; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import javax.persistence.*; +import java.util.Date; + +/** + * @author wjt + * @date 2023/5/17 + */ +@Getter +@Setter +@Entity +@Table(name = "tb_clue_boost_record") +@EntityListeners(AuditingEntityListener.class) +public class ClueBoostRecord { + @Id + @ApiModelProperty(value = "主键id(自动递增)") + @Column(name = "id") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "which_user_id") + @ApiModelProperty(value = "线索id") + private Long whichUserId; + + @Column(name = "create_time") + @ApiModelProperty(value = "创建时间") + private Date createTime; +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/ClueBoostDTO.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/ClueBoostDTO.java new file mode 100644 index 00000000..b03d621b --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/ClueBoostDTO.java @@ -0,0 +1,48 @@ +package com.baiye.modules.telemarkting.entity.dto; + +import lombok.Data; + +import java.util.Date; + +/** + * @author wjt + * @date 2023/5/16 + */ +@Data +public class ClueBoostDTO { + /** + * 线索id + */ + private Long clueId; + /** + * 拨打次数 + */ + private Integer callNum; + + /** + * 第一次拨打时间 + */ + private Date firstTime; + + /** + * 上一次拨打时间 + */ + private Date lastTime; + + private Long memberId; + + private Integer clueType; + + /** + * true 接通 false未接通 + */ + private Boolean status; + + public ClueBoostDTO addClueBoostDTO(Long clueId, Long memberId, Integer clueType, Boolean status) { + this.setClueId(clueId); + this.setMemberId(memberId); + this.setClueType(clueType); + this.setStatus(status); + return this; + } +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/ClueBoostQueryCriteria.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/ClueBoostQueryCriteria.java new file mode 100644 index 00000000..cef66efa --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/ClueBoostQueryCriteria.java @@ -0,0 +1,26 @@ +package com.baiye.modules.telemarkting.entity.dto; + +import com.baiye.annotation.Query; +import lombok.Data; + +import java.sql.Timestamp; +import java.util.List; + +/** + * @author wjt + * @date 2023/5/17 + */ +@Data +public class ClueBoostQueryCriteria { + @Query + private Boolean status = false; + + @Query + private Long whichUserId; + + @Query + private Integer clueType; + + @Query(type = Query.Type.BETWEEN) + private List createTime; +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/ClueBoostService.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/ClueBoostService.java new file mode 100644 index 00000000..71025c27 --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/ClueBoostService.java @@ -0,0 +1,17 @@ +package com.baiye.modules.telemarkting.service; + +import com.baiye.modules.telemarkting.entity.dto.ClueBoostQueryCriteria; +import org.springframework.data.domain.Pageable; + +import java.util.Set; + +/** + * @author wjt + * @date 2023/5/16 + */ +public interface ClueBoostService { + + Object queryAll(ClueBoostQueryCriteria clueBoostQueryCriteria, Pageable pageable); + + void compensate(Set ids); +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/ExtensionNumberService.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/ExtensionNumberService.java index bdfd4851..067f72c9 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/ExtensionNumberService.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/ExtensionNumberService.java @@ -7,7 +7,6 @@ import com.baiye.modules.telemarkting.entity.ExtensionNumber; import com.baiye.modules.telemarkting.entity.dto.ExtensionNumberCriteria; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; /** diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/ClueBoostServiceImpl.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/ClueBoostServiceImpl.java new file mode 100644 index 00000000..996a2568 --- /dev/null +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/ClueBoostServiceImpl.java @@ -0,0 +1,131 @@ +package com.baiye.modules.telemarkting.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baiye.feign.SourceClueClient; +import com.baiye.model.dto.UserDto; +import com.baiye.modules.agent.repository.ChannelCustomRepository; +import com.baiye.modules.system.domain.User; +import com.baiye.modules.system.repository.UserRepository; +import com.baiye.modules.telemarkting.dao.ClueBoostRecordRepository; +import com.baiye.modules.telemarkting.dao.ClueBoostRepository; +import com.baiye.modules.telemarkting.entity.ClueBoost; +import com.baiye.modules.telemarkting.entity.ClueBoostRecord; +import com.baiye.modules.telemarkting.entity.dto.ClueBoostDTO; +import com.baiye.modules.telemarkting.entity.dto.ClueBoostQueryCriteria; +import com.baiye.modules.telemarkting.service.ClueBoostService; +import com.baiye.util.PageUtil; +import com.baiye.util.QueryHelp; +import com.baiye.util.RedisUtils; +import com.baiye.util.SecurityUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.event.EventListener; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +/** + * @author wjt + * @date 2023/5/16 + * 线索补量逻辑 + */ +@Service +@Slf4j +public class ClueBoostServiceImpl implements ClueBoostService { + + private static final String KEY = "boost:"; + + @Resource + private RedisUtils redisUtils; + @Resource + private ClueBoostRepository clueBoostRepository; + @Resource + private SourceClueClient sourceClueClient; + @Resource + private ChannelCustomRepository channelCustomRepository; + @Resource + private ClueBoostRecordRepository clueBoostRecordRepository; + @Resource + private UserRepository userRepository; + + @Override + public Object queryAll(ClueBoostQueryCriteria clueBoostQueryCriteria, Pageable pageable) { + clueBoostQueryCriteria.setWhichUserId(SecurityUtils.getCurrentUserId()); + PageRequest pageRequest = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by(Sort.Direction.DESC, "createTime")); + Page all = clueBoostRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, clueBoostQueryCriteria, criteriaBuilder), pageRequest); + return PageUtil.toPage(all); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void compensate(Set ids) { + Integer integer = clueBoostRepository.updateStatusByIds(true, ids); + Long currentUserId = SecurityUtils.getCurrentUserId(); + channelCustomRepository.updateSurplusNumByUserId(currentUserId, integer); + ClueBoostRecord clueBoostRecord = new ClueBoostRecord(); + clueBoostRecord.setWhichUserId(currentUserId); + clueBoostRecord.setCreateTime(DateUtil.date()); + clueBoostRecordRepository.save(clueBoostRecord); + } + + + @EventListener(ClueBoostDTO.class) + @Transactional(rollbackFor = Exception.class) + public void boost(ClueBoostDTO clueBoostDTO) { + Object o = redisUtils.get(KEY + clueBoostDTO.getClueId()); + if (ObjectUtil.isNotEmpty(o)) { + if (clueBoostDTO.getStatus()) { + redisUtils.del(KEY + clueBoostDTO.getClueId()); + return; + } + //redis数据 + ClueBoostDTO clueBoost = BeanUtil.toBean(o, ClueBoostDTO.class); + + //上一次拨打距离当前时间间隔1小时 + Date lastTime = clueBoost.getLastTime(); + long betweenLast = DateUtil.between(lastTime, DateUtil.date(), DateUnit.HOUR); + if (betweenLast < 1) { + return; + } + //第一次拨打后 24小时内需2通 + Date firstTime = clueBoost.getFirstTime(); + long betweenFirst = DateUtil.between(firstTime, DateUtil.date(), DateUnit.HOUR); + Integer callNum = clueBoost.getCallNum(); + if (betweenFirst <= 24) { + clueBoost.setCallNum(callNum + 1); + clueBoost.setLastTime(DateUtil.date()); + redisUtils.set(KEY + clueBoostDTO.getClueId(), clueBoost, 48 - betweenFirst, TimeUnit.HOURS); + return; + } else if (betweenFirst < 48) { + if (callNum >= 2) { + //满足补量 + User user = userRepository.findById(clueBoost.getMemberId()).orElseGet(User::new); + Long whichUserId = user.getWhichUserId(); + ClueBoost clueBoostNew = new ClueBoost().addClueBoost(clueBoost.getClueId(), clueBoost.getMemberId(), clueBoost.getClueType(), whichUserId); + // 修改线索为冻结 + sourceClueClient.updateTalkClueFreeze(clueBoost.getClueId(), true); + clueBoostRepository.save(clueBoostNew); + redisUtils.del(KEY + clueBoostDTO.getClueId()); + return; + } + } + } + if (!clueBoostDTO.getStatus()) { + clueBoostDTO.setLastTime(DateUtil.date()); + clueBoostDTO.setFirstTime(DateUtil.date()); + clueBoostDTO.setCallNum(1); + redisUtils.set(KEY + clueBoostDTO.getClueId(), clueBoostDTO, 24, TimeUnit.HOURS); + } + } + +} diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/TelephoneCallServiceImpl.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/TelephoneCallServiceImpl.java index fabb2052..f113528a 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/TelephoneCallServiceImpl.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/TelephoneCallServiceImpl.java @@ -6,6 +6,7 @@ import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; +import com.baiye.constant.ClueTypeConstants; import com.baiye.constant.DefaultNumberConstants; import com.baiye.exception.BadRequestException; import com.baiye.feign.SourceClueClient; @@ -25,11 +26,13 @@ import com.baiye.modules.telemarkting.httpRequest.DoubleCallReq; import com.baiye.modules.telemarkting.httpRequest.RollCallReq; import com.baiye.modules.telemarkting.service.TelephoneCallService; import lombok.extern.slf4j.Slf4j; +import org.springframework.context.ApplicationContext; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.Arrays; import java.util.Date; import java.util.Objects; import java.util.concurrent.CompletableFuture; @@ -64,6 +67,8 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { private CallDeductRepository callDeductRepository; @Resource private UserService userService; + @Resource + private ApplicationContext applicationContext; @Override public CommonResponse doubleCallReq(TelephoneCallReqDTO doubleCallReq, Long companyId) { @@ -121,7 +126,6 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { allCallInfoRepository.save(allCallInfo); //实时扣费 callCostCount(allCallInfo.getMemberId(), allCallInfo.getClueId(), allCallInfo.getClueType(), allCallInfo.getDuration(), DefaultNumberConstants.TWO_NUMBER); - //更新资源通话状态 CompletableFuture.runAsync(() -> updateSourceCallStatus(userDate, DefaultNumberConstants.TWO_NUMBER, allCallInfo.getClueType())); } else { @@ -269,6 +273,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { allCallInfoRepository.updateByRecord(DefaultNumberConstants.ONE_NUMBER, rollCallBackDTO.getRecord_file_url(), allCallInfo.getId()); } else { log.info("被叫回调-点呼:otherLeg:{},详情:{}", otherLeg, rollCallBackDTO); + boolean status; //拨打线索号的回调 if (StrUtil.isNotBlank(rollCallBackDTO.getCallee_answer_time())) { //表示接通,更新线索状态 @@ -278,9 +283,16 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { CompletableFuture.runAsync(() -> updateSourceCallStatus(allCallInfo.getClueId(), DefaultNumberConstants.TWO_NUMBER, allCallInfo.getClueType())); //实时扣除话费 callCostCount(allCallInfo.getMemberId(), allCallInfo.getClueId(), allCallInfo.getClueType(), Integer.valueOf(rollCallBackDTO.getDuration()), 2); + status = true; } else { //更新资源通话状态 CompletableFuture.runAsync(() -> updateSourceCallStatus(allCallInfo.getClueId(), DefaultNumberConstants.ONE_NUMBER, allCallInfo.getClueType())); + status = false; + } + if (Arrays.asList(ClueTypeConstants.TOKER_TYPE).contains(allCallInfo.getClueType())) { + ClueBoostDTO clueBoostDTO = new ClueBoostDTO().addClueBoostDTO(allCallInfo.getClueId(), allCallInfo.getMemberId(), allCallInfo.getClueType(), null); + clueBoostDTO.setStatus(status); + applicationContext.publishEvent(clueBoostDTO); } } } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/timed/DeliveryBalanceTask.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/timed/DeliveryBalanceTask.java index b771435c..52f26e66 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/timed/DeliveryBalanceTask.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/timed/DeliveryBalanceTask.java @@ -94,7 +94,7 @@ public class DeliveryBalanceTask { // 判断剩余数量 if (ObjectUtil.isNull(channelCustom.getSurplusNum()) || ObjectUtil.isNull(dmpLimitNum) || channelCustom.getSurplusNum() - (number != null ? number : DefaultNumberConstants.ZERO_NUMBER) >> - DefaultNumberConstants.ONE_NUMBER < DefaultNumberConstants.ZERO_NUMBER) { + DefaultNumberConstants.ONE_NUMBER < DefaultNumberConstants.TEN_NUMBER) { continue; } lock.lock(); @@ -109,6 +109,13 @@ public class DeliveryBalanceTask { list = CollUtil.sub(list, DefaultNumberConstants.ZERO_NUMBER, count >= dmpLimitNum ? DefaultNumberConstants.ZERO_NUMBER : dmpLimitNum); } + // 最大数量不能大于剩余数量 + if (list.size() >= channelCustom.getSurplusNum()) { + list = CollUtil.sub(list, DefaultNumberConstants.ZERO_NUMBER, + channelCustom.getSurplusNum()); + downList.addAll(CollUtil.sub + (list, channelCustom.getSurplusNum(), list.size())); + } if (CollUtil.isNotEmpty(list)) { // 每次100000 数据 List> lists = Lists.partition diff --git a/ad-platform-pojo/src/main/java/com/baiye/model/dto/ClueDto.java b/ad-platform-pojo/src/main/java/com/baiye/model/dto/ClueDto.java index 5df94b90..df51ffaf 100644 --- a/ad-platform-pojo/src/main/java/com/baiye/model/dto/ClueDto.java +++ b/ad-platform-pojo/src/main/java/com/baiye/model/dto/ClueDto.java @@ -127,4 +127,6 @@ public class ClueDto implements Serializable { private String castInfo; @ApiModelProperty(value = "线索是否加密 0:不加密 1:加密") private Integer isEncryption; + @ApiModelProperty(value = "线索是否冻结 0:未冻结 1:冻结") + private Boolean isFreeze; } diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/controller/ClueController.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/controller/ClueController.java index 4e95a74b..0bc3f160 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/controller/ClueController.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/controller/ClueController.java @@ -202,4 +202,11 @@ public class ClueController { public ResponseEntity updateClueOrganize(@RequestBody Map map) { return new ResponseEntity<>(clueService.updateClueOrganize(map), HttpStatus.OK); } + + @ApiOperation("修改拓客和投流线索的冻结状态") + @GetMapping("/updateTalkClueFreeze") + @Inner(value = false) + public void updateTalkClueFreeze(@RequestParam("clueId") Long clueId, @RequestParam("isFreeze") Boolean isFreeze) { + clueService.updateTalkClueFreeze(clueId, isFreeze); + } } diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/AllCallInfoRepository.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/AllCallInfoRepository.java index a2a476fb..1911a27d 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/AllCallInfoRepository.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/AllCallInfoRepository.java @@ -17,4 +17,7 @@ import java.util.Set; @Repository public interface AllCallInfoRepository extends JpaRepository, JpaSpecificationExecutor { void deleteAllByClueIdIn(Set clueIds); + + @Query(value = "select DISTINCT(clue_id) from tb_call_info where status =?1 and (create_time between ?2 and ?3) and clue_id in ?4", nativeQuery = true) + List findTurnOnClue(Integer status, String beginTime, String endTime, List clueIds); } diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/ClueJpa.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/ClueJpa.java index 4a171ab3..57988542 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/ClueJpa.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/ClueJpa.java @@ -73,7 +73,7 @@ public class ClueJpa { 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," + "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 " + + "cm.newest_call_time as newestCallTime ,cm.turnover_amount as turnoverAmount ,cm.clue_type as clueType ,cm.is_freeze as isFreeze " + "from tb_clue as c LEFT JOIN tb_clue_talk as cm on c.id = cm.clue_id where 1=1 "); List confirmReceipt = getConfirmReceipt(clueQueryCriteria, sql, pageable); return getTradeInfo(confirmReceipt, clueQueryCriteria.getClueType(), clueQueryCriteria.getIsAdmin()); @@ -132,7 +132,7 @@ public class ClueJpa { if (id != null) { sql.append("and c.id = :id "); } - if (nid != null) { + if (StrUtil.isNotBlank(nid)) { sql.append("and c.nid = :nid "); } if (StringUtils.isNotBlank(name)) { @@ -202,7 +202,7 @@ public class ClueJpa { if (id != null) { query.setParameter("id", id); } - if (nid != null) { + if (StrUtil.isNotBlank(nid)) { query.setParameter("nid", AESUtils.encrypt(nid, secret)); } if (StringUtils.isNotBlank(name)) { @@ -339,6 +339,7 @@ public class ClueJpa { clueDto.setTurnoverAmount((Double) row.get("turnoverAmount")); clueDto.setCastInfo((String) row.get("castInfo")); clueDto.setClueType((Integer) row.get("clueType")); + clueDto.setIsFreeze((Boolean) row.get("isFreeze")); clueDtoList.add(clueDto); } return clueDtoList; @@ -520,7 +521,7 @@ public class ClueJpa { */ @Transactional(rollbackOn = Exception.class) public List getReportCallInfo(String beginTime, String endTime, Long managerId) { - StringBuilder sql = new StringBuilder("select tcm.newest_call_time as newestCallTime,tcm.clue_call_status as clueCallStatus ,tcm.member_status as memberStatus,tc.create_by as managerId " + + StringBuilder sql = new StringBuilder("select tcm.newest_call_time as newestCallTime,tcm.clue_call_status as clueCallStatus ,tcm.member_status as memberStatus,tc.create_by as managerId,tcm.clue_id as clueId " + "from tb_clue_talk as tcm left join tb_clue as tc on tcm.clue_id =tc.id " + " where tcm.newest_call_time between :beginTime and :endTime "); if (managerId != null) { @@ -544,6 +545,8 @@ public class ClueJpa { clueDto.setClueCallStatus((Integer) row.get("clueCallStatus")); clueDto.setNewestCallTime((Date) row.get("newestCallTime")); clueDto.setMemberStatus((Integer) row.get("memberStatus")); + BigInteger clueId = (BigInteger) row.get("clueId"); + clueDto.setClueId(clueId.longValue()); clueDtoList.add(clueDto); } return clueDtoList; diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/ClueTalkRepository.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/ClueTalkRepository.java index 594694a3..16b95ef2 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/ClueTalkRepository.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/ClueTalkRepository.java @@ -106,4 +106,9 @@ public interface ClueTalkRepository extends JpaRepository, JpaSp @Query(value = " select count(*) from tb_clue_talk as tcm left join tb_clue as tc on tcm.clue_id =tc.id" + " where tc.create_by = ?1 and tcm.create_time between ?2 and ?3", nativeQuery = true) Integer countByCreateTime(Long userId, String startTime, String endTime); + + + @Modifying + @Query(value = " update tb_clue_talk set is_freeze = ?2 where clue_id = ?1 ", nativeQuery = true) + void updateTalkClueFreeze(Long clueId, Boolean isFreeze); } diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/entity/ClueTalk.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/entity/ClueTalk.java index 3849204e..11e44e2f 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/entity/ClueTalk.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/entity/ClueTalk.java @@ -26,6 +26,10 @@ public class ClueTalk extends BaseClueMiddle { @NotNull(message = "资源id不能为空") private Long clueId; + @ApiModelProperty(value = "是否冻结") + @Column(name = "is_freeze") + private Boolean isFreeze; + @Transient private String clueName; @Transient @@ -46,7 +50,8 @@ public class ClueTalk extends BaseClueMiddle { super(taskId, memberStatus, optimisticVersion, clueStage, clueCallStatus, clueType, clueStageTime, memberId); this.clueId = clueId; } - public ClueTalk(){ + + public ClueTalk() { } } diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/entity/ReportTokerCall.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/entity/ReportTokerCall.java index 29fb0548..bd8fef9b 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/entity/ReportTokerCall.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/entity/ReportTokerCall.java @@ -28,7 +28,7 @@ public class ReportTokerCall { @Column(name = "create_time") @ApiModelProperty(value = "创建时间") - @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT-8") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT-8") private Date createTime; @ApiModelProperty(value = "使用数") @@ -62,6 +62,7 @@ public class ReportTokerCall { this.setUsrNumRate(0.00); this.setTurnOnNum(0); this.setTurnOnRate(0.00); + this.setEffectiveNum(0); return this; } } diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/ClueService.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/ClueService.java index c75cefb7..87067815 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/ClueService.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/ClueService.java @@ -166,11 +166,12 @@ public interface ClueService { /** * 保存线索 - * @param tagList tag列表 + * + * @param tagList tag列表 * @param phoneList - * @param taskId 认为id - * @param userId 用户id - * @param num 数量 + * @param taskId 认为id + * @param userId 用户id + * @param num 数量 * @return 数量 */ Integer saveClue(List tagList, List phoneList, Long taskId, Long userId, Integer num); @@ -186,4 +187,11 @@ public interface ClueService { * @param map key:用户ID value:用户要修改的组 */ Boolean updateClueOrganize(Map map); + + /** + * 修改拓客和投流线索的冻结状态 + * @param clueId + * @param isFreeze + */ + void updateTalkClueFreeze(Long clueId, Boolean isFreeze); } diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/dto/ClueTalkDTO.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/dto/ClueTalkDTO.java index 389a7148..7cb8439d 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/dto/ClueTalkDTO.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/dto/ClueTalkDTO.java @@ -16,4 +16,6 @@ public class ClueTalkDTO { private Integer clueCallStatus; private Integer memberStatus; + + private Long clueId; } diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/impl/ClueServiceImpl.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/impl/ClueServiceImpl.java index 380e5725..c4518379 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/impl/ClueServiceImpl.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/service/impl/ClueServiceImpl.java @@ -223,7 +223,7 @@ public class ClueServiceImpl implements ClueService { Long count = this.findClueCount(clueQueryCriteria); //手机号搜索 - if (StringUtils.isNotBlank(nid)) { + if (!StrUtil.isBlank(nid)) { clueDtoList = clueDtoList.stream().filter(ct -> ct.getNid().contains(nid)).collect(Collectors.toList()); } @@ -494,15 +494,16 @@ public class ClueServiceImpl implements ClueService { ClueMiddle clueMiddle = clueMiddleRepository.findById(clueId).orElseGet(ClueMiddle::new); ClueTalk clueTalk = clueTalkRepository.findById(clueId).orElseGet(ClueTalk::new); if (clueTalk.getClueId() != null && clueTalk.getClueType() != 2) throw new BadRequestException("无法删除非个人上传资源"); - if (clueMiddle.getClueId() != null && clueMiddle.getClueType() != 2) throw new BadRequestException("无法删除非个人上传资源"); + if (clueMiddle.getClueId() != null && clueMiddle.getClueType() != 2) + throw new BadRequestException("无法删除非个人上传资源"); Set clueIds = Collections.singleton(clueId); ClueQueryCriteria clueQueryCriteria = new ClueQueryCriteria(); clueQueryCriteria.setId(clueId); List clueAll = clueJpa.getClueList(clueQueryCriteria, null); - this.delete(clueAll ,clueIds); + this.delete(clueAll, clueIds); - if (clueTalk.getClueId() != null ) clueTalkRepository.deleteById(clueId); + if (clueTalk.getClueId() != null) clueTalkRepository.deleteById(clueId); if (clueMiddle.getClueId() != null) clueMiddleRepository.deleteById(clueId); } @@ -951,6 +952,12 @@ public class ClueServiceImpl implements ClueService { return true; } + @Override + @Transactional(rollbackFor = Exception.class) + public void updateTalkClueFreeze(Long clueId, Boolean isFreeze) { + clueTalkRepository.updateTalkClueFreeze(clueId, isFreeze); + } + private HashMap getReportMap(List clueMiddles) { int newClue = 0; int communicat = 0; diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/MailSourceTask.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/MailSourceTask.java index 5e8fe1c3..ce5969bb 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/MailSourceTask.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/MailSourceTask.java @@ -7,13 +7,13 @@ import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.text.StrPool; -import cn.hutool.core.text.csv.CsvData; -import cn.hutool.core.text.csv.CsvReader; -import cn.hutool.core.text.csv.CsvUtil; +import cn.hutool.core.text.csv.*; +import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONUtil; import com.baiye.config.properties.DeliveryProperties; +import com.baiye.constant.AdPlatFormConstants; import com.baiye.constant.DefaultNumberConstants; import com.baiye.constant.SecurityConstants; import com.baiye.feign.DeliveryRecordClient; @@ -115,53 +115,49 @@ public class MailSourceTask { CompressUtil.unzipFiles(deliveryProperties.getFileUrl(), path, deliveryProperties.getZipPassword()); if (ObjectUtil.isNotNull(byTaskName.getType())) { - if (byTaskName.getType() == DefaultNumberConstants.ONE_NUMBER - || byTaskName.getType() == DefaultNumberConstants.THREE_NUMBER) { - File file = new File(unzipPath); - File parseFile = Objects.requireNonNull - (file.listFiles())[DefaultNumberConstants.ZERO_NUMBER]; - // 解析文件 - CsvData data = reader.read(parseFile); - // csv通配 - data.getRows().forEach(clue -> { - phoneList.add(clue.size() == DefaultNumberConstants.THREE_NUMBER - ? clue.get(DefaultNumberConstants.TWO_NUMBER) : clue.get(DefaultNumberConstants.THREE_NUMBER)); - tagList.add(clue.size() == DefaultNumberConstants.THREE_NUMBER - ? clue.get(DefaultNumberConstants.ZERO_NUMBER) : clue.get(DefaultNumberConstants.ONE_NUMBER)); - }); - // 去除重复 - List phoneSets = Lists.newArrayList(Sets.newHashSet(phoneList)); - log.info("=============== the phone list as {} ==================", phoneList.size()); - // 集合分割 - List> partitions = ListUtil.partition(phoneSets, DefaultNumberConstants.TWO_HUNDRED); - for (List partition : partitions) { - String join = Joiner.on(StrPool.COMMA).skipNulls().join(partition); - // 批量解析号码 - SecretResponseBean responseBean = DecryptPnoUtil.batchDecryptPno - (Base64.encode(StringUtils.substringBeforeLast(join, StrPool.COMMA))); - if (ObjectUtil.isNotNull(responseBean) && ObjectUtil.isNotNull(responseBean.getTels())) { - String decodeStr = Base64.decodeStr(responseBean.getTels()); - String[] split = decodeStr.split(StrPool.COMMA); - if (split.length > DefaultNumberConstants.ZERO_NUMBER) { - decryptList.addAll(Lists.newArrayList(Arrays.asList(split))); - } - } - } - // 剔除空值 - decryptList = decryptList.stream().filter(StringUtils::isNotBlank).collect(Collectors.toList()); - // 请求黑名单 - if (CollUtil.isNotEmpty(decryptList)) { - log.info("=================== the decryptList size as {} =====================", decryptList.size()); - if (byTaskName.getType() == DefaultNumberConstants.ONE_NUMBER) { - saveClue(taskName, byTaskName, task, taskId, tagList, decryptList, path, unzipPath); - } - if (byTaskName.getType() == DefaultNumberConstants.THREE_NUMBER) { - sendRequest(taskName, tagList, decryptList, path, unzipPath); + File file = new File(unzipPath); + File parseFile = Objects.requireNonNull + (file.listFiles())[DefaultNumberConstants.ZERO_NUMBER]; + // 解析文件 + CsvData data = reader.read(parseFile); + // csv通配 + data.getRows().forEach(clue -> { + phoneList.add(clue.size() == DefaultNumberConstants.THREE_NUMBER + ? clue.get(DefaultNumberConstants.TWO_NUMBER) : clue.get(DefaultNumberConstants.THREE_NUMBER)); + tagList.add(clue.size() == DefaultNumberConstants.THREE_NUMBER + ? clue.get(DefaultNumberConstants.ZERO_NUMBER) : clue.get(DefaultNumberConstants.ONE_NUMBER)); + }); + // 去除重复 + List phoneSets = Lists.newArrayList(Sets.newHashSet(phoneList)); + log.info("=============== the phone list as {} ==================", phoneList.size()); + // 集合分割 + List> partitions = ListUtil.partition(phoneSets, DefaultNumberConstants.TWO_HUNDRED); + for (List partition : partitions) { + String join = Joiner.on(StrPool.COMMA).skipNulls().join(partition); + // 批量解析号码 + SecretResponseBean responseBean = DecryptPnoUtil.batchDecryptPno + (Base64.encode(StringUtils.substringBeforeLast(join, StrPool.COMMA))); + if (ObjectUtil.isNotNull(responseBean) && ObjectUtil.isNotNull(responseBean.getTels())) { + String decodeStr = Base64.decodeStr(responseBean.getTels()); + String[] split = decodeStr.split(StrPool.COMMA); + if (split.length > DefaultNumberConstants.ZERO_NUMBER) { + decryptList.addAll(Lists.newArrayList(Arrays.asList(split))); } } } - if (byTaskName.getType() == DefaultNumberConstants.TWO_NUMBER) { - downResource(taskName, byTaskName, decryptList, path); + // 剔除空值 + decryptList = decryptList.stream().filter(StringUtils::isNotBlank).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(decryptList)) { + log.info("=================== the decryptList size as {} =====================", decryptList.size()); + if (byTaskName.getType() == DefaultNumberConstants.ONE_NUMBER) { + saveClue(taskName, byTaskName, task, taskId, tagList, decryptList, path, unzipPath); + } + if (byTaskName.getType() == DefaultNumberConstants.THREE_NUMBER) { + sendRequest(taskName, tagList, decryptList, path, unzipPath); + } + if (byTaskName.getType() == DefaultNumberConstants.TWO_NUMBER) { + downResource(taskName, byTaskName, decryptList, path, data.getRows(), parseFile); + } } } } @@ -170,8 +166,19 @@ public class MailSourceTask { } } - private void downResource(String taskName, DeliveryRecord byTaskName, List decryptList, String path) { + + private void downResource(String taskName, DeliveryRecord byTaskName, List decryptList, String path, List rows, File parseFile) { log.info("========================= the path as {} =========================", path); + CsvWriter writer = CsvUtil.getWriter(parseFile, CharsetUtil.CHARSET_UTF_8); + for (int i = 0; i < decryptList.size(); i++) { + List rawList = rows.get(i).getRawList(); + rawList.add(EncryptUtil.aesEncrypt(decryptList.get(i), AdPlatFormConstants.PLAT_DECRYPTION)); + String[] addStr = rawList.toArray(new String[rawList.size() + 1]); + writer.writeLine(addStr); + } + writer.close(); + // 设置压缩文件 + CompressUtil.decryptionCompression(path, parseFile.getPath(), null); String filePath = path.substring(path.lastIndexOf(StrPool.SLASH) + DefaultNumberConstants.ONE_NUMBER); deliveryRecordService.updateStatusByTaskName(DefaultNumberConstants.ONE_NUMBER, decryptList.size(), taskName); deliveryRecordClient.updatePath(deliveryProperties.getDmpDownPath().concat(filePath), byTaskName.getId(), SecurityConstants.FROM_IN); @@ -253,3 +260,4 @@ public class MailSourceTask { } } + diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/ReportSync.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/ReportSync.java index e7fe1870..a1b88b4d 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/ReportSync.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/ReportSync.java @@ -6,10 +6,7 @@ import cn.hutool.core.util.NumberUtil; import com.baiye.constant.DefaultNumberConstants; import com.baiye.constant.SourceLabelConstants; import com.baiye.feign.UserClient; -import com.baiye.module.dao.ClueJpa; -import com.baiye.module.dao.ClueTalkRepository; -import com.baiye.module.dao.ReportTokerCallRepository; -import com.baiye.module.dao.ReportTokerRepository; +import com.baiye.module.dao.*; import com.baiye.module.entity.ClueTalk; import com.baiye.module.entity.ReportToker; import com.baiye.module.entity.ReportTokerCall; @@ -36,6 +33,8 @@ public class ReportSync { private final ClueJpa clueJpa; private final ReportTokerCallRepository repository; + private final AllCallInfoRepository allCallInfoRepository; + /** * 每天晚上23点,定时统计外呼信息 */ @@ -122,17 +121,27 @@ public class ReportSync { } ReportTokerCall talkReport = new ReportTokerCall().init(); List clueTalks = talkByManagerId.get(key); + //记录使用过的线索 + List usrClueIds = new ArrayList<>(); for (ClueTalkDTO clueTalk : clueTalks) { - if (clueTalk.getClueCallStatus() == DefaultNumberConstants.ONE_NUMBER) { - talkReport.setUsrNum(talkReport.getUsrNum() + 1); - } else if (clueTalk.getClueCallStatus() == DefaultNumberConstants.TWO_NUMBER) { - talkReport.setTurnOnNum(talkReport.getTurnOnNum() + 1); + if (clueTalk.getClueCallStatus() == DefaultNumberConstants.ONE_NUMBER || clueTalk.getClueCallStatus() == DefaultNumberConstants.TWO_NUMBER) { talkReport.setUsrNum(talkReport.getUsrNum() + 1); + usrClueIds.add(clueTalk.getClueId()); } +// else if () { +// talkReport.setTurnOnNum(talkReport.getTurnOnNum() + 1); +// talkReport.setUsrNum(talkReport.getUsrNum() + 1); +// } if (clueTalk.getMemberStatus() == DefaultNumberConstants.FOUR_NUMBER) { talkReport.setEffectiveNum(talkReport.getEffectiveNum() + 1); } } + if (CollUtil.isNotEmpty(usrClueIds)) { + List turnOnClue = allCallInfoRepository.findTurnOnClue(2, beginOfDay, endOfDay, usrClueIds); + if (CollUtil.isNotEmpty(turnOnClue)) { + talkReport.setTurnOnNum(turnOnClue.size()); + } + } rate(talkReport, totalNum); talkReport.setManagerId(key); list.add(talkReport);