运营端充值
This commit is contained in:
@@ -34,7 +34,7 @@ public class Main {
|
||||
// String packageName = "product";
|
||||
String packageName = "market";
|
||||
// tableName 指定需要生成的表
|
||||
String tableName = "mk_product_smart_suggest";
|
||||
String tableName = "mk_distribution_amount_flow";
|
||||
String author = "ww";
|
||||
//是否生成DTO实体 默认生成
|
||||
boolean isGenerateDto = true;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -34,6 +34,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Base64;
|
||||
@@ -101,7 +102,7 @@ public class WxServiceImpl implements WxService {
|
||||
private static String platformCertPath;
|
||||
private static String platformCertNo;
|
||||
private static String mchId;
|
||||
private static String apiV3Key;
|
||||
public static String apiV3Key;
|
||||
private static String apiV2Key;
|
||||
private static String notifyUrl;
|
||||
private static String refundNotifyUrl;
|
||||
@@ -322,6 +323,20 @@ public class WxServiceImpl implements WxService {
|
||||
log.info(publicKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decryptToString(String associatedData, String nonceStr, String ciphertext) {
|
||||
AesUtil aesUtil = new AesUtil(apiV3Key.getBytes(StandardCharsets.UTF_8));
|
||||
try {
|
||||
return aesUtil.decryptToString(
|
||||
associatedData.getBytes(StandardCharsets.UTF_8),
|
||||
nonceStr.getBytes(StandardCharsets.UTF_8),
|
||||
ciphertext
|
||||
);
|
||||
} catch (GeneralSecurityException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> v3Pay(String openId, BigDecimal amount, String desc, String tradeNo, String type) {
|
||||
if (desc == null) desc = "订单支付";
|
||||
@@ -338,7 +353,7 @@ public class WxServiceImpl implements WxService {
|
||||
String payInfo = JSONObject.toJSONString(model);
|
||||
log.info("统一下单参数: {}", payInfo);
|
||||
|
||||
IJPayHttpResponse resp = null;
|
||||
IJPayHttpResponse resp;
|
||||
try {
|
||||
resp = WxPayApi.v3(
|
||||
RequestMethodEnum.POST,
|
||||
|
||||
Reference in New Issue
Block a user