|
@@ -11,6 +11,7 @@ import cn.hutool.json.JSONUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dromara.backstage.config.ThirdPayConfig;
|
|
import org.dromara.backstage.config.ThirdPayConfig;
|
|
|
|
|
+import org.dromara.backstage.mq.PushKafkaData;
|
|
|
import org.dromara.backstage.payment.domain.bo.PayOrderBo;
|
|
import org.dromara.backstage.payment.domain.bo.PayOrderBo;
|
|
|
import org.dromara.backstage.payment.domain.bo.PurseInOutBo;
|
|
import org.dromara.backstage.payment.domain.bo.PurseInOutBo;
|
|
|
import org.dromara.backstage.payment.domain.vo.PayOrderVo;
|
|
import org.dromara.backstage.payment.domain.vo.PayOrderVo;
|
|
@@ -19,6 +20,9 @@ import org.dromara.backstage.payment.service.IPayOrderService;
|
|
|
import org.dromara.backstage.payment.service.IPtUserAccountService;
|
|
import org.dromara.backstage.payment.service.IPtUserAccountService;
|
|
|
import org.dromara.common.core.domain.R;
|
|
import org.dromara.common.core.domain.R;
|
|
|
import org.dromara.common.core.enums.*;
|
|
import org.dromara.common.core.enums.*;
|
|
|
|
|
+import org.dromara.common.message.kafka.constant.EventTypeConstants;
|
|
|
|
|
+import org.dromara.common.message.kafka.constant.KafkaTopicConstants;
|
|
|
|
|
+import org.dromara.common.message.kafka.enums.EventSenderEnum;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
@@ -44,9 +48,11 @@ public class ThirdPayBusiness {
|
|
|
private final PayOrderBusiness payOrderBusiness;
|
|
private final PayOrderBusiness payOrderBusiness;
|
|
|
private final ThirdPayConfig thirdPayConfig;
|
|
private final ThirdPayConfig thirdPayConfig;
|
|
|
private final IPtUserAccountService userAccountService;
|
|
private final IPtUserAccountService userAccountService;
|
|
|
|
|
+ private final PushKafkaData kafkaNormalProducer;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 创建二维码支付的收款码
|
|
* 创建二维码支付的收款码
|
|
|
|
|
+ *
|
|
|
* @param mapParams 二维码参数
|
|
* @param mapParams 二维码参数
|
|
|
* @return 二维信息
|
|
* @return 二维信息
|
|
|
*/
|
|
*/
|
|
@@ -63,10 +69,11 @@ public class ThirdPayBusiness {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 创建直接支付
|
|
* 创建直接支付
|
|
|
|
|
+ *
|
|
|
* @param mapParams 直接支付订单参数
|
|
* @param mapParams 直接支付订单参数
|
|
|
* @return 支付结果
|
|
* @return 支付结果
|
|
|
*/
|
|
*/
|
|
|
- public R<String> createDirectPayment(Map<String, String> mapParams){
|
|
|
|
|
|
|
+ public R<String> createDirectPayment(Map<String, String> mapParams) {
|
|
|
R<PayOrderVo> result = createThirdPayOrder(mapParams);
|
|
R<PayOrderVo> result = createThirdPayOrder(mapParams);
|
|
|
if (R.isError(result)) {
|
|
if (R.isError(result)) {
|
|
|
return R.fail(result.getMsg());
|
|
return R.fail(result.getMsg());
|
|
@@ -79,12 +86,13 @@ public class ThirdPayBusiness {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 创建第三方充值支付订单
|
|
* 创建第三方充值支付订单
|
|
|
|
|
+ *
|
|
|
* @param mapParams 订单参数
|
|
* @param mapParams 订单参数
|
|
|
* @return 订单信息
|
|
* @return 订单信息
|
|
|
*/
|
|
*/
|
|
|
public R<PayOrderVo> createThirdPayOrder(Map<String, String> mapParams) {
|
|
public R<PayOrderVo> createThirdPayOrder(Map<String, String> mapParams) {
|
|
|
Long userId = Long.valueOf(mapParams.get("userId"));
|
|
Long userId = Long.valueOf(mapParams.get("userId"));
|
|
|
- BigDecimal dealValue = new BigDecimal(mapParams.get("dealValue"));
|
|
|
|
|
|
|
+ BigDecimal dealValue = new BigDecimal(mapParams.get("dealValue"));
|
|
|
R<PayOrderBo> result = createPayOrderBo(userId, dealValue);
|
|
R<PayOrderBo> result = createPayOrderBo(userId, dealValue);
|
|
|
|
|
|
|
|
if (R.isError(result)) {
|
|
if (R.isError(result)) {
|
|
@@ -103,7 +111,8 @@ public class ThirdPayBusiness {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 组装第三方充值支付订单业务对象
|
|
* 组装第三方充值支付订单业务对象
|
|
|
- * @param userId 人员Id
|
|
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param userId 人员Id
|
|
|
* @param dealValue 充值金额
|
|
* @param dealValue 充值金额
|
|
|
* @return 订单业务对象
|
|
* @return 订单业务对象
|
|
|
*/
|
|
*/
|
|
@@ -162,16 +171,14 @@ public class ThirdPayBusiness {
|
|
|
return R.fail("订单入账失败");
|
|
return R.fail("订单入账失败");
|
|
|
}
|
|
}
|
|
|
// 3.更新订单的入账状态
|
|
// 3.更新订单的入账状态
|
|
|
- if (R.isSuccess(postResult)) {
|
|
|
|
|
- // 更新支付订单表的入账状态
|
|
|
|
|
- PayOrderBo updateBo = new PayOrderBo();
|
|
|
|
|
- updateBo.setOrderId(postBo.getOrderId());
|
|
|
|
|
- updateBo.setOriginalId(postResult.getData().getOriginalId());
|
|
|
|
|
- updateBo.setCreditStatus(CreditStatusEnum.SUCCESS.code().toString());
|
|
|
|
|
|
|
+ PayOrderBo updateBo = new PayOrderBo();
|
|
|
|
|
+ updateBo.setOrderId(postBo.getOrderId());
|
|
|
|
|
+ updateBo.setOriginalId(postResult.getData().getOriginalId());
|
|
|
|
|
+ updateBo.setCreditStatus(CreditStatusEnum.SUCCESS.code().toString());
|
|
|
|
|
+ //充值信息发送kafka
|
|
|
|
|
+ kafkaNormalProducer.sendKafkaMessage(KafkaTopicConstants.SYNC_DATA_TOPIC, EventTypeConstants.RECHARGE, EventSenderEnum.BACKSTAGE.code(), postResult.getData());
|
|
|
|
|
|
|
|
- return setOrderPostResult(updateBo);
|
|
|
|
|
- }
|
|
|
|
|
- return R.ok();
|
|
|
|
|
|
|
+ return setOrderPostResult(updateBo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -245,6 +252,7 @@ public class ThirdPayBusiness {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 根据一卡通订单号查询充值订单支付结果
|
|
* 根据一卡通订单号查询充值订单支付结果
|
|
|
|
|
+ *
|
|
|
* @param orderSn 订单号
|
|
* @param orderSn 订单号
|
|
|
* @return 查询结果
|
|
* @return 查询结果
|
|
|
*/
|
|
*/
|
|
@@ -261,6 +269,7 @@ public class ThirdPayBusiness {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 生成微信的二维码
|
|
* 生成微信的二维码
|
|
|
|
|
+ *
|
|
|
* @param vo 订单信息
|
|
* @param vo 订单信息
|
|
|
* @return 二维码
|
|
* @return 二维码
|
|
|
*/
|
|
*/
|
|
@@ -287,7 +296,7 @@ public class ThirdPayBusiness {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private R<String> requestForPayment(PayOrderVo vo, Map<String, String> mapParams){
|
|
|
|
|
|
|
+ private R<String> requestForPayment(PayOrderVo vo, Map<String, String> mapParams) {
|
|
|
String sendUrl = thirdPayConfig.getPayApi() + "toPay";
|
|
String sendUrl = thirdPayConfig.getPayApi() + "toPay";
|
|
|
vo.setBackUrl(thirdPayConfig.getRechargeBackUrl() + vo.getOrderId());
|
|
vo.setBackUrl(thirdPayConfig.getRechargeBackUrl() + vo.getOrderId());
|
|
|
HttpRequest req = HttpUtil.createPost(sendUrl);
|
|
HttpRequest req = HttpUtil.createPost(sendUrl);
|