支付调整
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.czg.service.order.mapper;
|
||||
|
||||
import com.czg.order.entity.ShopMerchant;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
|
||||
/**
|
||||
* 第三方商户进件 映射层。
|
||||
*
|
||||
* @author Administrator
|
||||
* @since 2025-02-11
|
||||
*/
|
||||
public interface ShopMerchantMapper extends BaseMapper<ShopMerchant> {
|
||||
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.czg.service.order.service;
|
||||
|
||||
import com.czg.entity.req.*;
|
||||
import com.czg.entity.resp.CzgBaseResp;
|
||||
import com.czg.entity.resp.CzgRefundResp;
|
||||
import com.czg.enums.CzgPayEnum;
|
||||
import com.czg.order.dto.LtPayOtherDTO;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.pay.CzgPayBaseReq;
|
||||
import com.czg.pay.CzgRefundReq;
|
||||
import com.czg.resp.CzgResult;
|
||||
import lombok.NonNull;
|
||||
|
||||
@@ -21,14 +23,10 @@ public interface PayService {
|
||||
BigDecimal MONEY_RATE = new BigDecimal("100");
|
||||
|
||||
|
||||
Long initOrderPayment(OrderPayment payment);
|
||||
Long initPayment(OrderPayment payment);
|
||||
|
||||
//-----------------------------------------------------------------付款 ----------------------------------------------------------
|
||||
CzgResult<Map<String, Object>> h5Pay(@NonNull Long shopId, CzgH5PayReq bizData);
|
||||
CzgResult<Map<String, Object>> jsPay(@NonNull Long shopId, @NonNull String payType, CzgJsPayReq bizData);
|
||||
CzgResult<Map<String, Object>> ltPay(@NonNull Long shopId, String payType, CzgLtPayReq bizData);
|
||||
CzgResult<Map<String, Object>> scanPay(@NonNull Long shopId, CzgScanPayReq bizData);
|
||||
CzgResult<Map<String, Object>> microPay(@NonNull Long shopId, CzgMicroPayReq bizData);
|
||||
CzgResult<Map<String, Object>> pay(@NonNull Long shopId, CzgPayEnum payType, CzgPayBaseReq<?> bizData);
|
||||
//-----------------------------------------------------------------积分商品/拼团 付款 ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,13 +7,14 @@ import com.czg.account.service.ShopUserService;
|
||||
import com.czg.account.service.UserInfoService;
|
||||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.constants.PayTypeConstants;
|
||||
import com.czg.entity.req.CzgLtPayReq;
|
||||
import com.czg.enums.CzgPayEnum;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.service.MkDistributionConfigService;
|
||||
import com.czg.market.vo.MkDistributionConfigVO;
|
||||
import com.czg.order.dto.MkDistributionPayDTO;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
import com.czg.pay.CzgPayBaseReq;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.market.service.impl.WxServiceImpl;
|
||||
import com.czg.service.order.service.DistributionPayService;
|
||||
@@ -67,7 +68,7 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
||||
ShopUser shopUserInfo = shopUserService.getShopUserInfo(payParam.getShopId(), userId);
|
||||
|
||||
OrderPayment orderPayment = new OrderPayment().setShopId(payParam.getShopId()).setSourceId(isRecharge ? payParam.getShopId() : shopUserInfo.getId())
|
||||
.setSourceType(isRecharge ? PayTypeConstants.SourceType.DISTRIBUTION_RECHARGE : PayTypeConstants.SourceType.DISTRIBUTION )
|
||||
.setSourceType(isRecharge ? PayTypeConstants.SourceType.DISTRIBUTION_RECHARGE : PayTypeConstants.SourceType.DISTRIBUTION)
|
||||
.setPayType(PayTypeConstants.PayType.PAY)
|
||||
.setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId())
|
||||
.setAmount(isRecharge ? payParam.getAmount() : detail.getPayAmount());
|
||||
@@ -89,12 +90,13 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
||||
@Override
|
||||
public CzgResult<Map<String, Object>> ltPayOrder(String clintIp, MkDistributionPayDTO payParam) {
|
||||
InitInfo initInfo = initPayment(payParam.getUserId(), payParam, false);
|
||||
return payService.ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(initInfo.payment.getOrderNo(), initInfo.payment.getAmount().multiply(MONEY_RATE).longValue(),
|
||||
payParam.getPayType(), "分销员开通", initInfo.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
return payService.pay(payParam.getShopId(), CzgPayEnum.LT_PAY,
|
||||
CzgPayBaseReq.ltPayReq(initInfo.payment.getOrderNo(), "分销员开通", initInfo.payment.getAmount().multiply(MONEY_RATE).longValue(),
|
||||
payParam.getPayType(), initInfo.getOpenId(), clintIp));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> mchRecharge(String clientIP, MkDistributionPayDTO payParam) {
|
||||
public Map<String, String> mchRecharge(MkDistributionPayDTO payParam) {
|
||||
InitInfo initInfo = initPayment(payParam.getUserId() == null ? payParam.getShopId() : payParam.getUserId(), payParam, true);
|
||||
return wxService.v3Pay(initInfo.openId, payParam.getAmount(), "商户运营余额充值", initInfo.payment.getOrderNo(), initInfo.payment.getSourceType());
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ import com.czg.account.service.UserInfoService;
|
||||
import com.czg.config.RabbitPublisher;
|
||||
import com.czg.config.RedisCst;
|
||||
import com.czg.constants.PayTypeConstants;
|
||||
import com.czg.entity.req.*;
|
||||
import com.czg.entity.resp.CzgRefundResp;
|
||||
import com.czg.enums.CzgPayEnum;
|
||||
import com.czg.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.exception.PaySuccessException;
|
||||
@@ -36,6 +36,8 @@ import com.czg.order.service.CreditBuyerOrderService;
|
||||
import com.czg.order.service.OrderDetailService;
|
||||
import com.czg.order.service.OrderInfoCustomService;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
import com.czg.pay.CzgPayBaseReq;
|
||||
import com.czg.pay.CzgRefundReq;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.service.order.dto.OrderPayParamDTO;
|
||||
@@ -62,6 +64,9 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class OrderPayServiceImpl implements OrderPayService {
|
||||
@@ -227,13 +232,15 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
return CzgResult.failure("支付失败 充值金额必须大雨订单金额");
|
||||
}
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), PayTypeConstants.SourceType.MEMBER_IN, PayTypeConstants.PayType.PAY, payOrderNo,
|
||||
"", rechargeDetail.getAmount(), rechargeDetail.getId()));
|
||||
Long paymentId = payService.initPayment(OrderPayment.pay(payParam.getShopId(), shopUser.getId(), PayTypeConstants.SourceType.MEMBER_IN,
|
||||
payOrderNo, rechargeDetail.getAmount(), "", rechargeDetail.getId()));
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.VIP_PAY, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, rechargeDetail.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
payParam.getPayType(), "充值并支付", "wechatPay".equals(payParam.getPayType()) ? userInfo.getWechatOpenId() : userInfo.getAlipayOpenId(),
|
||||
clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
return payService.pay(payParam.getShopId(), CzgPayEnum.LT_PAY,
|
||||
CzgPayBaseReq.ltPayReq(
|
||||
payOrderNo, "充值并支付",
|
||||
rechargeDetail.getAmount().multiply(PayService.MONEY_RATE).longValue(), payParam.getPayType(),
|
||||
"wechatPay".equals(payParam.getPayType()) ? userInfo.getWechatOpenId() : userInfo.getAlipayOpenId(), clintIp));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -241,12 +248,10 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
public CzgResult<Map<String, Object>> h5PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.H5_PAY, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.h5Pay(payParam.getShopId(), new CzgH5PayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
"点餐支付", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.H5_PAY, paymentId, payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.pay(payParam.getShopId(), CzgPayEnum.H5_PAY,
|
||||
CzgPayBaseReq.h5PayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(), clintIp));
|
||||
}
|
||||
|
||||
|
||||
@@ -257,12 +262,12 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
||||
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
"点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
|
||||
CzgPayBaseReq.jsPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
payParam.getPayType(), payParam.getOpenId(), clintIp));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -281,12 +286,12 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
orderInfo = orderInfoService.getById(payParam.getCheckOrderPay().getOrderId());
|
||||
}
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
||||
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
"点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
|
||||
CzgPayBaseReq.jsPayReq(payOrderNo, "扫码支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
payParam.getPayType(), payParam.getOpenId(), clintIp));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -296,12 +301,12 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
||||
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
payParam.getPayType(), "点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
return payService.pay(payParam.getShopId(), CzgPayEnum.LT_PAY,
|
||||
CzgPayBaseReq.ltPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
payParam.getPayType(), payParam.getOpenId(), clintIp));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -317,12 +322,11 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
BigDecimal amount = shopRechargeService.checkRecharge(mainShopId, payParam.getShopId(), shopUser.getUserId(), payParam.getRechargeDetailId(), payParam.getAmount());
|
||||
payParam.setAmount(amount);
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
||||
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.MAIN_SCAN, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.scanPay(payParam.getShopId(), new CzgScanPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
"点餐支付", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
return payService.pay(payParam.getShopId(), CzgPayEnum.SCAN_PAY,
|
||||
CzgPayBaseReq.scanPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(), clintIp));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -344,10 +348,9 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
}
|
||||
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, payParam.getAuthCode(), orderInfo.getOrderAmount()));
|
||||
CzgResult<Map<String, Object>> mapCzgResult = payService.microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
"点餐支付", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
|
||||
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), payParam.getAuthCode()));
|
||||
CzgResult<Map<String, Object>> mapCzgResult = payService.pay(payParam.getShopId(), CzgPayEnum.MICRO_PAY,
|
||||
CzgPayBaseReq.microPay(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(), payParam.getAuthCode()));
|
||||
if (mapCzgResult.getCode() == 200) {
|
||||
orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
||||
LocalDateTime.now(), paymentId, PayEnums.BACK_SCAN);
|
||||
@@ -508,8 +511,11 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
|
||||
OrderPayment payment = paymentService.getById(payOrderId);
|
||||
AssertUtil.isNull(payment, "退款失败支付记录不存在");
|
||||
Long refundId = payService.initOrderPayment(new OrderPayment(shopId, orderId, PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.REFUND, refPayOrderNo, null, refundAmount, payment.getId()));
|
||||
CzgResult<CzgRefundResp> refund = payService.refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), ""));
|
||||
Long refundId = payService.initPayment(OrderPayment.refund(shopId, orderId, PayTypeConstants.SourceType.ORDER,
|
||||
refPayOrderNo, refundAmount, payment.getId()));
|
||||
|
||||
CzgResult<CzgRefundResp> refund = payService.refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(PayService.MONEY_RATE).longValue(),
|
||||
payment.getAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), ""));
|
||||
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
|
||||
if (refund.getData() != null && refund.getData().getNote() != null) {
|
||||
throw new CzgException(refund.getData().getNote());
|
||||
|
||||
@@ -2,19 +2,24 @@ package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.CzgPayUtils;
|
||||
import com.czg.account.entity.ShopMerchant;
|
||||
import com.czg.account.service.ShopMerchantService;
|
||||
import com.czg.PayAdapter;
|
||||
import com.czg.PayAdapterFactory;
|
||||
import com.czg.order.entity.ShopMerchant;
|
||||
import com.czg.order.service.ShopMerchantService;
|
||||
import com.czg.constant.PayChannelCst;
|
||||
import com.czg.constants.ParamCodeCst;
|
||||
import com.czg.constants.PayTypeConstants;
|
||||
import com.czg.entity.req.*;
|
||||
import com.czg.entity.resp.CzgBaseResp;
|
||||
import com.czg.entity.resp.CzgRefundResp;
|
||||
import com.czg.enums.CzgPayEnum;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.order.dto.LtPayOtherDTO;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
import com.czg.pay.CzgPayBaseReq;
|
||||
import com.czg.pay.CzgRefundReq;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.order.mapper.OrderPaymentMapper;
|
||||
import com.czg.service.order.service.PayService;
|
||||
@@ -49,66 +54,16 @@ public class PayServiceImpl implements PayService {
|
||||
private OrderPaymentMapper paymentMapper;
|
||||
|
||||
@Override
|
||||
public CzgResult<Map<String, Object>> h5Pay(@NonNull Long shopId, CzgH5PayReq bizData) {
|
||||
public CzgResult<Map<String, Object>> pay(@NonNull Long shopId, CzgPayEnum payType, CzgPayBaseReq<?> bizData) {
|
||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
||||
getNotifyUrl());
|
||||
return CzgPayUtils.h5Pay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<Map<String, Object>> jsPay(@NonNull Long shopId, @NonNull String payType, CzgJsPayReq bizData) {
|
||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
||||
bizData.setSubAppid("aliPay".equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
|
||||
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(payType) ? "支付宝" : "微信") + "小程序");
|
||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
||||
getNotifyUrl());
|
||||
bizData.setPayType("aliPay".equals(payType) ? "ALIPAY" : "WECHAT");
|
||||
return CzgPayUtils.jsPay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<Map<String, Object>> ltPay(@NonNull Long shopId, String payType, CzgLtPayReq bizData) {
|
||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
||||
bizData.setSubAppid("aliPay".equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
|
||||
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(payType) ? "支付宝" : "微信") + "小程序");
|
||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
||||
getNotifyUrl());
|
||||
return CzgPayUtils.ltPay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<Map<String, Object>> scanPay(@NonNull Long shopId, CzgScanPayReq bizData) {
|
||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
||||
getNotifyUrl());
|
||||
return CzgPayUtils.scanPay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<Map<String, Object>> microPay(@NonNull Long shopId, CzgMicroPayReq bizData) {
|
||||
AssertUtil.isBlank(bizData.getAuthCode(), "扫码失败,请重试");
|
||||
if (bizData.getAuthCode().length() > 26) {
|
||||
throw new CzgException("支付失败,不支持的条码");
|
||||
PayAdapter adapter = PayAdapterFactory.getAdapter(shopMerchant.getChannel());
|
||||
String payData = null;
|
||||
if (shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
|
||||
payData = shopMerchant.getNativePayJson();
|
||||
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
|
||||
payData = shopMerchant.getPolyPayJson();
|
||||
}
|
||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
||||
getNotifyUrl());
|
||||
String firstTwoDigitsStr = bizData.getAuthCode().substring(0, 2);
|
||||
// 将截取的字符串转换为整数
|
||||
int firstTwoDigits = Integer.parseInt(firstTwoDigitsStr);
|
||||
// 判断范围
|
||||
if (firstTwoDigits >= 10 && firstTwoDigits <= 15) {
|
||||
//微信支付
|
||||
bizData.setSubAppid(shopMerchant.getWechatSmallAppid());
|
||||
} else if (firstTwoDigits >= 25 && firstTwoDigits <= 30) {
|
||||
//支付宝支付
|
||||
bizData.setSubAppid(shopMerchant.getAlipaySmallAppid());
|
||||
} else {
|
||||
throw new CzgException("扫描码非法或暂不支持");
|
||||
}
|
||||
return CzgPayUtils.microPay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||
return adapter.pay(payType, payData, getDomain(), getNotifyUrl(shopMerchant.getChannel()), bizData);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,17 +72,25 @@ public class PayServiceImpl implements PayService {
|
||||
AssertUtil.isBlank(param.getOpenId(), "用户小程序ID不能为空");
|
||||
AssertUtil.isBlank(param.getPayType(), "支付方式不能为空");
|
||||
String payOrderNo = "LT" + IdUtil.getSnowflakeNextId();
|
||||
initOrderPayment(new OrderPayment(param.getShopId(), param.getRecordId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
|
||||
"", param.getPrice(), null));
|
||||
return ltPay(param.getShopId(), param.getPayType(), new CzgLtPayReq(payOrderNo, param.getPrice().multiply(MONEY_RATE).longValue(),
|
||||
param.getPayType(), detail, param.getOpenId(), param.getIp(), "", "", ""));
|
||||
initPayment(OrderPayment.pay(param.getShopId(), param.getRecordId(), payType, payOrderNo,
|
||||
param.getPrice(), "", null));
|
||||
return pay(param.getShopId(), CzgPayEnum.LT_PAY,
|
||||
CzgPayBaseReq.ltPayReq(payOrderNo, detail, param.getPrice().multiply(MONEY_RATE).longValue(),
|
||||
param.getPayType(), param.getOpenId(), param.getIp()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<CzgRefundResp> refund(@NonNull Long shopId, CzgRefundReq bizData) {
|
||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
||||
bizData.setNotifyUrl(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_REFUND_NOTIFY_URL));
|
||||
return CzgPayUtils.refundOrder(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||
PayAdapter adapter = PayAdapterFactory.getAdapter(shopMerchant.getChannel());
|
||||
String payData = null;
|
||||
if (shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
|
||||
payData = shopMerchant.getNativePayJson();
|
||||
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
|
||||
payData = shopMerchant.getPolyPayJson();
|
||||
}
|
||||
// bizData.setNotifyUrl(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_REFUND_NOTIFY_URL));
|
||||
return adapter.refund(getDomain(), payData, "", bizData);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,9 +99,9 @@ public class PayServiceImpl implements PayService {
|
||||
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
|
||||
OrderPayment payment = paymentService.getById(payOrderId);
|
||||
AssertUtil.isNull(payment, "退款失败,支付记录不存在");
|
||||
Long refundId = initOrderPayment(new OrderPayment(shopId, sourceId, payment.getSourceType(), PayTypeConstants.PayType.REFUND, refPayOrderNo, null, refundAmount, payment.getId()));
|
||||
Long refundId = initPayment(OrderPayment.refund(shopId, sourceId, payment.getSourceType(), refPayOrderNo, refundAmount, payment.getId()));
|
||||
CzgResult<CzgRefundResp> refund = refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(MONEY_RATE).longValue(),
|
||||
payment.getOrderNo(), ""));
|
||||
payment.getAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), ""));
|
||||
OrderPayment uOrderPayment = new OrderPayment();
|
||||
uOrderPayment.setRespJson(JSONObject.toJSONString(refund.getData()));
|
||||
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
|
||||
@@ -157,10 +120,10 @@ public class PayServiceImpl implements PayService {
|
||||
//支付的 订单
|
||||
OrderPayment payment = paymentService.getById(refundPayment.getRelatedId());
|
||||
AssertUtil.isNull(payment, "退款失败,支付记录不存在");
|
||||
Long refundCompensate = initOrderPayment(new OrderPayment(refundPayment.getShopId(), refundPayment.getSourceId(), payment.getSourceType(), PayTypeConstants.PayType.REFUND_COMPENSATE,
|
||||
refPayOrderNo, null, refundPayment.getAmount(), refundPayment.getId()));
|
||||
Long refundCompensate = initPayment(OrderPayment.refundCompensate(refundPayment.getShopId(), refundPayment.getSourceId(),
|
||||
payment.getSourceType(), refPayOrderNo, refundPayment.getAmount(), refundPayment.getId()));
|
||||
CzgResult<CzgRefundResp> refund = refund(payment.getShopId(), new CzgRefundReq(refPayOrderNo, "退款补偿", refundPayment.getAmount().multiply(MONEY_RATE).longValue(),
|
||||
payment.getOrderNo(), ""));
|
||||
payment.getAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), ""));
|
||||
OrderPayment uOrderPayment = new OrderPayment();
|
||||
uOrderPayment.setTradeNumber(refund.getData().getRefundOrderId());
|
||||
uOrderPayment.setRespJson(JSONObject.toJSONString(refund.getData()));
|
||||
@@ -178,26 +141,55 @@ public class PayServiceImpl implements PayService {
|
||||
@Transactional
|
||||
public CzgResult<CzgBaseResp> queryPayOrder(@NonNull Long shopId, String payOrderId, String mchOrderNo) {
|
||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
||||
return CzgPayUtils.queryPayOrder(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), payOrderId, mchOrderNo);
|
||||
PayAdapter adapter = PayAdapterFactory.getAdapter(shopMerchant.getChannel());
|
||||
String payData = null;
|
||||
if (shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
|
||||
payData = shopMerchant.getNativePayJson();
|
||||
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
|
||||
payData = shopMerchant.getPolyPayJson();
|
||||
}
|
||||
return adapter.queryPayOrder(getDomain(), payData, payOrderId, mchOrderNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<CzgRefundResp> queryRefund(@NonNull Long shopId, String mchRefundNo, String refundOrderId) {
|
||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
||||
return CzgPayUtils.queryRefundOrder(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), mchRefundNo, refundOrderId);
|
||||
PayAdapter adapter = PayAdapterFactory.getAdapter(shopMerchant.getChannel());
|
||||
String payData = null;
|
||||
if (shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
|
||||
payData = shopMerchant.getNativePayJson();
|
||||
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
|
||||
payData = shopMerchant.getPolyPayJson();
|
||||
}
|
||||
return adapter.queryRefund(getDomain(), payData, mchRefundNo, refundOrderId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Long initOrderPayment(OrderPayment payment) {
|
||||
public Long initPayment(OrderPayment payment) {
|
||||
paymentMapper.insert(payment);
|
||||
return payment.getId();
|
||||
}
|
||||
|
||||
private ShopMerchant getMerchant(Long shopId) {
|
||||
try {
|
||||
return shopMerchantService.getById(shopId);
|
||||
ShopMerchant shopMerchant = shopMerchantService.getById(shopId);
|
||||
if (shopMerchant == null || StrUtil.isBlank(shopMerchant.getChannel())) {
|
||||
throw new CzgException("暂未开通支付");
|
||||
}
|
||||
if (shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
|
||||
if (StrUtil.isNotBlank(shopMerchant.getNativePayJson())) {
|
||||
throw new CzgException("原生支付未开通");
|
||||
}
|
||||
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
|
||||
if (StrUtil.isNotBlank(shopMerchant.getPolyPayJson())) {
|
||||
throw new CzgException("聚合支付未开通");
|
||||
}
|
||||
} else {
|
||||
throw new CzgException("暂不支持的支付渠道");
|
||||
}
|
||||
return shopMerchant;
|
||||
} catch (Exception e) {
|
||||
throw new CzgException("暂未开通支付");
|
||||
}
|
||||
@@ -207,7 +199,16 @@ public class PayServiceImpl implements PayService {
|
||||
return sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN);
|
||||
}
|
||||
|
||||
private String getNotifyUrl() {
|
||||
return sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_NOTIFY_URL);
|
||||
private String getNotifyUrl(String channel) {
|
||||
String notifyUrl = "";
|
||||
if (channel.equals(PayChannelCst.NATIVE)) {
|
||||
notifyUrl = sysParamsService.getSysParamValue(ParamCodeCst.System.NATIVE_PAY_NOTIFY_URL);
|
||||
} else if (channel.equals(PayChannelCst.POLY)) {
|
||||
notifyUrl = sysParamsService.getSysParamValue(ParamCodeCst.System.POLY_PAY_NOTIFY_URL);
|
||||
}
|
||||
if (StrUtil.isBlank(notifyUrl)) {
|
||||
throw new CzgException(channel.equals(PayChannelCst.NATIVE) ? "原生支付回调地址未配置" : "聚合支付回调地址未配置");
|
||||
}
|
||||
return notifyUrl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.constant.PayChannelCst;
|
||||
import com.czg.order.dto.ShopMerchantDTO;
|
||||
import com.czg.order.entity.ShopDirectMerchant;
|
||||
import com.czg.order.entity.ShopMerchant;
|
||||
import com.czg.order.service.ShopMerchantService;
|
||||
import com.czg.pay.NativeMerchantDTO;
|
||||
import com.czg.pay.PolyMerchantDTO;
|
||||
import com.czg.service.order.mapper.ShopMerchantMapper;
|
||||
import com.czg.service.order.service.ShopDirectMerchantService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 第三方商户进件 服务层实现。
|
||||
*
|
||||
* @author Administrator
|
||||
* @since 2025-02-11
|
||||
*/
|
||||
@CacheConfig(cacheNames = "shop:merchant")
|
||||
@Service
|
||||
public class ShopMerchantServiceImpl extends ServiceImpl<ShopMerchantMapper, ShopMerchant> implements ShopMerchantService {
|
||||
|
||||
@Resource
|
||||
private ShopDirectMerchantService shopDirectMerchantService;
|
||||
@DubboReference
|
||||
private ShopInfoService shopInfoService;
|
||||
|
||||
@Override
|
||||
public ShopMerchantDTO detail(Long shopId) {
|
||||
ShopMerchantDTO shopMerchantVO = new ShopMerchantDTO();
|
||||
ShopMerchant one = queryChain().eq(ShopMerchant::getShopId, shopId).one();
|
||||
if (one == null) {
|
||||
return null;
|
||||
}
|
||||
shopMerchantVO.setShopId(shopId);
|
||||
shopMerchantVO.setChannel(one.getChannel());
|
||||
shopMerchantVO.setRelatedLicenceNo(one.getRelatedLicenceNo());
|
||||
if (StrUtil.isNotBlank(one.getNativePayJson())) {
|
||||
shopMerchantVO.setNativeMerchantDTO(JSONObject.parseObject(one.getNativePayJson(), NativeMerchantDTO.class));
|
||||
}
|
||||
if (StrUtil.isNotBlank(one.getPolyPayJson())) {
|
||||
shopMerchantVO.setPolyMerchantDTO(JSONObject.parseObject(one.getPolyPayJson(), PolyMerchantDTO.class));
|
||||
}
|
||||
if (StrUtil.isNotBlank(one.getRelatedLicenceNo())) {
|
||||
shopMerchantVO.setShopDirectMerchant(shopDirectMerchantService.getOne(query().eq(ShopDirectMerchant::getLicenceNo, one.getRelatedLicenceNo())));
|
||||
}
|
||||
return shopMerchantVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* * shopId 修改的店铺Id
|
||||
* * relatedLicenceNo 关联值 原生native必填 对应 tb_shop_direct_merchant 的 licence_no营业执照
|
||||
* * channel {@link com.czg.constant.PayChannelCst}
|
||||
* * jsonObject 支付参数 详情
|
||||
* * isUp 是否要修改 传否时 如果存在支付数据 且与当前渠道不一致 则不修改
|
||||
*/
|
||||
@Override
|
||||
@CacheEvict(key = "#shopMerchantParam.shopId")
|
||||
public Boolean editEntry(ShopMerchantDTO shopMerchantParam, boolean isUp) {
|
||||
ShopMerchant shopMerchant = getOne(query().eq(ShopMerchant::getShopId, shopMerchantParam.getShopId()));
|
||||
if (shopMerchant == null) {
|
||||
shopMerchant = new ShopMerchant();
|
||||
shopMerchant.setChannel(shopMerchantParam.getChannel());
|
||||
shopMerchant.setRelatedLicenceNo(shopMerchantParam.getRelatedLicenceNo());
|
||||
if (PayChannelCst.NATIVE.equals(shopMerchantParam.getChannel()) && shopMerchantParam.getNativeMerchantDTO() != null) {
|
||||
shopMerchant.setNativePayJson(JSONObject.toJSONString(shopMerchantParam.getNativeMerchantDTO()));
|
||||
} else if (PayChannelCst.POLY.equals(shopMerchantParam.getChannel()) && shopMerchantParam.getPolyMerchantDTO() != null) {
|
||||
shopMerchant.setPolyPayJson(JSONObject.toJSONString(shopMerchantParam.getPolyMerchantDTO()));
|
||||
}
|
||||
} else if (isUp) {
|
||||
shopMerchant.setChannel(shopMerchantParam.getChannel());
|
||||
shopMerchant.setShopId(shopMerchantParam.getShopId());
|
||||
shopMerchant.setRelatedLicenceNo(shopMerchantParam.getRelatedLicenceNo());
|
||||
|
||||
if (PayChannelCst.NATIVE.equals(shopMerchantParam.getChannel()) && shopMerchantParam.getNativeMerchantDTO() != null) {
|
||||
shopMerchant.setNativePayJson(JSONObject.toJSONString(shopMerchantParam.getNativeMerchantDTO()));
|
||||
} else if (PayChannelCst.POLY.equals(shopMerchantParam.getChannel()) && shopMerchantParam.getPolyMerchantDTO() != null) {
|
||||
shopMerchant.setPolyPayJson(JSONObject.toJSONString(shopMerchantParam.getPolyMerchantDTO()));
|
||||
}
|
||||
} else {
|
||||
//不是新增且不是修改 只有进件完成会进入这里
|
||||
if (StrUtil.isBlank(shopMerchant.getRelatedLicenceNo())) {
|
||||
shopMerchant.setRelatedLicenceNo(shopMerchantParam.getRelatedLicenceNo());
|
||||
}
|
||||
if (StrUtil.isBlank(shopMerchant.getNativePayJson()) && shopMerchantParam.getNativeMerchantDTO() != null) {
|
||||
shopMerchant.setNativePayJson(JSONObject.toJSONString(shopMerchantParam.getNativeMerchantDTO()));
|
||||
}
|
||||
}
|
||||
return saveOrUpdate(shopMerchant);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#id")
|
||||
@Override
|
||||
public ShopMerchant getById(Serializable id) {
|
||||
ShopMerchant shopMerchant = getMapper().selectOneById(id);
|
||||
AssertUtil.isNull(shopMerchant, "暂未开通支付");
|
||||
return shopMerchant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopDirectMerchant getMainMerchant(Long shopId) {
|
||||
Long mainIdByShopId = shopInfoService.getMainIdByShopId(shopId);
|
||||
if (mainIdByShopId != null) {
|
||||
return shopDirectMerchantService.getOne(query().eq(ShopDirectMerchant::getShopId, mainIdByShopId));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,8 @@ import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||
import com.czg.account.entity.*;
|
||||
import com.czg.account.service.*;
|
||||
import com.czg.constants.PayTypeConstants;
|
||||
import com.czg.entity.req.*;
|
||||
import com.czg.entity.resp.CzgRefundResp;
|
||||
import com.czg.enums.CzgPayEnum;
|
||||
import com.czg.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MemberOrderDTO;
|
||||
@@ -24,6 +24,8 @@ import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.order.service.OrderInfoCustomService;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
import com.czg.pay.CzgPayBaseReq;
|
||||
import com.czg.pay.CzgRefundReq;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.order.dto.VipMemberPayParamDTO;
|
||||
import com.czg.service.order.dto.VipPayParamDTO;
|
||||
@@ -131,15 +133,16 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
||||
payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
|
||||
"", payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
||||
return payService.jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
"会员充值", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
payService.initPayment(OrderPayment.pay(payParam.getShopId(), shopUser.getId(), payType, payOrderNo,
|
||||
payParam.getAmount(), "", isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
||||
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
|
||||
CzgPayBaseReq.jsPayReq(payOrderNo, "会员充值", payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
payParam.getPayType(), payParam.getOpenId(), clintIp));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CzgResult<Map<String, Object>> ltPayMember(String clientIP, VipMemberPayParamDTO payParam) {
|
||||
public CzgResult<Map<String, Object>> ltPayMember(String clientIp, VipMemberPayParamDTO payParam) {
|
||||
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getMainShopId, shopInfoService.getMainIdByShopId(payParam.getShopId())).eq(ShopUser::getId, payParam.getShopUserId()));
|
||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||
MemberOrder memberOrder = memberOrderService.createMemberOrder(new MemberOrderDTO().setName(payParam.getName())
|
||||
@@ -155,7 +158,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
||||
.setShopId(payParam.getShopId())
|
||||
.setRecordId(shopUser.getId())
|
||||
.setPrice(memberOrder.getAmount())
|
||||
.setIp(clientIP);
|
||||
.setIp(clientIp);
|
||||
return payService.ltPayOther(payParam1, PayTypeConstants.SourceType.MEMBER_PAY, "会员充值");
|
||||
}
|
||||
|
||||
@@ -191,7 +194,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<Map<String, Object>> recharge(String clientIP, VipPayParamDTO rechargeDTO, Long shopUserId) {
|
||||
public CzgResult<Map<String, Object>> recharge(String clientIp, VipPayParamDTO rechargeDTO, Long shopUserId) {
|
||||
boolean isFree = checkPayVip(rechargeDTO);
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(rechargeDTO.getShopId());
|
||||
|
||||
@@ -212,7 +215,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
||||
.setShopId(rechargeDTO.getShopId())
|
||||
.setRecordId(shopUser.getId())
|
||||
.setPrice(amount)
|
||||
.setIp(clientIP);
|
||||
.setIp(clientIp);
|
||||
return payService.ltPayOther(payParam, payType, "会员充值");
|
||||
}
|
||||
|
||||
@@ -224,10 +227,10 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
||||
payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
|
||||
"", payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
||||
return payService.scanPay(payParam.getShopId(), new CzgScanPayReq(payOrderNo, payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
"会员充值", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
payService.initPayment(OrderPayment.pay(payParam.getShopId(), shopUser.getId(), payType, payOrderNo,
|
||||
payParam.getAmount(), "", isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
||||
return payService.pay(payParam.getShopId(), CzgPayEnum.SCAN_PAY,
|
||||
CzgPayBaseReq.scanPayReq(payOrderNo, "会员充值", payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(), clintIp));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -239,10 +242,9 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
||||
payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
|
||||
payParam.getAuthCode(), payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
||||
CzgResult<Map<String, Object>> mapCzgResult = payService.microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
"会员充值", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
|
||||
payService.initPayment(OrderPayment.pay(payParam.getShopId(), shopUser.getId(), payType, payOrderNo, payParam.getAmount(), "", isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
||||
CzgResult<Map<String, Object>> mapCzgResult = payService.pay(payParam.getShopId(), CzgPayEnum.MICRO_PAY,
|
||||
CzgPayBaseReq.microPay(payOrderNo, "会员充值", payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(), payParam.getAuthCode()));
|
||||
mapCzgResult.setData(Map.of("payOrderNo", payOrderNo));
|
||||
return mapCzgResult;
|
||||
}
|
||||
@@ -309,10 +311,11 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
||||
return CzgResult.failure("退款失败,该充值记录不存在");
|
||||
}
|
||||
String refPayOrderNo = "REFVIP" + IdUtil.getSnowflakeNextId();
|
||||
refPaymentId = payService.initOrderPayment(new OrderPayment(refPayParam.getShopId(), shopUser.getId(),
|
||||
PayTypeConstants.SourceType.MEMBER_IN, PayTypeConstants.PayType.REFUND, refPayOrderNo, null, refPayParam.getRefAmount()));
|
||||
refPaymentId = payService.initPayment(OrderPayment.refund(refPayParam.getShopId(), shopUser.getId(), PayTypeConstants.SourceType.MEMBER_IN,
|
||||
refPayOrderNo, refPayParam.getRefAmount(), inFlow.getId()));
|
||||
CzgResult<CzgRefundResp> refund = payService.refund(refPayParam.getShopId(), new CzgRefundReq(refPayOrderNo, refPayParam.getRemark(),
|
||||
refPayParam.getRefAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), ""));
|
||||
refPayParam.getRefAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
payment.getOrderNo(), ""));
|
||||
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
|
||||
throw new CzgException(refund.getMsg());
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.order.mapper.ShopMerchantMapper">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user