Commit f5fa03cc by 王昆

gsb

parent f50cf729
var system = require("../../../system") var system = require("../../../system")
const CtlBase = require("../../ctlms.base"); const CtlBase = require("../../ctlms.base");
var moment = require('moment'); var moment = require('moment');
class InvoiceCtl extends CtlBase { class InvoiceCtl extends CtlBase {
constructor() { constructor() {
super(); super();
this.invoiceSve = system.getObject("service.invoice.invoiceSve"); this.invoiceSve = system.getObject("service.invoice.invoiceSve");
this.userSve = system.getObject("service.uc.userSve"); this.userSve = system.getObject("service.uc.userSve");
this.INVOICE_TYPE = ["10","20","30"]; this.INVOICE_TYPE = ["10", "20", "30"];
} }
/** /**
...@@ -128,18 +129,18 @@ class InvoiceCtl extends CtlBase { ...@@ -128,18 +129,18 @@ class InvoiceCtl extends CtlBase {
return res; return res;
} }
/** // /**
* 发票试算接口 // * 发票试算接口
* @param {*} pobj // * @param {*} pobj
*/ // */
async calcInvoice(pobj) { // async calcInvoice(pobj) {
try { // try {
return await this.invoiceSve.calcInvoice(pobj); // return await this.invoiceSve.calcInvoice(pobj);
} catch (error) { // } catch (error) {
console.log(error); // console.log(error);
return system.getResultFail(500, `接口错误 错误信息 ${error}`); // return system.getResultFail(500, `接口错误 错误信息 ${error}`);
} // }
} // }
/** /**
* 发票试算接口 * 发票试算接口
...@@ -168,15 +169,24 @@ class InvoiceCtl extends CtlBase { ...@@ -168,15 +169,24 @@ class InvoiceCtl extends CtlBase {
} }
try { try {
let rs = await this.invoiceSve.calcInvoice(params); let rs = await this.invoiceSve.calcInvoice(params);
if (!rs) { if (rs.status !== 0) {
rs = { res.push({
credit_code: item.credit_code, credit_code: item.credit_code,
msg: "试算失败" status: rs.status,
}; msg: rs.msg
});
continue;
} }
res.push(rs); let data = rs.data;
data.status = rs.status;
res.push(data);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
res.push({
credit_code: item.credit_code,
status: rs.status,
msg: "试算异常," + error.message
});
} }
} }
return system.getResult(res); return system.getResult(res);
...@@ -234,7 +244,6 @@ class InvoiceCtl extends CtlBase { ...@@ -234,7 +244,6 @@ class InvoiceCtl extends CtlBase {
// } // }
// /** // /**
// * 计算发票增值税 // * 计算发票增值税
// * @param {*} pobj // * @param {*} pobj
...@@ -430,4 +439,5 @@ class InvoiceCtl extends CtlBase { ...@@ -430,4 +439,5 @@ class InvoiceCtl extends CtlBase {
// } // }
// } // }
} }
module.exports = InvoiceCtl; module.exports = InvoiceCtl;
\ No newline at end of file
...@@ -377,10 +377,16 @@ class InvoiceService extends ServiceBase { ...@@ -377,10 +377,16 @@ class InvoiceService extends ServiceBase {
value_added_tax = system.f2y(value_added_tax); value_added_tax = system.f2y(value_added_tax);
additional_tax = system.f2y(additional_tax); additional_tax = system.f2y(additional_tax);
service_amount = system.f2y(service_amount); service_amount = system.f2y(service_amount);
return {personal_invoice_tax:personal_invoice_tax,value_added_tax:value_added_tax,additional_tax:additional_tax,service_amount:service_amount,credit_code:params.credit_code}; return system.getResultSuccess({
personal_invoice_tax: personal_invoice_tax,
value_added_tax: value_added_tax,
additional_tax: additional_tax,
service_amount: service_amount,
credit_code: params.credit_code
});
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return null; return system.getResult(null, "试算失败");
} }
} }
......
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