Commit fd64dc6d by 王昆

ddg

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