Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
4e88c823
Commit
4e88c823
authored
Mar 10, 2020
by
孙亚楠
Browse files
Options
Browse Files
Download
Plain Diff
dd
parents
593e461f
4e16b406
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
377 additions
and
426 deletions
+377
-426
xggsve-invoice/app/base/api/impl/op/action.js
+92
-73
xggsve-invoice/app/base/service/impl/invoice/iinvoiceSve.js
+285
-0
xggsve-invoice/app/base/service/impl/invoice/invoiceSve.js
+0
-353
No files found.
xggsve-invoice/app/base/api/impl/op/action.js
View file @
4e88c823
...
...
@@ -31,88 +31,107 @@ class ActionAPI extends APIBase {
async
sjbOpActionProcess
(
action_process
,
action_type
,
action_body
)
{
var
opResult
=
null
;
switch
(
action_type
)
{
case
"verificationAndCalculation"
:
// 发票试算接口
case
"invoiceApply"
:
// 发票申请
opResult
=
await
rule
.
dispatcher
(
action_body
);
break
;
case
"calculationValueAddedTax"
:
// 计算增值税
let
calValueAddedTax
=
new
Calculation
(
action_body
);
let
vaInvoice
=
calValueAddedTax
.
getInvoice
();
opResult
=
await
vaInvoice
.
doActionValueAddedTax
(
action_body
);
case
"invoicePage"
:
// 发票申请列表页(平台)
opResult
=
await
rule
.
dispatcher
(
action_body
);
break
;
case
"calculationAdditionalTax"
:
// 计算附加税
let
calAdditionalTax
=
new
Calculation
(
action_body
);
let
addinvoice
=
calAdditionalTax
.
getInvoice
();
opResult
=
await
addinvoice
.
doActionAddtitionalTax
(
action_body
);
case
"deliverInvoicePage"
:
// 发票申请列表页(交付商)
opResult
=
await
rule
.
dispatcher
(
action_body
);
break
;
case
"saveInvoice"
:
// 发票保存
opResult
=
await
this
.
applySve
.
apiSaveInvoice
(
action_body
);
case
"handleStatus"
:
//进度处理
break
;
case
"queryTxPayment"
:
//查看完税证明
opResult
=
await
this
.
invoiceSve
.
apiQueryTxPayment
(
action_body
);
case
"productDics"
:
// 查询产品字典
opResult
=
await
this
.
oproductSve
.
productDics
(
action_body
);
break
;
case
"apiCancelInvoice"
:
// 发票申请单撤回
opResult
=
await
this
.
applySve
.
apiCancelInvoice
(
action_body
);
case
"allProcess"
:
// 查询业务进度
opResult
=
await
this
.
oprocessSve
.
allNames
(
action_body
);
break
;
case
"queryApplyInvoices"
:
// 发票申请列表(平台)
opResult
=
await
this
.
applySve
.
apiQueryApplyInvoices
(
action_body
);
break
;
case
"queryInvoices"
:
// 发票列表(平台)
opResult
=
await
this
.
invoiceSve
.
apiQueryInvoices
(
action_body
);
break
;
case
"queryInvoice"
:
// 发票明细(平台)
opResult
=
await
this
.
applySve
.
apiQueryInvoice
(
action_body
);
break
;
case
"platformAssignment"
:
// 平台审批
opResult
=
await
this
.
applySve
.
apiAssignment
(
action_body
);
break
;
case
"examineAndVerify"
:
//审批(v2)
opResult
=
await
this
.
context
.
request
(
action_body
);
break
;
case
"updateEmail"
:
//平台更新邮寄地址
opResult
=
await
this
.
delivererSve
.
apiUpEmNo
(
action_body
);
break
;
case
"queryProcess"
:
// 查看业务办理(平台)
opResult
=
await
this
.
delivererSve
.
apiQueryProcess
(
action_body
);
break
;
case
"redRushInvoice"
:
//红冲
opResult
=
await
this
.
applySve
.
apiRedRushInvoice
(
action_body
);
break
;
case
"redrushList"
:
opResult
=
await
this
.
invoiceSve
.
apiRedRushList
(
action_body
);
break
;
case
"statTransData"
:
//交易数据
opResult
=
await
this
.
applySve
.
apiStatTransData
(
action_body
);
break
;
case
"statBusinessData"
:
//发票办理
opResult
=
await
this
.
applySve
.
apiStatBusinessData
(
action_body
);
break
;
case
"statDeliverData"
:
//交付商业务概览
opResult
=
await
this
.
delivererSve
.
apiStatDeliverData
(
action_body
);
break
;
// case "verificationAndCalculation": // 发票试算接口
// opResult = await rule.dispatcher(action_body);
// break;
// case "calculationValueAddedTax": // 计算增值税
// let calValueAddedTax = new Calculation(action_body);
// let vaInvoice = calValueAddedTax.getInvoice();
// opResult = await vaInvoice.doActionValueAddedTax(action_body);
// break;
// case "calculationAdditionalTax": // 计算附加税
// let calAdditionalTax = new Calculation(action_body);
// let addinvoice = calAdditionalTax.getInvoice();
// opResult = await addinvoice.doActionAddtitionalTax(action_body);
// break;
// case "saveInvoice": // 发票保存
// opResult = await this.applySve.apiSaveInvoice(action_body);
// break;
// case "queryTxPayment": //查看完税证明
// opResult = await this.invoiceSve.apiQueryTxPayment(action_body);
// break;
// case "apiCancelInvoice": // 发票申请单撤回
// opResult = await this.applySve.apiCancelInvoice(action_body);
// break;
case
"delivererApplyInvoices"
:
//发票申请列表(交付商)
opResult
=
await
this
.
delivererSve
.
apiDelivererApplyInvoices
(
action_body
);
break
;
case
"delivererInvoices"
:
//发票列表(交付商)
opResult
=
await
this
.
delivererSve
.
apiDelInvs
(
action_body
);
break
;
case
"queryInvoiceDeliverer"
:
// 发票明细(交付商)
opResult
=
await
this
.
delivererSve
.
apiQueryInvoiceDeliverer
(
action_body
);
break
;
case
"delivererAssignment"
:
//交付商审批
opResult
=
await
this
.
delivererSve
.
apiAssignment
(
action_body
);
break
;
case
"txPayment"
:
//完税证明更新
opResult
=
await
this
.
invoiceSve
.
apiTxPayment
(
action_body
);
break
;
case
"delStatTransData"
:
//交易数据(交付商)
opResult
=
await
this
.
delivererSve
.
apiDelStatTransData
(
action_body
);
break
;
case
"delStatBusinessData"
:
//发票办理(交付商)
opResult
=
await
this
.
delivererSve
.
apiDelStatBusinessData
(
action_body
);
break
;
// case "queryApplyInvoices": // 发票申请列表(平台)
// opResult = await this.applySve.apiQueryApplyInvoices(action_body);
// break;
// case "queryInvoices": // 发票列表(平台)
// opResult = await this.invoiceSve.apiQueryInvoices(action_body);
// break;
// case "queryInvoice": // 发票明细(平台)
// opResult = await this.applySve.apiQueryInvoice(action_body);
// break;
// case "platformAssignment": // 平台审批
// opResult = await this.applySve.apiAssignment(action_body);
// break;
// case "examineAndVerify": //审批(v2)
// opResult = await this.context.request(action_body);
// break;
// case "updateEmail": //平台更新邮寄地址
// opResult = await this.delivererSve.apiUpEmNo(action_body);
// break;
// case "queryProcess": // 查看业务办理(平台)
// opResult = await this.delivererSve.apiQueryProcess(action_body);
// break;
// case "redRushInvoice": //红冲
// opResult = await this.applySve.apiRedRushInvoice(action_body);
// break;
// case "redrushList":
// opResult = await this.invoiceSve.apiRedRushList(action_body);
// break;
// case "statTransData": //交易数据
// opResult = await this.applySve.apiStatTransData(action_body);
// break;
// case "statBusinessData": //发票办理
// opResult = await this.applySve.apiStatBusinessData(action_body);
// break;
// case "statDeliverData": //交付商业务概览
// opResult = await this.delivererSve.apiStatDeliverData(action_body);
// break;
// case "delivererApplyInvoices": //发票申请列表(交付商)
// opResult = await this.delivererSve.apiDelivererApplyInvoices(action_body);
// break;
// case "delivererInvoices": //发票列表(交付商)
// opResult = await this.delivererSve.apiDelInvs(action_body);
// break;
// case "queryInvoiceDeliverer": // 发票明细(交付商)
// opResult = await this.delivererSve.apiQueryInvoiceDeliverer(action_body);
// break;
// case "delivererAssignment": //交付商审批
// opResult = await this.delivererSve.apiAssignment(action_body);
// break;
// case "txPayment": //完税证明更新
// opResult = await this.invoiceSve.apiTxPayment(action_body);
// break;
// case "delStatTransData": //交易数据(交付商)
// opResult = await this.delivererSve.apiDelStatTransData(action_body);
// break;
// case "delStatBusinessData": //发票办理(交付商)
// opResult = await this.delivererSve.apiDelStatBusinessData(action_body);
// break;
default
:
opResult
=
system
.
getResult
(
null
,
"action_type参数错误"
);
break
;
...
...
xggsve-invoice/app/base/service/impl/invoice/iinvoiceSve.js
0 → 100644
View file @
4e88c823
const
ServiceBase
=
require
(
"../../sve.base"
);
const
system
=
require
(
"../../../system"
);
const
moment
=
require
(
'moment'
)
/**
* 交付商 提交的信息
*/
class
InvoiceService
extends
ServiceBase
{
constructor
()
{
super
(
"invoice"
,
ServiceBase
.
getDaoName
(
InvoiceService
));
let
is
=
system
.
getObject
(
"util.invoiceStatus"
);
this
.
invoiceStatus
=
is
.
status
;
this
.
applyDao
=
system
.
getObject
(
"db.invoice.applyDao"
);
this
.
delivererDao
=
system
.
getObject
(
"db.invoice.delivererDao"
);
}
// /**
// * 完税证明
// * @param {*} params
// */
// async apiTxPayment(params) {
// if (!params.id) {
// return system.getResult(null, `参数错误 发票ID不合法`);
// }
// try {
// let res = await this.txPayment(params);
// return res;
// } catch (error) {
// return system.getResult(null, `参数错误 错误信息 ${error}`);
// }
// }
// /**
// * 查看完税证明
// * @param {*} params
// */
// async apiQueryTxPayment(params) {
// if (!params.id) {
// return system.getResult(null, `参数错误 发票ID不合法`);
// }
// try {
// return await this.queryTxPayment(params);
// } catch (error) {
// return system.getResult(null, `参数错误 错误信息 ${error}`);
// }
// }
// /**
// * 发票列表(平台)
// * @param {*} params
// */
// async apiQueryInvoices(params) {
// try {
// if(params.applyNo){params.applyNo=this.trim(params.applyNo)}
// if(params.type){params.type=this.trim(params.type);}
// if(params.invoiceTime){params.invoiceTime=this.trim(params.invoiceTime);}
// return await this.queryInvoices(params);
// } catch (error) {
// return system.getResult(null, `系统错误 错误信息 ${error}`);
// }
// }
// /**
// * 发票红冲列表
// * @param {*} params
// */
// async apiRedRushList(params) {
// try {
// if(params){}
// let res = await this.redRushList(params);
// return res;
// } catch (error) {
// return system.getResult(null, `参数错误 错误信息 ${error}`);
// }
// }
// //==============================================================
// /**
// * 红冲列表
// * @param {*} params
// */
// async redRushList(params){
// try {
// if (params.delivererId) {
// params.delivererId=this.trim(params.delivererId);
// }
// if (this.trim(params.applyNo)) {
// params.applyNo=this.trim(params.applyNo);
// }
// if (this.trim(params.invoiceNo)) {
// params.invoiceNo=this.trim(params.invoiceNo);
// }
// if (this.trim(params.invoiceTime)) {
// params.invoiceTime=this.trim(params.invoiceTime);
// }
// if (this.trim(params.startTime)) {
// params.startTime=this.trim(params.startTime);
// }
// if (this.trim(params.endTime)) {
// params.endTime=this.trim(params.endTime);
// }
// if (this.trim(params.type)) {
// params.type=this.trim(params.type);
// }
// if (this.trim(params.status)) {
// params.status=this.trim(params.status);
// }
// if (this.trim(params.redStatus)) {
// params.redStatus=this.trim(params.redStatus);
// }
// params.statRow = (Number(this.trim(params.pageIndex)) - 1) * Number(this.trim(params.pageSize));
// if (params.statRow <= 0) { params.statRow = 0; }
// params.pageSize = Number(this.trim(params.pageSize)) <= 0 ? 10 : Number(this.trim(params.pageSize));
// let total = await this.dao.countRedRushListByParams(params);
// if (total == 0 || total[0].count == 0) {
// let res = { rows: [], count: 0 };
// return system.getResult(res);
// }
// let rows = await this.dao.redRushListByParams(params);
// for (let item of rows) {
// if (item.type == "10") {
// item.type = "普通发票";
// } else if (item.type == "20") {
// item.type = "增值税专用发票";
// } else if (item.type == "30") {
// item.type = "电子发票";
// } else {
// item.type = "";
// }
// this.handleDate(item, ["invoice_time"], "YYYY-MM-DD HH:mm:ss", -8);
// this.dao.setRowCodeName(item, "status");
// }
// let res = { count: total[0].count, rows: rows };
// return system.getResult(res);
// } catch (error) {
// return system.getResult(null, `系统错误 错误信息 ${error}`);
// }
// }
// /**
// * 完税证明
// * @param {*} params
// * {
// * id:xxx //完税证明
// * }
// */
// async txPayment(params) {
// try {
// let _invoice = await this.dao.findOne({
// id: this.trim(params.id)
// });
// if (!_invoice) {
// return system.getResult(null, `发票不存在`);
// }
// let res = await this.dao.update({
// id: this.trim(params.id),
// taxNo: this.trim(params.taxNo),
// complateTax: 1,
// taxTime: this.trim(params.taxTime),
// taxVoucher: this.trim(params.taxVoucher)
// });
// return system.getResult(res);
// } catch (error) {
// return system.getResult(null, `参数错误 错误信息 ${error}`);
// }
// }
// /**
// * 查看完税证明
// * @param {*} params
// * {
// * id:xxx //完税证明
// * }
// */
// async queryTxPayment(params) {
// try {
// let _invoice = await this.dao.model.findOne({
// where: {
// id: this.trim(params.id),
// complateTax: 1
// },
// attributes: ['id', 'taxNo', 'complateTax', 'taxTime', 'taxVoucher']
// });
// if (!_invoice) {
// return system.getResult(null, `完税证明不存在`);
// }
// return system.getResult(_invoice);
// } catch (error) {
// return system.getResult(null, `参数错误 错误信息 ${error}`);
// }
// }
// /**
// * 发票列表查询(平台)
// * @param {*} params
// * @param applyNo 发票的申请编号
// * @param invoiceTime 发票的申请时间
// * @param type 发票的类型
// * @param status 业务进度
// */
// async queryInvoices(params) {
// try {
// var pageIndex = Number(params.pageIndex || 1);
// var pageSize = Number(params.pageSize || 10);
// var total = await this.dao.countByParams(params);
// if (total == 0) {
// return system.getResultSuccess({
// count: 0,
// rows: []
// });
// }
// var startRow = (pageIndex - 1) * pageSize;
// var list = await this.dao.pageByParams(params, startRow, pageSize);
// await this.setApply(list);
// for (var item of list) {
// // item.redStatusName = this.dao.getRowCodeName(item, "red_status");
// if (item.red_status == 1) {
// item.red_status = '未红冲';
// } else if (item.red_status == 2) {
// item.red_status = '红冲中';
// } else if (item.red_status == 3) {
// item.red_status = '红冲失败'
// } else if (item.red_status == 4) {
// item.red_status = '红冲成功';
// } else {
// item.red_status = '';
// }
// this.dao.getRowCodeName(item.apply,"status");
// item.complate_tax = item.complate_tax == 1 ? '已完税' : '未完税';
// item.month = moment(item.invoice_time).month() + 1;
// this.handleDate(item,['invoice_time'],null,-8);
// if (item.apply['type'] == '10') {
// item.apply['type'] = "普通发票";
// } else if (item.apply['type'] == '20') {
// item.apply['type'] = "增值税专用发票";
// } else {
// item.apply['type'] = "电子发票";
// }
// }
// var page = {
// count: total,
// rows: list
// };
// return system.getResultSuccess(page);
// } catch (error) {
// console.log(error);
// return system.getResult(`系统错误 错误信息 ${error}`);
// }
// }
// async setApply(list) {
// if (!list || list.length == 0) {
// return;
// }
// var ids = [];
// for (var item of list) {
// ids.push(item.id);
// }
// var applyMap = await this.applyDao.findMapByIds(ids) || {};
// for (var item of list) {
// item.apply = applyMap[item.id] || {};
// }
// }
}
module
.
exports
=
InvoiceService
;
\ No newline at end of file
xggsve-invoice/app/base/service/impl/invoice/invoiceSve.js
deleted
100644 → 0
View file @
593e461f
const
ServiceBase
=
require
(
"../../sve.base"
);
const
system
=
require
(
"../../../system"
);
const
moment
=
require
(
'moment'
)
/**
* 交付商 提交的信息
*/
class
InvoiceService
extends
ServiceBase
{
constructor
()
{
super
(
"invoice"
,
ServiceBase
.
getDaoName
(
InvoiceService
));
let
is
=
system
.
getObject
(
"util.invoiceStatus"
);
this
.
invoiceStatus
=
is
.
status
;
this
.
applyDao
=
system
.
getObject
(
"db.invoice.applyDao"
);
this
.
delivererDao
=
system
.
getObject
(
"db.invoice.delivererDao"
);
}
/**
* 业务员完善订单信息
* @param {*} params
* @id String 订单ID
* @status String 下一个状态
* @other Object 其他参数
*/
async
perfectInformation
(
params
)
{
//验证参数
this
.
verificationPerfectInformation
(
params
);
let
_oorderinforeg
=
await
this
.
oorderinforegDao
.
findById
(
params
.
_order
.
id
);
if
(
!
_oorderinforeg
)
{
return
system
.
getResult
(
null
,
`订单异常 订单明细不存在,请联系管理员`
);
}
//更新订单子表
_oorderinforeg
.
legal_name
=
this
.
trim
(
params
.
legal_name
);
_oorderinforeg
.
id_card
=
this
.
trim
(
params
.
id_card
);
_oorderinforeg
.
legal_mobile
=
this
.
trim
(
params
.
legal_mobile
);
_oorderinforeg
.
names
=
this
.
trim
(
params
.
names
);
_oorderinforeg
.
capital
=
this
.
trim
(
params
.
capital
);
_oorderinforeg
.
domicile_id
=
this
.
trim
(
params
.
domicile_id
);
_oorderinforeg
.
domicile_name
=
this
.
trim
(
params
.
domicile_name
);
_oorderinforeg
.
business_scope_id
=
this
.
trim
(
params
.
business_scope_id
);
_oorderinforeg
.
business_type
=
this
.
trim
(
params
.
business_type
);
_oorderinforeg
.
business_scope
=
this
.
trim
(
params
.
business_scope
);
_oorderinforeg
.
idcard_front
=
this
.
trim
(
params
.
idcard_front
);
_oorderinforeg
.
idcard_back
=
this
.
trim
(
params
.
idcard_back
);
_oorderinforeg
.
other_file
=
this
.
trim
(
params
.
other_file
);
_oorderinforeg
.
guest_mail_addr
=
this
.
trim
(
params
.
guest_mail_addr
);
_oorderinforeg
.
guest_mail_to
=
this
.
trim
(
params
.
guest_mail_to
);
_oorderinforeg
.
guest_mail_mobile
=
this
.
trim
(
params
.
guest_mail_mobile
);
//更新主表
params
.
_order
.
service_items
=
this
.
trim
(
params
.
service_items
);
params
.
_order
.
service_remark
=
this
.
trim
(
params
.
service_remark
);
params
.
_order
.
status
=
this
.
trim
(
params
.
status
);
try
{
//开启事务
await
this
.
db
.
transaction
(
async
t
=>
{
await
_oorderinforeg
.
save
();
await
params
.
_order
.
save
();
});
return
system
.
getResultSuccess
();
}
catch
(
error
)
{
console
.
log
(
error
);
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
/************************************************旧版接口**************************************************************** */
/**
* 完税证明
* @param {*} params
*/
async
apiTxPayment
(
params
)
{
if
(
!
params
.
id
)
{
return
system
.
getResult
(
null
,
`参数错误 发票ID不合法`
);
}
try
{
let
res
=
await
this
.
txPayment
(
params
);
return
res
;
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`参数错误 错误信息
${
error
}
`
);
}
}
/**
* 查看完税证明
* @param {*} params
*/
async
apiQueryTxPayment
(
params
)
{
if
(
!
params
.
id
)
{
return
system
.
getResult
(
null
,
`参数错误 发票ID不合法`
);
}
try
{
return
await
this
.
queryTxPayment
(
params
);
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`参数错误 错误信息
${
error
}
`
);
}
}
/**
* 发票列表(平台)
* @param {*} params
*/
async
apiQueryInvoices
(
params
)
{
try
{
if
(
params
.
applyNo
)
{
params
.
applyNo
=
this
.
trim
(
params
.
applyNo
)
}
if
(
params
.
type
)
{
params
.
type
=
this
.
trim
(
params
.
type
);
}
if
(
params
.
invoiceTime
)
{
params
.
invoiceTime
=
this
.
trim
(
params
.
invoiceTime
);
}
return
await
this
.
queryInvoices
(
params
);
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
/**
* 发票红冲列表
* @param {*} params
*/
async
apiRedRushList
(
params
)
{
try
{
if
(
params
)
{
}
let
res
=
await
this
.
redRushList
(
params
);
return
res
;
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`参数错误 错误信息
${
error
}
`
);
}
}
//==============================================================
/**
* 红冲列表
* @param {*} params
*/
async
redRushList
(
params
)
{
try
{
if
(
params
.
delivererId
)
{
params
.
delivererId
=
this
.
trim
(
params
.
delivererId
);
}
if
(
this
.
trim
(
params
.
applyNo
))
{
params
.
applyNo
=
this
.
trim
(
params
.
applyNo
);
}
if
(
this
.
trim
(
params
.
invoiceNo
))
{
params
.
invoiceNo
=
this
.
trim
(
params
.
invoiceNo
);
}
if
(
this
.
trim
(
params
.
invoiceTime
))
{
params
.
invoiceTime
=
this
.
trim
(
params
.
invoiceTime
);
}
if
(
this
.
trim
(
params
.
startTime
))
{
params
.
startTime
=
this
.
trim
(
params
.
startTime
);
}
if
(
this
.
trim
(
params
.
endTime
))
{
params
.
endTime
=
this
.
trim
(
params
.
endTime
);
}
if
(
this
.
trim
(
params
.
type
))
{
params
.
type
=
this
.
trim
(
params
.
type
);
}
if
(
this
.
trim
(
params
.
status
))
{
params
.
status
=
this
.
trim
(
params
.
status
);
}
if
(
this
.
trim
(
params
.
redStatus
))
{
params
.
redStatus
=
this
.
trim
(
params
.
redStatus
);
}
params
.
statRow
=
(
Number
(
this
.
trim
(
params
.
pageIndex
))
-
1
)
*
Number
(
this
.
trim
(
params
.
pageSize
));
if
(
params
.
statRow
<=
0
)
{
params
.
statRow
=
0
;
}
params
.
pageSize
=
Number
(
this
.
trim
(
params
.
pageSize
))
<=
0
?
10
:
Number
(
this
.
trim
(
params
.
pageSize
));
let
total
=
await
this
.
dao
.
countRedRushListByParams
(
params
);
if
(
total
==
0
||
total
[
0
].
count
==
0
)
{
let
res
=
{
rows
:
[],
count
:
0
};
return
system
.
getResult
(
res
);
}
let
rows
=
await
this
.
dao
.
redRushListByParams
(
params
);
for
(
let
item
of
rows
)
{
if
(
item
.
type
==
"10"
)
{
item
.
type
=
"普通发票"
;
}
else
if
(
item
.
type
==
"20"
)
{
item
.
type
=
"增值税专用发票"
;
}
else
if
(
item
.
type
==
"30"
)
{
item
.
type
=
"电子发票"
;
}
else
{
item
.
type
=
""
;
}
this
.
handleDate
(
item
,
[
"invoice_time"
],
"YYYY-MM-DD HH:mm:ss"
,
-
8
);
this
.
dao
.
setRowCodeName
(
item
,
"status"
);
}
let
res
=
{
count
:
total
[
0
].
count
,
rows
:
rows
};
return
system
.
getResult
(
res
);
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
/**
* 完税证明
* @param {*} params
* {
* id:xxx //完税证明
* }
*/
async
txPayment
(
params
)
{
try
{
let
_invoice
=
await
this
.
dao
.
findOne
({
id
:
this
.
trim
(
params
.
id
)
});
if
(
!
_invoice
)
{
return
system
.
getResult
(
null
,
`发票不存在`
);
}
let
res
=
await
this
.
dao
.
update
({
id
:
this
.
trim
(
params
.
id
),
taxNo
:
this
.
trim
(
params
.
taxNo
),
complateTax
:
1
,
taxTime
:
this
.
trim
(
params
.
taxTime
),
taxVoucher
:
this
.
trim
(
params
.
taxVoucher
)
});
return
system
.
getResult
(
res
);
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`参数错误 错误信息
${
error
}
`
);
}
}
/**
* 查看完税证明
* @param {*} params
* {
* id:xxx //完税证明
* }
*/
async
queryTxPayment
(
params
)
{
try
{
let
_invoice
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
id
:
this
.
trim
(
params
.
id
),
complateTax
:
1
},
attributes
:
[
'id'
,
'taxNo'
,
'complateTax'
,
'taxTime'
,
'taxVoucher'
]
});
if
(
!
_invoice
)
{
return
system
.
getResult
(
null
,
`完税证明不存在`
);
}
return
system
.
getResult
(
_invoice
);
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`参数错误 错误信息
${
error
}
`
);
}
}
/**
* 发票列表查询(平台)
* @param {*} params
* @param applyNo 发票的申请编号
* @param invoiceTime 发票的申请时间
* @param type 发票的类型
* @param status 业务进度
*/
async
queryInvoices
(
params
)
{
try
{
var
pageIndex
=
Number
(
params
.
pageIndex
||
1
);
var
pageSize
=
Number
(
params
.
pageSize
||
10
);
var
total
=
await
this
.
dao
.
countByParams
(
params
);
if
(
total
==
0
)
{
return
system
.
getResultSuccess
({
count
:
0
,
rows
:
[]
});
}
var
startRow
=
(
pageIndex
-
1
)
*
pageSize
;
var
list
=
await
this
.
dao
.
pageByParams
(
params
,
startRow
,
pageSize
);
await
this
.
setApply
(
list
);
for
(
var
item
of
list
)
{
// item.redStatusName = this.dao.getRowCodeName(item, "red_status");
if
(
item
.
red_status
==
1
)
{
item
.
red_status
=
'未红冲'
;
}
else
if
(
item
.
red_status
==
2
)
{
item
.
red_status
=
'红冲中'
;
}
else
if
(
item
.
red_status
==
3
)
{
item
.
red_status
=
'红冲失败'
}
else
if
(
item
.
red_status
==
4
)
{
item
.
red_status
=
'红冲成功'
;
}
else
{
item
.
red_status
=
''
;
}
this
.
dao
.
getRowCodeName
(
item
.
apply
,
"status"
);
item
.
complate_tax
=
item
.
complate_tax
==
1
?
'已完税'
:
'未完税'
;
item
.
month
=
moment
(
item
.
invoice_time
).
month
()
+
1
;
this
.
handleDate
(
item
,
[
'invoice_time'
],
null
,
-
8
);
if
(
item
.
apply
[
'type'
]
==
'10'
)
{
item
.
apply
[
'type'
]
=
"普通发票"
;
}
else
if
(
item
.
apply
[
'type'
]
==
'20'
)
{
item
.
apply
[
'type'
]
=
"增值税专用发票"
;
}
else
{
item
.
apply
[
'type'
]
=
"电子发票"
;
}
}
var
page
=
{
count
:
total
,
rows
:
list
};
return
system
.
getResultSuccess
(
page
);
}
catch
(
error
)
{
console
.
log
(
error
);
return
system
.
getResult
(
`系统错误 错误信息
${
error
}
`
);
}
}
async
setApply
(
list
)
{
if
(
!
list
||
list
.
length
==
0
)
{
return
;
}
var
ids
=
[];
for
(
var
item
of
list
)
{
ids
.
push
(
item
.
id
);
}
var
applyMap
=
await
this
.
applyDao
.
findMapByIds
(
ids
)
||
{};
for
(
var
item
of
list
)
{
item
.
apply
=
applyMap
[
item
.
id
]
||
{};
}
}
}
module
.
exports
=
InvoiceService
;
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment