Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Jeepay
Commits
e1b32b33
Commit
e1b32b33
authored
Aug 13, 2021
by
terrfly
Browse files
添加支付宝转账接口;
parent
c165e609
Changes
6
Hide whitespace changes
Inline
Side-by-side
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/ITransferService.java
View file @
e1b32b33
...
...
@@ -36,7 +36,7 @@ public interface ITransferService {
boolean
isSupport
(
String
entryType
);
/** 前置检查如参数等信息是否符合要求, 返回错误信息或直接抛出异常即可 */
String
preCheck
(
TransferOrderRQ
bizRQ
,
TransferOrder
refund
Order
);
String
preCheck
(
TransferOrderRQ
bizRQ
,
TransferOrder
transfer
Order
);
/** 调起退款接口,并响应数据; 内部处理普通商户和服务商模式 **/
ChannelRetMsg
transfer
(
TransferOrderRQ
bizRQ
,
TransferOrder
refundOrder
,
MchAppConfigContext
mchAppConfigContext
)
throws
Exception
;
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/AlipayKit.java
View file @
e1b32b33
...
...
@@ -67,6 +67,8 @@ public class AlipayKit {
((
AlipayTradeRefundRequest
)
req
).
putOtherTextParam
(
"app_auth_token"
,
isvsubMchParams
.
getAppAuthToken
());
}
else
if
(
req
instanceof
AlipayTradeFastpayRefundQueryRequest
)
{
((
AlipayTradeFastpayRefundQueryRequest
)
req
).
putOtherTextParam
(
"app_auth_token"
,
isvsubMchParams
.
getAppAuthToken
());
}
else
if
(
req
instanceof
AlipayFundTransToaccountTransferRequest
)
{
((
AlipayFundTransToaccountTransferRequest
)
req
).
putOtherTextParam
(
"app_auth_token"
,
isvsubMchParams
.
getAppAuthToken
());
}
// 服务商信息
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/AlipayTransferService.java
0 → 100644
View file @
e1b32b33
/*
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <p>
* 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.jeequan.jeepay.pay.channel.alipay
;
import
com.alipay.api.domain.AlipayFundTransToaccountTransferModel
;
import
com.alipay.api.request.AlipayFundTransToaccountTransferRequest
;
import
com.alipay.api.response.AlipayFundTransToaccountTransferResponse
;
import
com.alipay.api.response.AlipayTradeRefundResponse
;
import
com.jeequan.jeepay.core.constants.CS
;
import
com.jeequan.jeepay.core.entity.TransferOrder
;
import
com.jeequan.jeepay.core.utils.AmountUtil
;
import
com.jeequan.jeepay.pay.channel.ITransferService
;
import
com.jeequan.jeepay.pay.model.MchAppConfigContext
;
import
com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg
;
import
com.jeequan.jeepay.pay.rqrs.transfer.TransferOrderRQ
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
/**
* 转账接口: 支付宝官方
*
* @author terrfly
* @site https://www.jeepay.vip
* @date 2021/8/11 14:05
*/
@Slf4j
@Service
public
class
AlipayTransferService
implements
ITransferService
{
@Override
public
String
getIfCode
()
{
return
CS
.
IF_CODE
.
ALIPAY
;
}
@Override
public
boolean
isSupport
(
String
entryType
)
{
// 支付宝账户
if
(
TransferOrder
.
ENTRY_ALIPAY_CASH
.
equals
(
entryType
)){
return
true
;
}
return
false
;
}
@Override
public
String
preCheck
(
TransferOrderRQ
bizRQ
,
TransferOrder
transferOrder
)
{
return
null
;
}
@Override
public
ChannelRetMsg
transfer
(
TransferOrderRQ
bizRQ
,
TransferOrder
transferOrder
,
MchAppConfigContext
mchAppConfigContext
){
AlipayFundTransToaccountTransferRequest
request
=
new
AlipayFundTransToaccountTransferRequest
();
AlipayFundTransToaccountTransferModel
model
=
new
AlipayFundTransToaccountTransferModel
();
model
.
setAmount
(
AmountUtil
.
convertCent2Dollar
(
transferOrder
.
getAmount
()));
//转账金额,单位:元。
model
.
setOutBizNo
(
transferOrder
.
getTransferId
());
//商户转账唯一订单号
model
.
setPayeeType
(
"ALIPAY_LOGONID"
);
//ALIPAY_USERID: 支付宝用户ID ALIPAY_LOGONID:支付宝登录账号
model
.
setPayeeAccount
(
transferOrder
.
getAccountNo
());
//收款方账户
model
.
setPayeeRealName
(
StringUtils
.
defaultString
(
transferOrder
.
getAccountName
(),
null
));
//收款方真实姓名
model
.
setRemark
(
transferOrder
.
getTransferDesc
());
//转账备注
request
.
setBizModel
(
model
);
//统一放置 isv接口必传信息
AlipayKit
.
putApiIsvInfo
(
mchAppConfigContext
,
request
,
model
);
// 调起支付宝接口
AlipayFundTransToaccountTransferResponse
response
=
mchAppConfigContext
.
getAlipayClientWrapper
().
execute
(
request
);
ChannelRetMsg
channelRetMsg
=
new
ChannelRetMsg
();
channelRetMsg
.
setChannelAttach
(
response
.
getBody
());
// 调用成功
if
(
response
.
isSuccess
()){
channelRetMsg
.
setChannelState
(
ChannelRetMsg
.
ChannelState
.
CONFIRM_SUCCESS
);
channelRetMsg
.
setChannelOrderId
(
response
.
getOrderId
());
}
else
{
//若 系统繁忙, 无法确认结果
if
(
"SYSTEM_ERROR"
.
equalsIgnoreCase
(
response
.
getSubCode
())){
return
ChannelRetMsg
.
waiting
();
}
channelRetMsg
.
setChannelState
(
ChannelRetMsg
.
ChannelState
.
CONFIRM_FAIL
);
channelRetMsg
.
setChannelErrCode
(
response
.
getSubCode
());
channelRetMsg
.
setChannelErrMsg
(
response
.
getSubMsg
());
}
return
channelRetMsg
;
}
}
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/transfer/QueryTransferOrderController.java
0 → 100644
View file @
e1b32b33
/*
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <p>
* 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.jeequan.jeepay.pay.ctrl.transfer
;
import
com.jeequan.jeepay.core.entity.TransferOrder
;
import
com.jeequan.jeepay.core.exception.BizException
;
import
com.jeequan.jeepay.core.model.ApiRes
;
import
com.jeequan.jeepay.pay.ctrl.ApiController
;
import
com.jeequan.jeepay.pay.rqrs.transfer.QueryTransferOrderRQ
;
import
com.jeequan.jeepay.pay.rqrs.transfer.QueryTransferOrderRS
;
import
com.jeequan.jeepay.pay.service.ConfigContextService
;
import
com.jeequan.jeepay.service.impl.TransferOrderService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* 商户转账单查询controller
*
* @author terrfly
* @site https://www.jeequan.com
* @date 2021/8/13 15:20
*/
@Slf4j
@RestController
public
class
QueryTransferOrderController
extends
ApiController
{
@Autowired
private
TransferOrderService
transferOrderService
;
@Autowired
private
ConfigContextService
configContextService
;
/**
* 查单接口
* **/
@RequestMapping
(
"/api/transfer/query"
)
public
ApiRes
queryTransferOrder
(){
//获取参数 & 验签
QueryTransferOrderRQ
rq
=
getRQByWithMchSign
(
QueryTransferOrderRQ
.
class
);
if
(
StringUtils
.
isAllEmpty
(
rq
.
getMchOrderNo
(),
rq
.
getTransferId
())){
throw
new
BizException
(
"mchOrderNo 和 transferId不能同时为空"
);
}
TransferOrder
refundOrder
=
transferOrderService
.
queryMchOrder
(
rq
.
getMchNo
(),
rq
.
getMchOrderNo
(),
rq
.
getTransferId
());
if
(
refundOrder
==
null
){
throw
new
BizException
(
"订单不存在"
);
}
QueryTransferOrderRS
bizRes
=
QueryTransferOrderRS
.
buildByRecord
(
refundOrder
);
return
ApiRes
.
okWithSign
(
bizRes
,
configContextService
.
getMchAppConfigContext
(
rq
.
getMchNo
(),
rq
.
getAppId
()).
getMchApp
().
getAppSecret
());
}
}
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/rqrs/transfer/QueryTransferOrderRQ.java
View file @
e1b32b33
...
...
@@ -29,7 +29,7 @@ import lombok.Data;
public
class
QueryTransferOrderRQ
extends
AbstractMchAppRQ
{
/** 商户转账单号 **/
private
String
mch
Refund
No
;
private
String
mch
Order
No
;
/** 支付系统转账单号 **/
private
String
transferId
;
...
...
jeepay-service/src/main/java/com/jeequan/jeepay/service/impl/TransferOrderService.java
View file @
e1b32b33
...
...
@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.jeequan.jeepay.core.entity.TransferOrder
;
import
com.jeequan.jeepay.service.mapper.TransferOrderMapper
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -98,5 +99,19 @@ public class TransferOrderService extends ServiceImpl<TransferOrderMapper, Trans
/** 查询商户订单 **/
public
TransferOrder
queryMchOrder
(
String
mchNo
,
String
mchOrderNo
,
String
transferId
){
if
(
StringUtils
.
isNotEmpty
(
transferId
)){
return
getOne
(
TransferOrder
.
gw
().
eq
(
TransferOrder:
:
getMchNo
,
mchNo
).
eq
(
TransferOrder:
:
getTransferId
,
transferId
));
}
else
if
(
StringUtils
.
isNotEmpty
(
mchOrderNo
)){
return
getOne
(
TransferOrder
.
gw
().
eq
(
TransferOrder:
:
getMchNo
,
mchNo
).
eq
(
TransferOrder:
:
getMchOrderNo
,
mchOrderNo
));
}
else
{
return
null
;
}
}
}
Write
Preview
Supports
Markdown
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