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
ae5e8fff
Commit
ae5e8fff
authored
Apr 11, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
c5f45d87
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
245 additions
and
25 deletions
+245
-25
xgg-saas-platform/app/base/controller/impl/saas/invoiceCtl.js
+170
-23
xgg-saas-platform/app/base/system.js
+2
-2
xgg-saas-platform/app/base/utils/validation.js
+73
-0
xgg-saas-platform/app/front/entry/public/apidoc/saas/invoice.md
+0
-0
No files found.
xgg-saas-platform/app/base/controller/impl/saas/invoiceCtl.js
View file @
ae5e8fff
var
system
=
require
(
"../../../system"
)
const
CtlBase
=
require
(
"../../ctlms.base"
);
const
validation
=
system
.
getObject
(
"util.validation"
);
class
InvoiceCtl
extends
CtlBase
{
constructor
()
{
super
();
this
.
invoiceSve
=
system
.
getObject
(
"service.invoice.invoiceSve"
);
}
//发票列表
async
platforminvoicePage
(
params
,
pobj2
,
req
)
{
try
{
let
rs
=
await
this
.
invoiceSve
.
platforminvoicePage
(
params
);
return
rs
;
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
//发票申请列表
async
platforminvoiceapplyPage
(
params
,
pobj2
,
req
)
{
try
{
let
rs
=
await
this
.
invoiceSve
.
platforminvoiceapplyPage
(
params
);
return
rs
;
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
constructor
()
{
super
();
this
.
invoiceSve
=
system
.
getObject
(
"service.invoice.invoiceSve"
);
}
// 审核
async
audit
(
params
,
pobj2
,
req
)
{
try
{
let
id
=
this
.
trim
(
params
.
id
);
if
(
!
id
)
{
return
system
.
getResult
(
null
,
"发票申请不存在"
);
}
let
status
=
params
.
status
||
0
;
let
remark
=
this
.
trim
(
params
.
remark
);
if
(
!
remark
)
{
return
system
.
getResult
(
null
,
"请填写审核备注"
);
}
return
system
.
getResultSuccess
();
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
// 发票开具
// 审核
async
makeout
(
params
,
pobj2
,
req
)
{
try
{
validation
.
check
(
params
,
'invoice_no'
,
{
name
:
"发票代码"
,
is_require
:
true
});
validation
.
check
(
params
,
'invoice_number'
,
{
name
:
"发票号码"
,
is_require
:
true
});
validation
.
check
(
params
,
'invoice_time'
,
{
name
:
"开票时间"
,
is_require
:
true
});
validation
.
check
(
params
,
'mail_no'
,
{
name
:
"快递单号"
,
is_require
:
true
});
validation
.
check
(
params
,
'invoice_img'
,
{
name
:
"发票图片"
,
is_require
:
true
});
return
system
.
getResultSuccess
(
params
);
}
catch
(
error
)
{
let
msg
=
error
.
message
;
if
(
msg
.
startsWith
(
"bpo-validation-error:"
))
{
return
system
.
getResult
(
null
,
msg
.
replace
(
"bpo-validation-error:"
,
""
));
}
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
async
platformTitleAddr
(
params
,
pobj2
,
req
)
{
try
{
let
result
=
{};
result
.
title
=
{
"merchant_name"
:
"舟山兰和有限公司"
,
"merchant_credit_code"
:
"KHSDLKFJAFJ"
,
"merchant_tax_type"
:
"00"
,
"merchant_addr"
:
"河南信阳"
,
"merchant_mobile"
:
"18833836395"
,
"merchant_bank"
:
"北京银行栓秀支行"
,
"merchant_account"
:
"zhousanlanhe"
};
result
.
addr
=
{
"mail_addr"
:
"北京朝阳区国创元"
,
"mail_mobile"
:
"010-4525821-44"
,
"mail_to"
:
"张娇哒哒哒"
,};
return
system
.
getResultSuccess
(
result
);
}
catch
(
error
)
{
let
msg
=
error
.
message
;
if
(
msg
.
startsWith
(
"bpo-validation-error:"
))
{
return
system
.
getResult
(
null
,
msg
.
replace
(
"bpo-validation-error:"
,
""
));
}
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
async
platformInvoiceInfo
(
params
,
pobj2
,
req
)
{
try
{
let
result
=
{};
result
.
tax
=
{
"additional_tax_total"
:
5000
,
"personal_invoice_tax_total"
:
5000
,
"value_added_tax_total"
:
700
};
result
.
invoiceList
=
[{
"name"
:
"舟山兰和有限公司"
,
"credit_code"
:
"KHSDLKFJAFJ"
,
"is_bank"
:
0
,
"invoice_amount"
:
1000000
,
"personal_invoice_tax"
:
3000
,
"additional_tax"
:
5000
,
"service_tax"
:
5000
,
"value_added_tax"
:
700
,
"unit"
:
""
,
"quantity"
:
0
,
"price"
:
0
,
"remark"
:
""
},
{
"name"
:
"舟山兰和有限公司"
,
"credit_code"
:
"KHSDLKFJAFJ"
,
"is_bank"
:
0
,
"invoice_amount"
:
1000000
,
"personal_invoice_tax"
:
3000
,
"additional_tax"
:
5000
,
"service_tax"
:
5000
,
"value_added_tax"
:
700
,
"unit"
:
""
,
"quantity"
:
0
,
"price"
:
0
,
"remark"
:
""
}];
return
system
.
getResultSuccess
(
result
);
}
catch
(
error
)
{
let
msg
=
error
.
message
;
if
(
msg
.
startsWith
(
"bpo-validation-error:"
))
{
return
system
.
getResult
(
null
,
msg
.
replace
(
"bpo-validation-error:"
,
""
));
}
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
async
platformInvoiceApply
(
params
,
pobj2
,
req
)
{
try
{
return
system
.
getResultSuccess
();
}
catch
(
error
)
{
let
msg
=
error
.
message
;
if
(
msg
.
startsWith
(
"bpo-validation-error:"
))
{
return
system
.
getResult
(
null
,
msg
.
replace
(
"bpo-validation-error:"
,
""
));
}
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
//发票列表
async
invoicePage
(
params
,
pobj2
,
req
)
{
try
{
let
rs
=
await
this
.
invoiceSve
.
platforminvoicePage
(
params
);
return
rs
;
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
//发票申请列表
async
applyPage
(
params
,
pobj2
,
req
)
{
try
{
params
.
owner_type
=
"00"
;
let
rs
=
await
this
.
invoiceSve
.
platforminvoiceapplyPage
(
params
);
return
rs
;
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
//发票申请列表
async
platformApplyPage
(
params
,
pobj2
,
req
)
{
try
{
params
.
owner_type
=
"10"
;
let
rs
=
await
this
.
invoiceSve
.
platforminvoiceapplyPage
(
params
);
return
rs
;
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
// 审核
async
platformAudit
(
params
,
pobj2
,
req
)
{
try
{
let
id
=
this
.
trim
(
params
.
id
);
if
(
!
id
)
{
return
system
.
getResult
(
null
,
"发票申请不存在"
);
}
let
status
=
params
.
status
||
0
;
let
remark
=
this
.
trim
(
params
.
remark
);
if
(
!
remark
)
{
return
system
.
getResult
(
null
,
"请填写审核备注"
);
}
return
system
.
getResultSuccess
();
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
// 审核
async
platformAudit
(
params
,
pobj2
,
req
)
{
try
{
let
id
=
this
.
trim
(
params
.
id
);
if
(
!
id
)
{
return
system
.
getResult
(
null
,
"发票申请不存在"
);
}
let
status
=
params
.
status
||
0
;
let
remark
=
this
.
trim
(
params
.
remark
);
if
(
!
remark
)
{
return
system
.
getResult
(
null
,
"请填写审核备注"
);
}
return
system
.
getResultSuccess
();
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
// 审核
async
platformAudit
(
params
,
pobj2
,
req
)
{
try
{
let
id
=
this
.
trim
(
params
.
id
);
if
(
!
id
)
{
return
system
.
getResult
(
null
,
"发票申请不存在"
);
}
let
status
=
params
.
status
||
0
;
let
remark
=
this
.
trim
(
params
.
remark
);
if
(
!
remark
)
{
return
system
.
getResult
(
null
,
"请填写审核备注"
);
}
return
system
.
getResultSuccess
();
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
}
...
...
xgg-saas-platform/app/base/system.js
View file @
ae5e8fff
...
...
@@ -197,7 +197,7 @@ class System {
merchant
:
local
+
":3101"
+
path
,
// 订单服务
order
:
local
+
":3103"
+
path
,
order
:
dev
+
":3103"
+
path
,
// 发票服务
invoice
:
local
+
":3105"
+
path
,
...
...
@@ -206,7 +206,7 @@ class System {
uc
:
dev
+
":3106"
+
path
,
// 交易
trade
:
dev
+
":3107"
+
path
,
trade
:
local
+
":3107"
+
path
,
}
}
else
{
return
{
...
...
xgg-saas-platform/app/base/utils/validation.js
0 → 100644
View file @
ae5e8fff
const
system
=
require
(
"../system"
);
class
Validation
{
constructor
()
{
// this.restClient = system.getObject("util.restClient");
this
.
PATTERN
=
{
EMAIL_PATTERN
:
/^
\w
+
((
-
\w
+
)
|
(\.\w
+
))
*
\@[
A-Za-z0-9
]
+
((\.
|-
)[
A-Za-z0-9
]
+
)
*
\.[
A-Za-z0-9
]
+$/
,
PHONE_PATTERN
:
/^
(
1
[
0-9
])\d{9}
$/
,
CHINESE_PATTERN
:
/^
[\u
4E00-
\u
9FA5
]
+$/
,
ENGLISH_PATTERN
:
/^
[
A-Za-z
]
+$/
,
QQ_PATTERN
:
/^
[
1-9
][
0-9
]{4,}
$/
,
NUMBER_PATTERN
:
/^
\d
+$/
,
CONTAINS_CHINESE_PATTERN
:
/
[\u
4e00-
\u
9fa5
]
/
,
CONTAINS_ENGLISH_PATTERN
:
/.*
[
a-zA-Z
]
+.*/
,
CONTAINS_NUM_PATTERN
:
/
[
0-9
]
+
?
/
,
DATE_PATTERN
:
/
((
^
((
1
[
8-9
]\d{2})
|
([
2-9
]\d{3}))[
-
](
10|12|0
?[
13578
])[
-
](
3
[
01
]
|
[
12
][
0-9
]
|0
?[
1-9
])(\s{1}([
01
][
0-9
]
|2
[
0-3
])
:
[
0-5
][
0-9
]
:
[
0-5
][
0-9
])?
$
)
|
(
^
((
1
[
8-9
]\d{2})
|
([
2-9
]\d{3}))[
-
](
11|0
?[
469
])[
-
](
30|
[
12
][
0-9
]
|0
?[
1-9
])(\s{1}([
01
][
0-9
]
|2
[
0-3
])
:
[
0-5
][
0-9
]
:
[
0-5
][
0-9
])?
$
)
|
(
^
((
1
[
8-9
]\d{2})
|
([
2-9
]\d{3}))[
-
](
0
?
2
)[
-
](
2
[
0-8
]
|1
[
0-9
]
|0
?[
1-9
])(\s{1}([
01
][
0-9
]
|2
[
0-3
])
:
[
0-5
][
0-9
]
:
[
0-5
][
0-9
])?
$
)
|
(
^
([
2468
][
048
]
00
)[
-
](
0
?
2
)[
-
](
29
)(\s{1}([
01
][
0-9
]
|2
[
0-3
])
:
[
0-5
][
0-9
]
:
[
0-5
][
0-9
])?
$
)
|
(
^
([
3579
][
26
]
00
)[
-
](
0
?
2
)[
-
](
29
)(\s{1}([
01
][
0-9
]
|2
[
0-3
])
:
[
0-5
][
0-9
]
:
[
0-5
][
0-9
])?
$
)
|
(
^
([
1
][
89
][
0
][
48
])[
-
](
0
?
2
)[
-
](
29
)(\s{1}([
01
][
0-9
]
|2
[
0-3
])
:
[
0-5
][
0-9
]
:
[
0-5
][
0-9
])?
$
)
|
(
^
([
2-9
][
0-9
][
0
][
48
])[
-
](
0
?
2
)[
-
](
29
)(\s{1}([
01
][
0-9
]
|2
[
0-3
])
:
[
0-5
][
0-9
]
:
[
0-5
][
0-9
])?
$
)
|
(
^
([
1
][
89
][
2468
][
048
])[
-
](
0
?
2
)[
-
](
29
)(\s{1}([
01
][
0-9
]
|2
[
0-3
])
:
[
0-5
][
0-9
]
:
[
0-5
][
0-9
])?
$
)
|
(
^
([
2-9
][
0-9
][
2468
][
048
])[
-
](
0
?
2
)[
-
](
29
)(\s{1}([
01
][
0-9
]
|2
[
0-3
])
:
[
0-5
][
0-9
]
:
[
0-5
][
0-9
])?
$
)
|
(
^
([
1
][
89
][
13579
][
26
])[
-
](
0
?
2
)[
-
](
29
)(\s{1}([
01
][
0-9
]
|2
[
0-3
])
:
[
0-5
][
0-9
]
:
[
0-5
][
0-9
])?
$
)
|
(
^
([
2-9
][
0-9
][
13579
][
26
])[
-
](
0
?
2
)[
-
](
29
)(\s{1}([
01
][
0-9
]
|2
[
0-3
])
:
[
0-5
][
0-9
]
:
[
0-5
][
0-9
])?
$
)
|
(
^
([
2-9
][
0-9
][
13579
][
26
])[
-
](
0
?
2
)[
-
](
29
)(\s{1}([
this.01
][
0-9
]
|2
[
0-3
])
:
[
0-5
][
0-9
]
:
[
0-5
][
0-9
](\.[
0-9
]
*
))?
$
))
/
,
PASSWORD_PATTERN
:
/^
(?![
0-9
]
+$
)(?![
a-zA-Z
]
+$
)[
0-9A-Za-z
]{6,20}
$/
,
};
}
/**
* 验证字段合法
* @param data 验证的对象
* data.errors 数组,不为空时,会将验证数据放到数组中
* @param field 验证的key
* @param rule 验证规则
* @param vall 是否全部验证完成
* @returns
*/
check
(
data
,
field
,
rule
)
{
if
(
!
rule
)
{
return
true
;
}
if
(
!
data
)
{
throw
new
Error
(
msg
+
"对象不存在"
);
}
let
v
=
data
[
field
];
if
(
rule
.
is_require
&&
!
v
)
{
this
.
error
(
data
,
`
${
rule
.
name
}
:为空`
);
}
if
(
rule
.
maxLen
&&
v
.
length
>
rule
.
maxLen
)
{
this
.
error
(
data
,
`
${
rule
.
name
}
:长度不允许超过
${
rule
.
maxLen
}
`
);
}
if
(
rule
.
minLen
&&
v
.
length
<
rule
.
minLen
)
{
this
.
error
(
data
,
`
${
rule
.
name
}
:长度不允许少于
${
rule
.
minLen
}
`
);
}
if
(
rule
.
eqLen
&&
v
.
length
!=
rule
.
eqLen
)
{
this
.
error
(
data
,
`
${
rule
.
name
}
:长度为
${
rule
.
eqLen
}
`
);
}
if
(
rule
.
is_number
&&
isNaN
(
v
))
{
this
.
error
(
data
,
`
${
rule
.
name
}
:需要填写数字类型`
);
}
if
(
rule
.
is_mobile
&&
this
.
PATTERN
.
PHONE_PATTERN
.
test
(
v
))
{
this
.
error
(
data
,
`
${
rule
.
name
}
:需要填写数字类型`
);
}
if
(
rule
.
dics
&&
rule
.
dics
.
indexOf
(
v
)
==
-
1
)
{
this
.
error
(
data
,
`
${
rule
.
name
}
:
${
v
}
错误`
);
}
if
(
rule
.
arr_require
&&
(
!
v
||
v
.
length
==
0
))
{
this
.
error
(
data
,
`
${
rule
.
name
}
:数据为空`
);
}
}
error
(
data
,
msg
)
{
if
(
data
.
errors
)
{
data
.
errors
.
push
(
msg
);
}
else
{
throw
new
Error
(
`bpo-validation-error:
${
msg
}
`
);
}
}
}
module
.
exports
=
Validation
;
xgg-saas-platform/app/front/entry/public/apidoc/saas/invoice.md
View file @
ae5e8fff
This diff is collapsed.
Click to expand it.
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