Commit 3ad2f9c0 by linboxuan

utilsOrderSve add tmAccept,tmRefuse

parents 0a3cbbec d7ce1dc1
let WEBBase = require("../../web.base");
let system = require("../../../system");
class brand extends WEBBase {
constructor() {
super();
this.utilsNeedSve = system.getObject("service.utilsSve.utilsNeedSve");
}
async springBoard(pobj, qobj, req) {
return await this.opActionProcess(pobj, pobj.actionType, req);
}
async opActionProcess(pobj, action_type, req) {
let opResult = null;
switch (action_type) {
case "QueryTradeIntentionUserList":// 查询咨询客户列表
let endtime = Date.now();
let starttime = Date.now() - 30 * 60 * 1000;//30分钟(毫秒)
pobj.actionBody = {
Begin: starttime,
End: endtime
};
opResult = await this.utilsNeedSve.queryTradeIntentionUserList(pobj);
break;
}
return opResult;
}
}
module.exports = brand;
\ No newline at end of file
......@@ -14,7 +14,7 @@ class GatewaypushlogService extends ServiceBase {
var sql = "select * from gateway_pushlog where pushStatus='wts' and pushtimes<4"
var icloginfos = await this.customQuery(sql);
if (icloginfos.length > 0) {
var count = 10;
var count = 100;
if (icloginfos.length < count) {
count = icloginfos.length;
}
......
......@@ -7,6 +7,11 @@ class IcbcService extends AppServiceBase {
super();
this.zcApiUrl = settings.reqZcApi();
this.certificationUrl = settings.certificationUrl();
this.restClient = system.getObject("util.redisClient");
//处理企业资质证书数据
this.disposeCertificationData = "disposeCertificationData";
//企业资质证书查询
this.searchCertificationData = "searchCertificationData";
}
//企业模糊查询
async getCompanyListByVague(obj, req) {
......@@ -31,20 +36,35 @@ class IcbcService extends AppServiceBase {
//企业证书查询
async searchCertification(queryobj, req) {
if(!queryobj.companyName){
return system.getResultFail(-1,'companyName can not be empty');
if (!queryobj.companyName) {
return system.getResultFail(-1, 'companyName can not be empty');
}
var hashValue = await this.restClient.hget(this.searchCertificationData, queryobj.companyName);
if (hashValue) {
return system.getResultSuccess(JSON.parse(hashValue));
}
let url = this.certificationUrl + "gsb/SearchCertification";
let data = {
"company_name":queryobj.companyName,
"pageSize":20,
"pageIndex":1,
"isExactlySame":"True"
"company_name": queryobj.companyName,
"pageSize": 20,
"pageIndex": 1,
"isExactlySame": "True"
}
let result = await this.opReqResult(url, data, req);
if(result.Status != 200){
return system.getResultFail(-1,'查询失败');
if (!result) {
return system.getResultFail(-1, '查询失败!!!');
}
if (result.Status != 200) {
return system.getResultFail(-1, '查询失败');
}
//对结果处理
// "Tag": 1为qichacha,0为gsb
var setValue = {};
setValue[queryobj.companyName] = JSON.stringify(result.Result);
if (result.Tag == 1) {
this.restClient.hmset(this.disposeCertificationData, setValue);
}
this.restClient.hmset(this.searchCertificationData, setValue);
return system.getResult(result.Result);
}
......
......@@ -19,8 +19,8 @@ class UtilsNeedService extends AppServiceBase {
/**
* 提交需求
* @param {*} pobj
* @param {*} actionBody
* @param {*} pobj
* @param {*} actionBody
*/
async submitNeed(pobj, actionBody) {
if (!actionBody.intentionBizId) {
......@@ -41,6 +41,25 @@ class UtilsNeedService extends AppServiceBase {
pobj.actionBody.type_name = data.data.type_name;
pobj.actionBody.channel_type_code = data.data.channel_type_code;
pobj.actionBody.channel_type_name = data.data.channel_type_name;
if (pobj.actionBody.channel_type_code == 5) {
pobj.actionBody.type = "ali.icp";
} else {
pobj.actionBody.type = "ali.edi";
}
if (pobj.actionBody.description.indexOf("#备#") < 0) {
pobj.actionBody.level = "A";
} else {
var levelurl = "http://106.13.228.212:8000/recProbability";
var levelresult = await this.restPostUrl({ intentionBizId: pobj.actionBody.intentionBizId, type: pobj.actionBody.type, note: pobj.actionBody.description }, levelurl);
if (levelresult.status == 0) {
pobj.actionBody.level = levelresult.data.level;
pobj.actionBody.probability = levelresult.data.per;
} else {
pobj.actionBody.level = "C"
}
}
pobj.actionType = "submitNeed";
var reqUrl = this.centerOrderUrl + "action/need/springBoard";
var result = await this.restPostUrl(pobj, reqUrl);
......@@ -48,17 +67,17 @@ class UtilsNeedService extends AppServiceBase {
if (pobj.actionBody.channel_type_code == "esp.companyreg") {
this.utilsPushSve.aliBusiness2Fq(pobj, "pushNeedBusiness");
} else {
if (pobj.actionBody.channel_type_code == 5) {
pobj.actionBody.type = "ali.icp";
} else {
pobj.actionBody.type = "ali.edi";
}
var reqParams = {
actionBody: pobj.actionBody,
appInfo: pobj.appInfo
}
this.utilsPushSve.aliBusiness2Delivery(reqParams, "addChance");
pobj.actionBody.description = pobj.actionBody.description + " 成交概率:" + pobj.actionBody.level
if (pobj.actionBody.probability) {
pobj.actionBody.description = pobj.actionBody.description + "(" + pobj.actionBody.probability + ") "
}
this.utilsPushSve.aliBusiness2Fq(pobj, "pushNeedICPBusiness");
}
}
......@@ -75,7 +94,7 @@ class UtilsNeedService extends AppServiceBase {
}
var self = this;
pobj.actionType = "receiveIcpFeedback";
// 2020 0803 lin 修改;
// 2020 0803 lin 修改;
if (pobj.intentionStatus) {
// 如果需求当前字段为5(已关闭)则通知fq
if (pobj.intentionStatus == 5) {
......@@ -129,7 +148,7 @@ class UtilsNeedService extends AppServiceBase {
/**
* 获取需求详情
* @param {*} pobj
* @param {*} pobj
* @param {*} actionBody needNo 需求号
*/
async getItemByNeedNo(pobj, actionBody) {
......@@ -142,7 +161,7 @@ class UtilsNeedService extends AppServiceBase {
}
/**
* 获取需求详情
* @param {*} pobj
* @param {*} pobj
* @param {*} actionBody needNo 需求号
*/
async getItemByChannelNeedNo(pobj, actionBody) {
......@@ -155,7 +174,7 @@ class UtilsNeedService extends AppServiceBase {
}
/**
* 获取需求详情
* @param {*} pobj
* @param {*} pobj
* @param {*} actionBody bizId 渠道方案号
*/
async getItemByChannelSolutionNo(pobj, actionBody) {
......@@ -168,8 +187,8 @@ class UtilsNeedService extends AppServiceBase {
}
/**
* 关闭需求
* @param {*} pobj
* @param {*} actionBody
* @param {*} pobj
* @param {*} actionBody
*/
async needClose(pobj, actionBody) {
if (!actionBody.intentionBizId) {
......@@ -187,8 +206,8 @@ class UtilsNeedService extends AppServiceBase {
/**
* icp关闭需求
* @param {*} pobj
* @param {*} actionBody
* @param {*} pobj
* @param {*} actionBody
*/
async needCloseIcp(pobj, actionBody) {
if (!actionBody.channelNeedNo) {
......@@ -473,8 +492,8 @@ class UtilsNeedService extends AppServiceBase {
/**
* 2020 0827 lin 新增 4.1 用户在公司宝前端提交需求
* @param {*} pobj
* @param {*} actionBody
* @param {*} pobj
* @param {*} actionBody
*/
async submitIcpIntention(pobj, actionBody) {
// 校验文档上必填字段
......@@ -494,7 +513,7 @@ class UtilsNeedService extends AppServiceBase {
var reqUrl = this.centerOrderUrl + "action/need/springBoard";
var result = await this.restPostUrl(pobj, reqUrl);
// 生成成功 通知ali
if(result.status == 0) {
if (result.status == 0) {
var aliResult = await this.aliclient.reqbyget({ action: "SubmitIcpIntention", reqbody: actionBody, apiVersion: "2019-05-08" });
console.log(aliResult);
}
......@@ -503,8 +522,8 @@ class UtilsNeedService extends AppServiceBase {
/**
* 2020 0827 lin 新增 4.2 需求列表查询
* @param {*} pobj
* @param {*} actionBody
* @param {*} pobj
* @param {*} actionBody
*/
async queryIntentionList(pobj, actionBody) {
var aliResult = await self.aliclient.reqbyget({ action: "QueryIntentionList", reqbody: actionBody, apiVersion: "2019-05-08" });
......@@ -517,8 +536,8 @@ class UtilsNeedService extends AppServiceBase {
/**
* 2020 0827 lin 新增 4.3 用户需求确认 未测试
* @param {*} pobj
* @param {*} actionBody
* @param {*} pobj
* @param {*} actionBody
*/
async confirmIcpIntention(pobj, actionBody) {
if (!actionBody.intentionBizId) {
......@@ -534,26 +553,51 @@ class UtilsNeedService extends AppServiceBase {
}
}
async queryTradeIntentionUserList(pobj) {
if (!pobj.actionBody.intentionBizId) {
return system.getResult(null, "actionBody.intentionBizId can not be empty,100493");
}
if (!pobj.actionBody.userFeedBack) {
return system.getResult(null, "actionBody.userFeedBack can not be empty,100494");
}
// if (!pobj.actionBody.intentionBizId) {
// return system.getResult(null, "actionBody.intentionBizId can not be empty,100493");
// }
// if (!pobj.actionBody.userFeedBack) {
// return system.getResult(null, "actionBody.userFeedBack can not be empty,100494");
// }
pobj.actionBody.data = [];
await this.queryByAli(pobj,1);
pobj.actionType = "getUnCreated";
let reqUrl = this.centerOrderUrl + "action/need/springBoard";
let result = await this.restPostUrl(pobj, reqUrl);
if (result.status == 0) {
pobj.actionBody = {
type:"tmjy"
};
for (let item of result.data){
pobj.actionBody.intentionBizId=item.BizId;
pobj.actionBody.mobile=item.Mobile?item.Mobile:"";
pobj.actionBody.userName=item.UserName?item.UserName:"";
pobj.notes=`${item.RegisterNumber?"RegisterNumber:"+item.RegisterNumber:""}${item.Classification?"Classification:"+item.Classification:""}`;
let res = await this.submitNeed(JSON.parse(JSON.stringify(pobj)),{intentionBizId:item.BizId});
console.log(res)
}
return system.getResultSuccess();
}else {
return system.getResultFail(result.status,result.msg);
}
return system.getResultFail(res.status,res.msg);
}
async queryByAli(pobj,page){
let res = await this.aliclient.reqbyget({
action: "QueryTradeIntentionUserList", reqbody: {
BeginTime: pobj.actionBody.BeginTime ? pobj.actionBody.BeginTime : "",
EndTime: pobj.actionBody.EndTime ? pobj.actionBody.EndTime : "",
BizId: pobj.actionBody.intentionBizId,
UserFeedBack: pobj.actionBody.userFeedBack,
PageNum: pobj.actionBody.pageNum || 1,
PageSize: pobj.actionBody.pageSize || 10,
}, apiVersion: "2019-05-08"
action: "QueryTradeIntentionUserList", reqbody: {
Begin: pobj.actionBody.Begin ? pobj.actionBody.Begin : "",
End: pobj.actionBody.End ? pobj.actionBody.End : "",
PageNum: page,
PageSize: 10,
}, apiVersion: "2019-05-08"
});
console.log(res)
return system.getResultSuccess(res);
if (res.status == 0) {
pobj.actionBody.data.push(...res.data.Data);
if (page < res.data.TotalPageNum){
await this.queryByAli(pobj,page+1)
}
}
}
async testsymq(pobj) {
var a = null;
try {
......
......@@ -206,6 +206,7 @@ class RedisClient {
async delete(key) {
return this.client.delAsync(key);
}
//设置hash表数据,jsonObj格式:{key:value}
async hmset(key, jsonObj) {
return this.client.hmsetAsync(key, jsonObj);
}
......@@ -217,6 +218,18 @@ class RedisClient {
async hgetall(key) {
return this.client.hgetallAsync(key);
}
//获取指定hash表的所有key
async hkeys(key) {
return this.client.hkeysAsync(key);
}
//获取指定hash表的field对应的值
async hget(key, field) {
return this.client.hgetAsync(key, field);
}
//删除指定hash表的字段
async hdel(key, fields) {
return this.client.hdelAsync(key, ...fields);
}
async hincrby(key, f, n) {
return this.client.hincrbyAsync(key, f, n);
}
......@@ -245,13 +258,13 @@ class RedisClient {
}
}
module.exports = RedisClient;
// var client=new RedisClient();
// (async ()=>{
// await client.rpush("tasklist","xxx");
// await client.rpush("tasklist","xxx");
// var len=await client.llen("tasklist");
var client = new RedisClient();
// (async () => {
// await client.rpush("tasklist", "xxx");
// await client.rpush("tasklist", "xxx");
// var len = await client.llen("tasklist");
// //await client.clearlist("tasklist");
// len=await client.llen("tasklist");
// len = await client.llen("tasklist");
// console.log(len);
// })()
......@@ -277,10 +290,31 @@ module.exports = RedisClient;
// r.get("hello").then(function(result){
// console.log(result);
// });
// client.hmset("user_1",{name:"jy",age:13}).then(function(r){
// client.hmset("user_1", { "北京汉唐科技": "hantang-sy", age: 1314 }).then(function (r) {
// console.log(r);
// });
// client.hmset("user_1", { "北京汉唐科技-test01": "hantang-sy-test01" }).then(function (r) {
// console.log(r);
//
// });
// client.hgetall("user_1").then(function (r) {
// console.log(r, "hgetall.................");
// });
// client.hkeys("user_19").then(function (r) {
// console.log(r, "hkeys.................");//没有值则为[]
// });
// client.hget("user_19", "北京汉唐科技").then(function (r) {
// console.log(r, "hget.................");//没有值则为null
// });
// client.hdel("user_1", ["age"]).then(function (r) {
// console.log(r, "hdel.................");//删除成功为1,否则删除失败
// });
// client.hincrby("user_1","age",2).then(function(r){
// console.log(r);
// setTimeout(function(){
......
......@@ -3,7 +3,7 @@ var settings = {
host: "43.247.184.32",
port: 8967,
password: "Gongsibao2018",
db: 8,
db: 5,
},
database: {
dbname: "igirl_api",
......
......@@ -139,67 +139,67 @@ module.exports = function (app) {
}
});
//----------------------飞书小程序---------------------------------------------结束
// app-ali支付回调通知
app.use('/orderNotify/aliPayNotify', async function (req, res) {
try{
var client_ip = system.get_client_ip(req);
var result = await utilsOrderSve.aliPayNotify(req.body, client_ip);
logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "记录支付宝回调处理结果 api层",
op: "center-channel/orderNotify/aliPayNotify",
content: "支付回调处理结果:" + JSON.stringify(result),
clientIp: client_ip || ""
});
if (result.status != 0) {
return res.end("FAIL");
}
return res.end("success");
} catch(e) {
logCtl.error({
// app-ali支付回调通知
app.use('/orderNotify/aliPayNotify', async function (req, res) {
try {
var client_ip = system.get_client_ip(req);
var result = await utilsOrderSve.aliPayNotify(req.body, client_ip);
logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "记录支付宝回调处理结果 api层",
op: "center-channel/orderNotify/aliPayNotify",
content: "支付回调处理结果:" + JSON.stringify(result),
clientIp: client_ip || ""
});
if (result.status != 0) {
return res.end("FAIL");
}
return res.end("success");
} catch (e) {
logCtl.error({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "支付宝回调处理异常 api层",
op: "center-channel/orderNotify/aliPayNotify",
content: "回调参数:req=" + JSON.stringify(req) + "error:" + e.stack,
clientIp: client_ip || ""
});
}
});
// app-wx支付回调
app.use('/orderNotify/wxPayNotify', async function (req, res) {
try{
var body = "";
}
});
// app-wx支付回调
app.use('/orderNotify/wxPayNotify', async function (req, res) {
try {
var body = "";
req.on('data', function(data) {
body += data;
});
req.on('end', async function() {
xml2js.parseString(body, { trim: true, explicitArray: false, explicitRoot: false }, async function(err, json) {
var client_ip = system.get_client_ip(req);
var result = await utilsOrderSve.wxPayNotify(json);
logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "记录微信支付回调处理结果",
op: "center-channel/orderNotify/wxPayNotify",
content: "支付回调处理结果:" + JSON.stringify(result),
clientIp: client_ip || ""
});
if (result.status != 0) {
return res.end("FAIL");
}
return res.end("success");
})
})
} catch(e) {
logCtl.error({
req.on('data', function (data) {
body += data;
});
req.on('end', async function () {
xml2js.parseString(body, { trim: true, explicitArray: false, explicitRoot: false }, async function (err, json) {
var client_ip = system.get_client_ip(req);
var result = await utilsOrderSve.wxPayNotify(json);
logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "记录微信支付回调处理结果",
op: "center-channel/orderNotify/wxPayNotify",
content: "支付回调处理结果:" + JSON.stringify(result),
clientIp: client_ip || ""
});
if (result.status != 0) {
return res.end("FAIL");
}
return res.end("success");
})
})
} catch (e) {
logCtl.error({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "微信回调处理异常",
op: "center-channel/orderNotify/wxPayNotify",
content: "回调参数:req=" + JSON.stringify(req) + "error:" + e.stack,
clientIp: client_ip || ""
});
}
});
}
});
app.all("/web/*", async function (req, res, next) {
var result = system.getResult(null, "req method must is post");
if (req.method != "POST") {
......@@ -210,9 +210,9 @@ module.exports = function (app) {
result.msg = "actionType can not be empty";
res.end(JSON.stringify(result));
return;
}
// 2020 0812 lin 只去掉了check,因为要记录智能诊断的返回值,其他接口暂时未去掉
if (["getAppTokenByHosts", "getAppTokenByAppKey", "test","getIndustries","getSecondIndustries","getQualificationByIndustry","counselling"].indexOf(req.body.actionType) >= 0) {
}
// 2020 0812 lin 只去掉了check,因为要记录智能诊断的返回值,其他接口暂时未去掉
if (["getAppTokenByHosts", "getAppTokenByAppKey", "test", "getIndustries", "getSecondIndustries", "getQualificationByIndustry", "counselling"].indexOf(req.body.actionType) >= 0) {
req.body.actionBody.appHosts = req.host;
next();
return;
......@@ -229,26 +229,26 @@ module.exports = function (app) {
res.end(JSON.stringify(result));
return;
}
var cacheManager = system.getObject("db.common.cacheManager");
var result = await cacheManager["AppTokenByHostsCache"].getCache(token, system.exTime);
var cacheManager = system.getObject("db.common.cacheManager");
var result = await cacheManager["AppTokenByHostsCache"].getCache(token, system.exTime);
if (result.status != 0) {
res.end(JSON.stringify(result));
return;
}
req.body.appInfo = result.data;
req.body.actionProcess = result.data.app_code;
var lst = ["serviceProviderSubmitMaterial","closeOrderDelivery","serviceProviderNotification",
"tmConfirm", "getNeedSolutionDetailByUser","getProgrammeInfoByChannelNeedNo",
var lst = ["serviceProviderSubmitMaterial", "closeOrderDelivery", "serviceProviderNotification",
"tmConfirm", "getNeedSolutionDetailByUser", "getProgrammeInfoByChannelNeedNo",
"submitIcpProgramme", "submitIcpMaterial", "acceptIcpPartnerNotification", "abolishIcpProgramme",
"addOrder", "getH5PayUrl", "getOrderQrCode", "queryOrderStatus", "getOrderInfo", "getOrderDeliveryInfo", "getOrderDetails",
"getOrderDeliveryFlowInfo", "getOrderDeliveryFlowList", "getOrderLogInfo", "updateContacts", "updateTmOrder", "delOrder",
"submitProgramme", "getProgrammeListByUser", "getProgrammeInfoByNeedNo", "abolishProgramme", "getAliPayInfo",
"getPaidLogoListByUser","getCollectibleLogoListByUser","collectLogo","getLogoMaterial","cancelCollectLogo","icpNotify","createName","getNameDetail","orderConfirm",
"orderTotalSum", "collect", "reg", "orderCheck","getReOrderList","getOfficalList","addReviewList","opSubmitNeed","opNeedClose","opNeedList","getItemByNeedNo","opNeedDetailByChannelNo",
"getNeedListUser",
"manualEvaluation", "diagnosisInfo", "check", "enterpriseInfo", "diagnosisDetail",
"submitIcpIntention", "queryIntentionList", "confirmIcpIntention",
"tmAccept", "tmStatus"
"getPaidLogoListByUser", "getCollectibleLogoListByUser", "collectLogo", "getLogoMaterial", "cancelCollectLogo", "icpNotify", "createName", "getNameDetail", "orderConfirm",
"orderTotalSum", "collect", "reg", "orderCheck", "getReOrderList", "getOfficalList", "addReviewList", "opSubmitNeed", "opNeedClose", "opNeedList", "getItemByNeedNo", "opNeedDetailByChannelNo",
"getNeedListUser",
"manualEvaluation", "diagnosisInfo", "check", "enterpriseInfo", "diagnosisDetail",
"submitIcpIntention", "queryIntentionList", "confirmIcpIntention",
"tmAccept", "tmStatus"
];
if (lst.indexOf(req.body.actionType) >= 0) {
var userpin = req.headers["userpin"] || "";
......@@ -372,7 +372,7 @@ module.exports = function (app) {
req.body.appInfo = result.data;
req.body.actionProcess = result.data.app_code;
var lst = [
"submitNeed", "paySuccess","icpNotify"
"submitNeed", "paySuccess", "icpNotify"
];
if (lst.indexOf(req.body.actionType) >= 0) {
var userpin = req.headers["userpin"] || "";
......
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