Commit 01e9cb85 by 孙亚楠

Merge branch 'xggsve-invoice-dev' of gitlab.gongsibao.com:jiangyong/zhichan into xggsve-invoice-dev

parents 7dbe31bf d5a08535
......@@ -66,7 +66,7 @@ class IInvoiceDao extends Dao {
}
if(params.bd_path) {
params.bd_path_like = params.bd_path + "%";
sql.push("AND t1.`bd_path` = :bd_path_like");
sql.push("AND t1.`bd_path` LIKE :bd_path_like");
}
}
......
......@@ -14,8 +14,8 @@ class IInvoiceService extends ServiceBase {
this.iinvoiceprocessDao = system.getObject("db.invoice.iinvoiceprocessDao");
this.iinvoiceinforegDao = system.getObject("db.invoice.iinvoiceinforegDao");
this.iinvoicedeliverDao = system.getObject("db.invoice.iinvoicedeliverDao");
this.RULE_INVOICE_TYPE =["10",'20','30']; //发票类型
this.RULE_BUSINESSMEN_TYPE=['10','20']; //销售方类型
this.RULE_INVOICE_TYPE = ["10", '20', '30']; //发票类型
this.RULE_BUSINESSMEN_TYPE = ['10', '20']; //销售方类型
this.DEFAULT_PRODUCT_ID = "50010000"; //默认产品ID
this.iproductDao = system.getObject("db.product.iproductDao");
this.iprocessDao = system.getObject("db.product.iprocessDao");
......@@ -26,31 +26,31 @@ class IInvoiceService extends ServiceBase {
* 发票申请
* @param {*} params
*/
async invoiceApply(params){
if(!params.channel_id ){
return system.getResult(null,`渠道ID不能为空`);
async invoiceApply(params) {
if (!params.channel_id) {
return system.getResult(null, `渠道ID不能为空`);
}
if(!params.apply_no ){
return system.getResult(null,`发票申请编号不能为空`);
if (!params.apply_no) {
return system.getResult(null, `发票申请编号不能为空`);
}
try {
let invoiceExists =await this.dao.findByChannelAndApplyNo(this.trim(params.channel_id),this.trim(params.apply_no));
if(invoiceExists.total!=0){
return system.getResult(null,`发票编号[${params.apply_no}]已存在`);
}
let invoiceExists = await this.dao.findByChannelAndApplyNo(this.trim(params.channel_id), this.trim(params.apply_no));
if (invoiceExists.total != 0) {
return system.getResult(null, `发票编号[${params.apply_no}]已存在`);
}
} catch (error) {
console.log(error);
return system.getResult(null,`系统错误 ${error}`);
return system.getResult(null, `系统错误 ${error}`);
}
if(this.RULE_INVOICE_TYPE.indexOf(this.trim(params.invoice_type)) ==-1){
return system.getResult(null,`发票类型不存在`);
if (this.RULE_INVOICE_TYPE.indexOf(this.trim(params.invoice_type)) == -1) {
return system.getResult(null, `发票类型不存在`);
}
// if(!params.apply_time){
// return system.getResult(null,`发票申请时间错误`);
// }
if(!params.invoice_content){
return system.getResult(null,`开票内容不能为空`);
if (!params.invoice_content) {
return system.getResult(null, `开票内容不能为空`);
}
// if(!params.contract){
// return system.getResult(null,`合同不能为空`);
......@@ -64,27 +64,27 @@ class IInvoiceService extends ServiceBase {
_invoice.invoice_amount = this.trim(params.invoice_amount) || 0;
_invoice.invoice_content = this.trim(params.invoice_content) || "服务费";
_invoice.contract = this.trim(params.contract) || "";
_invoice.personal_invoice_tax = this.trim(params.personal_invoice_tax) || 0 ;
_invoice.additional_tax = this.trim(params.additional_tax) || 0 ;
_invoice.value_added_tax = this.trim(params.value_added_tax) || 0 ;
_invoice.personal_invoice_tax = this.trim(params.personal_invoice_tax) || 0;
_invoice.additional_tax = this.trim(params.additional_tax) || 0;
_invoice.value_added_tax = this.trim(params.value_added_tax) || 0;
_invoice.product_id = params.product_id || this.DEFAULT_PRODUCT_ID;
if(!params.merchant_name){
return system.getResult(null,`购买方名称不能为空`);
if (!params.merchant_name) {
return system.getResult(null, `购买方名称不能为空`);
}
if(!params.merchant_credit_code){
return system.getResult(null,`购买方社会统一信用代码不能为空`);
if (!params.merchant_credit_code) {
return system.getResult(null, `购买方社会统一信用代码不能为空`);
}
if(!params.merchant_addr){
return system.getResult(null,`购买方地址不能为空`);
if (!params.merchant_addr) {
return system.getResult(null, `购买方地址不能为空`);
}
if(!params.merchant_mobile){
return system.getResult(null,`购买方电话不能为空`);
if (!params.merchant_mobile) {
return system.getResult(null, `购买方电话不能为空`);
}
if(!params.merchant_bank){
return system.getResult(null,`购买方开户行不能为空`);
if (!params.merchant_bank) {
return system.getResult(null, `购买方开户行不能为空`);
}
if(!params.merchant_account){
return system.getResult(null,`购买方对公账户不能为空`);
if (!params.merchant_account) {
return system.getResult(null, `购买方对公账户不能为空`);
}
_invoice.merchant_id = this.trim(params.merchant_id);
_invoice.merchant_name = this.trim(params.merchant_name);
......@@ -94,26 +94,26 @@ class IInvoiceService extends ServiceBase {
_invoice.merchant_bank = this.trim(params.merchant_bank);
_invoice.merchant_account = this.trim(params.merchant_account);
if(!params.businessmen_name){
return system.getResult(null,`销售方名称不能为空`);
if (!params.businessmen_name) {
return system.getResult(null, `销售方名称不能为空`);
}
if(!params.businessmen_credit_code){
return system.getResult(null,`销售方社会统一信用代码不能为空`);
if (!params.businessmen_credit_code) {
return system.getResult(null, `销售方社会统一信用代码不能为空`);
}
if(!params.businessmen_addr){
return system.getResult(null,`销售方地址不能为空`);
if (!params.businessmen_addr) {
return system.getResult(null, `销售方地址不能为空`);
}
if(!params.businessmen_mobile){
return system.getResult(null,`销售方电话不能为空`);
if (!params.businessmen_mobile) {
return system.getResult(null, `销售方电话不能为空`);
}
if(!params.businessmen_bank){
return system.getResult(null,`销售方开户行不能为空`);
if (!params.businessmen_bank) {
return system.getResult(null, `销售方开户行不能为空`);
}
if(!params.businessmen_account){
return system.getResult(null,`销售方对公账户不能为空`);
if (!params.businessmen_account) {
return system.getResult(null, `销售方对公账户不能为空`);
}
if(this.RULE_BUSINESSMEN_TYPE.indexOf(this.trim(params.businessmen_type)) ==-1){
return system.getResult(null,`销售方类型错误`);
if (this.RULE_BUSINESSMEN_TYPE.indexOf(this.trim(params.businessmen_type)) == -1) {
return system.getResult(null, `销售方类型错误`);
}
_invoice.businessmen_type = this.trim(params.businessmen_type);
_invoice.businessmen_id = this.trim(params.businessmen_id);
......@@ -137,11 +137,11 @@ class IInvoiceService extends ServiceBase {
_invoice.status = processList[0].status;
await this.db.transaction(async t => {
_invoice = await this.dao.create(_invoice,t);
await this.iinvoiceinforegDao.create({id:_invoice.id},t);
await this.iinvoicesummaryinfoDao.create({id:_invoice.id},t);
_invoice = await this.dao.create(_invoice, t);
await this.iinvoiceinforegDao.create({ id: _invoice.id }, t);
await this.iinvoicesummaryinfoDao.create({ id: _invoice.id }, t);
for(let process of processList) {
for (let process of processList) {
process.invoice_id = _invoice.id;
}
await this.iinvoiceprocessDao.model.bulkCreate(processList, { transaction: t });
......@@ -149,10 +149,10 @@ class IInvoiceService extends ServiceBase {
return system.getResult(`success`);
} catch (error) {
console.log(error);
return system.getResult(null,`系统错误`);
return system.getResult(null, `系统错误`);
}
}
async invoicePage(params) {
params.currentPage = Number(params.currentPage || 1);
params.pageSize = Number(params.pageSize || 10);
......@@ -175,7 +175,7 @@ class IInvoiceService extends ServiceBase {
await this.setProduct(list);
}
return { count: total, rows: list };
return system.getResultSuccess({ count: total, rows: list });
}
/**
......@@ -189,7 +189,7 @@ class IInvoiceService extends ServiceBase {
productIdList.push(item.product_id);
}
}
if(!productIdList || productIdList.length === 0) {
if (!productIdList || productIdList.length === 0) {
return;
}
let productMap = await this.iproductDao.mapByIds(productIdList);
......@@ -205,12 +205,13 @@ class IInvoiceService extends ServiceBase {
let ids = [];
for (let item of list) {
item.invoice_deliver = {};
if (!item.invoice_deliver_id) {
continue;
}
ids.push(item.invoice_deliver_id)
}
if(!ids || ids.length === 0) {
if (!ids || ids.length === 0) {
return;
}
......@@ -233,7 +234,7 @@ class IInvoiceService extends ServiceBase {
statuses.push(item.status);
}
if(!ids || ids.length === 0 || !statuses || statuses.length === 0) {
if (!ids || ids.length === 0 || !statuses || statuses.length === 0) {
return;
}
......
......@@ -39,7 +39,7 @@ class IinvoicedeliverService extends ServiceBase {
await this.setStatus(list);
await this.setProduct(list);
}
return { count: total, rows: list };
return system.getResultSuccess({ count: total, rows: list });
}
/**
......
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