Commit 823f9503 by 孙亚楠

d

parent 31af8d85
......@@ -19,7 +19,9 @@ class InvoiceCtl extends CtlBase {
async audit(params, pobj2, req) {
try {
params.id = this.trim(params.id);
if (!params.id) {
let saasInvoiceApply = await this.saasinvoiceSve.getSaasInvoiceById({id:params.id,attrs:"id,fee_type,data_ids"});
saasInvoiceApply = saasInvoiceApply.status==0?saasInvoiceApply.data:null;
if (!params.id || !saasInvoiceApply || !saasInvoiceApply.id) {
return system.getResult(null, "发票申请不存在");
}
params.remark = this.trim(params.remark);
......@@ -27,9 +29,22 @@ class InvoiceCtl extends CtlBase {
return system.getResult(null, "请填写审核备注");
}
params.status = Number(params.status || 0) ? "1010" : "1020";
let rs = await this.saasinvoiceSve.audit(params)
if (rs.status === 0 && !params.status) {
await this.tradeSve.cancelInvoice({saas_invoice_id: params.id});
let rs = await this.saasinvoiceSve.audit(params);
if (rs.status === 0 && params.status == "1020") {
let data_ids = saasInvoiceApply.data_ids;
if(!data_ids || data_ids.split(',').length==0){
return rs;
}
let fee_type = saasInvoiceApply.fee_type;
if(fee_type=="10" || fee_type=="20"){//交易流水
// await this.tradeSve.cancelInvoice({saas_invoice_id: params.id});
await this.tradeSve.cancelInvoiceByDataIds({data_ids: data_ids.split(',')});
}else if(fee_type=="00"){ //注册订单
await this.orderSve.cancelInvoiceByDataIds({data_ids: data_ids.split(',')});
}else{
return rs;
}
}
return rs;
} catch (error) {
......
......@@ -111,5 +111,12 @@ class OrderService extends ServiceBase {
row.price = system.f2y(row.price);
}
}
async cancelInvoiceByDataIds(params) {
let rs = await this.callms("order", "cancelInvoiceByDataIds", params);
return rs;
}
}
module.exports = OrderService;
\ No newline at end of file
......@@ -254,5 +254,15 @@ class SaasinvoiceService extends ServiceBase {
return system.getResult(null, `系统错误`);
}
}
/**
* fn:根据ID 查询详情
* @param params
* @returns {Promise<{msg: *, data, bizmsg: *|string, status: number}|any|undefined>}
*/
async getSaasInvoiceById(params){
let rs = await this.callms("invoice", "getSaasInvoiceById", params);
return rs;
}
}
module.exports = SaasinvoiceService;
\ No newline at end of file
......@@ -110,6 +110,11 @@ class TradeService extends ServiceBase {
return rs;
}
async cancelInvoiceByDataIds(params) {
let rs = await this.callms("trade", "cancelInvoiceByDataIds", params);
return rs;
}
transFields(rows) {
if (!rows || rows.length == 0) {
return;
......
......@@ -197,7 +197,7 @@ class System {
merchant: dev + ":3101" + path,
// 订单服务
order: dev + ":3103" + path,
order: local + ":3103" + path,
// 发票服务
invoice: local + ":3105" + path,
......
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