记得上下班打卡 | 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
424b7b69
Commit
424b7b69
authored
Apr 12, 2022
by
zhengfuxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 notify dragon
parent
dbd81a91
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
469 additions
and
94 deletions
+469
-94
liquidnet-service-notify-dev.yml
...-config/liquidnet-config/liquidnet-service-notify-dev.yml
+2
-0
liquidnet-service-notify-test.yml
...config/liquidnet-config/liquidnet-service-notify-test.yml
+3
-1
DragonServiceCommonBiz.java
.../liquidnet/service/dragon/biz/DragonServiceCommonBiz.java
+2
-1
AbstractPayChannelStrategyImpl.java
...channel/strategy/impl/AbstractPayChannelStrategyImpl.java
+11
-0
ApplepayImpl.java
...et/service/dragon/channel/strategy/impl/ApplepayImpl.java
+78
-0
PayController.java
...om/liquidnet/service/dragon/controller/PayController.java
+8
-12
PayNotifyController.java
...uidnet/service/dragon/controller/PayNotifyController.java
+76
-4
DragonOrderRefundsServiceImpl.java
...ce/dragon/service/impl/DragonOrderRefundsServiceImpl.java
+81
-76
DragonOrdersServiceImpl.java
.../service/dragon/service/impl/DragonOrdersServiceImpl.java
+103
-0
ApplepayUtils.java
...ava/com/liquidnet/service/dragon/utils/ApplepayUtils.java
+97
-0
DataUtils.java
...in/java/com/liquidnet/service/dragon/utils/DataUtils.java
+8
-0
No files found.
liquidnet-bus-config/liquidnet-config/liquidnet-service-notify-dev.yml
View file @
424b7b69
...
@@ -40,3 +40,5 @@ liquidnet:
...
@@ -40,3 +40,5 @@ liquidnet:
certs-path
:
/data/certs/dragon/unionpay/test
certs-path
:
/data/certs/dragon/unionpay/test
certs-prefix
:
acp_prod
certs-prefix
:
acp_prod
pfx-pwd
:
'
520360'
pfx-pwd
:
'
520360'
apple
:
urlVerify
:
https://sandbox.itunes.apple.com/verifyReceipt
liquidnet-bus-config/liquidnet-config/liquidnet-service-notify-test.yml
View file @
424b7b69
...
@@ -39,4 +39,6 @@ liquidnet:
...
@@ -39,4 +39,6 @@ liquidnet:
refund-url
:
https://gateway.95516.com
refund-url
:
https://gateway.95516.com
certs-path
:
/data/certs/dragon/unionpay/test
certs-path
:
/data/certs/dragon/unionpay/test
certs-prefix
:
acp_test
certs-prefix
:
acp_test
pfx-pwd
:
'
520360'
pfx-pwd
:
'
520360'
\ No newline at end of file
apple
:
urlVerify
:
https://sandbox.itunes.apple.com/verifyReceipt
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/biz/DragonServiceCommonBiz.java
View file @
424b7b69
...
@@ -56,6 +56,7 @@ public class DragonServiceCommonBiz {
...
@@ -56,6 +56,7 @@ public class DragonServiceCommonBiz {
// orders.setFinishedAt();
// orders.setFinishedAt();
orders
.
setCreatedAt
(
LocalDateTime
.
now
());
orders
.
setCreatedAt
(
LocalDateTime
.
now
());
// orders.setUpdatedAt();
// orders.setUpdatedAt();
orders
.
setReceiptData
(
dragonPayBaseReqDto
.
getReceiptData
());
long
startTime
=
System
.
currentTimeMillis
();
long
startTime
=
System
.
currentTimeMillis
();
...
@@ -72,7 +73,7 @@ public class DragonServiceCommonBiz {
...
@@ -72,7 +73,7 @@ public class DragonServiceCommonBiz {
,
orders
.
getNotifyUrl
(),
orders
.
getNotifyStatus
(),
orders
.
getPaymentType
(),
,
orders
.
getNotifyUrl
(),
orders
.
getNotifyStatus
(),
orders
.
getPaymentType
(),
orders
.
getPaymentId
(),
orders
.
getPaymentAt
()
orders
.
getPaymentId
(),
orders
.
getPaymentAt
()
,
orders
.
getFinishedAt
(),
orders
.
getCreatedAt
()
,
orders
.
getFinishedAt
(),
orders
.
getCreatedAt
()
,
orders
.
getUpdatedAt
(),
orders
.
getDeletedAt
()}
,
orders
.
getUpdatedAt
(),
orders
.
getDeletedAt
()
,
orders
.
getReceiptData
()
}
,
DragonConstant
.
MysqlRedisQueueEnum
.
DRAGON_PAY_KEY
.
getCode
()
,
DragonConstant
.
MysqlRedisQueueEnum
.
DRAGON_PAY_KEY
.
getCode
()
);
);
log
.
info
(
"redis-queue-sendMySqlRedis->耗时:{}"
,(
System
.
currentTimeMillis
()
-
startTime
)+
"毫秒"
);
log
.
info
(
"redis-queue-sendMySqlRedis->耗时:{}"
,(
System
.
currentTimeMillis
()
-
startTime
)+
"毫秒"
);
...
...
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/impl/AbstractPayChannelStrategyImpl.java
View file @
424b7b69
...
@@ -65,6 +65,17 @@ public abstract class AbstractPayChannelStrategyImpl implements IPayChannelStrat
...
@@ -65,6 +65,17 @@ public abstract class AbstractPayChannelStrategyImpl implements IPayChannelStrat
//通知商户
//通知商户
return
dragonPayBiz
.
sendNotify
(
dragonPayBiz
.
buildPayNotifyReqBo
(
dragonOrdersDto
));
return
dragonPayBiz
.
sendNotify
(
dragonPayBiz
.
buildPayNotifyReqBo
(
dragonOrdersDto
));
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
completeSuccessOrderNoNotify
(
DragonOrdersDto
dragonOrdersDto
,
String
bankTrxNo
,
LocalDateTime
timeEnd
,
String
bankReturnMsg
)
{
log
.
info
(
"订单支付成功!"
);
dragonOrdersDto
.
setPaymentAt
(
timeEnd
);
dragonOrdersDto
.
setPaymentId
(
bankTrxNo
);
// 设置银行流水号
dragonOrdersDto
.
setStatus
(
Integer
.
parseInt
(
DragonConstant
.
PayStatusEnum
.
STATUS_PAID
.
getCode
()));
//更新缓存
dataUtils
.
updateOrderStatus
(
dragonOrdersDto
.
getCode
(),
dragonOrdersDto
);
//修改订单状态
dragonServiceCommonBiz
.
updateOrderStatus
(
dragonOrdersDto
.
getCode
(),
dragonOrdersDto
.
getStatus
(),
bankTrxNo
);
}
/**
/**
* 支付失败方法
* 支付失败方法
...
...
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/impl/ApplepayImpl.java
0 → 100644
View file @
424b7b69
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
strategy
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.dragon.channel.strategy.annotation.StrategyPayChannelHandler
;
import
com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.dto.DragonOrdersDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseReqDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto
;
import
com.liquidnet.service.dragon.service.impl.DragonOrdersServiceImpl
;
import
com.liquidnet.service.dragon.utils.DataUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.http.HttpServletRequest
;
import
java.time.LocalDateTime
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: PayChannelStrategyAlipayImpl
* @Package com.liquidnet.service.dragon.channel.strategy.impl
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/13 13:06
*/
@Slf4j
@Component
@StrategyPayChannelHandler
(
DragonConstant
.
PayChannelEnum
.
APPLEPAY
)
public
class
ApplepayImpl
extends
AbstractPayChannelStrategyImpl
{
@Autowired
private
DataUtils
dataUtils
;
@Autowired
private
DragonOrdersServiceImpl
dragonOrdersService
;
@Autowired
private
DragonPayBiz
dragonPayBiz
;
public
void
completeSuccessOrder
(
DragonOrdersDto
dragonOrdersDto
,
String
code
,
String
result
){
this
.
completeSuccessOrderNoNotify
(
dragonOrdersDto
,
code
,
LocalDateTime
.
now
(),
result
);
}
@Override
public
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
return
null
;
}
@Override
public
String
dragonNotify
(
HttpServletRequest
request
,
String
payType
,
String
deviceFrom
)
{
return
null
;
}
@Override
public
DragonPayOrderQueryRespDto
checkOrderStatus
(
String
code
)
{
DragonOrdersDto
ordersDto
=
dataUtils
.
getPayOrderByCode
(
code
);
//调用 苹果效验
String
verifyResult
=
dragonOrdersService
.
buyAppVerify
(
ordersDto
.
getReceiptData
());
if
(
verifyResult
==
null
)
{
// 苹果服务器没有返回验证结果
log
.
info
(
"苹果支付查询(checkOrderStatus),查不到订单信息"
);
return
null
;
}
else
{
JSONObject
job
=
JSONObject
.
parseObject
(
verifyResult
);
String
states
=
job
.
getString
(
"status"
);
if
(
states
.
equals
(
"0"
))
{
// 前端所提供的收据是有效的 验证成功
DragonPayOrderQueryRespDto
respDto
=
dragonPayBiz
.
buildPayOrderQueryRespDto
(
ordersDto
);
respDto
.
setStatus
(
Integer
.
valueOf
(
DragonConstant
.
PayStatusEnum
.
STATUS_PAID
.
getCode
()));
return
respDto
;
}
}
return
null
;
}
}
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/controller/PayController.java
View file @
424b7b69
package
com
.
liquidnet
.
service
.
dragon
.
controller
;
package
com
.
liquidnet
.
service
.
dragon
.
controller
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @version V1.0
...
@@ -13,11 +9,11 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -13,11 +9,11 @@ import org.springframework.web.bind.annotation.RestController;
* @Copyright: LightNet @ Copyright (c) 2021
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/7/9 12:29
* @date 2021/7/9 12:29
*/
*/
@Slf4j
/*
@Slf4j
@RestController
@RestController
@RequestMapping("pay")
@RequestMapping("pay")
public class PayController {
public class PayController {
/*
@Autowired
@Autowired
private IDragonOrdersService dragonOrdersService;
private IDragonOrdersService dragonOrdersService;
*//**
*//**
...
@@ -79,10 +75,10 @@ public class PayController {
...
@@ -79,10 +75,10 @@ public class PayController {
dragonPayBaseReqDto.setType(type);
dragonPayBaseReqDto.setType(type);
dragonPayBaseReqDto.setPrice(price);
dragonPayBaseReqDto.setPrice(price);
dragonPayBaseReqDto.setAuthCode(authCode);
dragonPayBaseReqDto.setAuthCode(authCode);
//
if(StringUtil.isNotNull(name)&&name.length()>=32){
if(StringUtil.isNotNull(name)&&name.length()>=32){
//
name = name.substring(0,32);
name = name.substring(0,32);
//
}
}
dragonPayBaseReqDto.setName(
"正在现场"
);
dragonPayBaseReqDto.setName(
name
);
// if(StringUtil.isNotNull(detail)&&detail.length()>=64){
// if(StringUtil.isNotNull(detail)&&detail.length()>=64){
// detail = detail.substring(0,64);
// detail = detail.substring(0,64);
// }
// }
...
@@ -141,5 +137,5 @@ public class PayController {
...
@@ -141,5 +137,5 @@ public class PayController {
rs.put("code", code);
rs.put("code", code);
rs.put("result", "" + respDto);
rs.put("result", "" + respDto);
return ResponseDto.success(rs);
return ResponseDto.success(rs);
}
*/
}
}
}
*/
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/controller/PayNotifyController.java
View file @
424b7b69
package
com
.
liquidnet
.
service
.
dragon
.
controller
;
package
com
.
liquidnet
.
service
.
dragon
.
controller
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.commons.lang.util.StringUtil
;
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.service.IDragonOrdersService
;
import
com.liquidnet.service.dragon.service.IDragonOrdersService
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiResponse
;
import
io.swagger.annotations.ApiResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.constraints.NotNull
;
import
java.math.BigDecimal
;
/**
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @author AnJiabin <anjiabin@zhengzai.tv>
...
@@ -41,4 +45,72 @@ public class PayNotifyController {
...
@@ -41,4 +45,72 @@ public class PayNotifyController {
public
String
dragonNotify
(
@PathVariable
(
"payType"
)
String
payType
,
@PathVariable
(
"deviceFrom"
)
String
deviceFrom
,
HttpServletRequest
request
,
HttpServletResponse
respone
)
throws
Exception
{
public
String
dragonNotify
(
@PathVariable
(
"payType"
)
String
payType
,
@PathVariable
(
"deviceFrom"
)
String
deviceFrom
,
HttpServletRequest
request
,
HttpServletResponse
respone
)
throws
Exception
{
return
dragonOrdersService
.
dragonNotify
(
request
,
payType
,
deviceFrom
);
return
dragonOrdersService
.
dragonNotify
(
request
,
payType
,
deviceFrom
);
}
}
/**
* 苹果内购
*/
@PostMapping
(
"/apple/purchase"
)
@ApiOperation
(
"苹果内购回调"
)
@ApiResponse
(
code
=
200
,
message
=
"接口返回对象参数"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"payType"
,
value
=
"支付类型:alipay,wepay,unionpay,applepay"
,
example
=
"unionpay"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"deviceFrom"
,
value
=
"设备来源:web,wap,app,js,apple,micropay,inner"
,
example
=
"wap"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"type"
,
value
=
"业务类型:TICKET,PRODUCT,COST,MBEANS,LIVE,VIDEO,VIP,CLUB,STRAWBERRY"
,
example
=
"TICKET"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"price"
,
value
=
"支付金额"
,
example
=
"0.1"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"name"
,
value
=
"订单名称"
,
example
=
"测试订单001"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"detail"
,
value
=
"订单描述"
,
example
=
"测试订单001"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"orderId"
,
value
=
"订单id"
,
example
=
"orderId"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"orderCode"
,
value
=
"订单编号"
,
example
=
"ORDER0001"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"clientIp"
,
value
=
"客户端ip"
,
example
=
"127.0.0.1"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"notifyUrl"
,
value
=
"通知url"
,
example
=
"devdragon.zhengzai.tv"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"createDate"
,
value
=
"订单创建时间"
,
example
=
"2021-11-10 13:00:00"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
true
,
dataType
=
"String"
,
name
=
"expireTime"
,
value
=
"订单过期时间"
,
example
=
"1000"
),
@ApiImplicitParam
(
type
=
"form"
,
required
=
false
,
dataType
=
"String"
,
name
=
"authCode"
,
value
=
"付款码"
,
example
=
"1000"
),
})
public
ResponseDto
<
DragonPayBaseRespDto
>
dragonNotifyApple
(
@RequestParam
(
value
=
"payType"
)
@NotNull
(
message
=
"支付类型不能为空"
)
String
payType
,
@RequestParam
(
value
=
"deviceFrom"
)
@NotNull
(
message
=
"设备来源不能为空"
)
String
deviceFrom
,
@RequestParam
(
value
=
"openId"
,
required
=
false
)
String
openId
,
@RequestParam
(
value
=
"type"
)
@NotNull
(
message
=
"业务类型不能为空"
)
String
type
,
@RequestParam
(
value
=
"price"
)
@NotNull
(
message
=
"支付金额不能为空"
)
BigDecimal
price
,
@RequestParam
(
value
=
"name"
)
@NotNull
(
message
=
"订单名称不能为空"
)
String
name
,
@RequestParam
(
value
=
"detail"
)
@NotNull
(
message
=
"订单描述不能为空"
)
String
detail
,
@RequestParam
(
value
=
"orderCode"
)
@NotNull
(
message
=
"订单编号不能为空"
)
String
orderCode
,
@RequestParam
(
value
=
"orderId"
,
required
=
false
)
String
orderId
,
@RequestParam
(
value
=
"clientIp"
)
@NotNull
(
message
=
"客户端ip不能为空"
)
String
clientIp
,
@RequestParam
(
value
=
"notifyUrl"
)
@NotNull
(
message
=
"通知Url不能为空"
)
String
notifyUrl
,
@RequestParam
(
value
=
"returnUrl"
,
required
=
false
)
String
returnUrl
,
@RequestParam
(
value
=
"showUrl"
,
required
=
false
)
String
showUrl
,
@RequestParam
(
value
=
"createDate"
,
required
=
true
)
String
createDate
,
@RequestParam
(
value
=
"expireTime"
,
required
=
true
)
String
expireTime
,
@RequestParam
(
value
=
"receiptData"
,
required
=
true
)
String
receiptData
,
@RequestParam
(
value
=
"transactionId"
,
required
=
true
)
String
transactionId
)
throws
Exception
{
long
startTime
=
System
.
currentTimeMillis
();
DragonPayBaseReqDto
dragonPayBaseReqDto
=
DragonPayBaseReqDto
.
getNew
();
dragonPayBaseReqDto
.
setPayType
(
payType
);
dragonPayBaseReqDto
.
setDeviceFrom
(
deviceFrom
);
dragonPayBaseReqDto
.
setType
(
type
);
dragonPayBaseReqDto
.
setPrice
(
price
);
if
(
StringUtil
.
isNotNull
(
name
)&&
name
.
length
()>=
32
){
name
=
name
.
substring
(
0
,
32
);
}
dragonPayBaseReqDto
.
setName
(
name
);
dragonPayBaseReqDto
.
setDetail
(
"正在现场"
);
dragonPayBaseReqDto
.
setOrderCode
(
orderCode
);
if
(
orderId
!=
null
)
{
dragonPayBaseReqDto
.
setOrderId
(
orderId
);
}
dragonPayBaseReqDto
.
setClientIp
(
clientIp
);
dragonPayBaseReqDto
.
setNotifyUrl
(
notifyUrl
);
dragonPayBaseReqDto
.
setReturnUrl
(
returnUrl
);
dragonPayBaseReqDto
.
setShowUrl
(
showUrl
);
dragonPayBaseReqDto
.
setCreateDate
(
createDate
);
dragonPayBaseReqDto
.
setExpireTime
(
expireTime
);
dragonPayBaseReqDto
.
setCode
(
IDGenerator
.
payCode
());
dragonPayBaseReqDto
.
setReceiptData
(
receiptData
);
dragonPayBaseReqDto
.
setTransactionId
(
transactionId
);
//调用苹果
return
ResponseDto
.
success
(
dragonOrdersService
.
dragonNotifyApple
(
dragonPayBaseReqDto
));
}
}
}
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/service/impl/DragonOrderRefundsServiceImpl.java
View file @
424b7b69
This diff is collapsed.
Click to expand it.
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/service/impl/DragonOrdersServiceImpl.java
View file @
424b7b69
package
com
.
liquidnet
.
service
.
dragon
.
service
.
impl
;
package
com
.
liquidnet
.
service
.
dragon
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.dragon.biz.DragonServiceCommonBiz
;
import
com.liquidnet.service.dragon.channel.strategy.PayChannelStrategyContext
;
import
com.liquidnet.service.dragon.channel.strategy.PayChannelStrategyContext
;
import
com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz
;
import
com.liquidnet.service.dragon.channel.strategy.biz.DragonPayBiz
;
import
com.liquidnet.service.dragon.channel.strategy.impl.ApplepayImpl
;
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.constant.DragonErrorCodeEnum
;
import
com.liquidnet.service.dragon.dto.DragonOrdersDto
;
import
com.liquidnet.service.dragon.dto.DragonOrdersDto
;
...
@@ -13,17 +17,29 @@ import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
...
@@ -13,17 +17,29 @@ 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.dto.DragonPayOrderQueryRespDto
;
import
com.liquidnet.service.dragon.service.IDragonOrdersService
;
import
com.liquidnet.service.dragon.service.IDragonOrdersService
;
import
com.liquidnet.service.dragon.utils.ApplepayUtils
;
import
com.liquidnet.service.dragon.utils.DataUtils
;
import
com.liquidnet.service.dragon.utils.DataUtils
;
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.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.SortedMap
;
import
java.util.TreeMap
;
@Slf4j
@Slf4j
@Service
@Service
public
class
DragonOrdersServiceImpl
implements
IDragonOrdersService
{
public
class
DragonOrdersServiceImpl
implements
IDragonOrdersService
{
@Value
(
"${apple.urlVerify}"
)
private
String
appleUrl
;
@Autowired
@Autowired
StringRedisTemplate
stringRedisTemplate
;
StringRedisTemplate
stringRedisTemplate
;
...
@@ -35,6 +51,10 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
...
@@ -35,6 +51,10 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
@Autowired
@Autowired
private
DragonPayBiz
dragonPayBiz
;
private
DragonPayBiz
dragonPayBiz
;
@Autowired
private
DragonServiceCommonBiz
dragonServiceCommonBiz
;
@Autowired
private
ApplepayImpl
applepay
;
@Override
@Override
public
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
public
ResponseDto
<
DragonPayBaseRespDto
>
dragonPay
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
...
@@ -75,8 +95,91 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
...
@@ -75,8 +95,91 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
return
dragonPayBiz
.
sendNotify
(
dragonPayBiz
.
buildPayNotifyReqBo
(
ordersDto
));
return
dragonPayBiz
.
sendNotify
(
dragonPayBiz
.
buildPayNotifyReqBo
(
ordersDto
));
}
}
/**
* 苹果支付
* @param dragonPayBaseReqDto
*/
@Override
@Override
public
DragonPayBaseRespDto
dragonNotifyApple
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
public
DragonPayBaseRespDto
dragonNotifyApple
(
DragonPayBaseReqDto
dragonPayBaseReqDto
)
{
//1 调用苹果查询结果
String
verifyResult
=
buyAppVerify
(
dragonPayBaseReqDto
.
getReceiptData
());
if
(
verifyResult
==
null
)
{
// 苹果服务器没有返回验证结果
log
.
info
(
"苹果支付,app调用,查不到订单信息"
);
return
null
;
}
else
{
JSONObject
job
=
JSONObject
.
parseObject
(
verifyResult
);
String
states
=
job
.
getString
(
"status"
);
if
(
states
.
equals
(
"0"
)){
// 前端所提供的收据是有效的 验证成功
String
r_receipt
=
job
.
getString
(
"receipt"
);
JSONObject
returnJson
=
JSONObject
.
parseObject
(
r_receipt
);
String
in_app
=
returnJson
.
getString
(
"in_app"
);
JSONObject
in_appJson
=
JSONObject
.
parseObject
(
in_app
.
substring
(
1
,
in_app
.
length
()
-
1
));
/* ApplePayRefundDto applePayRefundDto=ApplePayRefundDto.getNew();*/
String
product_id
=
in_appJson
.
getString
(
"product_id"
);
/*applePayRefundDto.setProductId(product_id);*/
String
transaction_id
=
in_appJson
.
getString
(
"transaction_id"
);
// 订单号
//如果单号一致 则开始处理逻辑
if
(
dragonPayBaseReqDto
.
getTransactionId
().
equals
(
transaction_id
)){
//判断是已经查过了。
DragonPayBaseRespDto
dragonPayBaseRespDto
=
dataUtils
.
getDragonPayBaseRespDto
(
dragonPayBaseReqDto
.
getOrderCode
());
if
(
null
!=
dragonPayBaseRespDto
){
return
dragonPayBaseRespDto
;
}
/*String[] moneys = product_id.split("\\.");//实际支付金额*/
//此处开始业务逻辑
//2 插入支付该支付的东西(预支付的东西)//dragon_orders
dragonServiceCommonBiz
.
buildPayOrders
(
dragonPayBaseReqDto
,
null
);
//第二部
//持久化通知记录
dragonServiceCommonBiz
.
createDragonOrderLogs
(
dragonPayBaseReqDto
.
getCode
(),
dragonPayBiz
.
getPaymentType
(
dragonPayBaseReqDto
.
getPayType
(),
dragonPayBaseReqDto
.
getDeviceFrom
()),
verifyResult
);
//修改状态
applepay
.
completeSuccessOrder
(
dataUtils
.
getPayOrderByCode
(
dragonPayBaseReqDto
.
getCode
()),
transaction_id
,
verifyResult
);
//
DragonPayBaseRespDto
respDto
=
buildCommonRespDto
(
dragonPayBaseReqDto
);
respDto
.
setProductId
(
product_id
);
dataUtils
.
createAPPLePayOrder
(
dragonPayBaseReqDto
.
getOrderCode
(),
respDto
);
return
respDto
;
}
}
else
{
return
null
;
}
}
return
null
;
}
public
String
buyAppVerify
(
String
receipt
)
{
try
{
SortedMap
<
String
,
Object
>
parameters
=
new
TreeMap
<>();
parameters
.
put
(
"receipt-data"
,
receipt
);
String
data
=
JSON
.
toJSONString
(
parameters
);
HttpPost
httpost
=
new
HttpPost
(
appleUrl
);
httpost
.
setEntity
(
new
StringEntity
(
data
,
"UTF-8"
));
CloseableHttpResponse
response
=
ApplepayUtils
.
getInstance
().
getHttpClient
().
execute
(
httpost
);
HttpEntity
entity
=
response
.
getEntity
();
//接受到返回信息
String
returnDate
=
EntityUtils
.
toString
(
response
.
getEntity
(),
"UTF-8"
);
EntityUtils
.
consume
(
entity
);
log
.
info
(
"苹果支付完成后查询{} "
,
returnDate
);
return
returnDate
;
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
());
}
return
null
;
return
null
;
}
}
/**
* 构造公共返回参数
* @param dragonPayBaseReqDto
* @return
*/
protected
DragonPayBaseRespDto
buildCommonRespDto
(
DragonPayBaseReqDto
dragonPayBaseReqDto
){
DragonPayBaseRespDto
respDto
=
new
DragonPayBaseRespDto
();
respDto
.
setPayType
(
dragonPayBaseReqDto
.
getPayType
());
respDto
.
setCode
(
dragonPayBaseReqDto
.
getCode
());
respDto
.
setOrderCode
(
dragonPayBaseReqDto
.
getOrderCode
());
DragonPayBaseRespDto
.
PayData
payData
=
new
DragonPayBaseRespDto
.
PayData
();
respDto
.
setPayData
(
payData
);
return
respDto
;
}
}
}
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/utils/ApplepayUtils.java
0 → 100644
View file @
424b7b69
package
com
.
liquidnet
.
service
.
dragon
.
utils
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.config.Registry
;
import
org.apache.http.config.RegistryBuilder
;
import
org.apache.http.conn.socket.ConnectionSocketFactory
;
import
org.apache.http.conn.socket.PlainConnectionSocketFactory
;
import
org.apache.http.conn.ssl.SSLConnectionSocketFactory
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.DefaultHttpRequestRetryHandler
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.impl.conn.PoolingHttpClientConnectionManager
;
import
javax.net.ssl.SSLContext
;
import
javax.net.ssl.TrustManager
;
import
javax.net.ssl.X509TrustManager
;
import
java.security.cert.CertificateException
;
import
java.security.cert.X509Certificate
;
public
class
ApplepayUtils
{
private
static
class
TrustAnyTrustManager
implements
X509TrustManager
{
public
void
checkClientTrusted
(
X509Certificate
[]
chain
,
String
authType
)
throws
CertificateException
{
}
public
void
checkServerTrusted
(
X509Certificate
[]
chain
,
String
authType
)
throws
CertificateException
{
}
public
X509Certificate
[]
getAcceptedIssuers
()
{
return
new
X509Certificate
[]
{};
}
}
private
CloseableHttpClient
httpClient
;
private
static
ApplepayUtils
instance
=
new
ApplepayUtils
();
// 池化管理
private
static
PoolingHttpClientConnectionManager
poolConnManager
=
null
;
public
ApplepayUtils
()
{
}
public
static
ApplepayUtils
getInstance
()
{
return
instance
;
}
public
CloseableHttpClient
getHttpClient
()
{
try
{
if
(
httpClient
==
null
)
{
/* SSLContext sslcontext = SSLContexts.custom()
.loadKeyMaterial(keyStore, merchantId.toCharArray())
.build();
*/
SSLContext
sslcontext
=
SSLContext
.
getInstance
(
"SSL"
);
sslcontext
.
init
(
null
,
new
TrustManager
[]
{
new
TrustAnyTrustManager
()
},
new
java
.
security
.
SecureRandom
());
SSLConnectionSocketFactory
sslsf
=
new
SSLConnectionSocketFactory
(
sslcontext
,
SSLConnectionSocketFactory
.
getDefaultHostnameVerifier
());
// 配置同时支持 HTTP 和 HTPPS
Registry
<
ConnectionSocketFactory
>
socketFactoryRegistry
=
RegistryBuilder
.<
ConnectionSocketFactory
>
create
().
register
(
"http"
,
PlainConnectionSocketFactory
.
getSocketFactory
()).
register
(
"https"
,
sslsf
).
build
();
// 初始化连接管理器
poolConnManager
=
new
PoolingHttpClientConnectionManager
(
socketFactoryRegistry
);
poolConnManager
.
setMaxTotal
(
4000
);
// 同时最多连接数
// 设置最大路由
poolConnManager
.
setDefaultMaxPerRoute
(
2000
);
// 初始化httpClient
httpClient
=
getConnection
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
httpClient
;
}
public
static
CloseableHttpClient
getConnection
()
{
RequestConfig
config
=
RequestConfig
.
custom
().
setConnectTimeout
(
5000
).
setConnectionRequestTimeout
(
5000
).
setSocketTimeout
(
5000
).
build
();
CloseableHttpClient
httpClient
=
HttpClients
.
custom
()
// 设置连接池管理
.
setConnectionManager
(
poolConnManager
)
.
setDefaultRequestConfig
(
config
)
// 设置重试次数
.
setRetryHandler
(
new
DefaultHttpRequestRetryHandler
(
2
,
false
)).
build
();
return
httpClient
;
}
public
static
void
main
(
String
[]
args
)
{
}
}
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/utils/DataUtils.java
View file @
424b7b69
...
@@ -3,6 +3,7 @@ package com.liquidnet.service.dragon.utils;
...
@@ -3,6 +3,7 @@ package com.liquidnet.service.dragon.utils;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.constant.DragonConstant
;
import
com.liquidnet.service.dragon.dto.DragonOrdersDto
;
import
com.liquidnet.service.dragon.dto.DragonOrdersDto
;
import
com.liquidnet.service.dragon.dto.DragonPayBaseRespDto
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -16,6 +17,13 @@ public class DataUtils {
...
@@ -16,6 +17,13 @@ public class DataUtils {
public
void
createPayOrder
(
String
code
,
DragonOrdersDto
ordersDto
)
{
public
void
createPayOrder
(
String
code
,
DragonOrdersDto
ordersDto
)
{
redisUtil
.
set
(
DragonConstant
.
REDIS_KET_PAY_CODE
+
code
,
ordersDto
,
keyExpireTime
);
redisUtil
.
set
(
DragonConstant
.
REDIS_KET_PAY_CODE
+
code
,
ordersDto
,
keyExpireTime
);
}
}
public
void
createAPPLePayOrder
(
String
orderCode
,
DragonPayBaseRespDto
dragonPayBaseRespDto
)
{
redisUtil
.
set
(
DragonConstant
.
REDIS_KET_ORDERCODE_PAY_CODE
+
orderCode
,
dragonPayBaseRespDto
,
keyExpireTime
);
}
public
DragonPayBaseRespDto
getDragonPayBaseRespDto
(
String
orderCode
){
return
(
DragonPayBaseRespDto
)
redisUtil
.
get
(
DragonConstant
.
REDIS_KET_ORDERCODE_PAY_CODE
+
orderCode
);
}
public
DragonOrdersDto
getPayOrderByCode
(
String
code
)
{
public
DragonOrdersDto
getPayOrderByCode
(
String
code
)
{
Object
obj
=
redisUtil
.
get
(
DragonConstant
.
REDIS_KET_PAY_CODE
+
code
);
Object
obj
=
redisUtil
.
get
(
DragonConstant
.
REDIS_KET_PAY_CODE
+
code
);
...
...
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