From f9c008d81fbf4bff701d1cbfb092605b0b854f6b Mon Sep 17 00:00:00 2001 From: bynt Date: Fri, 11 Feb 2022 18:15:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0axb=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/baiye/http/AxbCallResponse.java | 22 +++++++ .../config/properties/AxbProperties.java | 27 ++++++++ .../service/impl/CompanyServiceImpl.java | 3 + .../telemarkting/api/RollCallController.java | 9 ++- ...ller.java => TelephoneCallController.java} | 59 ++++++++++-------- .../entity/dto/AxbCallRequestDTO.java | 45 ++++++++++++++ ...BackDTO.java => TelephoneCallBackDTO.java} | 2 +- ...O.java => TelephoneCallBackStatusDTO.java} | 2 +- ...llReqDTO.java => TelephoneCallReqDTO.java} | 11 +++- ...StopDTO.java => TelephoneCallStopDTO.java} | 2 +- ...emDTO.java => TelephoneCallSystemDTO.java} | 2 +- .../telemarkting/httpRequest/AxbRequest.java | 57 +++++++++++++++++ .../telemarkting/httpRequest/CallReq.java | 26 ++++---- .../httpRequest/DoubleCallReq.java | 55 ++++++++--------- .../telemarkting/httpRequest/RollCallReq.java | 6 +- .../service/DoubleCallService.java | 53 ---------------- .../telemarkting/service/RollCallService.java | 6 +- .../service/TelephoneCallService.java | 60 ++++++++++++++++++ .../service/impl/RollCallServiceImpl.java | 29 +++++---- ...mpl.java => TelephoneCallServiceImpl.java} | 61 +++++++++++++++---- .../main/resources/config/application-dev.yml | 20 ++++++ .../resources/config/application-prod.yml | 20 ++++++ .../src/main/resources/config/application.yml | 10 +-- .../module/service/impl/ClueServiceImpl.java | 10 +-- 24 files changed, 421 insertions(+), 176 deletions(-) create mode 100644 ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/http/AxbCallResponse.java create mode 100644 manage/ad-platform-management/src/main/java/com/baiye/config/properties/AxbProperties.java rename manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/{DoubleCallController.java => TelephoneCallController.java} (52%) create mode 100644 manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/AxbCallRequestDTO.java rename manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/{DoubleCallBackDTO.java => TelephoneCallBackDTO.java} (97%) rename manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/{DoubleCallBackStatusDTO.java => TelephoneCallBackStatusDTO.java} (85%) rename manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/{DoubleCallReqDTO.java => TelephoneCallReqDTO.java} (78%) rename manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/{DoubleCallStopDTO.java => TelephoneCallStopDTO.java} (83%) rename manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/{DoubleCallSystemDTO.java => TelephoneCallSystemDTO.java} (90%) create mode 100644 manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/AxbRequest.java delete mode 100644 manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/DoubleCallService.java create mode 100644 manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/TelephoneCallService.java rename manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/{DoubleCallServiceImpl.java => TelephoneCallServiceImpl.java} (67%) diff --git a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/http/AxbCallResponse.java b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/http/AxbCallResponse.java new file mode 100644 index 00000000..fcb0556a --- /dev/null +++ b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/http/AxbCallResponse.java @@ -0,0 +1,22 @@ +package com.baiye.http; + +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Enzo + * @date : 2022/2/10 + */ +@Data +@NoArgsConstructor +public class AxbCallResponse { + private String reason; + private String bindingId; + private String gateway; + private String requestId; + private String prefixA; + private String prefixX; + private String telX; + private String xtypeID; + private String result; +} diff --git a/manage/ad-platform-management/src/main/java/com/baiye/config/properties/AxbProperties.java b/manage/ad-platform-management/src/main/java/com/baiye/config/properties/AxbProperties.java new file mode 100644 index 00000000..8427295b --- /dev/null +++ b/manage/ad-platform-management/src/main/java/com/baiye/config/properties/AxbProperties.java @@ -0,0 +1,27 @@ +package com.baiye.config.properties; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * @author Enzo + * @date : 2022/2/10 + */ +@Data +@Configuration +@ConfigurationProperties(prefix = "axb.call") +public class AxbProperties { + + private String appid; + + private String cdrUrl; + + private String bingUrl; + + private String statusUrl; + + private String unBingUrl; + + +} diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/service/impl/CompanyServiceImpl.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/service/impl/CompanyServiceImpl.java index 13339edc..bba7d5fa 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/service/impl/CompanyServiceImpl.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/service/impl/CompanyServiceImpl.java @@ -19,6 +19,8 @@ import com.baiye.util.PageUtil; import com.baiye.util.QueryHelp; import com.baiye.util.SecurityUtils; import lombok.RequiredArgsConstructor; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; @@ -84,6 +86,7 @@ public class CompanyServiceImpl implements CompanyService { } @Override + @Cacheable(cacheNames = "companyCache",key = "#companyId") public Company findById(Long companyId) { return companyRepository.findById(companyId).orElseGet(Company::new); } diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/RollCallController.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/RollCallController.java index 90ecf513..3a462d23 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/RollCallController.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/RollCallController.java @@ -4,8 +4,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import com.baiye.http.CommonResponse; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallBackDTO; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallReqDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO; import com.baiye.modules.telemarkting.entity.dto.RollCallBackDTO; import com.baiye.modules.telemarkting.service.RollCallService; import io.swagger.annotations.Api; @@ -35,11 +34,11 @@ public class RollCallController { @PostMapping("/roll/req") @ApiOperation("请求接入点呼") - public CommonResponse rollCallReq(@Validated @RequestBody DoubleCallReqDTO doubleCallReq) { - if (ObjectUtil.isEmpty(doubleCallReq)) { + public CommonResponse rollCallReq(@Validated @RequestBody TelephoneCallReqDTO telephoneCallReqDTO) { + if (ObjectUtil.isEmpty(telephoneCallReqDTO)) { return CommonResponse.createByError(); } - return rollCallService.rollCallReq(doubleCallReq); + return rollCallService.rollCallReq(telephoneCallReqDTO); } @PostMapping("/roll/cdrUrl") diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/DoubleCallController.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/TelephoneCallController.java similarity index 52% rename from manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/DoubleCallController.java rename to manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/TelephoneCallController.java index 11fc50bf..1f30bcf9 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/DoubleCallController.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/api/TelephoneCallController.java @@ -3,12 +3,17 @@ package com.baiye.modules.telemarkting.api; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; +import com.baiye.constant.DefaultNumberConstants; import com.baiye.http.CommonResponse; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallBackDTO; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallBackStatusDTO; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallReqDTO; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallStopDTO; -import com.baiye.modules.telemarkting.service.DoubleCallService; +import com.baiye.modules.system.domain.Company; +import com.baiye.modules.system.service.CompanyService; +import com.baiye.modules.system.service.OrganizeService; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallBackDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallBackStatusDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallStopDTO; +import com.baiye.modules.telemarkting.service.TelephoneCallService; +import com.baiye.util.SecurityUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -16,8 +21,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; - /** * @author wjt * @date 2021/12/14 @@ -25,35 +28,43 @@ import javax.annotation.Resource; @Slf4j @RestController @RequestMapping("/api") -@Api(tags = "对接双呼") +@Api(tags = "拨打电话") @RequiredArgsConstructor -public class DoubleCallController { +public class TelephoneCallController { - private final DoubleCallService doubleCallService; + private final TelephoneCallService telephoneCallService; + private final CompanyService companyService; - @PostMapping("/double/req") - @ApiOperation("请求接入双呼") - public CommonResponse doubleCallReq(@Validated @RequestBody DoubleCallReqDTO doubleCallReq) { - if (ObjectUtil.isEmpty(doubleCallReq)) { + @PostMapping("/telephone/req") + @ApiOperation("拨打电话") + public CommonResponse doubleCallReq(@Validated @RequestBody TelephoneCallReqDTO telephoneCallReqDTO) { + if (ObjectUtil.isEmpty(telephoneCallReqDTO)) { return CommonResponse.createByError(); } - Long teamId = doubleCallReq.getTeamId(); - - return doubleCallService.doubleCallReq(doubleCallReq); + Long companyId = SecurityUtils.getCompanyId(); + if (companyId != null) { + Company byId = companyService.findById(SecurityUtils.getCompanyId()); + telephoneCallReqDTO.setCompanyName(byId.getCompanyName()); + return telephoneCallReqDTO.getCallMode() != null + && telephoneCallReqDTO.getCallMode() > DefaultNumberConstants.ONE_NUMBER + ? telephoneCallService.doubleCallReq(telephoneCallReqDTO) + : telephoneCallService.axbDialNumber(telephoneCallReqDTO); + } + return CommonResponse.createByError(); } @PostMapping("/back/cdrUrl") @ApiOperation("双呼系统回调话单") public CommonResponse doubleCallBack(@RequestBody String json) { try { - DoubleCallBackDTO doubleCallReq = JSONUtil.toBean(json, DoubleCallBackDTO.class); + TelephoneCallBackDTO doubleCallReq = JSONUtil.toBean(json, TelephoneCallBackDTO.class); if (ObjectUtil.isEmpty(doubleCallReq) || StrUtil.isEmpty(doubleCallReq.getSessionId())) { return CommonResponse.createByErrorMessage("参数为空"); } log.info("=======双呼回调话单: {}", doubleCallReq); - doubleCallService.doubleCallBack(doubleCallReq); + telephoneCallService.doubleCallBack(doubleCallReq); } catch (Exception e) { log.error("双呼回调话单错误 参数 :{}", json); log.error("双呼回调话单错误,数据解析错误 :{}", e.getMessage()); @@ -66,12 +77,12 @@ public class DoubleCallController { @ApiOperation("双呼系统回调状态") public CommonResponse doubleCallBackStatus(@RequestBody String json) { try { - DoubleCallBackStatusDTO doubleCallBack = JSONUtil.toBean(json, DoubleCallBackStatusDTO.class); + TelephoneCallBackStatusDTO doubleCallBack = JSONUtil.toBean(json, TelephoneCallBackStatusDTO.class); if (ObjectUtil.isEmpty(doubleCallBack) || StrUtil.isEmpty(doubleCallBack.getSessionId())) { return CommonResponse.createByErrorMessage("参数为空"); } log.info("=====双呼状态话单 :{}", doubleCallBack); - doubleCallService.doubleCallBackStatus(doubleCallBack); + telephoneCallService.doubleCallBackStatus(doubleCallBack); } catch (Exception e) { log.error("双呼回调状态错误 参数 :{}", json); log.error("双呼回调状态错误,数据解析错误 :{}", e.getMessage()); @@ -82,13 +93,13 @@ public class DoubleCallController { @PostMapping("/double/stop") @ApiOperation("挂断呼叫") - public CommonResponse doubleCallStop(@RequestBody DoubleCallStopDTO doubleCallStopDTO) { - return doubleCallService.doubleCallStop(doubleCallStopDTO); + public CommonResponse doubleCallStop(@RequestBody TelephoneCallStopDTO telephoneCallStopDTO) { + return telephoneCallService.doubleCallStop(telephoneCallStopDTO); } @GetMapping("/call/record") @ApiOperation("获取通话记录和录音地址") public CommonResponse getCallRecord(@RequestParam(value = "clueId") Long clueId, @RequestParam(value = "memberId") Long memberId) { - return doubleCallService.getCallRecord(clueId, memberId); + return telephoneCallService.getCallRecord(clueId, memberId); } } diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/AxbCallRequestDTO.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/AxbCallRequestDTO.java new file mode 100644 index 00000000..01aa3217 --- /dev/null +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/AxbCallRequestDTO.java @@ -0,0 +1,45 @@ +package com.baiye.modules.telemarkting.entity.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author Enzo + * @date : 2022/2/10 + */ +@Data +public class AxbCallRequestDTO implements Serializable { + private static final long serialVersionUID = 215726963974324463L; + + @ApiModelProperty("appid") + private String appid; + + @ApiModelProperty("请求唯一 id") + private String requestId; + + @ApiModelProperty("真实主叫号码") + private String telA; + + @ApiModelProperty("真实被叫号码") + private String telB; + + @ApiModelProperty("AB呼叫的虚拟中间X号") + private String telX; + + @ApiModelProperty("X号码的群组") + private String xGroup; + + @ApiModelProperty("自动解绑周期,不带由 系统指定") + private Integer expires; + + @ApiModelProperty("话单回推地址") + private String cdrUrl; + + @ApiModelProperty("状态回推地址") + private String statusUrl; + + @ApiModelProperty("用户附属信息") + private String userData; +} diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/DoubleCallBackDTO.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/TelephoneCallBackDTO.java similarity index 97% rename from manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/DoubleCallBackDTO.java rename to manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/TelephoneCallBackDTO.java index 2c280fe3..41a278f5 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/DoubleCallBackDTO.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/TelephoneCallBackDTO.java @@ -8,7 +8,7 @@ import lombok.Data; * 话单回调接收 */ @Data -public class DoubleCallBackDTO { +public class TelephoneCallBackDTO { private Integer direction; private String spId; private String appKey; diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/DoubleCallBackStatusDTO.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/TelephoneCallBackStatusDTO.java similarity index 85% rename from manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/DoubleCallBackStatusDTO.java rename to manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/TelephoneCallBackStatusDTO.java index 61f7c3ad..35311064 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/DoubleCallBackStatusDTO.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/TelephoneCallBackStatusDTO.java @@ -8,7 +8,7 @@ import lombok.Data; * 状态回调 */ @Data -public class DoubleCallBackStatusDTO { +public class TelephoneCallBackStatusDTO { private String status; private String callId; private String sessionId; diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/DoubleCallReqDTO.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/TelephoneCallReqDTO.java similarity index 78% rename from manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/DoubleCallReqDTO.java rename to manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/TelephoneCallReqDTO.java index ab6b1dfb..974b3b2a 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/DoubleCallReqDTO.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/TelephoneCallReqDTO.java @@ -12,7 +12,7 @@ import java.io.Serializable; * 前段请求接通双呼的参数类 */ @Data -public class DoubleCallReqDTO implements Serializable { +public class TelephoneCallReqDTO implements Serializable { private static final long serialVersionUID = 8037829549747968861L; @@ -41,4 +41,13 @@ public class DoubleCallReqDTO implements Serializable { @ApiModelProperty("主任务id") @NotNull private Long taskId; + + + @ApiModelProperty("公司名称") + private String companyName; + + + @ApiModelProperty(value = "组呼叫方式:0:双呼 1:点呼 2:AXB") + private Integer callMode; + } diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/DoubleCallStopDTO.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/TelephoneCallStopDTO.java similarity index 83% rename from manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/DoubleCallStopDTO.java rename to manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/TelephoneCallStopDTO.java index fc694ca6..121d6d69 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/DoubleCallStopDTO.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/TelephoneCallStopDTO.java @@ -7,7 +7,7 @@ import lombok.Data; * @date 2022/01/18 */ @Data -public class DoubleCallStopDTO { +public class TelephoneCallStopDTO { private String sessionid; private String callId; } diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/DoubleCallSystemDTO.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/TelephoneCallSystemDTO.java similarity index 90% rename from manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/DoubleCallSystemDTO.java rename to manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/TelephoneCallSystemDTO.java index 61a59f40..cf024dc9 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/DoubleCallSystemDTO.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/entity/dto/TelephoneCallSystemDTO.java @@ -7,7 +7,7 @@ import lombok.Data; * @date 2021/12/14 */ @Data -public class DoubleCallSystemDTO { +public class TelephoneCallSystemDTO { private String appid; private String requestId; private String telA; diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/AxbRequest.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/AxbRequest.java new file mode 100644 index 00000000..2551eb83 --- /dev/null +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/AxbRequest.java @@ -0,0 +1,57 @@ +package com.baiye.modules.telemarkting.httpRequest; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.json.JSONUtil; +import com.baiye.config.properties.AxbProperties; +import com.baiye.constant.DefaultNumberConstants; +import com.baiye.exception.BadRequestException; +import com.baiye.http.AxbCallResponse; +import com.baiye.model.enums.ResponseCode; +import com.baiye.modules.telemarkting.entity.dto.AxbCallRequestDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +/** + * @author Enzo + * @date : 2022/2/10 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class AxbRequest { + + private final AxbProperties axbProperties; + + public String call(TelephoneCallReqDTO telephoneCallReqDTO) { + AxbCallRequestDTO axbCallRequestDTO = new AxbCallRequestDTO(); + BeanUtil.copyProperties(telephoneCallReqDTO, axbCallRequestDTO); + axbCallRequestDTO.setAppid(axbProperties.getAppid()); + axbCallRequestDTO.setXGroup(telephoneCallReqDTO.getCompanyName()); + axbCallRequestDTO.setCdrUrl(axbProperties.getCdrUrl()); + axbCallRequestDTO.setStatusUrl(axbProperties.getStatusUrl()); + HttpResponse response = + HttpRequest.post + (axbProperties.getBingUrl()) + .body(JSONUtil.toJsonPrettyStr + (axbCallRequestDTO)).execute(); + if (response.isOk()) { + AxbCallResponse axbCallResponse = JSONUtil + .toBean(response.body(), AxbCallResponse.class); + if (String.valueOf + (DefaultNumberConstants.ZERO_NUMBER) + .equals(axbCallResponse.getResult())) { + return axbCallResponse.getBindingId(); + } + throw new BadRequestException + (StringUtils.isNotBlank(axbCallResponse.getReason()) ? + axbCallResponse.getReason() + : ResponseCode.CALL_ERROR.getDesc()); + } + throw new BadRequestException(ResponseCode.CALL_ERROR.getDesc()); + } +} diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/CallReq.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/CallReq.java index 266c6ffe..4e1fb543 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/CallReq.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/CallReq.java @@ -9,9 +9,9 @@ import cn.hutool.json.JSONUtil; import com.baiye.exception.BadRequestException; import com.baiye.http.DoubleCallResponse; import com.baiye.model.enums.ResponseCode; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallReqDTO; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallStopDTO; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallSystemDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallStopDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallSystemDTO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; @@ -30,23 +30,21 @@ public class CallReq { private String stopUrl; @Value("${double.call.appid}") private String appid; - @Value("${double.call.companyName}") - private String companyName; @Value("${double.call.cdrUrl}") private String cdrUrl; @Value("${double.call.statusUrl}") private String statusUrl; - public String startReq(DoubleCallReqDTO doubleCallReq) { + public String startReq(TelephoneCallReqDTO doubleCallReq) { log.info("=======================doubleCallReq start in {}", DateUtil.date()); return reqTask(doubleCallReq); } - private String reqTask(DoubleCallReqDTO doubleCallReq) { - DoubleCallSystemDTO doubleCallSystemDTO = new DoubleCallSystemDTO(); - BeanUtil.copyProperties(doubleCallReq, doubleCallSystemDTO); + private String reqTask(TelephoneCallReqDTO telephoneCallReqDTO) { + TelephoneCallSystemDTO doubleCallSystemDTO = new TelephoneCallSystemDTO(); + BeanUtil.copyProperties(telephoneCallReqDTO, doubleCallSystemDTO); doubleCallSystemDTO.setAppid(appid); - doubleCallSystemDTO.setCompanyName(companyName); + doubleCallSystemDTO.setCompanyName(telephoneCallReqDTO.getCompanyName()); doubleCallSystemDTO.setCdrUrl(cdrUrl); doubleCallSystemDTO.setStatusUrl(statusUrl); int count = 0; @@ -70,16 +68,16 @@ public class CallReq { return null; } - public Boolean stopReq(DoubleCallStopDTO doubleCallStopDTO) { + public Boolean stopReq(TelephoneCallStopDTO telephoneCallStopDTO) { log.info("=======================stopReq start in {}", DateUtil.date()); - return stopTask(doubleCallStopDTO); + return stopTask(telephoneCallStopDTO); } - private Boolean stopTask(DoubleCallStopDTO doubleCallStopDTO) { + private Boolean stopTask(TelephoneCallStopDTO telephoneCallStopDTO) { int count = 0; int flag = 3; while (count <= flag) { - HttpResponse httpResponse = sendCallReq(JSONUtil.toJsonPrettyStr(doubleCallStopDTO), stopUrl); + HttpResponse httpResponse = sendCallReq(JSONUtil.toJsonPrettyStr(telephoneCallStopDTO), stopUrl); if (httpResponse.isOk()) { log.info("请求挂断成功,返回值:{}", httpResponse.body()); return Boolean.TRUE; diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/DoubleCallReq.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/DoubleCallReq.java index a21f23a9..9ed1c447 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/DoubleCallReq.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/DoubleCallReq.java @@ -9,9 +9,9 @@ import cn.hutool.json.JSONUtil; import com.baiye.exception.BadRequestException; import com.baiye.http.DoubleCallResponse; import com.baiye.model.enums.ResponseCode; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallReqDTO; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallStopDTO; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallSystemDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallStopDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallSystemDTO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; @@ -30,56 +30,49 @@ public class DoubleCallReq { private String stopUrl; @Value("${double.call.appid}") private String appid; - @Value("${double.call.companyName}") - private String companyName; + @Value("${double.call.cdrUrl}") private String cdrUrl; @Value("${double.call.statusUrl}") private String statusUrl; - public String startReq(DoubleCallReqDTO doubleCallReq) { + public String startReq(TelephoneCallReqDTO doubleCallReq) { log.info("=======================doubleCallReq start in {}", DateUtil.date()); return reqTask(doubleCallReq); } - private String reqTask(DoubleCallReqDTO doubleCallReq) { - DoubleCallSystemDTO doubleCallSystemDTO = new DoubleCallSystemDTO(); - BeanUtil.copyProperties(doubleCallReq, doubleCallSystemDTO); + private String reqTask(TelephoneCallReqDTO telephoneCallReqDTO) { + TelephoneCallSystemDTO doubleCallSystemDTO = new TelephoneCallSystemDTO(); + BeanUtil.copyProperties(telephoneCallReqDTO, doubleCallSystemDTO); doubleCallSystemDTO.setAppid(appid); - doubleCallSystemDTO.setCompanyName(companyName); + doubleCallSystemDTO.setCompanyName(telephoneCallReqDTO.getCompanyName()); doubleCallSystemDTO.setCdrUrl(cdrUrl); doubleCallSystemDTO.setStatusUrl(statusUrl); - int count = 0; - int flag = 3; log.info("请求对象:{}", JSONUtil.toJsonPrettyStr(doubleCallSystemDTO)); - while (count <= flag) { - HttpResponse httpResponse = sendCallReq(JSONUtil.toJsonPrettyStr(doubleCallSystemDTO), reqUrl); - if (httpResponse.isOk() && httpResponse.body().contains("success")) { - log.info("请求呼叫成功,返回值:{}", httpResponse.body()); - JSONObject result = JSONUtil.parseObj(httpResponse.body()); - return result.get("sessionId").toString(); - } else { - count++; - String body = httpResponse.body(); - log.error("请求失败,response==={}", body); - throw new BadRequestException(StringUtils.isNotBlank(body) ? - JSONUtil.toBean(body, DoubleCallResponse.class).getReason() : ResponseCode.CALL_ERROR.getDesc()); - } + HttpResponse httpResponse = sendCallReq(JSONUtil.toJsonPrettyStr(doubleCallSystemDTO), reqUrl); + if (httpResponse.isOk() && httpResponse.body().contains("success")) { + log.info("请求呼叫成功,返回值:{}", httpResponse.body()); + JSONObject result = JSONUtil.parseObj(httpResponse.body()); + return result.get("sessionId").toString(); + } else { + String body = httpResponse.body(); + log.error("请求失败,response==={}", body); + throw new BadRequestException(StringUtils.isNotBlank(body) ? + JSONUtil.toBean(body, DoubleCallResponse.class).getReason() : ResponseCode.CALL_ERROR.getDesc()); } - log.info("=======================doubleCallReq end in {}", DateUtil.date()); - return null; + } - public Boolean stopReq(DoubleCallStopDTO doubleCallStopDTO) { + public Boolean stopReq(TelephoneCallStopDTO telephoneCallStopDTO) { log.info("=======================stopReq start in {}", DateUtil.date()); - return stopTask(doubleCallStopDTO); + return stopTask(telephoneCallStopDTO); } - private Boolean stopTask(DoubleCallStopDTO doubleCallStopDTO) { + private Boolean stopTask(TelephoneCallStopDTO telephoneCallStopDTO) { int count = 0; int flag = 3; while (count <= flag) { - HttpResponse httpResponse = sendCallReq(JSONUtil.toJsonPrettyStr(doubleCallStopDTO), stopUrl); + HttpResponse httpResponse = sendCallReq(JSONUtil.toJsonPrettyStr(telephoneCallStopDTO), stopUrl); if (httpResponse.isOk()) { log.info("请求挂断成功,返回值:{}", httpResponse.body()); return Boolean.TRUE; diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/RollCallReq.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/RollCallReq.java index 87ab7129..b777c155 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/RollCallReq.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/httpRequest/RollCallReq.java @@ -1,3 +1,4 @@ +/* package com.baiye.modules.telemarkting.httpRequest; import cn.hutool.core.codec.Base64; @@ -14,10 +15,12 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +*/ /** * @author wujingtao * @date 2022/02/10 - */ + *//* + @Slf4j @Component public class RollCallReq { @@ -72,3 +75,4 @@ public class RollCallReq { return HttpRequest.post(url).header("Authorization", authorization).body(json).execute(); } } +*/ diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/DoubleCallService.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/DoubleCallService.java deleted file mode 100644 index 650137b7..00000000 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/DoubleCallService.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.baiye.modules.telemarkting.service; - -import com.baiye.http.CommonResponse; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallBackDTO; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallBackStatusDTO; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallReqDTO; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallStopDTO; - -/** - * @author wjt - * @date 2021/12/14 - */ -public interface DoubleCallService { - /** - * 双呼请求 - * - * @param doubleCallReq - * @return - */ - CommonResponse doubleCallReq(DoubleCallReqDTO doubleCallReq); - - /** - * 回调话单 - * - * @param doubleCallBack - */ - void doubleCallBack(DoubleCallBackDTO doubleCallBack); - - /** - * 回调状态 - * - * @param doubleCallBackStatus - */ - void doubleCallBackStatus(DoubleCallBackStatusDTO doubleCallBackStatus); - - /** - * 停止通话 - * - * @param doubleCallStopDTO - * @return - */ - CommonResponse doubleCallStop(DoubleCallStopDTO doubleCallStopDTO); - - - /** - * h获取通话记录和录音地址 - * - * @param clueId - * @param memberId - * @return - */ - CommonResponse getCallRecord(Long clueId, Long memberId); -} diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/RollCallService.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/RollCallService.java index 675d94c7..5171c2fa 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/RollCallService.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/RollCallService.java @@ -1,7 +1,7 @@ package com.baiye.modules.telemarkting.service; import com.baiye.http.CommonResponse; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallReqDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO; import com.baiye.modules.telemarkting.entity.dto.RollCallBackDTO; /** @@ -13,10 +13,10 @@ public interface RollCallService { /** * 点呼请求 * - * @param doubleCallReq + * @param telephoneCallReqDTO * @return */ - CommonResponse rollCallReq(DoubleCallReqDTO doubleCallReq); + CommonResponse rollCallReq(TelephoneCallReqDTO telephoneCallReqDTO); /** * 电呼回调 diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/TelephoneCallService.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/TelephoneCallService.java new file mode 100644 index 00000000..e6ebc124 --- /dev/null +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/TelephoneCallService.java @@ -0,0 +1,60 @@ +package com.baiye.modules.telemarkting.service; + +import com.baiye.http.CommonResponse; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallBackDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallBackStatusDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallStopDTO; + +/** + * @author wjt + * @date 2021/12/14 + */ +public interface TelephoneCallService { + /** + * 双呼请求 + * + * @param telephoneCallReqDTO + * @return + */ + CommonResponse doubleCallReq(TelephoneCallReqDTO telephoneCallReqDTO); + + /** + * 回调话单 + * + * @param telephoneCallBackDTO + */ + void doubleCallBack(TelephoneCallBackDTO telephoneCallBackDTO); + + /** + * 回调状态 + * + * @param telephoneCallBackStatusDTO + */ + void doubleCallBackStatus(TelephoneCallBackStatusDTO telephoneCallBackStatusDTO); + + /** + * 停止通话 + * + * @param telephoneCallStopDTO + * @return + */ + CommonResponse doubleCallStop(TelephoneCallStopDTO telephoneCallStopDTO); + + + /** + * h获取通话记录和录音地址 + * + * @param clueId + * @param memberId + * @return + */ + CommonResponse getCallRecord(Long clueId, Long memberId); + + /** + * axb拨打电话 + * @param telephoneCallReqDTO + * @return + */ + CommonResponse axbDialNumber(TelephoneCallReqDTO telephoneCallReqDTO); +} diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/RollCallServiceImpl.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/RollCallServiceImpl.java index 46f395aa..ff5f6cfd 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/RollCallServiceImpl.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/RollCallServiceImpl.java @@ -6,14 +6,12 @@ import cn.hutool.core.util.StrUtil; import com.baiye.constant.DefaultNumberConstants; import com.baiye.feign.SourceClueClient; import com.baiye.http.CommonResponse; -import com.baiye.modules.system.domain.Clue; import com.baiye.modules.telemarkting.dao.AllCallInfoRepository; import com.baiye.modules.telemarkting.dao.CallClueRepository; import com.baiye.modules.telemarkting.entity.AllCallInfo; import com.baiye.modules.telemarkting.entity.CallClueInfo; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallReqDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO; import com.baiye.modules.telemarkting.entity.dto.RollCallBackDTO; -import com.baiye.modules.telemarkting.httpRequest.RollCallReq; import com.baiye.modules.telemarkting.service.RollCallService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -34,37 +32,38 @@ public class RollCallServiceImpl implements RollCallService { private CallClueRepository callClueRepository; @Resource private SourceClueClient sourceClueClient; - @Resource - private RollCallReq rollCallReq; + /* @Resource + private RollCallReq rollCallReq;*/ @Override - public CommonResponse rollCallReq(DoubleCallReqDTO doubleCallReq) { + public CommonResponse rollCallReq(TelephoneCallReqDTO telephoneCallReqDTO) { String requestId = RandomUtil.randomString(10); - doubleCallReq.setRequestId(requestId); + telephoneCallReqDTO.setRequestId(requestId); // Clue body = sourceClueClient.queryDetails(Long.parseLong(doubleCallReq.getUserData())).getBody(); // if (ObjectUtil.isNull(body) || StrUtil.isEmpty(body.getNid())) { // return CommonResponse.createByErrorMessage("未获取到号码"); // } // doubleCallReq.setTelB(body.getNid()); - doubleCallReq.setTelB("13003658692"); - String sessionId = rollCallReq.startReq(doubleCallReq); + telephoneCallReqDTO.setTelB("13003658692"); + // TODO sessionId not setting + String sessionId = ""; log.info("=============================sessionId {}", sessionId); if (StrUtil.isNotBlank(sessionId)) { AllCallInfo allCallInfo = new AllCallInfo(); allCallInfo.setSessionId(sessionId); allCallInfo.setRequestId(requestId); - allCallInfo.setClueId(Long.parseLong(doubleCallReq.getUserData())); - allCallInfo.setMemberId(doubleCallReq.getMemberId()); + allCallInfo.setClueId(Long.parseLong(telephoneCallReqDTO.getUserData())); + allCallInfo.setMemberId(telephoneCallReqDTO.getMemberId()); allCallInfo.setStatus(DefaultNumberConstants.ONE_NUMBER); allCallInfo.setType(DefaultNumberConstants.ONE_NUMBER); allCallInfo.setRecordFlag(DefaultNumberConstants.ZERO_NUMBER); CallClueInfo clueInfo = new CallClueInfo(); - clueInfo.setClueId(Long.parseLong(doubleCallReq.getUserData())); - clueInfo.setTeamId(doubleCallReq.getTeamId()); - clueInfo.setMemberId(doubleCallReq.getMemberId()); + clueInfo.setClueId(Long.parseLong(telephoneCallReqDTO.getUserData())); + clueInfo.setTeamId(telephoneCallReqDTO.getTeamId()); + clueInfo.setMemberId(telephoneCallReqDTO.getMemberId()); clueInfo.setStatus(DefaultNumberConstants.ONE_NUMBER); - clueInfo.setTaskId(doubleCallReq.getTaskId()); + clueInfo.setTaskId(telephoneCallReqDTO.getTaskId()); allCallInfoRepository.save(allCallInfo); callClueRepository.save(clueInfo); diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/DoubleCallServiceImpl.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/TelephoneCallServiceImpl.java similarity index 67% rename from manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/DoubleCallServiceImpl.java rename to manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/TelephoneCallServiceImpl.java index 5a030867..b5d9f1dc 100644 --- a/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/DoubleCallServiceImpl.java +++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/telemarkting/service/impl/TelephoneCallServiceImpl.java @@ -2,6 +2,7 @@ package com.baiye.modules.telemarkting.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; @@ -14,14 +15,16 @@ import com.baiye.modules.telemarkting.dao.AllCallInfoRepository; import com.baiye.modules.telemarkting.dao.CallClueRepository; import com.baiye.modules.telemarkting.entity.AllCallInfo; import com.baiye.modules.telemarkting.entity.CallClueInfo; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallBackDTO; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallBackStatusDTO; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallReqDTO; -import com.baiye.modules.telemarkting.entity.dto.DoubleCallStopDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallBackDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallBackStatusDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallReqDTO; +import com.baiye.modules.telemarkting.entity.dto.TelephoneCallStopDTO; import com.baiye.modules.telemarkting.entity.vo.CallRecordsVO; +import com.baiye.modules.telemarkting.httpRequest.AxbRequest; import com.baiye.modules.telemarkting.httpRequest.DoubleCallReq; -import com.baiye.modules.telemarkting.service.DoubleCallService; +import com.baiye.modules.telemarkting.service.TelephoneCallService; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -37,9 +40,14 @@ import java.util.Objects; */ @Service @Slf4j -public class DoubleCallServiceImpl implements DoubleCallService { +public class TelephoneCallServiceImpl implements TelephoneCallService { + + @Resource + private AxbRequest axbRequest; + @Resource private DoubleCallReq doubleCallReq; + @Resource private AllCallInfoRepository allCallInfoRepository; @Resource @@ -48,7 +56,7 @@ public class DoubleCallServiceImpl implements DoubleCallService { private SourceClueClient sourceClueClient; @Override - public CommonResponse doubleCallReq(DoubleCallReqDTO doubleCallReq) { + public CommonResponse doubleCallReq(TelephoneCallReqDTO doubleCallReq) { String requestId = RandomUtil.randomString(10); doubleCallReq.setRequestId(requestId); Clue body = sourceClueClient.queryDetails(Long.parseLong(doubleCallReq.getUserData())).getBody(); @@ -90,7 +98,7 @@ public class DoubleCallServiceImpl implements DoubleCallService { } @Override - public void doubleCallBack(DoubleCallBackDTO doubleCallBack) { + public void doubleCallBack(TelephoneCallBackDTO doubleCallBack) { String sessionId = doubleCallBack.getSessionId(); AllCallInfo allCallInfo = allCallInfoRepository.findBySessionId(sessionId); if (ObjectUtil.isNotEmpty(allCallInfo)) { @@ -105,7 +113,7 @@ public class DoubleCallServiceImpl implements DoubleCallService { @Override @Transactional(rollbackFor = Exception.class) - public void doubleCallBackStatus(DoubleCallBackStatusDTO doubleCallBackStatus) { + public void doubleCallBackStatus(TelephoneCallBackStatusDTO doubleCallBackStatus) { String sessionId = doubleCallBackStatus.getSessionId(); long userDate = Long.parseLong(doubleCallBackStatus.getUserData()); @@ -118,8 +126,8 @@ public class DoubleCallServiceImpl implements DoubleCallService { } @Override - public CommonResponse doubleCallStop(DoubleCallStopDTO doubleCallStopDTO) { - if (doubleCallReq.stopReq(doubleCallStopDTO)) { + public CommonResponse doubleCallStop(TelephoneCallStopDTO telephoneCallStopDTO) { + if (doubleCallReq.stopReq(telephoneCallStopDTO)) { return CommonResponse.createBySuccess(); } return CommonResponse.createByError(); @@ -143,4 +151,35 @@ public class DoubleCallServiceImpl implements DoubleCallService { list.sort(Comparator.comparing(CallRecordsVO::getCreateTime)); return CommonResponse.createBySuccess(list); } + + @Override + public CommonResponse axbDialNumber(TelephoneCallReqDTO doubleCallReq) { + long originalNumber = Long.parseLong(doubleCallReq.getUserData()); + ResponseEntity body = sourceClueClient.queryDetails(originalNumber); + if (ObjectUtil.isNotNull(body) && ObjectUtil.isNotNull(body.getBody())) { + String nid = Objects.requireNonNull(body.getBody()).getNid(); + String randomString = RandomUtil.randomString(DefaultNumberConstants.TEN_NUMBER); + doubleCallReq.setRequestId(randomString); + doubleCallReq.setTelB(nid); + String sessionId = axbRequest.call(doubleCallReq); + if (CharSequenceUtil.isNotBlank(sessionId)) { + AllCallInfo allCallInfo = new AllCallInfo(); + allCallInfo.setSessionId(sessionId); + allCallInfo.setRequestId(randomString); + allCallInfo.setClueId(originalNumber); + allCallInfo.setMemberId(doubleCallReq.getMemberId()); + allCallInfo.setStatus(DefaultNumberConstants.ONE_NUMBER); + CallClueInfo clueInfo = new CallClueInfo(); + clueInfo.setClueId(originalNumber); + clueInfo.setTeamId(doubleCallReq.getTeamId()); + clueInfo.setMemberId(doubleCallReq.getMemberId()); + clueInfo.setStatus(DefaultNumberConstants.ONE_NUMBER); + clueInfo.setTaskId(doubleCallReq.getTaskId()); + allCallInfoRepository.save(allCallInfo); + callClueRepository.save(clueInfo); + return CommonResponse.createBySuccess(sessionId); + } + } + return CommonResponse.createByError(); + } } diff --git a/manage/ad-platform-management/src/main/resources/config/application-dev.yml b/manage/ad-platform-management/src/main/resources/config/application-dev.yml index be21ca2a..7e604612 100644 --- a/manage/ad-platform-management/src/main/resources/config/application-dev.yml +++ b/manage/ad-platform-management/src/main/resources/config/application-dev.yml @@ -110,6 +110,26 @@ file: avatarMaxSize: 5 +#配置双呼参数 +double: + call: + reqUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Hw/CallBack + appid: app1 + cdrUrl: http://118.178.137.129:8866/api/back/cdrUrl + statusUrl: http://118.178.137.129:8866/api/back/status + stopUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Hw/CallBackStop + +#axb地址 +axb: + call: + appid: app1 + cdrUrl: http://118.178.137.129:8866/api/back/cdrUrl + statusUrl: http://118.178.137.129:8866/api/back/status + bingUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Calls/AxbBinding + unBingUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Calls/AxbUnBinding + + + #ribbon: # #建立连接超时时间 # ConnectTimeout: 50000 diff --git a/manage/ad-platform-management/src/main/resources/config/application-prod.yml b/manage/ad-platform-management/src/main/resources/config/application-prod.yml index e66b085c..8c57bf37 100644 --- a/manage/ad-platform-management/src/main/resources/config/application-prod.yml +++ b/manage/ad-platform-management/src/main/resources/config/application-prod.yml @@ -115,3 +115,23 @@ file: # ConnectTimeout: 50000 # #建立连接之后,读取响应资源超时时间 # ReadTimeout: 50000 + + +#配置呼出参数 +double: + call: + reqUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Hw/CallBack + appid: app1 + cdrUrl: https://mm.tuoz.net/api/back/cdrUrl + statusUrl: https://mm.tuoz.net/api/back/status + stopUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Hw/CallBackStop + + +#axb地址 +axb: + call: + appid: app1 + cdrUrl: https://mm.tuoz.net/api/back/cdrUrl + statusUrl: https://mm.tuoz.net/api/back/status + bingUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Calls/AxbBinding + unBingUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Calls/AxbUnBinding diff --git a/manage/ad-platform-management/src/main/resources/config/application.yml b/manage/ad-platform-management/src/main/resources/config/application.yml index acd6693a..7bb389d4 100644 --- a/manage/ad-platform-management/src/main/resources/config/application.yml +++ b/manage/ad-platform-management/src/main/resources/config/application.yml @@ -59,15 +59,7 @@ code: rsa: private_key: MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKLhn7fPqFSK9z3Ao4yFFisDO8YV1dOn1I3wpwj1IIu3Z7vkaHyynBf7eF8fo86EQRvnJIo3jVO2jUw5Lor2OYcZVK72oxD5LIULVYI/eXJogzd1C+tJ5IHC7dmTJ37qfjP9VV3mDWlsRusdCoVPE2xUI13H4bPOCE4DyyeldXlFAgMBAAECgYBakWx3D5+AyvipPKl0JDhsWFLvVQrdss+M0Uh/wZWEOsoSfvHejI4hA7It6nDyDzYI5uC5fiQ2bSZqQM1xdXIMmq4F0WM2+ni4Q/bYbaLt9UDGs6GXwHcg3gOTBJoSJq0SZxBpflxbfVOj63ITehTl51q0FvaedxWl63hf6bikQQJBANT3s1usMZmubYxQPLrBeK1mcXG1JxwKDK6n7bJnlBeZy1GCUZ7bwBgr32gRvUXtgqrzT3IyZlld5cUScX601TUCQQDDyxVAPExwbpxD0Ao7CZE9LRYC8YaMQ46NENqaIhnmhMa4vqoTky8t2nLZITmk0EqecTBt/Io+37+X/KCHD+XRAkAraGmIb+qUNndhuCEIt9KPFWheEtxr3KiFGPlb+by3qsNEU9mrFYNr6dVZcvQvQp/1lC5HSnqOEJN6va2gc99ZAkEAnYtF+EAMydNXDgHSmZqjMXSb55Zsy2R4ye2r2KZj7Ocd9/4DYGjoZ58FFs3zUjkAMemmLHouy1TDGAsBKGyUYQJBAJ1io1DxuejCE+sN/bu4Y2S7oQ2Mpfjh7jRYGruDzhdqVnnLxf0spaqJZ5HekQz3uMpkQQGkcN1MZZcRpoWJ7XU= -#配置双呼参数 -double: - call: - reqUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Hw/CallBack - appid: app1 - companyName: 杭州百业互联科技有限公司 - cdrUrl: http://118.178.137.129:8866/api/back/cdrUrl - statusUrl: http://118.178.137.129:8866/api/back/status - stopUrl: http://ax.hzdaba.cn/callback/Accounts/dbby_hangzhoubaiyehl/Hw/CallBackStop + #配置短信参数 sms: diff --git a/services/ad-platform-source/src/main/java/com/baiye/module/service/impl/ClueServiceImpl.java b/services/ad-platform-source/src/main/java/com/baiye/module/service/impl/ClueServiceImpl.java index 83e23cb7..1d37bdfc 100644 --- a/services/ad-platform-source/src/main/java/com/baiye/module/service/impl/ClueServiceImpl.java +++ b/services/ad-platform-source/src/main/java/com/baiye/module/service/impl/ClueServiceImpl.java @@ -169,11 +169,11 @@ public class ClueServiceImpl implements ClueService { if (clueQueryCriteria.getId() != null) { for (ClueDto clueDto : clueDtoList) { //循环查库,ID查询只一次循环 -// String organizeStr = organizeClient.query(clueDto.getOrganizeId()).getBody().toString(); -// String str = organizeStr.replaceAll("=", ":"); -// JSONArray jsonArray = JSONUtil.parseArray(str); -// JSONObject jsonObject = JSONUtil.parseObj(jsonArray.get(0)); -// clueDto.setCallMode((Integer)jsonObject.get("callMode")); + String organizeStr = organizeClient.query(clueDto.getOrganizeId()).getBody().toString(); + String str = organizeStr.replaceAll("=", ":"); + JSONArray jsonArray = JSONUtil.parseArray(str); + JSONObject jsonObject = JSONUtil.parseObj(jsonArray.get(0)); + clueDto.setCallMode((Integer)jsonObject.get("callMode")); Map> mapList = organizeClient.getLabel(clueDto.getTaskId(), clueDto.getOrganizeId()).getBody(); clueDto.setBaseLabel(mapList.get("baseLabel")); clueDto.setOrganizeLabel(mapList.get("organizeLabel"));