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
78e12915
Commit
78e12915
authored
Nov 26, 2019
by
孙亚楠
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dd
parent
8e7ee514
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
539 additions
and
9 deletions
+539
-9
xggsve-invoice/app/base/api/impl/op/action.js
+5
-0
xggsve-invoice/app/base/service/impl/invoice/applySve.js
+6
-4
xggsve-invoice/app/base/utils/invoiceRule/algorithm/calInvoice10.js
+9
-5
xggsve-invoice/app/base/utils/stateChain/actions/auditFailForCustomer.js
+23
-0
xggsve-invoice/app/base/utils/stateChain/actions/auditSuccessForDeliverer.js
+45
-0
xggsve-invoice/app/base/utils/stateChain/actions/common.js
+70
-0
xggsve-invoice/app/base/utils/stateChain/actions/delivererClose.js
+44
-0
xggsve-invoice/app/base/utils/stateChain/actions/finish.js
+10
-0
xggsve-invoice/app/base/utils/stateChain/actions/index.js
+31
-0
xggsve-invoice/app/base/utils/stateChain/actions/invoiced.js
+33
-0
xggsve-invoice/app/base/utils/stateChain/actions/mailed.js
+12
-0
xggsve-invoice/app/base/utils/stateChain/actions/pendingDisposal.js
+40
-0
xggsve-invoice/app/base/utils/stateChain/actions/redRush.js
+5
-0
xggsve-invoice/app/base/utils/stateChain/actions/toBeAllocated.js
+25
-0
xggsve-invoice/app/base/utils/stateChain/actions/unAuditFailForDeliverer.js
+48
-0
xggsve-invoice/app/base/utils/stateChain/actions/unAuditForCustomer.js
+10
-0
xggsve-invoice/app/base/utils/stateChain/actions/unAuditedForDeliverer.js
+35
-0
xggsve-invoice/app/base/utils/stateChain/actions/util.js
+33
-0
xggsve-invoice/app/base/utils/stateChain/actions/withdrawInvoice.js
+7
-0
xggsve-invoice/app/base/utils/stateChain/context.js
+22
-0
xggsve-invoice/app/base/utils/stateChain/stateBase.js
+26
-0
No files found.
xggsve-invoice/app/base/api/impl/op/action.js
View file @
78e12915
...
@@ -2,12 +2,14 @@ var APIBase = require("../../api.base");
...
@@ -2,12 +2,14 @@ var APIBase = require("../../api.base");
var
system
=
require
(
"../../../system"
);
var
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
var
settings
=
require
(
"../../../../config/settings"
);
var
rule
=
require
(
"../../../utils/invoiceRule/rule"
);
var
rule
=
require
(
"../../../utils/invoiceRule/rule"
);
var
Context
=
require
(
"../../../utils/stateChain/context"
);
class
ActionAPI
extends
APIBase
{
class
ActionAPI
extends
APIBase
{
constructor
()
{
constructor
()
{
super
();
super
();
this
.
invoiceSve
=
system
.
getObject
(
"service.invoice.invoiceSve"
);
this
.
invoiceSve
=
system
.
getObject
(
"service.invoice.invoiceSve"
);
this
.
applySve
=
system
.
getObject
(
"service.invoice.applySve"
);
this
.
applySve
=
system
.
getObject
(
"service.invoice.applySve"
);
this
.
delivererSve
=
system
.
getObject
(
"service.invoice.delivererSve"
);
this
.
delivererSve
=
system
.
getObject
(
"service.invoice.delivererSve"
);
this
.
context
=
new
Context
();
}
}
/**
/**
* 接口跳转
* 接口跳转
...
@@ -54,6 +56,9 @@ class ActionAPI extends APIBase {
...
@@ -54,6 +56,9 @@ class ActionAPI extends APIBase {
case
"platformAssignment"
:
// 平台审批
case
"platformAssignment"
:
// 平台审批
opResult
=
await
this
.
applySve
.
apiAssignment
(
action_body
);
opResult
=
await
this
.
applySve
.
apiAssignment
(
action_body
);
break
;
break
;
case
"examineAndVerify"
:
//审批(v2)
opResult
=
await
this
.
context
.
request
(
action_body
);
break
;
case
"updateEmail"
:
//平台更新邮寄地址
case
"updateEmail"
:
//平台更新邮寄地址
opResult
=
await
this
.
delivererSve
.
apiUpEmNo
(
action_body
);
opResult
=
await
this
.
delivererSve
.
apiUpEmNo
(
action_body
);
break
;
break
;
...
...
xggsve-invoice/app/base/service/impl/invoice/applySve.js
View file @
78e12915
...
@@ -177,7 +177,9 @@ class ApplyService extends ServiceBase {
...
@@ -177,7 +177,9 @@ class ApplyService extends ServiceBase {
try
{
try
{
//试算
//试算
let
val
=
await
rule
.
dispatcher
(
params
);
let
val
=
await
rule
.
dispatcher
(
params
);
if
(
val
.
data
==-
1
){
return
getResult
(
-
1
,
`系统错误
${
val
.
msg
}
`
);
}
params
.
personalIncomeTax
=
this
.
trim
(
val
.
personalIncomeTax
);
params
.
personalIncomeTax
=
this
.
trim
(
val
.
personalIncomeTax
);
params
.
additionalTax
=
this
.
trim
(
val
.
additionalTax
);
params
.
additionalTax
=
this
.
trim
(
val
.
additionalTax
);
params
.
valueAddedTax
=
this
.
trim
(
val
.
valueAddedTax
);
params
.
valueAddedTax
=
this
.
trim
(
val
.
valueAddedTax
);
...
@@ -380,9 +382,9 @@ class ApplyService extends ServiceBase {
...
@@ -380,9 +382,9 @@ class ApplyService extends ServiceBase {
applyNo
:
_nowObj
.
applyNo
,
applyNo
:
_nowObj
.
applyNo
,
merchantId
:
_nowObj
.
merchantId
,
merchantId
:
_nowObj
.
merchantId
,
red_status
:
'1'
,
red_status
:
'1'
,
businessmenType
=
nowObj
.
businessmenType
,
businessmenType
:
nowObj
.
businessmenType
,
ruleCode
=
nowObj
.
ruleCode
,
ruleCode
:
nowObj
.
ruleCode
,
ruleParams
=
nowObj
.
ruleParams
ruleParams
:
nowObj
.
ruleParams
},
t
);
},
t
);
// 源发票改为红冲办理中
// 源发票改为红冲办理中
...
...
xggsve-invoice/app/base/utils/invoiceRule/algorithm/calInvoice10.js
View file @
78e12915
...
@@ -12,6 +12,9 @@ const VAL_TAX = 2; //增值税
...
@@ -12,6 +12,9 @@ const VAL_TAX = 2; //增值税
/**
/**
* 试算接口
* 试算接口
* 注意:1 由于销售方类型不同 所以算法不同 需要对参数验证单独处理
* 注意:1 由于销售方类型不同 所以算法不同 需要对参数验证单独处理
*
* 税率的格式 传去除 %号的数值 比如:
* 96%, 则这个值就传 "taxCostPriRat"=96
*/
*/
module
.
exports
.
calcInvoice
=
async
(
params
)
=>
{
module
.
exports
.
calcInvoice
=
async
(
params
)
=>
{
try
{
try
{
...
@@ -108,7 +111,7 @@ let calRateRange = (amount, taxRange, type) => {
...
@@ -108,7 +111,7 @@ let calRateRange = (amount, taxRange, type) => {
/**
/**
* 计算个税
* 计算个税
* @param {*} x2 //累计
不含说价
* @param {*} x2 //累计
利润
* @param {*} taxPer //个税税率
* @param {*} taxPer //个税税率
* @param {*} quiCalDed //速算扣除数
* @param {*} quiCalDed //速算扣除数
* @param {*} cumulativeProfit //累计缴纳的个税
* @param {*} cumulativeProfit //累计缴纳的个税
...
@@ -167,12 +170,12 @@ module.exports.formatParams=(params)=>{
...
@@ -167,12 +170,12 @@ module.exports.formatParams=(params)=>{
* params
* params
*/
*/
let
verificationParams
=
(
params
)
=>
{
let
verificationParams
=
(
params
)
=>
{
if
(
params
.
taxIncPriRat
>
100
00
||
params
.
serviceRate
>
10000
||
params
.
taxCostPriRat
>
100
00
)
{
if
(
params
.
taxIncPriRat
>
100
||
params
.
serviceRate
>
100
||
params
.
taxCostPriRat
>
1
00
)
{
return
system
.
getResult
(
-
1
,
`参数错误 费率不合法`
);
return
system
.
getResult
(
-
1
,
`参数错误 费率不合法`
);
}
else
{
}
else
{
params
.
taxIncPriRat
=
new
Decimal
(
params
.
taxIncPriRat
).
div
(
100
00
).
toFixed
(
4
);
params
.
taxIncPriRat
=
new
Decimal
(
params
.
taxIncPriRat
).
div
(
100
).
toFixed
(
4
);
params
.
taxCostPriRat
=
new
Decimal
(
params
.
taxCostPriRat
).
div
(
100
00
).
toFixed
(
4
);
params
.
taxCostPriRat
=
new
Decimal
(
params
.
taxCostPriRat
).
div
(
100
).
toFixed
(
4
);
params
.
serviceRate
=
new
Decimal
(
params
.
serviceRate
).
div
(
100
00
).
toFixed
(
4
);
params
.
serviceRate
=
new
Decimal
(
params
.
serviceRate
).
div
(
100
).
toFixed
(
4
);
}
}
return
params
;
return
params
;
}
}
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/actions/auditFailForCustomer.js
0 → 100644
View file @
78e12915
//平台审核发票申请失败 1010 但执行的状态是 1000
const
system
=
require
(
"../../../system"
);
const
common
=
require
(
"./common"
);
module
.
exports
.
auditFailForCustomer
=
async
function
(
params
){
console
.
log
(
"第一次未审批 状态 1000"
);
let
_apply
=
await
common
.
applyVerification
(
params
);
if
(
_apply
.
status
==-
1
){
return
_apply
;}
params
.
nextStatus
=
common
.
trim
(
params
.
nextStatus
);
params
.
remark
=
common
.
trim
(
params
.
remark
);
_apply
.
status
=
params
.
nextStatus
;
_apply
.
customerStatus
=
params
.
nextStatus
;
_apply
.
remark
=
params
.
remark
;
if
(
params
.
nextStatus
!=
"1010"
)
{
return
system
.
getResult
(
-
1
,
`参数错误 请核对状态码`
);
}
try
{
await
_apply
.
save
();
return
system
.
getResultSuccess
();
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/actions/auditSuccessForDeliverer.js
0 → 100644
View file @
78e12915
const
common
=
require
(
"./common"
);
const
system
=
require
(
"../../../system"
);
const
applyDao
=
system
.
getObject
(
"db.invoice.applyDao"
);
const
invoiceDao
=
system
.
getObject
(
"db.invoice.invoiceDao"
);
const
delivererDao
=
system
.
getObject
(
"db.invoice.delivererDao"
);
//审核通过 1070
module
.
exports
.
auditSuccessForDeliverer
=
async
function
(
params
){
console
.
log
(
"审核通过 1070"
);
let
_apply
=
await
common
.
applyVerification
(
params
);
if
(
_apply
.
status
==-
1
){
return
_apply
;}
let
delivererData
=
{},
applyData
=
{},
invoiceData
=
{};
let
_deliverer
=
await
delivererDao
.
findOne
({
id
:
_apply
.
delivererId
});
delivererData
.
auditContent
=
common
.
trim
(
params
.
auditContent
);
delivererData
.
delivererContent
=
common
.
trim
(
params
.
delivererContent
);
delivererData
.
mailAddr
=
common
.
trim
(
params
.
mailAddr
);
delivererData
.
mailMobile
=
common
.
trim
(
params
.
mailMobile
);
delivererData
.
mailTo
=
common
.
trim
(
params
.
mailTo
);
delivererData
.
mailEmail
=
common
.
trim
(
params
.
mailEmail
);
delivererData
.
id
=
common
.
trim
(
_deliverer
.
id
);
applyData
.
status
=
common
.
trim
(
params
.
nextStatus
);
applyData
.
id
=
common
.
trim
(
params
.
id
);
invoiceData
.
status
=
common
.
trim
(
params
.
nextStatus
);
invoiceData
.
id
=
common
.
trim
(
params
.
id
);
await
applyDao
.
db
.
transaction
(
async
(
t
)
=>
{
//更新deliverer信息
await
delivererDao
.
update
(
delivererData
,
t
);
//更新 申请单和发票单
await
applyDao
.
update
(
applyData
,
t
);
await
invoiceDao
.
update
(
invoiceData
,
t
);
if
(
_apply
.
parentId
)
{
await
invoiceDao
.
update
({
id
:
_apply
.
parentId
,
redStatus
:
'4'
},
t
);
}
}).
catch
(
error
=>
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
});
return
system
.
getResultSuccess
();
}
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/actions/common.js
0 → 100644
View file @
78e12915
const
system
=
require
(
"../../../system"
);
const
applyDao
=
system
.
getObject
(
"db.invoice.applyDao"
);
const
invoiceDao
=
system
.
getObject
(
"db.invoice.invoiceDao"
);
const
is
=
system
.
getObject
(
"util.invoiceStatus"
);
const
invoiceStatus
=
is
.
status
;
/**
* 平台状态验证
*/
module
.
exports
.
applyVerification
=
async
(
params
)
=>
{
let
_apply
=
await
applyDao
.
findOne
({
id
:
trim
(
params
.
id
)
});
if
(
!
_apply
)
{
return
system
.
getResult
(
null
,
`此发票不存在`
);
}
//获取当前状态 的对象
let
_status
=
invoiceStatus
[
_apply
.
status
];
//如果不符合状态则退出
if
(
params
.
nextStatus
==
"1300"
||
params
.
nextStatus
==
"1040"
||
params
.
nextStatus
==
"1010"
)
{
return
_apply
;
}
if
(
!
_status
&&
_status
.
next
!=
params
.
nextStatus
)
{
let
name
=
invoiceStatus
[
invoiceStatus
[
_apply
.
status
].
next
].
name
;
return
system
.
getResult
(
null
,
`更新状态错误,提示:当前状态的下一个状态是
${
name
}
`
);
}
return
_apply
;
}
/**
* 交付商转该验证
*/
module
.
exports
.
delivererVerification
=
async
(
params
)
=>
{
let
_apply
=
await
applyDao
.
findOne
({
id
:
params
.
id
});
let
_invoice
=
await
invoiceDao
.
findOne
({
id
:
params
.
id
});
if
(
!
_invoice
)
{
return
system
.
getResult
(
null
,
`此发票不存在`
);
}
//获取当前状态 的对象
let
_status
=
invoiceStatus
[
_invoice
.
status
];
//如果不符合状态则退出
if
(
params
.
nextStatus
==
"1300"
||
params
.
nextStatus
==
"1040"
||
params
.
nextStatus
==
"1010"
)
{
let
obj
=
{
_apply
:
_apply
,
_invoice
:
_invoice
};
return
obj
;
}
else
if
(
!
_status
&&
_status
.
dstatus
!=
params
.
nextStatus
)
{
let
name
=
invoiceStatus
[
invoiceStatus
[
_invoice
.
status
].
dstatus
].
name
;
return
system
.
getResult
(
null
,
`更新状态错误,提示:当前状态的下一个状态是
${
name
}
`
);
}
let
obj
=
{
_apply
:
_apply
,
_invoice
:
_invoice
};
return
obj
;
}
function
trim
(
o
)
{
if
(
!
o
)
{
return
""
;
}
return
o
.
toString
().
trim
();
}
module
.
exports
.
trim
=
(
o
)
=>
{
if
(
!
o
)
{
return
""
;
}
return
o
.
toString
().
trim
();
}
xggsve-invoice/app/base/utils/stateChain/actions/delivererClose.js
0 → 100644
View file @
78e12915
const
system
=
require
(
"../../../system"
);
const
applyDao
=
system
.
getObject
(
"db.invoice.applyDao"
);
const
invoiceDao
=
system
.
getObject
(
"db.invoice.invoiceDao"
);
const
delivererDao
=
system
.
getObject
(
"db.invoice.delivererDao"
);
const
common
=
require
(
"./common"
);
//交付商关闭 1040
module
.
exports
.
delivererClose
=
async
function
(
params
)
{
console
.
log
(
"交付商关闭 1040"
);
let
obj
=
await
common
.
delivererVerification
(
params
);
if
(
obj
.
status
==
-
1
)
{
return
obj
;
}
let
_apply
=
obj
.
_apply
;
let
_invoice
=
obj
.
_invoice
;
//更改发票表信息
_invoice
.
status
=
common
.
trim
(
params
.
nextStatus
);
//添加拒绝原因
let
delivererData
=
{
breakReason
:
common
.
trim
(
params
.
breakReason
)
||
""
,
id
:
_apply
.
delivererId
};
//更改申请表信息
_apply
.
status
=
"1020"
;
_apply
.
delivererId
=
null
;
let
applyData
=
{};
applyData
.
id
=
_apply
.
id
;
applyData
.
status
=
"1020"
;
applyData
.
delivererId
=
''
;
let
invoiceData
=
{};
invoiceData
.
status
=
"1020"
;
invoiceData
.
id
=
_apply
.
id
;
await
delivererDao
.
db
.
transaction
(
async
(
t
)
=>
{
//更新申请表状态
await
applyDao
.
update
(
applyData
,
t
);
//更新发票表状态
await
invoiceDao
.
update
(
invoiceData
,
t
);
//更新拒绝原因
await
delivererDao
.
update
(
delivererData
,
t
);
}).
catch
(
error
=>
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
});
return
system
.
getResultSuccess
();
}
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/actions/finish.js
0 → 100644
View file @
78e12915
const
applySve
=
require
(
"../../../service/impl/invoice/applySve"
);
const
common
=
require
(
"./common"
);
//完成 1090
module
.
exports
.
finish
=
async
function
(
params
){
console
.
log
(
"完成 1090"
);
let
_apply
=
await
common
.
applyVerification
(
params
);
if
(
_apply
.
status
==-
1
){
return
_apply
;}
return
applySve
.
examine1090
(
params
,
_apply
);
}
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/actions/index.js
0 → 100644
View file @
78e12915
module
.
exports
=
{
//客户未付款 0090
unAuditForCustomer
:
require
(
'./unAuditForCustomer'
),
//客户提交审核 状态1000
unAuditForCustomer
:
require
(
'./unAuditForCustomer'
),
//平台审核发票申请失败 1010
auditFailForCustomer
:
require
(
'./auditFailForCustomer'
),
//待分配 1020
toBeAllocated
:
require
(
'./toBeAllocated'
),
//待处理 1030
pendingDisposal
:
require
(
'./pendingDisposal'
),
//交付商关闭 1040
delivererClose
:
require
(
'./delivererClose'
),
//已开具 1050
invoiced
:
require
(
'./invoiced'
),
//待审核 1060
unAuditedForDeliverer
:
require
(
'./unAuditedForDeliverer'
),
//待处理 1300
unAuditFailForDeliverer
:
require
(
'./unAuditFailForDeliverer'
),
//审核通过 1070
auditSuccessForDeliverer
:
require
(
'./auditSuccessForDeliverer'
),
//已邮寄 1080
mailed
:
require
(
'./mailed'
),
//完成 1090
finish
:
require
(
'./finish'
),
//发票撤回 1100
withdrawInvoice
:
require
(
'./withdrawInvoice'
),
//红冲 1200
redRush
:
require
(
'./redRush'
),
}
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/actions/invoiced.js
0 → 100644
View file @
78e12915
const
system
=
require
(
"../../../system"
);
const
applyDao
=
system
.
getObject
(
"db.invoice.applyDao"
);
const
invoiceDao
=
system
.
getObject
(
"db.invoice.invoiceDao"
);
const
delivererDao
=
system
.
getObject
(
"db.invoice.delivererDao"
);
const
common
=
require
(
"./common"
);
//已开具 1050
module
.
exports
.
invoiced
=
async
function
(
params
){
console
.
log
(
"已开具 1050"
);
let
obj
=
await
common
.
delivererVerification
(
params
);
if
(
obj
.
status
==-
1
){
return
obj
;}
//更改发票表信息
let
invoiceData
=
{};
invoiceData
.
id
=
params
.
id
;
invoiceData
.
invoiceNo
=
common
.
trim
(
params
.
invoiceNo
);
invoiceData
.
invoiceTime
=
common
.
trim
(
params
.
invoiceTime
);
invoiceData
.
invoiceImg
=
common
.
trim
(
params
.
invoiceImg
);
invoiceData
.
status
=
common
.
trim
(
params
.
nextStatus
);
//更改申请表信息
let
applyData
=
{};
applyData
.
id
=
params
.
id
;
applyData
.
status
=
common
.
trim
(
params
.
nextStatus
);
applyData
.
customerStatus
=
common
.
trim
(
params
.
nextStatus
);
await
delivererDao
.
db
.
transaction
(
async
(
t
)
=>
{
//更新申请表状态
await
applyDao
.
update
(
applyData
,
t
);
//更新发票表状态
await
invoiceDao
.
update
(
invoiceData
,
t
);
}).
catch
(
error
=>
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
});
return
system
.
getResultSuccess
();
}
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/actions/mailed.js
0 → 100644
View file @
78e12915
const
delivererSve
=
require
(
"../../../service/impl/invoice/delivererSve"
);
const
common
=
require
(
"./common"
);
//已邮寄 1080
module
.
exports
.
mailed
=
async
(
params
)
=>
{
console
.
log
(
"已邮寄 1080"
);
let
obj
=
await
common
.
delivererVerification
(
params
);
if
(
obj
.
status
==-
1
){
return
obj
;}
let
_apply
=
obj
.
_apply
;
let
_invoice
=
obj
.
_invoice
;
return
delivererSve
.
examine1080
(
params
,
_apply
,
_invoice
);
}
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/actions/pendingDisposal.js
0 → 100644
View file @
78e12915
const
common
=
require
(
"./common"
);
const
system
=
require
(
"../../../system"
);
const
applyDao
=
system
.
getObject
(
"db.invoice.applyDao"
);
const
invoiceDao
=
system
.
getObject
(
"db.invoice.invoiceDao"
);
const
delivererDao
=
system
.
getObject
(
"db.invoice.delivererDao"
);
//待处理 1030
module
.
exports
.
pendingDisposal
=
async
function
(
params
){
console
.
log
(
"待处理 1030"
);
if
(
!
params
.
id
||
!
params
.
delivererName
)
{
return
system
.
getResult
(
-
1
,
`系统错误 错误信息
${
error
}
`
);
}
let
_apply
=
await
common
.
applyVerification
(
params
);
if
(
_apply
.
status
==-
1
){
return
_apply
;}
await
applyDao
.
db
.
transaction
(
async
(
t
)
=>
{
let
_deliverer
=
await
delivererDao
.
create
({
invoiceId
:
_apply
.
id
,
applyNo
:
_apply
.
applyNo
,
merchantId
:
_apply
.
merchantId
,
delivererId
:
common
.
trim
(
params
.
delivererId
),
delivererName
:
common
.
trim
(
params
.
delivererName
),
delivererAmount
:
Number
(
common
.
trim
(
params
.
delivererAmount
))
},
t
);
let
applyData
=
{};
applyData
.
status
=
common
.
trim
(
params
.
nextStatus
);
applyData
.
customerStatus
=
common
.
trim
(
params
.
nextStatus
);
applyData
.
delivererId
=
common
.
trim
(
_deliverer
.
id
);
applyData
.
id
=
common
.
trim
(
params
.
id
);
//更新申请发票内容
await
applyDao
.
update
(
applyData
,
t
);
//更改发票状态
let
invoiceData
=
{};
invoiceData
.
status
=
common
.
trim
(
params
.
nextStatus
);
invoiceData
.
id
=
common
.
trim
(
params
.
id
);
await
invoiceDao
.
update
(
invoiceData
,
t
);
}).
catch
(
error
=>
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
});
return
system
.
getResultSuccess
();
}
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/actions/redRush.js
0 → 100644
View file @
78e12915
//红冲 1200
module
.
exports
.
redRush
=
async
(
params
)
=>
{
console
.
log
(
"红冲 1200"
);
}
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/actions/toBeAllocated.js
0 → 100644
View file @
78e12915
const
common
=
require
(
"./common"
);
const
system
=
require
(
"../../../system"
);
//待分配 1020
module
.
exports
.
toBeAllocated
=
async
function
(
params
){
console
.
log
(
"//待分配 1020"
);
let
_apply
=
await
common
.
applyVerification
(
params
);
if
(
_apply
.
status
==-
1
){
return
_apply
;}
if
(
Number
(
params
.
isPay
)
!=
1
)
{
return
system
.
getResult
(
null
,
`参数错误 请核对付款信息`
);
}
params
.
nextStatus
=
common
.
trim
(
params
.
nextStatus
);
params
.
remark
=
common
.
trim
(
params
.
remark
);
_apply
.
status
=
params
.
nextStatus
;
_apply
.
remark
=
params
.
remark
;
_apply
.
isPay
=
Number
(
params
.
isPay
);
try
{
await
_apply
.
save
();
return
system
.
getResultSuccess
();
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/actions/unAuditFailForDeliverer.js
0 → 100644
View file @
78e12915
const
system
=
require
(
"../../../system"
);
const
applyDao
=
system
.
getObject
(
"db.invoice.applyDao"
);
const
invoiceDao
=
system
.
getObject
(
"db.invoice.invoiceDao"
);
const
delivererDao
=
system
.
getObject
(
"db.invoice.delivererDao"
);
const
common
=
require
(
"./common"
);
//待处理 1300(平台第二次审核失败)
module
.
exports
.
unAuditFailForDeliverer
=
async
(
params
)
=>
{
console
.
log
(
"待处理 1300"
);
let
_apply
=
await
common
.
applyVerification
(
params
);
if
(
_apply
.
status
==-
1
){
return
_apply
;}
// let _apply = await applyDao.findOne({
// id: common.trim(params.id)
// });
if
(
!
_apply
)
{
return
system
.
getResult
(
null
,
`发票不存在,请核对发票ID`
);
}
let
_deliverer
=
await
delivererDao
.
model
.
findOne
({
where
:
{
id
:
_apply
.
delivererId
}
});
if
(
!
_deliverer
)
{
return
system
.
getResult
(
null
,
`交付商不存在,请联系管理员`
);
}
await
applyDao
.
db
.
transaction
(
async
(
t
)
=>
{
//更新 申请单和发票单
await
applyDao
.
update
({
status
:
"1300"
,
id
:
_apply
.
id
},
t
);
await
invoiceDao
.
update
({
status
:
"1300"
,
id
:
_apply
.
id
},
t
);
if
(
_deliverer
.
id
)
{
//提交审核信息
await
delivererDao
.
update
({
auditContent
:
common
.
trim
(
params
.
auditContent
),
id
:
_deliverer
.
id
});
}
}).
catch
(
error
=>
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
});
return
system
.
getResultSuccess
();
}
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/actions/unAuditForCustomer.js
0 → 100644
View file @
78e12915
const
applySve
=
require
(
"../../../service/impl/invoice/applySve"
);
const
common
=
require
(
"./common"
);
//第一次未审批 状态 1000
module
.
exports
.
unAuditForCustomer
=
async
function
(
params
)
{
console
.
log
(
"第一次未审批 状态 1000"
);
let
_apply
=
await
common
.
applyVerification
(
params
);
if
(
_apply
.
status
==-
1
){
return
_apply
;}
return
applySve
.
examine1000
(
params
,
_apply
);
}
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/actions/unAuditedForDeliverer.js
0 → 100644
View file @
78e12915
const
system
=
require
(
"../../../system"
);
const
applyDao
=
system
.
getObject
(
"db.invoice.applyDao"
);
const
invoiceDao
=
system
.
getObject
(
"db.invoice.invoiceDao"
);
const
delivererDao
=
system
.
getObject
(
"db.invoice.delivererDao"
);
const
common
=
require
(
"./common"
);
//待审核 1060
module
.
exports
.
unAuditedForDeliverer
=
async
(
params
)
=>
{
console
.
log
(
"待审核 1060"
);
let
obj
=
await
common
.
delivererVerification
(
params
);
if
(
obj
.
status
==-
1
){
return
obj
;}
let
invoiceData
=
{},
applyData
=
{};
invoiceData
.
status
=
params
.
nextStatus
;
invoiceData
.
id
=
params
.
id
;
if
(
params
.
invoiceNo
)
{
invoiceData
.
invoiceNo
=
common
.
trim
(
params
.
invoiceNo
);
}
if
(
params
.
invoiceTime
)
{
invoiceData
.
invoiceTime
=
common
.
trim
(
params
.
invoiceTime
);
}
if
(
params
.
invoiceImg
)
{
invoiceData
.
invoiceImg
=
common
.
trim
(
params
.
invoiceImg
);
}
applyData
.
status
=
params
.
nextStatus
;
applyData
.
id
=
params
.
id
;
await
delivererDao
.
db
.
transaction
(
async
(
t
)
=>
{
//更新申请表状态
await
applyDao
.
update
(
applyData
,
t
);
//更新发票表状态
await
invoiceDao
.
update
(
invoiceData
,
t
);
}).
catch
(
error
=>
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
});
return
system
.
getResultSuccess
();
}
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/actions/util.js
0 → 100644
View file @
78e12915
module
.
exports
=
{
// "0090": "未付款",
// "1000": "待审核",
// "1010": "审核不通过",
// "1020": "待分配",
// "1030": "待处理",
// "1040": "交付商关闭",
// "1050": "已开具",
// "1060": "待审核",
// "1300": "审核失败(平台第二次审核)",
// "1070": "审核通过",
// "1080": "已邮寄",
// "1090": "完成",
// "1100": "发票撤回",
// "1200": "红冲",
"0090"
:
"unAuditForCustomer"
,
"1000"
:
"unAuditForCustomer"
,
"1010"
:
"auditFailForCustomer"
,
"1020"
:
"toBeAllocated"
,
"1030"
:
"pendingDisposal"
,
"1040"
:
"delivererClose"
,
"1050"
:
"invoiced"
,
"1060"
:
"unAuditedForDeliverer"
,
"1300"
:
"unAuditFailForDeliverer"
,
"1070"
:
"auditSuccessForDeliverer"
,
"1080"
:
"mailed"
,
"1090"
:
"finish"
,
"1100"
:
"withdrawInvoice"
,
"1200"
:
"redRush"
,
};
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/actions/withdrawInvoice.js
0 → 100644
View file @
78e12915
//发票撤回 1100
const
applySve
=
require
(
"../../../service/impl/invoice/applySve"
);
const
common
=
require
(
"./common"
);
module
.
exports
.
withdrawInvoice
=
async
function
(
params
){
console
.
log
(
"发票撤回 1100 "
);
}
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/context.js
0 → 100644
View file @
78e12915
const
StateBase
=
require
(
'./stateBase'
);
const
API
=
require
(
'./actions/index'
);
const
AllState
=
require
(
'./actions/util'
);
const
system
=
require
(
"../../system"
);
class
Context
{
constructor
(){
this
.
stateBase
=
new
StateBase
(
API
);
this
.
allState
=
AllState
;
}
async
request
(
params
){
let
methodName
=
this
.
allState
[
params
.
nextStatus
];
if
(
!
methodName
){
return
system
.
getResult
(
-
1
,
`参数错误 状态码错误`
);
}
let
_self
=
this
.
stateBase
.
setState
(
methodName
);
return
await
_self
.
doAction
(
params
);
}
}
module
.
exports
=
Context
;
\ No newline at end of file
xggsve-invoice/app/base/utils/stateChain/stateBase.js
0 → 100644
View file @
78e12915
const
system
=
require
(
"../../system"
);
class
StateBase
{
constructor
(
api
){
this
.
actions
=
api
;
this
.
curState
=
null
;
}
//改变状态
setState
(
curState
){
this
.
curState
=
curState
;
return
this
;
}
//执行操作
async
doAction
(
params
){
try
{
if
(
this
.
actions
[
this
.
curState
]){
return
await
this
.
actions
[
this
.
curState
][
this
.
curState
].
apply
(
this
,[
params
]);
}
else
{
return
system
.
getResult
(
-
1
,
`系统错误 未找到处理器`
);
}
}
catch
(
error
)
{
return
system
.
getResult
(
-
1
,
`系统错误 错误信息
${
error
}
`
);
}
}
}
module
.
exports
=
StateBase
;
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