Commit e8e019fd by Sxy

feat:交付商信息

parent d7ea23a4
...@@ -6,6 +6,7 @@ var settings = require("../../../../config/settings"); ...@@ -6,6 +6,7 @@ var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base"); const CtlBase = require("../../ctl.base");
const moment = require('moment'); const moment = require('moment');
const System = require("../../../system"); const System = require("../../../system");
const toFtClient = require("../../../utils/toFtClient");
const appconfig = system.getSysConfig(); const appconfig = system.getSysConfig();
class DeliverybillCtl extends CtlBase { class DeliverybillCtl extends CtlBase {
constructor() { constructor() {
...@@ -119,6 +120,9 @@ class DeliverybillCtl extends CtlBase { ...@@ -119,6 +120,9 @@ class DeliverybillCtl extends CtlBase {
/** /**
* 分配人 * 分配人
* @param {*} pobj
* @param {*} qobj
* @param {*} req
*/ */
async distributionPerson(pobj, qobj, req) { async distributionPerson(pobj, qobj, req) {
try { try {
...@@ -144,9 +148,29 @@ class DeliverybillCtl extends CtlBase { ...@@ -144,9 +148,29 @@ class DeliverybillCtl extends CtlBase {
} }
} }
/**
* 获取交付商信息
* @param {*} pobj
* @param {*} qobj
* @param {*} req
*/
async getChannelCompany(pobj, qobj, req) {
try {
const rs = await toFtClient.getChannelCompany();
return system.getResult(rs.map(item => {
return {
id: item.id,
name: item.name
}
}));
} catch (err) {
return system.getResult(null, err.message)
}
}
// 创建融易算服务实例 // 创建融易算服务实例
async insertInfo(mobj, qobj, req) { async insertInfo(mobj, qobj, req) {
console.log('mobj--------------------------------',mobj); console.log('mobj--------------------------------', mobj);
try { try {
var pobj = mobj.actionBody; var pobj = mobj.actionBody;
var cachestr = sha235(JSON.stringify(pobj)); var cachestr = sha235(JSON.stringify(pobj));
...@@ -281,7 +305,7 @@ class DeliverybillCtl extends CtlBase { ...@@ -281,7 +305,7 @@ class DeliverybillCtl extends CtlBase {
} }
} }
async portog(){ async portog() {
console.log(settings.port); console.log(settings.port);
} }
} }
......
const axios = require("axios"); const axios = require("axios");
const settings = require("../../config/settings"); const settings = require("../../config/settings");
const system = require("../system"); const system = require("../system");
const moment = require('moment');
const ftConfig = settings.ftConfig(); const ftConfig = settings.ftConfig();
let ftTenantInfo; // 财税中心 缓存 const _ = require("lodash")
/** /**
* 发送 post 请求 * 发送 post 请求
...@@ -12,7 +13,7 @@ let ftTenantInfo; // 财税中心 缓存 ...@@ -12,7 +13,7 @@ let ftTenantInfo; // 财税中心 缓存
*/ */
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))
let result = await axios.post(url, data, { let result = await axios.post(url, data, {
headers: { headers: {
...@@ -22,7 +23,7 @@ const postRequest = async (url, data, headers = {}) => { ...@@ -22,7 +23,7 @@ const postRequest = async (url, data, headers = {}) => {
timeout: 5000, timeout: 5000,
}); });
result = result.data; result = result.data;
console.log("推送财税中心返回数据 ------- "); console.log("${url} : 返回数据 ------- ");
console.log(JSON.stringify(result)); console.log(JSON.stringify(result));
if (result.code == 1) { if (result.code == 1) {
return result.data return result.data
...@@ -62,47 +63,55 @@ const postToFtBySign = async (url, data, headers = {}) => { ...@@ -62,47 +63,55 @@ const postToFtBySign = async (url, data, headers = {}) => {
/** /**
* 财税 获取 租户信息 * 财税 获取 租户信息
*/ */
const getChannelCompany = async () => { const getChannelCompany = async (id) => {
// 内存 缓存
if (ftTenantInfo) {
return ftTenantInfo
}
let reqData = { let reqData = {
channelCode: ftConfig.channelCode, channelCode: ftConfig.channelCode,
} }
let sign = system.signValid(reqData, ftConfig.secret); let sign = system.signValid(reqData, ftConfig.secret);
const companyData = await postToFt("/company/getChannelCompany", { let companyData = await postToFt("/company/getChannelCompany", {
...reqData, ...reqData,
sign sign
}); });
if (companyData.datas && companyData.datas.length > 0) { companyData = companyData.datas;
ftTenantInfo = companyData.datas[0] if (id) {
return ftTenantInfo; // TODO: 获取单个信息
} else {
throw ("渠道码信息获取错误");
} }
return companyData;
} }
/** /**
* 建账 * 建账
* @param {*} deliverData
* @param {*} pobj
*/ */
const addCusAccApplyInfo = async () => { const addCusAccApplyInfo = async (deliverData, pobj) => {
const accountStandard = {
"小企业会计准则": 1,
"企业会计准则": 2
}
const valueAddedTax = {
"小规模纳税人": 0,
"一般纳税人": 1,
"个体工商户": 2
}
let reqData = { let reqData = {
accountStandard: 1, accountStandard: accountStandard[pobj.accountingType],
applyDate: "2020-09-10", applyDate: pobj.time,
contact: "JAMES7", contact: deliverData.delivery_info.contactsName,
creditCode: "911101053516460817K", creditCode: deliverData.delivery_info.creditCode,
customerName: "北京融易算", customerName: deliverData.delivery_info.companyName,
phoneNumber: "18510669367", phoneNumber: deliverData.delivery_info.contactsPhone,
valueAddedTax: 1, valueAddedTax: valueAddedTax[pobj.taxpayerType],
serviceTime: "5", serviceTime: moment(deliverData.delivery_info.serviceEndTime).diff(moment(deliverData.delivery_info.serviceStartTime), 'months').toString(),
initPeriod: 202009, initPeriod: parseInt(moment(deliverData.delivery_info.serviceStartTime).format('YYYYMMDD')),
} }
const data = await postToFtBySign('/cusAccApplyInfo/addCusAccApplyInfo', reqData); const data = await postToFtBySign('/cusAccApplyInfo/addCusAccApplyInfo', reqData);
console.log(data); console.log(data);
} }
// console.log(moment("2021-05-31").diff(moment("2020-06-01"), 'months', true).toString())
module.exports = { module.exports = {
postToFtBySign, postToFtBySign,
addCusAccApplyInfo addCusAccApplyInfo,
getChannelCompany
} }
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