Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
youjj
cloud-platform
Commits
c8f1af62
Commit
c8f1af62
authored
Jan 08, 2020
by
hanfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
开票
parent
f0606e79
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
101 deletions
+122
-101
Invoice.java
...main/java/com/xxfc/platform/universal/entity/Invoice.java
+11
-2
InvoiceVo.java
...java/com/xxfc/platform/universal/entity/vo/InvoiceVo.java
+46
-42
InvoiceBiz.java
.../java/com/xxfc/platform/universal/service/InvoiceBiz.java
+65
-57
No files found.
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/entity/Invoice.java
View file @
c8f1af62
...
...
@@ -25,9 +25,11 @@ public class Invoice {
private
String
orderId
;
/**
*
公司代码
*
发票订单表id
*/
private
String
companyCode
;
private
Integer
orderInvoiceId
;
/**
* 发票订单号
...
...
@@ -35,11 +37,18 @@ public class Invoice {
private
String
orderNo
;
/**
* 公司代码
*/
private
String
companyCode
;
/**
* 机构代码
*/
private
String
orgCode
;
/**
* 发票代码
*/
...
...
xx-universal/xx-universal-api/src/main/java/com/xxfc/platform/universal/entity/vo/InvoiceVo.java
View file @
c8f1af62
...
...
@@ -14,56 +14,60 @@ import java.util.List;
@Data
public
class
InvoiceVo
{
/**
* 发票分类:01 专票,02 货物运输业增值税专用发票,03 机动车销售统一发票,
* 04 增值税普通发票,10 增值税普通发票(电子),11 增值税普通发票(卷票),14 增值税普通发票(卷票)
*/
private
Integer
invoiceCategory
=
10
;
/**
* 发票分类:01 专票,02 货物运输业增值税专用发票,03 机动车销售统一发票,
* 04 增值税普通发票,10 增值税普通发票(电子),11 增值税普通发票(卷票),14 增值税普通发票(卷票)
*/
private
Integer
invoiceCategory
=
10
;
/**
* 订单id :多个以逗号隔开
*/
private
String
orderId
;
/**
* 订单id :多个以逗号隔开
*/
private
String
orderId
;
/**
* 发票订单表id
*/
private
Integer
orderInvoiceId
;
/**
* 备注
*/
private
String
remark
;
/**
* 备注
*/
private
String
remark
;
/**
* 购买方名称
*/
private
String
purchaserName
;
/**
* 购买方纳税人识别号
*/
private
String
purchaserTaxCode
;
/**
* 购方邮箱
*/
private
String
purchaserEmail
;
/**
* 购买方地址电话
*/
private
String
purchaserAddressPhone
;
/**
* 购买方银行账号
*/
private
String
purchaserAccountBank
;
/**
* 购买方名称
*/
private
String
purchaserName
;
/**
* 购买方纳税人识别号
*/
private
String
purchaserTaxCode
;
/**
* 购方邮箱
*/
private
String
purchaserEmail
;
/**
* 购买方地址电话
*/
private
String
purchaserAddressPhone
;
/**
* 购买方银行账号
*/
private
String
purchaserAccountBank
;
/**
* 开票内容
*/
private
String
content
;
/**
* 购方手机
*/
private
String
purchaserPhone
;
/**
* 开票内容
*/
private
String
content
;
/**
* 购方手机
*/
private
String
purchaserPhone
;
private
List
<
OrderData
>
orders
;
private
List
<
OrderData
>
orders
;
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/service/InvoiceBiz.java
View file @
c8f1af62
...
...
@@ -76,13 +76,13 @@ public class InvoiceBiz extends BaseBiz<InvoiceMapper, Invoice> {
* 开票人
*/
@Value
(
"${invoice.clerk}"
)
private
String
clerk
;
private
String
clerk
;
/**
* 推送方式:-1,不推送;0,邮箱;1,手机(默认);2,邮箱、手机
*/
@Value
(
"${invoice.pushMode}"
)
private
Integer
pushMode
=
2
;
private
Integer
pushMode
;
private
static
final
ScheduledExecutorService
executorService
=
new
ScheduledThreadPoolExecutor
(
8
);
/**
...
...
@@ -113,6 +113,10 @@ public class InvoiceBiz extends BaseBiz<InvoiceMapper, Invoice> {
* @throws Exception
*/
public
String
Invoicing
(
InvoiceVo
invoiceVo
)
throws
Exception
{
//没有填写邮箱不需要进行推送
if
(
StringUtils
.
isBlank
(
invoiceVo
.
getPurchaserEmail
()))
{
pushMode
=
-
1
;
}
Invoice
invoice
=
new
Invoice
();
long
on
=
snowflakeIdWorker
.
nextId
();
...
...
@@ -127,6 +131,7 @@ public class InvoiceBiz extends BaseBiz<InvoiceMapper, Invoice> {
invoice
.
setReviewer
(
checker
);
invoice
.
setIssuer
(
clerk
);
invoice
.
setPushMode
(
pushMode
);
Date
invoiceDate
=
new
Date
();
invoice
.
setCreateTime
(
invoiceDate
);
invoice
.
setInvoiceDate
(
invoiceDate
);
...
...
@@ -150,57 +155,58 @@ public class InvoiceBiz extends BaseBiz<InvoiceMapper, Invoice> {
*/
public
void
insertInvoic
(
Invoice
invoice
,
String
invoiceSerialNum
,
List
<
OrderData
>
orders
)
throws
Exception
{
IJWTInfo
infoFromToken
=
userAuthUtil
.
getInfoFromToken
(
userAuthConfig
.
getToken
(
request
));
invoice
.
setUserId
(
Integer
.
valueOf
(
infoFromToken
.
getId
()));
invoice
.
setCreateBy
(
infoFromToken
.
getName
());
invoice
.
setInvoiceSerialNum
(
invoiceSerialNum
);
BigDecimal
taxExcludedAmount
=
BigDecimal
.
ZERO
;
BigDecimal
taxIncludedAmount
=
BigDecimal
.
ZERO
;
for
(
OrderData
order
:
orders
)
{
if
(
order
.
getWithTaxFlag
()==
1
)
{
//含价税合计
BigDecimal
taxIncluded
=
order
.
getPrice
();
//税率
BigDecimal
taxRate
=
order
.
getTaxRate
();
//不含税单价
BigDecimal
TaxFree
=
taxIncluded
.
divide
(
taxRate
.
add
(
new
BigDecimal
(
1
)),
2
,
BigDecimal
.
ROUND_HALF_UP
);
taxExcludedAmount
=
taxExcludedAmount
.
add
(
TaxFree
);
taxIncludedAmount
=
taxIncludedAmount
.
add
(
taxIncluded
);
}
else
{
//不含税单价
BigDecimal
taxFree
=
order
.
getPrice
();
//税率
BigDecimal
taxRate
=
order
.
getTaxRate
();
//含税单价
BigDecimal
taxIncluded
=
taxFree
.
multiply
(
taxRate
.
add
(
new
BigDecimal
(
1
)));
taxExcludedAmount
=
taxExcludedAmount
.
add
(
taxFree
);
taxIncludedAmount
=
taxIncludedAmount
.
add
(
taxIncluded
);
}
IJWTInfo
infoFromToken
=
userAuthUtil
.
getInfoFromToken
(
userAuthConfig
.
getToken
(
request
));
invoice
.
setUserId
(
Integer
.
valueOf
(
infoFromToken
.
getId
()));
invoice
.
setCreateBy
(
infoFromToken
.
getName
());
invoice
.
setInvoiceSerialNum
(
invoiceSerialNum
);
BigDecimal
taxExcludedAmount
=
BigDecimal
.
ZERO
;
BigDecimal
taxIncludedAmount
=
BigDecimal
.
ZERO
;
for
(
OrderData
order
:
orders
)
{
if
(
order
.
getWithTaxFlag
()
==
1
)
{
//含价税合计
BigDecimal
taxIncluded
=
order
.
getPrice
();
//税率
BigDecimal
taxRate
=
order
.
getTaxRate
();
//不含税单价
BigDecimal
TaxFree
=
taxIncluded
.
divide
(
taxRate
.
add
(
new
BigDecimal
(
1
)),
2
,
BigDecimal
.
ROUND_HALF_UP
);
taxExcludedAmount
=
taxExcludedAmount
.
add
(
TaxFree
);
taxIncludedAmount
=
taxIncludedAmount
.
add
(
taxIncluded
);
}
else
{
//不含税单价
BigDecimal
taxFree
=
order
.
getPrice
();
//税率
BigDecimal
taxRate
=
order
.
getTaxRate
();
//含税单价
BigDecimal
taxIncluded
=
taxFree
.
multiply
(
taxRate
.
add
(
new
BigDecimal
(
1
)));
taxExcludedAmount
=
taxExcludedAmount
.
add
(
taxFree
);
taxIncludedAmount
=
taxIncludedAmount
.
add
(
taxIncluded
);
}
invoice
.
setInvoiceAmount
(
taxExcludedAmount
);
invoice
.
setTaxAmount
(
taxIncludedAmount
.
subtract
(
taxExcludedAmount
));
invoice
.
setInvoiceSummaryAmount
(
taxIncludedAmount
);
invoice
.
setInvoiceSummaryAmountText
(
NumberToCN
.
number2CNMontrayUnit
(
taxIncludedAmount
));
}
invoice
.
setInvoiceAmount
(
taxExcludedAmount
);
invoice
.
setTaxAmount
(
taxIncludedAmount
.
subtract
(
taxExcludedAmount
));
invoice
.
setInvoiceSummaryAmount
(
taxIncludedAmount
);
invoice
.
setInvoiceSummaryAmountText
(
NumberToCN
.
number2CNMontrayUnit
(
taxIncludedAmount
));
//保存到数据库
mapper
.
insert
(
invoice
);
//保存到数据库
mapper
.
insert
(
invoice
);
//异步查询开票结果
schedule
(
invoiceSerialNum
,
invoice
.
getId
(),
invoice
.
getOrderId
(),
null
,
0
,
5
,
TimeUnit
.
SECONDS
);
//异步查询开票结果
schedule
(
invoiceSerialNum
,
invoice
.
getId
(),
invoice
.
getOrderId
(),
null
,
0
,
5
,
TimeUnit
.
SECONDS
);
}
/**
* 或去查询结果
* 或去查询结果
*
* @param invoiceSerialNum 发票流水号
* @param id 发票id
* @param orderId 订单id
* @param lastStatus 上一次产需到的开票状态
* @param count 已经查询过的次数
* @param id
发票id
* @param orderId
订单id
* @param lastStatus
上一次产需到的开票状态
* @param count
已经查询过的次数
*/
public
void
queryInvoiceResult
(
String
invoiceSerialNum
,
Integer
id
,
String
orderId
,
Integer
lastStatus
,
Integer
count
)
{
if
(
count
==
2
)
{
public
void
queryInvoiceResult
(
String
invoiceSerialNum
,
Integer
id
,
String
orderId
,
Integer
lastStatus
,
Integer
count
)
{
if
(
count
==
2
)
{
InvoiceQueryError
invoiceQueryError
=
new
InvoiceQueryError
();
invoiceQueryError
.
setInvoiceId
(
id
);
invoiceQueryError
.
setInvoiceSerialNum
(
invoiceSerialNum
);
...
...
@@ -211,24 +217,24 @@ public class InvoiceBiz extends BaseBiz<InvoiceMapper, Invoice> {
}
List
<
Map
<
String
,
Object
>>
result
=
invoiceResult
(
invoiceSerialNum
);
if
(
result
==
null
)
{
schedule
(
invoiceSerialNum
,
id
,
orderId
,
null
,
++
count
,
2
,
TimeUnit
.
HOURS
);
if
(
result
==
null
)
{
schedule
(
invoiceSerialNum
,
id
,
orderId
,
null
,
++
count
,
2
,
TimeUnit
.
HOURS
);
return
;
}
log
.
info
(
"查询到的开票结果={}"
,
result
);
log
.
info
(
"查询到的开票结果={}"
,
result
);
Map
<
String
,
Object
>
data
=
result
.
get
(
0
);
Integer
status
=
(
Integer
)
data
.
get
(
"status"
);
String
invoiceFileUrl
=
(
String
)
data
.
get
(
"invoiceFileUrl"
);
String
invoiceCode
=
(
String
)
data
.
get
(
"invoiceCode"
);
String
invoiceNum
=
(
String
)
data
.
get
(
"invoiceNum"
);
String
taxIncludedAmountStr
=
String
.
valueOf
(
data
.
get
(
"taxIncludedAmount"
))
;
String
taxExcludedAmountStr
=
String
.
valueOf
(
data
.
get
(
"taxExcludedAmount"
))
;
String
taxIncludedAmountStr
=
String
.
valueOf
(
data
.
get
(
"taxIncludedAmount"
));
String
taxExcludedAmountStr
=
String
.
valueOf
(
data
.
get
(
"taxExcludedAmount"
));
Invoice
invoice
=
new
Invoice
();
invoice
.
setId
(
id
);
invoice
.
setStatus
(
status
);
invoice
.
setUpdateTime
(
new
Date
());
if
(
StringUtils
.
isNotBlank
(
taxExcludedAmountStr
)
&&
StringUtils
.
isNotBlank
(
taxIncludedAmountStr
))
{
if
(
StringUtils
.
isNotBlank
(
taxExcludedAmountStr
)
&&
StringUtils
.
isNotBlank
(
taxIncludedAmountStr
))
{
BigDecimal
taxExcludedAmount
=
new
BigDecimal
(
taxExcludedAmountStr
);
BigDecimal
taxIncludedAmount
=
new
BigDecimal
(
taxIncludedAmountStr
);
invoice
.
setInvoiceAmount
(
taxExcludedAmount
);
...
...
@@ -237,15 +243,15 @@ public class InvoiceBiz extends BaseBiz<InvoiceMapper, Invoice> {
invoice
.
setInvoiceSummaryAmountText
(
NumberToCN
.
number2CNMontrayUnit
(
taxIncludedAmount
));
}
if
(
InvoiceStatusEum
.
ONGOING
.
getCode
().
equals
(
status
)
||
InvoiceStatusEum
.
UNBILLED
.
getCode
().
equals
(
status
))
{
schedule
(
invoiceSerialNum
,
id
,
orderId
,
status
,
++
count
,
2
,
TimeUnit
.
HOURS
);
}
else
if
(
InvoiceStatusEum
.
SUCCESS
.
getCode
().
equals
(
status
))
{
schedule
(
invoiceSerialNum
,
id
,
orderId
,
status
,
++
count
,
2
,
TimeUnit
.
HOURS
);
}
else
if
(
InvoiceStatusEum
.
SUCCESS
.
getCode
().
equals
(
status
))
{
invoice
.
setInvoiceCode
(
invoiceCode
);
invoice
.
setInvoiceNo
(
invoiceNum
);
invoice
.
setPictureUrl
(
invoiceFileUrl
);
setOrderInvoice
(
orderId
,
status
,
invoiceFileUrl
);
}
else
{
setOrderInvoice
(
orderId
,
status
,
null
);
}
else
{
setOrderInvoice
(
orderId
,
status
,
null
);
}
mapper
.
updateByPrimaryKeySelective
(
invoice
);
...
...
@@ -253,8 +259,9 @@ public class InvoiceBiz extends BaseBiz<InvoiceMapper, Invoice> {
/**
* 设置订单发票表
* @param orderId 订单id
* @param status 发票查询状态
*
* @param orderId 订单id
* @param status 发票查询状态
* @param invoiceFileUrl 发票pdf地址
*/
public
void
setOrderInvoice
(
String
orderId
,
Integer
status
,
String
invoiceFileUrl
)
{
...
...
@@ -268,6 +275,7 @@ public class InvoiceBiz extends BaseBiz<InvoiceMapper, Invoice> {
/**
* 再次查询开票结果
*
* @param invoiceSerialNum
* @param id
* @param orderId
...
...
@@ -276,9 +284,9 @@ public class InvoiceBiz extends BaseBiz<InvoiceMapper, Invoice> {
* @param time
* @param timeUnit
*/
public
void
schedule
(
String
invoiceSerialNum
,
Integer
id
,
String
orderId
,
Integer
lastStatus
,
int
count
,
int
time
,
TimeUnit
timeUnit
)
{
public
void
schedule
(
String
invoiceSerialNum
,
Integer
id
,
String
orderId
,
Integer
lastStatus
,
int
count
,
int
time
,
TimeUnit
timeUnit
)
{
executorService
.
schedule
(()
->
{
queryInvoiceResult
(
invoiceSerialNum
,
id
,
orderId
,
lastStatus
,
count
);
queryInvoiceResult
(
invoiceSerialNum
,
id
,
orderId
,
lastStatus
,
count
);
},
time
,
timeUnit
);
}
...
...
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