Commit 2f806950 by 王昆

Merge branch 'xgg-saas-merchant' of gitlab.gongsibao.com:jiangyong/zhichan into xgg-saas-merchant

parents 98ffcca1 39d502fa
...@@ -294,22 +294,28 @@ class InvoiceCtl extends CtlBase { ...@@ -294,22 +294,28 @@ class InvoiceCtl extends CtlBase {
let orders = await this.orderSve.byIds({ let orders = await this.orderSve.byIds({
ids: params.data_ids, ids: params.data_ids,
saas_merchant_id: params.saas_merchant_id, saas_merchant_id: params.saas_merchant_id,
attrs: "id", attrs: "id,price",
handle_status: ['20','30'], handle_status: ['20','30'],
unInvoice: true, unInvoice: true,
}) || []; }) || [];
if (orders.data.length != params.data_ids.length) { if (orders.data.length != params.data_ids.length) {
return system.getResult(null, "订单数据选择有误,请重新搜索后选择"); return system.getResult(null, "订单数据选择有误,请重新搜索后选择");
} }
let invoice_amount = 0;
for(let item of orders.data){
invoice_amount = invoice_amount + Number(item.price || 0);
}
let info = await this.merchantSve.signInfo({id: params.saas_merchant_id}) || {}; let info = await this.merchantSve.signInfo({id: params.saas_merchant_id}) || {};
// service_tax
info = info.data || {}; info = info.data || {};
if (!info.main_trade) { if (!info.main) {
return system.getResult(null, "商户未设置转账交易主体,请联系平台进行设置、"); return system.getResult(null, "商户未设置转账交易主体,请联系平台进行设置、");
} }
let main = info.main_trade || {}; let main = info.main || {};
let batch_no = await this.redisClient.genrateId("invoice_batch_no"); let batch_no = await this.redisClient.genrateId("invoice_batch_no");
let apply_no = batch_no; let apply_no = batch_no;
let service_tax = parseFloat((Number(invoice_amount) * Number(info.invoice_service_rate) / 100).toFixed(2));
let data = { let data = {
saas_id: params.saas_id, saas_id: params.saas_id,
saas_merchant_id: params.saas_merchant_id, saas_merchant_id: params.saas_merchant_id,
...@@ -338,6 +344,10 @@ class InvoiceCtl extends CtlBase { ...@@ -338,6 +344,10 @@ class InvoiceCtl extends CtlBase {
mail_addr: this.trim(addr.mail_addr), mail_addr: this.trim(addr.mail_addr),
mail_mobile: this.trim(addr.mail_mobile), mail_mobile: this.trim(addr.mail_mobile),
mail_to: this.trim(addr.mail_to), mail_to: this.trim(addr.mail_to),
invoice_amount:invoice_amount,
service_tax:service_tax,
}; };
data = await this.invoiceSve.applySave(data); data = await this.invoiceSve.applySave(data);
......
...@@ -61,6 +61,15 @@ class OrderService extends ServiceBase { ...@@ -61,6 +61,15 @@ class OrderService extends ServiceBase {
row.price = system.f2y(row.price); row.price = system.f2y(row.price);
} }
} }
async byIds(params) {
let rs = await this.callms("order", "itemByIds", params);
return rs;
}
async updateInvoice(params) {
let rs = await this.callms("order", "updateItemInvoice", params);
return rs;
}
} }
module.exports = OrderService; module.exports = OrderService;
\ No newline at end of file
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