Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fzm-joying
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
lei
fzm-joying
Commits
83c576d0
Commit
83c576d0
authored
Jan 24, 2022
by
tangtuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微信支付
parent
4819f7b0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
291 additions
and
91 deletions
+291
-91
RabbitMQConfig.java
...n/src/main/java/com/fzm/common/config/RabbitMQConfig.java
+0
-35
NftPublishMsg.java
...rc/main/java/com/fzm/common/entity/dto/NftPublishMsg.java
+21
-0
ResultCode.java
...common/src/main/java/com/fzm/common/enums/ResultCode.java
+1
-0
WxPayProperties.java
.../main/java/com/fzm/common/properties/WxPayProperties.java
+3
-3
WxPayService.java
...on/src/main/java/com/fzm/common/service/WxPayService.java
+24
-0
NftServiceImpl.java
...main/java/com/fzm/common/service/impl/NftServiceImpl.java
+6
-22
WxPayServiceImpl.java
...in/java/com/fzm/common/service/impl/WxPayServiceImpl.java
+73
-2
TestController.java
...g-portal/src/main/java/com/fzm/portal/TestController.java
+32
-0
OrderController.java
.../main/java/com/fzm/portal/controller/OrderController.java
+7
-10
WxPayController.java
.../main/java/com/fzm/portal/controller/WxPayController.java
+18
-0
NftListener.java
...al/src/main/java/com/fzm/portal/listener/NftListener.java
+74
-0
OrderListener.java
.../src/main/java/com/fzm/portal/listener/OrderListener.java
+0
-5
application-dev.yml
joying-portal/src/main/resources/application-dev.yml
+2
-2
application-local.yml
joying-portal/src/main/resources/application-local.yml
+3
-3
application-nj.yml
joying-portal/src/main/resources/application-nj.yml
+2
-2
application-prod.yml
joying-portal/src/main/resources/application-prod.yml
+3
-3
application.yml
joying-portal/src/main/resources/application.yml
+1
-1
RabbitTestDemo.java
...g-portal/src/test/java/com/fzm/portal/RabbitTestDemo.java
+12
-0
WxPayTest.java
joying-portal/src/test/java/com/fzm/portal/WxPayTest.java
+9
-3
logback.2022-01-21.0.log
logs/logback.2022-01-21.0.log
+0
-0
logback.2022-01-24.0.log
logs/logback.2022-01-24.0.log
+0
-0
No files found.
joying-common/src/main/java/com/fzm/common/config/RabbitMQConfig.java
View file @
83c576d0
...
@@ -47,41 +47,6 @@ public class RabbitMQConfig {
...
@@ -47,41 +47,6 @@ public class RabbitMQConfig {
return
new
DirectExchange
(
DEAD_LETTER_DIRECT
,
true
,
false
,
null
);
return
new
DirectExchange
(
DEAD_LETTER_DIRECT
,
true
,
false
,
null
);
}
}
/**
* 存放死信的队列,用户监听这个队列
*
* @return
*/
@Bean
public
Queue
copyrightQueue
()
{
return
new
Queue
(
COPYRIGHT_QUEUE
,
true
);
}
/**
* 定义死信队列
*
* @return
*/
@Bean
public
Queue
dlQueue
()
{
return
QueueBuilder
.
durable
(
DEAD_LETTER_QUEUE
)
.
ttl
(
1000
*
60
*
60
*
6
)
.
ttl
(
1000
*
60
*
2
)
// 测试环境
.
deadLetterExchange
(
DEAD_LETTER_DIRECT
)
.
deadLetterRoutingKey
(
"copyright.notify"
)
.
build
();
}
@Bean
public
Binding
dlBinding
()
{
return
BindingBuilder
.
bind
(
dlQueue
()).
to
(
copyrightDirect
()).
with
(
"copyright.apply"
);
}
@Bean
public
Binding
copyrightBinding
()
{
return
BindingBuilder
.
bind
(
copyrightQueue
()).
to
(
dlDirect
()).
with
(
"copyright.notify"
);
}
/**
/**
...
...
joying-common/src/main/java/com/fzm/common/entity/dto/NftPublishMsg.java
0 → 100644
View file @
83c576d0
package
com
.
fzm
.
common
.
entity
.
dto
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @author tangtuo
* @date 2022/1/21 16:56
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public
class
NftPublishMsg
{
private
String
hash
;
private
Integer
id
;
private
Long
tokenId
;
}
joying-common/src/main/java/com/fzm/common/enums/ResultCode.java
View file @
83c576d0
...
@@ -21,6 +21,7 @@ public enum ResultCode implements IErrorCode {
...
@@ -21,6 +21,7 @@ public enum ResultCode implements IErrorCode {
COPYRIGHT_FAILED
(
420
,
"版权申请失败"
),
COPYRIGHT_FAILED
(
420
,
"版权申请失败"
),
SELECT_FAILED
(
421
,
"查询失败"
),
SELECT_FAILED
(
421
,
"查询失败"
),
PAY_FAILED
(
422
,
"支付失败"
),
PAY_FAILED
(
422
,
"支付失败"
),
REFUND_FAILED
(
422
,
"退款失败"
),
;
;
...
...
joying-common/src/main/java/com/fzm/common/properties/WxPayProperties.java
View file @
83c576d0
...
@@ -34,9 +34,9 @@ public class WxPayProperties {
...
@@ -34,9 +34,9 @@ public class WxPayProperties {
private
String
privateKeyPath
;
private
String
privateKeyPath
;
@ApiModelProperty
(
"h5支付回调地址"
)
@ApiModelProperty
(
"h5支付回调地址"
)
private
String
h5P
ayNotifyUrl
;
private
String
p
ayNotifyUrl
;
@ApiModelProperty
(
"
h5
退款回调地址"
)
@ApiModelProperty
(
"退款回调地址"
)
private
String
h5R
efundNotifyUrl
;
private
String
r
efundNotifyUrl
;
}
}
joying-common/src/main/java/com/fzm/common/service/WxPayService.java
View file @
83c576d0
package
com
.
fzm
.
common
.
service
;
package
com
.
fzm
.
common
.
service
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fzm.common.entity.dto.JsapiPayDto
;
import
com.fzm.common.entity.dto.JsapiPayDto
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.security.GeneralSecurityException
;
import
java.security.GeneralSecurityException
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -34,4 +36,26 @@ public interface WxPayService {
...
@@ -34,4 +36,26 @@ public interface WxPayService {
void
processOrder
(
JSONObject
jsonObject
)
throws
GeneralSecurityException
;
void
processOrder
(
JSONObject
jsonObject
)
throws
GeneralSecurityException
;
String
queryOrder
(
Long
orderId
);
String
queryOrder
(
Long
orderId
);
/**
* 退款
*
* @param orderId
*/
void
refund
(
Long
orderId
)
throws
IOException
;
/**
* 退款回调
*
* @param request
* @return
*/
Boolean
notifyRefund
(
HttpServletRequest
request
);
/**
* 处理退款成功后的订单
*
* @param jsonObject
*/
void
processRefund
(
JSONObject
jsonObject
);
}
}
joying-common/src/main/java/com/fzm/common/service/impl/NftServiceImpl.java
View file @
83c576d0
...
@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...
@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import
com.fzm.common.constant.RedisConstant
;
import
com.fzm.common.constant.RedisConstant
;
import
com.fzm.common.constant.SystemConstant
;
import
com.fzm.common.constant.SystemConstant
;
import
com.fzm.common.entity.*
;
import
com.fzm.common.entity.*
;
import
com.fzm.common.entity.dto.NftPublishMsg
;
import
com.fzm.common.entity.vo.CollectionNftVo
;
import
com.fzm.common.entity.vo.CollectionNftVo
;
import
com.fzm.common.entity.vo.CopyrightVo
;
import
com.fzm.common.entity.vo.CopyrightVo
;
import
com.fzm.common.entity.vo.NftListVo
;
import
com.fzm.common.entity.vo.NftListVo
;
...
@@ -109,7 +110,8 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
...
@@ -109,7 +110,8 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
@Override
@Override
public
Integer
publish
(
Integer
id
)
{
public
Integer
publish
(
Integer
id
)
{
User
user
=
userService
.
getUserByToken
();
Nft
nft
=
getById
(
id
);
User
user
=
userService
.
getUserByWallet
(
nft
.
getPublishAddress
());
if
(!
AuthStatus
.
SUCCESS
.
getStatus
().
equals
(
user
.
getAuthStatus
()))
{
if
(!
AuthStatus
.
SUCCESS
.
getStatus
().
equals
(
user
.
getAuthStatus
()))
{
throw
GlobalException
.
newException
(
ResultCode
.
PUBLISH_ERROR
,
"您还未实名认证,请先实名认证"
);
throw
GlobalException
.
newException
(
ResultCode
.
PUBLISH_ERROR
,
"您还未实名认证,请先实名认证"
);
}
}
...
@@ -118,7 +120,6 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
...
@@ -118,7 +120,6 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
String
privkey
=
paraChainClient
.
walletDumpPrivkey
(
wallet
);
String
privkey
=
paraChainClient
.
walletDumpPrivkey
(
wallet
);
// 生产tokenId
// 生产tokenId
long
tokenId
=
getTokenId
();
long
tokenId
=
getTokenId
();
Nft
nft
=
getById
(
id
);
TreeMap
<
String
,
String
>
map
=
new
TreeMap
<>();
TreeMap
<
String
,
String
>
map
=
new
TreeMap
<>();
map
.
put
(
"hash"
,
nft
.
getFileHash
());
map
.
put
(
"hash"
,
nft
.
getFileHash
());
map
.
put
(
"publishAddress"
,
wallet
);
map
.
put
(
"publishAddress"
,
wallet
);
...
@@ -138,26 +139,9 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
...
@@ -138,26 +139,9 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
if
(
StringUtils
.
isBlank
(
tradeHash
))
{
if
(
StringUtils
.
isBlank
(
tradeHash
))
{
throw
GlobalException
.
newException
(
ResultCode
.
PUBLISH_ERROR
,
"nft发行失败"
);
throw
GlobalException
.
newException
(
ResultCode
.
PUBLISH_ERROR
,
"nft发行失败"
);
}
}
// 确认交易结果
// 给mq发送一条消息,异步确认交易结果
TxResult
txResult
=
paraChainClient
.
cycleConfirmTxWithHash
(
hash
,
true
,
1000
);
NftPublishMsg
nftPublishMsg
=
new
NftPublishMsg
(
hash
,
id
,
tokenId
);
if
(!
TxStatusEnum
.
SUCCESS
.
equals
(
txResult
.
getStatus
()))
{
rabbitTemplate
.
convertAndSend
(
"nft-exchange"
,
"nft.publish"
,
nftPublishMsg
);
throw
GlobalException
.
newException
(
ResultCode
.
PUBLISH_ERROR
,
txResult
.
getErrMsg
().
getValue
());
}
String
realHash
=
paraChainClient
.
getRealTxHashFromGrp
(
hash
);
/*TxResult txResult = paraChainClient.cycleConfirmTxWithHash(realHash, false, 1000);
if (!TxStatusEnum.SUCCESS.equals(txResult.getStatus())) {
throw GlobalException.newException(ResultCode.PUBLISH_ERROR, txResult.getErrMsg().getValue());
}*/
nft
.
setNftHash
(
realHash
);
nft
.
setTokenId
(
tokenId
);
nft
.
setPublishTime
(
new
Date
());
updateById
(
nft
);
// 如果用户是第一次发行作品,把用户的isPublish修改成1,并清空用户统计的缓存信息
if
(
SystemConstant
.
BOOLEAN_DATA_FALSE
.
equals
(
user
.
getIsPublish
()))
{
User
u
=
new
User
().
setId
(
user
.
getId
()).
setIsPublish
(
SystemConstant
.
BOOLEAN_DATA_TRUE
);
userService
.
updateById
(
u
);
redisUtil
.
delete
(
"user::statistic"
);
}
return
nft
.
getId
();
return
nft
.
getId
();
}
}
...
...
joying-common/src/main/java/com/fzm/common/service/impl/WxPayServiceImpl.java
View file @
83c576d0
...
@@ -13,7 +13,7 @@ import com.fzm.common.enums.*;
...
@@ -13,7 +13,7 @@ import com.fzm.common.enums.*;
import
com.fzm.common.exception.GlobalException
;
import
com.fzm.common.exception.GlobalException
;
import
com.fzm.common.properties.WxPayProperties
;
import
com.fzm.common.properties.WxPayProperties
;
import
com.fzm.common.service.*
;
import
com.fzm.common.service.*
;
import
com.fzm.common.utils.
Jwt
Util
;
import
com.fzm.common.utils.
Snowflake
Util
;
import
com.wechat.pay.contrib.apache.httpclient.util.AesUtil
;
import
com.wechat.pay.contrib.apache.httpclient.util.AesUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -74,6 +74,9 @@ public class WxPayServiceImpl implements WxPayService {
...
@@ -74,6 +74,9 @@ public class WxPayServiceImpl implements WxPayService {
@Resource
@Resource
private
RabbitTemplate
rabbitTemplate
;
private
RabbitTemplate
rabbitTemplate
;
@Resource
private
SnowflakeUtil
snowflakeUtil
;
public
Map
<
String
,
Object
>
payJsapi
(
JsapiPayDto
jsapiPayDto
)
throws
Exception
{
public
Map
<
String
,
Object
>
payJsapi
(
JsapiPayDto
jsapiPayDto
)
throws
Exception
{
RLock
lock
=
redisson
.
getLock
(
"pay-"
+
jsapiPayDto
.
getOrderId
());
RLock
lock
=
redisson
.
getLock
(
"pay-"
+
jsapiPayDto
.
getOrderId
());
if
(!
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
))
{
if
(!
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
))
{
...
@@ -94,7 +97,7 @@ public class WxPayServiceImpl implements WxPayService {
...
@@ -94,7 +97,7 @@ public class WxPayServiceImpl implements WxPayService {
rootNode
.
put
(
"mchid"
,
wxPayProperties
.
getMchId
())
rootNode
.
put
(
"mchid"
,
wxPayProperties
.
getMchId
())
.
put
(
"appid"
,
appId
)
.
put
(
"appid"
,
appId
)
.
put
(
"description"
,
PayScene
.
getTypeByCode
(
order
.
getPayScene
()))
.
put
(
"description"
,
PayScene
.
getTypeByCode
(
order
.
getPayScene
()))
.
put
(
"notify_url"
,
wxPayProperties
.
get
H5
PayNotifyUrl
())
.
put
(
"notify_url"
,
wxPayProperties
.
getPayNotifyUrl
())
.
put
(
"out_trade_no"
,
String
.
valueOf
(
out_trade_no
));
.
put
(
"out_trade_no"
,
String
.
valueOf
(
out_trade_no
));
rootNode
.
putObject
(
"amount"
)
rootNode
.
putObject
(
"amount"
)
.
put
(
"total"
,
order
.
getFee
());
.
put
(
"total"
,
order
.
getFee
());
...
@@ -216,6 +219,74 @@ public class WxPayServiceImpl implements WxPayService {
...
@@ -216,6 +219,74 @@ public class WxPayServiceImpl implements WxPayService {
return
null
;
return
null
;
}
}
@Override
public
void
refund
(
Long
orderId
)
throws
IOException
{
Order
order
=
orderService
.
getById
(
orderId
);
if
(
order
==
null
||
!
order
.
getOrderStatus
().
equals
(
OrderStatus
.
PAYED
.
getStatus
()))
{
throw
GlobalException
.
newException
(
ResultCode
.
REFUND_FAILED
,
"当前订单未支付成功"
);
}
String
out_refund_no
=
"refund-"
+
snowflakeUtil
.
snowflakeId
();
String
url
=
"https://api.mch.weixin.qq.com/v3/refund/domestic/refunds"
;
HttpPost
httpPost
=
new
HttpPost
(
url
);
httpPost
.
addHeader
(
"Accept"
,
"application/json"
);
httpPost
.
addHeader
(
"Content-type"
,
"application/json; charset=utf-8"
);
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
ObjectNode
rootNode
=
objectMapper
.
createObjectNode
();
rootNode
.
put
(
"mchid"
,
wxPayProperties
.
getMchId
())
.
put
(
"appid"
,
wxPayProperties
.
getAppId
())
.
put
(
"out_refund_no"
,
out_refund_no
)
.
put
(
"notify_url"
,
wxPayProperties
.
getRefundNotifyUrl
())
.
put
(
"out_trade_no"
,
String
.
valueOf
(
orderId
));
rootNode
.
putObject
(
"amount"
)
.
put
(
"refund"
,
order
.
getFee
())
.
put
(
"total"
,
order
.
getFee
())
.
put
(
"currency"
,
"CNY"
);
String
json
=
objectMapper
.
writeValueAsString
(
rootNode
);
log
.
info
(
"退款接口请求参数: {}"
,
json
);
objectMapper
.
writeValue
(
bos
,
rootNode
);
httpPost
.
setEntity
(
new
StringEntity
(
bos
.
toString
(
"UTF-8"
),
"UTF-8"
));
CloseableHttpResponse
response
=
httpClient
.
execute
(
httpPost
);
String
bodyAsString
=
EntityUtils
.
toString
(
response
.
getEntity
());
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
bodyAsString
);
// 修改订单状态为退款中
orderService
.
updateOrderStatus
(
orderId
,
OrderStatus
.
REFUNDING
);
}
@Override
public
Boolean
notifyRefund
(
HttpServletRequest
request
)
{
try
{
String
requestBodyData
=
this
.
getRequestBodyData
(
request
);
log
.
info
(
"接收微信退款接口回调请求, 请求参数: {}"
,
requestBodyData
);
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
requestBodyData
);
JSONObject
resource
=
jsonObject
.
getJSONObject
(
"resource"
);
String
plainText
=
this
.
decrypt
(
resource
);
log
.
info
(
"解密后的明文信息为: {}"
,
plainText
);
JSONObject
obj
=
JSONUtil
.
parseObj
(
plainText
);
processRefund
(
jsonObject
);
return
null
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
@Override
public
void
processRefund
(
JSONObject
jsonObject
)
{
Long
out_trade_no
=
jsonObject
.
getLong
(
"out_trade_no"
);
RLock
lock
=
redisson
.
getLock
(
"refund-"
+
out_trade_no
);
lock
.
lock
(
10
,
TimeUnit
.
SECONDS
);
try
{
// 修改订单未退款成功
orderService
.
updateOrderStatus
(
out_trade_no
,
OrderStatus
.
REFUNDED
);
// 保存流水信息
}
finally
{
lock
.
unlock
();
}
}
/**
/**
* 解密
* 解密
*
*
...
...
joying-portal/src/main/java/com/fzm/portal/TestController.java
0 → 100644
View file @
83c576d0
package
com
.
fzm
.
portal
;
import
com.fzm.common.entity.dto.OrderProcessMsg
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.scheduling.support.SimpleTriggerContext
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
/**
* @author tangtuo
* @date 2022/1/21 16:28
*/
@Slf4j
@RestController
@RequestMapping
(
"/test"
)
public
class
TestController
{
@Resource
private
RabbitTemplate
rabbitTemplate
;
@GetMapping
(
"/send"
)
public
String
send
(){
log
.
info
(
"发送消息: {}"
,
123
);
rabbitTemplate
.
convertAndSend
(
"nft-exchange"
,
"nft.publish"
,
123
);
return
"SUCCESS"
;
}
}
joying-portal/src/main/java/com/fzm/portal/controller/OrderController.java
View file @
83c576d0
package
com
.
fzm
.
portal
.
controller
;
package
com
.
fzm
.
portal
.
controller
;
import
com.fzm.common.annotation.Authentication
;
import
com.fzm.common.annotation.Authentication
;
import
com.fzm.common.entity.Order
;
import
com.fzm.common.entity.dto.OrderDto
;
import
com.fzm.common.entity.dto.OrderDto
;
import
com.fzm.common.enums.PayScene
;
import
com.fzm.common.model.ResponseModel
;
import
com.fzm.common.model.ResponseModel
;
import
com.fzm.common.service.CopyrightApplyService
;
import
com.fzm.common.service.NftService
;
import
com.fzm.common.service.OrderService
;
import
com.fzm.common.service.OrderService
;
import
com.fzm.common.utils.SnowflakeUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
/**
* @author tangtuo
* @author tangtuo
* @date 2022/1/20 18:22
* @date 2022/1/20 18:22
*/
*/
@Authentication
@Authentication
@Api
(
tags
=
"
作品类别
"
)
@Api
(
tags
=
"
订单管理
"
)
@RestController
@RestController
@RequestMapping
(
"/o
pus/category
"
)
@RequestMapping
(
"/o
rder
"
)
public
class
OrderController
{
public
class
OrderController
{
@Resource
@Resource
...
@@ -31,13 +28,13 @@ public class OrderController {
...
@@ -31,13 +28,13 @@ public class OrderController {
@PostMapping
(
"/create"
)
@PostMapping
(
"/create"
)
@ApiOperation
(
"下单"
)
@ApiOperation
(
"下单"
)
public
ResponseModel
<
Lo
ng
>
createOrder
(
@RequestBody
OrderDto
orderDto
)
{
public
ResponseModel
<
Stri
ng
>
createOrder
(
@RequestBody
OrderDto
orderDto
)
{
Long
orderId
=
orderService
.
createOrder
(
orderDto
);
Long
orderId
=
orderService
.
createOrder
(
orderDto
);
return
ResponseModel
.
success
(
orderId
);
return
ResponseModel
.
success
(
String
.
valueOf
(
orderId
)
);
}
}
@GetMapping
(
"/query-order-status"
)
@GetMapping
(
"/query-order-status
/{orderId}
"
)
@ApiOperation
(
value
=
"查询订单状态"
)
@ApiOperation
(
value
=
"查询订单状态"
)
public
ResponseModel
<
Integer
>
queryOrderStatus
(
@PathVariable
Long
orderId
)
{
public
ResponseModel
<
Integer
>
queryOrderStatus
(
@PathVariable
Long
orderId
)
{
return
ResponseModel
.
success
(
orderService
.
getById
(
orderId
).
getOrderStatus
());
return
ResponseModel
.
success
(
orderService
.
getById
(
orderId
).
getOrderStatus
());
...
...
joying-portal/src/main/java/com/fzm/portal/controller/WxPayController.java
View file @
83c576d0
...
@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
...
@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -52,6 +53,23 @@ public class WxPayController {
...
@@ -52,6 +53,23 @@ public class WxPayController {
return
result
;
return
result
;
}
}
@ApiOperation
(
"退款回调通知"
)
@PostMapping
(
"/notify/refund"
)
public
Map
<
String
,
String
>
notifyRefund
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
Map
<
String
,
String
>
result
=
new
HashMap
<>();
Boolean
refund
=
wxPayService
.
notifyRefund
(
request
);
if
(
refund
)
{
result
.
put
(
"code"
,
"SUCCESS"
);
result
.
put
(
"message"
,
"成功"
);
response
.
setStatus
(
HttpStatus
.
HTTP_OK
);
}
else
{
result
.
put
(
"code"
,
"FAILED"
);
result
.
put
(
"message"
,
"系统异常"
);
response
.
setStatus
(
HttpStatus
.
HTTP_INTERNAL_ERROR
);
}
return
result
;
}
}
}
joying-portal/src/main/java/com/fzm/portal/listener/NftListener.java
0 → 100644
View file @
83c576d0
package
com
.
fzm
.
portal
.
listener
;
import
cn.fzm.chain.simplesdk.client.ParaChainClient
;
import
cn.fzm.chain.simplesdk.constant.TxStatusEnum
;
import
cn.fzm.chain.simplesdk.model.TxResult
;
import
com.fzm.common.constant.SystemConstant
;
import
com.fzm.common.entity.Nft
;
import
com.fzm.common.entity.User
;
import
com.fzm.common.entity.dto.NftPublishMsg
;
import
com.fzm.common.enums.ResultCode
;
import
com.fzm.common.exception.GlobalException
;
import
com.fzm.common.service.NftService
;
import
com.fzm.common.service.UserService
;
import
com.fzm.common.utils.RedisUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.Date
;
/**
* @author tangtuo
* @date 2022/1/21 16:49
*/
@Slf4j
@Component
public
class
NftListener
{
@Resource
private
ParaChainClient
paraChainClient
;
@Resource
private
NftService
nftService
;
@Resource
UserService
userService
;
@Resource
private
RedisUtil
redisUtil
;
/**
* 监听nft发行结果
*
* @param msg
*/
@RabbitListener
(
queues
=
"nft.publish.queue"
)
public
void
listenNftPublish
(
NftPublishMsg
msg
)
{
log
.
info
(
"收到处理确认nft发行结果的消息: {}"
,
msg
);
Nft
nft
=
nftService
.
getById
(
msg
.
getId
());
User
user
=
userService
.
getUserByWallet
(
nft
.
getPublishAddress
());
String
hash
=
msg
.
getHash
();
// 确认交易结果
TxResult
txResult
=
paraChainClient
.
cycleConfirmTxWithHash
(
hash
,
true
,
1000
);
if
(!
TxStatusEnum
.
SUCCESS
.
equals
(
txResult
.
getStatus
()))
{
throw
GlobalException
.
newException
(
ResultCode
.
PUBLISH_ERROR
,
txResult
.
getErrMsg
().
getValue
());
}
String
realHash
=
paraChainClient
.
getRealTxHashFromGrp
(
hash
);
/*TxResult txResult = paraChainClient.cycleConfirmTxWithHash(realHash, false, 1000);
if (!TxStatusEnum.SUCCESS.equals(txResult.getStatus())) {
throw GlobalException.newException(ResultCode.PUBLISH_ERROR, txResult.getErrMsg().getValue());
}*/
nft
.
setNftHash
(
realHash
);
nft
.
setTokenId
(
msg
.
getTokenId
());
nft
.
setPublishTime
(
new
Date
());
nftService
.
updateById
(
nft
);
// 如果用户是第一次发行作品,把用户的isPublish修改成1,并清空用户统计的缓存信息
if
(
SystemConstant
.
BOOLEAN_DATA_FALSE
.
equals
(
user
.
getIsPublish
()))
{
User
u
=
new
User
().
setId
(
user
.
getId
()).
setIsPublish
(
SystemConstant
.
BOOLEAN_DATA_TRUE
);
userService
.
updateById
(
u
);
redisUtil
.
delete
(
"user::statistic"
);
}
}
}
joying-portal/src/main/java/com/fzm/portal/listener/OrderListener.java
View file @
83c576d0
...
@@ -37,9 +37,4 @@ public class OrderListener {
...
@@ -37,9 +37,4 @@ public class OrderListener {
}
}
}
}
@RabbitListener
(
queues
=
"nft.publish.queue"
)
public
void
listenProcessOrder
(
Long
id
)
{
log
.
info
(
"接收到信息: {}"
,
id
);
}
}
}
joying-portal/src/main/resources/application-dev.yml
View file @
83c576d0
...
@@ -113,5 +113,5 @@ wx-pay:
...
@@ -113,5 +113,5 @@ wx-pay:
api-v3-key
:
D864DA53FEF8ACD41519064967DC10D2
api-v3-key
:
D864DA53FEF8ACD41519064967DC10D2
mch-serial-num
:
72A62544B0A08A214FAEC780108692EDC6E7D5FA
mch-serial-num
:
72A62544B0A08A214FAEC780108692EDC6E7D5FA
private-key-path
:
apiclient_key.pem
private-key-path
:
apiclient_key.pem
h5-pay-notify-url
:
https://146.56.218.121:12100/wx-pay/notify/h5
pay-notify-url
:
https://146.56.218.121:12100/wx-pay/notify/jsapi
h5-refund-notify-url
:
refund-notify-url
:
https://146.56.218.121:12100/wx-pay/notify/refund
joying-portal/src/main/resources/application-local.yml
View file @
83c576d0
...
@@ -113,5 +113,5 @@ wx-pay:
...
@@ -113,5 +113,5 @@ wx-pay:
api-v3-key
:
D864DA53FEF8ACD41519064967DC10D2
api-v3-key
:
D864DA53FEF8ACD41519064967DC10D2
mch-serial-num
:
72A62544B0A08A214FAEC780108692EDC6E7D5FA
mch-serial-num
:
72A62544B0A08A214FAEC780108692EDC6E7D5FA
private-key-path
:
apiclient_key.pem
private-key-path
:
apiclient_key.pem
h5-pay-notify-url
:
https://146.56.218.121:12100/wx-pay/notify/h5
pay-notify-url
:
https://146.56.218.121:12100/wx-pay/notify/jsapi
h5-refund-notify-url
:
refund-notify-url
:
https://146.56.218.121:12100/wx-pay/notify/refund
\ No newline at end of file
\ No newline at end of file
joying-portal/src/main/resources/application-nj.yml
View file @
83c576d0
...
@@ -126,5 +126,5 @@ wx-pay:
...
@@ -126,5 +126,5 @@ wx-pay:
api-v3-key
:
D864DA53FEF8ACD41519064967DC10D2
api-v3-key
:
D864DA53FEF8ACD41519064967DC10D2
mch-serial-num
:
72A62544B0A08A214FAEC780108692EDC6E7D5FA
mch-serial-num
:
72A62544B0A08A214FAEC780108692EDC6E7D5FA
private-key-path
:
apiclient_key.pem
private-key-path
:
apiclient_key.pem
h5-pay-notify-url
:
https://test.inmvo.com:8985/proxyApi/wx-pay/notify/h5
pay-notify-url
:
https://test.inmvo.com:8985/proxyApi/wx-pay/notify/jsapi
h5-refund-notify-url
:
refund-notify-url
:
https://test.inmvo.com:8985/proxyApi/wx-pay/notify/refund
joying-portal/src/main/resources/application-prod.yml
View file @
83c576d0
...
@@ -115,5 +115,5 @@ wx-pay:
...
@@ -115,5 +115,5 @@ wx-pay:
api-v3-key
:
D864DA53FEF8ACD41519064967DC10D2
api-v3-key
:
D864DA53FEF8ACD41519064967DC10D2
mch-serial-num
:
72A62544B0A08A214FAEC780108692EDC6E7D5FA
mch-serial-num
:
72A62544B0A08A214FAEC780108692EDC6E7D5FA
private-key-path
:
apiclient_key.pem
private-key-path
:
apiclient_key.pem
h5-pay-notify-url
:
https://nft.inmvo.com/proxyApi/wx-pay/notify/h5
pay-notify-url
:
https://nft.inmvo.com/proxyApi/wx-pay/notify/jsapi
h5-refund-notify-url
:
refund-notify-url
:
https://nft.inmvo.com/proxyApi/wx-pay/notify/refund
\ No newline at end of file
\ No newline at end of file
joying-portal/src/main/resources/application.yml
View file @
83c576d0
spring
:
spring
:
profiles
:
profiles
:
active
:
local
active
:
nj
application
:
application
:
name
:
joying-portal
name
:
joying-portal
servlet
:
servlet
:
...
...
joying-portal/src/test/java/com/fzm/portal/RabbitTestDemo.java
View file @
83c576d0
package
com
.
fzm
.
portal
;
package
com
.
fzm
.
portal
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
javax.annotation.Resource
;
/**
/**
* @author tangtuo
* @author tangtuo
...
@@ -12,4 +17,11 @@ import org.springframework.boot.test.context.SpringBootTest;
...
@@ -12,4 +17,11 @@ import org.springframework.boot.test.context.SpringBootTest;
public
class
RabbitTestDemo
{
public
class
RabbitTestDemo
{
@Resource
private
RabbitTemplate
rabbitTemplate
;
@Test
public
void
send
()
{
}
}
}
joying-portal/src/test/java/com/fzm/portal/WxPayTest.java
View file @
83c576d0
...
@@ -2,6 +2,7 @@ package com.fzm.portal;
...
@@ -2,6 +2,7 @@ package com.fzm.portal;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.fzm.common.entity.dto.OrderProcessMsg
;
import
com.fzm.common.properties.WxPayProperties
;
import
com.fzm.common.properties.WxPayProperties
;
import
com.fzm.common.service.WxPayService
;
import
com.fzm.common.service.WxPayService
;
import
com.fzm.common.utils.SnowflakeUtil
;
import
com.fzm.common.utils.SnowflakeUtil
;
...
@@ -12,6 +13,7 @@ import org.apache.http.entity.StringEntity;
...
@@ -12,6 +13,7 @@ import org.apache.http.entity.StringEntity;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.util.EntityUtils
;
import
org.apache.http.util.EntityUtils
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -39,6 +41,9 @@ public class WxPayTest {
...
@@ -39,6 +41,9 @@ public class WxPayTest {
@Resource
@Resource
private
SnowflakeUtil
snowflakeUtil
;
private
SnowflakeUtil
snowflakeUtil
;
@Resource
private
RabbitTemplate
rabbitTemplate
;
@Test
@Test
public
void
testSnowFlake
()
{
public
void
testSnowFlake
()
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
...
@@ -48,9 +53,10 @@ public class WxPayTest {
...
@@ -48,9 +53,10 @@ public class WxPayTest {
@Test
@Test
public
void
testH5Pay
()
throws
IOException
{
public
void
testH5Pay
()
throws
IOException
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
OrderProcessMsg
orderProcessMsg
=
new
OrderProcessMsg
(
1
,
1
);
log
.
info
(
String
.
valueOf
(
snowflakeUtil
.
snowflakeId
()));
rabbitTemplate
.
convertAndSend
(
"order-exchange"
,
"order.process"
,
orderProcessMsg
);
}
// for (int i = 0; i < 10; i++) {
// log.info(String.valueOf(snowflakeUtil.snowflakeId()));// }
// String url = "https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi";
// String url = "https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi";
// HttpPost httpPost = new HttpPost(url);
// HttpPost httpPost = new HttpPost(url);
// httpPost.addHeader("Accept", "application/json");
// httpPost.addHeader("Accept", "application/json");
...
...
logs/logback.2022-01-21.0.log
View file @
83c576d0
This diff is collapsed.
Click to expand it.
logs/logback.2022-01-24.0.log
0 → 100644
View file @
83c576d0
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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