提交
This commit is contained in:
@ -1,11 +1,13 @@
|
||||
package co.yixiang.yshop.module.pay.config.handlers;
|
||||
|
||||
import co.yixiang.yshop.module.pay.enums.PayTypeEnum;
|
||||
import co.yixiang.yshop.module.pay.mq.producer.PayNoticeProducer;
|
||||
import com.egzosn.pay.ali.api.AliPayService;
|
||||
import com.egzosn.pay.ali.bean.AliPayMessage;
|
||||
import com.egzosn.pay.common.api.PayMessageHandler;
|
||||
import com.egzosn.pay.common.bean.PayOutMessage;
|
||||
import com.egzosn.pay.common.exception.PayErrorException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -16,6 +18,7 @@ import java.util.Map;
|
||||
* @author hupeng
|
||||
* @date 2023/7/15
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AliPayMessageHandler implements PayMessageHandler<AliPayMessage, AliPayService> {
|
||||
|
||||
@ -41,9 +44,10 @@ public class AliPayMessageHandler implements PayMessageHandler<AliPayMessage, Al
|
||||
if ("TRADE_SUCCESS".equals(trade_status) || "TRADE_FINISHED".equals(trade_status)) {
|
||||
|
||||
String orderId = (String) payMessage.getPayMessage().get("out_trade_no");
|
||||
log.info("支付宝回调消息处理,发送处理消息orderId={}",orderId);
|
||||
//消息队列处理
|
||||
payNoticeProducer.sendPayNoticeMessage(orderId,"alipay");
|
||||
|
||||
payNoticeProducer.sendPayNoticeMessage(orderId, PayTypeEnum.ALI.getValue());
|
||||
log.info("支付宝回调消息发送完毕");
|
||||
return payService.getPayOutMessage("success", "成功");
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package co.yixiang.yshop.module.pay.config.handlers;
|
||||
|
||||
import co.yixiang.yshop.module.pay.enums.PayTypeEnum;
|
||||
import co.yixiang.yshop.module.pay.mq.producer.PayNoticeProducer;
|
||||
import com.egzosn.pay.common.api.PayMessageHandler;
|
||||
import com.egzosn.pay.common.api.PayService;
|
||||
@ -17,6 +18,7 @@ import java.util.Map;
|
||||
* @author hupeng
|
||||
* @date 2023/7/15
|
||||
*/
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class WxPayMessageHandler implements PayMessageHandler<WxPayMessage, PayService> {
|
||||
@ -33,7 +35,8 @@ public class WxPayMessageHandler implements PayMessageHandler<WxPayMessage, PayS
|
||||
if ("SUCCESS".equals(payMessage.getPayMessage().get("result_code"))){
|
||||
String orderId = (String) payMessage.getPayMessage().get("out_trade_no");
|
||||
//消息队列处理
|
||||
payNoticeProducer.sendPayNoticeMessage(orderId,"weixin");
|
||||
log.info("微信回调消息处理,发送处理消息orderId={}",orderId);
|
||||
payNoticeProducer.sendPayNoticeMessage(orderId, PayTypeEnum.WEIXIN.getValue());
|
||||
|
||||
return payService.getPayOutMessage("SUCCESS", "OK");
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (C) 2018-2022
|
||||
* All rights reserved, Designed By www.yixiang.co
|
||||
|
||||
*/
|
||||
package co.yixiang.yshop.module.pay.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* 支付相关枚举
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum PayTypeEnum {
|
||||
|
||||
ALI("alipay","支付宝支付"),
|
||||
WEIXIN("weixin","微信支付"),
|
||||
WEIXIN_H5("weixin_h5","微信H5支付"),
|
||||
WEIXIN_APPLET("weixin_applet","微信小程序支付"),
|
||||
WEIXIN_APP("weixin_app","微信app支付"),
|
||||
YUE("yue","余额支付"),
|
||||
INTEGRAL("integral","积分兑换");
|
||||
|
||||
|
||||
private String value;
|
||||
private String desc;
|
||||
|
||||
public static PayTypeEnum toType(String value) {
|
||||
return Stream.of(PayTypeEnum.values())
|
||||
.filter(p -> p.value.equals(value))
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user