2024年8月11日 新增虚拟号码接口
This commit is contained in:
parent
0cc360ab17
commit
a9b6895d42
|
@ -0,0 +1,165 @@
|
||||||
|
package com.sqx.interfaces.virtualphone;
|
||||||
|
|
||||||
|
import com.sqx.modules.common.controller.CommonController;
|
||||||
|
import com.sqx.modules.common.entity.CommonInfo;
|
||||||
|
import com.sqx.modules.common.service.CommonInfoService;
|
||||||
|
import com.winnerlook.model.*;
|
||||||
|
import com.winnerlook.service.VoiceSender;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName VirtualPhoneMain
|
||||||
|
* @Description TODO
|
||||||
|
* @Author bai
|
||||||
|
* @Date 2024/8/9 上午9:12
|
||||||
|
* @Version 1.0
|
||||||
|
**/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class VirtualPhoneMain {
|
||||||
|
|
||||||
|
private static String accountId;
|
||||||
|
private static String token;
|
||||||
|
// private static final String accountId = "314900";
|
||||||
|
// private static String token = "4713212ccf7242f38a1d7def5c3de813";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CommonInfoService commonService;
|
||||||
|
|
||||||
|
public void initToken(){
|
||||||
|
if(accountId == null){
|
||||||
|
CommonInfo data = commonService.findOne(461);
|
||||||
|
accountId = data.getValue();
|
||||||
|
}
|
||||||
|
if(token == null){
|
||||||
|
CommonInfo data = commonService.findOne(462);
|
||||||
|
token = data.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提前绑定小号号码、号码 A 的关系,任意主叫呼叫小号即可与 A 通话,可以提前指定号码 B。
|
||||||
|
* @param phone 绑定的手机号
|
||||||
|
* @param name 绑定手机号号主姓名
|
||||||
|
* @param idCard 绑定手机号号主身份证号
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public VoiceResponseResult insertVirtualPhoneAxN(String phone, String name, String idCard) throws Exception {
|
||||||
|
initToken();
|
||||||
|
PrivacyBindBodyAx privacyBindBodyAx = new PrivacyBindBodyAx();
|
||||||
|
privacyBindBodyAx.setBindNumberA(phone);
|
||||||
|
//绑定人姓名
|
||||||
|
privacyBindBodyAx.setCalleeName(name);
|
||||||
|
//绑定人身份证号
|
||||||
|
privacyBindBodyAx.setCalleeId(idCard);
|
||||||
|
privacyBindBodyAx.setMode(1);
|
||||||
|
privacyBindBodyAx.setMaxBindingTime(3 * 60);//绑定3分钟
|
||||||
|
|
||||||
|
VoiceResponseResult res = VoiceSender.httpPrivacyBindAx(privacyBindBodyAx, accountId,token);
|
||||||
|
|
||||||
|
log.info("AxN绑定返回值为:{}",res);
|
||||||
|
if(StringUtils.equals(res.getResult(),"000000")){
|
||||||
|
//绑定成功
|
||||||
|
log.info("AxN绑定成功,小号为:{}",res.getMiddleNumber());
|
||||||
|
}else{
|
||||||
|
log.info("AxN绑定失败,{}",res.getMessage());
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解绑AxN模式绑定的小号
|
||||||
|
* @param middleNumber 绑定的小号
|
||||||
|
* @param bindNumberA 绑定的真实手机号
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public VoiceResponseResult unbindInsertVirtualPhoneAxN(String middleNumber, String bindNumberA) throws Exception {
|
||||||
|
initToken();
|
||||||
|
return unbindInsertVirtualPhone(middleNumber, bindNumberA, null, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提前绑定小号号码、号码 A、号码 B 的关系,A、B 呼叫小号即可互相通话。
|
||||||
|
* @param phoneA 号码A
|
||||||
|
* @param phoneB 号码B
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public VoiceResponseResult insertVirtualPhoneAxB(String phoneA, String phoneB) throws Exception {
|
||||||
|
initToken();
|
||||||
|
PrivacyBindBodyAxb privacyBindBodyAxb = new PrivacyBindBodyAxb();
|
||||||
|
privacyBindBodyAxb.setBindNumberA(phoneA);
|
||||||
|
privacyBindBodyAxb.setBindNumberB(phoneB);
|
||||||
|
|
||||||
|
privacyBindBodyAxb.setMaxBindingTime(3 * 60);//绑定3分钟
|
||||||
|
VoiceResponseResult res = VoiceSender.httpPrivacyBindAxb(privacyBindBodyAxb, accountId,token);
|
||||||
|
log.info("AxB绑定返回值为:{}",res);
|
||||||
|
if(StringUtils.equals(res.getResult(),"000000")){
|
||||||
|
//绑定成功
|
||||||
|
log.info("AxB绑定成功,小号为:{}",res.getMiddleNumber());
|
||||||
|
}else{
|
||||||
|
log.info("AxB绑定失败,{}",res.getMessage());
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 解绑AxN模式绑定的小号
|
||||||
|
* @param middleNumber 绑定的小号
|
||||||
|
* @param bindNumberA 绑定的真实手机号A
|
||||||
|
* @param bindNumberB 绑定的真实手机号B
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public VoiceResponseResult unbindInsertVirtualPhoneAxB(String middleNumber, String bindNumberA, String bindNumberB) throws Exception {
|
||||||
|
initToken();
|
||||||
|
return unbindInsertVirtualPhone(middleNumber, bindNumberA, bindNumberB, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param middleNumber 小号号码 必须传
|
||||||
|
* @param bindNumberA 绑定小号的号码 A 必须传
|
||||||
|
* @param bindNumberB 绑定小号的号码 B
|
||||||
|
* @param mode 解绑对应的模式 0: AXB; 1: AXN; 2: AX; 3: AXx; 4: AXyb 模式 5: XYB 模式手工绑定 必须传
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public VoiceResponseResult unbindInsertVirtualPhone(String middleNumber, String bindNumberA, String bindNumberB, Integer mode) throws Exception {
|
||||||
|
initToken();
|
||||||
|
PrivacyUnbindBody privacyUnbindBody = new PrivacyUnbindBody();
|
||||||
|
privacyUnbindBody.setMiddleNumber(middleNumber);
|
||||||
|
privacyUnbindBody.setBindNumberA(bindNumberA);
|
||||||
|
privacyUnbindBody.setBindNumberB(bindNumberB);
|
||||||
|
privacyUnbindBody.setMode(mode);
|
||||||
|
|
||||||
|
VoiceResponseResult res = VoiceSender.httpPrivacyUnbind(privacyUnbindBody, accountId,token);
|
||||||
|
|
||||||
|
log.info("解除绑定返回值为:{}",res);
|
||||||
|
if(StringUtils.equals(res.getResult(),"000000")){
|
||||||
|
//绑定成功
|
||||||
|
log.info("解除绑定成功");
|
||||||
|
}else{
|
||||||
|
log.info("解除绑定失败");
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
//AxN绑定
|
||||||
|
//VirtualPhoneMain.insertVirtualPhoneAxN("13080012853","白玉鑫","220182199610136610");
|
||||||
|
//AxB绑定
|
||||||
|
//VirtualPhoneMain.insertVirtualPhoneAxB("13080012853","15124691957");
|
||||||
|
//解绑
|
||||||
|
//VirtualPhoneMain.unbindInsertVirtualPhoneAxN("043184334838","13080012853");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,35 +1,33 @@
|
||||||
package com.sqx.modules.app.controller.app;
|
package com.sqx.modules.app.controller.app;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.aliyun.dyplsapi20170525.models.BindAxnResponse;
|
import com.aliyun.dyplsapi20170525.models.BindAxnResponse;
|
||||||
import com.aliyun.dyplsapi20170525.models.BindAxnResponseBody;
|
import com.aliyun.dyplsapi20170525.models.BindAxnResponseBody;
|
||||||
import com.aliyun.dyplsapi20170525.models.UpdateSubscriptionResponse;
|
import com.aliyun.dyplsapi20170525.models.UpdateSubscriptionResponse;
|
||||||
import com.aliyun.dyplsapi20170525.models.UpdateSubscriptionResponseBody;
|
import com.aliyun.dyplsapi20170525.models.UpdateSubscriptionResponseBody;
|
||||||
import com.aliyuncs.DefaultAcsClient;
|
|
||||||
import com.aliyuncs.IAcsClient;
|
|
||||||
import com.aliyuncs.profile.DefaultProfile;
|
|
||||||
import com.aliyun.tea.TeaException;
|
import com.aliyun.tea.TeaException;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.sqx.common.utils.DateUtils;
|
import com.sqx.common.utils.DateUtils;
|
||||||
import com.sqx.common.utils.Result;
|
import com.sqx.common.utils.Result;
|
||||||
|
import com.sqx.common.utils.Result2;
|
||||||
|
import com.sqx.interfaces.virtualphone.VirtualPhoneMain;
|
||||||
import com.sqx.modules.app.annotation.Login;
|
import com.sqx.modules.app.annotation.Login;
|
||||||
import com.sqx.modules.app.annotation.LoginUser;
|
import com.sqx.modules.app.annotation.LoginUser;
|
||||||
import com.sqx.modules.app.dao.UserCertificationDao;
|
|
||||||
import com.sqx.modules.app.entity.UserCertification;
|
|
||||||
import com.sqx.modules.app.entity.UserEntity;
|
import com.sqx.modules.app.entity.UserEntity;
|
||||||
import com.sqx.modules.app.entity.UserMoney;
|
import com.sqx.modules.app.entity.UserMoney;
|
||||||
import com.sqx.modules.app.service.AppService;
|
import com.sqx.modules.app.service.AppService;
|
||||||
import com.sqx.modules.app.service.UserMoneyService;
|
import com.sqx.modules.app.service.UserMoneyService;
|
||||||
import com.sqx.modules.app.service.UserService;
|
import com.sqx.modules.app.service.UserService;
|
||||||
import com.sqx.modules.artificer.entity.Artificer;
|
import com.sqx.modules.artificer.entity.Artificer;
|
||||||
|
import com.sqx.modules.artificer.entity.Certification;
|
||||||
import com.sqx.modules.artificer.service.ArtificerService;
|
import com.sqx.modules.artificer.service.ArtificerService;
|
||||||
|
import com.sqx.modules.artificer.service.RealNameService;
|
||||||
import com.sqx.modules.common.service.CommonInfoService;
|
import com.sqx.modules.common.service.CommonInfoService;
|
||||||
import com.sqx.modules.coupon.entity.CouponUser;
|
import com.sqx.modules.coupon.entity.CouponUser;
|
||||||
import com.sqx.modules.coupon.service.CouponUserService;
|
import com.sqx.modules.coupon.service.CouponUserService;
|
||||||
import com.sqx.modules.message.dao.MessageInfoDao;
|
import com.sqx.modules.message.dao.MessageInfoDao;
|
||||||
import com.sqx.modules.message.entity.MessageInfo;
|
import com.sqx.modules.message.entity.MessageInfo;
|
||||||
import com.sqx.modules.utils.MD5Util;
|
import com.winnerlook.model.VoiceResponseResult;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -39,8 +37,6 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APP登录授权
|
* APP登录授权
|
||||||
|
@ -65,6 +61,10 @@ public class AppController {
|
||||||
private CouponUserService couponUserService;
|
private CouponUserService couponUserService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ArtificerService artificerService;
|
private ArtificerService artificerService;
|
||||||
|
@Autowired
|
||||||
|
private VirtualPhoneMain virtualPhoneMain;
|
||||||
|
@Autowired
|
||||||
|
private RealNameService realNameService;
|
||||||
|
|
||||||
@Login
|
@Login
|
||||||
@ApiOperation("生成虚拟号码")
|
@ApiOperation("生成虚拟号码")
|
||||||
|
@ -148,6 +148,50 @@ public class AppController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Login
|
||||||
|
@ApiOperation("生成虚拟号码,AxN,只绑定技师手机号,客户拨打返回的小号即可联系到技师,绑定时间为3分钟")
|
||||||
|
@GetMapping("/insertVirtualPhoneAxN")
|
||||||
|
public Result2<?> insertVirtualPhoneAxN(String phone) throws Exception {
|
||||||
|
Result2<VoiceResponseResult> res = new Result2<>();
|
||||||
|
//查找技师绑定的身份证号和姓名
|
||||||
|
Certification certification = realNameService.getOne(new QueryWrapper<Certification>().eq("phone", phone).orderByDesc("update_time").last("limit 1"));
|
||||||
|
if(certification == null) {
|
||||||
|
VoiceResponseResult r = new VoiceResponseResult();
|
||||||
|
r.setResult("500000");//自定义错误
|
||||||
|
r.setMessage("未找到技师实名信息!");
|
||||||
|
res.setData(r);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
res.setData(virtualPhoneMain.insertVirtualPhoneAxN(phone,certification.getName(),certification.getIdNumber()));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Login
|
||||||
|
@ApiOperation("生成虚拟号码,AxB,绑定技师手机号A,绑定客户手机号B,双方可互相拨打,其他账号无法拨打,绑定时间为3分钟")
|
||||||
|
@GetMapping("/insertVirtualPhoneAxB")
|
||||||
|
public Result2<VoiceResponseResult> insertVirtualPhoneAxB(String phoneA, String phoneB) throws Exception {
|
||||||
|
Result2<VoiceResponseResult> res = new Result2<>();
|
||||||
|
res.setData(virtualPhoneMain.insertVirtualPhoneAxB(phoneA,phoneB));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Login
|
||||||
|
@ApiOperation("解绑小号,AxN,需要当时绑定的小号,和绑定的手机号")
|
||||||
|
@GetMapping("/unbindInsertVirtualPhoneAxN")
|
||||||
|
public Result2<VoiceResponseResult> unbindInsertVirtualPhoneAxN(String middleNumber, String phoneA) throws Exception {
|
||||||
|
Result2<VoiceResponseResult> res = new Result2<>();
|
||||||
|
res.setData(virtualPhoneMain.unbindInsertVirtualPhoneAxN(middleNumber, phoneA));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Login
|
||||||
|
@ApiOperation("解绑小号,AxB,需要当时绑定的小号,绑定的手机号A和绑定的手机号B")
|
||||||
|
@GetMapping("/unbindInsertVirtualPhoneAxB")
|
||||||
|
public Result2<VoiceResponseResult> unbindInsertVirtualPhoneAxB(String middleNumber, String phoneA, String phoneB) throws Exception {
|
||||||
|
Result2<VoiceResponseResult> res = new Result2<>();
|
||||||
|
res.setData(virtualPhoneMain.unbindInsertVirtualPhoneAxB(middleNumber, phoneA, phoneB));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
@Login
|
@Login
|
||||||
@RequestMapping(value = "/updatePwd", method = RequestMethod.POST)
|
@RequestMapping(value = "/updatePwd", method = RequestMethod.POST)
|
||||||
|
|
Loading…
Reference in New Issue