Commit 9b74bb2d by 王昆

gsb

parent 0edf5b3f
...@@ -9,6 +9,8 @@ class InvoiceCtl extends CtlBase { ...@@ -9,6 +9,8 @@ class InvoiceCtl extends CtlBase {
this.tradeSve = system.getObject("service.trade.tradeSve"); this.tradeSve = system.getObject("service.trade.tradeSve");
this.invoiceSve = system.getObject("service.saas.invoiceSve"); this.invoiceSve = system.getObject("service.saas.invoiceSve");
this.merchantSve = system.getObject("service.saas.merchantSve"); this.merchantSve = system.getObject("service.saas.merchantSve");
this.redisClient = system.getObject("util.redisClient");
} }
// 注册订单列表 // 注册订单列表
...@@ -48,6 +50,7 @@ class InvoiceCtl extends CtlBase { ...@@ -48,6 +50,7 @@ class InvoiceCtl extends CtlBase {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
} }
} }
//发票列表 //发票列表
async merchantinvoicePage(params, pobj2, req) { async merchantinvoicePage(params, pobj2, req) {
try { try {
...@@ -76,7 +79,7 @@ class InvoiceCtl extends CtlBase { ...@@ -76,7 +79,7 @@ class InvoiceCtl extends CtlBase {
return await this.orderSve.page(params); return await this.orderSve.page(params);
} catch (error) { } catch (error) {
let msg = error.message; let msg = error.message;
if(msg.startsWith("bpo-validation-error:")) { if (msg.startsWith("bpo-validation-error:")) {
return system.getResult(null, msg.replace("bpo-validation-error:", "")); return system.getResult(null, msg.replace("bpo-validation-error:", ""));
} }
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
...@@ -87,7 +90,7 @@ class InvoiceCtl extends CtlBase { ...@@ -87,7 +90,7 @@ class InvoiceCtl extends CtlBase {
// 功能2开票 // 功能2开票
async apply10(params, pobj2, req) { async apply10(params, pobj2, req) {
validation.check(params, 'data_ids', {name:"交易信息", arr_require: true}); validation.check(params, 'data_ids', {name: "交易信息", arr_require: true});
let title = await this.merchantSve.title(params) || {}; let title = await this.merchantSve.title(params) || {};
title = title.data || {}; title = title.data || {};
...@@ -102,23 +105,53 @@ class InvoiceCtl extends CtlBase { ...@@ -102,23 +105,53 @@ class InvoiceCtl extends CtlBase {
return system.getResult(null, "开票邮寄不完整"); return system.getResult(null, "开票邮寄不完整");
} }
let data = { let trades = await this.tradeSve.byIds({
ids: params.data_ids,
saas_merchant_id: params.saas_merchant_id,
attrs: "id",
trade_statuses: ['00'],
unInvoice: true,
}) || [];
if (trades.data.length != params.data_ids.length) {
return system.getResult(null, "交易数据选择有误,请重新搜索后选择");
}
let info = await this.merchantSve.signInfo({id: params.saas_merchant_id}) || {};
info = info.data || {};
if (!info.main_trade || !info.main_trade.id) {
return system.getResult(null, "商户未设置转账交易主体,请联系平台进行设置、");
}
let main = info.main_trade || {};
let batch_no = await this.redisClient.genrateId("invoice_batch_no");
let apply_no = await this.redisClient.genrateId("invoice_apply_no");
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,
data_ids: params.data_ids, parent_id: "",
owner_type: "00",
status: "1000",
batch_no: batch_no,
apply_no: apply_no,
fee_type: this.trim(params.fee_type), fee_type: this.trim(params.fee_type),
invoice_type: this.trim(params.invoice_type), invoice_type: this.trim(params.invoice_type),
to_name : this.trim(title.merchant_name), from_name: main.name,
to_credit_code : this.trim(title.merchant_credit_code), from_credit_code: main.credit_code,
to_addr : this.trim(title.merchant_addr), from_mobile: main.mobile,
to_mobile : this.trim(title.merchant_mobile), from_addr: main.addr,
to_bank : this.trim(title.merchant_bank), from_bank: main.bank_name,
to_account : this.trim(title.merchant_account), from_account: main.bank_account,
mail_addr : this.trim(addr.mail_addr), to_name: this.trim(title.merchant_name),
mail_mobile : this.trim(addr.mail_mobile), to_credit_code: this.trim(title.merchant_credit_code),
mail_to : this.trim(addr.mail_to), to_addr: this.trim(title.merchant_addr),
to_mobile: this.trim(title.merchant_mobile),
to_bank: this.trim(title.merchant_bank),
to_account: this.trim(title.merchant_account),
mail_addr: this.trim(addr.mail_addr),
mail_mobile: this.trim(addr.mail_mobile),
mail_to: this.trim(addr.mail_to),
}; };
console.log(data); console.log(data);
return system.getResultSuccess(data); return system.getResultSuccess(data);
......
...@@ -247,7 +247,7 @@ class TradeService extends ServiceBase { ...@@ -247,7 +247,7 @@ class TradeService extends ServiceBase {
} }
async byIds(params) { async byIds(params) {
let rs = await this.callms("trade", "orderPay", params); let rs = await this.callms("trade", "itemByIds", params);
return rs; return rs;
} }
......
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