Commit a60cc651 by 王昆

gsb

parents 47567dbe 22333022
......@@ -111,7 +111,7 @@ class InvoiceCtl extends CtlBase {
* @param {*} pobj2
* @param {*} req
*/
async uploadDetailSve(pobj, pobj2, req){
async uploadDetail(pobj, pobj2, req){
if(!pobj.invoice_id){
return system.getResult(null,`参数错误 发票ID 不能为空`);
}
......
......@@ -379,6 +379,22 @@ class OrderCtl extends CtlBase {
}
}
/**
* 获取账簿用户信息
* @param {*} pobj
* @param {*} pobj2
* @param {*} req
* @id
*/
async getCustomerById(pobj, pobj2, req){
if(!pobj.id){
return system.getResult(null,`参数错误 ID 不能为空`);
}
let res = await this.orderSve.getCustomerById(pobj.invoice_id);
return res;
}
}
......
......@@ -135,15 +135,15 @@ class InvoiceService extends ServiceBase {
if(!invoicesummaryinfo.summary){
return system.getResult("系统错误 发票摘要信息错误");
}
let _summary = JSON.parse(invoicesummaryinfo.summary);
let _res = [];
for(let item of _summary){
for(let item of invoicesummaryinfo.summary){
// item = JSON.parse(item);
let temp = {
abstractMsg:item.summaryInfo,
attr:{"standard":item.category,"unit":item.unit,"number":item.number,"unit_price":item.unitPrice},
amount:item.amount,
tax:item.taxAmount,
totalPrice:Number(item.amount)+Number(item.tax),
totalPrice:Number(item.amount)+Number(item.taxAmount),
taxRate:item.taxRate,
abstractType:item.summaryType
};
......@@ -166,10 +166,10 @@ class InvoiceService extends ServiceBase {
}
let businessmen = await this.callms("order", "queryObusinessmenByCreditCode", {credit_code:invoice.data.invoicesummaryinfo.businessmen_credit_code});
//获取交付商信息 拿到companyID 在common服务下 参数:通过deliver_id
if(!invoice.data.invoicedeliver[0].deliver_id){
if(!invoice.data.deliver_id){
return system.getResult(`交付商不存在`);
}
var deliver = await this.callms("common", "deliverInfo", {id: invoice.data.invoicedeliver[0].deliver_id});
var deliver = await this.callms("common", "deliverInfo", {id: invoice.data.deliver_id});
if(!deliver.data ){
return system.getResult(null,`交付商不存在`);
}
......@@ -183,13 +183,13 @@ class InvoiceService extends ServiceBase {
return system.getResult("推送失败,参数错误");
}
let url = settings.ntapi().uploadDetail;
let res = await this.callApi(url, data, "提交发票");
let res = await this.callApi(url, _params, "提交发票");
console.log(res);
if(!res || !res.data) {
if(!res || res.code!='000000') {
return system.getResult(null, "提交发票失败");
}
//更新发票建账
await this.callms("invoice", "updateAccountCreation", {id:invoice_id});
await this.callms("invoice", "uploadDetail", {id:invoice_id});
return system.getResultSuccess();
} catch (error) {
console.log(error);
......@@ -201,42 +201,48 @@ class InvoiceService extends ServiceBase {
* 推送票据
*/
async buildParams(businessmen,invoice,deliver){
let _invoicesummaryinfo = invoice.invoicesummaryinfo || null;
if(!_invoicesummaryinfo){
return system.getResult(null, `系统错误 发票信息错误`);
}
let params = {
companyId:deliver.nt_company_id, //公司ID
customerId:businessmen.customer_id, //客户ID
uploadPeriod:moment(businessmen.create_account_time).format('YYYYMM'), //上传账期
imageName: invoice['invoice_img'].slice(str.lastIndexOf("/")+1,-1) ||"", //图片名称
imageBasename:invoice['invoice_img'] || "", //图片url
billType:formatInvoiceType(_invoicesummaryinfo), //发票类型
isDaikai:`1`, //是否代开 1:yes 0:no
signDate:moment(_invoicesummaryinfo.invoice_time).format("YYYY-MM-DD"), //开票时间
invoiceCode:_invoicesummaryinfo.invoice_no, //发票代码
invoiceNumber:_invoicesummaryinfo.invoice_number, //发票号码
invoiceOrder:formatInvoiceJoin(_invoicesummaryinfo), //发票联次
payName:_invoicesummaryinfo.merchant_name,
receiveName:_invoicesummaryinfo.businessmen_name,
payBank:_invoicesummaryinfo.merchant_bank,
payAccount:_invoicesummaryinfo.merchant_account,
payTel:_invoicesummaryinfo.merchant_mobile,
payAddress:_invoicesummaryinfo.merchant_addr,
payAccountAame:"", //xxxx
payerTaxIdentificationNumber:_invoicesummaryinfo.merchant_credit_code,
receiveBank:_invoicesummaryinfo.businessmen_bank,
receiveAccount:_invoicesummaryinfo.businessmen_account,
receiveTel:_invoicesummaryinfo.businessmen_mobile,
receiveAddress:_invoicesummaryinfo.businessmen_addr,
receiveTaxIdentificationNumber:_invoicesummaryinfo.businessmen_credit_code,
province:PROVINCE_CODE_MAP[_invoicesummaryinfo.province],
receiveAccountName:"", //xxxx
sourceClient:"0", //票据来源
createDate:moment(_invoicesummaryinfo.created_at).format("YYYY-MM-DD"), //创建时间
list:formatSummary(_invoicesummaryinfo)
}
return params;
try {
let _invoicesummaryinfo = invoice.invoicesummaryinfo || null;
if(!_invoicesummaryinfo){
return system.getResult(null, `系统错误 发票信息错误`);
}
let params = {
companyId:deliver.nt_company_id, //公司ID
customerId:businessmen.customer_id, //客户ID
uploadPeriod:moment(businessmen.create_account_time).format('YYYYMM'), //上传账期
imageName: invoice['invoice_img'].slice(invoice['invoice_img'].lastIndexOf("/")+1,-1) ||"", //图片名称
imageBasename:invoice['invoice_img'] || "", //图片url
billType:this.formatInvoiceType(_invoicesummaryinfo), //发票类型
isDaikai:`1`, //是否代开 1:yes 0:no
signDate:moment(_invoicesummaryinfo.invoice_time).format("YYYY-MM-DD"), //开票时间
invoiceCode:_invoicesummaryinfo.invoice_no, //发票代码
invoiceNumber:_invoicesummaryinfo.invoice_number, //发票号码
invoiceOrder:this.formatInvoiceJoin(_invoicesummaryinfo), //发票联次
payName:_invoicesummaryinfo.merchant_name,
receiveName:_invoicesummaryinfo.businessmen_name,
payBank:_invoicesummaryinfo.merchant_bank,
payAccount:_invoicesummaryinfo.merchant_account,
payTel:_invoicesummaryinfo.merchant_mobile,
payAddress:_invoicesummaryinfo.merchant_addr,
payAccountAame:"", //xxxx
payerTaxIdentificationNumber:_invoicesummaryinfo.merchant_credit_code,
receiveBank:_invoicesummaryinfo.businessmen_bank,
receiveAccount:_invoicesummaryinfo.businessmen_account,
receiveTel:_invoicesummaryinfo.businessmen_mobile,
receiveAddress:_invoicesummaryinfo.businessmen_addr,
receiveTaxIdentificationNumber:_invoicesummaryinfo.businessmen_credit_code,
province:PROVINCE_CODE_MAP[_invoicesummaryinfo.province],
receiveAccountName:"", //xxxx
sourceClient:"0", //票据来源
createDate:moment(_invoicesummaryinfo.created_at).format("YYYY-MM-DD HH:ss:mm"), //创建时间
// createDate:new Date(_invoicesummaryinfo.created_at), //创建时间
list:this.formatSummary(_invoicesummaryinfo)
}
return params;
} catch (error) {
console.log(error);
return {};
}
}
......
......@@ -251,5 +251,25 @@ class OrderService extends ServiceBase {
return system.getResult(null,`系统错误 错误信息 ${error}`);
}
}
/**
* 获取用户账簿信息
* @param {*} params
* id 个体工商户ID
*/
async getCustomerById(params){
try {
let businessmen = await this.callms("order", "queryObusinessmen", {id:params.id});
if(!businessmen || !businessmen.data){
return system.getResult(null,`个体工商户不存在`);
}
let url = settings.ntapi().getCustomerById;
let res = await this.callApi(url, {id:businessmen.customer_id}, "获取用户账簿信息");
return res;
} catch (error) {
console.log(error);
return system.getResult(null,`系统错误`);
}
}
}
module.exports = OrderService;
\ No newline at end of file
......@@ -186,8 +186,8 @@ class System {
// order: "http://127.0.0.1:3103" + path,
// 发票服务
// invoice: domain2 + ":3105" + path,
invoice: "http://127.0.0.1:3105" + path,
invoice: domain2 + ":3105" + path,
// invoice: "http://127.0.0.1:3105" + path,
// 用户中心
uc: domain + ":3106" + path ,
......
......@@ -94,7 +94,7 @@ var settings = {
domain_page = "https://nga.gongsibao.com";
}
return {
return {
// 税务登录地址
taxLoginUrl: domain_page + "/web/auth",
// 财务地址
......@@ -105,15 +105,15 @@ var settings = {
updateCompanyStatus: domain + "/nga-api/company/updateCompanyStatus",
// 建账
createCustomer: domain + "/nga-api/createCustomer",
// 查询账户信息
getCustomerById: domain + "/nga-api/getCustomerById",
// 上传发票
uploadDetail: domain + "/nga-api/uploadDetail",
// 获取用户账簿
getCustomerById: domain + "/nga-api/getCustomerById",
// 月报表
getReportData: domain + "/nga-api/report/getReportData",
// 季报表
getReportDataQuarter: domain + "/nga-api/report/getReportDataQuarter",
}
getReportDataQuarter: domain + "/nga-api/report/getReportDataQuarter"
};
},
redis: function () {
if (this.env == "dev") {
......
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