Commit 14cbd8b4 by 王昆

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

parents c395fb97 d5664c7b
......@@ -166,6 +166,85 @@ class InvoiceCtl extends CtlBase {
return system.getResultSuccess(data);
}
// 功能1开票
async apply00(params, pobj2, req) {
validation.check(params, 'data_ids', {name: "提示信息", arr_require: true});
let title = await this.merchantSve.title(params) || {};
title = title.data || {};
if (!title.merchant_name || !title.merchant_credit_code || !title.merchant_addr
|| !title.merchant_mobile || !title.merchant_bank || !title.merchant_account) {
return system.getResult(null, "开票抬头不完整,请联系平台");
}
let addr = await this.merchantSve.addr(params) || {};
addr = addr.data || {};
if (!addr || !addr.mail_to || !addr.mail_addr || !addr.mail_mobile) {
return system.getResult(null, "开票邮寄不完整");
}
let orders = await this.orderSve.byIds({
ids: params.data_ids,
saas_merchant_id: params.saas_merchant_id,
attrs: "id",
handle_status: ['20','30'],
unInvoice: true,
}) || [];
if (orders.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) {
return system.getResult(null, "商户未设置转账交易主体,请联系平台进行设置、");
}
let main = info.main_trade || {};
let batch_no = await this.redisClient.genrateId("invoice_batch_no");
let apply_no = batch_no;
let data = {
saas_id: params.saas_id,
saas_merchant_id: params.saas_merchant_id,
parent_id: "",
owner_type: "00",
status: "1000",
batch_no: batch_no,
apply_no: apply_no,
fee_type: this.trim(params.fee_type),
invoice_type: this.trim(params.invoice_type),
from_name: main.name,
from_credit_code: main.credit_code,
from_mobile: main.mobile,
from_addr: main.addr,
from_bank: main.bank_name,
from_account: main.bank_account,
to_name: this.trim(title.merchant_name),
to_credit_code: this.trim(title.merchant_credit_code),
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),
};
data = await this.invoiceSve.applySave(data);
console.log(data);
data = data.data;
if (!data || !data.id) {
return system.getResult(null, "网络异常,发票申请失败");
}
let rs = await this.orderSve.updateInvoice({ids: params.data_ids, saas_invoice_id: data.id});
console.log(rs);
console.log(data);
return system.getResultSuccess(data);
}
//发票申请列表
async merchantinvoiceapplyPage(params, pobj2, req) {
try {
......
......@@ -74,6 +74,14 @@ class InvoiceService extends ServiceBase {
}
}
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 = InvoiceService;
\ No newline at end of file
......@@ -187,10 +187,10 @@ class System {
merchant: dev + ":3101" + path,
// 订单服务
order: dev + ":3103" + path,
order: local + ":3103" + path,
// 发票服务
invoice: dev + ":3105" + path,
invoice: local + ":3105" + path,
// 用户服务
uc: dev + ":3106" + 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