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,93 +143,142 @@ class DeliverybillCtl extends CtlBase { ...@@ -142,93 +143,142 @@ 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') {
return { return {
"status": 1, //1代表成功,否则失败 "status": 1, //1代表成功,否则失败
"msg": "已处理成功!", "msg": "已处理成功!",
"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 不能为空");
var buInfo = await this.service.insertInfo(pobj); }
if (buInfo){ if (!pobj.areatype || pobj.areatype == 'undefined') {
await this.cacheManager["TxCache"].cache(cachestr, JSON.stringify({ cachestr: cachestr }), 180);//插入redis缓存 throw new Error("areatype 不能为空");
return { }
"status": 1, //1代表成功,否则失败 if (!pobj.area || pobj.area == 'undefined') {
"msg": "处理成功!", throw new Error("area 不能为空");
"data": buInfo, }
"requestId": "" if (!pobj.topOrgCode || pobj.topOrgCode == 'undefined') {
} throw new Error("topOrgCode 不能为空");
} }
else{ if (!pobj.taxpayerType || pobj.taxpayerType == 'undefined') {
return system.getResultError("参数错误!"); 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);
if (buInfo) {
await this.cacheManager["TxCache"].cache(cachestr, JSON.stringify({ cachestr: cachestr }), 180);//插入redis缓存
return {
"status": 1, //1代表成功,否则失败
"msg": "处理成功!",
"data": buInfo,
"requestId": ""
} }
} 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 {
if (!pobj.requestId || pobj.requestId == 'undefined') { var pobj = obj.actionBody.messageBody;
throw new Error("requestId 不能为空"); var cachestr = sha235(JSON.stringify(pobj));
} var cacheInfo = await this.cacheManager["TxCache"].getCache(cachestr);
if (!pobj.bizId || pobj.bizId == 'undefined') { var cacheInfo;
throw new Error("bizId 不能为空"); if (cacheInfo && cacheInfo != 'undefined') {
} return {
if (!pobj.orderId || pobj.orderId == 'undefined') { "status": 1, //1代表成功,否则失败
throw new Error("orderId 不能为空"); "msg": "已处理成功!",
} "data": "",
if (!pobj.topOrgCode || pobj.topOrgCode == 'undefined') { "requestId": ""
throw new Error("topOrgCode 不能为空"); }
} } else {
if (!pobj.companyName || pobj.companyName == 'undefined') { if (!pobj.requestId || pobj.requestId == 'undefined') {
throw new Error("companyName 不能为空"); throw new Error("requestId 不能为空");
} }
if (!pobj.contactName || pobj.contactName == 'undefined') { if (!pobj.bizId || pobj.bizId == 'undefined') {
throw new Error("contactName 不能为空"); throw new Error("bizId 不能为空");
} }
if (!pobj.companyBizType || pobj.companyBizType == 'undefined') { if (!pobj.orderId || pobj.orderId == 'undefined') {
throw new Error("companyBizType 不能为空"); throw new Error("orderId 不能为空");
} }
if (!pobj.uscc || pobj.uscc == 'undefined') { if (!pobj.topOrgCode || pobj.topOrgCode == 'undefined') {
throw new Error("uscc 不能为空"); throw new Error("topOrgCode 不能为空");
}
if (!pobj.companyName || pobj.companyName == 'undefined') {
throw new Error("companyName 不能为空");
}
if (!pobj.contactName || pobj.contactName == 'undefined') {
throw new Error("contactName 不能为空");
}
if (!pobj.companyBizType || pobj.companyBizType == 'undefined') {
throw new Error("companyBizType 不能为空");
}
if (!pobj.uscc || pobj.uscc == 'undefined') {
throw new Error("uscc 不能为空");
}
const rs = await this.service.updateServer(pobj);
if (rs) {
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);
}
} }
const rs = await this.service.updateServer(pobj); }
return system.getResult(rs); catch (err) {
} 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