Browse Source

修改提现功能

master
xh-pan1 1 year ago
parent
commit
b6da4fd597
  1. 11
      cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/xs/XsPayService.java
  2. 81
      cereshop-admin/src/main/java/com/shop/cereshop/admin/pay/xs/impl/XsPayServiceImpl.java
  3. 4
      cereshop-admin/src/main/java/com/shop/cereshop/admin/service/buyer/impl/CereBuyerWithdrawalServiceImpl.java
  4. 30
      cereshop-business/src/main/java/com/shop/cereshop/business/pay/xs/service/impl/XsPayServiceImpl.java

11
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 {
}

81
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<String, String> refund(String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
Map<String, String> 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<String, String> refundBond(String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
Map<String, String> 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;
}
}

4
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());

30
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<String, String> refund(String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund, Long afterId) throws Exception {
//构建请求参数
// Map<String, Object> contentMap = build06ContentMap(orderFormId, outRefundNo, outTradeNo, transactionId, refund,
// XspayConfig.BUSINESS_RETURN_NOTICE_URL);
// String respMsg = XsPayUtils.requestByXs(REFUND_SER_CODE, contentMap);
Map<String, Object> 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<String, String> orderRefund(String orderFormId, String outTradeNo, String transactionId, String outRefundNo, BigDecimal total, BigDecimal refund) throws CoBusinessException, Exception {
// Map<String, Object> contentMap = build06ContentMap(orderFormId, outRefundNo, outTradeNo, transactionId, refund, XspayConfig.APP_NOTICE_URL);
// String respMsg = XsPayUtils.requestByXs(REFUND_SER_CODE, contentMap);
Map<String, Object> 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) {

Loading…
Cancel
Save