11
This commit is contained in:
1 parent
4f50cc2952
commit
5d0e19ae1e
9 files changed
+102
-14
No files matched your search
+7
@@ -28,4 +28,11 @@ public interface RemoterThirdAppPlusPayService {
|
||||
@PostMapping("/pay-remoter/micropay")
|
||||
R<String> remoterMicropay(@RequestBody ThirdMicropayDto dto);
|
||||
|
||||
/**
|
||||
* 支付退款
|
||||
*/
|
||||
@NoToken
|
||||
@PostMapping("/pay-remoter/refund")
|
||||
R<String> remoterRefund(@RequestBody ThirdMicropayDto dto);
|
||||
|
||||
}
|
||||
+1
-1
@@ -13,7 +13,7 @@ import java.util.Arrays;
|
||||
@Getter
|
||||
public enum ThirdPayOrderBizTypeEnum {
|
||||
|
||||
MINI_APP_RECHARGE("10", "小程序用户钱包充值"),
|
||||
MINI_APP_WALLET_RECHARGE("10", "小程序用户钱包充值"),
|
||||
YXFJ_PAY("20", "云消费机付款码支付"),
|
||||
;
|
||||
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.bsd.pjcloud.thirdparty.dto.appplus;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ThirdRemoterRefundDto {
|
||||
|
||||
/**
|
||||
* 订单id
|
||||
*/
|
||||
@NotNull(message = "订单id不能为空")
|
||||
private Long orderId;
|
||||
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
@NotNull(message = "退款金额不能为空")
|
||||
private Integer price;
|
||||
|
||||
}
|
||||
+7
@@ -6,6 +6,7 @@ import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import com.bsd.pjcloud.thirdparty.constant.miniplatform.AppPlusPlatformPayType;
|
||||
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdMicropayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdRemoterRefundDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.appplus.pay.wechat.ThirdMiniWechatRefundDto;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdAppPlusService;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdAppPlusWechatFzService;
|
||||
@@ -40,6 +41,12 @@ public class ThirdAppPlusController {
|
||||
|
||||
/* ************************************* start 远程调用 start ************************************* */
|
||||
|
||||
@Operation(summary = "支付退款")
|
||||
@PostMapping("/refund")
|
||||
public R<ThirdMiniAppPayVo> remoterRefund(@Valid @RequestBody ThirdRemoterRefundDto dto) {
|
||||
return R.ok(thirdAppPlusService.remoterRefund(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "付款码支付")
|
||||
@PostMapping("/micropay")
|
||||
@Inner
|
||||
|
||||
+9
-6
@@ -1,14 +1,12 @@
|
||||
package com.bsd.pjcloud.thirdparty.service;
|
||||
|
||||
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdMicropayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdMiniAppGetUniqueDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdMiniAppOAth2LoginDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdMiniAppPayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.appplus.*;
|
||||
import com.bsd.pjcloud.thirdparty.dto.appplus.pay.wechat.ThirdMiniWechatRefundDto;
|
||||
import com.bsd.pjcloud.thirdparty.entity.pay.ThirdPayOrderEntity;
|
||||
import com.bsd.pjcloud.thirdparty.vo.appplus.ThirdMinAppOAth2LoginVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.appplus.pay.ThirdMiniAppPayVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.pay.ThirdPayOrderVo;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -37,13 +35,18 @@ public interface ThirdAppPlusService {
|
||||
/**
|
||||
* 付款码支付
|
||||
*/
|
||||
String micropay(ThirdMicropayDto dto );
|
||||
String micropay(ThirdMicropayDto dto);
|
||||
|
||||
/**
|
||||
* 小程序退款
|
||||
* 退款
|
||||
*/
|
||||
ThirdMiniAppPayVo miniRefund(ThirdMiniWechatRefundDto dto);
|
||||
|
||||
/**
|
||||
* 远程退款
|
||||
*/
|
||||
ThirdMiniAppPayVo remoterRefund(@Valid ThirdRemoterRefundDto dto);
|
||||
|
||||
/**
|
||||
* 小程序支付回调
|
||||
*/
|
||||
|
||||
+3
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPayOrderBizTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.ThirdPayOrderDto;
|
||||
import com.bsd.pjcloud.thirdparty.entity.pay.ThirdPayOrderEntity;
|
||||
import com.bsd.pjcloud.thirdparty.vo.pay.ThirdPayOrderVo;
|
||||
@@ -14,5 +15,7 @@ public interface ThirdPayOrderService extends IService<ThirdPayOrderEntity> {
|
||||
|
||||
ThirdPayOrderEntity getByPayNo(String payNo);
|
||||
|
||||
ThirdPayOrderEntity getByBiz(ThirdPayOrderBizTypeEnum bizType, String bizId);
|
||||
|
||||
|
||||
}
|
||||
+43
-5
@@ -22,10 +22,7 @@ import com.bsd.pjcloud.thirdparty.constant.miniplatform.AppPlusPlatformPayType;
|
||||
import com.bsd.pjcloud.thirdparty.constant.miniplatform.AppPlusPlatformTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPayOrderBizTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPayOrderStatusEnum;
|
||||
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdMicropayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdMiniAppGetUniqueDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdMiniAppOAth2LoginDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.appplus.ThirdMiniAppPayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.appplus.*;
|
||||
import com.bsd.pjcloud.thirdparty.dto.appplus.pay.wechat.ThirdAppPlusPayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.appplus.pay.wechat.ThirdMiniWechatRefundDto;
|
||||
import com.bsd.pjcloud.thirdparty.entity.pay.ThirdPayOrderEntity;
|
||||
@@ -194,7 +191,7 @@ public class ThirdAppPlusServiceImpl implements ThirdAppPlusService {
|
||||
|
||||
List<MchPaySettingVo> paySettingList = mchManage.getPaySettingList();
|
||||
|
||||
if (ObjectUtil.equals(dto.getBizType(), ThirdPayOrderBizTypeEnum.MINI_APP_RECHARGE)) {
|
||||
if (ObjectUtil.equals(dto.getBizType(), ThirdPayOrderBizTypeEnum.MINI_APP_WALLET_RECHARGE)) {
|
||||
|
||||
Long bizId = null;
|
||||
try {
|
||||
@@ -381,6 +378,41 @@ public class ThirdAppPlusServiceImpl implements ThirdAppPlusService {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程退款
|
||||
*/
|
||||
@Override
|
||||
public ThirdMiniAppPayVo remoterRefund(ThirdRemoterRefundDto dto) {
|
||||
// 查询详情
|
||||
ThirdPayOrderEntity thirdPayOrder = thirdPayOrderService.getByBiz(ThirdPayOrderBizTypeEnum.YXFJ_PAY, String.valueOf(dto.getOrderId()));
|
||||
if (ObjectUtil.isEmpty(thirdPayOrder)) {
|
||||
log.error("|{}|远程退款,订单不存在dto:|{}|", TAG, JSONUtil.toJsonStr(dto));
|
||||
throw new RuntimeException("订单不存在");
|
||||
}
|
||||
|
||||
ThirdMiniWechatRefundDto refundDto = new ThirdMiniWechatRefundDto();
|
||||
refundDto.setPayNo(thirdPayOrder.getPayNo());
|
||||
refundDto.setRefundPrice(dto.getPrice());
|
||||
// 微信小程序
|
||||
if (ObjectUtil.equals(thirdPayOrder.getPayPlatformType(), AppPlusPlatformTypeEnum.WECHAT.getType())) {
|
||||
thirdMiniAppWechatService.refund(thirdPayOrder, refundDto);
|
||||
}
|
||||
// 支付宝
|
||||
else if (ObjectUtil.equals(thirdPayOrder.getPayPlatformType(), AppPlusPlatformTypeEnum.ALI_PAY.getType())) {
|
||||
boolean isRefund = thirdMiniAppAliPayService.refund(thirdPayOrder, refundDto);
|
||||
if (isRefund) {
|
||||
// 再查询一下
|
||||
thirdPayOrder = thirdPayOrderService.getByBiz(ThirdPayOrderBizTypeEnum.YXFJ_PAY, String.valueOf(dto.getOrderId()));
|
||||
disposeRefundSuccessAfter(thirdPayOrder);
|
||||
}
|
||||
}
|
||||
// 不支持的支付类型
|
||||
else {
|
||||
throw new RuntimeException("不支持的支付类型");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序支付回调
|
||||
*/
|
||||
@@ -578,6 +610,9 @@ public class ThirdAppPlusServiceImpl implements ThirdAppPlusService {
|
||||
if (ObjectUtil.notEqual(thirdPayOrder.getStatus(), ThirdPayOrderStatusEnum.PAY_SUCCESS.getType())) {
|
||||
return true;
|
||||
}
|
||||
if (ObjectUtil.notEqual(thirdPayOrder.getBizType(), ThirdPayOrderBizTypeEnum.MINI_APP_WALLET_RECHARGE.getType())) {
|
||||
return true;
|
||||
}
|
||||
// 已经支付
|
||||
try {
|
||||
WalletRechargePaySuccess dto = new WalletRechargePaySuccess();
|
||||
@@ -596,6 +631,9 @@ public class ThirdAppPlusServiceImpl implements ThirdAppPlusService {
|
||||
if (ObjectUtil.notEqual(thirdPayOrder.getStatus(), ThirdPayOrderStatusEnum.REFUND_SUCCESS.getType())) {
|
||||
return true;
|
||||
}
|
||||
if (ObjectUtil.notEqual(thirdPayOrder.getBizType(), ThirdPayOrderBizTypeEnum.MINI_APP_WALLET_RECHARGE.getType())) {
|
||||
return true;
|
||||
}
|
||||
// 已退款
|
||||
try {
|
||||
WalletRechargeRefundSuccess dto = new WalletRechargeRefundSuccess();
|
||||
|
||||
+9
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysUser;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPayOrderBizTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.ThirdPayOrderDto;
|
||||
import com.bsd.pjcloud.thirdparty.entity.pay.ThirdPayOrderEntity;
|
||||
import com.bsd.pjcloud.thirdparty.mapper.pay.ThirdPayOrderMapper;
|
||||
@@ -44,6 +45,14 @@ public class ThirdPayOrderServiceImpl extends ServiceImpl<ThirdPayOrderMapper, T
|
||||
return getOne(new LambdaQueryWrapper<ThirdPayOrderEntity>().eq(ThirdPayOrderEntity::getPayNo, payNo));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThirdPayOrderEntity getByBiz(ThirdPayOrderBizTypeEnum bizType, String bizId) {
|
||||
return getOne(new LambdaQueryWrapper<ThirdPayOrderEntity>()
|
||||
.eq(ThirdPayOrderEntity::getBizType, bizType.getType())
|
||||
.eq(ThirdPayOrderEntity::getBizId, bizId)
|
||||
);
|
||||
}
|
||||
|
||||
private void disposePageList(List<ThirdPayOrderVo> list, ThirdPayOrderDto dto) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
// 查询用户
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ public class WalletRechargePackageServiceImpl extends ServiceImpl<WalletRecharge
|
||||
@Override
|
||||
public Boolean remotePaySuccess(WalletRechargePaySuccess dto) {
|
||||
// 小程序用户钱包充值
|
||||
if (ObjectUtil.equals(dto.getBizType(), ThirdPayOrderBizTypeEnum.MINI_APP_RECHARGE.getType())) {
|
||||
if (ObjectUtil.equals(dto.getBizType(), ThirdPayOrderBizTypeEnum.MINI_APP_WALLET_RECHARGE.getType())) {
|
||||
// 查询充值套餐
|
||||
WalletRechargePackageEntity rechargePackage = baseMapper.selectById(dto.getBizId());
|
||||
if (ObjectUtil.isEmpty(rechargePackage)) {
|
||||
@@ -78,7 +78,7 @@ public class WalletRechargePackageServiceImpl extends ServiceImpl<WalletRecharge
|
||||
@Override
|
||||
public Boolean remoteRefundSuccess(WalletRechargeRefundSuccess dto) {
|
||||
// 小程序用户钱包充值
|
||||
if (ObjectUtil.equals(dto.getBizType(), ThirdPayOrderBizTypeEnum.MINI_APP_RECHARGE.getType())) {
|
||||
if (ObjectUtil.equals(dto.getBizType(), ThirdPayOrderBizTypeEnum.MINI_APP_WALLET_RECHARGE.getType())) {
|
||||
// 查询充值套餐
|
||||
WalletRechargePackageEntity rechargePackage = baseMapper.selectById(dto.getBizId());
|
||||
if (ObjectUtil.isEmpty(rechargePackage)) {
|
||||
|
||||
Reference in new issue
Block a user