Commit 8dec9120 by Sxy

fix: 取值bug && feat: 磐农信息推送启服通

parent f3ea4a47
...@@ -13,7 +13,6 @@ class servicebillCtl extends CtlBase { ...@@ -13,7 +13,6 @@ class servicebillCtl extends CtlBase {
} }
async create(obj) { async create(obj) {
//TODO: 复写create 校验服务单是否已存在
const res = await this.service.findOne({ bizId: obj.bizId }); const res = await this.service.findOne({ bizId: obj.bizId });
if (res != null) { if (res != null) {
return system.getResult({ massage: "该服务单已创建" }); return system.getResult({ massage: "该服务单已创建" });
......
...@@ -3,12 +3,13 @@ const ydzPush = require("./../../../utils/ydzClient"); ...@@ -3,12 +3,13 @@ const ydzPush = require("./../../../utils/ydzClient");
const settings = require("./../../../../config/settings"); const settings = require("./../../../../config/settings");
const System = require("../../../system"); const System = require("../../../system");
const moment = require("moment"); const moment = require("moment");
const toQft = require("./../../../utils/toQft/index") const TOQFT = require("../../../utils/toQft");
class ServicebillService extends ServiceBase { class ServicebillService extends ServiceBase {
constructor() { constructor() {
super("agriculture", ServiceBase.getDaoName(ServicebillService)); super("agriculture", ServiceBase.getDaoName(ServicebillService));
this.accountsetSve = system.getObject("service.agriculture.accountsetSve"); this.accountsetSve = System.getObject("service.agriculture.accountsetSve");
} }
async findAndCountAll(obj) { async findAndCountAll(obj) {
...@@ -44,6 +45,7 @@ class ServicebillService extends ServiceBase { ...@@ -44,6 +45,7 @@ class ServicebillService extends ServiceBase {
// dev gsbweb.qifu-dev.gongsibao.com/api/opreceive/service/notice // dev gsbweb.qifu-dev.gongsibao.com/api/opreceive/service/notice
// pro gsbweb.qifu.gongsibao.com/api/opreceive/service/notice // pro gsbweb.qifu.gongsibao.com/api/opreceive/service/notice
// pushQiFuTong({"actionType":"accountingInfo","actionBody": backData}); // pushQiFuTong({"actionType":"accountingInfo","actionBody": backData});
await TOQFT.getClientByType("pannong").pushQiFuTong(obj.username, { "actionType": "accountingInfo", "actionBody": data });
// TODO: 分配会计并推送易代账新建帐套 回传后新建本地帐套 // TODO: 分配会计并推送易代账新建帐套 回传后新建本地帐套
const accountset = await ydzPush.pushYiDaZhang(user, data); const accountset = await ydzPush.pushYiDaZhang(user, data);
...@@ -51,6 +53,7 @@ class ServicebillService extends ServiceBase { ...@@ -51,6 +53,7 @@ class ServicebillService extends ServiceBase {
// TODO: 推送企服通帐套信息 // TODO: 推送企服通帐套信息
// pushQiFuTong({"actionType":"booksInfo","actionBody": res}); // pushQiFuTong({"actionType":"booksInfo","actionBody": res});
await TOQFT.getClientByType("pannong").pushQiFuTong(obj.username, { "actionType": "booksInfo", "actionBody": res });
} else { } else {
console.log('查无此单:' + obj.bizId); console.log('查无此单:' + obj.bizId);
} }
...@@ -74,6 +77,7 @@ class ServicebillService extends ServiceBase { ...@@ -74,6 +77,7 @@ class ServicebillService extends ServiceBase {
} }
//TODO: 推送企服通 //TODO: 推送企服通
// pushQiFuTong({"actionType":"feedback","actionBody": backData}); // pushQiFuTong({"actionType":"feedback","actionBody": backData});
await TOQFT.getClientByType("pannong").pushQiFuTong(obj.username, { "actionType": "feedback", "actionBody": backData });
} else { } else {
console.log('查无此单:' + obj.bizId); console.log('查无此单:' + obj.bizId);
} }
......
...@@ -11,9 +11,10 @@ const qifutongUrl = settings.qifutongUrl(); ...@@ -11,9 +11,10 @@ const qifutongUrl = settings.qifutongUrl();
* 统一日志记录 * 统一日志记录
*/ */
class BaseClient { class BaseClient {
constructor(appKey, secret) { constructor(appKey, secret, url) {
this.appKey = appKey; this.appKey = appKey;
this.secret = secret; this.secret = secret;
this.url = url
} }
/** /**
* 推送到 启服通 * 推送到 启服通
...@@ -22,7 +23,7 @@ class BaseClient { ...@@ -22,7 +23,7 @@ class BaseClient {
*/ */
async pushQiFuTong(user, data) { async pushQiFuTong(user, data) {
const header = await this.getLoginByUserName(user); const header = await this.getLoginByUserName(user);
await this.postRequest(`${qifutongUrl}/web/action/qcapi/springBoard`, data, header); await this.postRequest(`${qifutongUrl}${this.url}`, data, header);
} }
async getLoginByUserName(user) { async getLoginByUserName(user) {
......
const vatClient = require("./vatClient") const vatClient = require("./vatClient")
const wangwenClient = require("./wangwenClient") const wangwenClient = require("./wangwenClient")
const pannongClient = require("./pannongClient")
const system = require("../../system"); const system = require("../../system");
...@@ -14,8 +15,10 @@ function getClientByType(type) { ...@@ -14,8 +15,10 @@ function getClientByType(type) {
return new vatClient() return new vatClient()
case system.SERVICECODE.WANGWEN: case system.SERVICECODE.WANGWEN:
return new wangwenClient() return new wangwenClient()
case system.SERVICECODE.PANNONG:
return new pannongClient()
default: default:
throw new Error("此状态手动不能更改"); throw new Error("无此产品类型");
} }
} }
......
const BaseClient = require("./baseClient")
const settings = require("../../../config/settings");
const { appKey, secret } = settings;
/**
* 磐农 产品
*/
class PannongClient extends BaseClient {
constructor() {
super(appKey, secret, "/api/opreceive/service/notice");
}
}
module.exports = PannongClient
\ No newline at end of file
...@@ -8,7 +8,7 @@ const qualificationDao = system.getObject("db.delivery.qualificationDao"); ...@@ -8,7 +8,7 @@ const qualificationDao = system.getObject("db.delivery.qualificationDao");
*/ */
class VatClient extends BaseClient { class VatClient extends BaseClient {
constructor() { constructor() {
super(appKey, secret); super(appKey, secret, "/web/action/qcapi/springBoard");
this.CIRCUITSTATUS = { this.CIRCUITSTATUS = {
ACCOUNTREGISTRATION: 507, // 完成账户注册 ACCOUNTREGISTRATION: 507, // 完成账户注册
SUBMITING: 508, // 提交材料到工信部 SUBMITING: 508, // 提交材料到工信部
......
...@@ -7,7 +7,7 @@ const { appKey, secret } = settings; ...@@ -7,7 +7,7 @@ const { appKey, secret } = settings;
*/ */
class WangwenClient extends BaseClient { class WangwenClient extends BaseClient {
constructor() { constructor() {
super(appKey, secret); super(appKey, secret, "/web/action/qcapi/springBoard");
} }
/** /**
......
...@@ -8,7 +8,7 @@ const centerChannelUrl = settings.centerChannelUrl(); ...@@ -8,7 +8,7 @@ const centerChannelUrl = settings.centerChannelUrl();
* 封装 获取 userpin token * 封装 获取 userpin token
*/ */
const pushYiDaZhang = async(data = {}) => { const pushYiDaZhang = async (data = {}) => {
const ydzUrl = settings.ydzUrl(); const ydzUrl = settings.ydzUrl();
const { appKey, appSecret } = settings.ydzKey(); const { appKey, appSecret } = settings.ydzKey();
// const openToken = getOpenTokenByAppKey(appKey, appSecret); // const openToken = getOpenTokenByAppKey(appKey, appSecret);
...@@ -22,7 +22,7 @@ const pushYiDaZhang = async(data = {}) => { ...@@ -22,7 +22,7 @@ const pushYiDaZhang = async(data = {}) => {
await this.postRequest(`${ydzUrl}/ydz/easyacctg/customer/create/{${manageId}}`, data, header); await this.postRequest(`${ydzUrl}/ydz/easyacctg/customer/create/{${manageId}}`, data, header);
} }
const getOpenTokenByAppKey = async(appKey, appSecret) => { const getOpenTokenByAppKey = async (appKey, appSecret) => {
const data = await this.postRequest(`${ydzUrl}/api/opreceive/accessAuth/getAppTokenByAppKey`, { const data = await this.postRequest(`${ydzUrl}/api/opreceive/accessAuth/getAppTokenByAppKey`, {
"Content-Type": "application/json", "Content-Type": "application/json",
"appKey": appKey, "appKey": appKey,
...@@ -31,12 +31,12 @@ const getOpenTokenByAppKey = async(appKey, appSecret) => { ...@@ -31,12 +31,12 @@ const getOpenTokenByAppKey = async(appKey, appSecret) => {
return data.token return data.token
} }
const getManageIdByOpenToken = async(header) => { const getManageIdByOpenToken = async (header) => {
const data = await this.postRequest(`${centerChannelUrl}/ydz/setup/openAccess/MainTenant/findMainTenant`, {}, header); const data = await this.postRequest(`${centerChannelUrl}/ydz/setup/openAccess/MainTenant/findMainTenant`, {}, header);
return { manageId: data.id } return { manageId: data.id }
} }
const postRequest = async(url, data, headers = {}) => { const postRequest = async (url, data, headers = {}) => {
try { try {
console.log(` ${url} : 请求信息 ------- `); console.log(` ${url} : 请求信息 ------- `);
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
...@@ -52,10 +52,10 @@ const postRequest = async(url, data, headers = {}) => { ...@@ -52,10 +52,10 @@ const postRequest = async(url, data, headers = {}) => {
console.log(result); console.log(result);
system.execLogs( system.execLogs(
`请求易代账`, { `请求易代账`, {
url, url,
data, data,
headers headers
}, },
'交付请求', '交付请求',
result, result,
null null
...@@ -78,6 +78,6 @@ const postRequest = async(url, data, headers = {}) => { ...@@ -78,6 +78,6 @@ const postRequest = async(url, data, headers = {}) => {
module.exports = { module.exports = {
pushYiDaZhang, pushYiDaZhang,
getManageIdByOpenToken, getManageIdByOpenToken,
getAppTokenByAppKey, // getAppTokenByAppKey,
postRequest postRequest
} }
\ No newline at end of file
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