记得上下班打卡 | 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
9687411d
Commit
9687411d
authored
Jul 14, 2021
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交支付查询
parent
3dbc5b28
Changes
33
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
817 additions
and
805 deletions
+817
-805
DragonConstant.java
...com/liquidnet/service/dragon/constant/DragonConstant.java
+2
-0
DragonErrorCodeEnum.java
...iquidnet/service/dragon/constant/DragonErrorCodeEnum.java
+43
-0
PayNotifyDto.java
...n/java/com/liquidnet/service/dragon/dto/PayNotifyDto.java
+16
-0
IDragonOrdersService.java
...iquidnet/service/dragon/service/IDragonOrdersService.java
+5
-0
liquidnet-service-dragon-dev.yml
...-config/liquidnet-config/liquidnet-service-dragon-dev.yml
+1
-1
liquidnet-service-dragon-test.yml
...config/liquidnet-config/liquidnet-service-dragon-test.yml
+2
-3
DragonOrderLogsDto.java
.../com/liquidnet/service/dragon/dto/DragonOrderLogsDto.java
+43
-0
DragonOrdersDto.java
...ava/com/liquidnet/service/dragon/dto/DragonOrdersDto.java
+106
-0
AlipayBiz.java
...iquidnet/service/dragon/channel/alipay/biz/AlipayBiz.java
+152
-0
AlipayConfigUtil.java
...ervice/dragon/channel/alipay/config/AlipayConfigUtil.java
+0
-98
AlipayConstant.java
...ervice/dragon/channel/alipay/constant/AlipayConstant.java
+33
-0
AlipayStrategyAppImpl.java
...n/channel/alipay/strategy/impl/AlipayStrategyAppImpl.java
+5
-2
AlipayStrategyWapImpl.java
...n/channel/alipay/strategy/impl/AlipayStrategyWapImpl.java
+5
-2
AlipayUtil.java
...uidnet/service/dragon/channel/alipay/util/AlipayUtil.java
+0
-169
IPayChannelStrategy.java
.../service/dragon/channel/strategy/IPayChannelStrategy.java
+3
-0
PayChannelStrategyAlipayImpl.java
...n/channel/strategy/impl/PayChannelStrategyAlipayImpl.java
+114
-2
PayChannelStrategyApplepayImpl.java
...channel/strategy/impl/PayChannelStrategyApplepayImpl.java
+6
-0
PayChannelStrategyWepayImpl.java
...on/channel/strategy/impl/PayChannelStrategyWepayImpl.java
+66
-0
WepayBiz.java
.../liquidnet/service/dragon/channel/wepay/biz/WepayBiz.java
+49
-20
WeixinConfigUtil.java
...service/dragon/channel/wepay/config/WeixinConfigUtil.java
+0
-82
WepayConstant.java
.../service/dragon/channel/wepay/constant/WepayConstant.java
+28
-0
WepayOrderQueryRespDto.java
...ice/dragon/channel/wepay/resp/WepayOrderQueryRespDto.java
+16
-0
IWepayStrategy.java
...service/dragon/channel/wepay/strategy/IWepayStrategy.java
+3
-0
AbstractWepayStrategy.java
...on/channel/wepay/strategy/impl/AbstractWepayStrategy.java
+19
-4
WepayStrategyAppImpl.java
...gon/channel/wepay/strategy/impl/WepayStrategyAppImpl.java
+5
-0
WepayStrategyAppletImpl.java
.../channel/wepay/strategy/impl/WepayStrategyAppletImpl.java
+5
-0
WepayStrategyJsImpl.java
...agon/channel/wepay/strategy/impl/WepayStrategyJsImpl.java
+5
-0
WepayStrategyWapImpl.java
...gon/channel/wepay/strategy/impl/WepayStrategyWapImpl.java
+5
-0
MD5Util.java
.../liquidnet/service/dragon/channel/wepay/util/MD5Util.java
+0
-70
WepayUtil.java
...iquidnet/service/dragon/channel/wepay/util/WepayUtil.java
+0
-349
DragonOrdersServiceImpl.java
.../service/dragon/service/impl/DragonOrdersServiceImpl.java
+11
-0
DataUtils.java
...in/java/com/liquidnet/service/dragon/utils/DataUtils.java
+42
-0
PayWepayUtils.java
...ava/com/liquidnet/service/dragon/utils/PayWepayUtils.java
+27
-3
No files found.
liquidnet-bus-api/liquidnet-service-dragon-api/src/main/java/com/liquidnet/service/dragon/constant/DragonConstant.java
View file @
9687411d
...
@@ -17,6 +17,8 @@ public class DragonConstant {
...
@@ -17,6 +17,8 @@ public class DragonConstant {
public
static
final
String
REFUND_REDIS_KET
=
"dragon:refund:refundCode:"
;
// 订单号对应回调地址
public
static
final
String
REFUND_REDIS_KET
=
"dragon:refund:refundCode:"
;
// 订单号对应回调地址
public
static
final
String
REDIS_KET_PAY_ORDERCODE
=
"dragon:pay:orderCode:"
;
// 订单编号
public
static
final
String
REDIS_KET_PAY_CODE
=
"dragon:pay:code:"
;
// 支付流水号
public
enum
PayChannelEnum
{
public
enum
PayChannelEnum
{
ALIPAY
(
"alipay"
,
"支付宝"
),
ALIPAY
(
"alipay"
,
"支付宝"
),
...
...
liquidnet-bus-api/liquidnet-service-dragon-api/src/main/java/com/liquidnet/service/dragon/constant/DragonErrorCodeEnum.java
0 → 100644
View file @
9687411d
package
com
.
liquidnet
.
service
.
dragon
.
constant
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: DragonErrorCodeEnum
* @Package com.liquidnet.service.dragon.constant
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/13 20:25
*/
public
enum
DragonErrorCodeEnum
{
TRADE_PAY_WAY_ERROR
(
"PAY0010001"
,
"错误的支付方式"
),
TRADE_WEIXIN_ERROR
(
"PAY0010002"
,
"微信异常"
),
TRADE_ORDER_ERROR
(
"PAY0010003"
,
"错误的支付方式"
),
TRADE_ORDER_STATUS_NOT_SUCCESS
(
"PAY0010004"
,
"交易不成功"
),
TRADE_ALIPAY_ERROR
(
"PAY0010005"
,
"支付宝异常"
),
TRADE_PARAM_ERROR
(
"PAY0010006"
,
"支付参数异常"
),
TRADE_ERROR_NOT_EXISTS
(
"PAY0010007"
,
"订单不存在!"
),
TRADE_ERROR_HAS_PAID
(
"PAY0010008"
,
"订单已经支付成功!"
),
TRADE_ALIPAY_SIGN_ERROR
(
"PAY0010009"
,
"支付宝签名异常!"
),
TRADE_WEPAY_SIGN_ERROR
(
"PAY0020001"
,
"微信签名异常!"
);
private
String
code
;
private
String
message
;
DragonErrorCodeEnum
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getMessage
()
{
return
message
;
}
}
liquidnet-bus-api/liquidnet-service-dragon-api/src/main/java/com/liquidnet/service/dragon/dto/PayNotifyDto.java
0 → 100644
View file @
9687411d
package
com
.
liquidnet
.
service
.
dragon
.
dto
;
import
lombok.Data
;
import
java.math.BigDecimal
;
@Data
public
class
PayNotifyDto
{
private
Integer
status
;
private
String
type
;
private
String
code
;
private
String
paymentId
;
private
String
orderCode
;
private
BigDecimal
price
;
private
String
paymentType
;
}
liquidnet-bus-api/liquidnet-service-dragon-api/src/main/java/com/liquidnet/service/dragon/service/IDragonOrdersService.java
View file @
9687411d
...
@@ -3,6 +3,7 @@ package com.liquidnet.service.dragon.service;
...
@@ -3,6 +3,7 @@ package com.liquidnet.service.dragon.service;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -12,4 +13,8 @@ public interface IDragonOrdersService {
...
@@ -12,4 +13,8 @@ public interface IDragonOrdersService {
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
);
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
);
void
dragonNotify
(
HttpServletRequest
request
,
String
payType
,
String
deviceFrom
);
void
dragonNotify
(
HttpServletRequest
request
,
String
payType
,
String
deviceFrom
);
DragonPayOrderQueryRespDto
checkOrderStatusByCode
(
String
code
);
DragonPayOrderQueryRespDto
checkOrderStatusByOrderCode
(
String
orderCode
);
}
}
liquidnet-bus-config/liquidnet-config/liquidnet-service-dragon-dev.yml
View file @
9687411d
...
@@ -30,5 +30,5 @@ liquidnet:
...
@@ -30,5 +30,5 @@ liquidnet:
gataway-url
:
https://openapi.alipay.com/gateway.do
gataway-url
:
https://openapi.alipay.com/gateway.do
merchantId
:
1551961491
merchantId
:
1551961491
appId
:
wx3498304dda39c5a1
appId
:
wx3498304dda39c5a1
par
ent
Key
:
itIuO65O9yKmemOu3S8g1S4orqvCGwXK
par
tner
Key
:
itIuO65O9yKmemOu3S8g1S4orqvCGwXK
liquidnet-bus-config/liquidnet-config/liquidnet-service-dragon-test.yml
View file @
9687411d
...
@@ -23,12 +23,11 @@ liquidnet:
...
@@ -23,12 +23,11 @@ liquidnet:
sslEnabled
:
false
sslEnabled
:
false
database
:
test_ln_scene
database
:
test_ln_scene
dragon
:
dragon
:
url
:
https://testdragon.zhengzai.tv/dragon
alipay
:
alipay
:
gataway-url
:
https://openapi.alipay.com/gateway.do
gataway-url
:
https://openapi.alipay.com/gateway.do
notify-url
:
https://testdragon.zhengzai.tv/dragon/notify/alipay
wepay
:
wepay
:
gataway-url
:
https://openapi.alipay.com/gateway.do
gataway-url
:
https://openapi.alipay.com/gateway.do
notify-url
:
https://testdragon.zhengzai.tv/dragon/notify/wepay
merchantId
:
1551961491
merchantId
:
1551961491
appId
:
wx3498304dda39c5a1
appId
:
wx3498304dda39c5a1
parentKey
:
itIuO65O9yKmemOu3S8g1S4orqvCGwXK
partnerKey
:
itIuO65O9yKmemOu3S8g1S4orqvCGwXK
\ No newline at end of file
\ No newline at end of file
liquidnet-bus-do/liquidnet-service-dragon-do/src/main/java/com/liquidnet/service/dragon/dto/DragonOrderLogsDto.java
0 → 100644
View file @
9687411d
package
com
.
liquidnet
.
service
.
dragon
.
dto
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
DragonOrderLogsDto
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@TableId
(
value
=
"mid"
,
type
=
IdType
.
AUTO
)
private
Long
mid
;
/**
* order_id
*/
private
String
orderId
;
/**
* payment_type
*/
private
String
paymentType
;
/**
* content
*/
private
String
content
;
/**
* created_at
*/
private
LocalDateTime
createdAt
;
/**
* updated_at
*/
private
LocalDateTime
updatedAt
;
}
liquidnet-bus-do/liquidnet-service-dragon-do/src/main/java/com/liquidnet/service/dragon/dto/DragonOrdersDto.java
0 → 100644
View file @
9687411d
package
com
.
liquidnet
.
service
.
dragon
.
dto
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: DragonOrdersDto
* @Package com.liquidnet.service.dragon.dto
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/13 19:36
*/
@Data
public
class
DragonOrdersDto
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@TableId
(
value
=
"mid"
,
type
=
IdType
.
AUTO
)
private
Long
mid
;
/**
* status
*/
private
Integer
status
;
/**
* code
*/
private
String
code
;
/**
* type
*/
private
String
type
;
/**
* price
*/
private
BigDecimal
price
;
/**
* name
*/
private
String
name
;
/**
* detail
*/
private
String
detail
;
/**
* order_code
*/
private
String
orderCode
;
/**
* client_ip
*/
private
String
clientIp
;
/**
* notify_url
*/
private
String
notifyUrl
;
/**
* payment_type
*/
private
String
paymentType
;
/**
* payment_id
*/
private
String
paymentId
;
/**
* payment_at
*/
private
LocalDateTime
paymentAt
;
/**
* finished_at
*/
private
LocalDateTime
finishedAt
;
/**
* created_at
*/
private
LocalDateTime
createdAt
;
/**
* updated_at
*/
private
LocalDateTime
updatedAt
;
/**
* deleted_at
*/
private
LocalDateTime
deletedAt
;
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/alipay/biz/AlipayBiz.java
View file @
9687411d
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
alipay
.
biz
;
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
alipay
.
biz
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alipay.api.AlipayApiException
;
import
com.alipay.api.AlipayClient
;
import
com.alipay.api.request.AlipayTradeAppPayRequest
;
import
com.alipay.api.request.AlipayTradeQueryRequest
;
import
com.alipay.api.request.AlipayTradeWapPayRequest
;
import
com.alipay.api.response.AlipayTradeAppPayResponse
;
import
com.alipay.api.response.AlipayTradeQueryResponse
;
import
com.alipay.api.response.AlipayTradeWapPayResponse
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.dragon.channel.alipay.req.AlipayTradePayReq
;
import
com.liquidnet.service.dragon.channel.alipay.sign.MD5
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.entity.DragonOrders
;
import
com.liquidnet.service.dragon.entity.DragonOrders
;
import
com.liquidnet.service.dragon.utils.MqHandleUtil
;
import
com.liquidnet.service.dragon.utils.MqHandleUtil
;
import
com.liquidnet.service.dragon.utils.PayAlipayUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.*
;
/**
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @author AnJiabin <anjiabin@zhengzai.tv>
...
@@ -20,6 +35,7 @@ import java.time.LocalDateTime;
...
@@ -20,6 +35,7 @@ import java.time.LocalDateTime;
* @Copyright: LightNet @ Copyright (c) 2021
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/10 16:21
* @date 2021/7/10 16:21
*/
*/
@Slf4j
@Component
@Component
public
class
AlipayBiz
{
public
class
AlipayBiz
{
@Autowired
@Autowired
...
@@ -56,4 +72,140 @@ public class AlipayBiz {
...
@@ -56,4 +72,140 @@ public class AlipayBiz {
);
);
return
orders
;
return
orders
;
}
}
/**
* 支付宝支付
* @param alipayTradePayReq
* @return
*/
public
static
Map
<
String
,
Object
>
tradeWapPay
(
AlipayTradePayReq
alipayTradePayReq
)
{
log
.
info
(
"AlipayUtil.tradeWapPay-->> req : {}"
,
alipayTradePayReq
.
toString
());
String
timeExpress
=
"5m"
;
// 支付超时,线下扫码交易定义为5分钟
AlipayClient
alipayClient
=
PayAlipayUtils
.
getInstance
().
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
(
alipayTradePayReq
.
getNotifyUrl
());
// request.setTimestamp(DateUtil.now());
log
.
info
(
"bizContent :{}"
,
JSONObject
.
toJSONString
(
paramMap
));
request
.
setBizContent
(
JSONObject
.
toJSONString
(
paramMap
));
try
{
AlipayTradeWapPayResponse
response
=
alipayClient
.
sdkExecute
(
request
);
JSONObject
responseJSON
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
response
));
log
.
info
(
"AlipayUtil-->tradeWapPay-->支付宝返回结果:{}"
,
responseJSON
);
return
responseJSON
;
}
catch
(
AlipayApiException
e
)
{
log
.
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
>
tradeAppPay
(
AlipayTradePayReq
alipayTradePayReq
)
{
log
.
info
(
"AlipayUtil.tradeAppPay-->> req : {}"
,
alipayTradePayReq
.
toString
());
String
timeExpress
=
"5m"
;
// 支付超时,线下扫码交易定义为5分钟
AlipayClient
alipayClient
=
PayAlipayUtils
.
getInstance
().
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
);
AlipayTradeAppPayRequest
request
=
new
AlipayTradeAppPayRequest
();
request
.
setNotifyUrl
(
alipayTradePayReq
.
getNotifyUrl
());
// request.setTimestamp(DateUtil.now());
log
.
info
(
"bizContent :{}"
,
JSONObject
.
toJSONString
(
paramMap
));
request
.
setBizContent
(
JSONObject
.
toJSONString
(
paramMap
));
try
{
AlipayTradeAppPayResponse
response
=
alipayClient
.
sdkExecute
(
request
);
JSONObject
responseJSON
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
response
));
log
.
info
(
"AlipayUtil-->tradeAppPay-->支付宝返回结果:{}"
,
responseJSON
);
return
responseJSON
;
}
catch
(
AlipayApiException
e
)
{
log
.
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
)
{
log
.
info
(
"======>支付宝交易查询"
);
String
charset
=
"UTF-8"
;
String
format
=
"json"
;
String
signType
=
"RSA2"
;
AlipayClient
alipayClient
=
PayAlipayUtils
.
getInstance
().
getHttpClient
();
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
));
log
.
info
(
"支付宝订单查询返回结果:{}"
,
responseJSON
);
return
responseJSON
;
}
catch
(
AlipayApiException
e
)
{
log
.
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"
);
}
public
static
Map
<
String
,
String
>
parseNotifyMsg
(
Map
<
String
,
String
[]>
requestParams
){
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
for
(
Iterator
iter
=
requestParams
.
keySet
().
iterator
();
iter
.
hasNext
();)
{
String
name
=
(
String
)
iter
.
next
();
String
[]
values
=
requestParams
.
get
(
name
);
String
valueStr
=
""
;
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
valueStr
=
(
i
==
values
.
length
-
1
)
?
valueStr
+
values
[
i
]
:
valueStr
+
values
[
i
]
+
","
;
}
params
.
put
(
name
,
valueStr
);
}
return
params
;
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/alipay/config/AlipayConfigUtil.java
deleted
100644 → 0
View file @
3dbc5b28
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/constant/AlipayConstant.java
0 → 100644
View file @
9687411d
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
alipay
.
constant
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: AlipayConstant
* @Package com.liquidnet.service.dragon.channel.alipay.constant
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/13 20:52
*/
public
class
AlipayConstant
{
public
enum
AlipayTradeStateEnum
{
TRADE_CLOSED
(
"TRADE_CLOSED"
,
"交易关闭"
),
TRADE_FINISHED
(
"TRADE_FINISHED"
,
"支付完成"
),
TRADE_SUCCESS
(
"TRADE_SUCCESS"
,
"支付成功"
),
WAIT_BUYER_PAY
(
"WAIT_BUYER_PAY"
,
"交易创建"
),
FAIL
(
""
,
"支付失败"
);
private
String
code
;
private
String
message
;
AlipayTradeStateEnum
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
String
getCode
()
{
return
code
;
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/alipay/strategy/impl/AlipayStrategyAppImpl.java
View file @
9687411d
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
alipay
.
strategy
.
impl
;
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
alipay
.
strategy
.
impl
;
import
com.liquidnet.service.dragon.channel.alipay.biz.AlipayBiz
;
import
com.liquidnet.service.dragon.channel.alipay.req.AlipayTradePayReq
;
import
com.liquidnet.service.dragon.channel.alipay.req.AlipayTradePayReq
;
import
com.liquidnet.service.dragon.channel.alipay.strategy.annotation.StrategyAlipayHandler
;
import
com.liquidnet.service.dragon.channel.alipay.strategy.annotation.StrategyAlipayHandler
;
import
com.liquidnet.service.dragon.channel.alipay.util.AlipayUtil
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -35,9 +35,12 @@ public class AlipayStrategyAppImpl extends AbstractAlipayStrategy {
...
@@ -35,9 +35,12 @@ public class AlipayStrategyAppImpl extends AbstractAlipayStrategy {
@Autowired
@Autowired
StringRedisTemplate
stringRedisTemplate
;
StringRedisTemplate
stringRedisTemplate
;
@Autowired
private
AlipayBiz
alipayBiz
;
@Override
@Override
protected
Map
<
String
,
Object
>
executePay
(
AlipayTradePayReq
alipayTradePayReq
)
{
protected
Map
<
String
,
Object
>
executePay
(
AlipayTradePayReq
alipayTradePayReq
)
{
return
AlipayUtil
.
tradeAppPay
(
alipayTradePayReq
);
return
alipayBiz
.
tradeAppPay
(
alipayTradePayReq
);
}
}
protected
void
setProductCode
()
{
protected
void
setProductCode
()
{
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/alipay/strategy/impl/AlipayStrategyWapImpl.java
View file @
9687411d
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
alipay
.
strategy
.
impl
;
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
alipay
.
strategy
.
impl
;
import
com.liquidnet.service.dragon.channel.alipay.biz.AlipayBiz
;
import
com.liquidnet.service.dragon.channel.alipay.req.AlipayTradePayReq
;
import
com.liquidnet.service.dragon.channel.alipay.req.AlipayTradePayReq
;
import
com.liquidnet.service.dragon.channel.alipay.strategy.annotation.StrategyAlipayHandler
;
import
com.liquidnet.service.dragon.channel.alipay.strategy.annotation.StrategyAlipayHandler
;
import
com.liquidnet.service.dragon.channel.alipay.util.AlipayUtil
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -35,9 +35,12 @@ public class AlipayStrategyWapImpl extends AbstractAlipayStrategy {
...
@@ -35,9 +35,12 @@ public class AlipayStrategyWapImpl extends AbstractAlipayStrategy {
@Autowired
@Autowired
StringRedisTemplate
stringRedisTemplate
;
StringRedisTemplate
stringRedisTemplate
;
@Autowired
private
AlipayBiz
alipayBiz
;
@Override
@Override
protected
Map
<
String
,
Object
>
executePay
(
AlipayTradePayReq
alipayTradePayReq
)
{
protected
Map
<
String
,
Object
>
executePay
(
AlipayTradePayReq
alipayTradePayReq
)
{
return
AlipayUtil
.
tradeWapPay
(
alipayTradePayReq
);
return
alipayBiz
.
tradeWapPay
(
alipayTradePayReq
);
}
}
protected
void
setProductCode
()
{
protected
void
setProductCode
()
{
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/alipay/util/AlipayUtil.java
deleted
100644 → 0
View file @
3dbc5b28
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.AlipayTradeAppPayRequest
;
import
com.alipay.api.request.AlipayTradeQueryRequest
;
import
com.alipay.api.request.AlipayTradeWapPayRequest
;
import
com.alipay.api.response.AlipayTradeAppPayResponse
;
import
com.alipay.api.response.AlipayTradeQueryResponse
;
import
com.alipay.api.response.AlipayTradeWapPayResponse
;
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
java.util.*
;
@Slf4j
public
class
AlipayUtil
{
/**
* 支付宝支付
* @param alipayTradePayReq
* @return
*/
public
static
Map
<
String
,
Object
>
tradeWapPay
(
AlipayTradePayReq
alipayTradePayReq
)
{
log
.
info
(
"AlipayUtil.tradeWapPay-->> req : {}"
,
alipayTradePayReq
.
toString
());
String
timeExpress
=
"5m"
;
// 支付超时,线下扫码交易定义为5分钟
AlipayClient
alipayClient
=
PayAlipayUtils
.
getInstance
().
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
(
alipayTradePayReq
.
getNotifyUrl
());
// request.setTimestamp(DateUtil.now());
log
.
info
(
"bizContent :{}"
,
JSONObject
.
toJSONString
(
paramMap
));
request
.
setBizContent
(
JSONObject
.
toJSONString
(
paramMap
));
try
{
AlipayTradeWapPayResponse
response
=
alipayClient
.
sdkExecute
(
request
);
JSONObject
responseJSON
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
response
));
log
.
info
(
"AlipayUtil-->tradeWapPay-->支付宝返回结果:{}"
,
responseJSON
);
return
responseJSON
;
}
catch
(
AlipayApiException
e
)
{
log
.
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
>
tradeAppPay
(
AlipayTradePayReq
alipayTradePayReq
)
{
log
.
info
(
"AlipayUtil.tradeAppPay-->> req : {}"
,
alipayTradePayReq
.
toString
());
String
timeExpress
=
"5m"
;
// 支付超时,线下扫码交易定义为5分钟
AlipayClient
alipayClient
=
PayAlipayUtils
.
getInstance
().
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
);
AlipayTradeAppPayRequest
request
=
new
AlipayTradeAppPayRequest
();
request
.
setNotifyUrl
(
alipayTradePayReq
.
getNotifyUrl
());
// request.setTimestamp(DateUtil.now());
log
.
info
(
"bizContent :{}"
,
JSONObject
.
toJSONString
(
paramMap
));
request
.
setBizContent
(
JSONObject
.
toJSONString
(
paramMap
));
try
{
AlipayTradeAppPayResponse
response
=
alipayClient
.
sdkExecute
(
request
);
JSONObject
responseJSON
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
response
));
log
.
info
(
"AlipayUtil-->tradeAppPay-->支付宝返回结果:{}"
,
responseJSON
);
return
responseJSON
;
}
catch
(
AlipayApiException
e
)
{
log
.
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
)
{
log
.
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
));
log
.
info
(
"支付宝订单查询返回结果:{}"
,
responseJSON
);
return
responseJSON
;
}
catch
(
AlipayApiException
e
)
{
log
.
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"
);
}
public
static
Map
<
String
,
String
>
parseNotifyMsg
(
Map
<
String
,
String
[]>
requestParams
){
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
for
(
Iterator
iter
=
requestParams
.
keySet
().
iterator
();
iter
.
hasNext
();)
{
String
name
=
(
String
)
iter
.
next
();
String
[]
values
=
requestParams
.
get
(
name
);
String
valueStr
=
""
;
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
valueStr
=
(
i
==
values
.
length
-
1
)
?
valueStr
+
values
[
i
]
:
valueStr
+
values
[
i
]
+
","
;
}
params
.
put
(
name
,
valueStr
);
}
return
params
;
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/IPayChannelStrategy.java
View file @
9687411d
...
@@ -3,6 +3,7 @@ package com.liquidnet.service.dragon.channel.strategy;
...
@@ -3,6 +3,7 @@ package com.liquidnet.service.dragon.channel.strategy;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -20,4 +21,6 @@ public interface IPayChannelStrategy {
...
@@ -20,4 +21,6 @@ public interface IPayChannelStrategy {
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
);
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
);
void
dragonNotify
(
HttpServletRequest
request
,
String
payType
,
String
deviceFrom
);
void
dragonNotify
(
HttpServletRequest
request
,
String
payType
,
String
deviceFrom
);
DragonPayOrderQueryRespDto
checkOrderStatus
(
String
code
);
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/impl/PayChannelStrategyAlipayImpl.java
View file @
9687411d
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
strategy
.
impl
;
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
strategy
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alipay.api.AlipayApiException
;
import
com.alipay.api.internal.util.AlipaySignature
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.dragon.channel.alipay.biz.AlipayBiz
;
import
com.liquidnet.service.dragon.channel.alipay.constant.AlipayConstant
;
import
com.liquidnet.service.dragon.channel.alipay.strategy.AlipayStrategyContext
;
import
com.liquidnet.service.dragon.channel.alipay.strategy.AlipayStrategyContext
;
import
com.liquidnet.service.dragon.channel.alipay.util.AlipayUtil
;
import
com.liquidnet.service.dragon.channel.strategy.IPayChannelStrategy
;
import
com.liquidnet.service.dragon.channel.strategy.IPayChannelStrategy
;
import
com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChannelHandler
;
import
com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChannelHandler
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.constant.DragonErrorCodeEnum
;
import
com.liquidnet.service.dragon.dto.DragonOrdersDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto
;
import
com.liquidnet.service.dragon.utils.DataUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -33,6 +46,15 @@ public class PayChannelStrategyAlipayImpl implements IPayChannelStrategy {
...
@@ -33,6 +46,15 @@ public class PayChannelStrategyAlipayImpl implements IPayChannelStrategy {
@Autowired
@Autowired
private
AlipayStrategyContext
alipayStrategyContext
;
private
AlipayStrategyContext
alipayStrategyContext
;
@Autowired
private
DataUtils
dataUtils
;
@Autowired
private
AlipayBiz
alipayBiz
;
@Value
(
"${liquidnet.dragon.wepay.partnerKey}"
)
private
String
partnerKey
;
@Override
@Override
public
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
public
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
return
alipayStrategyContext
.
getStrategy
(
dragonPayBaseReqDto
.
getDeviceFrom
()).
dragonPay
(
dragonPayBaseReqDto
);
return
alipayStrategyContext
.
getStrategy
(
dragonPayBaseReqDto
.
getDeviceFrom
()).
dragonPay
(
dragonPayBaseReqDto
);
...
@@ -42,8 +64,98 @@ public class PayChannelStrategyAlipayImpl implements IPayChannelStrategy {
...
@@ -42,8 +64,98 @@ public class PayChannelStrategyAlipayImpl implements IPayChannelStrategy {
public
void
dragonNotify
(
HttpServletRequest
request
,
String
payType
,
String
deviceFrom
)
{
public
void
dragonNotify
(
HttpServletRequest
request
,
String
payType
,
String
deviceFrom
)
{
Map
<
String
,
String
[]>
requestParams
=
request
.
getParameterMap
();
Map
<
String
,
String
[]>
requestParams
=
request
.
getParameterMap
();
Map
<
String
,
String
>
notifyMap
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
notifyMap
=
new
HashMap
<
String
,
String
>();
notifyMap
=
AlipayUtil
.
parseNotifyMsg
(
requestParams
);
notifyMap
=
alipayBiz
.
parseNotifyMsg
(
requestParams
);
log
.
info
(
"dragonNotify-->alipay json : {}"
,
JSON
.
toJSONString
(
notifyMap
));
log
.
info
(
"dragonNotify-->alipay json : {}"
,
JSON
.
toJSONString
(
notifyMap
));
log
.
info
(
"接收到{}支付结果{}"
,
payType
,
notifyMap
);
String
returnStr
=
null
;
String
code
=
notifyMap
.
get
(
"out_trade_no"
);
// 根据银行订单号获取支付信息
DragonOrdersDto
dragonOrdersDto
=
dataUtils
.
getPayOrderByCode
(
code
);
if
(
dragonOrdersDto
==
null
)
{
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_ERROR_NOT_EXISTS
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ERROR_NOT_EXISTS
.
getMessage
());
}
if
(
DragonConstant
.
PayStatusEnum
.
STATUS_PAID
.
getCode
().
equals
(
dragonOrdersDto
.
getStatus
()))
{
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_ERROR_HAS_PAID
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ERROR_HAS_PAID
.
getMessage
());
}
try
{
if
(
AlipaySignature
.
rsaCheckV1
(
notifyMap
,
partnerKey
,
"UTF-8"
,
"RSA2"
)){
String
tradeStatus
=
notifyMap
.
get
(
"trade_status"
);
if
(
AlipayConstant
.
AlipayTradeStateEnum
.
TRADE_FINISHED
.
name
().
equals
(
tradeStatus
))
{
// 判断该笔订单是否在商户网站中已经做过处理
// 如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
// 请务必判断请求时的total_fee、seller_id与通知时获取的total_fee、seller_id为一致的
// 如果有做过处理,不执行商户的业务程序
// 注意:
// 退款日期超过可退款期限后(如三个月可退款),支付宝系统发送该交易状态通知
}
else
if
(
AlipayConstant
.
AlipayTradeStateEnum
.
TRADE_SUCCESS
.
name
().
equals
(
tradeStatus
))
{
String
gmtPaymentStr
=
notifyMap
.
get
(
"gmt_payment"
);
// 付款时间
LocalDateTime
timeEnd
=
null
;
if
(!
StringUtil
.
isEmpty
(
gmtPaymentStr
))
{
timeEnd
=
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
parse
(
gmtPaymentStr
);
}
completeSuccessOrder
(
dragonOrdersDto
,
notifyMap
.
get
(
"trade_no"
),
timeEnd
,
notifyMap
.
toString
());
returnStr
=
"success"
;
}
else
{
// completeFailOrder(dragonOrdersDto, notifyMap.toString());
returnStr
=
"fail"
;
}
}
else
{
// 验证失败
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_ALIPAY_SIGN_ERROR
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ALIPAY_SIGN_ERROR
.
getMessage
());
}
}
catch
(
AlipayApiException
e
)
{
log
.
error
(
"验签失败:"
,
e
);
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_ALIPAY_SIGN_ERROR
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ALIPAY_SIGN_ERROR
.
getMessage
());
}
log
.
info
(
"返回支付通道{}信息{}"
,
payType
,
returnStr
);
}
@Override
public
DragonPayOrderQueryRespDto
checkOrderStatus
(
String
code
)
{
Map
<
String
,
Object
>
result
=
alipayBiz
.
tradeQuery
(
code
);
DragonPayOrderQueryRespDto
respDto
=
new
DragonPayOrderQueryRespDto
();
return
respDto
;
}
}
/**
* 支付成功方法
* @param dragonOrdersDto
* @param bankTrxNo
* @param timeEnd
* @param bankReturnMsg
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
void
completeSuccessOrder
(
DragonOrdersDto
dragonOrdersDto
,
String
bankTrxNo
,
LocalDateTime
timeEnd
,
String
bankReturnMsg
)
{
log
.
info
(
"订单支付成功!"
);
dragonOrdersDto
.
setPaymentAt
(
timeEnd
);
dragonOrdersDto
.
setPaymentId
(
bankTrxNo
);
// 设置银行流水号
// DragonOrdersDto.(bankReturnMsg);
dragonOrdersDto
.
setStatus
(
Integer
.
parseInt
(
DragonConstant
.
PayStatusEnum
.
STATUS_PAID
.
getCode
()));
dataUtils
.
updateOrderStatus
(
dragonOrdersDto
.
getCode
(),
dragonOrdersDto
);
String
notifyUrl
=
dragonOrdersDto
.
getNotifyUrl
();
}
/**
* 支付失败方法
*
* @param DragonOrdersDto
*/
// private void completeFailOrder(DragonOrdersDto dragonOrdersDto, String bankReturnMsg) {
// log.info("订单支付失败!");
//// DragonOrdersDto.(bankReturnMsg);
// dragonOrdersDto.setStatus(Integer.parseInt(DragonConstant.PayStatusEnum.STATUS_PAID.getCode()));
// dataUtils.updateOrderStatus(dragonOrdersDto.getCode(),dragonOrdersDto);
//
// String notifyUrl = dragonOrdersDto.getNotifyUrl();
// }
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/impl/PayChannelStrategyApplepayImpl.java
View file @
9687411d
...
@@ -6,6 +6,7 @@ import com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChann
...
@@ -6,6 +6,7 @@ import com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChann
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -34,4 +35,9 @@ public class PayChannelStrategyApplepayImpl implements IPayChannelStrategy {
...
@@ -34,4 +35,9 @@ public class PayChannelStrategyApplepayImpl implements IPayChannelStrategy {
public
void
dragonNotify
(
HttpServletRequest
request
,
String
payType
,
String
deviceFrom
)
{
public
void
dragonNotify
(
HttpServletRequest
request
,
String
payType
,
String
deviceFrom
)
{
}
}
@Override
public
DragonPayOrderQueryRespDto
checkOrderStatus
(
String
code
)
{
return
null
;
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/impl/PayChannelStrategyWepayImpl.java
View file @
9687411d
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
strategy
.
impl
;
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
strategy
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.dragon.channel.strategy.IPayChannelStrategy
;
import
com.liquidnet.service.dragon.channel.strategy.IPayChannelStrategy
;
import
com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChannelHandler
;
import
com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChannelHandler
;
import
com.liquidnet.service.dragon.channel.wepay.constant.WepayConstant
;
import
com.liquidnet.service.dragon.channel.wepay.strategy.WepayStrategyContext
;
import
com.liquidnet.service.dragon.channel.wepay.strategy.WepayStrategyContext
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.constant.DragonErrorCodeEnum
;
import
com.liquidnet.service.dragon.dto.DragonOrdersDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto
;
import
com.liquidnet.service.dragon.utils.DataUtils
;
import
com.liquidnet.service.dragon.utils.PayWepayUtils
;
import
com.liquidnet.service.dragon.utils.PayWepayUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -35,6 +45,9 @@ public class PayChannelStrategyWepayImpl implements IPayChannelStrategy {
...
@@ -35,6 +45,9 @@ public class PayChannelStrategyWepayImpl implements IPayChannelStrategy {
@Autowired
@Autowired
private
WepayStrategyContext
wepayStrategyContext
;
private
WepayStrategyContext
wepayStrategyContext
;
@Autowired
private
DataUtils
dataUtils
;
@Override
@Override
public
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
public
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
return
wepayStrategyContext
.
getStrategy
(
dragonPayBaseReqDto
.
getDeviceFrom
()).
dragonPay
(
dragonPayBaseReqDto
);
return
wepayStrategyContext
.
getStrategy
(
dragonPayBaseReqDto
.
getDeviceFrom
()).
dragonPay
(
dragonPayBaseReqDto
);
...
@@ -48,6 +61,39 @@ public class PayChannelStrategyWepayImpl implements IPayChannelStrategy {
...
@@ -48,6 +61,39 @@ public class PayChannelStrategyWepayImpl implements IPayChannelStrategy {
try
{
try
{
notifyMap
=
PayWepayUtils
.
parseXml
(
inputStream
);
notifyMap
=
PayWepayUtils
.
parseXml
(
inputStream
);
log
.
info
(
"dragonNotify-->wepay json : {}"
,
JSON
.
toJSONString
(
notifyMap
));
log
.
info
(
"dragonNotify-->wepay json : {}"
,
JSON
.
toJSONString
(
notifyMap
));
log
.
info
(
"接收到{}支付结果{}"
,
payType
,
notifyMap
);
String
code
=
notifyMap
.
get
(
"out_trade_no"
);
// 根据银行订单号获取支付信息
DragonOrdersDto
dragonOrdersDto
=
dataUtils
.
getPayOrderByCode
(
code
);
if
(
dragonOrdersDto
==
null
)
{
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_ERROR_NOT_EXISTS
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ERROR_NOT_EXISTS
.
getMessage
());
}
if
(
DragonConstant
.
PayStatusEnum
.
STATUS_PAID
.
getCode
().
equals
(
dragonOrdersDto
.
getStatus
()))
{
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_ERROR_HAS_PAID
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_ERROR_HAS_PAID
.
getMessage
());
}
String
partnerKey
=
""
;
String
sign
=
notifyMap
.
remove
(
"sign"
);
if
(
PayWepayUtils
.
notifySign
(
notifyMap
,
sign
,
partnerKey
))
{
// 根据配置信息验证签名
if
(
WepayConstant
.
WeixinTradeStateEnum
.
SUCCESS
.
getCode
().
equals
(
notifyMap
.
get
(
"result_code"
)))
{
// 业务结果
// 成功
String
timeEndStr
=
notifyMap
.
get
(
"time_end"
);
LocalDateTime
timeEnd
=
null
;
if
(!
StringUtil
.
isEmpty
(
timeEndStr
))
{
timeEnd
=
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
parse
(
timeEndStr
);
}
completeSuccessOrder
(
dragonOrdersDto
,
notifyMap
.
get
(
"transaction_id"
),
timeEnd
,
notifyMap
.
toString
());
// returnStr = "<xml>\n" + " <return_code><![CDATA[SUCCESS]]></return_code>\n" + " <return_msg><![CDATA[OK]]></return_msg>\n" + "</xml>";
}
else
{
// completeFailOrder(dragonOrdersDto, notifyMap.toString());
}
}
else
{
throw
new
LiquidnetServiceException
(
DragonErrorCodeEnum
.
TRADE_WEPAY_SIGN_ERROR
.
getCode
(),
DragonErrorCodeEnum
.
TRADE_WEPAY_SIGN_ERROR
.
getMessage
());
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -55,4 +101,24 @@ public class PayChannelStrategyWepayImpl implements IPayChannelStrategy {
...
@@ -55,4 +101,24 @@ public class PayChannelStrategyWepayImpl implements IPayChannelStrategy {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
@Override
public
DragonPayOrderQueryRespDto
checkOrderStatus
(
String
code
)
{
DragonOrdersDto
ordersDto
=
dataUtils
.
getPayOrderByCode
(
code
);
DragonPayOrderQueryRespDto
respDto
=
wepayStrategyContext
.
getStrategy
(
ordersDto
.
getPaymentType
()).
checkOrderStatus
(
code
);
return
respDto
;
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
void
completeSuccessOrder
(
DragonOrdersDto
dragonOrdersDto
,
String
bankTrxNo
,
LocalDateTime
timeEnd
,
String
bankReturnMsg
)
{
log
.
info
(
"订单支付成功!"
);
dragonOrdersDto
.
setPaymentAt
(
timeEnd
);
dragonOrdersDto
.
setPaymentId
(
bankTrxNo
);
// 设置银行流水号
// DragonOrdersDto.(bankReturnMsg);
dragonOrdersDto
.
setStatus
(
Integer
.
parseInt
(
DragonConstant
.
PayStatusEnum
.
STATUS_PAID
.
getCode
()));
dataUtils
.
updateOrderStatus
(
dragonOrdersDto
.
getCode
(),
dragonOrdersDto
);
String
notifyUrl
=
dragonOrdersDto
.
getNotifyUrl
();
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/biz/WepayBiz.java
View file @
9687411d
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
wepay
.
biz
;
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
wepay
.
biz
;
import
com.liquidnet.service.dragon.channel.wepay.req.WepayPrePayReq
;
import
com.liquidnet.service.dragon.channel.wepay.resp.WepayOrderQueryRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.utils.PayWepayUtils
;
import
com.liquidnet.service.dragon.utils.XmlUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.Set
;
import
java.util.SortedMap
;
import
java.util.TreeMap
;
/**
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @version V1.0
...
@@ -17,25 +28,43 @@ import org.springframework.stereotype.Component;
...
@@ -17,25 +28,43 @@ import org.springframework.stereotype.Component;
@Slf4j
@Slf4j
@Component
@Component
public
class
WepayBiz
{
public
class
WepayBiz
{
public
WepayPrePayReq
sealWeixinPerPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
@Value
(
"${liquidnet.dragon.wepay.merchantId}"
)
WepayPrePayReq
WepayPrePayReq
=
new
WepayPrePayReq
();
private
String
merchantId
;
/**
* 订单查询
*
* @return
*/
public
WepayOrderQueryRespDto
tradeQuery
(
String
outTradeNo
,
String
appid
)
{
log
.
info
(
"======>支付宝交易查询"
);
WepayOrderQueryRespDto
respDto
=
null
;
SortedMap
<
String
,
Object
>
paramMap
=
new
TreeMap
<>();
paramMap
.
put
(
"appid"
,
appid
);
paramMap
.
put
(
"mch_id"
,
merchantId
);
String
nonce_str
=
PayWepayUtils
.
getInstance
().
getNonceStr
();
paramMap
.
put
(
"nonce_str"
,
nonce_str
);
paramMap
.
put
(
"out_trade_no"
,
outTradeNo
);
String
sign
=
PayWepayUtils
.
getInstance
().
createSign
(
paramMap
);
paramMap
.
put
(
"sign"
,
sign
);
Set
<
String
>
ks
=
paramMap
.
keySet
();
// WepayPrePayReq.setAppid(appId);
String
data
=
PayWepayUtils
.
getInstance
().
getRequestXml
(
paramMap
);
// WepayPrePayReq.setMchId(mchId);
try
{
// WepayPrePayReq.setBody(productName);// 商品描述
HttpPost
httpost
=
new
HttpPost
(
"https://api.mch.weixin.qq.com/pay/orderquery"
);
// WepayPrePayReq.setAttach(remark);// 支付备注
httpost
.
setEntity
(
new
StringEntity
(
data
,
"UTF-8"
));
// WepayPrePayReq.setOutTradeNo(bankOrderNo);// 银行订单号
CloseableHttpResponse
response
=
null
;
//
// Integer totalFee = orderPrice.multiply(BigDecimal.valueOf(100d)).intValue();
// WepayPrePayReq.setTotalFee(totalFee);// 订单金额
// WepayPrePayReq.setTimeStart(DateUtil.parse(orderTime, "yyyyMMddHHmmss"));// 订单开始时间
//// WepayPrePayReq.setTimeExpire(DateUtil.formatDate(DateUtil.addMinute(orderTime, orderPeriod), "yyyyMMddHHmmss"));// 订单到期时间
// WepayPrePayReq.setNotifyUrl(WeixinConfigUtil.readConfig("notify_url"));// 通知地址
//// WepayPrePayReq.setTradeType("");// 交易类型
// WepayPrePayReq.setProductId(productId);// 商品ID
// WepayPrePayReq.setOpenid(openId);// 用户标识
// WepayPrePayReq.setSpbillCreateIp(orderIp);// 下单IP
return
WepayPrePayReq
;
response
=
PayWepayUtils
.
getInstance
().
getHttpClient
().
execute
(
httpost
);
HttpEntity
entity
=
response
.
getEntity
();
//接受到返回信息
String
xmlStr
=
EntityUtils
.
toString
(
response
.
getEntity
(),
"UTF-8"
);
EntityUtils
.
consume
(
entity
);
log
.
info
(
"dragonPay:wepay:wap response xmlStr: {} "
,
xmlStr
);
respDto
=
XmlUtil
.
toBean
(
xmlStr
,
WepayOrderQueryRespDto
.
class
);
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
());
}
return
respDto
;
}
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/config/WeixinConfigUtil.java
deleted
100644 → 0
View file @
3dbc5b28
/*
* 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
.
wepay
.
config
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
java.io.IOException
;
import
java.util.Properties
;
/**
* <b>功能说明:微信属性文件工具类
* </b>
* @author Peter
* <a href="http://www.roncoo.com">龙果学院(www.roncoo.com)</a>
*/
public
class
WeixinConfigUtil
{
private
static
final
Log
LOG
=
LogFactory
.
getLog
(
WeixinConfigUtil
.
class
);
/**
* 通过静态代码块读取上传文件的验证格式配置文件,静态代码块只执行一次(单例)
*/
private
static
Properties
properties
=
new
Properties
();
private
WeixinConfigUtil
()
{
}
// 通过类装载器装载进来
static
{
try
{
// 从类路径下读取属性文件
properties
.
load
(
WeixinConfigUtil
.
class
.
getClassLoader
()
.
getResourceAsStream
(
"weixinpay_config.properties"
));
}
catch
(
IOException
e
)
{
LOG
.
error
(
e
);
}
}
/**
* 函数功能说明 :读取配置项 Administrator 2012-12-14 修改者名字 : 修改日期 : 修改内容 :
*
* @参数:
* @return void
* @throws
*/
public
static
String
readConfig
(
String
key
)
{
return
(
String
)
properties
.
get
(
key
);
}
//app_id
public
static
final
String
appId
=
(
String
)
properties
.
get
(
"appId"
);
//商户号
public
static
final
String
mch_id
=
(
String
)
properties
.
get
(
"mch_id"
);
//商户秘钥
public
static
final
String
partnerKey
=
(
String
)
properties
.
get
(
"partnerKey"
);
//小程序支付
public
static
final
String
xAuthUrl
=
(
String
)
properties
.
get
(
"x_auth_url"
);
public
static
final
String
xGrantType
=
(
String
)
properties
.
get
(
"x_grant_type"
);
public
static
final
String
xAppId
=
(
String
)
properties
.
get
(
"x_appId"
);
public
static
final
String
xPartnerKey
=
(
String
)
properties
.
get
(
"x_partnerKey"
);
public
static
final
String
xPayKey
=
(
String
)
properties
.
get
(
"x_payKey"
);
public
static
final
String
xMchId
=
(
String
)
properties
.
get
(
"x_mch_id"
);
public
static
final
String
x_notify_url
=
(
String
)
properties
.
get
(
"x_notify_url"
);
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/constant/WepayConstant.java
0 → 100644
View file @
9687411d
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
wepay
.
constant
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: WepayConstant
* @Package com.liquidnet.service.dragon.channel.wepay
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/14 11:05
*/
public
class
WepayConstant
{
public
enum
WeixinTradeStateEnum
{
SUCCESS
(
"SUCCESS"
,
"成功"
),
FAIL
(
"FAIL"
,
"失败"
);
private
String
code
;
private
String
message
;
WeixinTradeStateEnum
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
String
getCode
()
{
return
code
;
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/resp/WepayOrderQueryRespDto.java
0 → 100644
View file @
9687411d
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
wepay
.
resp
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: WepayPayOrderQueryRespDto
* @Package com.liquidnet.service.dragon.channel.wepay.resp
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/14 13:21
*/
@Data
public
class
WepayOrderQueryRespDto
{
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/strategy/IWepayStrategy.java
View file @
9687411d
...
@@ -3,6 +3,7 @@ package com.liquidnet.service.dragon.channel.wepay.strategy;
...
@@ -3,6 +3,7 @@ package com.liquidnet.service.dragon.channel.wepay.strategy;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto
;
/**
/**
...
@@ -16,4 +17,6 @@ import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
...
@@ -16,4 +17,6 @@ import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
*/
*/
public
interface
IWepayStrategy
{
public
interface
IWepayStrategy
{
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
);
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
);
DragonPayOrderQueryRespDto
checkOrderStatus
(
String
code
);
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/strategy/impl/AbstractWepayStrategy.java
View file @
9687411d
...
@@ -2,10 +2,13 @@ package com.liquidnet.service.dragon.channel.wepay.strategy.impl;
...
@@ -2,10 +2,13 @@ package com.liquidnet.service.dragon.channel.wepay.strategy.impl;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.dragon.channel.wepay.biz.WepayBiz
;
import
com.liquidnet.service.dragon.channel.wepay.resp.WepayOrderQueryRespDto
;
import
com.liquidnet.service.dragon.channel.wepay.resp.WepayPayRespDto
;
import
com.liquidnet.service.dragon.channel.wepay.resp.WepayPayRespDto
;
import
com.liquidnet.service.dragon.channel.wepay.strategy.IWepayStrategy
;
import
com.liquidnet.service.dragon.channel.wepay.strategy.IWepayStrategy
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto
;
import
com.liquidnet.service.dragon.utils.PayWepayUtils
;
import
com.liquidnet.service.dragon.utils.PayWepayUtils
;
import
com.liquidnet.service.dragon.utils.XmlUtil
;
import
com.liquidnet.service.dragon.utils.XmlUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -14,7 +17,7 @@ import org.apache.http.client.methods.CloseableHttpResponse;
...
@@ -14,7 +17,7 @@ import org.apache.http.client.methods.CloseableHttpResponse;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.util.EntityUtils
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.beans.factory.annotation.
Value
;
import
org.springframework.beans.factory.annotation.
Autowired
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.SortedMap
;
import
java.util.SortedMap
;
...
@@ -31,8 +34,8 @@ import java.util.TreeMap;
...
@@ -31,8 +34,8 @@ import java.util.TreeMap;
*/
*/
@Slf4j
@Slf4j
public
abstract
class
AbstractWepayStrategy
implements
IWepayStrategy
{
public
abstract
class
AbstractWepayStrategy
implements
IWepayStrategy
{
@
Value
(
"${liquidnet.dragon.wepay.parentKey}"
)
@
Autowired
private
String
parentKey
;
private
WepayBiz
wepayBiz
;
@Override
@Override
public
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
public
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
...
@@ -103,7 +106,7 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy {
...
@@ -103,7 +106,7 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy {
parameters
.
put
(
"mch_id"
,
PayWepayUtils
.
getInstance
().
getMerchantId
());
parameters
.
put
(
"mch_id"
,
PayWepayUtils
.
getInstance
().
getMerchantId
());
parameters
.
put
(
"nonce_str"
,
nonceStr
);
parameters
.
put
(
"nonce_str"
,
nonceStr
);
parameters
.
put
(
"spbill_create_ip"
,
dragonPayBaseReqDto
.
getClientIp
());
parameters
.
put
(
"spbill_create_ip"
,
dragonPayBaseReqDto
.
getClientIp
());
parameters
.
put
(
"total_fee"
,
dragonPayBaseReqDto
.
getPrice
().
multiply
(
BigDecimal
.
valueOf
(
100L
)).
intValue
());
parameters
.
put
(
"total_fee"
,
dragonPayBaseReqDto
.
getPrice
().
multiply
(
BigDecimal
.
valueOf
(
100L
)).
intValue
()
+
""
);
parameters
.
put
(
"body"
,
dragonPayBaseReqDto
.
getName
());
parameters
.
put
(
"body"
,
dragonPayBaseReqDto
.
getName
());
parameters
.
put
(
"detail"
,
dragonPayBaseReqDto
.
getDetail
());
parameters
.
put
(
"detail"
,
dragonPayBaseReqDto
.
getDetail
());
parameters
.
put
(
"out_trade_no"
,
dragonPayBaseReqDto
.
getCode
());
parameters
.
put
(
"out_trade_no"
,
dragonPayBaseReqDto
.
getCode
());
...
@@ -135,4 +138,16 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy {
...
@@ -135,4 +138,16 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy {
* 设置notifyUrl
* 设置notifyUrl
*/
*/
protected
abstract
String
getNotifyUrl
();
protected
abstract
String
getNotifyUrl
();
@Override
public
DragonPayOrderQueryRespDto
checkOrderStatus
(
String
code
)
{
WepayOrderQueryRespDto
result
=
wepayBiz
.
tradeQuery
(
code
,
this
.
getAppid
());
DragonPayOrderQueryRespDto
respDto
=
new
DragonPayOrderQueryRespDto
();
respDto
.
setCode
(
code
);
respDto
.
setOrderCode
(
""
);
respDto
.
setStatus
(
""
);
return
respDto
;
}
protected
abstract
String
getAppid
();
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/strategy/impl/WepayStrategyAppImpl.java
View file @
9687411d
...
@@ -49,4 +49,9 @@ public class WepayStrategyAppImpl extends AbstractWepayStrategy {
...
@@ -49,4 +49,9 @@ public class WepayStrategyAppImpl extends AbstractWepayStrategy {
protected
String
getNotifyUrl
()
{
protected
String
getNotifyUrl
()
{
return
notifyUrl
+
"/notify/wepay/app"
;
return
notifyUrl
+
"/notify/wepay/app"
;
}
}
@Override
protected
String
getAppid
()
{
return
PayWepayUtils
.
getInstance
().
getAPP_ID
();
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/strategy/impl/WepayStrategyAppletImpl.java
View file @
9687411d
...
@@ -50,4 +50,9 @@ public class WepayStrategyAppletImpl extends AbstractWepayStrategy{
...
@@ -50,4 +50,9 @@ public class WepayStrategyAppletImpl extends AbstractWepayStrategy{
protected
String
getNotifyUrl
()
{
protected
String
getNotifyUrl
()
{
return
notifyUrl
+
"/notify/wepay/applet"
;
return
notifyUrl
+
"/notify/wepay/applet"
;
}
}
@Override
protected
String
getAppid
()
{
return
PayWepayUtils
.
getInstance
().
getAPPLET_APP_ID
();
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/strategy/impl/WepayStrategyJsImpl.java
View file @
9687411d
...
@@ -50,4 +50,9 @@ public class WepayStrategyJsImpl extends AbstractWepayStrategy{
...
@@ -50,4 +50,9 @@ public class WepayStrategyJsImpl extends AbstractWepayStrategy{
protected
String
getNotifyUrl
()
{
protected
String
getNotifyUrl
()
{
return
notifyUrl
+
"/notify/wepay/js"
;
return
notifyUrl
+
"/notify/wepay/js"
;
}
}
@Override
protected
String
getAppid
()
{
return
PayWepayUtils
.
getInstance
().
getJS_APP_ID
();
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/strategy/impl/WepayStrategyWapImpl.java
View file @
9687411d
...
@@ -49,4 +49,9 @@ public class WepayStrategyWapImpl extends AbstractWepayStrategy{
...
@@ -49,4 +49,9 @@ public class WepayStrategyWapImpl extends AbstractWepayStrategy{
protected
String
getNotifyUrl
()
{
protected
String
getNotifyUrl
()
{
return
notifyUrl
+
"/notify/wepay/wap"
;
return
notifyUrl
+
"/notify/wepay/wap"
;
}
}
@Override
protected
String
getAppid
()
{
return
PayWepayUtils
.
getInstance
().
getWAP_APP_ID
();
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/util/MD5Util.java
deleted
100644 → 0
View file @
3dbc5b28
/*
* 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
.
wepay
.
util
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.security.MessageDigest
;
/**
* <b>功能说明:MD5签名工具类
* </b>
* @author Peter
* <a href="http://www.roncoo.com">龙果学院(www.roncoo.com)</a>
*/
public
class
MD5Util
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MD5Util
.
class
);
/**
* 私有构造方法,将该工具类设为单例模式.
*/
private
MD5Util
()
{
}
private
static
final
String
[]
hex
=
{
"0"
,
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"a"
,
"b"
,
"c"
,
"d"
,
"e"
,
"f"
};
public
static
String
encode
(
String
password
)
{
try
{
MessageDigest
md5
=
MessageDigest
.
getInstance
(
"MD5"
);
byte
[]
byteArray
=
md5
.
digest
(
password
.
getBytes
(
"utf-8"
));
String
passwordMD5
=
byteArrayToHexString
(
byteArray
);
return
passwordMD5
;
}
catch
(
Exception
e
)
{
LOG
.
error
(
e
.
toString
());
}
return
password
;
}
private
static
String
byteArrayToHexString
(
byte
[]
byteArray
)
{
StringBuffer
sb
=
new
StringBuffer
();
for
(
byte
b
:
byteArray
)
{
sb
.
append
(
byteToHexChar
(
b
));
}
return
sb
.
toString
();
}
private
static
Object
byteToHexChar
(
byte
b
)
{
int
n
=
b
;
if
(
n
<
0
)
{
n
=
256
+
n
;
}
int
d1
=
n
/
16
;
int
d2
=
n
%
16
;
return
hex
[
d1
]
+
hex
[
d2
];
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/wepay/util/WepayUtil.java
deleted
100644 → 0
View file @
3dbc5b28
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/DragonOrdersServiceImpl.java
View file @
9687411d
...
@@ -5,6 +5,7 @@ import com.liquidnet.service.base.ResponseDto;
...
@@ -5,6 +5,7 @@ import com.liquidnet.service.base.ResponseDto;
import
com.liquidnet.service.dragon.channel.strategy.PayChannelStrategyContext
;
import
com.liquidnet.service.dragon.channel.strategy.PayChannelStrategyContext
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto
;
import
com.liquidnet.service.dragon.service.IDragonOrdersService
;
import
com.liquidnet.service.dragon.service.IDragonOrdersService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -48,4 +49,14 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
...
@@ -48,4 +49,14 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
public
void
dragonNotify
(
HttpServletRequest
request
,
String
payType
,
String
deviceFrom
)
{
public
void
dragonNotify
(
HttpServletRequest
request
,
String
payType
,
String
deviceFrom
)
{
payChannelStrategyContext
.
getStrategy
(
payType
).
dragonNotify
(
request
,
payType
,
deviceFrom
);
payChannelStrategyContext
.
getStrategy
(
payType
).
dragonNotify
(
request
,
payType
,
deviceFrom
);
}
}
@Override
public
DragonPayOrderQueryRespDto
checkOrderStatusByCode
(
String
code
)
{
return
null
;
}
@Override
public
DragonPayOrderQueryRespDto
checkOrderStatusByOrderCode
(
String
orderCode
)
{
return
null
;
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/utils/DataUtils.java
0 → 100644
View file @
9687411d
package
com
.
liquidnet
.
service
.
dragon
.
utils
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.dto.DragonOrdersDto
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
@Component
public
class
DataUtils
{
@Autowired
private
RedisUtil
redisUtil
;
public
void
createPayOrder
(
String
orderCode
,
String
code
,
DragonOrdersDto
ordersDto
)
{
if
(
redisUtil
.
hasKey
(
DragonConstant
.
REDIS_KET_PAY_ORDERCODE
+
orderCode
))
{
}
else
{
redisUtil
.
set
(
DragonConstant
.
REDIS_KET_PAY_ORDERCODE
+
orderCode
,
code
);
redisUtil
.
set
(
DragonConstant
.
REDIS_KET_PAY_CODE
+
code
,
ordersDto
);
}
}
public
DragonOrdersDto
getPayOrderByCode
(
String
code
){
if
(!
redisUtil
.
hasKey
(
DragonConstant
.
REDIS_KET_PAY_CODE
+
code
))
{
//TODO 是否降级处理
}
return
(
DragonOrdersDto
)
redisUtil
.
get
(
DragonConstant
.
REDIS_KET_PAY_CODE
+
code
);
}
public
DragonOrdersDto
getPayOrderByOrderCode
(
String
orderCode
){
if
(!
redisUtil
.
hasKey
(
DragonConstant
.
REDIS_KET_PAY_ORDERCODE
+
orderCode
))
{
//TODO 是否降级处理
}
//获取支付订单号
String
code
=
(
String
)
redisUtil
.
get
(
DragonConstant
.
REDIS_KET_PAY_ORDERCODE
+
orderCode
);
return
(
DragonOrdersDto
)
redisUtil
.
get
(
DragonConstant
.
REDIS_KET_PAY_CODE
+
code
);
}
public
void
updateOrderStatus
(
String
code
,
DragonOrdersDto
dragonOrdersDto
){
redisUtil
.
set
(
DragonConstant
.
REDIS_KET_PAY_CODE
+
code
,
dragonOrdersDto
);
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/utils/PayWepayUtils.java
View file @
9687411d
...
@@ -25,7 +25,7 @@ public class PayWepayUtils {
...
@@ -25,7 +25,7 @@ public class PayWepayUtils {
private
static
PayWepayUtils
instance
=
new
PayWepayUtils
();
private
static
PayWepayUtils
instance
=
new
PayWepayUtils
();
private
final
String
merchantId
=
"1551961491"
;
private
final
String
merchantId
=
"1551961491"
;
private
final
String
par
ent
Key
=
"itIuO65O9yKmemOu3S8g1S4orqvCGwXK"
;
private
final
String
par
tner
Key
=
"itIuO65O9yKmemOu3S8g1S4orqvCGwXK"
;
private
final
String
APP_ID
=
"wx86f9777acf2cb585"
;
private
final
String
APP_ID
=
"wx86f9777acf2cb585"
;
private
final
String
WEB_APP_ID
=
"wx3498304dda39c5a1"
;
private
final
String
WEB_APP_ID
=
"wx3498304dda39c5a1"
;
...
@@ -121,7 +121,7 @@ public class PayWepayUtils {
...
@@ -121,7 +121,7 @@ public class PayWepayUtils {
sb
.
append
(
k
+
"="
+
v
+
"&"
);
sb
.
append
(
k
+
"="
+
v
+
"&"
);
}
}
}
}
sb
.
append
(
"key="
+
par
ent
Key
);
sb
.
append
(
"key="
+
par
tner
Key
);
return
MD5Utils
.
md5
(
sb
.
toString
()).
toUpperCase
();
return
MD5Utils
.
md5
(
sb
.
toString
()).
toUpperCase
();
}
}
...
@@ -147,7 +147,7 @@ public class PayWepayUtils {
...
@@ -147,7 +147,7 @@ public class PayWepayUtils {
public
String
unCodeReqInfo
(
String
reqInfo
)
{
public
String
unCodeReqInfo
(
String
reqInfo
)
{
try
{
try
{
Cipher
cipher
;
Cipher
cipher
;
String
key
=
MD5Utils
.
md5
(
par
ent
Key
);
String
key
=
MD5Utils
.
md5
(
par
tner
Key
);
SecretKeySpec
secretKeySpec
=
new
SecretKeySpec
(
key
.
getBytes
(),
"AES"
);
SecretKeySpec
secretKeySpec
=
new
SecretKeySpec
(
key
.
getBytes
(),
"AES"
);
Security
.
addProvider
(
new
BouncyCastleProvider
());
Security
.
addProvider
(
new
BouncyCastleProvider
());
...
@@ -185,4 +185,28 @@ public class PayWepayUtils {
...
@@ -185,4 +185,28 @@ public class PayWepayUtils {
return
map
;
return
map
;
}
}
public
String
getPartnerKey
()
{
return
this
.
partnerKey
;
}
public
static
boolean
notifySign
(
Map
<
String
,
String
>
result
,
String
sign
,
String
partnerKey
)
{
String
argNotifySign
=
getStringByStringMap
(
result
)
+
"&key="
+
partnerKey
;
String
notifySign
=
MD5Utils
.
md5
(
argNotifySign
).
toUpperCase
();
if
(
notifySign
.
equals
(
sign
))
{
return
true
;
}
else
{
return
false
;
}
}
public
static
String
getStringByStringMap
(
Map
<
String
,
String
>
map
)
{
SortedMap
<
String
,
Object
>
smap
=
new
TreeMap
<
String
,
Object
>(
map
);
StringBuffer
sb
=
new
StringBuffer
();
for
(
Map
.
Entry
<
String
,
Object
>
m
:
smap
.
entrySet
())
{
sb
.
append
(
m
.
getKey
()).
append
(
"="
).
append
(
m
.
getValue
()).
append
(
"&"
);
}
sb
.
delete
(
sb
.
length
()
-
1
,
sb
.
length
());
return
sb
.
toString
();
}
}
}
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