Commit 41be9a5b by Sxy

feat: 给财税中心传建账信息

parent fa903c92
......@@ -91,7 +91,7 @@ class DeliverybillCtl extends CtlBase {
if (!pobj.deliverId) {
throw new Error("deliverId 不能为空");
}
if (!pobj.contactsName || !pobj.time || !pobj.accountingType || !pobj.taxpayerType || !pobj.supplier) {
if (!pobj.contactsName || !pobj.time || !pobj.accountingType || !pobj.taxpayerType || (!pobj.supplier && pobj.supplier != 0)) {
throw new Error("参数不能为空");
}
const rs = await this.service.setupBill(pobj);
......
......@@ -3,6 +3,7 @@ const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const System = require("../../../system");
const appconfig = system.getSysConfig();
const toFtClient = require("../../../utils/toFtClient");
class DeliverybillService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(DeliverybillService));
......@@ -65,6 +66,7 @@ class DeliverybillService extends ServiceBase {
if (deliverData.delivery_info.setupStatus && deliverData.delivery_info.setupStatus === system.SERVERSESTATUS.SETUP) {
throw new Error("已建账");
}
await toFtClient.addCusAccApplyInfo(deliverData, pobj);
await this.dao.updateByWhere({
delivery_info: {
...delivery_info,
......
......@@ -23,7 +23,7 @@ const postRequest = async (url, data, headers = {}) => {
timeout: 5000,
});
result = result.data;
console.log("${url} : 返回数据 ------- ");
console.log(`${url} : 返回数据 ------- `);
console.log(JSON.stringify(result));
if (result.code == 1) {
return result.data
......@@ -54,7 +54,7 @@ const postToFt = (url, data, headers = {}) => {
* @param {*} headers
*/
const postToFtBySign = async (url, data, headers = {}) => {
let tenantInfo = await getChannelCompany();
let tenantInfo = await getChannelCompany(data.companyId);
data.companyId = tenantInfo.id;
let sign = system.signValid(data, tenantInfo.signSecret);
return postRequest(`${ftConfig.url}${url}`, { ...data, sign }, headers = {})
......@@ -74,7 +74,12 @@ const getChannelCompany = async (id) => {
});
companyData = companyData.datas;
if (id) {
// TODO: 获取单个信息
companyData = _.find(companyData, (item) => {
return item.id === id
})
if (!companyData) {
throw new Error(("查不到租户信息"));
}
}
return companyData;
}
......@@ -104,9 +109,9 @@ const addCusAccApplyInfo = async (deliverData, pobj) => {
valueAddedTax: valueAddedTax[pobj.taxpayerType],
serviceTime: moment(deliverData.delivery_info.serviceEndTime).diff(moment(deliverData.delivery_info.serviceStartTime), 'months').toString(),
initPeriod: parseInt(moment(deliverData.delivery_info.serviceStartTime).format('YYYYMMDD')),
companyId: pobj.supplier
}
const data = await postToFtBySign('/cusAccApplyInfo/addCusAccApplyInfo', reqData);
console.log(data);
await postToFtBySign('/cusAccApplyInfo/addCusAccApplyInfo', reqData);
}
// console.log(moment("2021-05-31").diff(moment("2020-06-01"), 'months', true).toString())
......@@ -114,4 +119,4 @@ module.exports = {
postToFtBySign,
addCusAccApplyInfo,
getChannelCompany
}
}
\ 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