记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
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
董敬伟
liquidnet-bus-v1
Commits
02c2ab15
Commit
02c2ab15
authored
Jul 10, 2021
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交支付宝支付
parent
b9d95beb
Changes
20
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
841 additions
and
44 deletions
+841
-44
DragonConstant.java
...com/liquidnet/service/dragon/constant/DragonConstant.java
+40
-18
DragonPayBaseReqDto.java
...com/liquidnet/service/dragon/dto/DragonPayBaseReqDto.java
+4
-3
IDragonOrdersService.java
...iquidnet/service/dragon/service/IDragonOrdersService.java
+9
-0
IDGenerator.java
...ain/java/com/liquidnet/commons/lang/util/IDGenerator.java
+7
-0
liquidnet-service-dragon-dev.yml
...-config/liquidnet-config/liquidnet-service-dragon-dev.yml
+2
-0
DragonOrders.java
...ava/com/liquidnet/service/dragon/entity/DragonOrders.java
+5
-0
RedisStreamConfig.java
...ice/consumer/dragon/service/config/RedisStreamConfig.java
+8
-8
ConsumerPayProcessor.java
...nsumer/dragon/service/processor/ConsumerPayProcessor.java
+61
-0
ConsumerRefundProcessor.java
...mer/dragon/service/processor/ConsumerRefundProcessor.java
+28
-0
RedisRefundReceiver.java
...consumer/dragon/service/receiver/RedisRefundReceiver.java
+1
-1
AlipayConfigUtil.java
...ervice/dragon/channel/alipay/config/AlipayConfigUtil.java
+98
-0
AlipayTradePayReq.java
.../service/dragon/channel/alipay/req/AlipayTradePayReq.java
+29
-0
MD5.java
...com/liquidnet/service/dragon/channel/alipay/sign/MD5.java
+77
-0
AlipayUtil.java
...uidnet/service/dragon/channel/alipay/util/AlipayUtil.java
+167
-0
WepayUtil.java
...iquidnet/service/dragon/channel/wepay/util/WepayUtil.java
+13
-0
PayController.java
...om/liquidnet/service/dragon/controller/PayController.java
+177
-1
DragonOrderRefundsServiceImpl.java
...ce/dragon/service/impl/DragonOrderRefundsServiceImpl.java
+4
-4
DragonOrdersServiceImpl.java
.../service/dragon/service/impl/DragonOrdersServiceImpl.java
+94
-0
PayAlipayUtils.java
...va/com/liquidnet/service/dragon/utils/PayAlipayUtils.java
+12
-9
sqlmap.properties
...-service-dragon-impl/src/main/resources/sqlmap.properties
+5
-0
No files found.
liquidnet-bus-api/liquidnet-service-dragon-api/src/main/java/com/liquidnet/service/dragon/constant/DragonConstant.java
View file @
02c2ab15
...
...
@@ -15,13 +15,13 @@ public class DragonConstant {
public
static
final
String
REFUND_TYPE_JS_WEPAY
=
"JSWEPAY"
;
//,"微信内网页、微信公众号"),
public
static
final
String
REFUND_TYPE_APPLET_WEPAY
=
"APPLETWEPAY"
;
//,"微信小程序");
public
enum
p
ayChannelEnum
{
public
enum
P
ayChannelEnum
{
ALIPAY
(
"alipay"
,
"支付宝"
),
WEPAY
(
"wePay"
,
"微信"
),
CLOUDPAY
(
"cloudPay"
,
"云闪付"
);
private
String
code
;
private
String
message
;
p
ayChannelEnum
(
String
code
,
String
message
)
{
P
ayChannelEnum
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
...
...
@@ -29,7 +29,7 @@ public class DragonConstant {
/**
* 支付状态
*/
public
enum
p
ayStatusEnum
{
public
enum
P
ayStatusEnum
{
STATUS_UNPAID
(
"0"
,
"未支付,或支付中"
),
STATUS_PAID
(
"1"
,
"已支付"
),
STATUS_SUCCESS
(
"2"
,
"已支付,通知成功,交易结束"
),
...
...
@@ -38,16 +38,30 @@ public class DragonConstant {
private
String
code
;
private
String
message
;
p
ayStatusEnum
(
String
code
,
String
message
)
{
P
ayStatusEnum
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
PayStatusEnum
getEnumByCode
(
String
code
){
PayStatusEnum
[]
arry
=
PayStatusEnum
.
values
();
for
(
int
i
=
0
;
i
<
arry
.
length
;
i
++)
{
if
(
arry
[
i
].
getCode
().
equals
(
code
))
{
return
arry
[
i
];
}
}
return
null
;
}
public
String
getCode
()
{
return
code
;
}
}
/**
* 退款状态
*/
public
enum
r
efundStatusEnum
{
public
enum
R
efundStatusEnum
{
STATUS_UNFILLED
(
"0"
,
"未处理"
),
STATUS_REFUNDED
(
"1"
,
"退款成功"
),
STATUS_SUCCESS
(
"2"
,
"退款成功,通知成功,交易结束"
),
...
...
@@ -61,7 +75,7 @@ public class DragonConstant {
private
String
code
;
private
String
message
;
r
efundStatusEnum
(
String
code
,
String
message
)
{
R
efundStatusEnum
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
...
...
@@ -74,7 +88,7 @@ public class DragonConstant {
/**
* 支付业务类型
*/
public
enum
b
ussinessTypeEnum
{
public
enum
B
ussinessTypeEnum
{
TYPE_TICKET
(
"TICKET"
,
"票务购买(实物购买)"
),
TYPE_PRODUCT
(
"PRODUCT"
,
"商品购买(实物购买)"
),
TYPE_COST
(
"COST"
,
"活动资费(活动成本费、活动报名费)"
),
...
...
@@ -87,16 +101,20 @@ public class DragonConstant {
private
String
code
;
private
String
message
;
b
ussinessTypeEnum
(
String
code
,
String
message
)
{
B
ussinessTypeEnum
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
String
getCode
()
{
return
code
;
}
}
/**
* 支付类型
*/
public
enum
p
ayTypeEnum
{
public
enum
P
ayTypeEnum
{
PAYMENT_TYPE_APP_ALIPAY
(
"APPALIPAY"
,
"App内支付宝支付"
),
PAYMENT_TYPE_APP_WEPAY
(
"APPWEPAY"
,
"App内微信支付"
),
PAYMENT_TYPE_APP_IAP
(
"APPIAP"
,
"App内IAP(In-App Purchase)支付,iOS虚拟道具支付"
),
...
...
@@ -109,16 +127,20 @@ public class DragonConstant {
private
String
code
;
private
String
message
;
p
ayTypeEnum
(
String
code
,
String
message
)
{
P
ayTypeEnum
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
String
getCode
()
{
return
code
;
}
}
/**
* 退款类型
*/
public
enum
r
efundTypeEnum
{
public
enum
R
efundTypeEnum
{
REFUND_TYPE_APP_ALIPAY
(
"APPALIPAY"
,
"App内支付宝支付"
),
REFUND_TYPE_APP_WEPAY
(
"APPWEPAY"
,
"App内微信支付"
),
REFUND_TYPE_APP_IAP
(
"APPIAP"
,
"App内IAP(In-App Purchase)支付,iOS虚拟道具支付"
),
...
...
@@ -131,7 +153,7 @@ public class DragonConstant {
private
String
code
;
private
String
message
;
r
efundTypeEnum
(
String
code
,
String
message
)
{
R
efundTypeEnum
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
...
...
@@ -144,14 +166,14 @@ public class DragonConstant {
/**
* MYSQL_REDIS_QUEUE
*/
public
enum
m
ysqlRedisQueueEnum
{
public
enum
M
ysqlRedisQueueEnum
{
DRAGON_PAY_KEY
(
"dragon-pay"
,
"同步数据-支付"
),
DRAGON_REFUND_KEY
(
"dragon-refund"
,
"同步数据-退款"
),
DRAGON_PAY_GROUP
(
"dragon-pay-group"
,
"同步数据-支付-组"
),
DRAGON_REFUND_GROUP
(
"dragon-refund-group"
,
"同步数据-退款-组"
);
private
String
code
;
private
String
message
;
m
ysqlRedisQueueEnum
(
String
code
,
String
message
)
{
M
ysqlRedisQueueEnum
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
...
...
@@ -164,7 +186,7 @@ public class DragonConstant {
/**
* CHANNEL_REDIS_QUEUE
*/
public
enum
c
hannelRedisQueueEnum
{
public
enum
C
hannelRedisQueueEnum
{
WECHAT_PAY_KEY
(
"wechat-pay"
,
"微信-支付-回调"
),
WECHAT_REFUND_KEY
(
"wechat-pay"
,
"微信-退款-回调"
),
ALIPAY_PAY_KEY
(
"alipay-pay"
,
"支付宝-支付-回调"
),
...
...
@@ -175,7 +197,7 @@ public class DragonConstant {
ALIPAY_REFUND_GROUP
(
"alipay-refund-group"
,
"支付宝-退款-回调-组"
);
private
String
code
;
private
String
message
;
c
hannelRedisQueueEnum
(
String
code
,
String
message
)
{
C
hannelRedisQueueEnum
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
...
...
@@ -184,7 +206,7 @@ public class DragonConstant {
/**
* CHANNEL_REFUND_URL
*/
public
enum
c
hannelRefundUrlEnum
{
public
enum
C
hannelRefundUrlEnum
{
JSAPI_REFUND_URL
(
"https://api.mch.weixin.qq.com/v3/refund/domestic/refunds"
,
"JSAPI-退款-接口"
),
APP_REFUND_URL
(
"https://api.mch.weixin.qq.com/v3/refund/domestic/refunds"
,
"APP-退款-接口"
),
H5_REFUND_URL
(
"https://api.mch.weixin.qq.com/v3/refund/domestic/refunds"
,
"H5-退款-接口"
),
...
...
@@ -192,7 +214,7 @@ public class DragonConstant {
MCH_REFUND_URL
(
"https://api.mch.weixin.qq.com/v3/refund/domestic/refunds"
,
"小程序-退款-接口"
);
private
String
code
;
private
String
message
;
c
hannelRefundUrlEnum
(
String
code
,
String
message
)
{
C
hannelRefundUrlEnum
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
...
...
liquidnet-bus-api/liquidnet-service-dragon-api/src/main/java/com/liquidnet/service/dragon/dto/DragonPayBaseReqDto.java
View file @
02c2ab15
package
com
.
liquidnet
.
service
.
dragon
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
import
java.math.BigDecimal
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
...
...
@@ -13,11 +15,10 @@ import javax.validation.constraints.NotNull;
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/9 10:56
*/
@Data
public
class
DragonPayBaseReqDto
{
@ApiModelProperty
(
position
=
14
,
required
=
true
,
value
=
"性别[32]"
,
example
=
"{\"val\":\"MS00\",\"desc\":\"其他性别\"}"
)
@NotNull
(
message
=
"性别不能为空"
)
private
String
type
;
private
String
price
;
private
BigDecimal
price
;
private
String
name
;
private
String
detail
;
private
String
orderCode
;
...
...
liquidnet-bus-api/liquidnet-service-dragon-api/src/main/java/com/liquidnet/service/dragon/service/IDragonOrdersService.java
View file @
02c2ab15
package
com
.
liquidnet
.
service
.
dragon
.
service
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonRefundAppDto
;
import
java.math.BigDecimal
;
public
interface
IDragonOrdersService
{
void
sendRedisQueue
();
ResponseDto
<
DragonPayBaseRespDto
>
alipay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
);
}
liquidnet-bus-common/liquidnet-common-base/src/main/java/com/liquidnet/commons/lang/util/IDGenerator.java
View file @
02c2ab15
...
...
@@ -47,6 +47,13 @@ public class IDGenerator {
return
orderCode
;
}
public
static
String
payCode
(){
String
refundCode
=
System
.
currentTimeMillis
()+
""
;
int
randomCode
=
RandomUtil
.
getRandomInt
(
0
,
10000
);
StringUtils
.
leftPad
(
refundCode
,
3
,
"0"
);
return
refundCode
.
concat
(
StringUtils
.
leftPad
(
randomCode
+
""
,
(
randomCode
/
10
),
"0"
)+
"R"
);
}
public
static
String
refundCode
(){
String
refundCode
=
System
.
currentTimeMillis
()+
""
;
int
randomCode
=
RandomUtil
.
getRandomInt
(
0
,
10000
);
...
...
liquidnet-bus-config/liquidnet-config/liquidnet-service-dragon-dev.yml
View file @
02c2ab15
...
...
@@ -22,3 +22,5 @@ liquidnet:
mongodb
:
sslEnabled
:
false
database
:
dev_ln_scene
dragon
:
alipay-gataway-url
:
https://openapi.alipay.com/gateway.do
liquidnet-bus-do/liquidnet-service-dragon-do/src/main/java/com/liquidnet/service/dragon/entity/DragonOrders.java
View file @
02c2ab15
...
...
@@ -92,4 +92,9 @@ public class DragonOrders implements Serializable {
*/
private
LocalDateTime
updatedAt
;
/**
* deleted_at
*/
private
LocalDateTime
deletedAt
;
}
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-dragon/src/main/java/com/liquidnet/service/consumer/dragon/service/config/RedisStreamConfig.java
View file @
02c2ab15
...
...
@@ -32,8 +32,8 @@ public class RedisStreamConfig {
.
pollTimeout
(
Duration
.
ofMillis
(
1
))
.
build
();
var
listenerContainer
=
StreamMessageListenerContainer
.
create
(
factory
,
options
);
var
subscription
=
listenerContainer
.
receiveAutoAck
(
Consumer
.
from
(
DragonConstant
.
m
ysqlRedisQueueEnum
.
DRAGON_PAY_GROUP
.
getCode
(),
"dragon-pay-0"
),
StreamOffset
.
create
(
DragonConstant
.
m
ysqlRedisQueueEnum
.
DRAGON_PAY_KEY
.
getCode
(),
ReadOffset
.
lastConsumed
()),
redisPayReceiver
);
var
subscription
=
listenerContainer
.
receiveAutoAck
(
Consumer
.
from
(
DragonConstant
.
M
ysqlRedisQueueEnum
.
DRAGON_PAY_GROUP
.
getCode
(),
"dragon-pay-0"
),
StreamOffset
.
create
(
DragonConstant
.
M
ysqlRedisQueueEnum
.
DRAGON_PAY_KEY
.
getCode
(),
ReadOffset
.
lastConsumed
()),
redisPayReceiver
);
listenerContainer
.
start
();
return
subscription
;
}
...
...
@@ -46,8 +46,8 @@ public class RedisStreamConfig {
.
pollTimeout
(
Duration
.
ofMillis
(
1
))
.
build
();
var
listenerContainer
=
StreamMessageListenerContainer
.
create
(
factory
,
options
);
var
subscription
=
listenerContainer
.
receiveAutoAck
(
Consumer
.
from
(
DragonConstant
.
m
ysqlRedisQueueEnum
.
DRAGON_PAY_GROUP
.
getCode
(),
"dragon-pay-1"
),
StreamOffset
.
create
(
DragonConstant
.
m
ysqlRedisQueueEnum
.
DRAGON_PAY_KEY
.
getCode
(),
ReadOffset
.
lastConsumed
()),
redisPayReceiver
);
var
subscription
=
listenerContainer
.
receiveAutoAck
(
Consumer
.
from
(
DragonConstant
.
M
ysqlRedisQueueEnum
.
DRAGON_PAY_GROUP
.
getCode
(),
"dragon-pay-1"
),
StreamOffset
.
create
(
DragonConstant
.
M
ysqlRedisQueueEnum
.
DRAGON_PAY_KEY
.
getCode
(),
ReadOffset
.
lastConsumed
()),
redisPayReceiver
);
listenerContainer
.
start
();
return
subscription
;
}
...
...
@@ -60,8 +60,8 @@ public class RedisStreamConfig {
.
pollTimeout
(
Duration
.
ofMillis
(
1
))
.
build
();
var
listenerContainer
=
StreamMessageListenerContainer
.
create
(
factory
,
options
);
var
subscription
=
listenerContainer
.
receiveAutoAck
(
Consumer
.
from
(
DragonConstant
.
m
ysqlRedisQueueEnum
.
DRAGON_REFUND_GROUP
.
getCode
(),
"dragon-refund-0"
),
StreamOffset
.
create
(
DragonConstant
.
m
ysqlRedisQueueEnum
.
DRAGON_REFUND_KEY
.
getCode
(),
ReadOffset
.
lastConsumed
()),
redisRefundReceiver
);
var
subscription
=
listenerContainer
.
receiveAutoAck
(
Consumer
.
from
(
DragonConstant
.
M
ysqlRedisQueueEnum
.
DRAGON_REFUND_GROUP
.
getCode
(),
"dragon-refund-0"
),
StreamOffset
.
create
(
DragonConstant
.
M
ysqlRedisQueueEnum
.
DRAGON_REFUND_KEY
.
getCode
(),
ReadOffset
.
lastConsumed
()),
redisRefundReceiver
);
listenerContainer
.
start
();
return
subscription
;
}
...
...
@@ -74,8 +74,8 @@ public class RedisStreamConfig {
.
pollTimeout
(
Duration
.
ofMillis
(
1
))
.
build
();
var
listenerContainer
=
StreamMessageListenerContainer
.
create
(
factory
,
options
);
var
subscription
=
listenerContainer
.
receiveAutoAck
(
Consumer
.
from
(
DragonConstant
.
m
ysqlRedisQueueEnum
.
DRAGON_REFUND_GROUP
.
getCode
(),
"dragon-refund-1"
),
StreamOffset
.
create
(
DragonConstant
.
m
ysqlRedisQueueEnum
.
DRAGON_REFUND_KEY
.
getCode
(),
ReadOffset
.
lastConsumed
()),
redisRefundReceiver
);
var
subscription
=
listenerContainer
.
receiveAutoAck
(
Consumer
.
from
(
DragonConstant
.
M
ysqlRedisQueueEnum
.
DRAGON_REFUND_GROUP
.
getCode
(),
"dragon-refund-1"
),
StreamOffset
.
create
(
DragonConstant
.
M
ysqlRedisQueueEnum
.
DRAGON_REFUND_KEY
.
getCode
(),
ReadOffset
.
lastConsumed
()),
redisRefundReceiver
);
listenerContainer
.
start
();
return
subscription
;
}
...
...
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-dragon/src/main/java/com/liquidnet/service/consumer/dragon/service/processor/ConsumerPayProcessor.java
0 → 100644
View file @
02c2ab15
package
com
.
liquidnet
.
service
.
consumer
.
dragon
.
service
.
processor
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.consumer.dragon.service.IBaseDao
;
import
com.rabbitmq.client.Channel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.amqp.core.Message
;
import
org.springframework.amqp.core.MessageProperties
;
import
org.springframework.data.redis.connection.stream.MapRecord
;
import
org.springframework.data.redis.stream.StreamListener
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ConsumerPayProcessor
* @Package com.liquidnet.service.consumer.dragon.service.processor
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/8 10:59
*/
@Slf4j
@Component
public
class
ConsumerPayProcessor
implements
StreamListener
<
String
,
MapRecord
<
String
,
String
,
String
>>
{
@Resource
IBaseDao
baseDao
;
@Override
public
void
onMessage
(
MapRecord
<
String
,
String
,
String
>
message
)
{
log
.
info
(
"接受到来自redis PAY 的消息"
);
System
.
out
.
println
(
"message id "
+
message
.
getId
());
System
.
out
.
println
(
"stream "
+
message
.
getStream
());
System
.
out
.
println
(
"body "
+
message
.
getValue
());
}
private
void
consumerSqlDaoHandler
(
Message
msg
,
Channel
channel
)
{
MessageProperties
properties
=
msg
.
getMessageProperties
();
String
consumerQueue
=
properties
.
getConsumerQueue
();
long
deliveryTag
=
properties
.
getDeliveryTag
();
log
.
info
(
"CONSUMER SQL ==> [consumerQueue:{},deliveryTag:{}]"
,
consumerQueue
,
deliveryTag
);
SqlMapping
.
SqlMessage
sqlMessage
=
JsonUtils
.
fromJson
(
new
String
(
msg
.
getBody
()),
SqlMapping
.
SqlMessage
.
class
);
log
.
debug
(
"CONSUMER SQL ==> Preparing:{}"
,
JsonUtils
.
toJson
(
sqlMessage
.
getSqls
()));
log
.
debug
(
"CONSUMER SQL ==> Parameters:{}"
,
JsonUtils
.
toJson
(
sqlMessage
.
getArgs
()));
try
{
Boolean
rstBatchSqls
=
baseDao
.
batchSqls
(
sqlMessage
.
getSqls
(),
sqlMessage
.
getArgs
());
log
.
debug
(
"CONSUMER SQL result of execution:{}"
,
rstBatchSqls
);
if
(
rstBatchSqls
)
{
channel
.
basicAck
(
deliveryTag
,
false
);
}
else
{
log
.
warn
(
"###CONSUMER SQL[consumerQueue:{},deliveryTag={},sqlMessage:{}]"
,
consumerQueue
,
deliveryTag
,
JsonUtils
.
toJson
(
sqlMessage
));
channel
.
basicAck
(
deliveryTag
,
false
);
}
}
catch
(
IOException
e
)
{
log
.
error
(
"CONSUMER SQL[consumerQueue:{},deliveryTag:{},sqlMessage:{}]"
,
consumerQueue
,
deliveryTag
,
JsonUtils
.
toJson
(
sqlMessage
),
e
);
}
}
}
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-dragon/src/main/java/com/liquidnet/service/consumer/dragon/service/processor/ConsumerRefundProcessor.java
0 → 100644
View file @
02c2ab15
package
com
.
liquidnet
.
service
.
consumer
.
dragon
.
service
.
processor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.redis.connection.stream.MapRecord
;
import
org.springframework.data.redis.stream.StreamListener
;
import
org.springframework.stereotype.Component
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ConsumerRefundProcessor
* @Package com.liquidnet.service.consumer.dragon.service.processor
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/8 10:59
*/
@Slf4j
@Component
public
class
ConsumerRefundProcessor
implements
StreamListener
<
String
,
MapRecord
<
String
,
String
,
String
>>
{
@Override
public
void
onMessage
(
MapRecord
<
String
,
String
,
String
>
message
)
{
log
.
info
(
"接受到来自redis REFUND 的消息"
);
System
.
out
.
println
(
"message id "
+
message
.
getId
());
System
.
out
.
println
(
"stream "
+
message
.
getStream
());
System
.
out
.
println
(
"body "
+
message
.
getValue
());
}
}
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-dragon/src/main/java/com/liquidnet/service/consumer/dragon/service/receiver/RedisRefundReceiver.java
View file @
02c2ab15
...
...
@@ -61,7 +61,7 @@ public class RedisRefundReceiver implements StreamListener<String, MapRecord<Str
try
{
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"message"
,
msg
);
MapRecord
<
String
,
String
,
String
>
record
=
StreamRecords
.
mapBacked
(
map
).
withStreamKey
(
DragonConstant
.
m
ysqlRedisQueueEnum
.
DRAGON_REFUND_KEY
.
getCode
());
MapRecord
<
String
,
String
,
String
>
record
=
StreamRecords
.
mapBacked
(
map
).
withStreamKey
(
DragonConstant
.
M
ysqlRedisQueueEnum
.
DRAGON_REFUND_KEY
.
getCode
());
stringRedisTemplate
.
opsForStream
().
add
(
record
);
return
true
;
}
catch
(
Exception
e
)
{
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/alipay/config/AlipayConfigUtil.java
0 → 100644
View file @
02c2ab15
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
alipay
.
config
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
java.io.IOException
;
import
java.util.Properties
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: AlipayUtil
* @Package com.liquidnet.service.dragon.channel.alipay.config
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/9 15:20
*/
public
class
AlipayConfigUtil
{
private
static
final
Log
LOG
=
LogFactory
.
getLog
(
AlipayConfigUtil
.
class
);
/**
* 通过静态代码块读取上传文件的验证格式配置文件,静态代码块只执行一次(单例)
*/
private
static
Properties
properties
=
new
Properties
();
/**
* 私有构造方法
**/
private
AlipayConfigUtil
()
{
}
static
{
try
{
// 从类路径下读取属性文件
properties
.
load
(
AlipayConfigUtil
.
class
.
getClassLoader
()
.
getResourceAsStream
(
"alipay_config.properties"
));
}
catch
(
IOException
e
)
{
LOG
.
error
(
e
);
}
}
//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
// 合作身份者ID,签约账号,以2088开头由16位纯数字组成的字符串,查看地址:https://b.alipay.com/order/pidAndKey.htm
public
static
final
String
partner
=
(
String
)
properties
.
get
(
"partner"
);
// 收款支付宝账号,以2088开头由16位纯数字组成的字符串,一般情况下收款账号就是签约账号
public
static
final
String
seller_id
=
(
String
)
properties
.
get
(
"seller_id"
);
// MD5密钥,安全检验码,由数字和字母组成的32位字符串,查看地址:https://b.alipay.com/order/pidAndKey.htm
public
static
final
String
key
=
(
String
)
properties
.
get
(
"key"
);
// 服务器异步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问
public
static
final
String
notify_url
=
(
String
)
properties
.
get
(
"notify_url"
);
// 页面跳转同步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问
public
static
final
String
return_url
=
(
String
)
properties
.
get
(
"return_url"
);
// 签名方式
public
static
final
String
sign_type
=
(
String
)
properties
.
get
(
"sign_type"
);
// 调试用,创建TXT日志文件夹路径,见AlipayCore.java类中的logResult(String sWord)打印方法。
public
static
final
String
log_path
=
(
String
)
properties
.
get
(
"log_path"
);
// 字符编码格式 目前支持 gbk 或 utf-8
public
static
final
String
input_charset
=
(
String
)
properties
.
get
(
"input_charset"
);
// 支付类型 ,无需修改
public
static
final
String
payment_type
=
(
String
)
properties
.
get
(
"payment_type"
);
// 调用的接口名,无需修改
public
static
final
String
service
=
(
String
)
properties
.
get
(
"service"
);
//支付宝被扫地址
public
static
final
String
trade_pay_url
=
(
String
)
properties
.
get
(
"trade_pay_url"
);
//支付宝交易查询地址
public
static
final
String
trade_query_url
=
(
String
)
properties
.
get
(
"trade_query_url"
);
//app_id
public
static
final
String
app_id
=
(
String
)
properties
.
get
(
"app_id"
);
//商户私钥
public
static
final
String
mch_private_key
=
(
String
)
properties
.
get
(
"mch_private_key"
);
//支付宝公钥
public
static
final
String
ali_public_key
=
(
String
)
properties
.
get
(
"ali_public_key"
);
// 防钓鱼时间戳 若要使用请调用类文件submit中的query_timestamp函数
public
static
final
String
anti_phishing_key
=
""
;
// 客户端的IP地址 非局域网的外网IP地址,如:221.0.0.1
public
static
final
String
exter_invoke_ip
=
""
;
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/alipay/req/AlipayTradePayReq.java
0 → 100644
View file @
02c2ab15
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
alipay
.
req
;
import
com.alibaba.fastjson.JSON
;
import
lombok.Data
;
import
java.math.BigDecimal
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: AlipayTradePayReq
* @Package com.liquidnet.service.dragon.channel.alipay.req
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/9 17:50
*/
@Data
public
class
AlipayTradePayReq
{
private
String
productCode
;
private
BigDecimal
totalAmount
;
private
String
subject
;
private
String
body
;
private
String
outTradeNo
;
private
String
timeExpire
;
@Override
public
String
toString
(){
return
JSON
.
toJSONString
(
this
);
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/alipay/sign/MD5.java
0 → 100644
View file @
02c2ab15
/*
* Copyright 2015-2102 RonCoo(http://www.roncoo.com) Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
alipay
.
sign
;
import
org.apache.commons.codec.digest.DigestUtils
;
import
java.io.UnsupportedEncodingException
;
import
java.security.SignatureException
;
/**
* 签名加密MD%
*/
public
class
MD5
{
/**
* 签名字符串
* @param text 需要签名的字符串
* @param key 密钥
* @param input_charset 编码格式
* @return 签名结果
*/
public
static
String
sign
(
String
text
,
String
key
,
String
input_charset
)
{
text
=
text
+
key
;
return
DigestUtils
.
md5Hex
(
getContentBytes
(
text
,
input_charset
));
}
/**
* 签名字符串
* @param text 需要签名的字符串
* @param sign 签名结果
* @param key 密钥
* @param input_charset 编码格式
* @return 签名结果
*/
public
static
boolean
verify
(
String
text
,
String
sign
,
String
key
,
String
input_charset
)
{
text
=
text
+
key
;
String
mysign
=
DigestUtils
.
md5Hex
(
getContentBytes
(
text
,
input_charset
));
if
(
mysign
.
equals
(
sign
))
{
return
true
;
}
else
{
return
false
;
}
}
/**
* @param content
* @param charset
* @return
* @throws SignatureException
* @throws UnsupportedEncodingException
*/
private
static
byte
[]
getContentBytes
(
String
content
,
String
charset
)
{
if
(
charset
==
null
||
""
.
equals
(
charset
))
{
return
content
.
getBytes
();
}
try
{
return
content
.
getBytes
(
charset
);
}
catch
(
UnsupportedEncodingException
e
)
{
throw
new
RuntimeException
(
"MD5签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:"
+
charset
);
}
}
}
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/alipay/util/AlipayUtil.java
0 → 100644
View file @
02c2ab15
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
alipay
.
util
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: AlipayUtil
* @Package com.liquidnet.service.dragon.channel.alipay.util
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/9 15:20
*/
import
com.alibaba.fastjson.JSONObject
;
import
com.alipay.api.AlipayApiException
;
import
com.alipay.api.AlipayClient
;
import
com.alipay.api.DefaultAlipayClient
;
import
com.alipay.api.request.AlipayTradePagePayRequest
;
import
com.alipay.api.request.AlipayTradePayRequest
;
import
com.alipay.api.request.AlipayTradeQueryRequest
;
import
com.alipay.api.request.AlipayTradeWapPayRequest
;
import
com.alipay.api.response.AlipayTradePagePayResponse
;
import
com.alipay.api.response.AlipayTradePayResponse
;
import
com.alipay.api.response.AlipayTradeQueryResponse
;
import
com.alipay.api.response.AlipayTradeWapPayResponse
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.dragon.channel.alipay.config.AlipayConfigUtil
;
import
com.liquidnet.service.dragon.channel.alipay.req.AlipayTradePayReq
;
import
com.liquidnet.service.dragon.channel.alipay.sign.MD5
;
import
com.liquidnet.service.dragon.utils.PayAlipayUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.math.BigDecimal
;
import
java.util.*
;
@Slf4j
public
class
AlipayUtil
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AlipayUtil
.
class
);
private
AlipayUtil
()
{
}
/**
* 支付宝支付
* @param alipayTradePayReq
* @return
*/
public
static
Map
<
String
,
Object
>
tradePagePay
(
AlipayTradePayReq
alipayTradePayReq
)
{
logger
.
info
(
"AlipayUtil.tradePay-->> req : {}"
,
alipayTradePayReq
.
toString
());
String
timeExpress
=
"5m"
;
// 支付超时,线下扫码交易定义为5分钟
AlipayClient
alipayClient
=
PayAlipayUtils
.
getHttpClient
();
SortedMap
<
String
,
Object
>
paramMap
=
new
TreeMap
<>();
paramMap
.
put
(
"product_code"
,
alipayTradePayReq
.
getProductCode
());
paramMap
.
put
(
"total_amount"
,
alipayTradePayReq
.
getTotalAmount
().
toString
());
paramMap
.
put
(
"subject"
,
alipayTradePayReq
.
getSubject
());
paramMap
.
put
(
"body"
,
alipayTradePayReq
.
getBody
());
paramMap
.
put
(
"out_trade_no"
,
alipayTradePayReq
.
getOutTradeNo
());
paramMap
.
put
(
"timeout_express"
,
timeExpress
);
AlipayTradePagePayRequest
request
=
new
AlipayTradePagePayRequest
();
request
.
setNotifyUrl
(
"https://testpay.zhengzai.tv"
);
// request.setTimestamp(DateUtil.now());
logger
.
info
(
"bizContent :{}"
,
JSONObject
.
toJSONString
(
paramMap
));
request
.
setBizContent
(
JSONObject
.
toJSONString
(
paramMap
));
try
{
AlipayTradePagePayResponse
response
=
alipayClient
.
sdkExecute
(
request
);
JSONObject
responseJSON
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
response
));
logger
.
info
(
"支付宝返回结果:{}"
,
responseJSON
);
return
responseJSON
;
}
catch
(
AlipayApiException
e
)
{
logger
.
error
(
"支付宝支付异常:{}"
,
e
);
JSONObject
resultJSON
=
new
JSONObject
();
resultJSON
.
put
(
"outTradeNo"
,
alipayTradePayReq
.
getOutTradeNo
());
resultJSON
.
put
(
"totalAmount"
,
alipayTradePayReq
.
getTotalAmount
().
toString
());
resultJSON
.
put
(
"errorCode"
,
"9999"
);
return
resultJSON
;
}
}
/**
* 支付宝支付
* @param alipayTradePayReq
* @return
*/
public
static
Map
<
String
,
Object
>
tradeWapPay
(
AlipayTradePayReq
alipayTradePayReq
)
{
logger
.
info
(
"AlipayUtil.tradePay-->> req : {}"
,
alipayTradePayReq
.
toString
());
String
timeExpress
=
"5m"
;
// 支付超时,线下扫码交易定义为5分钟
AlipayClient
alipayClient
=
PayAlipayUtils
.
getHttpClient
();
SortedMap
<
String
,
Object
>
paramMap
=
new
TreeMap
<>();
paramMap
.
put
(
"product_code"
,
alipayTradePayReq
.
getProductCode
());
paramMap
.
put
(
"total_amount"
,
alipayTradePayReq
.
getTotalAmount
().
toString
());
paramMap
.
put
(
"subject"
,
alipayTradePayReq
.
getSubject
());
paramMap
.
put
(
"body"
,
alipayTradePayReq
.
getBody
());
paramMap
.
put
(
"out_trade_no"
,
alipayTradePayReq
.
getOutTradeNo
());
paramMap
.
put
(
"timeout_express"
,
timeExpress
);
AlipayTradeWapPayRequest
request
=
new
AlipayTradeWapPayRequest
();
request
.
setNotifyUrl
(
"https://testpay.zhengzai.tv"
);
// request.setTimestamp(DateUtil.now());
logger
.
info
(
"bizContent :{}"
,
JSONObject
.
toJSONString
(
paramMap
));
request
.
setBizContent
(
JSONObject
.
toJSONString
(
paramMap
));
try
{
AlipayTradeWapPayResponse
response
=
alipayClient
.
sdkExecute
(
request
);
if
(
response
.
isSuccess
()){
}
JSONObject
responseJSON
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
response
));
logger
.
info
(
"支付宝返回结果:{}"
,
responseJSON
);
return
responseJSON
;
}
catch
(
AlipayApiException
e
)
{
logger
.
error
(
"支付宝支付异常:{}"
,
e
);
JSONObject
resultJSON
=
new
JSONObject
();
resultJSON
.
put
(
"outTradeNo"
,
alipayTradePayReq
.
getOutTradeNo
());
resultJSON
.
put
(
"totalAmount"
,
alipayTradePayReq
.
getTotalAmount
().
toString
());
resultJSON
.
put
(
"errorCode"
,
"9999"
);
return
resultJSON
;
}
}
/**
* 订单查询
*
* @return
*/
public
static
Map
<
String
,
Object
>
tradeQuery
(
String
outTradeNo
)
{
logger
.
info
(
"======>支付宝交易查询"
);
String
charset
=
"UTF-8"
;
String
format
=
"json"
;
String
signType
=
"RSA2"
;
AlipayClient
alipayClient
=
new
DefaultAlipayClient
(
AlipayConfigUtil
.
trade_query_url
,
AlipayConfigUtil
.
app_id
,
AlipayConfigUtil
.
mch_private_key
,
format
,
charset
,
AlipayConfigUtil
.
ali_public_key
,
signType
);
SortedMap
<
String
,
Object
>
bizContentMap
=
new
TreeMap
<>();
bizContentMap
.
put
(
"out_trade_no"
,
outTradeNo
);
AlipayTradeQueryRequest
request
=
new
AlipayTradeQueryRequest
();
request
.
setBizContent
(
JSONObject
.
toJSONString
(
bizContentMap
));
try
{
AlipayTradeQueryResponse
response
=
alipayClient
.
execute
(
request
);
JSONObject
responseJSON
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
response
));
logger
.
info
(
"支付宝订单查询返回结果:{}"
,
responseJSON
);
return
responseJSON
;
}
catch
(
AlipayApiException
e
)
{
logger
.
error
(
"支付宝交易查询异常:{}"
,
e
);
return
null
;
}
}
private
static
String
getSign
(
SortedMap
<
String
,
String
>
paramMap
,
String
key
)
{
StringBuilder
signBuilder
=
new
StringBuilder
();
for
(
Map
.
Entry
<
String
,
String
>
entry
:
paramMap
.
entrySet
())
{
if
(!
"sign"
.
equals
(
entry
.
getKey
())
&&
!
"sign_type"
.
equals
(
entry
.
getKey
())
&&
!
StringUtil
.
isEmpty
(
entry
.
getValue
()))
{
signBuilder
.
append
(
entry
.
getKey
()).
append
(
"="
).
append
(
entry
.
getValue
()).
append
(
"&"
);
}
}
return
MD5
.
sign
(
signBuilder
.
substring
(
0
,
signBuilder
.
length
()
-
1
),
key
,
"UTF-8"
);
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/util/WepayUtil.java
0 → 100644
View file @
02c2ab15
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
wepay
.
util
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: WepayUtil
* @Package com.liquidnet.service.dragon.channel.wepay.util
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/9 15:20
*/
public
class
WepayUtil
{
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/controller/PayController.java
View file @
02c2ab15
This diff is collapsed.
Click to expand it.
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/service/impl/DragonOrderRefundsServiceImpl.java
View file @
02c2ab15
...
...
@@ -132,7 +132,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
if
(
response
.
getFundChange
().
equals
(
"N"
)
||
response
.
getFundChange
()
==
null
)
{
try
{
String
refundError
=
""
;
refundStatus
=
DragonConstant
.
r
efundStatusEnum
.
STATUS_ERROR
.
getCode
();
refundStatus
=
DragonConstant
.
R
efundStatusEnum
.
STATUS_ERROR
.
getCode
();
if
(
null
==
response
.
getSubMsg
())
{
refundError
=
"退款失败,原因未知"
;
}
else
{
...
...
@@ -170,10 +170,10 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
try
{
String
refundAt
=
""
;
if
(
response
.
getFundChange
().
equals
(
"Y"
))
{
refundStatus
=
DragonConstant
.
r
efundStatusEnum
.
STATUS_REFUNDED
.
getCode
();
refundStatus
=
DragonConstant
.
R
efundStatusEnum
.
STATUS_REFUNDED
.
getCode
();
refundAt
=
DateUtil
.
format
(
response
.
getGmtRefundPay
(),
DateUtil
.
Formatter
.
yyyyMMddHHmmss
);
}
else
{
refundStatus
=
DragonConstant
.
r
efundStatusEnum
.
STATUS_REFUNDING
.
getCode
();
refundStatus
=
DragonConstant
.
R
efundStatusEnum
.
STATUS_REFUNDING
.
getCode
();
}
sendMySqlRedis
(
SqlMapping
.
get
(
"dragon_order_refund_success.update"
),
...
...
@@ -220,7 +220,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"message"
,
sqlData
);
MapRecord
<
String
,
String
,
String
>
record
=
StreamRecords
.
mapBacked
(
map
).
withStreamKey
(
DragonConstant
.
m
ysqlRedisQueueEnum
.
DRAGON_REFUND_KEY
.
getCode
());
MapRecord
<
String
,
String
,
String
>
record
=
StreamRecords
.
mapBacked
(
map
).
withStreamKey
(
DragonConstant
.
M
ysqlRedisQueueEnum
.
DRAGON_REFUND_KEY
.
getCode
());
stringRedisTemplate
.
opsForStream
().
add
(
record
);
return
true
;
}
catch
(
Exception
e
)
{
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/service/impl/DragonOrdersServiceImpl.java
View file @
02c2ab15
package
com
.
liquidnet
.
service
.
dragon
.
service
.
impl
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.dragon.channel.alipay.req.AlipayTradePayReq
;
import
com.liquidnet.service.dragon.channel.alipay.util.AlipayUtil
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.entity.DragonOrders
;
import
com.liquidnet.service.dragon.service.IDragonOrdersService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.connection.stream.MapRecord
;
import
org.springframework.data.redis.connection.stream.StreamRecords
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Service
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.Map
;
@Service
public
class
DragonOrdersServiceImpl
implements
IDragonOrdersService
{
@Autowired
StringRedisTemplate
stringRedisTemplate
;
@Value
(
"liquidnet.dragon.alipay-gataway-url"
)
private
String
alipayGatewayUrl
;
@Override
public
void
sendRedisQueue
()
{
...
...
@@ -25,4 +40,83 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
e
.
printStackTrace
();
}
}
@Override
public
ResponseDto
<
DragonPayBaseRespDto
>
alipay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
AlipayTradePayReq
alipayTradePayReq
=
new
AlipayTradePayReq
();
alipayTradePayReq
.
setProductCode
(
"QUICK_WAP_PAY"
);
alipayTradePayReq
.
setTotalAmount
(
dragonPayBaseReqDto
.
getPrice
());
alipayTradePayReq
.
setSubject
(
dragonPayBaseReqDto
.
getName
());
alipayTradePayReq
.
setBody
(
dragonPayBaseReqDto
.
getDetail
());
//dragon中支付编号
alipayTradePayReq
.
setOutTradeNo
(
IDGenerator
.
payCode
());
alipayTradePayReq
.
setTimeExpire
(
dragonPayBaseReqDto
.
getExpireTime
());
Map
<
String
,
Object
>
result
=
AlipayUtil
.
tradeWapPay
(
alipayTradePayReq
);
DragonPayBaseRespDto
respDto
=
new
DragonPayBaseRespDto
();
respDto
.
setCode
(
alipayTradePayReq
.
getOutTradeNo
());
respDto
.
setOrder_code
(
dragonPayBaseReqDto
.
getOrderCode
());
DragonPayBaseRespDto
.
PayData
payData
=
new
DragonPayBaseRespDto
.
PayData
();
payData
.
setRedirectUrl
(
alipayGatewayUrl
+
result
.
get
(
"body"
));
respDto
.
setPay_data
(
payData
);
//支付订单持久化
this
.
buildPayOrders
(
dragonPayBaseReqDto
,
respDto
);
return
ResponseDto
.
success
(
respDto
);
}
private
DragonOrders
buildPayOrders
(
DragonPayBaseReqDto
dragonPayBaseReqDto
,
DragonPayBaseRespDto
respDto
){
DragonOrders
orders
=
new
DragonOrders
();
// orders.setMid();
orders
.
setStatus
(
Integer
.
valueOf
(
DragonConstant
.
PayStatusEnum
.
STATUS_UNPAID
.
getCode
()));
orders
.
setCode
(
respDto
.
getCode
());
orders
.
setType
(
dragonPayBaseReqDto
.
getType
());
orders
.
setPrice
(
dragonPayBaseReqDto
.
getPrice
());
orders
.
setName
(
dragonPayBaseReqDto
.
getName
());
orders
.
setDetail
(
dragonPayBaseReqDto
.
getDetail
());
orders
.
setOrderCode
(
dragonPayBaseReqDto
.
getOrderCode
());
orders
.
setClientIp
(
dragonPayBaseReqDto
.
getClientIp
());
orders
.
setNotifyUrl
(
dragonPayBaseReqDto
.
getNotifyUrl
());
orders
.
setPaymentType
(
DragonConstant
.
PayTypeEnum
.
PAYMENT_TYPE_APP_IAP
.
getCode
());
// orders.setPaymentId();
orders
.
setPaymentAt
(
LocalDateTime
.
now
());
// orders.setFinishedAt();
orders
.
setCreatedAt
(
LocalDateTime
.
now
());
// orders.setUpdatedAt();
// 修改退款订单
boolean
insertResult
=
sendMySqlRedis
(
SqlMapping
.
get
(
"dragon_orders.insert"
),
new
Object
[]{
orders
.
getStatus
(),
orders
.
getCode
(),
orders
.
getType
()
,
orders
.
getPrice
(),
orders
.
getName
(),
orders
.
getDetail
()
,
orders
.
getOrderCode
(),
orders
.
getClientIp
()
,
orders
.
getNotifyUrl
(),
orders
.
getPaymentType
(),
orders
.
getPaymentId
(),
orders
.
getPaymentAt
()
,
orders
.
getFinishedAt
(),
orders
.
getCreatedAt
()
,
orders
.
getUpdatedAt
()}
);
return
orders
;
}
/**
* 给 REDIS 队列发送消息 数据库相关
*
* @param sql sql语句
* @param data 需要操作的数据
* @return
*/
private
boolean
sendMySqlRedis
(
String
sql
,
Object
[]
data
)
{
try
{
LinkedList
<
String
>
sqls
=
new
LinkedList
<>();
sqls
.
add
(
sql
);
LinkedList
<
Object
[]>
sqlsData
=
new
LinkedList
();
sqlsData
.
add
(
data
);
String
sqlData
=
SqlMapping
.
gets
(
sqls
,
sqlsData
);
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"message"
,
sqlData
);
MapRecord
<
String
,
String
,
String
>
record
=
StreamRecords
.
mapBacked
(
map
).
withStreamKey
(
DragonConstant
.
MysqlRedisQueueEnum
.
DRAGON_PAY_KEY
.
getCode
());
stringRedisTemplate
.
opsForStream
().
add
(
record
);
return
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/utils/PayAlipayUtils.java
View file @
02c2ab15
...
...
@@ -21,18 +21,17 @@ import java.net.URL;
import
java.security.PrivateKey
;
public
class
PayAlipayUtils
{
private
static
AlipayClient
httpClient
;
private
static
AlipayClient
httpClient
=
null
;
private
static
PayAlipayUtils
instance
=
new
PayAlipayUtils
();
private
String
appId
=
"2019082866535131"
;
private
String
merchant_pub_key
=
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmePaETscydypY3rV4mXa8MtcQIL5zjP1KxdusNkHpePeU61hAZxKn0Z8pDB1wNaTK72wgEWaORXeRp4YTbf4usHlW562Pe5wdiSutb3iT6EMJ5eBD4HLI9wWDgYBtwfHwS5JJFhf0eptP4R1XluLiMhmMynLwJvHepgkVrS3mN+jmoPRmKFhZHGIYDoWypBMbUKiFHWiToHK1n0NYHHIi4WgK2wt4Wj7nexQGD69W7ofRCirYmz35c/cNFUA1lqzOEKu2z7PpjA6jQV2GJolnJ4xXPJ8Dpgp4g/dgsGqRydlmFqZD71i/pDDpF0RfRKHL+WhWVhI1hqe6jLtvJE+zQIDAQAB"
;
private
String
merchant_private_key
=
"MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCArhnBTpcAww8wSYBTwGp6oBvenzCCYFrugERgxJDZ7YnBZ3ZdiAaHjJ9PI0WymkpDr27FSg9czVbiH7G91zPq+8s9onrZi/l6cBZ2VjrwQ9BQPN2a8zHy8D6BfoKEV+PIicGz6hNPA7lgf04NgsXeWjeXnYD/IBTLZmnCxB2sPYo/0EN32mlSG9snO63HlPkoqn8ycw71a1cBrlQ+Y22fFnJAk/vrGoou8E0UHfL5zVE/up+ToOYW/eOKMFL/DSceCy32t9Za0RmpV3i2E9s8gBDewzT10Yf4+4mPUiTR6AhcLjqafAy2IaKPK57WZ6cGF9cGs9yq8bSTRpeNC4alAgMBAAECggEAH0Ms+qvPP94j6IVS6gYLWHNhkfp23JXwQZVkB2Z6EpgFKbmrJhoQDAp8Acv9+OBHPp52ePP/O3qfqxwsIIUSFfrKa9T3p7a8C6UDsAhPFWRETdobtLN05SK87NUBfImly2i8aKtruXycIveKzPmCfPzKGMmpN1Jh+vCMrUbcNqX8OUcxmhGvJwnQuBW4QEiepzl89Nl91iSwFmxaZoqLaB9lYUKke/z7FDHTpTWpZvtvxlZ0gvMVNLVp9NBNazolQ8eEjBG2PsQGD2cLUbM33mLTz+/VQjzZR3KXu5kQR9MloURILDsdxE1AyA4AkIXd4eMszEjA4Dv6CQK/jjrsgQKBgQDIiCt1OGmV2sqDBSn4nZNH7BzY3Hdnf+qsYUi+TXKhnQaT8XPKWZpKE/AcqsIKnANmO4sX0NL7ACBe7Rl1RcU9Mq5XuHhnkveFBVRRIHindzUfEN0WgdLy23qmJ2N+1i4FigelY0E5T2lojVb7wycAgAc6vflwE+eYf8W3968q0QKBgQCkRgsVCWWNMSLZeB0V9LV3Om2/UPWY/ovadTxAQtxg0Z75V6Wdu8u0hrYaPSeUK2ryaoE6HKgp7U8NiJGzgm2wpj7D2ysrPmhX5+CjiWkDMCuvWytVT7hLqhhLp7frZT39u8VhyfC8lE0xA67gAPsGSl1sBoZPwvvsmNAQ/h6rlQKBgQCtCtw9be2m88M3JnieYhOax8Po2u5qsLZoBBcKqLhXf7ISbhPWNFXwwJ29jxicoR5J1O3lIj09fVFxuLX0Pb3DXn2VksjLz8Wp0vx8eUHEeRis8xdleaf4C68du/WemOHjw8VvUWQSOVWjc/vwiumYA+K5LQAXWAXM0c1jP+e3UQKBgEWY/1z8TDATn0Yvo3MH6FIJSTIDJOqa/bmibdJ0AVZruUS+o4Y+aEGlyUU4n6og8wCdqv5p4b1Rs2pyb/hzy/FJndHw60s495A2x2/B6eHV6Mw0fhl42wYDnKOA/WUX0bnMcgXKPtpGoqWff9mb0L6LhyUbZpAodf95hr2MTIY5AoGBAIyPtYP6jRyR980h/Ud1MS0fBxymjQrR+kg3GWjnw0ZJJ8yFEXxDqLV8uLyXQKc89HGbI0cClWgZBTjfIPJ5U4Gl19Xlwx1SFrdgg5mGUqnMARTg7w1TG5QLSqNhZo2jgBM5FCJRbDUCO/MzLcFhTeGNva9yP7E7gW5/Dott9D7d"
;
private
String
sign_type
=
"RSA2"
;
private
String
charset
=
"utf-8"
;
private
String
gatewayUrl
=
"https://openapi.alipay.com/gateway.do"
;
private
static
String
appId
=
"2019082866535131"
;
private
static
String
merchant_pub_key
=
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmePaETscydypY3rV4mXa8MtcQIL5zjP1KxdusNkHpePeU61hAZxKn0Z8pDB1wNaTK72wgEWaORXeRp4YTbf4usHlW562Pe5wdiSutb3iT6EMJ5eBD4HLI9wWDgYBtwfHwS5JJFhf0eptP4R1XluLiMhmMynLwJvHepgkVrS3mN+jmoPRmKFhZHGIYDoWypBMbUKiFHWiToHK1n0NYHHIi4WgK2wt4Wj7nexQGD69W7ofRCirYmz35c/cNFUA1lqzOEKu2z7PpjA6jQV2GJolnJ4xXPJ8Dpgp4g/dgsGqRydlmFqZD71i/pDDpF0RfRKHL+WhWVhI1hqe6jLtvJE+zQIDAQAB"
;
private
static
String
merchant_private_key
=
"MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCArhnBTpcAww8wSYBTwGp6oBvenzCCYFrugERgxJDZ7YnBZ3ZdiAaHjJ9PI0WymkpDr27FSg9czVbiH7G91zPq+8s9onrZi/l6cBZ2VjrwQ9BQPN2a8zHy8D6BfoKEV+PIicGz6hNPA7lgf04NgsXeWjeXnYD/IBTLZmnCxB2sPYo/0EN32mlSG9snO63HlPkoqn8ycw71a1cBrlQ+Y22fFnJAk/vrGoou8E0UHfL5zVE/up+ToOYW/eOKMFL/DSceCy32t9Za0RmpV3i2E9s8gBDewzT10Yf4+4mPUiTR6AhcLjqafAy2IaKPK57WZ6cGF9cGs9yq8bSTRpeNC4alAgMBAAECggEAH0Ms+qvPP94j6IVS6gYLWHNhkfp23JXwQZVkB2Z6EpgFKbmrJhoQDAp8Acv9+OBHPp52ePP/O3qfqxwsIIUSFfrKa9T3p7a8C6UDsAhPFWRETdobtLN05SK87NUBfImly2i8aKtruXycIveKzPmCfPzKGMmpN1Jh+vCMrUbcNqX8OUcxmhGvJwnQuBW4QEiepzl89Nl91iSwFmxaZoqLaB9lYUKke/z7FDHTpTWpZvtvxlZ0gvMVNLVp9NBNazolQ8eEjBG2PsQGD2cLUbM33mLTz+/VQjzZR3KXu5kQR9MloURILDsdxE1AyA4AkIXd4eMszEjA4Dv6CQK/jjrsgQKBgQDIiCt1OGmV2sqDBSn4nZNH7BzY3Hdnf+qsYUi+TXKhnQaT8XPKWZpKE/AcqsIKnANmO4sX0NL7ACBe7Rl1RcU9Mq5XuHhnkveFBVRRIHindzUfEN0WgdLy23qmJ2N+1i4FigelY0E5T2lojVb7wycAgAc6vflwE+eYf8W3968q0QKBgQCkRgsVCWWNMSLZeB0V9LV3Om2/UPWY/ovadTxAQtxg0Z75V6Wdu8u0hrYaPSeUK2ryaoE6HKgp7U8NiJGzgm2wpj7D2ysrPmhX5+CjiWkDMCuvWytVT7hLqhhLp7frZT39u8VhyfC8lE0xA67gAPsGSl1sBoZPwvvsmNAQ/h6rlQKBgQCtCtw9be2m88M3JnieYhOax8Po2u5qsLZoBBcKqLhXf7ISbhPWNFXwwJ29jxicoR5J1O3lIj09fVFxuLX0Pb3DXn2VksjLz8Wp0vx8eUHEeRis8xdleaf4C68du/WemOHjw8VvUWQSOVWjc/vwiumYA+K5LQAXWAXM0c1jP+e3UQKBgEWY/1z8TDATn0Yvo3MH6FIJSTIDJOqa/bmibdJ0AVZruUS+o4Y+aEGlyUU4n6og8wCdqv5p4b1Rs2pyb/hzy/FJndHw60s495A2x2/B6eHV6Mw0fhl42wYDnKOA/WUX0bnMcgXKPtpGoqWff9mb0L6LhyUbZpAodf95hr2MTIY5AoGBAIyPtYP6jRyR980h/Ud1MS0fBxymjQrR+kg3GWjnw0ZJJ8yFEXxDqLV8uLyXQKc89HGbI0cClWgZBTjfIPJ5U4Gl19Xlwx1SFrdgg5mGUqnMARTg7w1TG5QLSqNhZo2jgBM5FCJRbDUCO/MzLcFhTeGNva9yP7E7gW5/Dott9D7d"
;
private
static
String
sign_type
=
"RSA2"
;
private
static
String
charset
=
"utf-8"
;
private
static
String
gatewayUrl
=
"https://openapi.alipay.com/gateway.do"
;
public
PayAlipayUtils
()
{
httpClient
=
new
DefaultAlipayClient
(
gatewayUrl
,
appId
,
merchant_private_key
,
"json"
,
charset
,
merchant_pub_key
,
sign_type
);
}
private
static
PayAlipayUtils
getInstance
()
{
...
...
@@ -40,6 +39,10 @@ public class PayAlipayUtils {
}
public
static
AlipayClient
getHttpClient
()
{
if
(
httpClient
==
null
){
httpClient
=
new
DefaultAlipayClient
(
gatewayUrl
,
appId
,
merchant_private_key
,
"json"
,
charset
,
merchant_pub_key
,
sign_type
);
}
return
httpClient
;
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/resources/sqlmap.properties
View file @
02c2ab15
...
...
@@ -5,3 +5,8 @@ dragon_order_refund_error.update=UPDATE `dragon_order_refunds` SET updated_at =
dragon_order_refund_success.update
=
UPDATE `dragon_order_refunds` SET updated_at = ? , refund_at=? , status=? WHERE order_refund_id = ?
# ------------------------创建退款订单日志----------------------------
dragon_order_refund_log.insert
=
INSERT INTO `dragon_order_refunds`(`order_refund_id` ,`refund_type` ,`content`,`created_at`,`updated_at`)VALUES(?,?,?,?,?);
dragon_orders.insert
=
INSERT INTO DRAGON_ORDERS (ID, STATUS, CODE, TYPE, PRICE, NAME, DETAIL, ORDER_CODE, CLIENT_IP, NOTIFY_URL, PAYMENT_TYPE,PAYMENT_ID, PAYMENT_AT, FINISHED_AT, CREATED_AT, UPDATED_AT, DELETED_AT)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
dragon_order_logs.insert
=
INSERT INTO DRAGON_ORDER_LOGS (ID, ORDER_ID, PAYMENT_TYPE, CONTENT, CREATED_AT, UPDATED_AT, DELETED_AT) VALUES(?,?,?,?,?,?,?)
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