diff --git a/ad-platform-common/ad-platform-common-log/src/main/java/com/baiye/common/CommonLog.java b/ad-platform-common/ad-platform-common-log/src/main/java/com/baiye/common/CommonLog.java index 2c8277f3..f52ba6a1 100644 --- a/ad-platform-common/ad-platform-common-log/src/main/java/com/baiye/common/CommonLog.java +++ b/ad-platform-common/ad-platform-common-log/src/main/java/com/baiye/common/CommonLog.java @@ -77,7 +77,8 @@ public class CommonLog { /** * 指定业务方 ,更新当前traceId */ - public static void infoBusinessPartyTypeNewTraceId(String message, String logBusinessPartyType) { + public static void infoBusinessPartyTypeNewTraceId(String message, String logBusinessPartyType, String traceId) { + updateTraceId(traceId); MDC.put("businessPartyType", logBusinessPartyType); printType(message, null, LogType.INFO); } @@ -152,9 +153,9 @@ public class CommonLog { MDC.put("userName", getUsername()); - if (StringUtils.isBlank(MDC.get(TRACE_ID))){ + if (StringUtils.isBlank(MDC.get(TRACE_ID))) { long id = IdUtil.getSnowflake(9, 9).nextId(); - MDC.put(TRACE_ID,id + "-0"); + MDC.put(TRACE_ID, id + "-0"); } } 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 e3fa23e5..e84ba9b2 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 @@ -1,6 +1,7 @@ package com.baiye.modules.agent.controller; import com.baiye.annotation.Inner; +import com.baiye.annotation.Log; import com.baiye.http.CommonResponse; import com.baiye.modules.agent.entity.ChannelCustom; import com.baiye.modules.agent.entity.query.ChannelQuery; @@ -45,20 +46,21 @@ public class ChannelManageController { @ApiOperation("激活开通") @PostMapping("/active") + @Log("管理员开通子账号") public CommonResponse active(@RequestBody Set ids) { - log.info("激活账号 操作人={}", SecurityUtils.getCurrentUserId()); return channelManageService.active(ids); } @ApiOperation("禁用") @PostMapping("/forbidden") + @Log("管理员禁用子账号") public CommonResponse forbidden(@RequestBody Set ids) { - log.info("禁用账号 操作人={}", SecurityUtils.getCurrentUserId()); return channelManageService.forbidden(ids); } @ApiOperation("配置开通账号") @PostMapping("/update") + @Log("管理员修改渠道商") 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/service/impl/ChannelManageServiceImpl.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/agent/service/impl/ChannelManageServiceImpl.java index 2d4b9bfd..cd42eb91 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 @@ -3,6 +3,7 @@ package com.baiye.modules.agent.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; +import com.baiye.common.CommonLog; import com.baiye.constant.DefaultNumberConstants; import com.baiye.feign.IRemoteAuthService; import com.baiye.http.CommonResponse; @@ -138,6 +139,7 @@ public class ChannelManageServiceImpl implements ChannelManageService { @Override @Transactional(rollbackFor = Exception.class) public CommonResponse forbidden(Set ids) { + CommonLog.getTraceId(); List list = new ArrayList<>(); List channelCustoms = channelCustomRepository.findAllById(ids); for (ChannelCustom channelCustom : channelCustoms) { 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 fa4e17d0..46b5c09e 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 @@ -28,6 +28,18 @@ public class ExcellentCases implements Serializable { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + @Column(name = "cases_name") + @ApiModelProperty(value = "案例名") + private String casesName; + + @Column(name = "type") + @ApiModelProperty(value = "类型 1-公司 2-小组") + private Integer type; + + @Column(name = "watch_user_id") + @ApiModelProperty(value = "业务管理员id") + private Long watchUserId; + @Column(name = "url") @NotNull(groups = AddGroup.class) @ApiModelProperty(value = "url") diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/domain/ScriptOrganize.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/domain/ScriptOrganize.java index 6a002322..5163fd99 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/domain/ScriptOrganize.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/domain/ScriptOrganize.java @@ -51,4 +51,8 @@ public class ScriptOrganize implements Serializable { @ApiModelProperty(value = "话术模板") @Transient private List scriptTemplateList; + + @ApiModelProperty(value = "置顶话术") + @Transient + private ScriptTemplate top; } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/domain/ScriptTemplate.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/domain/ScriptTemplate.java index 10b235b6..3578a25f 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/domain/ScriptTemplate.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/domain/ScriptTemplate.java @@ -2,12 +2,14 @@ package com.baiye.modules.platform.domain; import cn.hutool.core.date.DateUtil; import com.baiye.util.SecurityUtils; +import com.baiye.valid.AddGroup; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; import org.springframework.data.jpa.domain.support.AuditingEntityListener; import javax.persistence.*; +import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.Date; @@ -34,6 +36,7 @@ public class ScriptTemplate implements Serializable { @Column(name = "answer") @ApiModelProperty(value = "回答") + @NotNull(message = "问答不能为空", groups = {AddGroup.class}) private String answer; @Column(name = "create_by") @@ -44,16 +47,21 @@ public class ScriptTemplate implements Serializable { @ApiModelProperty(value = "话术组id") private Long scriptOrganizeId; + @Column(name = "is_top") + @ApiModelProperty(value = "是否置顶") + private Boolean isTop = false; + @Column(name = "create_time") @ApiModelProperty(value = "创建时间") private Date createTime; - public ScriptTemplate addScriptTemplate(String question, String answer, Long scriptOrganizeId) { + public ScriptTemplate addScriptTemplate(String question, String answer) { this.setQuestion(question); this.setAnswer(answer); this.setCreateBy(SecurityUtils.getCurrentUserId()); this.setCreateTime(DateUtil.date()); - this.setScriptOrganizeId(scriptOrganizeId); + this.setScriptOrganizeId(null); + this.setIsTop(false); return this; } } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/ScriptTemplateRepository.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/ScriptTemplateRepository.java index 0da5c14d..cc22768a 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/ScriptTemplateRepository.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/repository/ScriptTemplateRepository.java @@ -20,4 +20,6 @@ public interface ScriptTemplateRepository extends JpaRepository findByScriptOrganizeIdAndAndCreateBy(Long scriptOrganizeId, Long createBy); List findByScriptOrganizeIdIn(Set scriptOrganizeIds); + + ScriptTemplate findByCreateByAndIsTop(Long createBy, Boolean isTop); } 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 5f567cc1..600179bc 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 @@ -1,5 +1,6 @@ package com.baiye.modules.platform.rest; +import com.baiye.annotation.Log; import com.baiye.http.CommonResponse; import com.baiye.modules.platform.domain.ExcellentCases; import com.baiye.modules.platform.service.ExcellentCasesService; @@ -25,6 +26,7 @@ public class ExcellentCasesController { @PostMapping("/addCases") @ApiOperation("新增案例") + @Log("新增优秀案例") public CommonResponse addExcellentCases(@RequestBody @Validated ExcellentCases excellentCases) { excellentCasesService.addExcellentCases(excellentCases); return CommonResponse.createBySuccess(); @@ -32,13 +34,14 @@ public class ExcellentCasesController { @DeleteMapping("/delete/{id}") @ApiOperation("删除") + @Log("删除优秀案例") public CommonResponse delete(@PathVariable("id") Long id) { excellentCasesService.delete(id); return CommonResponse.createBySuccess(); } @GetMapping("/queryAll") - public ResponseEntity query(ExcellentCasesQueryCriteria excellentCasesQueryCriteria, Pageable pageable) { + public ResponseEntity query(@Validated ExcellentCasesQueryCriteria excellentCasesQueryCriteria, Pageable pageable) { return new ResponseEntity<>(excellentCasesService.queryAll(excellentCasesQueryCriteria, pageable), HttpStatus.OK); } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/ScriptOrganizeController.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/ScriptOrganizeController.java index 0b1efd6c..8d368009 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/ScriptOrganizeController.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/ScriptOrganizeController.java @@ -1,5 +1,6 @@ package com.baiye.modules.platform.rest; +import com.baiye.annotation.Log; import com.baiye.http.CommonResponse; import com.baiye.modules.platform.domain.ScriptOrganize; import com.baiye.modules.platform.service.ScriptOrganizeService; @@ -26,6 +27,7 @@ public class ScriptOrganizeController { @ApiOperation("新增话术组和话术") @PostMapping("/add") + @Log("新增话术") public CommonResponse save(@Validated({AddGroup.class}) @RequestBody ScriptOrganize scriptOrganize) { scriptOrganizeService.save(scriptOrganize); return CommonResponse.createBySuccess(); @@ -33,6 +35,7 @@ public class ScriptOrganizeController { @ApiOperation("修改话术组") @PostMapping("/update") + @Log("修改话术") public CommonResponse update(@Validated({UpdateGroup.class}) @RequestBody ScriptOrganize scriptOrganize) { scriptOrganizeService.update(scriptOrganize); return CommonResponse.createBySuccess(); @@ -40,6 +43,7 @@ public class ScriptOrganizeController { @ApiOperation("删除话术组") @DeleteMapping("/delete/{id}") + @Log("删除话术组") public CommonResponse delete(@PathVariable("id") Long id) { scriptOrganizeService.delete(id); return CommonResponse.createBySuccess(); diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/ScriptTemplateController.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/ScriptTemplateController.java index 1319a676..bf123d4a 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/ScriptTemplateController.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/rest/ScriptTemplateController.java @@ -1,16 +1,15 @@ package com.baiye.modules.platform.rest; +import com.baiye.annotation.Log; import com.baiye.http.CommonResponse; import com.baiye.modules.platform.domain.ScriptTemplate; import com.baiye.modules.platform.service.ScriptTemplateService; -import com.baiye.modules.platform.service.dto.ScriptTemplateDTO; import com.baiye.valid.AddGroup; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import java.util.List; /** * @author wjt @@ -25,11 +24,13 @@ public class ScriptTemplateController { @PostMapping("/add") @ApiOperation("新建话术模板") - public CommonResponse add(@Validated({AddGroup.class}) @RequestBody List scriptTemplateDTOList) { - return scriptTemplateService.addScriptTemplate(scriptTemplateDTOList); + @Log("新增置顶话术") + public CommonResponse add(@Validated({AddGroup.class}) @RequestBody ScriptTemplate scriptTemplate) { + return scriptTemplateService.addScriptTemplate(scriptTemplate); } @DeleteMapping("/del/{id}") + @Log("删除话术") public CommonResponse del(@PathVariable("id") Long id) { scriptTemplateService.del(id); return CommonResponse.createBySuccess(); @@ -37,6 +38,7 @@ public class ScriptTemplateController { @PostMapping("/update") @ApiOperation("修改话术模板") + @Log("修改话术") public CommonResponse update(@RequestBody ScriptTemplate scriptTemplate) { scriptTemplateService.update(scriptTemplate); return CommonResponse.createBySuccess(); diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/ScriptOrganizeService.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/ScriptOrganizeService.java index b476d9f8..9a96c890 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/ScriptOrganizeService.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/ScriptOrganizeService.java @@ -4,7 +4,7 @@ import com.baiye.modules.platform.domain.ScriptOrganize; import com.baiye.modules.platform.service.dto.ScriptOrganizeQueryCriteria; import org.springframework.data.domain.Pageable; -import java.util.List; +import java.util.Map; /** * @author wjt @@ -23,5 +23,5 @@ public interface ScriptOrganizeService { Object queryAll(ScriptOrganizeQueryCriteria scriptOrganizeQueryCriteria, Pageable pageable); - List queryOrganize(Long userId); + Map queryOrganize(Long userId); } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/ScriptTemplateService.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/ScriptTemplateService.java index 5e740adb..31b4d47d 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/ScriptTemplateService.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/ScriptTemplateService.java @@ -2,7 +2,6 @@ package com.baiye.modules.platform.service; import com.baiye.http.CommonResponse; import com.baiye.modules.platform.domain.ScriptTemplate; -import com.baiye.modules.platform.service.dto.ScriptTemplateDTO; import java.util.List; @@ -15,10 +14,10 @@ public interface ScriptTemplateService { /** * 添加话术模板 * - * @param scriptTemplateDTOList 话术 + * @param scriptTemplate 话术 * @return 成功 */ - CommonResponse addScriptTemplate(List scriptTemplateDTOList); + CommonResponse addScriptTemplate(ScriptTemplate scriptTemplate); /** * 删除话术 @@ -34,5 +33,6 @@ public interface ScriptTemplateService { */ void update(ScriptTemplate scriptTemplate); - List queryScript(Long scriptOrganizeId,Long userId); + List queryScript(Long scriptOrganizeId, Long userId); + } 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 68784be3..417e89d5 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 @@ -4,6 +4,7 @@ import com.baiye.annotation.Query; import lombok.Data; import javax.validation.constraints.NotNull; +import java.util.List; /** * @author wjt @@ -17,4 +18,17 @@ public class ExcellentCasesQueryCriteria { @Query(type = Query.Type.EQUAL) private Long createBy; + + @Query(type = Query.Type.EQUAL) + @NotNull(message = "类型不能为空") + private Integer type; + + @Query(type = Query.Type.EQUAL) + @NotNull(message = "管理员id不能为空") + private Long watchUserId; + + private Boolean isManager = false; + + @Query(propName = "createBy", type = Query.Type.IN) + private List createByList; } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/ScriptTemplateDTO.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/ScriptTemplateDTO.java index a04cf774..6b7836f6 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/ScriptTemplateDTO.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/dto/ScriptTemplateDTO.java @@ -30,4 +30,6 @@ public class ScriptTemplateDTO { @NotNull(message = "回答话术不能为空", groups = {AddGroup.class}) private String answer; + @ApiModelProperty(value = "是否置顶") + private Boolean isTop; } 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 aab25297..aa4b502d 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 @@ -5,8 +5,11 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.URLUtil; +import com.baiye.common.CommonLog; import com.baiye.config.properties.FileProperties; +import com.baiye.constant.DefaultNumberConstants; import com.baiye.exception.BadRequestException; +import com.baiye.model.dto.UserDto; import com.baiye.modules.platform.domain.ExcellentCases; import com.baiye.modules.platform.repository.ExcellentCasesRepository; import com.baiye.modules.platform.repository.OrganizeUserRepository; @@ -25,6 +28,8 @@ import org.springframework.stereotype.Service; import java.io.*; import java.net.URL; +import java.util.ArrayList; +import java.util.List; /** * @author wjt @@ -38,6 +43,7 @@ public class ExcellentCasesServiceImpl implements ExcellentCasesService { private final ExcellentCasesRepository excellentCasesRepository; private final OrganizeUserRepository organizeUserRepository; + private final FileProperties fileProperties; @Override @@ -51,33 +57,76 @@ public class ExcellentCasesServiceImpl implements ExcellentCasesService { return; } } + UserDto user = SecurityUtils.getCurrentUser().getUser(); + Long whichUserId = user.getWhichUserId(); + excellentCases.setWatchUserId(whichUserId); excellentCases.setCreateBy(SecurityUtils.getCurrentUserId()); excellentCases.setCreateTime(DateUtil.date()); excellentCases.setCreateName(SecurityUtils.getCurrentUsername()); + excellentCases.setType(2); URL url1 = URLUtil.url(excellentCases.getUrl()); BufferedInputStream inputStream; String url; try { inputStream = new BufferedInputStream(url1.openStream()); String substring = DateUtil.format(DateUtil.date(), "MMdd") + RandomUtil.randomString(6) + ".wav"; - File file = inputStreamToFile(inputStream, substring); + inputStreamToFile(inputStream, substring); url = "cases" + File.separator + substring; } catch (Exception e) { - e.printStackTrace(); - throw new BadRequestException("保存错误,获取录音错误"); + CommonLog.error("保存案例失败,获取录音错误"); + throw new BadRequestException("保存失败,获取录音错误"); } if (StrUtil.isBlank(url)) { - throw new BadRequestException("保存错误,未获取到录音"); + CommonLog.error("保存案例失败,未获取到录音"); + throw new BadRequestException("保存失败,未获取到录音"); } excellentCases.setUrl(url); excellentCasesRepository.save(excellentCases); } - public File inputStreamToFile(InputStream ins, String name) throws Exception { + @Override + public Object queryAll(ExcellentCasesQueryCriteria excellentCasesQueryCriteria, Pageable pageable) { + + if (excellentCasesQueryCriteria.getIsManager()) { + excellentCasesQueryCriteria.setWatchUserId(SecurityUtils.getCurrentUserId()); + 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); + } else { + if (excellentCasesQueryCriteria.getType() == DefaultNumberConstants.TWO_NUMBER) { + Long userIdAndIsLeader = organizeUserRepository.findUserIdAndIsLeader(SecurityUtils.getCurrentUserId()); + excellentCasesQueryCriteria.setCreateBy(userIdAndIsLeader); + } else if (excellentCasesQueryCriteria.getType() == DefaultNumberConstants.ONE_NUMBER) { + excellentCasesQueryCriteria.setCreateBy(excellentCasesQueryCriteria.getWatchUserId()); + } else { + Long userIdAndIsLeader = organizeUserRepository.findUserIdAndIsLeader(SecurityUtils.getCurrentUserId()); + List list = new ArrayList<>(); + list.add(userIdAndIsLeader); + list.add(excellentCasesQueryCriteria.getWatchUserId()); + excellentCasesQueryCriteria.setCreateByList(list); + excellentCasesQueryCriteria.setType(null); + } + 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); + } + + private void inputStreamToFile(InputStream ins, String name) throws Exception { String path = fileProperties.getPath().getPath(); File file = new File(path + File.separator + "cases" + File.separator + name); if (file.exists()) { - return file; + return; } OutputStream os = new FileOutputStream(file); int bytesRead; @@ -88,25 +137,5 @@ public class ExcellentCasesServiceImpl implements ExcellentCasesService { } os.close(); ins.close(); - return file; - } - - @Override - public Object queryAll(ExcellentCasesQueryCriteria excellentCasesQueryCriteria, Pageable pageable) { - 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 e674e1cb..ee3a6aad 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 @@ -2,13 +2,14 @@ package com.baiye.modules.platform.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.baiye.exception.BadRequestException; import com.baiye.modules.platform.domain.ScriptOrganize; import com.baiye.modules.platform.domain.ScriptTemplate; import com.baiye.modules.platform.repository.ScriptOrganizeRepository; import com.baiye.modules.platform.repository.ScriptTemplateRepository; import com.baiye.modules.platform.service.ScriptOrganizeService; import com.baiye.modules.platform.service.dto.ScriptOrganizeQueryCriteria; -import com.baiye.util.PageUtil; import com.baiye.util.QueryHelp; import com.baiye.util.SecurityUtils; import lombok.RequiredArgsConstructor; @@ -19,9 +20,7 @@ import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; /** @@ -40,6 +39,9 @@ public class ScriptOrganizeServiceImpl implements ScriptOrganizeService { public void save(ScriptOrganize scriptOrganize) { Long currentUserId = SecurityUtils.getCurrentUserId(); if (scriptOrganize.getId() == null) { + if (StrUtil.isBlank(scriptOrganize.getScriptOrganizeName())) { + throw new BadRequestException("话术组名不能为空"); + } scriptOrganize.setCreateBy(currentUserId); scriptOrganize.setCreateTime(DateUtil.date()); scriptOrganize.setStatus(true); @@ -90,11 +92,23 @@ public class ScriptOrganizeServiceImpl implements ScriptOrganizeService { scriptOrganize.setScriptTemplateList(collect.get(id)); } } - return PageUtil.toPage(all); + ScriptTemplate byCreateByAndIsTop = scriptTemplateRepository.findByCreateByAndIsTop(SecurityUtils.getCurrentUserId(), true); + Map map = new HashMap<>(2); + Map map1 = new HashMap<>(); + map1.put("content", all.getContent()); + map1.put("top", byCreateByAndIsTop); + map.put("content", map1); + map.put("totalElements", all.getTotalElements()); + return map; } @Override - public List queryOrganize(Long userId) { - return scriptOrganizeRepository.findByCreateByAndStatus(userId, true); + public Map queryOrganize(Long userId) { + List byCreateByAndStatus = scriptOrganizeRepository.findByCreateByAndStatus(userId, true); + ScriptTemplate byCreateByAndIsTop = scriptTemplateRepository.findByCreateByAndIsTop(userId, true); + Map map = new HashMap<>(2); + map.put("organize", byCreateByAndStatus); + map.put("top", byCreateByAndIsTop); + return map; } } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/ScriptTemplateImpl.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/ScriptTemplateImpl.java index 48af0f2b..8c4df05c 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/ScriptTemplateImpl.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/platform/service/impl/ScriptTemplateImpl.java @@ -1,16 +1,16 @@ package com.baiye.modules.platform.service.impl; - +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; import com.baiye.http.CommonResponse; import com.baiye.modules.platform.domain.ScriptTemplate; import com.baiye.modules.platform.repository.ScriptTemplateRepository; import com.baiye.modules.platform.service.ScriptTemplateService; -import com.baiye.modules.platform.service.dto.ScriptTemplateDTO; +import com.baiye.util.SecurityUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import java.util.ArrayList; import java.util.List; @@ -25,13 +25,22 @@ public class ScriptTemplateImpl implements ScriptTemplateService { private final ScriptTemplateRepository scriptTemplateRepository; @Override - public CommonResponse addScriptTemplate(List scriptTemplateDTOList) { - List list = new ArrayList<>(); - for (ScriptTemplateDTO scriptTemplateDTO : scriptTemplateDTOList) { - ScriptTemplate scriptTemplate = new ScriptTemplate().addScriptTemplate(scriptTemplateDTO.getQuestion(), scriptTemplateDTO.getAnswer(), scriptTemplateDTO.getScriptOrganizeId()); - list.add(scriptTemplate); + public CommonResponse addScriptTemplate(ScriptTemplate scriptTemplate) { + ScriptTemplate scriptTemplate1 = new ScriptTemplate().addScriptTemplate(scriptTemplate.getQuestion(), scriptTemplate.getAnswer()); + if (scriptTemplate.getScriptOrganizeId() == null) { + ScriptTemplate byCreateByAndIsTop = scriptTemplateRepository.findByCreateByAndIsTop(SecurityUtils.getCurrentUserId(), true); + if (ObjectUtil.isNotEmpty(byCreateByAndIsTop)) { + byCreateByAndIsTop.setAnswer(scriptTemplate.getAnswer()); + byCreateByAndIsTop.setQuestion(scriptTemplate.getQuestion()); + byCreateByAndIsTop.setCreateTime(DateUtil.date()); + scriptTemplateRepository.save(byCreateByAndIsTop); + return CommonResponse.createBySuccess(); + } + scriptTemplate1.setIsTop(true); + } else { + scriptTemplate1.setScriptOrganizeId(scriptTemplate.getScriptOrganizeId()); } - scriptTemplateRepository.saveAll(list); + scriptTemplateRepository.save(scriptTemplate1); return CommonResponse.createBySuccess(); } 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 index cd7f7bbc..cc64e28f 100644 --- 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 @@ -1,5 +1,6 @@ package com.baiye.modules.telemarkting.api; +import com.baiye.annotation.Log; import com.baiye.http.CommonResponse; import com.baiye.modules.telemarkting.entity.dto.ClueBoostQueryCriteria; import com.baiye.modules.telemarkting.service.ClueBoostService; @@ -31,6 +32,7 @@ public class ClueBoostController { @ApiOperation("赔付") @PostMapping("/compensate") + @Log("线索赔付") 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..4cc7e70d 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 @@ -1,6 +1,7 @@ package com.baiye.modules.telemarkting.api; import com.baiye.annotation.Inner; +import com.baiye.annotation.Log; import com.baiye.http.CommonResponse; import com.baiye.modules.telemarkting.entity.ExtensionNumber; import com.baiye.modules.telemarkting.entity.dto.ExtensionNumberCriteria; @@ -32,6 +33,7 @@ public class ExtensionNumberController { @PostMapping("/add/extension") @ApiOperation("导入分机号和外显号") + @Log("导入分机号和去显号") public CommonResponse addNumbers(@RequestParam(value = "file", required = false) MultipartFile file, @RequestParam("display") Long display, @RequestParam("dyDisplay") Long dyDisplay, diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/TelephoneCallController.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/TelephoneCallController.java index cef3d127..b3807764 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/TelephoneCallController.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/TelephoneCallController.java @@ -4,6 +4,8 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; +import com.baiye.annotation.Log; +import com.baiye.common.CommonLog; import com.baiye.constant.DefaultNumberConstants; import com.baiye.exception.BadRequestException; import com.baiye.http.CommonResponse; @@ -47,16 +49,19 @@ public class TelephoneCallController { @PostMapping("/telephone/req") @ApiOperation("拨打电话") + @Log("电话请求") public CommonResponse doubleCallReq(@Validated @RequestBody TelephoneCallReqDTO telephoneCallReqDTO) { int hour = DateUtil.hour(DateUtil.date(), true); if (hour < DefaultNumberConstants.EIGHT_NUMBER || hour >= DefaultNumberConstants.TWENTY_ONE) { + CommonLog.error("请在8点-21点之间拨打电话"); return CommonResponse.createByErrorMessage("请在8点-21点之间拨打电话"); } //判断账号是否到期 Date expirationTime = userService.findExpirationTimeByUserId(SecurityUtils.getCurrentUserId()); if (ObjectUtil.isNull(expirationTime) || DateUtil.compare(expirationTime, DateUtil.date()) < DefaultNumberConstants.ZERO_NUMBER) { - return CommonResponse.createByErrorMessage("您的账号已到期,请续费后使用"); + CommonLog.error("您的账号已到期,请联系管理员"); + return CommonResponse.createByErrorMessage("您的账号已到期,请联系管理员"); } Long companyId = SecurityUtils.getCompanyId(); Organize organize; @@ -68,13 +73,11 @@ public class TelephoneCallController { } Company company = companyService.findById(companyId); if (ObjectUtil.isNull(organize) || ObjectUtil.isNull(company)) { + CommonLog.error("缺失小组信息或公司信息"); return CommonResponse.createByErrorMessage("缺失小组信息或公司信息"); } -// if (company.getUserBalance() == null || company.getUserBalance() <= 0) { -// return CommonResponse.createByErrorMessage("余额不足,请充值后使用"); -// } - if (organize.getCallMode() == null) { + CommonLog.error("请指定呼叫方式后使用"); return CommonResponse.createByErrorMessage("请指定呼叫方式后使用"); } //呼叫方式:0:双呼 1:点呼 2:AXB @@ -138,12 +141,6 @@ public class TelephoneCallController { return telephoneCallService.doubleCallStop(telephoneCallStopDTO); } - @PostMapping("/roll/stop") - @ApiOperation("点呼挂断呼叫") - public CommonResponse rollCallStop(@RequestBody TelephoneCallStopDTO telephoneCallStopDTO) { - return telephoneCallService.rollCallStop(telephoneCallStopDTO); - } - @PostMapping("/roll/cdrUrl") @ApiOperation("点呼系统回调话单") public CommonResponse rollCallBack(@RequestBody String json) { @@ -159,4 +156,10 @@ public class TelephoneCallController { } return CommonResponse.createBySuccess(); } + + @PostMapping("/roll/stop") + @ApiOperation("点呼挂断呼叫") + public CommonResponse rollCallStop(@RequestBody TelephoneCallStopDTO telephoneCallStopDTO) { + return telephoneCallService.rollCallStop(telephoneCallStopDTO); + } } diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/RollCallReq.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/RollCallReq.java index 3a0aef15..57f4cf8c 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/RollCallReq.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/RollCallReq.java @@ -9,6 +9,7 @@ import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import com.baiye.common.CommonLog; import com.baiye.constant.DefaultNumberConstants; import com.baiye.exception.BadRequestException; import com.baiye.http.RollCallResponse; @@ -60,7 +61,7 @@ public class RollCallReq { rollCallSystemDTO.setCdr_url(cdrUrl); rollCallSystemDTO.setDisplay_callee(String.valueOf(doubleCallReq.getDisplay())); rollCallSystemDTO.setDisplay_caller(String.valueOf(doubleCallReq.getDisplay())); - log.info("点呼请求参数:{}", BeanUtil.beanToMap(rollCallSystemDTO)); + CommonLog.info("点呼请求参数: " + BeanUtil.beanToMap(rollCallSystemDTO)); //设置重试机制 int count = 0; @@ -75,7 +76,7 @@ public class RollCallReq { return doubleCallResponse.getReqid(); } else { count++; - log.error("点呼请求失败,response==={}", doubleCallResponse.getReason()); + CommonLog.error("点呼请求失败,response===" + doubleCallResponse.getReason()); Thread.sleep(3000); } } catch (Exception e) { diff --git a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/ExtensionNumberServiceImpl.java b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/ExtensionNumberServiceImpl.java index 048059be..b13807aa 100644 --- a/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/ExtensionNumberServiceImpl.java +++ b/ad-platform-manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/ExtensionNumberServiceImpl.java @@ -8,6 +8,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.poi.excel.ExcelReader; import cn.hutool.poi.excel.ExcelUtil; +import com.baiye.common.CommonLog; import com.baiye.constant.DefaultNumberConstants; import com.baiye.exception.BadRequestException; import com.baiye.http.CommonResponse; @@ -133,7 +134,7 @@ public class ExtensionNumberServiceImpl implements ExtensionNumberService { try { reader = ExcelUtil.getReader(file.getInputStream()); } catch (Exception e) { - log.error("读取文件错误:{}", e.getMessage()); + CommonLog.error("文件读取错误"); return CommonResponse.createByErrorMessage("读取文件错误"); } List> read = reader.read(0, reader.getRowCount()); @@ -152,7 +153,7 @@ public class ExtensionNumberServiceImpl implements ExtensionNumberService { String sip = numberSipReq.req(number, company.getCompanyName()); if (StrUtil.isBlank(sip)) { - log.error("未获取到分机号密码,分机号={},公司={}", number, company.getCompanyName()); + CommonLog.error("未获取到分机号密码"); throw new BadRequestException("未获取到分机号密码,分机号=" + number + "-----公司={}" + company.getCompanyName()); } extensionNumber.setSip(sip); 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 f9b26848..c7365085 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 @@ -5,6 +5,8 @@ import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; +import com.baiye.common.CommonLog; +import com.baiye.constant.BusinessPartyType; import com.baiye.constant.ClueTypeConstants; import com.baiye.constant.DefaultNumberConstants; import com.baiye.exception.BadRequestException; @@ -17,7 +19,6 @@ import com.baiye.modules.agent.repository.ChannelCustomRepository; import com.baiye.modules.platform.domain.CallDeduct; import com.baiye.modules.platform.domain.Clue; import com.baiye.modules.platform.repository.CallDeductRepository; -import com.baiye.modules.platform.service.CompanyService; import com.baiye.modules.system.service.UserService; import com.baiye.modules.telemarkting.dao.*; import com.baiye.modules.telemarkting.entity.*; @@ -26,6 +27,7 @@ import com.baiye.modules.telemarkting.httpRequest.AxbRequest; import com.baiye.modules.telemarkting.httpRequest.DoubleCallReq; import com.baiye.modules.telemarkting.httpRequest.RollCallReq; import com.baiye.modules.telemarkting.service.TelephoneCallService; +import com.baiye.util.RedisUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.context.ApplicationContext; import org.springframework.http.ResponseEntity; @@ -37,6 +39,7 @@ import java.util.Arrays; import java.util.Date; import java.util.Objects; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; /** * @author wjt @@ -63,8 +66,6 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { @Resource private ExtensionDisplayRepository extensionDisplayRepository; @Resource - private CompanyService companyService; - @Resource private CallDeductRepository callDeductRepository; @Resource private UserService userService; @@ -74,6 +75,9 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { @Resource private ChannelCustomRepository channelCustomRepository; + @Resource + private RedisUtils redisUtils; + @Override public CommonResponse doubleCallReq(TelephoneCallReqDTO doubleCallReq, Long companyId) { String requestId = RandomUtil.randomString(10); @@ -133,10 +137,10 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { //实时扣费 callCostCount(allCallInfo.getMemberId(), allCallInfo.getClueId(), allCallInfo.getClueType(), allCallInfo.getDuration(), DefaultNumberConstants.TWO_NUMBER, whichUserId); //更新资源通话状态 - CompletableFuture.runAsync(() -> updateSourceCallStatus(userDate, DefaultNumberConstants.TWO_NUMBER, allCallInfo.getClueType())); + CompletableFuture.runAsync(() -> updateSourceCallStatus(userDate, DefaultNumberConstants.TWO_NUMBER, allCallInfo.getClueType(), null)); } else { //更新资源通话状态 - CompletableFuture.runAsync(() -> updateSourceCallStatus(userDate, DefaultNumberConstants.ONE_NUMBER, allCallInfo.getClueType())); + CompletableFuture.runAsync(() -> updateSourceCallStatus(userDate, DefaultNumberConstants.ONE_NUMBER, allCallInfo.getClueType(), null)); } } @@ -186,64 +190,29 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { Long whichUserId = user.getWhichUserId(); Integer surplusPhoneBillByUserId = channelCustomRepository.findSurplusPhoneBillByUserId(whichUserId); if (surplusPhoneBillByUserId == null || surplusPhoneBillByUserId <= 0) { + CommonLog.error("话费不足"); return CommonResponse.createByErrorMessage("话费不足"); } String requestId = RandomUtil.randomString(10); telephoneCallReqDTO.setRequestId(requestId); if (telephoneCallReqDTO.getDisplay() == null || telephoneCallReqDTO.getTelA() == null) { - //获取分机号 - Integer number = extensionUserRepository.findNumberByMemberId(telephoneCallReqDTO.getMemberId()); - if (number == null) { - return CommonResponse.createByErrorMessage("未分配分机号"); - } - ExtensionDisplay extensionDisplay = extensionDisplayRepository.findExtensionDisplayByCompanyId(companyId); - if (ObjectUtil.isNull(extensionDisplay)) { - return CommonResponse.createByErrorMessage("未配置去显号"); - } - telephoneCallReqDTO.setTelA(String.valueOf(number)); - //获取去显号 - Long display; - switch (telephoneCallReqDTO.getClueType()) { - case DefaultNumberConstants.THREE_NUMBER: - if (extensionDisplay.getDyDisplay() == null) { - return CommonResponse.createByErrorMessage("未配置抖音去显号"); - } - display = extensionDisplay.getDyDisplay(); - break; - case DefaultNumberConstants.FOUR_NUMBER: - if (extensionDisplay.getDeliveryDisplay() == null) { - return CommonResponse.createByErrorMessage("未配置投流去显号"); - } - display = extensionDisplay.getDeliveryDisplay(); - break; - case DefaultNumberConstants.FIVE_NUMBER: - if (extensionDisplay.getTokerDisplay() == null) { - return CommonResponse.createByErrorMessage("未配置拓客去显号"); - } - display = extensionDisplay.getTokerDisplay(); - break; - default: - if (extensionDisplay.getDisplay() == null) { - return CommonResponse.createByErrorMessage("未配置去显号"); - } - display = extensionDisplay.getDisplay(); - } - telephoneCallReqDTO.setDisplay(display); + //获取去显号和分机号 + getNumberAndDisplay(telephoneCallReqDTO, companyId); } - //获取被叫号 CallClueDTO body; try { body = sourceClueClient.queryDetailsByClueType(Long.parseLong(telephoneCallReqDTO.getUserData()), telephoneCallReqDTO.getClueType()).getBody(); } catch (Exception e) { - log.error("获取被叫号错误:{},time:{} ", e.getMessage(), DateUtil.now()); + CommonLog.error("呼叫失败"); throw new BadRequestException("呼叫失败"); } if (ObjectUtil.isNull(body) || StrUtil.isEmpty(body.getNid())) { - log.error("未获取到号码"); + CommonLog.error("未获取到号码"); return CommonResponse.createByErrorMessage("未获取到号码"); } if (body.getMemberId() == null) { + CommonLog.error("线索未分配"); return CommonResponse.createByErrorMessage("线索未分配,请刷新后重试"); } telephoneCallReqDTO.setTelB("474" + telephoneCallReqDTO.getDisplay() + body.getNid()); @@ -256,12 +225,61 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { CallClueInfo clueInfo = new CallClueInfo().init(Long.parseLong(telephoneCallReqDTO.getUserData()), telephoneCallReqDTO.getTeamId(), telephoneCallReqDTO.getMemberId(), telephoneCallReqDTO.getTaskId(), companyId, DefaultNumberConstants.ONE_NUMBER); callClueRepository.save(clueInfo); + redisUtils.set(requestId, CommonLog.getTraceId(), 3, TimeUnit.HOURS); TelephoneCallStopDTO telephoneCallStopDTO = new TelephoneCallStopDTO(); telephoneCallStopDTO.setSessionid(reqId); telephoneCallStopDTO.setCallId(requestId); return CommonResponse.createBySuccess(telephoneCallStopDTO); } + private void getNumberAndDisplay(TelephoneCallReqDTO telephoneCallReqDTO, Long companyId) { + //获取分机号 + Integer number = extensionUserRepository.findNumberByMemberId(telephoneCallReqDTO.getMemberId()); + if (number == null) { + CommonLog.error("未分配分机号"); + throw new BadRequestException("未分配分机号"); + } + ExtensionDisplay extensionDisplay = extensionDisplayRepository.findExtensionDisplayByCompanyId(companyId); + if (ObjectUtil.isNull(extensionDisplay)) { + CommonLog.error("未配置去显号"); + throw new BadRequestException("未配置去显号"); + } + telephoneCallReqDTO.setTelA(String.valueOf(number)); + //获取去显号 + Long display; + switch (telephoneCallReqDTO.getClueType()) { + case DefaultNumberConstants.THREE_NUMBER: + if (extensionDisplay.getDyDisplay() == null) { + CommonLog.error("未配置抖音去显号"); + throw new BadRequestException("未配置抖音去显号"); + } + display = extensionDisplay.getDyDisplay(); + break; + case DefaultNumberConstants.FOUR_NUMBER: + if (extensionDisplay.getDeliveryDisplay() == null) { + CommonLog.error("未配置投流去显号"); + throw new BadRequestException("未配置投流去显号"); + } + display = extensionDisplay.getDeliveryDisplay(); + break; + case DefaultNumberConstants.FIVE_NUMBER: + if (extensionDisplay.getTokerDisplay() == null) { + CommonLog.error("未配置拓客去显号"); + throw new BadRequestException("未配置拓客去显号"); + } + display = extensionDisplay.getTokerDisplay(); + break; + default: + if (extensionDisplay.getDisplay() == null) { + CommonLog.error("未配置去显号"); + throw new BadRequestException("未配置去显号"); + } + display = extensionDisplay.getDisplay(); + } + telephoneCallReqDTO.setDisplay(display); + } + + @Override public CommonResponse rollCallStop(TelephoneCallStopDTO telephoneCallStopDTO) { if (rollCallReq.stopReq(telephoneCallStopDTO)) { @@ -278,17 +296,19 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { @Override @Transactional(rollbackFor = Exception.class) public void rollCallBack(RollCallBackDTO rollCallBackDTO) { + String sessionId = rollCallBackDTO.getSessionid(); String otherLeg = rollCallBackDTO.getOtherLeg(); + String traceId = String.valueOf(redisUtils.get(otherLeg)); AllCallInfo allCallInfo = allCallInfoRepository.findBySessionId(otherLeg); if (ObjectUtil.isNotEmpty(allCallInfo)) { //相同说明是分机号的回调 if (sessionId.equals(otherLeg) && StrUtil.isNotBlank(rollCallBackDTO.getRecord_file_url())) { - log.info("分机回调-点呼:otherLeg:{},详情:{}", otherLeg, rollCallBackDTO); + CommonLog.infoBusinessPartyTypeNewTraceId("分机回调-点呼:" + rollCallBackDTO, BusinessPartyType.DB, traceId); allCallInfoRepository.updateByRecord(DefaultNumberConstants.ONE_NUMBER, rollCallBackDTO.getRecord_file_url(), allCallInfo.getId()); } else { - log.info("被叫回调-点呼:otherLeg:{},详情:{}", otherLeg, rollCallBackDTO); + CommonLog.infoBusinessPartyType("被叫回调-点呼:" + rollCallBackDTO, BusinessPartyType.DB); UserDto user = userService.findById(allCallInfo.getMemberId()); Long whichUserId = user.getWhichUserId(); boolean status; @@ -298,13 +318,13 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { callClueRepository.updateByStatus(DefaultNumberConstants.TWO_NUMBER, allCallInfo.getClueId()); allCallInfoRepository.updateByDurationAndStatus(DefaultNumberConstants.TWO_NUMBER, Integer.valueOf(rollCallBackDTO.getDuration()), allCallInfo.getId()); //更新资源通话状态 - CompletableFuture.runAsync(() -> updateSourceCallStatus(allCallInfo.getClueId(), DefaultNumberConstants.TWO_NUMBER, allCallInfo.getClueType())); + CompletableFuture.runAsync(() -> updateSourceCallStatus(allCallInfo.getClueId(), DefaultNumberConstants.TWO_NUMBER, allCallInfo.getClueType(), traceId)); //实时扣除话费 callCostCount(allCallInfo.getMemberId(), allCallInfo.getClueId(), allCallInfo.getClueType(), Integer.valueOf(rollCallBackDTO.getDuration()), 2, whichUserId); status = true; } else { //更新资源通话状态 - CompletableFuture.runAsync(() -> updateSourceCallStatus(allCallInfo.getClueId(), DefaultNumberConstants.ONE_NUMBER, allCallInfo.getClueType())); + CompletableFuture.runAsync(() -> updateSourceCallStatus(allCallInfo.getClueId(), DefaultNumberConstants.ONE_NUMBER, allCallInfo.getClueType(), traceId)); status = false; } if (Arrays.asList(ClueTypeConstants.TOKER_TYPE).contains(allCallInfo.getClueType())) { @@ -322,14 +342,17 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { * @param clueId 资源ID * @param status 1:未接听 2:已接通 */ - private void updateSourceCallStatus(Long clueId, Integer status, Integer clueType) { + private void updateSourceCallStatus(Long clueId, Integer status, Integer clueType, String traceId) { ClueMiddle clueMiddle = new ClueMiddle(); clueMiddle.setClueId(clueId); clueMiddle.setClueCallStatus(status); clueMiddle.setOptimisticVersion(DefaultNumberConstants.THREE_NUMBER); clueMiddle.setNewestCallTime(new Date()); clueMiddle.setClueType(clueType); - sourceClueClient.update(clueMiddle); + int code = sourceClueClient.update(clueMiddle).getStatus(); + if (code != 0) { + CommonLog.infoTraceId("通话同步状态错误", traceId); + } } /** @@ -405,6 +428,8 @@ public class TelephoneCallServiceImpl implements TelephoneCallService { if (num > 0) { save.setStatus(true); callDeductRepository.save(save); + } else { + CommonLog.error("话费扣除失败,记录id:" + save.getId()); } // else { // updateBalance(mul, companyId, version + 1, save); diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/TurnoverRecordRepository.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/TurnoverRecordRepository.java index a522d497..62a76057 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/TurnoverRecordRepository.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/module/dao/TurnoverRecordRepository.java @@ -1,6 +1,5 @@ package com.baiye.module.dao; -import com.baiye.module.entity.ClueMiddle; import com.baiye.module.entity.TurnoverRecord; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; diff --git a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/PublicCluePoolSync.java b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/PublicCluePoolSync.java index 6a1271a4..408d76bd 100644 --- a/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/PublicCluePoolSync.java +++ b/ad-platform-services/ad-platform-source/src/main/java/com/baiye/task/PublicCluePoolSync.java @@ -3,6 +3,7 @@ package com.baiye.task; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; +import com.baiye.common.CommonLog; import com.baiye.constant.DefaultNumberConstants; import com.baiye.enums.ClueStageEnum; import com.baiye.feign.UserClient; @@ -136,7 +137,6 @@ public class PublicCluePoolSync { publicCluePool.setStatus(0); publicCluePoolRepository.save(publicCluePool); - ConductRecord conductRecord = new ConductRecord(); conductRecord.setClueId(clueMiddle.getClueId()); conductRecord.setRecordInfo("移入公海"); @@ -151,6 +151,8 @@ public class PublicCluePoolSync { clueMiddle.setMemberStatus(DefaultNumberConstants.ZERO_NUMBER); clueMiddle.setOptimisticVersion(clueMiddle.getOptimisticVersion() + 1); clueMiddleRepository.save(clueMiddle); + + CommonLog.info("线索:" + clueMiddle.getClueId() + "移入公海"); } } }