mirror of
https://gitee.com/dromara/dax-pay
synced 2026-08-11 07:05:33 +08:00
feat 钱包和储值卡适配多商户
This commit is contained in:
@@ -4,6 +4,7 @@ import cn.bootx.platform.common.core.rest.PageResult;
|
||||
import cn.bootx.platform.common.core.rest.Res;
|
||||
import cn.bootx.platform.common.core.rest.ResResult;
|
||||
import cn.bootx.platform.common.core.rest.dto.KeyValue;
|
||||
import cn.bootx.platform.common.core.rest.dto.LabelValue;
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.daxpay.core.channel.alipay.service.AlipayConfigService;
|
||||
import cn.bootx.platform.daxpay.dto.channel.alipay.AlipayConfigDto;
|
||||
@@ -59,7 +60,7 @@ public class AlipayConfigController {
|
||||
|
||||
@Operation(summary = "支付宝支持支付方式")
|
||||
@GetMapping("/findPayWayList")
|
||||
public ResResult<List<KeyValue>> findPayWayList() {
|
||||
public ResResult<List<LabelValue>> findPayWayList() {
|
||||
return Res.ok(alipayConfigService.findPayWayList());
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package cn.bootx.platform.daxpay.controller;
|
||||
import cn.bootx.platform.common.core.rest.PageResult;
|
||||
import cn.bootx.platform.common.core.rest.Res;
|
||||
import cn.bootx.platform.common.core.rest.ResResult;
|
||||
import cn.bootx.platform.common.core.rest.dto.LabelValue;
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.daxpay.core.merchant.service.MchAppPayConfigService;
|
||||
import cn.bootx.platform.daxpay.core.merchant.service.MchAppService;
|
||||
@@ -59,6 +60,12 @@ public class MchApplicationController {
|
||||
return Res.ok(applicationService.findById(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "下拉列表")
|
||||
@GetMapping("/dropdown")
|
||||
public ResResult<List<LabelValue>> dropdown(String mchCode) {
|
||||
return Res.ok(applicationService.dropdown(mchCode));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询所有")
|
||||
@GetMapping(value = "/findAll")
|
||||
public ResResult<List<MchApplicationDto>> findAll() {
|
||||
|
||||
@@ -3,7 +3,7 @@ package cn.bootx.platform.daxpay.controller;
|
||||
import cn.bootx.platform.common.core.rest.PageResult;
|
||||
import cn.bootx.platform.common.core.rest.Res;
|
||||
import cn.bootx.platform.common.core.rest.ResResult;
|
||||
import cn.bootx.platform.common.core.rest.dto.KeyValue;
|
||||
import cn.bootx.platform.common.core.rest.dto.LabelValue;
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.daxpay.core.merchant.service.MerchantInfoService;
|
||||
import cn.bootx.platform.daxpay.dto.merchant.MerchantInfoDto;
|
||||
@@ -45,7 +45,7 @@ public class MerchantInfoController {
|
||||
|
||||
@Operation(summary = "下拉列表")
|
||||
@GetMapping("/dropdown")
|
||||
public ResResult<List<KeyValue>> dropdown() {
|
||||
public ResResult<List<LabelValue>> dropdown() {
|
||||
return Res.ok(merchantInfoService.dropdown());
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package cn.bootx.platform.daxpay.controller;
|
||||
import cn.bootx.platform.common.core.rest.PageResult;
|
||||
import cn.bootx.platform.common.core.rest.Res;
|
||||
import cn.bootx.platform.common.core.rest.ResResult;
|
||||
import cn.bootx.platform.common.core.rest.dto.KeyValue;
|
||||
import cn.bootx.platform.common.core.rest.dto.LabelValue;
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.daxpay.core.channel.wechat.service.WeChatPayConfigService;
|
||||
import cn.bootx.platform.daxpay.dto.channel.wechat.WeChatPayConfigDto;
|
||||
@@ -58,7 +58,7 @@ public class WeChatPayConfigController {
|
||||
|
||||
@Operation(summary = "微信支持支付方式")
|
||||
@GetMapping("/findPayWayList")
|
||||
public ResResult<List<KeyValue>> findPayWayList() {
|
||||
public ResResult<List<LabelValue>> findPayWayList() {
|
||||
return Res.ok(weChatPayConfigService.findPayWayList());
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package cn.bootx.platform.daxpay.core.channel.alipay.service;
|
||||
import cn.bootx.platform.common.core.exception.BizException;
|
||||
import cn.bootx.platform.common.core.exception.DataNotExistException;
|
||||
import cn.bootx.platform.common.core.rest.PageResult;
|
||||
import cn.bootx.platform.common.core.rest.dto.KeyValue;
|
||||
import cn.bootx.platform.common.core.rest.dto.LabelValue;
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.bootx.platform.daxpay.code.MchAndAppCode;
|
||||
@@ -12,8 +12,8 @@ import cn.bootx.platform.daxpay.code.paymodel.AliPayCode;
|
||||
import cn.bootx.platform.daxpay.code.paymodel.AliPayWay;
|
||||
import cn.bootx.platform.daxpay.core.channel.alipay.dao.AlipayConfigManager;
|
||||
import cn.bootx.platform.daxpay.core.channel.alipay.entity.AlipayConfig;
|
||||
import cn.bootx.platform.daxpay.core.merchant.dao.MchAppPayConfigManager;
|
||||
import cn.bootx.platform.daxpay.core.merchant.entity.MchAppPayConfig;
|
||||
import cn.bootx.platform.daxpay.core.merchant.service.MchAppPayConfigService;
|
||||
import cn.bootx.platform.daxpay.core.merchant.service.MchAppService;
|
||||
import cn.bootx.platform.daxpay.dto.channel.alipay.AlipayConfigDto;
|
||||
import cn.bootx.platform.daxpay.param.channel.alipay.AlipayConfigParam;
|
||||
@@ -50,7 +50,7 @@ public class AlipayConfigService {
|
||||
|
||||
private final MchAppService mchAppService;
|
||||
|
||||
private final MchAppPayConfigManager mchAppPayConfigManager;
|
||||
private final MchAppPayConfigService appPayConfigService;
|
||||
|
||||
/**
|
||||
* 添加支付宝配置
|
||||
@@ -70,7 +70,7 @@ public class AlipayConfigService {
|
||||
.setConfigId(alipayConfig.getId())
|
||||
.setChannel(PayChannelEnum.ALI.getCode())
|
||||
.setState(alipayConfig.getState());
|
||||
mchAppPayConfigManager.save(mchAppPayConfig);
|
||||
appPayConfigService.add(mchAppPayConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,10 +107,10 @@ public class AlipayConfigService {
|
||||
/**
|
||||
* 支付宝支持支付方式
|
||||
*/
|
||||
public List<KeyValue> findPayWayList() {
|
||||
public List<LabelValue> findPayWayList() {
|
||||
return AliPayWay.getPayWays()
|
||||
.stream()
|
||||
.map(e -> new KeyValue(e.getCode(), e.getName()))
|
||||
.map(e -> new LabelValue(e.getName(),e.getCode()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ public class VoucherPayService {
|
||||
.setPaymentId(payment.getId())
|
||||
.setBusinessId(payment.getBusinessId())
|
||||
.setType(VoucherCode.LOG_FREEZE_BALANCE)
|
||||
.setRemark(String.format("钱包预冻结金额 %.2f ", amount))
|
||||
.setRemark(String.format("预冻结金额 %.2f ", amount))
|
||||
.setVoucherId(voucher.getId())
|
||||
.setVoucherNo(voucher.getCardNo());
|
||||
|
||||
@@ -153,7 +153,7 @@ public class VoucherPayService {
|
||||
.setPaymentId(voucherPayment.getPaymentId())
|
||||
.setBusinessId(voucherPayment.getBusinessId())
|
||||
.setType(VoucherCode.LOG_REDUCE_AND_UNFREEZE_BALANCE)
|
||||
.setRemark(String.format("钱包扣款金额 %.2f ", voucherPayment.getAmount()))
|
||||
.setRemark(String.format("扣款金额 %.2f ", voucherPayment.getAmount()))
|
||||
.setVoucherId(voucher.getId())
|
||||
.setAmount(voucher.getFreezeBalance())
|
||||
.setVoucherNo(voucher.getCardNo());
|
||||
@@ -182,7 +182,7 @@ public class VoucherPayService {
|
||||
.setPaymentId(payment.getId())
|
||||
.setBusinessId(payment.getBusinessId())
|
||||
.setType(VoucherCode.LOG_PAY)
|
||||
.setRemark(String.format("钱包支付金额 %.2f ", amount))
|
||||
.setRemark(String.format("支付金额 %.2f ", amount))
|
||||
.setVoucherId(voucher.getId())
|
||||
.setVoucherNo(voucher.getCardNo());
|
||||
|
||||
|
||||
@@ -139,9 +139,9 @@ public class WalletManager extends BaseManager<WalletMapper, Wallet> {
|
||||
QueryWrapper<UserInfo> wrapper = new QueryWrapper<>();
|
||||
wrapper.isNull("w.id")
|
||||
.orderByDesc("w.id")
|
||||
.eq("w.mch_code",mchCode)
|
||||
.like(StrUtil.isNotBlank(userInfoParam.getUsername()), "w.username", userInfoParam.getUsername())
|
||||
.like(StrUtil.isNotBlank(userInfoParam.getName()), "w.name", userInfoParam.getName());
|
||||
.and(o->o.ne("w.mch_code",mchCode).or().isNull("w.mch_code"))
|
||||
.like(StrUtil.isNotBlank(userInfoParam.getUsername()), "u.username", userInfoParam.getUsername())
|
||||
.like(StrUtil.isNotBlank(userInfoParam.getName()), "u.name", userInfoParam.getName());
|
||||
return walletMapper.pageByNotWallet(mpPage, wrapper);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package cn.bootx.platform.daxpay.core.channel.wechat.service;
|
||||
import cn.bootx.platform.common.core.exception.BizException;
|
||||
import cn.bootx.platform.common.core.exception.DataNotExistException;
|
||||
import cn.bootx.platform.common.core.rest.PageResult;
|
||||
import cn.bootx.platform.common.core.rest.dto.KeyValue;
|
||||
import cn.bootx.platform.common.core.rest.dto.LabelValue;
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.bootx.platform.daxpay.code.MchAndAppCode;
|
||||
@@ -11,8 +11,8 @@ import cn.bootx.platform.daxpay.code.pay.PayChannelEnum;
|
||||
import cn.bootx.platform.daxpay.code.paymodel.WeChatPayWay;
|
||||
import cn.bootx.platform.daxpay.core.channel.wechat.dao.WeChatPayConfigManager;
|
||||
import cn.bootx.platform.daxpay.core.channel.wechat.entity.WeChatPayConfig;
|
||||
import cn.bootx.platform.daxpay.core.merchant.dao.MchAppPayConfigManager;
|
||||
import cn.bootx.platform.daxpay.core.merchant.entity.MchAppPayConfig;
|
||||
import cn.bootx.platform.daxpay.core.merchant.service.MchAppPayConfigService;
|
||||
import cn.bootx.platform.daxpay.core.merchant.service.MchAppService;
|
||||
import cn.bootx.platform.daxpay.dto.channel.wechat.WeChatPayConfigDto;
|
||||
import cn.bootx.platform.daxpay.exception.payment.PayFailureException;
|
||||
@@ -41,7 +41,7 @@ public class WeChatPayConfigService {
|
||||
|
||||
private final WeChatPayConfigManager weChatPayConfigManager;
|
||||
private final MchAppService mchAppService;
|
||||
private final MchAppPayConfigManager mchAppPayConfigManager;
|
||||
private final MchAppPayConfigService appPayConfigService;
|
||||
|
||||
/**
|
||||
* 添加微信支付配置
|
||||
@@ -61,7 +61,7 @@ public class WeChatPayConfigService {
|
||||
.setConfigId(weChatPayConfig.getId())
|
||||
.setChannel(PayChannelEnum.WECHAT.getCode())
|
||||
.setState(weChatPayConfig.getState());
|
||||
mchAppPayConfigManager.save(mchAppPayConfig);
|
||||
appPayConfigService.add(mchAppPayConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,10 +100,10 @@ public class WeChatPayConfigService {
|
||||
/**
|
||||
* 微信支持支付方式
|
||||
*/
|
||||
public List<KeyValue> findPayWayList() {
|
||||
public List<LabelValue> findPayWayList() {
|
||||
return WeChatPayWay.getPayWays()
|
||||
.stream()
|
||||
.map(e -> new KeyValue(e.getCode(), e.getName()))
|
||||
.map(e -> new LabelValue(e.getName(),e.getCode()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@@ -40,4 +41,10 @@ public class MchAppManager extends BaseManager<MchApplicationMapper, MchApplicat
|
||||
return this.page(mpPage, wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商户编码查询
|
||||
*/
|
||||
public List<MchApplication> findAllByMchCode(String mchCode) {
|
||||
return findAllByField(MchApplication::getMchCode,mchCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,4 +15,13 @@ import org.springframework.stereotype.Repository;
|
||||
@RequiredArgsConstructor
|
||||
public class MchAppPayConfigManager extends BaseManager<MchAppPayConfigMapper, MchAppPayConfig> {
|
||||
|
||||
/**
|
||||
* 该商户应用的指定类型的支付配置是否已经存在
|
||||
*/
|
||||
public boolean existsByAppCodeAndChannel(String mchAppCode, String channel){
|
||||
return lambdaQuery()
|
||||
.eq(MchAppPayConfig::getAppCode,mchAppCode)
|
||||
.eq(MchAppPayConfig::getChannel,channel)
|
||||
.exists();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.bootx.platform.daxpay.core.merchant.dao;
|
||||
|
||||
import cn.bootx.platform.common.core.rest.dto.KeyValue;
|
||||
import cn.bootx.platform.common.core.rest.dto.LabelValue;
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
@@ -47,11 +47,11 @@ public class MerchantInfoManager extends BaseManager<MerchantInfoMapper, Merchan
|
||||
/**
|
||||
* 下拉列表
|
||||
*/
|
||||
public List<KeyValue> findDropdown() {
|
||||
public List<LabelValue> findDropdown() {
|
||||
return lambdaQuery().select(MerchantInfo::getCode, MerchantInfo::getName)
|
||||
.list()
|
||||
.stream()
|
||||
.map(mch -> new KeyValue(mch.getCode(), mch.getName()))
|
||||
.map(mch -> new LabelValue(mch.getName(),mch.getCode()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package cn.bootx.platform.daxpay.core.merchant.entity;
|
||||
import cn.bootx.mybatis.table.modify.annotation.DbColumn;
|
||||
import cn.bootx.mybatis.table.modify.mybatis.mysq.annotation.DbMySqlIndex;
|
||||
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -24,14 +26,17 @@ public class MchAppPayConfig extends MpBaseEntity {
|
||||
/** 关联应用编码 */
|
||||
@DbMySqlIndex(comment = "关联商户应用编码索引")
|
||||
@DbColumn(comment = "关联商户应用编码")
|
||||
@TableField(updateStrategy = FieldStrategy.NEVER)
|
||||
private String appCode;
|
||||
|
||||
/** 关联配置ID */
|
||||
@DbColumn(comment = "关联配置ID")
|
||||
@TableField(updateStrategy = FieldStrategy.NEVER)
|
||||
private Long configId;
|
||||
|
||||
/** 支付通道编码 */
|
||||
@DbColumn(comment = "支付通道编码")
|
||||
@TableField(updateStrategy = FieldStrategy.NEVER)
|
||||
private String channel;
|
||||
|
||||
/** 状态 */
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.bootx.platform.daxpay.core.merchant.service;
|
||||
|
||||
import cn.bootx.platform.common.core.exception.BizException;
|
||||
import cn.bootx.platform.daxpay.core.channel.config.dao.PayChannelConfigManager;
|
||||
import cn.bootx.platform.daxpay.core.channel.config.entity.PayChannelConfig;
|
||||
import cn.bootx.platform.daxpay.core.merchant.dao.MchAppPayConfigManager;
|
||||
@@ -30,6 +31,17 @@ public class MchAppPayConfigService {
|
||||
|
||||
private final PayChannelConfigManager channelConfigManager;
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add(MchAppPayConfig config){
|
||||
// 是否重复
|
||||
if (mchAppPayConfigManager.existsByAppCodeAndChannel(config.getAppCode(),config.getChannel())){
|
||||
throw new BizException("该商户应用的支付通道已经进行配置, 请勿重新配置");
|
||||
}
|
||||
mchAppPayConfigManager.save(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据应用ID删除
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,7 @@ package cn.bootx.platform.daxpay.core.merchant.service;
|
||||
|
||||
import cn.bootx.platform.common.core.exception.DataNotExistException;
|
||||
import cn.bootx.platform.common.core.rest.PageResult;
|
||||
import cn.bootx.platform.common.core.rest.dto.LabelValue;
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.common.core.util.ResultConvertUtil;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
@@ -21,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 商户应用
|
||||
@@ -71,6 +73,15 @@ public class MchAppService {
|
||||
return mchAppManager.findById(id).map(MchApplication::toDto).orElseThrow(DataNotExistException::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉列表
|
||||
*/
|
||||
public List<LabelValue> dropdown(String mchCode){
|
||||
return mchAppManager.findAllByMchCode(mchCode).stream()
|
||||
.map(o->new LabelValue(o.getName(),o.getCode()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@ package cn.bootx.platform.daxpay.core.merchant.service;
|
||||
|
||||
import cn.bootx.platform.common.core.exception.DataNotExistException;
|
||||
import cn.bootx.platform.common.core.rest.PageResult;
|
||||
import cn.bootx.platform.common.core.rest.dto.KeyValue;
|
||||
import cn.bootx.platform.common.core.rest.dto.LabelValue;
|
||||
import cn.bootx.platform.common.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.common.core.util.ResultConvertUtil;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
@@ -73,7 +73,7 @@ public class MerchantInfoService {
|
||||
/**
|
||||
* 下拉框
|
||||
*/
|
||||
public List<KeyValue> dropdown() {
|
||||
public List<LabelValue> dropdown() {
|
||||
return merchantInfoManager.findDropdown();
|
||||
}
|
||||
|
||||
|
||||
@@ -64,16 +64,16 @@
|
||||
|
||||
<!-- 待开通钱包的用户列表 -->
|
||||
<select id="pageByNotWallet" resultType="cn.bootx.platform.iam.core.user.entity.UserInfo">
|
||||
select
|
||||
iam_user_info.id,
|
||||
iam_user_info.`name`,
|
||||
iam_user_info.username
|
||||
select distinct
|
||||
u.id,
|
||||
u.`name`,
|
||||
u.username
|
||||
from
|
||||
iam_user_info
|
||||
iam_user_info AS u
|
||||
LEFT JOIN
|
||||
pay_wallet AS w
|
||||
on
|
||||
iam_user_info.id = w.user_id
|
||||
u.id = w.user_id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user