mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-24 16:05:08 +08:00
mall + pay:
1、增加获得支付渠道接口
This commit is contained in:
@ -1,17 +1,17 @@
|
||||
package cn.iocoder.yudao.module.pay.controller.admin.merchant;
|
||||
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.*;
|
||||
import cn.iocoder.yudao.module.pay.convert.channel.PayChannelConvert;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO;
|
||||
import cn.iocoder.yudao.module.pay.service.merchant.PayChannelService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.*;
|
||||
import cn.iocoder.yudao.module.pay.convert.channel.PayChannelConvert;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO;
|
||||
import cn.iocoder.yudao.module.pay.service.merchant.PayChannelService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -20,10 +20,11 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Tag(name = "管理后台 - 支付渠道")
|
||||
@ -68,16 +69,6 @@ public class PayChannelController {
|
||||
return success(PayChannelConvert.INSTANCE.convert(channel));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得支付渠道列表")
|
||||
@Parameter(name = "ids", description = "编号列表",
|
||||
required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('pay:channel:query')")
|
||||
public CommonResult<List<PayChannelRespVO>> getChannelList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<PayChannelDO> list = channelService.getChannelList(ids);
|
||||
return success(PayChannelConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得支付渠道分页")
|
||||
@PreAuthorize("@ss.hasPermission('pay:channel:query')")
|
||||
@ -98,6 +89,7 @@ public class PayChannelController {
|
||||
ExcelUtils.write(response, "支付渠道.xls", "数据", PayChannelExcelVO.class, datas);
|
||||
}
|
||||
|
||||
// TODO 芋艿:需要 review 下实现
|
||||
@GetMapping("/get-channel")
|
||||
@Operation(summary = "根据条件查询微信支付渠道")
|
||||
@Parameters({
|
||||
@ -121,4 +113,12 @@ public class PayChannelController {
|
||||
return success(respVo);
|
||||
}
|
||||
|
||||
@GetMapping("/get-enable-code-list")
|
||||
@Operation(summary = "获得指定应用的开启的支付渠道编码列表")
|
||||
@Parameter(name = "appId", description = "应用编号", required = true, example = "1")
|
||||
public CommonResult<Set<String>> getEnableChannelCodeList(@RequestParam("appId") Long appId) {
|
||||
List<PayChannelDO> channels = channelService.getEnableChannelList(appId);
|
||||
return success(convertSet(channels, PayChannelDO::getCode));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
package cn.iocoder.yudao.module.pay.controller.app.channel;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO;
|
||||
import cn.iocoder.yudao.module.pay.service.merchant.PayChannelService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
|
||||
@Tag(name = "用户 App - 支付渠道")
|
||||
@RestController
|
||||
@RequestMapping("/pay/channel")
|
||||
@Validated
|
||||
public class AppPayChannelController {
|
||||
|
||||
@Resource
|
||||
private PayChannelService channelService;
|
||||
|
||||
@GetMapping("/get-enable-code-list")
|
||||
@Operation(summary = "获得指定应用的开启的支付渠道编码列表")
|
||||
@Parameter(name = "appId", description = "应用编号", required = true, example = "1")
|
||||
public CommonResult<Set<String>> getEnableChannelCodeList(@RequestParam("appId") Long appId) {
|
||||
List<PayChannelDO> channels = channelService.getEnableChannelList(appId);
|
||||
return success(convertSet(channels, PayChannelDO::getCode));
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.pay.dal.mysql.merchant;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelExportReqVO;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelPageReqVO;
|
||||
@ -43,21 +44,6 @@ public interface PayChannelMapper extends BaseMapperX<PayChannelDO> {
|
||||
.orderByDesc("id"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件获取渠道数量
|
||||
*
|
||||
* @param merchantId 商户编号
|
||||
* @param appid 应用编号
|
||||
* @param code 渠道编码
|
||||
* @return 数量
|
||||
*/
|
||||
default Integer selectCount(Long merchantId, Long appid, String code) {
|
||||
return this.selectCount(new QueryWrapper<PayChannelDO>().lambda()
|
||||
.eq(PayChannelDO::getMerchantId, merchantId)
|
||||
.eq(PayChannelDO::getAppId, appid)
|
||||
.eq(PayChannelDO::getCode, code)).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件获取渠道
|
||||
*
|
||||
@ -86,4 +72,10 @@ public interface PayChannelMapper extends BaseMapperX<PayChannelDO> {
|
||||
.in(PayChannelDO::getAppId, appIds));
|
||||
}
|
||||
|
||||
default List<PayChannelDO> selectListByAppId(Long appId, Integer status) {
|
||||
return selectList(new LambdaQueryWrapperX<PayChannelDO>()
|
||||
.eq(PayChannelDO::getAppId, appId)
|
||||
.eq(PayChannelDO::getStatus, status));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,15 +54,6 @@ public interface PayChannelService {
|
||||
*/
|
||||
PayChannelDO getChannel(Long id);
|
||||
|
||||
/**
|
||||
* 获得支付渠道列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 支付渠道
|
||||
* 列表
|
||||
*/
|
||||
List<PayChannelDO> getChannelList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得支付渠道分页
|
||||
*
|
||||
@ -89,16 +80,6 @@ public interface PayChannelService {
|
||||
*/
|
||||
List<PayChannelDO> getChannelListByAppIds(Collection<Long> appIds);
|
||||
|
||||
/**
|
||||
* 根据条件获取渠道数量
|
||||
*
|
||||
* @param merchantId 商户编号
|
||||
* @param appid 应用编号
|
||||
* @param code 渠道编码
|
||||
* @return 数量
|
||||
*/
|
||||
Integer getChannelCountByConditions(Long merchantId, Long appid, String code);
|
||||
|
||||
/**
|
||||
* 根据条件获取渠道
|
||||
*
|
||||
@ -130,4 +111,12 @@ public interface PayChannelService {
|
||||
*/
|
||||
PayChannelDO validPayChannel(Long appId, String code);
|
||||
|
||||
/**
|
||||
* 获得指定应用的开启的渠道列表
|
||||
*
|
||||
* @param appId 应用编号
|
||||
* @return 渠道列表
|
||||
*/
|
||||
List<PayChannelDO> getEnableChannelList(Long appId);
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Validator;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -42,11 +41,6 @@ import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.CHANNEL_NOT_E
|
||||
@Validated
|
||||
public class PayChannelServiceImpl implements PayChannelService {
|
||||
|
||||
/**
|
||||
* 缓存菜单的最大更新时间,用于后续的增量轮询,判断是否有更新
|
||||
*/
|
||||
private volatile LocalDateTime maxUpdateTime;
|
||||
|
||||
@Resource
|
||||
private PayClientFactory payClientFactory;
|
||||
|
||||
@ -121,11 +115,6 @@ public class PayChannelServiceImpl implements PayChannelService {
|
||||
return channelMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayChannelDO> getChannelList(Collection<Long> ids) {
|
||||
return channelMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<PayChannelDO> getChannelPage(PayChannelPageReqVO pageReqVO) {
|
||||
return channelMapper.selectPage(pageReqVO);
|
||||
@ -147,20 +136,6 @@ public class PayChannelServiceImpl implements PayChannelService {
|
||||
return channelMapper.getChannelListByAppIds(appIds);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据条件获取渠道数量
|
||||
*
|
||||
* @param merchantId 商户编号
|
||||
* @param appid 应用编号
|
||||
* @param code 渠道编码
|
||||
* @return 数量
|
||||
*/
|
||||
@Override
|
||||
public Integer getChannelCountByConditions(Long merchantId, Long appid, String code) {
|
||||
return this.channelMapper.selectCount(merchantId, appid, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件获取渠道
|
||||
*
|
||||
@ -204,10 +179,15 @@ public class PayChannelServiceImpl implements PayChannelService {
|
||||
@Override
|
||||
public PayChannelDO validPayChannel(Long appId, String code) {
|
||||
PayChannelDO channel = channelMapper.selectByAppIdAndCode(appId, code);
|
||||
this.validPayChannel(channel);
|
||||
validPayChannel(channel);
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayChannelDO> getEnableChannelList(Long appId) {
|
||||
return channelMapper.selectListByAppId(appId, CommonStatusEnum.ENABLE.getStatus());
|
||||
}
|
||||
|
||||
private void validPayChannel(PayChannelDO channel) {
|
||||
if (channel == null) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.PAY_CHANNEL_NOT_FOUND);
|
||||
@ -216,4 +196,5 @@ public class PayChannelServiceImpl implements PayChannelService {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.PAY_CHANNEL_IS_DISABLE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user