Commit fd64dc6d by 王昆

ddg

parent 010c42d8
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
const validation = system.getObject("util.validation");
var moment = require('moment');
const settings = require("../../../../config/settings");
const axios = require("axios");
class InvoiceCtl extends CtlBase {
constructor() {
super();
......@@ -139,6 +141,7 @@ class InvoiceCtl extends CtlBase {
"invoice_type": invoice_type,
"invoice_amount": amount
});
// TODO 总统计算 end
invoiceList.push({
"name": businessmen.name,
......@@ -163,17 +166,18 @@ class InvoiceCtl extends CtlBase {
// TODO 总统计算 begin
// 计算税金
try {
let url = settings.deliverSysApi().calcInvoice;
let res = await axios({
method: 'post',
url: url,
data: calcParams
});
if(!res || !res.data || res.status !=0){
if(!res || !res.data || res.data.status !=0 || res.data.data.length==0){
return system.getResult(null,`试算错误`);
}
let calcList = res.data;
let calcList = res.data.data;
let calcMap = {};
for (let c of calcList) {
calcMap[c.credit_code] = c;
......@@ -201,6 +205,10 @@ class InvoiceCtl extends CtlBase {
},
invoiceList: invoiceList
}
} catch (error) {
console.log(error);
return system.getResult(null,`系统错误`);
}
}
async platformInvoiceApply(params, pobj2, req) {
......
......@@ -71,9 +71,11 @@ class SaasinvoiceService extends ServiceBase {
return system.getResult(null, "发票状态错误,请刷新重试");
}
// TODO 总统 推送发票信息 begin
await this.pushInvoiceToDeliver(apply);
let res = await this.pushInvoiceToDeliver(apply);
// TODO 总统 推送发票信息 end
if(!res || !res.data || res.status!=0){
return system.getResult(null ,`发票推送失败`);
}else{
let updateStatus = {
id: apply.id,
preStatus: "1010",
......@@ -82,6 +84,7 @@ class SaasinvoiceService extends ServiceBase {
let rs = await this.invoiceapplyStatus(updateStatus);
return rs;
}
}
/**
* fn:发票推送
......@@ -102,42 +105,36 @@ class SaasinvoiceService extends ServiceBase {
* 4. 申请时间 不存在
*/
async pushInvoiceToDeliver(invoice) {
try {
let params = {
"businessmen_type": this.DEFAULT_BUSINESSMEN_TYPE,
"from_id": invoice.from_id || "",
"from_credit_code": invoice.from_credit_code,
"from_name": invoice.from_name,
"from_addr": invoice.from_addr,
"from_mobile": invoice.from_mobile,
"from_bank": invoice.from_bank || "",
"from_account": invoice.from_account || "",
"businessmen_id": invoice.from_id || "",
"businessmen_credit_code": invoice.from_credit_code,
"businessmen_name": invoice.from_name,
"businessmen_addr": invoice.from_addr,
"businessmen_mobile": invoice.from_mobile,
"businessmen_bank": invoice.from_bank || "",
"businessmen_account": invoice.from_account || "",
"mail_to": invoice.mail_to,
"mail_mobile": invoice.mail_mobile,
"mail_addr": invoice.mail_addr,
"to_id": invoice.to_id || "",
"to_name": invoice.to_name,
"to_credit_code": invoice.to_credit_code,
"to_addr": invoice.to_addr,
"to_mobile": invoice.to_mobile,
"to_bank": invoice.to_bank,
"to_account": invoice.to_account,
"merchant_id": invoice.to_id || "",
"merchant_name": invoice.to_name,
"merchant_credit_code": invoice.to_credit_code,
"merchant_addr": invoice.to_addr,
"merchant_mobile": invoice.to_mobile,
"merchant_bank": invoice.to_bank,
"merchant_account": invoice.to_account,
"apply_no": invoice.id,
"invoice_type": invoice.invoice_type,
"apply_time": invoice.apply_time,
"apply_time": invoice.created_at,
"invoice_amount": invoice.invoice_amount,
"invoice_content": invoice_content || "",
"personal_invoice_tax": invoice.personal_invoice_tax,
"additional_tax": invoice.additional_tax,
"value_added_tax": invoice.value_added_tax,
"invoice_content": invoice.invoice_content || "",
"personal_invoice_tax": invoice.personal_invoice_tax || 0,
"additional_tax": invoice.additional_tax || 0,
"value_added_tax": invoice.value_added_tax || 0,
"channel_id": this.DEFAULT_CHANNEL_ID
}
let rs = await this.callms("invoice", "invoiceApply", params);
return rs;
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误`);
}
return await this.callms("invoice", "invoiceApply", params);
}
}
module.exports = SaasinvoiceService;
\ No newline at end of file
......@@ -206,7 +206,7 @@ class System {
uc: dev + ":3106" + path,
// 交易
trade: local + ":3107" + path,
trade: dev + ":3107" + path,
}
} else {
return {
......
......@@ -90,7 +90,8 @@ var settings = {
deliverSysApi: function () {
let domain = "";
if (this.env == "dev") {
domain = "http://39.107.234.14:3002";
// domain = "http://39.107.234.14:3002";
domain = "http://127.0.0.1:3002";
} else {
domain = "https://xggadmin.gongsibao.com";
}
......
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