分销后台相关接口 现金充值 记录明细

This commit is contained in:
张松
2025-10-27 10:31:09 +08:00
parent 6c3f5e22d7
commit ac002cb1dd
27 changed files with 1406 additions and 582 deletions

View File

@@ -0,0 +1,38 @@
package com.czg.service.order.service;
import com.czg.order.dto.MkDistributionPayDTO;
import com.czg.resp.CzgResult;
import java.util.Map;
/**
* 支付
*
* @author ww
*/
public interface DistributionPayService {
/**
* 现金支付
*/
CzgResult<Object> cashPayOrder(MkDistributionPayDTO payParam);
/**
* 小程序支付
*/
CzgResult<Map<String, Object>> ltPayOrder(String clintIp, MkDistributionPayDTO payParam);
/**
* PC扫码支付
*/
CzgResult<Map<String, Object>> scanPayOrder(String clintIp, MkDistributionPayDTO payParam);
/**
* 反扫
*/
CzgResult<Map<String, Object>> microPayOrder(MkDistributionPayDTO payParam);
}

View File

@@ -0,0 +1,103 @@
package com.czg.service.order.service.impl;
import cn.hutool.core.util.IdUtil;
import com.czg.account.entity.ShopUser;
import com.czg.account.entity.UserInfo;
import com.czg.account.service.ShopInfoService;
import com.czg.account.service.ShopUserService;
import com.czg.account.service.UserInfoService;
import com.czg.constant.TableValueConstant;
import com.czg.entity.req.CzgLtPayReq;
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;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.dubbo.config.annotation.DubboReference;
import java.math.BigDecimal;
import java.util.Map;
/**
* @author Administrator
*/
public class DistributionPayServiceImpl implements DistributionPayService {
private final BigDecimal MONEY_RATE = new BigDecimal("100");
@Resource
private OrderPaymentService orderPaymentService;
@Resource
private MkDistributionConfigService configService;
@Resource
private WxService wxService;
@Resource
private PayServiceImpl payService;
@DubboReference
private ShopInfoService shopInfoService;
@DubboReference
private ShopUserService shopUserService;
@DubboReference
private UserInfoService userInfoService;
@Accessors(chain = true)
@Data
private static class InitInfo {
public OrderPayment payment;
public MkDistributionConfigVO config;
public ShopUser shopUser;
private String openId;
}
private InitInfo initPayment(Long userId, MkDistributionPayDTO payParam) {
Long mainShopId = shopInfoService.getMainIdByShopId(payParam.getShopId());
MkDistributionConfigVO detail = configService.detail(payParam.getShopId());
AssertUtil.isTrue(detail.getIsEnable() != 1, "分销未开启");
if (!TableValueConstant.DistributionConfig.OpenType.PAY.getCode().equals(detail.getOpenType())) {
throw new CzgException("当前未开启购买分销配置");
}
OrderPayment orderPayment = new OrderPayment().setShopId(mainShopId).setSourceId(userId)
.setPayType("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());
}
@Override
public CzgResult<Object> cashPayOrder(MkDistributionPayDTO payParam) {
return null;
}
@Override
public CzgResult<Map<String, Object>> ltPayOrder(String clintIp, MkDistributionPayDTO payParam) {
InitInfo initInfo = initPayment(payParam.getUserId(), payParam);
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 CzgResult<Map<String, Object>> scanPayOrder(String clintIp, MkDistributionPayDTO payParam) {
return null;
}
@Override
public CzgResult<Map<String, Object>> microPayOrder(MkDistributionPayDTO payParam) {
return null;
}
}

View File

@@ -862,7 +862,7 @@ public class PayServiceImpl implements PayService {
return execPayResult(jsPayRespCzgResult);
}
private CzgResult<Map<String, Object>> ltPay(@NonNull Long shopId, String payType, CzgLtPayReq bizData) {
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) ? "支付宝" : "微信") + "小程序");