From b6da4fd5977718ca3fadc95e47060be710b673f6 Mon Sep 17 00:00:00 2001 From: xh-pan1 Date: Fri, 25 Aug 2023 04:51:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E7=8E=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shop/cereshop/admin/pay/xs/XsPayService.java | 11 +++ .../admin/pay/xs/impl/XsPayServiceImpl.java | 81 ++++++++++++++++++++++ .../buyer/impl/CereBuyerWithdrawalServiceImpl.java | 4 ++ .../pay/xs/service/impl/XsPayServiceImpl.java | 30 -------- 4 files changed, 96 insertions(+), 30 deletions(-) create mode 100644 cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/xs/XsPayService.java create mode 100644 cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/xs/impl/XsPayServiceImpl.java diff --git a/cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/xs/XsPayService.java b/cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/xs/XsPayService.java new file mode 100644 index 0000000..ad2a15d --- /dev/null +++ b/cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/xs/XsPayService.java @@ -0,0 +1,11 @@ +/* + * Copyright (C) 2017-2021 + * All rights reserved, Designed By 深圳中科鑫智科技有限公司 + * Copyright authorization contact 18814114118 + */ +package com.shop.cereshop.admin.pay.xs; + +import com.shop.cereshop.admin.pay.PayService; + +public interface XsPayService extends PayService { +} diff --git a/cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/xs/impl/XsPayServiceImpl.java b/cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/xs/impl/XsPayServiceImpl.java new file mode 100644 index 0000000..7228f96 --- /dev/null +++ b/cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/xs/impl/XsPayServiceImpl.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2017-2021 + * All rights reserved, Designed By 深圳中科鑫智科技有限公司 + * Copyright authorization contact 18814114118 + */ +package com.shop.cereshop.admin.pay.xs.impl; + +import com.alipay.api.AlipayClient; +import com.alipay.api.DefaultAlipayClient; +import com.alipay.api.domain.AlipayTradeRefundApplyModel; +import com.alipay.api.request.AlipayTradeRefundRequest; +import com.alipay.api.response.AlipayTradeRefundResponse; +import com.shop.cereshop.admin.pay.alipay.service.AliPayService; +import com.shop.cereshop.commons.config.AlipayConfig; +import com.shop.cereshop.commons.constant.CoReturnFormat; +import com.shop.cereshop.commons.constant.WxPayEnum; +import com.shop.cereshop.commons.exception.CoBusinessException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; + +@Service +@Slf4j(topic = "XsPayServiceImpl") +public class XsPayServiceImpl implements AliPayService { + + @Override + public Map refund(String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception { + Map result = new HashMap<>(); + + AlipayClient client = new DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.RSA_PRIVATE_KEY, AlipayConfig.FORMAT, AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.SIGNTYPE); + AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); + //request.setNotifyUrl(AlipayConfig.REFUND_NOTIFY_URL); + AlipayTradeRefundApplyModel model = new AlipayTradeRefundApplyModel(); + //model.setOutTradeNo(outTradeNo); + model.setTradeNo(transactionId); + model.setRefundAmount(refund.toString()); + request.setBizModel(model); + + AlipayTradeRefundResponse response = client.execute(request); + if (response.isSuccess()) { + //这里只是申请退款,兼容微信的返回 + result.put("return_msg", WxPayEnum.REFUND_SUCCESS.getCode()); + result.put("return_code", WxPayEnum.REFUND_OK.getCode()); + } else { + log.error("alipay refund failed: subCode = {}, subMsg = {}", response.getSubCode(), response.getSubMsg()); + throw new CoBusinessException(CoReturnFormat.APPLY_REFUND_FAILED); + } + return result; + } + + @Override + public Map refundBond(String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception { + Map result = new HashMap<>(); + + AlipayClient client = new DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.RSA_PRIVATE_KEY, AlipayConfig.FORMAT, AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.SIGNTYPE); + AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); + //request.setNotifyUrl(AlipayConfig.REFUND_NOTIFY_URL); + AlipayTradeRefundApplyModel model = new AlipayTradeRefundApplyModel(); + //model.setOutTradeNo(outTradeNo); + model.setTradeNo(transactionId); + model.setRefundAmount(refund.toString()); + request.setBizModel(model); + + AlipayTradeRefundResponse response = client.execute(request); + if (response.isSuccess()) { + //这里只是申请退款,兼容微信的返回 + result.put("return_msg", WxPayEnum.REFUND_SUCCESS.getCode()); + result.put("return_code", WxPayEnum.REFUND_OK.getCode()); + result.put("out_trade_no", response.getOutTradeNo()); + result.put("transaction_id", response.getTradeNo()); + } else { + log.error("alipay refundBond failed: subCode = {}, subMsg = {}", response.getSubCode(), response.getSubMsg()); + throw new CoBusinessException(CoReturnFormat.APPLY_REFUND_FAILED); + } + return result; + } + +} diff --git a/cereshop-admin/src/main/java/com/shop/cereshop/admin/service/buyer/impl/CereBuyerWithdrawalServiceImpl.java b/cereshop-admin/src/main/java/com/shop/cereshop/admin/service/buyer/impl/CereBuyerWithdrawalServiceImpl.java index 4621f65..d391c84 100644 --- a/cereshop-admin/src/main/java/com/shop/cereshop/admin/service/buyer/impl/CereBuyerWithdrawalServiceImpl.java +++ b/cereshop-admin/src/main/java/com/shop/cereshop/admin/service/buyer/impl/CereBuyerWithdrawalServiceImpl.java @@ -72,6 +72,10 @@ public class CereBuyerWithdrawalServiceImpl implements CereBuyerWithdrawalServic if(IntegerEnum.WITHDRAWAL_SUCCESS.getCode().equals(param.getState())){ describe="同意用户提现申请"; cereBuyerWithdrawal.setState(IntegerEnum.WITHDRAWAL_SUCCESS.getCode()); + //TODO pxh +// if(){ +// +// } }else { describe="拒绝用户提现申请"; cereBuyerWithdrawal.setState(IntegerEnum.WITHDRAWAL_ERROR.getCode()); diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/pay/xs/service/impl/XsPayServiceImpl.java b/cereshop-business/src/main/java/com/shop/cereshop/business/pay/xs/service/impl/XsPayServiceImpl.java index 9dd8243..014712b 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/pay/xs/service/impl/XsPayServiceImpl.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/pay/xs/service/impl/XsPayServiceImpl.java @@ -64,11 +64,6 @@ public class XsPayServiceImpl implements XsPayService { @Override public Map refund(String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund, Long afterId) throws Exception { - //构建请求参数 -// Map contentMap = build06ContentMap(orderFormId, outRefundNo, outTradeNo, transactionId, refund, -// XspayConfig.BUSINESS_RETURN_NOTICE_URL); -// String respMsg = XsPayUtils.requestByXs(REFUND_SER_CODE, contentMap); - Map contentMap = build22ContentMap(orderFormId, outRefundNo, outTradeNo, transactionId, refund, XspayConfig.BUSINESS_RETURN_NOTICE_URL); String respMsg = XsPayUtils.requestByXs(SHARE_REFUND_SER_CODE, contentMap); @@ -90,18 +85,6 @@ public class XsPayServiceImpl implements XsPayService { result.put("return_msg", WxPayEnum.REFUND_SUCCESS.getCode()); result.put("return_code", WxPayEnum.REFUND_OK.getCode()); return result; -// String merOrderId = content.getString("merOrderId"); -// String oldMmerOrderId = content.getString("oldMerOrderId"); -// String dealId = content.getString("refundOrderNo"); -// -// String[] split = oldMmerOrderId.split("-"); -// if (!EmptyUtils.isEmpty(split)) { -// String orderFormId = split[0]; -// if (!EmptyUtils.isEmpty(orderFormId)) { -// //处理支付成功后的其他逻辑 -// cereShopOrderService.handleRefundWxLog(orderFormId, dealId, merOrderId); -// } -// } } } catch (CoBusinessException e) { if(StringUtils.equals(e.getCode(), "0005")){ @@ -125,8 +108,6 @@ public class XsPayServiceImpl implements XsPayService { //订单退款 @Override public Map orderRefund(String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception { -// Map contentMap = build06ContentMap(orderFormId, outRefundNo, outTradeNo, transactionId, refund, XspayConfig.APP_NOTICE_URL); -// String respMsg = XsPayUtils.requestByXs(REFUND_SER_CODE, contentMap); Map contentMap = build22ContentMap(orderFormId, outRefundNo, outTradeNo, transactionId, refund, XspayConfig.APP_NOTICE_URL); String respMsg = XsPayUtils.requestByXs(SHARE_REFUND_SER_CODE, contentMap); if(StrUtil.isNotBlank(respMsg)){ @@ -146,17 +127,6 @@ public class XsPayServiceImpl implements XsPayService { result.put("return_msg", WxPayEnum.REFUND_SUCCESS.getCode()); result.put("return_code", WxPayEnum.REFUND_OK.getCode()); return result; -// if(StringUtils.equals(status, "0")) { -// String merOrderId = content.getString("merOrderId"); -// String[] split = merOrderId.split("-"); -// if (!EmptyUtils.isEmpty(split)) { -// String orderFormId = split[0]; -// if (!EmptyUtils.isEmpty(orderFormId)) { -// String dealId = content.getString("refundOrderNo"); -// //处理支付成功后的其他逻辑 -// cereShopOrderService.handleRefundWxLog(orderFormId, dealId, merOrderId); -// } -// } } } catch (CoBusinessException e) {