运营端充值
This commit is contained in:
@@ -34,5 +34,6 @@ public interface DistributionPayService {
|
||||
CzgResult<Map<String, Object>> microPayOrder(MkDistributionPayDTO payParam);
|
||||
|
||||
|
||||
Map<String, String> mchRecharge(String clientIP, MkDistributionPayDTO payParam);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.entity.UserInfo;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
@@ -12,13 +13,10 @@ 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.OrderInfo;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.order.enums.PayEnums;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.order.service.DistributionPayService;
|
||||
import com.czg.service.order.service.PayService;
|
||||
import com.czg.system.service.WxService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -63,21 +61,28 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
||||
private String openId;
|
||||
}
|
||||
|
||||
private InitInfo initPayment(Long userId, MkDistributionPayDTO payParam) {
|
||||
private InitInfo initPayment(Long userId, MkDistributionPayDTO payParam, boolean isRecharge) {
|
||||
MkDistributionConfigVO detail = configService.detail(payParam.getShopId());
|
||||
AssertUtil.isTrue(detail.getIsEnable() != 1, "分销未开启");
|
||||
if (!TableValueConstant.DistributionConfig.OpenType.PAY.getCode().equals(detail.getOpenType())) {
|
||||
if (!isRecharge && !TableValueConstant.DistributionConfig.OpenType.PAY.getCode().equals(detail.getOpenType())) {
|
||||
throw new CzgException("当前未开启购买分销配置");
|
||||
}
|
||||
|
||||
OrderPayment orderPayment = new OrderPayment().setShopId(payParam.getShopId()).setSourceId(userId)
|
||||
.setPayType("distribution").setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId()).setAmount(detail.getPayAmount());
|
||||
.setPayType(isRecharge ? "distributionRecharge" : "distribution").setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId()).setAmount(detail.getPayAmount());
|
||||
orderPaymentService.save(orderPayment);
|
||||
|
||||
ShopUser shopUserInfo = shopUserService.getShopUserInfo(payParam.getShopId(), userId);
|
||||
UserInfo userInfo = userInfoService.getById(userId);
|
||||
return new InitInfo().setConfig(detail).setPayment(orderPayment).setShopUser(shopUserInfo)
|
||||
.setOpenId("aliPay".equals(payParam.getPayType()) ? userInfo.getAlipayOpenId() : userInfo.getWechatOpenId());
|
||||
InitInfo initInfo = new InitInfo().setConfig(detail);
|
||||
if (isRecharge) {
|
||||
ShopInfo shopInfo = shopInfoService.getById(payParam.getShopId());
|
||||
initInfo.setOpenId(shopInfo.getWechatOpenId());
|
||||
} else {
|
||||
ShopUser shopUserInfo = shopUserService.getShopUserInfo(payParam.getShopId(), userId);
|
||||
UserInfo userInfo = userInfoService.getById(userId);
|
||||
initInfo.setPayment(orderPayment).setShopUser(shopUserInfo)
|
||||
.setOpenId("aliPay".equals(payParam.getPayType()) ? userInfo.getAlipayOpenId() : userInfo.getWechatOpenId());
|
||||
}
|
||||
return initInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,11 +92,17 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
||||
|
||||
@Override
|
||||
public CzgResult<Map<String, Object>> ltPayOrder(String clintIp, MkDistributionPayDTO payParam) {
|
||||
InitInfo initInfo = initPayment(payParam.getUserId(), 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(), ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> mchRecharge(String clientIP, MkDistributionPayDTO payParam) {
|
||||
InitInfo initInfo = initPayment(payParam.getUserId(), payParam, true);
|
||||
return wxService.v3Pay(initInfo.openId, payParam.getAmount(), "商户运营余额充值", initInfo.payment.getOrderNo(), initInfo.payment.getPayType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<Map<String, Object>> scanPayOrder(String clintIp, MkDistributionPayDTO payParam) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user