Commit b0da6c73 by 王勇飞

gyq

parents a1db065d 4fdb1a83
var system = require("../../../system"); var system = require("../../../system");
const http = require("http"); const http = require("http");
const querystring = require('querystring'); const querystring = require('querystring');
const sha235 = require("sha256");
var settings = require("../../../../config/settings"); var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base"); const CtlBase = require("../../ctl.base");
const moment = require('moment'); const moment = require('moment');
...@@ -142,9 +143,10 @@ class DeliverybillCtl extends CtlBase { ...@@ -142,9 +143,10 @@ class DeliverybillCtl extends CtlBase {
} }
} }
// 创建服务实例 // 创建融易算服务实例
async insertInfo(pobj, qobj, req) { async insertInfo(obj, qobj, req) {
try { try {
var pobj = obj.actionBody.messageBody;
var cachestr = sha235(JSON.stringify(pobj)); var cachestr = sha235(JSON.stringify(pobj));
var cacheInfo = await this.cacheManager["TxCache"].getCache(cachestr); var cacheInfo = await this.cacheManager["TxCache"].getCache(cachestr);
if (cacheInfo && cacheInfo != 'undefined') { if (cacheInfo && cacheInfo != 'undefined') {
...@@ -154,25 +156,52 @@ class DeliverybillCtl extends CtlBase { ...@@ -154,25 +156,52 @@ class DeliverybillCtl extends CtlBase {
"data": "", "data": "",
"requestId": "" "requestId": ""
} }
} } else {
else {
// 检验各项必传参数 // 检验各项必传参数
if (pobj.acrequestId && pobj.requestId != 'undefined' && if (!pobj.requestId || pobj.requestId == 'undefined') {
pobj.bizId && pobj.bizId != 'undefined' && throw new Error("requestId 不能为空");
pobj.contactsPhone && pobj.contactsPhone != 'undefined' && }
pobj.userId && pobj.userId != 'undefined' && if (!pobj.bizId || pobj.bizId == 'undefined') {
pobj.orderId && pobj.orderId != 'undefined' && throw new Error("bizId 不能为空");
pobj.areaType && pobj.areaType != 'undefined' && }
pobj.area && pobj.area != 'undefined' && if (!pobj.contactsPhone || pobj.contactsPhone == 'undefined') {
pobj.topOrgCode && pobj.topOrgCode != 'undefined' && throw new Error("contactsPhone 不能为空");
pobj.taxpayerType && pobj.taxpayerType != 'undefined' && }
pobj.product_code && pobj.product_code != 'undefined' && if (!pobj.userId || pobj.userId == 'undefined') {
pobj.product_name && pobj.product_name != 'undefined' && throw new Error("userId 不能为空");
pobj.service_address && pobj.service_address != 'undefined' && }
pobj.delivery_status && pobj.delivery_status != 'undefined' && if (!pobj.orderId || pobj.orderId == 'undefined') {
pobj.facilitator_id && pobj.facilitator_id != 'undefined') { throw new Error("orderId 不能为空");
}
if (!pobj.areatype || pobj.areatype == 'undefined') {
throw new Error("areatype 不能为空");
}
if (!pobj.area || pobj.area == 'undefined') {
throw new Error("area 不能为空");
}
if (!pobj.topOrgCode || pobj.topOrgCode == 'undefined') {
throw new Error("topOrgCode 不能为空");
}
if (!pobj.taxpayerType || pobj.taxpayerType == 'undefined') {
throw new Error("taxpayerType 不能为空");
}
if (!pobj.product_code || pobj.product_code == 'undefined') {
throw new Error("product_code 不能为空");
}
if (!pobj.product_name || pobj.product_name == 'undefined') {
throw new Error("product_name 不能为空");
}
if (!pobj.service_address || pobj.service_address == 'undefined') {
throw new Error("service_address 不能为空");
}
if (!pobj.delivery_status || pobj.delivery_status == 'undefined') {
throw new Error("delivery_status 不能为空");
}
if (!pobj.facilitator_id || pobj.delivery_status == 'undefined') {
throw new Error("delivery_status 不能为空");
}
var buInfo = await this.service.insertInfo(pobj); var buInfo = await this.service.insertInfo(pobj);
if (buInfo){ if (buInfo) {
await this.cacheManager["TxCache"].cache(cachestr, JSON.stringify({ cachestr: cachestr }), 180);//插入redis缓存 await this.cacheManager["TxCache"].cache(cachestr, JSON.stringify({ cachestr: cachestr }), 180);//插入redis缓存
return { return {
"status": 1, //1代表成功,否则失败 "status": 1, //1代表成功,否则失败
...@@ -180,25 +209,33 @@ class DeliverybillCtl extends CtlBase { ...@@ -180,25 +209,33 @@ class DeliverybillCtl extends CtlBase {
"data": buInfo, "data": buInfo,
"requestId": "" "requestId": ""
} }
}
else{
return system.getResultError("参数错误!");
}
} else { } else {
return system.getResultError("参数错误!"); return system.getResultFail(buInfo);
} }
} }
} }
catch (error) { catch (err) {
return system.getResultError(error); return system.getResult(null, err.message)
} }
} }
async updateServer(pobj, qobj, req) { // 更新融易算服务实例
async updateServer(obj, qobj, req) {
try { try {
var pobj = obj.actionBody.messageBody;
var cachestr = sha235(JSON.stringify(pobj));
var cacheInfo = await this.cacheManager["TxCache"].getCache(cachestr);
var cacheInfo;
if (cacheInfo && cacheInfo != 'undefined') {
return {
"status": 1, //1代表成功,否则失败
"msg": "已处理成功!",
"data": "",
"requestId": ""
}
} else {
if (!pobj.requestId || pobj.requestId == 'undefined') { if (!pobj.requestId || pobj.requestId == 'undefined') {
throw new Error("requestId 不能为空"); throw new Error("requestId 不能为空");
} }
...@@ -224,11 +261,24 @@ class DeliverybillCtl extends CtlBase { ...@@ -224,11 +261,24 @@ class DeliverybillCtl extends CtlBase {
throw new Error("uscc 不能为空"); throw new Error("uscc 不能为空");
} }
const rs = await this.service.updateServer(pobj); const rs = await this.service.updateServer(pobj);
return system.getResult(rs); if (rs) {
} catch (err) { await this.cacheManager["TxCache"].cache(cachestr, JSON.stringify({ cachestr: cachestr }), 180);//插入redis缓存
return {
"status": 1, //1代表成功,否则失败
"msg": "处理成功!",
"data": rs,
"requestId": ""
}
} else {
return system.getResultFail(rs);
}
}
}
catch (err) {
return system.getResult(null, err.message) return system.getResult(null, err.message)
} }
} }
//根据bizId查询deliverybill表中的所有信息 //根据bizId查询deliverybill表中的所有信息
async getInfo(pobj, qobj, req) { async getInfo(pobj, qobj, req) {
try { try {
...@@ -246,10 +296,31 @@ class DeliverybillCtl extends CtlBase { ...@@ -246,10 +296,31 @@ class DeliverybillCtl extends CtlBase {
module.exports = DeliverybillCtl; module.exports = DeliverybillCtl;
// var task = new DeliverybillCtl(); // var task = new DeliverybillCtl();
// var obj={ // var obj = {
// "deliverId":"1111111" // "actionType": "produceData",
// "actionBody": {
// "pushUrl": "http://ic.com:8000/web/bizchance/deliverybillCtl",
// "actionType": "insertInfo",
// "identifyCode": "book-manage",
// "messageBody": {
// "requestId": "825da0a74432-738f-4bed-b48d-d51aa808",
// "bizId": "5892748825",
// "contactsPhone": "18510669321",
// "userId": "10973452443103825",
// "orderId": "341184456620496_book",
// "areatype": "city",
// "area": "100010",
// "topOrgCode": "rong_yi_suan",
// "taxpayerType": 1,
// "product_code": "bookkeeping",
// "product_name": "代账服务",
// "service_address": "110100",
// "delivery_status": "waituserconfirm",
// "facilitator_id": "10"
// }
// }
// } // }
// task.deliverInfo(obj,{},{}).then(d=>{ // task.insertInfo(obj, {}, {}).then(d => {
// console.log(JSON.stringify(d)); // console.log(JSON.stringify(d));
// }) // })
......
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