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
22fd011a
Commit
22fd011a
authored
Dec 31, 2019
by
hanfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发票
parent
d5507559
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
319 additions
and
0 deletions
+319
-0
pom.xml
xx-universal/xx-universal-server/pom.xml
+6
-0
InvoiceController.java
...xxfc/platform/universal/controller/InvoiceController.java
+52
-0
InvoiceDao.java
...m/xxfc/platform/universal/service/Invoice/InvoiceDao.java
+19
-0
InvoiceDaoImpl.java
...atform/universal/service/Invoice/impl/InvoiceDaoImpl.java
+209
-0
InvoiceService.java
...a/com/xxfc/platform/universal/service/InvoiceService.java
+33
-0
No files found.
xx-universal/xx-universal-server/pom.xml
View file @
22fd011a
...
...
@@ -105,6 +105,12 @@
<version>
2.0-SNAPSHOT
</version>
<scope>
compile
</scope>
</dependency>
<!-- 诺诺发票sdk-->
<dependency>
<groupId>
com.nuonuo
</groupId>
<artifactId>
open-sdk
</artifactId>
<version>
1.0.3
</version>
</dependency>
</dependencies>
<build>
...
...
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/controller/InvoiceController.java
0 → 100644
View file @
22fd011a
package
com
.
xxfc
.
platform
.
universal
.
controller
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.xxfc.platform.universal.entity.Invoice
;
import
com.xxfc.platform.universal.service.InvoiceService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.Map
;
/**
* 发票接口
* @Auther: Administrator
* @Date: 2019/12/31 09:57
* @Description:
*/
@RestController
@RequestMapping
(
"/invoice"
)
public
class
InvoiceController
{
@Autowired
private
InvoiceService
invoiceService
;
/**
* 根据开票代码获取税号
* @param code
* @return
*/
@GetMapping
(
"/dutyParagraph"
)
public
ObjectRestResponse
getDutyParagraphByCode
(
@RequestParam
(
"code"
)
String
code
){
String
dutyParagraph
=
invoiceService
.
getDutyParagraphByCode
(
code
);
return
ObjectRestResponse
.
succ
(
dutyParagraph
);
}
/**
* 模糊查询获取公司全名和开票代码
* @param name
* @return
*/
@GetMapping
(
"/corporateName"
)
public
ObjectRestResponse
corporateName
(
@RequestParam
(
"name"
)
String
name
){
List
<
Map
<
String
,
String
>>
mapList
=
invoiceService
.
corporateName
(
name
);
return
ObjectRestResponse
.
succ
(
mapList
);
}
@PostMapping
public
ObjectRestResponse
Invoicing
(
@RequestBody
Invoice
invoice
){
invoiceService
.
Invoicing
(
invoice
);
return
ObjectRestResponse
.
succ
();
}
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/service/Invoice/InvoiceDao.java
0 → 100644
View file @
22fd011a
package
com
.
xxfc
.
platform
.
universal
.
service
.
Invoice
;
import
com.xxfc.platform.universal.entity.Invoice
;
import
java.util.List
;
import
java.util.Map
;
/**
* @Auther: Administrator
* @Date: 2019/12/31 10:23
* @Description:
*/
public
interface
InvoiceDao
{
List
<
Map
<
String
,
String
>>
corporateName
(
String
name
);
String
getDutyParagraphByCode
(
String
code
);
void
Invoicing
(
Invoice
invoice
);
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/service/Invoice/impl/InvoiceDaoImpl.java
0 → 100644
View file @
22fd011a
package
com
.
xxfc
.
platform
.
universal
.
service
.
Invoice
.
impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.wxiaoqi.security.common.exception.BaseException
;
import
com.google.common.collect.Lists
;
import
com.xxfc.platform.universal.entity.Invoice
;
import
com.xxfc.platform.universal.service.Invoice.InvoiceDao
;
import
lombok.extern.slf4j.Slf4j
;
import
nuonuo.open.sdk.NNOpenSDK
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
/**
* @Auther: Administrator
* @Date: 2019/12/31 10:26
* @Description:
*/
@Service
@Primary
@Slf4j
public
class
InvoiceDaoImpl
implements
InvoiceDao
{
@Autowired
private
RedisTemplate
redisTemplate
;
/**
* 诺诺-极速开票
*/
private
static
final
String
taxnum
=
"91441900MA53C6713X"
;
private
static
final
String
appKey
=
"80653463"
;
private
static
final
String
appSecret
=
"EA55B47A6D0A4560"
;
/**
* 诺诺-诺诺发票
*/
private
static
final
String
taxnum2
=
"91441900MA53C6713X"
;
private
static
final
String
appKey2
=
"26345711"
;
private
static
final
String
appSecret2
=
"901B543442BF41A1"
;
/**
* 给定的部分名获取税号
* @param name
* @return
*/
@Override
public
List
<
Map
<
String
,
String
>>
corporateName
(
String
name
)
{
NNOpenSDK
sdk
=
NNOpenSDK
.
getIntance
();
HashMap
<
String
,
String
>
map
=
new
HashMap
();
map
.
put
(
"q"
,
"name"
);
String
content
=
JSON
.
toJSONString
(
map
);
//方法名
String
method
=
"nuonuo.speedBilling.prefixQuery"
;
// SDK请求地址
String
url
=
"https://sdk.nuonuo.com/open/v1/services"
;
// 唯一标识,由企业自己生成32位随机码
String
senid
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
String
result
=
sdk
.
sendPostSyncRequest
(
url
,
senid
,
appKey
,
appSecret
,
getTokenJS
(),
taxnum
,
method
,
content
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
result
);
List
<
Map
<
String
,
String
>>
mapList
=
(
List
<
Map
<
String
,
String
>>)
jsonObject
.
get
(
"result"
);
if
(
CollectionUtil
.
isNotEmpty
(
mapList
))
{
return
mapList
;
}
return
new
ArrayList
<>();
}
/**
* 根据开票代码,调用第三方接口获取税号
* @param code
* @return
*/
@Override
public
String
getDutyParagraphByCode
(
String
code
)
{
NNOpenSDK
sdk
=
NNOpenSDK
.
getIntance
();
// API方法名
String
method
=
"nuonuo.speedBilling.queryNameAndTaxByCode"
;
// SDK请求地址
String
url
=
"https://sdk.jss.com.cn/open/v1/services"
;
HashMap
<
String
,
String
>
map
=
new
HashMap
();
map
.
put
(
"code"
,
code
);
String
content
=
JSON
.
toJSONString
(
map
);
// 唯一标识,由企业自己生成32位随机码
String
senid
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
String
result
=
sdk
.
sendPostSyncRequest
(
url
,
senid
,
appKey
,
appSecret
,
getTokenJS
(),
taxnum
,
method
,
content
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
result
);
Map
<
String
,
String
>
resultMap
=
(
Map
<
String
,
String
>)
jsonObject
.
get
(
"result"
);
return
resultMap
.
get
(
"kpCode"
);
}
@Override
public
void
Invoicing
(
Invoice
invoice
)
{
NNOpenSDK
sdk
=
NNOpenSDK
.
getIntance
();
// API方法名
String
method
=
"nuonuo.electronInvoice.requestBilling"
;
// SDK请求地址
String
url
=
"https://sandbox.nuonuocs.cn/open/v1/services"
;
// 唯一标识,由企业自己生成32位随机码
String
senid
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
HashMap
<
String
,
Map
<
String
,
Object
>>
orderMap
=
new
HashMap
<>();
orderMap
.
put
(
"order"
,
map
);
map
.
put
(
"buyerName"
,
"欣新房车网络科技(广东)股份有限公司"
);
map
.
put
(
"buyerTaxNum"
,
"91441900MA53C6713X"
);
map
.
put
(
"buyerTel"
,
"13926892766"
);
map
.
put
(
"buyerAddress"
,
"广东省东莞市松山湖园区科汇路1号1栋801室"
);
map
.
put
(
"buyerAccount"
,
"中国建设银行股份有限公司东莞虎门连升支行44050110140900000777"
);
map
.
put
(
"orderNo"
,
"20190611094711010009"
);
map
.
put
(
"invoiceDate"
,
"2019-12-27 14:30:00"
);
map
.
put
(
"clerk"
,
"小弟"
);
map
.
put
(
"salerName"
,
"欣新房车网络科技(广东)股份有限公司"
);
map
.
put
(
"salerTaxNum"
,
"339901999999142"
);
map
.
put
(
"salerTel"
,
"13926892766"
);
map
.
put
(
"salerAddress"
,
"广东省东莞市松山湖园区科汇路1号1栋801室"
);
map
.
put
(
"salerAccount"
,
"中国建设银行股份有限公司东莞虎门连升支行44050110140900000777"
);
map
.
put
(
"invoiceType"
,
"1"
);
map
.
put
(
"remark"
,
"出差路费"
);
map
.
put
(
"payee"
,
"老老大"
);
map
.
put
(
"checker"
,
"老大"
);
map
.
put
(
"pushMode"
,
"2"
);
map
.
put
(
"buyerPhone"
,
"13691751141"
);
map
.
put
(
"email"
,
"1208472890@qq.com"
);
map
.
put
(
"listFlag"
,
"0"
);
map
.
put
(
"listName"
,
"房车租赁"
);
map
.
put
(
"proxyInvoiceFlag"
,
"0"
);
ArrayList
<
Map
<
String
,
String
>>
arrayList
=
Lists
.
newArrayList
();
map
.
put
(
"invoiceDetail"
,
arrayList
);
HashMap
<
String
,
String
>
mx
=
new
HashMap
<>();
mx
.
put
(
"goodsName"
,
"房车租赁"
);
mx
.
put
(
"num"
,
"1"
);
mx
.
put
(
"withTaxFlag"
,
"0"
);
mx
.
put
(
"price"
,
"100"
);
mx
.
put
(
"taxRate"
,
"0.13"
);
mx
.
put
(
"unit"
,
"次"
);
arrayList
.
add
(
mx
);
map
.
put
(
"invoiceDetail"
,
arrayList
);
HashMap
<
String
,
String
>
mx2
=
new
HashMap
<>();
mx2
.
put
(
"goodsName"
,
"房车租赁"
);
mx2
.
put
(
"num"
,
"1"
);
mx2
.
put
(
"withTaxFlag"
,
"1"
);
mx2
.
put
(
"price"
,
"100"
);
mx2
.
put
(
"taxRate"
,
"0.13"
);
mx2
.
put
(
"unit"
,
"次"
);
arrayList
.
add
(
mx2
);
HashMap
<
String
,
String
>
mx3
=
new
HashMap
<>();
mx3
.
put
(
"goodsName"
,
"房车租赁"
);
mx3
.
put
(
"num"
,
"1"
);
mx3
.
put
(
"withTaxFlag"
,
"1"
);
mx3
.
put
(
"price"
,
"100"
);
mx3
.
put
(
"taxRate"
,
"0.13"
);
mx3
.
put
(
"unit"
,
"次"
);
arrayList
.
add
(
mx3
);
String
jsonString
=
JSON
.
toJSONString
(
orderMap
);
String
result
=
sdk
.
sendPostSyncRequest
(
url
,
senid
,
appKey2
,
appSecret2
,
getTokenFP
(),
taxnum2
,
method
,
jsonString
);
System
.
out
.
println
(
result
);
}
/**
* 获取极速开票token
*/
private
String
getTokenJS
()
{
return
getToken
(
appKey
,
appSecret
);
}
/**
* 获取诺诺发票token
*/
public
String
getTokenFP
()
{
return
getToken
(
appKey2
,
appSecret2
);
}
private
String
getToken
(
String
appKey
,
String
appSecret
)
{
String
token
=
(
String
)
redisTemplate
.
opsForValue
().
get
(
appKey
);
if
(
StringUtils
.
isBlank
(
token
))
{
String
json
=
NNOpenSDK
.
getIntance
().
getMerchantToken
(
appKey
,
appSecret
);
log
.
info
(
"token={}"
,
json
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
json
);
token
=
(
String
)
jsonObject
.
get
(
"access_token"
);
if
(
StringUtils
.
isBlank
(
token
))
{
throw
new
BaseException
(
"获取极速开票token失败"
);
}
redisTemplate
.
opsForValue
().
set
(
appKey
,
token
,
24
,
TimeUnit
.
HOURS
);
}
return
token
;
}
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/service/InvoiceService.java
0 → 100644
View file @
22fd011a
package
com
.
xxfc
.
platform
.
universal
.
service
;
import
com.xxfc.platform.universal.entity.Invoice
;
import
com.xxfc.platform.universal.service.Invoice.InvoiceDao
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Map
;
/**
* 发票服务
* @author Administrator
* @Date: 2019/12/31 10:05
* @Description:
*/
@Service
public
class
InvoiceService
{
@Autowired
private
InvoiceDao
invoiceDao
;
public
String
getDutyParagraphByCode
(
String
code
)
{
return
invoiceDao
.
getDutyParagraphByCode
(
code
);
}
public
List
<
Map
<
String
,
String
>>
corporateName
(
String
name
)
{
return
invoiceDao
.
corporateName
(
name
);
}
public
void
Invoicing
(
Invoice
invoice
)
{
invoiceDao
.
Invoicing
(
invoice
);
}
}
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