Commit a8e75c7c by 陈思聪

商标交易订单-阿里双呼对接

parent 4e4e2803
...@@ -10,6 +10,8 @@ class TradetransferCtl extends CtlBase { ...@@ -10,6 +10,8 @@ class TradetransferCtl extends CtlBase {
constructor() { constructor() {
super("transfer", CtlBase.getServiceName(TradetransferCtl)); super("transfer", CtlBase.getServiceName(TradetransferCtl));
this.postfile = system.getObject("util.restClient"); this.postfile = system.getObject("util.restClient");
this.aliApiClient = system.getObject('util.aliApiClient');
} }
// { // {
// tid:"xxxx", // tid:"xxxx",
...@@ -20,11 +22,113 @@ class TradetransferCtl extends CtlBase { ...@@ -20,11 +22,113 @@ class TradetransferCtl extends CtlBase {
// "content":"" // "content":""
// } // }
// } // }
async updatePhone(p,q,req){
if(!p.id){
return system.getResultFail(-1,"id不能为空");
}
if(!p.phone){
return system.getResultFail(-1,"手机号不能为空");
}
if(p.phone.length!=11){
return system.getResultFail(-1,"手机号长度必须为11位");
}
if(!p.phone.startsWith("1")){
return system.getResultFail(-1,"不是有效的手机号");
}
try{
var traninfo = await this.service.findById(p.id);
if(traninfo){
if(traninfo.mobile&&traninfo.mobile.length==11){
return system.getResultFail(-1,"手机号已存在,不允许修改");
}
var res = await this.service.updatePhone(p.id,p.phone);
return system.getResult(res);
}else{
return system.getResultFail(-1,"服务单为空");
}
}catch (e) {
console.log(e)
return system.getResultFail(-1,"修改手机号异常");
}
}
async aliDoubleCall(p,q,req){
if(!p.aliBizId){
return system.getResultFail(-1,"服务单号不能为空");
}
// 1.获取可用外呼号码列表
var queryAvailabelPhoneResult = await this.aliApiClient.queryAvailabelNumbers();
if(queryAvailabelPhoneResult.status == 0){
if(!queryAvailabelPhoneResult.data||queryAvailabelPhoneResult.data.length==0){
console.log('获取到的可用外呼列表为空')
return system.getResultFail(-1,"呼叫失败。获取到的可用外呼列表为空");
}
console.log(queryAvailabelPhoneResult.data)
// // 2.发起双呼
var startCallParams = {
"bizType": "TM_TRADE",
"skillType":2,
"bizId":p.aliBizId,
"caller":settings.aliDoubleCallCaller(),
"callCenterNumber":queryAvailabelPhoneResult.data[0]
};
var startCallResult = await this.aliApiClient.startBackToBackCall(startCallParams);
if(startCallResult.status == 0){
return system.getResultSuccess(null,"呼叫成功");
}else{
return system.getResultFail(-1,"呼叫失败,"+startCallResult.msg);
}
}else{
console.log('获取可用外呼号码列表失败。原因:',queryAvailabelPhoneResult.msg)
return system.getResultFail(-1,"获取可用外呼号码列表失败。原因:"+queryAvailabelPhoneResult.msg);
}
// // 1.获取可用外呼号码列表
// var rtn = await this.execClient.execPostWithAppkey({
// "actionType": "queryAvailabelNumbers",
// "actionBody": {
// "bizType": "TM_TRADE"
// }
// }, settings.centerChannelUrl()+"api/action/aliyunapi/springBoard");
// if(rtn){
// var result = JSON.parse(rtn.stdout)
// if(result.status ==0){
// // 可用外呼号码不为空
// if(result.data&&result.data.length>0){
// var availabelPhoneNumber = result.data[0]
// console.log(availabelPhoneNumber)
//
// // 2.发起双呼
//
//
//
// }else{
// console.log('获取可用外呼号码列表为空',rtn.stdout)
// return system.getResultFail(-1,"未获取到可用外呼号码列表。");
// }
// }else{
// console.log('获取可用外呼号码列表失败。原因:',rtn.stdout)
// return system.getResultFail(-1,"获取可用外呼号码列表失败,原因:"+rtn.stdout);
// }
// }else{
// console.log('获取可用外呼号码列表失败,请求未响应',rtn)
// return system.getResultFail(-1,"获取可用外呼号码列表失败,请求未响应");
// }
}
async track(p,q,req){ async track(p,q,req){
console.log(p) console.log(p)
//获取当前日期 //获取当前日期
//获取当前时间 //获取当前时间
p.logdata.log.dateStr=new Date().toLocaleDateString() p.logdata.log.dateStr=new Date().toLocaleDateString()
p.logdata.log.timeStr=new Date().toLocaleTimeString() p.logdata.log.timeStr=new Date().toLocaleTimeString()
p.logdata.log.yw=req.session.user.userName p.logdata.log.yw=req.session.user.userName
...@@ -146,7 +250,7 @@ class TradetransferCtl extends CtlBase { ...@@ -146,7 +250,7 @@ class TradetransferCtl extends CtlBase {
async updateCommunicationLog(p, q, req){ async updateCommunicationLog(p, q, req){
var self = this; var self = this;
if(!p.ali_bizid){ if(!p.ali_bizid){
return system.getResult(null, "请求异常"); return system.getResult(null, "请求异常");
} }
try { try {
var rst = await self.service.writecommunicationlog(p); var rst = await self.service.writecommunicationlog(p);
......
...@@ -11,6 +11,13 @@ class TradetransferService extends ServiceBase { ...@@ -11,6 +11,13 @@ class TradetransferService extends ServiceBase {
this.dingClient = system.getObject("util.dingClient"); this.dingClient = system.getObject("util.dingClient");
} }
async updatePhone(id,mobile){
var self = this;
return await this.db.transaction(async function (t) {
var updateRes = await self.dao.model.update({"mobile":mobile},{where:{id:id},transaction:t});
return updateRes;
});
}
//订单创建 //订单创建
async createtransfer(obj) { async createtransfer(obj) {
if (!obj.BizId) { if (!obj.BizId) {
......
var system = require("../system")
var RPCClient = require('@alicloud/pop-core').RPCClient; var RPCClient = require('@alicloud/pop-core').RPCClient;
class AliApiClient { class AliApiClient {
...@@ -37,6 +37,74 @@ class AliApiClient { ...@@ -37,6 +37,74 @@ class AliApiClient {
}); });
} }
//-----------阿里云商标交易服务单 双呼能力接口接入------start--------chensicong----2022.02.24----------------------
// 商标交易(商标优选) 双呼客户端
getAliDoubleCallClientForTMTRADE() {
return new RPCClient({
accessKeyId: 'LTAI4FmyipY1wuLHjLhMWiPa', // 对应的aliuid 是 1525276744866147
accessKeySecret: 'hp4FF18IDCSym1prqzxrAjnnhNH3ju',
endpoint: "https://companyreg.aliyuncs.com",
apiVersion: "2020-03-06"
});
}
// 获取可用外呼号码列表
async queryAvailabelNumbers(){
let res = null;
try{
console.log(`开始调用阿里云-获取商标交易可用外呼号码列表接口。`)
let reqAliclient = this.getAliDoubleCallClientForTMTRADE()
let obj = { bizType:"TM_TRADE" }
res = await reqAliclient.request("QueryAvailableNumbers", obj, {
timeout: 3000, // default 3000 ms
formatAction: true, // default true, format the action to Action
formatParams: true, // default true, format the parameter name to first letter upper case
method: 'POST', // set the http method, default is GET
headers: {}, // set the http request headers
});
console.log(`结束调用阿里云-获取商标交易可用外呼号码列表接口。结果=${JSON.stringify(res)}`)
return system.getResultSuccess(res.Data||res.data);
}catch (e){
console.log(`调用异常:阿里云-获取商标交易可用外呼号码列表接口。结果=${JSON.stringify(res)},异常信息=${e.stack}`)
return system.getResultFail(-200, "api调用出现异常,error:" + e.stack);
}
}
/**
* 发起双呼
* @param reqbody
* @returns {Promise<{msg: *, data: *, status: *}|{msg: *, data, status: number}>}
*/
async startBackToBackCall(reqbody){
let res = null;
try{
console.log(`开始调用阿里云-发起双呼接口。参数reqbody`,reqbody)
if(!reqbody.bizType){
return system.getResultFail(-200, "bizType不能为空");
}
let reqAliclient = this.getAliDoubleCallClientForTMTRADE()
res = await reqAliclient.request("StartBackToBackCall",reqbody, {
timeout: 10000, // default 3000 ms 2020 0916 lin修改3000为10000,原因ConfirmIcpIntention BizIds 超过5条会超时
formatAction: true, // default true, format the action to Action
formatParams: true, // default true, format the parameter name to first letter upper case
method: 'POST', // set the http method, default is GET
headers: {}, // set the http request headers
});
console.log(`结束调用阿里云-发起双呼接口。参数reqbody=`,reqbody,'结果=',JSON.stringify(res))
return system.getResultSuccess(res.Data||res.data);
}catch (e){
console.log(`调用异常:阿里云-发起双呼接口。参数reqbody=`,reqbody,'结果=',JSON.stringify(res),`异常信息=${e.stack}`)
return system.getResultFail(-200, JSON.stringify(e.data));
}
}
//-----------阿里云商标交易服务单 双呼能力接口接入------end--------chensicong----2022.02.24----------------------
} }
module.exports = AliApiClient; module.exports = AliApiClient;
\ No newline at end of file
...@@ -52,6 +52,13 @@ var settings = { ...@@ -52,6 +52,13 @@ var settings = {
return "http://er.es.gongsibao.com:7200/"; return "http://er.es.gongsibao.com:7200/";
} }
}, },
aliDoubleCallCaller:function(){
if(this.env=="dev"){
return "15001304640";
}else {
return "17521131496";
}
},
apiconfig:{ apiconfig:{
opLogUrl:function(){ opLogUrl:function(){
return settings.reqEsAddr()+"bigdata_zc_op_log/_doc?pretty"; return settings.reqEsAddr()+"bigdata_zc_op_log/_doc?pretty";
......
...@@ -5,10 +5,22 @@ ...@@ -5,10 +5,22 @@
:headStyle="headStyle" :colFormatter="onColFormater" :isSingleSelect="isSingleSelect" @rowclick="onRowClick" :headStyle="headStyle" :colFormatter="onColFormater" :isSingleSelect="isSingleSelect" @rowclick="onRowClick"
@onDlgFormClick="onDlgFormClick" :validateformmethod="validateformmethod"> @onDlgFormClick="onDlgFormClick" :validateformmethod="validateformmethod">
<div slot="other2" slot-scope="s"> <div slot="other2" slot-scope="s">
<span v-if="s.row.mobile">{{s.row.mobile}}</span> <span v-if="s.row.mobile && s.row.mobile.length==11">{{s.row.mobile}}</span>
<span v-else><button @click="inputMobile(s.row)">输入号码</button></span> <span v-else><button @click="inputMobile(s.row)">输入号码</button></span>
</div> </div>
</gsb-grid2> </gsb-grid2>
<el-dialog title="手机号" :visible.sync="showEditPhoneForm" width="350px" height="350px" center>
<el-form :model="editPhoneForm" :rules="rules" ref="editPhoneForm">
<el-form-item prop="phone">
<el-input :rows="2" placeholder="请输入合法手机号" v-model.trim="editPhoneForm.phone">
</el-form-item>
</el-input>
<el-row style="text-align: right;margin-top: 20px;">
<el-button type="warning" @click="phoneFormCancelClick">取消</el-button>
<el-button type="primary" @click="phoneFormSaveClick" :loading="isPhoneSaveRunning">保存</el-button>
</el-row>
</el-form>
</el-dialog>
<el-dialog title="上传资料" :visible.sync="showUploadform" width="350px" height="350px" center> <el-dialog title="上传资料" :visible.sync="showUploadform" width="350px" height="350px" center>
<gsb-aliupload v-model="f1" @uploadsuccess="upsuccess" mtype="test"></gsb-aliupload> <gsb-aliupload v-model="f1" @uploadsuccess="upsuccess" mtype="test"></gsb-aliupload>
</el-dialog> </el-dialog>
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
isSingleSelect: false, isSingleSelect: false,
bizCode: 'mytradetransferdiliver', bizCode: 'mytradetransferdiliver',
showUploadform: false, showUploadform: false,
showEditPhoneForm: false,
f1: "", f1: "",
trackVisable:false, trackVisable:false,
trackContent:"", trackContent:"",
...@@ -14,6 +15,18 @@ ...@@ -14,6 +15,18 @@
], ],
currentRow:null, currentRow:null,
isbtnRunning:false, isbtnRunning:false,
isPhoneSaveRunning:false,
editPhoneForm:{
id:null,
phone:"",
row:null
},
rules: {
phone: [
{ required: true, message: '请输入手机号', trigger: 'blur' },
{ min: 11, max: 11, message: '手机号长度必须为11位', trigger: 'blur' }
]
}
} }
}, },
mounted: function() { mounted: function() {
...@@ -33,7 +46,46 @@ ...@@ -33,7 +46,46 @@
return cbk(); return cbk();
}, },
inputMobile(row){ inputMobile(row){
alert("input mobile..") this.showEditPhoneForm = true;
this.editPhoneForm.id = row.id;
if(row.mobile&&row.mobile.length==11){
this.editPhoneForm.phone = row.mobile;
}else{
this.editPhoneForm.phone = null
}
this.editPhoneForm.row = row;
},
phoneFormCancelClick(){
this.showEditPhoneForm = false;
this.editPhoneForm.id = null;
this.editPhoneForm.phone = null;
this.editPhoneForm.row = null;
},
phoneFormSaveClick(){
this.$refs["editPhoneForm"].validate((valid) => {
if (valid) {
this.$root.postReq("/web/transfer/tradetransferCtl/updatePhone", {
id:this.editPhoneForm.id,
phone:this.editPhoneForm.phone
}).then((d)=> {
if (d.status > -1) {
this.$message({
type: 'success',
message: '修改手机号成功!'
});
this.editPhoneForm.row.mobile = this.editPhoneForm.phone;
this.showEditPhoneForm = false;
this.editPhoneForm.id = null;
this.editPhoneForm.phone = null;
this.editPhoneForm.row = null;
}else{
this.$message.warning("修改手机号失败");
}
})
} else {
return false;
}
});
}, },
onDlgFormClick(k, model){ onDlgFormClick(k, model){
var that=this; var that=this;
...@@ -98,7 +150,23 @@ ...@@ -98,7 +150,23 @@
} }
} }
if(key=="bicall"){ if(key=="bicall"){
alert("开始双虎 "); this.$confirm('确定要发起双呼?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$root.postReq("/web/transfer/tradetransferCtl/aliDoubleCall", {aliBizId:row.ali_bizid}).then( (d) =>{
if (d.status > -1) {
this.$message({
type: 'success',
message: '呼叫成功'
});
}else{
this.$message.warning(d.msg);
}
})
}).catch(() => {
});
} }
}, },
handlerTrackLog(row){ handlerTrackLog(row){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment