Commit 41be9a5b by Sxy

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

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