Commit 1c536b2f by 宋毅

Merge branch 'center-channel' of gitlab.gongsibao.com:jiangyong/zhichan into center-channel

parents f2f11dc2 a0ca761d
......@@ -23,6 +23,28 @@ class edi extends APIBase {
return result
}
async notify(pobj,query,req) {
console.log(pobj);
// 校验必填 pannong 2.1
var checkResult = await this.serviceNotifyCheck(pobj,req.headers);
if(checkResult.status != 0) {
return checkResult;
}
var qobj = {appInfo:pobj.appInfo};
qobj.actionBody = pobj;
var result = await this.utilsServiceSve.notifyService(qobj,qobj.actionBody,req);
return result
}
async notice(pobj,query,req) {
console.log("/api/opreceive/service/notice",pobj)
if(!pobj.actionType) {
return system.getResult(null, "pobj.actionType cannot be empty");
}
var result = await this.utilsServiceSve.noticeService(pobj,pobj.actionBody,req);
return result
}
async serviceCreateCheck(pobj,headers) {
if(!headers.appkey) {
return system.getResult(null, "headers.appkey cannot be empty");
......@@ -72,5 +94,23 @@ class edi extends APIBase {
return system.getResultSuccess()
}
async serviceNotifyCheck(pobj,headers) {
if(!headers.appkey) {
return system.getResult(null, "headers.appkey cannot be empty");
}
if(!headers.sign) {
return system.getResult(null, "headers.sign cannot be empty");
}
if(!pobj.bizId) {
return system.getResult(null, "bizId cannot be empty");
}
if(!pobj.status) {
return system.getResult(null, "status cannot be empty");
}
if(pobj.status != 4 && pobj.status != 8 && pobj.status != 16) {
return system.getResult(null, "status error");
}
return system.getResultSuccess()
}
}
module.exports = edi;
\ No newline at end of file
......@@ -122,6 +122,11 @@ module.exports = SignService;
// "orderNo":"c76a7c1a0cf747db92e9fc6beab770f0",
// "remark":"lin"
// }
// task.createSign(obj,"7cbb892450174167b5c7e01we4716t51").then(d=>{
// var obj = {
// "bizId":"202011031421",
// "status":"16"
// }
// task.createSign(obj,"7cbb892450174167b5c7e01we4717z51").then(d=>{
// console.log(d,"!!!!!!!!!!!!!!!!!!!!!!!!!!");
// });
\ No newline at end of file
var system = require("../../../system");
var settings = require("../../../../config/settings");
const AppServiceBase = require("../../app.base");
const md5 = require('md5')
const md5 = require('md5');
const { sign } = require("crypto");
//阿里支付类
class utils360Sve extends AppServiceBase {
constructor() {
super();
this.centerAppUrl = settings.centerAppUrl();
this.pannongServiceConfig = settings.pannongServiceConfig();
this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve")
this.pushlogSve = system.getObject("service.common.pushlogSve");
this.utilsOrderSve = system.getObject("service.utilsSve.utilsOrderSve");
this.utilsPushSve = system.getObject("service.utilsSve.utilsPushSve");
this.signSve = system.getObject("service.common.signSve");
}
/**
......@@ -65,12 +68,15 @@ class utils360Sve extends AppServiceBase {
orderStatus: 2
}
var orderrtn = await this.utilsOrderSve.addOrder(pobj, pobj.actionBody);
this.logCtl.info({
op: "service/impl/utilsSve/utilsServiceSve.js/submitService",
content: "参数=" + JSON.stringify(pobj) + " 返回值=" + JSON.stringify(orderrtn),
clientIp: req.client_ip || "",
optitle: "服务单创建接口"
});
if (orderrtn.status != 0 && orderrtn.status != -1) {
return system.getResultFail(-5012, "订单创建失败");
}
console.log("创建服务单 order信息 start");
console.log(orderrtn);
console.log("创建服务单 order信息 end");
if (orderrtn.data) {
pobj.actionBody.orderNo = orderrtn.data.orderNo;
}
......@@ -78,6 +84,7 @@ class utils360Sve extends AppServiceBase {
var deliveryObj = {
actionBody: {
"bizId":pobj.actionBody.bizId,
"orderNo":pobj.actionBody.orderNo,
"contactName":pobj.actionBody.contactName,
"contactMobile":pobj.actionBody.contactMobile,
"timeUnit":pobj.actionBody.timeUnit,
......@@ -98,6 +105,114 @@ class utils360Sve extends AppServiceBase {
return system.getResultSuccess();
}
async notifyService(pobj, actionBody,req) {
// 根据渠道订单号查出订单 判断订单状态是否可以变更
pobj.actionBody.channelOrderNo = pobj.bizId;
var sobj = {
actionType: "getOrderByChannelOrderNo",
actionBody: pobj.actionBody,
appInfo: pobj.appInfo,
userInfo: {
channelUerId: ""// 获取不到userpin 模拟
}
}
var url = settings.centerOrderUrl() + "action/order/springBoard";
var orderInfoResult = await this.restPostUrl(sobj, url);
if(orderInfoResult.status != 0) {
return system.getResult(null, "order data is empty");
}
var orderInfo = orderInfoResult.data;
// 2020 1106 lin 这里为什么要查出订单 再去修改 不直接修改?
// 因为先暂时不做状态判断是否可以修改 后面优化
pobj.actionBody.orderId = orderInfo.id;
if(actionBody.status == 16) {// 2020 1106 lin 这里转换一下已关闭为16不合适 换为已作废
var orderStatus = 32
} else {
var orderStatus = actionBody.status;
}
var sobj = {
actionType: "updateOrderStatusById",
actionBody: {
orderStatus: orderStatus,
orderId: orderInfo.id
},
appInfo: pobj.appInfo,
userInfo: {
channelUerId: ""// 获取不到userpin 模拟
}
}
var url = settings.centerOrderUrl() + "action/order/springBoard";
var orderInfoResult = await this.restPostUrl(sobj, url);
if(orderInfoResult.status != 0) {
return system.getResult(null, "order data is empty");
}
var deliveryObj = {
actionBody: {
"bizId": actionBody.bizId,
"status": actionBody.status
},
appInfo: pobj.appInfo
}
if(actionBody.serviceStartTime && actionBody.serviceEndTime ) {
deliveryObj.actionBody.serviceStartTime = actionBody.serviceStartTime,
deliveryObj.actionBody.serviceEndTime = actionBody.serviceEndTime
}
this.utilsPushSve.aliBusiness2Delivery(deliveryObj, "notifyService");
return system.getResultSuccess();
}
async noticeService(pobj, actionBody,req) {
delete actionBody.appHosts
var obj = {
appid: this.pannongServiceConfig.appid,
noncestr: this.getUUID(),
timestamp: new Date().getTime(),
body: actionBody
}
var signResult = await this.signSve.createSign(obj, this.pannongServiceConfig.appkey);
if(signResult.status != 0) {
return system.getResult(null, "create sign fail");
}
obj.sign = signResult.data;
switch(pobj.actionType) {
case "feedback":
var url = settings.pannongUrl() + "pas-api/gsb/service/feedback";
var result = await this.restPostUrl(obj, url);
this.logCtl.info({
op: "service/impl/utilsSve/utilsServiceSve.js/feedback",
content: "参数=" + JSON.stringify(obj) + " 返回值=" + JSON.stringify(result),
clientIp: req.client_ip || "",
optitle: "服务单处理反馈接收接口"
});
return result;
case "accountingInfo":
var url = settings.pannongUrl() + "pas-api/gsb/service/accountingInfo";
var result = await this.restPostUrl(obj, url);
this.logCtl.info({
op: "service/impl/utilsSve/utilsServiceSve.js/feedback",
content: "参数=" + JSON.stringify(obj) + " 返回值=" + JSON.stringify(result),
clientIp: req.client_ip || "",
optitle: "回传会计信息"
});
return result;
case "booksInfo":
var url = settings.pannongUrl() + "pas-api/gsb/service/booksInfo";
var result = await this.restPostUrl(obj, url);
this.logCtl.info({
op: "service/impl/utilsSve/utilsServiceSve.js/feedback",
content: "参数=" + JSON.stringify(obj) + " 返回值=" + JSON.stringify(result),
clientIp: req.client_ip || "",
optitle: "帐套信息接受接口"
});
return result;
default:
return system.getResult(null, "actionType参数错误");
}
}
}
module.exports = utils360Sve;
......@@ -19,6 +19,6 @@ module.exports = {
"putUserPwdByMobile", "icpNotifyNew"
],
apiMustUserpinList: ["submitNeed", "paySuccess", "icpNotify", "getLoginInfo", "icpNotifyNew", "submitIcpProgramme","serviceProviderSubmitMaterial","abolishIcpProgramme","submitService"],
apiSecretPathList: ["/api/icp/consultation/submit","/api/icp/feedback/submit","/api/icp/order/notify","/api/opreceive/service/create","/api/icp/order/close"]
apiSecretPathList: ["/api/icp/consultation/submit","/api/icp/feedback/submit","/api/icp/order/notify","/api/opreceive/service/create","/api/icp/order/close","/api/opreceive/service/notify"]
}
}
......@@ -442,7 +442,7 @@ module.exports = function (app) {
}
}
if (["getAppTokenByHosts", "getAppTokenByAppKey", "getTmNclFilterSearch"].indexOf(req.body.actionType) >= 0) {
if (["getAppTokenByHosts", "getAppTokenByAppKey", "getTmNclFilterSearch","feedback"].indexOf(req.body.actionType) >= 0) {
req.body.actionBody.appHosts = req.host;
next();
return;
......
......@@ -354,6 +354,23 @@ var settings = {
} else {
return "15754717260";// 7.7修改正式环境优客 辅助/担保订单推送业务员手机号 刘文悦
}
},
pannongServiceConfig: function() {
if (this.env == "dev") {
return {
appid: "10015683988",
appkey: "b74b73acf78cc2851aa559e93c84f7888adq23we"
}
} else {
// 2020 1106 lin 正式环境还未给出
}
},
pannongUrl: function() {
if (this.env == "dev") {
return "http://39.101.172.142:8980/"
} else {
// 2020 1106 lin 正式环境还未给出
}
}
};
module.exports = settings;
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