Commit f3bb7333 by 程裕兵

feat:pay

parent 0776bd03
...@@ -10,12 +10,14 @@ import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantGetAuthSubC ...@@ -10,12 +10,14 @@ import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantGetAuthSubC
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantGetRequest; import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantGetRequest;
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantPageApplyRequest; import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantPageApplyRequest;
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantPayRequest; import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantPayRequest;
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantRefundRequest;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantApplyVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantAuthSubChannelVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantAuthSubChannelVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantBindXcxAppIdVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantBindXcxAppIdVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO;
import com.jiejing.paycenter.api.pay.request.PayRequest; import com.jiejing.paycenter.api.pay.request.PayRequest;
import com.jiejing.paycenter.api.pay.vo.PayVO; import com.jiejing.paycenter.api.pay.vo.PayVO;
import com.jiejing.paycenter.api.pay.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;
...@@ -69,4 +71,8 @@ public interface BrandMerchantApi { ...@@ -69,4 +71,8 @@ public interface BrandMerchantApi {
@PostMapping(value = "/private/brandMerchant/pay") @PostMapping(value = "/private/brandMerchant/pay")
JsonResult<PayVO> pay(BrandMerchantPayRequest request); JsonResult<PayVO> pay(BrandMerchantPayRequest request);
@ApiOperation(value = "退款", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/refund")
JsonResult<RefundVO> refund(BrandMerchantRefundRequest request);
} }
...@@ -10,11 +10,13 @@ import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantGetAuthSubC ...@@ -10,11 +10,13 @@ import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantGetAuthSubC
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantGetRequest; import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantGetRequest;
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantPageApplyRequest; import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantPageApplyRequest;
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantPayRequest; import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantPayRequest;
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantRefundRequest;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantApplyVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantAuthSubChannelVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantAuthSubChannelVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantBindXcxAppIdVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantBindXcxAppIdVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO;
import com.jiejing.paycenter.api.pay.vo.PayVO; import com.jiejing.paycenter.api.pay.vo.PayVO;
import com.jiejing.paycenter.api.pay.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;
...@@ -76,6 +78,11 @@ public class BrandMerchantApiFallback implements FallbackFactory<BrandMerchantAp ...@@ -76,6 +78,11 @@ public class BrandMerchantApiFallback implements FallbackFactory<BrandMerchantAp
public JsonResult<PayVO> pay(BrandMerchantPayRequest request) { public JsonResult<PayVO> pay(BrandMerchantPayRequest request) {
return JsonResult.rpcError(); return JsonResult.rpcError();
} }
@Override
public JsonResult<RefundVO> refund(BrandMerchantRefundRequest request) {
return JsonResult.rpcError();
}
}; };
} }
} }
...@@ -30,7 +30,7 @@ public class BrandMerchantPayRequest { ...@@ -30,7 +30,7 @@ public class BrandMerchantPayRequest {
@ApiModelProperty(name = "支付总金额(元)", required = true) @ApiModelProperty(name = "支付总金额(元)", required = true)
@NotNull(message = "支付总金额不能为空") @NotNull(message = "支付总金额不能为空")
private BigDecimal amount; private BigDecimal transAmount;
@ApiModelProperty(name = "业务订单号", required = true) @ApiModelProperty(name = "业务订单号", required = true)
@NotBlank(message = "业务订单号不能为空") @NotBlank(message = "业务订单号不能为空")
......
package com.jiejing.fitness.finance.api.merchant.request;
import com.alibaba.fastjson.JSONObject;
import com.jiejing.paycenter.common.enums.merchant.SubChannelEnums;
import com.jiejing.paycenter.common.enums.pay.PayTypeEnums;
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 = "品牌商户退款Request")
public class BrandMerchantRefundRequest {
@ApiModelProperty(value = "品牌ID", required = true)
@NotNull(message = "品牌ID不能为空")
private Long brandId;
@ApiModelProperty(name = "支付总金额(元)", required = true)
@NotNull(message = "支付总金额不能为空")
private BigDecimal amount;
@ApiModelProperty(name = "业务订单号", required = true)
@NotBlank(message = "业务订单号不能为空")
private String orderNo;
@ApiModelProperty(name = "业务订单类型", required = true)
@NotNull(message = "业务订单类型不能为空")
private Integer orderType;
@ApiModelProperty(name = "支付类型", required = true)
@NotNull(message = "支付类型不能为空")
private PayTypeEnums payType;
@ApiModelProperty(name = "正扫:三方支付账户ID", notes = "微信的openId,支付宝的userId,JS、MINI、NATIVE支付必传")
private String openId;
@ApiModelProperty(name = "反扫:支付授权码", notes = "扫码设备读出的条形码或者二维码信息,BARCODE支付必传")
private String authCode;
@ApiModelProperty(name = "支付子渠道", notes = "聚合支付时需要")
private SubChannelEnums subChannel;
@ApiModelProperty(name = "商品名称", required = true)
@NotBlank(message = "商品名称不能为空")
private String goods;
@ApiModelProperty(name = "appId", notes = "指定本次使用的appId")
private String appId;
@ApiModelProperty(name = "过期时间(单位:秒)", required = true)
@NotNull(message = "过期时间不能为空")
private Integer timeExpire;
@ApiModelProperty(name = "业务扩展信息")
private JSONObject extra;
}
...@@ -12,6 +12,7 @@ import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantGetAuthSubC ...@@ -12,6 +12,7 @@ import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantGetAuthSubC
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantGetRequest; import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantGetRequest;
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantPageApplyRequest; import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantPageApplyRequest;
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantPayRequest; import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantPayRequest;
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantRefundRequest;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantApplyVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantAuthSubChannelVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantAuthSubChannelVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantBindXcxAppIdVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantBindXcxAppIdVO;
...@@ -21,7 +22,9 @@ import com.jiejing.fitness.finance.service.merchant.params.ApplyBrandMerchantPar ...@@ -21,7 +22,9 @@ import com.jiejing.fitness.finance.service.merchant.params.ApplyBrandMerchantPar
import com.jiejing.fitness.finance.service.merchant.params.PageBrandMerchantApplyParams; import com.jiejing.fitness.finance.service.merchant.params.PageBrandMerchantApplyParams;
import com.jiejing.fitness.finance.service.pay.PayService; import com.jiejing.fitness.finance.service.pay.PayService;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantPayParams; import com.jiejing.fitness.finance.service.pay.params.BrandMerchantPayParams;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantRefundParams;
import com.jiejing.paycenter.api.pay.vo.PayVO; import com.jiejing.paycenter.api.pay.vo.PayVO;
import com.jiejing.paycenter.api.pay.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;
...@@ -108,7 +111,6 @@ public class BrandMerchantController implements BrandMerchantApi { ...@@ -108,7 +111,6 @@ public class BrandMerchantController implements BrandMerchantApi {
public JsonResult<List<BrandMerchantAuthSubChannelVO>> listAuthSubChannel( public JsonResult<List<BrandMerchantAuthSubChannelVO>> listAuthSubChannel(
@RequestBody @Valid BrandMerchantGetAuthSubChannelRequest request) { @RequestBody @Valid BrandMerchantGetAuthSubChannelRequest request) {
return JsonResult.success(brandMerchantService.listAuthSubChannel(request.getBrandId())); return JsonResult.success(brandMerchantService.listAuthSubChannel(request.getBrandId()));
} }
@ApiOperation(value = "支付", tags = {TAG}) @ApiOperation(value = "支付", tags = {TAG})
...@@ -119,4 +121,12 @@ public class BrandMerchantController implements BrandMerchantApi { ...@@ -119,4 +121,12 @@ public class BrandMerchantController implements BrandMerchantApi {
return JsonResult.success(payService.merchantPay(params)); return JsonResult.success(payService.merchantPay(params));
} }
@ApiOperation(value = "退款", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/refund")
@Override
public JsonResult<RefundVO> refund(@RequestBody @Valid BrandMerchantRefundRequest request) {
BrandMerchantRefundParams params = BeanUtil.map(request, BrandMerchantRefundParams.class);
return JsonResult.success(payService.merchantRefund(params));
}
} }
...@@ -59,7 +59,7 @@ public class ListenerService { ...@@ -59,7 +59,7 @@ public class ListenerService {
public void payEventCallback(PayEvent event, @Header(DELIVERY_ATTEMPT) int retryNum) { public void payEventCallback(PayEvent event, @Header(DELIVERY_ATTEMPT) int retryNum) {
try { try {
log.info("start process pay event {}", event.getTransNo()); log.info("start process pay event {}", event.getTransNo());
payService.callback(event); payService.payCallback(event);
} catch (Exception e) { } catch (Exception e) {
log.info("process pay event fail {}", event.getTransNo(), e); log.info("process pay event fail {}", event.getTransNo(), e);
} }
......
package com.jiejing.fitness.finance.service.pay; package com.jiejing.fitness.finance.service.pay;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantPayParams; import com.jiejing.fitness.finance.service.pay.params.BrandMerchantPayParams;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantRefundParams;
import com.jiejing.paycenter.api.pay.vo.PayVO; import com.jiejing.paycenter.api.pay.vo.PayVO;
import com.jiejing.paycenter.api.pay.vo.RefundVO;
import com.jiejing.paycenter.common.event.PayEvent; import com.jiejing.paycenter.common.event.PayEvent;
/** /**
...@@ -23,6 +25,14 @@ public interface PayService { ...@@ -23,6 +25,14 @@ public interface PayService {
* *
* @param event 事件 * @param event 事件
*/ */
void callback(PayEvent event); void payCallback(PayEvent event);
/**
* 商户退款
*
* @param params 参数
* @return 结果
*/
RefundVO merchantRefund(BrandMerchantRefundParams params);
} }
...@@ -12,6 +12,7 @@ import com.jiejing.fitness.finance.repository.entity.BrandCashierRecord; ...@@ -12,6 +12,7 @@ import com.jiejing.fitness.finance.repository.entity.BrandCashierRecord;
import com.jiejing.fitness.finance.repository.entity.BrandToMerchant; import com.jiejing.fitness.finance.repository.entity.BrandToMerchant;
import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums; import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantPayParams; import com.jiejing.fitness.finance.service.pay.params.BrandMerchantPayParams;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantRefundParams;
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.api.merchant.vo.MerchantVO; import com.jiejing.paycenter.api.merchant.vo.MerchantVO;
...@@ -56,7 +57,7 @@ public class PayConvert { ...@@ -56,7 +57,7 @@ public class PayConvert {
return request; return request;
} }
public static BrandCashierRecord convertInit(BrandMerchantPayParams params, BrandToMerchant relation, public static BrandCashierRecord convertPayInit(BrandMerchantPayParams params, BrandToMerchant relation,
MerchantVO merchant) { MerchantVO merchant) {
setSubChannel(params); setSubChannel(params);
Long id = IdWorker.getId(); Long id = IdWorker.getId();
...@@ -136,7 +137,7 @@ public class PayConvert { ...@@ -136,7 +137,7 @@ public class PayConvert {
System.out.println(fee); System.out.println(fee);
} }
public static BrandCashierRecord convertRecord(BrandCashierRecord record, PayEvent event) { public static BrandCashierRecord convertPay(BrandCashierRecord record, PayEvent event) {
return BrandCashierRecord.builder() return BrandCashierRecord.builder()
.id(record.getId()) .id(record.getId())
.successTime(event.getFinishTime()) .successTime(event.getFinishTime())
......
...@@ -7,12 +7,15 @@ import com.jiejing.fitness.finance.repository.service.BrandToMerchantRpService; ...@@ -7,12 +7,15 @@ import com.jiejing.fitness.finance.repository.service.BrandToMerchantRpService;
import com.jiejing.fitness.finance.service.pay.PayService; 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.params.BrandMerchantPayParams; import com.jiejing.fitness.finance.service.pay.params.BrandMerchantPayParams;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantRefundParams;
import com.jiejing.fitness.finance.service.rpc.MerchantRpcService; import com.jiejing.fitness.finance.service.rpc.MerchantRpcService;
import com.jiejing.fitness.finance.service.rpc.PayRpcService; import com.jiejing.fitness.finance.service.rpc.PayRpcService;
import com.jiejing.fitness.finance.service.rpc.StudioRpcService; import com.jiejing.fitness.finance.service.rpc.StudioRpcService;
import com.jiejing.paycenter.api.merchant.vo.MerchantVO; import com.jiejing.paycenter.api.merchant.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.vo.PayVO; import com.jiejing.paycenter.api.pay.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.studio.api.studio.vo.StudioVO; import com.jiejing.studio.api.studio.vo.StudioVO;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -49,7 +52,7 @@ public class PayServiceImpl implements PayService { ...@@ -49,7 +52,7 @@ public class PayServiceImpl implements PayService {
MerchantVO merchant = merchantRpcService.getByMerchantId(relation.getMerchantId()); MerchantVO merchant = merchantRpcService.getByMerchantId(relation.getMerchantId());
BrandCashierRecord record = PayConvert.convertInit(params, relation, merchant); BrandCashierRecord record = PayConvert.convertPayInit(params, relation, merchant);
brandCashierRecordRpService.insert(record); brandCashierRecordRpService.insert(record);
PayRequest request = PayConvert.convert(params, record, merchant); PayRequest request = PayConvert.convert(params, record, merchant);
...@@ -57,15 +60,30 @@ public class PayServiceImpl implements PayService { ...@@ -57,15 +60,30 @@ public class PayServiceImpl implements PayService {
} }
@Override @Override
public void callback(PayEvent event) { public void payCallback(PayEvent event) {
BrandCashierRecord record = brandCashierRecordRpService.getById(Long.parseLong(event.getTransNo())) BrandCashierRecord record = brandCashierRecordRpService.getById(Long.parseLong(event.getTransNo()))
.orElse(null); .orElse(null);
if (null == record) { if (null == record) {
return; return;
} }
BrandCashierRecord toModify = PayConvert.convertRecord(record, event); BrandCashierRecord toModify = PayConvert.convertPay(record, event);
brandCashierRecordRpService.updateById(toModify); brandCashierRecordRpService.updateById(toModify);
} }
@Override
public RefundVO merchantRefund(BrandMerchantRefundParams params) {
StudioVO studio = studioRpcService.getStudio(params.getStudioId());
BrandToMerchant relation = brandToMerchantRpService.getByBrandId(studio.getBrandId());
MerchantVO merchant = merchantRpcService.getByMerchantId(relation.getMerchantId());
// BrandCashierRecord record = PayConvert.convertRefundInit(params, relation, merchant);
// brandCashierRecordRpService.insert(record);
//
// RefundPayRequest request = PayConvert.convert(params, record, merchant);
// return payRpcService.refund(request);
return null;
}
} }
package com.jiejing.fitness.finance.service.pay.params;
import com.alibaba.fastjson.JSONObject;
import com.jiejing.paycenter.common.enums.merchant.SubChannelEnums;
import com.jiejing.paycenter.common.enums.pay.PayTypeEnums;
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 javax.validation.constraints.Size;
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 = "品牌商户退款Params")
public class BrandMerchantRefundParams {
@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 orderNo;
@ApiModelProperty(name = "业务订单类型", required = true)
@NotNull(message = "业务订单类型不能为空")
private Integer orderType;
@ApiModelProperty(name = "支付类型", required = true)
@NotNull(message = "支付类型不能为空")
private PayTypeEnums payType;
@ApiModelProperty(name = "正扫:三方支付账户ID", notes = "微信的openId,支付宝的userId,JS、MINI、NATIVE支付必传")
private String openId;
@ApiModelProperty(name = "反扫:支付授权码", notes = "扫码设备读出的条形码或者二维码信息,BARCODE支付必传")
private String authCode;
@ApiModelProperty(name = "支付子渠道", notes = "聚合支付时需要")
private SubChannelEnums subChannel;
@ApiModelProperty(name = "商品名称", required = true)
@NotBlank(message = "商品名称不能为空")
private String goods;
@ApiModelProperty(name = "付款人姓名", required = true)
@NotBlank(message = "付款人姓名不能为空")
@Size(max = 30)
private String buyerName;
@ApiModelProperty(name = "付款人手机号", required = true)
@NotBlank(message = "付款人手机号不能为空")
@Size(max = 11)
private String buyerPhone;
@ApiModelProperty(name = "备注")
private String remark;
@ApiModelProperty(name = "appId", notes = "指定本次使用的appId")
private String appId;
@ApiModelProperty(name = "过期时间(单位:秒)", required = true)
@NotNull(message = "过期时间不能为空")
private Integer timeExpire;
@ApiModelProperty(name = "业务扩展信息")
private JSONObject extra;
}
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