Commit 8dec9120 by Sxy

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

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