Commit 6a25cea4 by 程裕兵

feat:refund

parent 171749c7
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.jiejing.paycenter</groupId> <groupId>com.jiejing.paycenter</groupId>
<artifactId>api</artifactId> <artifactId>paycenter-api</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</dependency> </dependency>
......
...@@ -14,12 +14,14 @@ import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantApplyRe ...@@ -14,12 +14,14 @@ import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantApplyRe
import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.PageStudioMerchantApplyRequest; import com.jiejing.fitness.finance.api.merchant.request.PageStudioMerchantApplyRequest;
import com.jiejing.fitness.finance.api.merchant.request.StudioMerchantPayRequest; import com.jiejing.fitness.finance.api.merchant.request.StudioMerchantPayRequest;
import com.jiejing.fitness.finance.api.merchant.request.StudioMerchantRefundRequest;
import com.jiejing.fitness.finance.api.merchant.request.UnbindStudioMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.UnbindStudioMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantApplyVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantAuthSubChannelVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantAuthSubChannelVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantBindXcxAppIdVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantBindXcxAppIdVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO;
import com.jiejing.paycenter.common.model.vo.PayVO; import com.jiejing.paycenter.common.model.vo.PayVO;
import com.jiejing.paycenter.common.model.vo.RefundVO;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.List; import java.util.List;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
...@@ -94,4 +96,8 @@ public interface StudioMerchantApi { ...@@ -94,4 +96,8 @@ public interface StudioMerchantApi {
@PostMapping(value = "/private/studioMerchant/pay") @PostMapping(value = "/private/studioMerchant/pay")
JsonResult<PayVO> pay(StudioMerchantPayRequest request); JsonResult<PayVO> pay(StudioMerchantPayRequest request);
@ApiOperation(value = "退款", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/refund")
JsonResult<RefundVO> refund(StudioMerchantRefundRequest request);
} }
\ No newline at end of file
...@@ -14,12 +14,14 @@ import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantApplyRe ...@@ -14,12 +14,14 @@ import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantApplyRe
import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.PageStudioMerchantApplyRequest; import com.jiejing.fitness.finance.api.merchant.request.PageStudioMerchantApplyRequest;
import com.jiejing.fitness.finance.api.merchant.request.StudioMerchantPayRequest; import com.jiejing.fitness.finance.api.merchant.request.StudioMerchantPayRequest;
import com.jiejing.fitness.finance.api.merchant.request.StudioMerchantRefundRequest;
import com.jiejing.fitness.finance.api.merchant.request.UnbindStudioMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.UnbindStudioMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantApplyVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantAuthSubChannelVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantAuthSubChannelVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantBindXcxAppIdVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantBindXcxAppIdVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO;
import com.jiejing.paycenter.common.model.vo.PayVO; import com.jiejing.paycenter.common.model.vo.PayVO;
import com.jiejing.paycenter.common.model.vo.RefundVO;
import feign.hystrix.FallbackFactory; import feign.hystrix.FallbackFactory;
import java.util.List; import java.util.List;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -112,6 +114,11 @@ public class StudioMerchantApiFallback implements FallbackFactory<StudioMerchant ...@@ -112,6 +114,11 @@ public class StudioMerchantApiFallback implements FallbackFactory<StudioMerchant
public JsonResult<PayVO> pay(StudioMerchantPayRequest request) { public JsonResult<PayVO> pay(StudioMerchantPayRequest request) {
return JsonResult.rpcError(); return JsonResult.rpcError();
} }
@Override
public JsonResult<RefundVO> refund(StudioMerchantRefundRequest request) {
return JsonResult.rpcError();
}
}; };
} }
} }
package com.jiejing.fitness.finance.api.merchant.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author chengyubing
* @since 2024/2/27 10:54
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(description = "场馆商户退款请求")
public class StudioMerchantRefundRequest {
@ApiModelProperty(value = "场馆ID", required = true)
@NotNull(message = "场馆ID不能为空")
private Long studioId;
@ApiModelProperty(name = "退款总金额(元)", required = true)
@NotNull(message = "退款总金额不能为空")
private BigDecimal transAmount;
@ApiModelProperty(name = "退款请求对应的支付流水号", required = true)
@NotBlank(message = "退款请求对应的支付流水号不能为空")
private String payTransNo;
@ApiModelProperty(name = "退款原因", required = true)
@NotBlank(message = "退款原因不能为空")
private String refundReason;
@ApiModelProperty(name = "上层业务退款单号")
private String orderNo;
}
...@@ -16,6 +16,7 @@ import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantApplyRe ...@@ -16,6 +16,7 @@ import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantApplyRe
import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.PageStudioMerchantApplyRequest; import com.jiejing.fitness.finance.api.merchant.request.PageStudioMerchantApplyRequest;
import com.jiejing.fitness.finance.api.merchant.request.StudioMerchantPayRequest; import com.jiejing.fitness.finance.api.merchant.request.StudioMerchantPayRequest;
import com.jiejing.fitness.finance.api.merchant.request.StudioMerchantRefundRequest;
import com.jiejing.fitness.finance.api.merchant.request.UnbindStudioMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.UnbindStudioMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantApplyVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantAuthSubChannelVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantAuthSubChannelVO;
...@@ -26,7 +27,9 @@ import com.jiejing.fitness.finance.service.merchant.params.ApplyStudioMerchantPa ...@@ -26,7 +27,9 @@ import com.jiejing.fitness.finance.service.merchant.params.ApplyStudioMerchantPa
import com.jiejing.fitness.finance.service.merchant.params.PageStudioMerchantApplyParams; import com.jiejing.fitness.finance.service.merchant.params.PageStudioMerchantApplyParams;
import com.jiejing.fitness.finance.service.pay.PayService; import com.jiejing.fitness.finance.service.pay.PayService;
import com.jiejing.fitness.finance.service.pay.params.StudioMerchantPayParams; import com.jiejing.fitness.finance.service.pay.params.StudioMerchantPayParams;
import com.jiejing.fitness.finance.service.pay.params.StudioMerchantRefundParams;
import com.jiejing.paycenter.common.model.vo.PayVO; import com.jiejing.paycenter.common.model.vo.PayVO;
import com.jiejing.paycenter.common.model.vo.RefundVO;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -170,4 +173,13 @@ public class StudioMerchantController implements StudioMerchantApi { ...@@ -170,4 +173,13 @@ public class StudioMerchantController implements StudioMerchantApi {
StudioMerchantPayParams params = BeanUtil.map(request, StudioMerchantPayParams.class); StudioMerchantPayParams params = BeanUtil.map(request, StudioMerchantPayParams.class);
return JsonResult.success(payService.merchantPay(params)); return JsonResult.success(payService.merchantPay(params));
} }
@ApiOperation(value = "退款", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/refund")
@Override
public JsonResult<RefundVO> refund(@RequestBody @Valid StudioMerchantRefundRequest request) {
StudioMerchantRefundParams params = BeanUtil.map(request, StudioMerchantRefundParams.class);
return JsonResult.success(payService.merchantRefund(params));
}
} }
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.jiejing.paycenter</groupId> <groupId>com.jiejing.paycenter</groupId>
<artifactId>api</artifactId> <artifactId>paycenter-api</artifactId>
<version>${pay-center.version}</version> <version>${pay-center.version}</version>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.jiejing.paycenter</groupId> <groupId>com.jiejing.paycenter</groupId>
<artifactId>api</artifactId> <artifactId>paycenter-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.jiejing.app</groupId> <groupId>com.jiejing.app</groupId>
......
...@@ -3,12 +3,12 @@ package com.jiejing.fitness.finance.service.pay; ...@@ -3,12 +3,12 @@ package com.jiejing.fitness.finance.service.pay;
import com.jiejing.fitness.finance.service.pay.params.AppPayParams; import com.jiejing.fitness.finance.service.pay.params.AppPayParams;
import com.jiejing.fitness.finance.service.pay.params.NativePayParams; import com.jiejing.fitness.finance.service.pay.params.NativePayParams;
import com.jiejing.fitness.finance.service.pay.params.StudioMerchantPayParams; import com.jiejing.fitness.finance.service.pay.params.StudioMerchantPayParams;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantRefundParams; import com.jiejing.fitness.finance.service.pay.params.StudioMerchantRefundParams;
import com.jiejing.paycenter.common.enums.common.PayChannelEnums; import com.jiejing.paycenter.common.enums.common.PayChannelEnums;
import com.jiejing.paycenter.common.model.vo.PayVO; import com.jiejing.paycenter.common.model.vo.PayVO;
import com.jiejing.paycenter.api.pay.vo.RefundVO;
import com.jiejing.paycenter.common.event.PayEvent; import com.jiejing.paycenter.common.event.PayEvent;
import com.jiejing.paycenter.common.event.RefundEvent; import com.jiejing.paycenter.common.event.RefundEvent;
import com.jiejing.paycenter.common.model.vo.RefundVO;
import java.util.Date; import java.util.Date;
/** /**
...@@ -64,7 +64,7 @@ public interface PayService { ...@@ -64,7 +64,7 @@ public interface PayService {
* @param params 参数 * @param params 参数
* @return 结果 * @return 结果
*/ */
RefundVO merchantRefund(BrandMerchantRefundParams params); RefundVO merchantRefund(StudioMerchantRefundParams params);
/** /**
* 退款回调 * 退款回调
......
...@@ -11,23 +11,22 @@ import com.jiejing.common.utils.text.StringUtil; ...@@ -11,23 +11,22 @@ import com.jiejing.common.utils.text.StringUtil;
import com.jiejing.fitness.enums.finance.BrandCashierTransStateEnum; import com.jiejing.fitness.enums.finance.BrandCashierTransStateEnum;
import com.jiejing.fitness.enums.finance.BrandCashierTransTypeEnum; import com.jiejing.fitness.enums.finance.BrandCashierTransTypeEnum;
import com.jiejing.fitness.finance.repository.entity.MerchantSettleRecord; import com.jiejing.fitness.finance.repository.entity.MerchantSettleRecord;
import com.jiejing.fitness.finance.repository.entity.PartyToMerchant;
import com.jiejing.fitness.finance.repository.entity.StudioCashierRecord; import com.jiejing.fitness.finance.repository.entity.StudioCashierRecord;
import com.jiejing.fitness.finance.repository.entity.StudioCheckSettleRecord; import com.jiejing.fitness.finance.repository.entity.StudioCheckSettleRecord;
import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply; import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply;
import com.jiejing.fitness.finance.repository.entity.StudioSettleRecord; import com.jiejing.fitness.finance.repository.entity.StudioSettleRecord;
import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums; import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantRefundParams; import com.jiejing.fitness.finance.service.pay.params.StudioMerchantRefundParams;
import com.jiejing.fitness.finance.service.pay.params.StudioMerchantPayParams; import com.jiejing.fitness.finance.service.pay.params.StudioMerchantPayParams;
import com.jiejing.fitness.finance.service.utils.FeeUtil; import com.jiejing.fitness.finance.service.utils.FeeUtil;
import com.jiejing.fitness.finance.service.utils.MoneyUtil; import com.jiejing.fitness.finance.service.utils.MoneyUtil;
import com.jiejing.paycenter.common.model.vo.MerchantVO; import com.jiejing.paycenter.common.model.vo.MerchantVO;
import com.jiejing.paycenter.common.model.vo.PayVO; import com.jiejing.paycenter.common.model.vo.PayVO;
import com.jiejing.paycenter.common.model.vo.RefundVO;
import com.jiejing.paycenter.common.model.vo.SettleVO; import com.jiejing.paycenter.common.model.vo.SettleVO;
import com.jiejing.paycenter.common.model.vo.SubChannelVO; import com.jiejing.paycenter.common.model.vo.SubChannelVO;
import com.jiejing.paycenter.api.pay.request.PayRequest; import com.jiejing.paycenter.api.pay.request.PayRequest;
import com.jiejing.paycenter.api.pay.request.RefundPayRequest; import com.jiejing.paycenter.api.pay.request.RefundPayRequest;
import com.jiejing.paycenter.api.pay.vo.RefundVO;
import com.jiejing.paycenter.common.enums.common.TransStateEnums; import com.jiejing.paycenter.common.enums.common.TransStateEnums;
import com.jiejing.paycenter.common.enums.merchant.SubChannelEnums; import com.jiejing.paycenter.common.enums.merchant.SubChannelEnums;
import com.jiejing.paycenter.common.enums.merchant.SubChannelOpenTypeEnums; import com.jiejing.paycenter.common.enums.merchant.SubChannelOpenTypeEnums;
...@@ -185,7 +184,7 @@ public class PayConvert { ...@@ -185,7 +184,7 @@ public class PayConvert {
return convertTransState(PayStateEnums.getByCode(state)); return convertTransState(PayStateEnums.getByCode(state));
} }
public static StudioCashierRecord convertRefundInit(BrandMerchantRefundParams params, public static StudioCashierRecord convertRefundInit(StudioMerchantRefundParams params,
StudioCashierRecord pay, BigDecimal historyRefundActualAmount) { StudioCashierRecord pay, BigDecimal historyRefundActualAmount) {
StudioCashierRecord record = BeanUtil.map(pay, StudioCashierRecord.class); StudioCashierRecord record = BeanUtil.map(pay, StudioCashierRecord.class);
record.setId(IdWorker.getId()); record.setId(IdWorker.getId());
...@@ -207,7 +206,7 @@ public class PayConvert { ...@@ -207,7 +206,7 @@ public class PayConvert {
return record; return record;
} }
public static RefundPayRequest convert(BrandMerchantRefundParams params, StudioCashierRecord record) { public static RefundPayRequest convert(StudioMerchantRefundParams params, StudioCashierRecord record) {
RefundPayRequest request = BeanUtil.map(params, RefundPayRequest.class); RefundPayRequest request = BeanUtil.map(params, RefundPayRequest.class);
request.setTransNo(record.getTransNo()); request.setTransNo(record.getTransNo());
return request; return request;
......
...@@ -4,7 +4,6 @@ import static java.util.stream.Collectors.toList; ...@@ -4,7 +4,6 @@ import static java.util.stream.Collectors.toList;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alipay.api.AlipayApiException; import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient; import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipaySystemOauthTokenRequest; import com.alipay.api.request.AlipaySystemOauthTokenRequest;
import com.alipay.api.response.AlipaySystemOauthTokenResponse; import com.alipay.api.response.AlipaySystemOauthTokenResponse;
...@@ -21,7 +20,6 @@ import com.jiejing.fitness.finance.repository.entity.MerchantSettleRecord; ...@@ -21,7 +20,6 @@ import com.jiejing.fitness.finance.repository.entity.MerchantSettleRecord;
import com.jiejing.fitness.finance.repository.entity.StudioCashierRecord; import com.jiejing.fitness.finance.repository.entity.StudioCashierRecord;
import com.jiejing.fitness.finance.repository.entity.PartyToMerchant; import com.jiejing.fitness.finance.repository.entity.PartyToMerchant;
import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply; import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply;
import com.jiejing.fitness.finance.repository.entity.StudioSettleRecord;
import com.jiejing.fitness.finance.repository.service.GlobalConfigRpService; import com.jiejing.fitness.finance.repository.service.GlobalConfigRpService;
import com.jiejing.fitness.finance.repository.service.MerchantSettleRecordRpService; import com.jiejing.fitness.finance.repository.service.MerchantSettleRecordRpService;
import com.jiejing.fitness.finance.repository.service.StudioCashierRecordRpService; import com.jiejing.fitness.finance.repository.service.StudioCashierRecordRpService;
...@@ -37,7 +35,7 @@ import com.jiejing.fitness.finance.service.pay.PayService; ...@@ -37,7 +35,7 @@ import com.jiejing.fitness.finance.service.pay.PayService;
import com.jiejing.fitness.finance.service.pay.convert.PayConvert; import com.jiejing.fitness.finance.service.pay.convert.PayConvert;
import com.jiejing.fitness.finance.service.pay.enums.PayFailMessageReplaceEnums; import com.jiejing.fitness.finance.service.pay.enums.PayFailMessageReplaceEnums;
import com.jiejing.fitness.finance.service.pay.params.AppPayParams; import com.jiejing.fitness.finance.service.pay.params.AppPayParams;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantRefundParams; import com.jiejing.fitness.finance.service.pay.params.StudioMerchantRefundParams;
import com.jiejing.fitness.finance.service.pay.params.NativePayParams; import com.jiejing.fitness.finance.service.pay.params.NativePayParams;
import com.jiejing.fitness.finance.service.pay.params.StudioMerchantPayParams; import com.jiejing.fitness.finance.service.pay.params.StudioMerchantPayParams;
import com.jiejing.fitness.finance.service.rpc.MerchantRpcService; import com.jiejing.fitness.finance.service.rpc.MerchantRpcService;
...@@ -57,7 +55,7 @@ import com.jiejing.paycenter.common.model.vo.MerchantVO; ...@@ -57,7 +55,7 @@ import com.jiejing.paycenter.common.model.vo.MerchantVO;
import com.jiejing.paycenter.api.pay.request.PayRequest; import com.jiejing.paycenter.api.pay.request.PayRequest;
import com.jiejing.paycenter.api.pay.request.RefundPayRequest; import com.jiejing.paycenter.api.pay.request.RefundPayRequest;
import com.jiejing.paycenter.common.model.vo.PayVO; import com.jiejing.paycenter.common.model.vo.PayVO;
import com.jiejing.paycenter.api.pay.vo.RefundVO; import com.jiejing.paycenter.common.model.vo.RefundVO;
import com.jiejing.paycenter.common.event.PayEvent; import com.jiejing.paycenter.common.event.PayEvent;
import com.jiejing.paycenter.common.event.RefundEvent; import com.jiejing.paycenter.common.event.RefundEvent;
import com.jiejing.paycenter.common.model.vo.SettleVO; import com.jiejing.paycenter.common.model.vo.SettleVO;
...@@ -67,8 +65,6 @@ import com.jiejing.wechat.vo.weChat.BaseAuthInfoVO; ...@@ -67,8 +65,6 @@ import com.jiejing.wechat.vo.weChat.BaseAuthInfoVO;
import com.xiaomai.event.EventAgent; import com.xiaomai.event.EventAgent;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -257,20 +253,24 @@ public class PayServiceImpl implements PayService { ...@@ -257,20 +253,24 @@ public class PayServiceImpl implements PayService {
} }
@Override @Override
public RefundVO merchantRefund(BrandMerchantRefundParams params) { public RefundVO merchantRefund(StudioMerchantRefundParams params) {
StudioCashierRecord pay = studioCashierRecordRpService.getById(Long.parseLong(params.getPayTransNo())) StudioCashierRecord refund = transactionTemplate.execute(action -> {
.orElseThrow(() -> new BizException(FinanceErrorEnums.NOT_EXIST)); Long payId = Long.parseLong(params.getPayTransNo());
StudioCashierRecord pay = studioCashierRecordRpService.getById(payId)
BigDecimal historyRefundActualAmount = studioCashierRecordRpService.sumRefundActualAmountByPayTransNo( .orElseThrow(() -> new BizException(FinanceErrorEnums.NOT_EXIST));
params.getPayTransNo());
BigDecimal historyRefundActualAmount = studioCashierRecordRpService.sumRefundActualAmountByPayTransNo(
StudioCashierRecord record = PayConvert.convertRefundInit(params, pay, historyRefundActualAmount); params.getPayTransNo());
studioCashierRecordRpService.insert(record);
StudioCashierRecord record = PayConvert.convertRefundInit(params, pay, historyRefundActualAmount);
studioCashierRecordRpService.insert(record);
return record;
});
RefundPayRequest request = PayConvert.convert(params, record); RefundPayRequest request = PayConvert.convert(params, refund);
RefundVO vo = payRpcService.refund(request); RefundVO vo = payRpcService.refund(request);
StudioCashierRecord toModify = PayConvert.convertRefund(record, vo); StudioCashierRecord toModify = PayConvert.convertRefund(refund, vo);
studioCashierRecordRpService.updateById(toModify); studioCashierRecordRpService.updateById(toModify);
return vo; return vo;
} }
......
...@@ -18,21 +18,17 @@ import lombok.NoArgsConstructor; ...@@ -18,21 +18,17 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel(description = "品牌商户退款Params") @ApiModel(description = "场馆商户退款Params")
public class BrandMerchantRefundParams { public class StudioMerchantRefundParams {
@ApiModelProperty(value = "场馆ID", required = true) @ApiModelProperty(value = "场馆ID", required = true)
@NotNull(message = "场馆ID不能为空") @NotNull(message = "场馆ID不能为空")
private Long studioId; private Long studioId;
@ApiModelProperty(name = "支付总金额(元)", required = true) @ApiModelProperty(name = "退款总金额(元)", required = true)
@NotNull(message = "支付总金额不能为空") @NotNull(message = "退款总金额不能为空")
private BigDecimal transAmount; private BigDecimal transAmount;
@ApiModelProperty(name = "上层业务退款单号", required = true)
@NotBlank(message = "上层业务退款单号不能为空")
private String orderNo;
@ApiModelProperty(name = "退款请求对应的支付流水号", required = true) @ApiModelProperty(name = "退款请求对应的支付流水号", required = true)
@NotBlank(message = "退款请求对应的支付流水号不能为空") @NotBlank(message = "退款请求对应的支付流水号不能为空")
private String payTransNo; private String payTransNo;
...@@ -41,4 +37,7 @@ public class BrandMerchantRefundParams { ...@@ -41,4 +37,7 @@ public class BrandMerchantRefundParams {
@NotBlank(message = "退款原因不能为空") @NotBlank(message = "退款原因不能为空")
private String refundReason; private String refundReason;
@ApiModelProperty(name = "上层业务退款单号")
private String orderNo;
} }
package com.jiejing.fitness.finance.service.rpc; package com.jiejing.fitness.finance.service.rpc;
import com.alibaba.fastjson.JSON;
import com.jiejing.common.model.JsonResult; import com.jiejing.common.model.JsonResult;
import com.jiejing.paycenter.api.pay.PayApi; import com.jiejing.paycenter.api.pay.PayApi;
import com.jiejing.paycenter.api.pay.request.PayRequest; import com.jiejing.paycenter.api.pay.request.PayRequest;
import com.jiejing.paycenter.api.pay.request.RefundPayRequest; import com.jiejing.paycenter.api.pay.request.RefundPayRequest;
import com.jiejing.paycenter.api.pay.request.SyncSettleRequest; import com.jiejing.paycenter.api.pay.request.SyncSettleRequest;
import com.jiejing.paycenter.common.model.vo.PayVO; import com.jiejing.paycenter.common.model.vo.PayVO;
import com.jiejing.paycenter.api.pay.vo.RefundVO;
import com.jiejing.paycenter.common.enums.common.TransStateEnums; import com.jiejing.paycenter.common.enums.common.TransStateEnums;
import com.jiejing.paycenter.common.enums.pay.PayStateEnums; import com.jiejing.paycenter.common.enums.pay.PayStateEnums;
import com.jiejing.paycenter.common.model.vo.RefundVO;
import com.jiejing.paycenter.common.model.vo.SettleVO; import com.jiejing.paycenter.common.model.vo.SettleVO;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.Optional; import java.util.Optional;
import javax.annotation.Resource; import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
* @author chengyubing * @author chengyubing
* @since 2024/2/27 11:12 * @since 2024/2/27 11:12
*/ */
@Slf4j
@Service @Service
public class PayRpcService { public class PayRpcService {
...@@ -32,6 +35,7 @@ public class PayRpcService { ...@@ -32,6 +35,7 @@ public class PayRpcService {
result.assertSuccess(); result.assertSuccess();
return result.getResult(); return result.getResult();
} catch (Exception e) { } catch (Exception e) {
log.error("pay occur error {}", JSON.toJSONString(request), e);
return PayVO.builder().payState(PayStateEnums.FAILED.name()).failMsg(e.getMessage()).build(); return PayVO.builder().payState(PayStateEnums.FAILED.name()).failMsg(e.getMessage()).build();
} }
} }
...@@ -42,6 +46,7 @@ public class PayRpcService { ...@@ -42,6 +46,7 @@ public class PayRpcService {
result.assertSuccess(); result.assertSuccess();
return result.getResult(); return result.getResult();
} catch (Exception e) { } catch (Exception e) {
log.error("refund occur error {}", JSON.toJSONString(request), e);
return RefundVO.builder().refundState(TransStateEnums.FAIL.name()).failMessage(e.getMessage()).build(); return RefundVO.builder().refundState(TransStateEnums.FAIL.name()).failMessage(e.getMessage()).build();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment