多模块重构 7:pay 模块的初始化
This commit is contained in:
@@ -1,163 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.app;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.*;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.convert.app.PayAppConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.app.PayAppService;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.channel.PayChannelService;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.merchant.PayMerchantService;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Slf4j
|
||||
@Api(tags = "支付应用信息")
|
||||
@RestController
|
||||
@RequestMapping("/pay/app")
|
||||
@Validated
|
||||
public class PayAppController {
|
||||
|
||||
@Resource
|
||||
private PayAppService appService;
|
||||
@Resource
|
||||
private PayChannelService channelService;
|
||||
@Resource
|
||||
private PayMerchantService merchantService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建支付应用信息")
|
||||
@PreAuthorize("@ss.hasPermission('pay:app:create')")
|
||||
public CommonResult<Long> createApp(@Valid @RequestBody PayAppCreateReqVO createReqVO) {
|
||||
return success(appService.createApp(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新支付应用信息")
|
||||
@PreAuthorize("@ss.hasPermission('pay:app:update')")
|
||||
public CommonResult<Boolean> updateApp(@Valid @RequestBody PayAppUpdateReqVO updateReqVO) {
|
||||
appService.updateApp(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/update-status")
|
||||
@ApiOperation("更新支付应用状态")
|
||||
@PreAuthorize("@ss.hasPermission('pay:app:update')")
|
||||
public CommonResult<Boolean> updateAppStatus(@Valid @RequestBody PayAppUpdateStatusReqVO updateReqVO) {
|
||||
appService.updateAppStatus(updateReqVO.getId(), updateReqVO.getStatus());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除支付应用信息")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('pay:app:delete')")
|
||||
public CommonResult<Boolean> deleteApp(@RequestParam("id") Long id) {
|
||||
appService.deleteApp(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得支付应用信息")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('pay:app:query')")
|
||||
public CommonResult<PayAppRespVO> getApp(@RequestParam("id") Long id) {
|
||||
PayAppDO app = appService.getApp(id);
|
||||
return success(PayAppConvert.INSTANCE.convert(app));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得支付应用信息列表")
|
||||
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
|
||||
@PreAuthorize("@ss.hasPermission('pay:app:query')")
|
||||
public CommonResult<List<PayAppRespVO>> getAppList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<PayAppDO> list = appService.getAppList(ids);
|
||||
return success(PayAppConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得支付应用信息分页")
|
||||
@PreAuthorize("@ss.hasPermission('pay:app:query')")
|
||||
public CommonResult<PageResult<PayAppPageItemRespVO>> getAppPage(@Valid PayAppPageReqVO pageVO) {
|
||||
// 得到应用分页列表
|
||||
PageResult<PayAppDO> pageResult = appService.getAppPage(pageVO);
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return success(new PageResult<>(pageResult.getTotal()));
|
||||
}
|
||||
|
||||
// 得到所有的应用编号,查出所有的通道
|
||||
Collection<Long> payAppIds = CollectionUtils.convertList(pageResult.getList(), PayAppDO::getId);
|
||||
List<PayChannelDO> channels = channelService.getChannelListByAppIds(payAppIds);
|
||||
// TODO @aquan:可以基于 appId 简历一个 multiMap。这样下面,直接 get 到之后,CollUtil buildSet 即可
|
||||
Iterator<PayChannelDO> iterator = channels.iterator();
|
||||
|
||||
// 得到所有的商户信息
|
||||
Collection<Long> merchantIds = CollectionUtils.convertList(pageResult.getList(), PayAppDO::getMerchantId);
|
||||
Map<Long, PayMerchantDO> deptMap = merchantService.getMerchantMap(merchantIds);
|
||||
|
||||
// 利用反射将通道数据复制到返回的数据结构中去
|
||||
List<PayAppPageItemRespVO> appList = new ArrayList<>(pageResult.getList().size());
|
||||
pageResult.getList().forEach(app -> {
|
||||
// 写入应用信息的数据
|
||||
PayAppPageItemRespVO respVO = PayAppConvert.INSTANCE.pageConvert(app);
|
||||
// 写入商户的数据
|
||||
respVO.setPayMerchant(PayAppConvert.INSTANCE.convert(deptMap.get(app.getMerchantId())));
|
||||
// 写入支付渠道信息的数据
|
||||
Set<String> channelCodes = new HashSet<>(PayChannelEnum.values().length);
|
||||
while (iterator.hasNext()) {
|
||||
PayChannelDO channelDO = iterator.next();
|
||||
if (channelDO.getAppId().equals(app.getId())) {
|
||||
channelCodes.add(channelDO.getCode());
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
respVO.setChannelCodes(channelCodes);
|
||||
appList.add(respVO);
|
||||
});
|
||||
|
||||
return success(new PageResult<>(appList, pageResult.getTotal()));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出支付应用信息 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('pay:app:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportAppExcel(@Valid PayAppExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<PayAppDO> list = appService.getAppList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<PayAppExcelVO> datas = PayAppConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "支付应用信息.xls", "数据", PayAppExcelVO.class, datas);
|
||||
}
|
||||
|
||||
@GetMapping("/list-merchant-id")
|
||||
@ApiOperation("根据商户 ID 查询支付应用信息")
|
||||
@ApiImplicitParam(name = "merchantId", value = "商户ID", required = true, example = "1", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('pay:merchant:query')")
|
||||
public CommonResult<List<PayAppRespVO>> getMerchantListByName(@RequestParam String merchantId) {
|
||||
List<PayAppDO> appListDO = appService.getListByMerchantId(merchantId);
|
||||
return success(PayAppConvert.INSTANCE.convertList(appListDO));
|
||||
}
|
||||
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 支付应用信息 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class PayAppBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "应用名", required = true)
|
||||
@NotNull(message = "应用名不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "开启状态", required = true)
|
||||
@NotNull(message = "开启状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "支付结果的回调地址", required = true)
|
||||
@NotNull(message = "支付结果的回调地址不能为空")
|
||||
private String payNotifyUrl;
|
||||
|
||||
@ApiModelProperty(value = "退款结果的回调地址", required = true)
|
||||
@NotNull(message = "退款结果的回调地址不能为空")
|
||||
private String refundNotifyUrl;
|
||||
|
||||
@ApiModelProperty(value = "商户编号", required = true)
|
||||
@NotNull(message = "商户编号不能为空")
|
||||
private Long merchantId;
|
||||
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@ApiModel("支付应用信息创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayAppCreateReqVO extends PayAppBaseVO {
|
||||
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
/**
|
||||
* 支付应用信息 Excel VO
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Data
|
||||
public class PayAppExcelVO {
|
||||
|
||||
@ExcelProperty("应用编号")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("应用名")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("开启状态")
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty("支付结果的回调地址")
|
||||
private String payNotifyUrl;
|
||||
|
||||
@ExcelProperty("退款结果的回调地址")
|
||||
private String refundNotifyUrl;
|
||||
|
||||
@ExcelProperty("商户编号")
|
||||
private Long merchantId;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel(value = "支付应用信息 Excel 导出 Request VO", description = "参数和 PayAppPageReqVO 是一致的")
|
||||
@Data
|
||||
public class PayAppExportReqVO {
|
||||
|
||||
@ApiModelProperty(value = "应用名")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "开启状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "支付结果的回调地址")
|
||||
private String payNotifyUrl;
|
||||
|
||||
@ApiModelProperty(value = "退款结果的回调地址")
|
||||
private String refundNotifyUrl;
|
||||
|
||||
@ApiModelProperty(value = "商户名称")
|
||||
private String merchantName;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始创建时间")
|
||||
private Date beginCreateTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束创建时间")
|
||||
private Date endCreateTime;
|
||||
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 支付应用信息分页查询 Response VO
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@ApiModel(value = "支付应用信息分页查询 Response VO", description = "相比于支付信息,还会多出应用渠道的开关信息")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayAppPageItemRespVO extends PayAppBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "应用编号", required = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 所属商户
|
||||
*/
|
||||
private PayMerchant payMerchant;
|
||||
|
||||
@ApiModel("商户")
|
||||
@Data
|
||||
public static class PayMerchant {
|
||||
|
||||
@ApiModelProperty(value = "商户编号", required = true, example = "1")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "商户名称", required = true, example = "研发部")
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "渠道编码集合", required = true, example = "alipay_pc,alipay_wap...")
|
||||
private Set<String> channelCodes;
|
||||
|
||||
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("支付应用信息分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayAppPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "应用名")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "开启状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "支付结果的回调地址")
|
||||
private String payNotifyUrl;
|
||||
|
||||
@ApiModelProperty(value = "退款结果的回调地址")
|
||||
private String refundNotifyUrl;
|
||||
|
||||
@ApiModelProperty(value = "商户名称")
|
||||
private String merchantName;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始创建时间")
|
||||
private Date beginCreateTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束创建时间")
|
||||
private Date endCreateTime;
|
||||
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
@ApiModel("支付应用信息 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayAppRespVO extends PayAppBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "应用编号", required = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@ApiModel("支付应用信息更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayAppUpdateReqVO extends PayAppBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "应用编号", required = true)
|
||||
@NotNull(message = "应用编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("应用更新状态 Request VO")
|
||||
@Data
|
||||
public class PayAppUpdateStatusReqVO {
|
||||
|
||||
@ApiModelProperty(value = "商户编号", required = true, example = "1024")
|
||||
@NotNull(message = "商户编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 SysCommonStatusEnum 枚举")
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
}
|
@@ -1,129 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.channel;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.*;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.convert.channel.PayChannelConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.channel.PayChannelService;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO;
|
||||
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.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
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 static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
/**
|
||||
* 支付渠道 controller 组件
|
||||
* @author aquan
|
||||
*/
|
||||
@Api(tags = "支付渠道")
|
||||
@RestController
|
||||
@RequestMapping("/pay/channel")
|
||||
@Validated
|
||||
public class PayChannelController {
|
||||
|
||||
@Resource
|
||||
private PayChannelService channelService;
|
||||
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建支付渠道 ")
|
||||
@PreAuthorize("@ss.hasPermission('pay:channel:create')")
|
||||
public CommonResult<Long> createChannel(@Valid @RequestBody PayChannelCreateReqVO createReqVO) {
|
||||
return success(channelService.createChannel(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新支付渠道 ")
|
||||
@PreAuthorize("@ss.hasPermission('pay:channel:update')")
|
||||
public CommonResult<Boolean> updateChannel(@Valid @RequestBody PayChannelUpdateReqVO updateReqVO) {
|
||||
channelService.updateChannel(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除支付渠道 ")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('pay:channel:delete')")
|
||||
public CommonResult<Boolean> deleteChannel(@RequestParam("id") Long id) {
|
||||
channelService.deleteChannel(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得支付渠道 ")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('pay:channel:query')")
|
||||
public CommonResult<PayChannelRespVO> getChannel(@RequestParam("id") Long id) {
|
||||
PayChannelDO channel = channelService.getChannel(id);
|
||||
return success(PayChannelConvert.INSTANCE.convert(channel));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得支付渠道列表")
|
||||
@ApiImplicitParam(name = "ids", value = "编号列表",
|
||||
required = true, example = "1024,2048", dataTypeClass = List.class)
|
||||
@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")
|
||||
@ApiOperation("获得支付渠道分页")
|
||||
@PreAuthorize("@ss.hasPermission('pay:channel:query')")
|
||||
public CommonResult<PageResult<PayChannelRespVO>> getChannelPage(@Valid PayChannelPageReqVO pageVO) {
|
||||
PageResult<PayChannelDO> pageResult = channelService.getChannelPage(pageVO);
|
||||
return success(PayChannelConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出支付渠道Excel")
|
||||
@PreAuthorize("@ss.hasPermission('pay:channel:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportChannelExcel(@Valid PayChannelExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<PayChannelDO> list = channelService.getChannelList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<PayChannelExcelVO> datas = PayChannelConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "支付渠道.xls", "数据", PayChannelExcelVO.class, datas);
|
||||
}
|
||||
|
||||
@GetMapping("/get-channel")
|
||||
@ApiOperation("根据条件查询微信支付渠道")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "merchantId", value = "商户编号",
|
||||
required = true, example = "1", dataTypeClass = Long.class),
|
||||
@ApiImplicitParam(name = "appId", value = "应用编号",
|
||||
required = true, example = "1", dataTypeClass = Long.class),
|
||||
@ApiImplicitParam(name = "code", value = "支付渠道编码",
|
||||
required = true, example = "wx_pub", dataTypeClass = String.class)
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('pay:channel:query')")
|
||||
public CommonResult<PayChannelRespVO> getChannel(
|
||||
@RequestParam Long merchantId, @RequestParam Long appId, @RequestParam String code) {
|
||||
|
||||
// 獲取渠道
|
||||
PayChannelDO channel = channelService.getChannelByConditions(merchantId, appId, code);
|
||||
if (channel == null) {
|
||||
return success(new PayChannelRespVO());
|
||||
}
|
||||
// 拼凑数据
|
||||
PayChannelRespVO respVo = PayChannelConvert.INSTANCE.convert(channel);
|
||||
return success(respVo);
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 支付渠道
|
||||
Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class PayChannelBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "渠道编码", required = true)
|
||||
@NotNull(message = "渠道编码不能为空")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "开启状态", required = true)
|
||||
@NotNull(message = "开启状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "渠道费率,单位:百分比", required = true)
|
||||
@NotNull(message = "渠道费率,单位:百分比不能为空")
|
||||
private Double feeRate;
|
||||
|
||||
@ApiModelProperty(value = "商户编号", required = true)
|
||||
@NotNull(message = "商户编号不能为空")
|
||||
private Long merchantId;
|
||||
|
||||
@ApiModelProperty(value = "应用编号", required = true)
|
||||
@NotNull(message = "应用编号不能为空")
|
||||
private Long appId;
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@ApiModel("支付渠道 创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayChannelCreateReqVO extends PayChannelBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "通道配置的 json 字符串")
|
||||
@NotBlank(message = "通道配置不能为空")
|
||||
private String config;
|
||||
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
/**
|
||||
* 支付渠道
|
||||
Excel VO
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Data
|
||||
public class PayChannelExcelVO {
|
||||
|
||||
@ExcelProperty("商户编号")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("渠道编码")
|
||||
private String code;
|
||||
|
||||
@ExcelProperty("开启状态")
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty("渠道费率,单位:百分比")
|
||||
private Double feeRate;
|
||||
|
||||
@ExcelProperty("商户编号")
|
||||
private Long merchantId;
|
||||
|
||||
@ExcelProperty("应用编号")
|
||||
private Long appId;
|
||||
|
||||
/**
|
||||
* todo @芋艿 mapStruct 存在转换问题
|
||||
* java: Can't map property "PayClientConfig payChannelDO.config" to "String payChannelExcelVO.config".
|
||||
* Consider to declare/implement a mapping method: "String map(PayClientConfig value)".
|
||||
*/
|
||||
/// @ExcelProperty("支付渠道配置")
|
||||
/// private String config;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel(value = "支付渠道 Excel 导出 Request VO", description = "参数和 PayChannelPageReqVO 是一致的")
|
||||
@Data
|
||||
public class PayChannelExportReqVO {
|
||||
|
||||
@ApiModelProperty(value = "渠道编码")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "开启状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "渠道费率,单位:百分比")
|
||||
private Double feeRate;
|
||||
|
||||
@ApiModelProperty(value = "商户编号")
|
||||
private Long merchantId;
|
||||
|
||||
@ApiModelProperty(value = "应用编号")
|
||||
private Long appId;
|
||||
|
||||
@ApiModelProperty(value = "支付渠道配置")
|
||||
private String config;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始创建时间")
|
||||
private Date beginCreateTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束创建时间")
|
||||
private Date endCreateTime;
|
||||
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("支付渠道 分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayChannelPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "渠道编码")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "开启状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "渠道费率,单位:百分比")
|
||||
private Double feeRate;
|
||||
|
||||
@ApiModelProperty(value = "商户编号")
|
||||
private Long merchantId;
|
||||
|
||||
@ApiModelProperty(value = "应用编号")
|
||||
private Long appId;
|
||||
|
||||
@ApiModelProperty(value = "支付渠道配置")
|
||||
private String config;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始创建时间")
|
||||
private Date beginCreateTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束创建时间")
|
||||
private Date endCreateTime;
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
@ApiModel("支付渠道 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayChannelRespVO extends PayChannelBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "商户编号", required = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "配置", required = true)
|
||||
private String config;
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@ApiModel("支付渠道 更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayChannelUpdateReqVO extends PayChannelBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "商户编号", required = true)
|
||||
@NotNull(message = "商户编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "通道配置的json字符串")
|
||||
@NotBlank(message = "通道配置不能为空")
|
||||
private String config;
|
||||
}
|
@@ -1,116 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.merchant;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.*;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.convert.merchant.PayMerchantConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.merchant.PayMerchantService;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO;
|
||||
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.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
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 static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Api(tags = "支付商户信息")
|
||||
@RestController
|
||||
@RequestMapping("/pay/merchant")
|
||||
@Validated
|
||||
public class PayMerchantController {
|
||||
|
||||
@Resource
|
||||
private PayMerchantService merchantService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建支付商户信息")
|
||||
@PreAuthorize("@ss.hasPermission('pay:merchant:create')")
|
||||
public CommonResult<Long> createMerchant(@Valid @RequestBody PayMerchantCreateReqVO createReqVO) {
|
||||
return success(merchantService.createMerchant(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新支付商户信息")
|
||||
@PreAuthorize("@ss.hasPermission('pay:merchant:update')")
|
||||
public CommonResult<Boolean> updateMerchant(@Valid @RequestBody PayMerchantUpdateReqVO updateReqVO) {
|
||||
merchantService.updateMerchant(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/update-status")
|
||||
@ApiOperation("修改支付商户状态")
|
||||
@PreAuthorize("@ss.hasPermission('pay:merchant:update')")
|
||||
public CommonResult<Boolean> updateMerchantStatus(@Valid @RequestBody PayMerchantUpdateStatusReqVO reqVO) {
|
||||
merchantService.updateMerchantStatus(reqVO.getId(), reqVO.getStatus());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除支付商户信息")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('pay:merchant:delete')")
|
||||
public CommonResult<Boolean> deleteMerchant(@RequestParam("id") Long id) {
|
||||
merchantService.deleteMerchant(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得支付商户信息")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('pay:merchant:query')")
|
||||
public CommonResult<PayMerchantRespVO> getMerchant(@RequestParam("id") Long id) {
|
||||
PayMerchantDO merchant = merchantService.getMerchant(id);
|
||||
return success(PayMerchantConvert.INSTANCE.convert(merchant));
|
||||
}
|
||||
|
||||
@GetMapping("/list-by-name")
|
||||
@ApiOperation("根据商户名称获得支付商户信息列表")
|
||||
@ApiImplicitParam(name = "name", value = "商户名称", example = "芋道", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('pay:merchant:query')")
|
||||
public CommonResult<List<PayMerchantRespVO>> getMerchantListByName(@RequestParam(required = false) String name) {
|
||||
List<PayMerchantDO> merchantListDO = merchantService.getMerchantListByName(name);
|
||||
return success(PayMerchantConvert.INSTANCE.convertList(merchantListDO));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得支付商户信息列表")
|
||||
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
|
||||
@PreAuthorize("@ss.hasPermission('pay:merchant:query')")
|
||||
public CommonResult<List<PayMerchantRespVO>> getMerchantList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<PayMerchantDO> list = merchantService.getMerchantList(ids);
|
||||
return success(PayMerchantConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得支付商户信息分页")
|
||||
@PreAuthorize("@ss.hasPermission('pay:merchant:query')")
|
||||
public CommonResult<PageResult<PayMerchantRespVO>> getMerchantPage(@Valid PayMerchantPageReqVO pageVO) {
|
||||
PageResult<PayMerchantDO> pageResult = merchantService.getMerchantPage(pageVO);
|
||||
return success(PayMerchantConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出支付商户信息 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('pay:merchant:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportMerchantExcel(@Valid PayMerchantExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<PayMerchantDO> list = merchantService.getMerchantList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<PayMerchantExcelVO> datas = PayMerchantConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "支付商户信息.xls", "数据", PayMerchantExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 支付商户信息 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class PayMerchantBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "商户全称", required = true)
|
||||
@NotNull(message = "商户全称不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "商户简称", required = true)
|
||||
@NotNull(message = "商户简称不能为空")
|
||||
private String shortName;
|
||||
|
||||
@ApiModelProperty(value = "开启状态", required = true)
|
||||
@NotNull(message = "开启状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@ApiModel("支付商户信息创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayMerchantCreateReqVO extends PayMerchantBaseVO {
|
||||
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 支付商户信息 Excel VO
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Data
|
||||
public class PayMerchantExcelVO {
|
||||
|
||||
@ExcelProperty("商户编号")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("商户号")
|
||||
private String no;
|
||||
|
||||
@ExcelProperty("商户全称")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("商户简称")
|
||||
private String shortName;
|
||||
|
||||
@ExcelProperty(value = "开启状态",converter = DictConvert.class)
|
||||
@DictFormat("sys_common_status")
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel(value = "支付商户信息 Excel 导出 Request VO", description = "参数和 PayMerchantPageReqVO 是一致的")
|
||||
@Data
|
||||
public class PayMerchantExportReqVO {
|
||||
|
||||
@ApiModelProperty(value = "商户号")
|
||||
private String no;
|
||||
|
||||
@ApiModelProperty(value = "商户全称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "商户简称")
|
||||
private String shortName;
|
||||
|
||||
@ApiModelProperty(value = "开启状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始创建时间")
|
||||
private Date beginCreateTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束创建时间")
|
||||
private Date endCreateTime;
|
||||
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("支付商户信息分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayMerchantPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "商户号")
|
||||
private String no;
|
||||
|
||||
@ApiModelProperty(value = "商户全称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "商户简称")
|
||||
private String shortName;
|
||||
|
||||
@ApiModelProperty(value = "开启状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始创建时间")
|
||||
private Date beginCreateTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束创建时间")
|
||||
private Date endCreateTime;
|
||||
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("支付商户信息 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayMerchantRespVO extends PayMerchantBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "商户编号", required = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 商户号
|
||||
* 例如说,M233666999
|
||||
* 只有新增时插入,不允许修改
|
||||
*/
|
||||
private String no;
|
||||
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@ApiModel("支付商户信息更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayMerchantUpdateReqVO extends PayMerchantBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "商户编号", required = true)
|
||||
@NotNull(message = "商户编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("商户更新状态 Request VO")
|
||||
@Data
|
||||
public class PayMerchantUpdateStatusReqVO {
|
||||
|
||||
@ApiModelProperty(value = "商户编号", required = true, example = "1024")
|
||||
@NotNull(message = "商户编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 SysCommonStatusEnum 枚举")
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
}
|
@@ -1,177 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order.*;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.convert.order.PayOrderConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.app.PayAppService;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.merchant.PayMerchantService;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.order.PayOrderExtensionService;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.order.PayOrderService;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderExtensionDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
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 javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
/**
|
||||
* 支付订单 controller 组件
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Api(tags = "支付订单")
|
||||
@RestController
|
||||
@RequestMapping("/pay/order")
|
||||
@Validated
|
||||
public class PayOrderController {
|
||||
|
||||
/**
|
||||
* 订单 service 组件
|
||||
*/
|
||||
@Resource
|
||||
private PayOrderService orderService;
|
||||
|
||||
/**
|
||||
* 订单扩展 service 组件
|
||||
*/
|
||||
@Resource
|
||||
private PayOrderExtensionService orderExtensionService;
|
||||
|
||||
/**
|
||||
* 商户 service 组件
|
||||
*/
|
||||
@Resource
|
||||
private PayMerchantService merchantService;
|
||||
|
||||
/**
|
||||
* 应用 service 组件
|
||||
*/
|
||||
@Resource
|
||||
private PayAppService appService;
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得支付订单")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('pay:order:query')")
|
||||
public CommonResult<PayOrderDetailsRespVO> getOrder(@RequestParam("id") Long id) {
|
||||
PayOrderDO order = orderService.getOrder(id);
|
||||
if (ObjectUtil.isNull(order)) {
|
||||
return success(new PayOrderDetailsRespVO());
|
||||
}
|
||||
|
||||
PayMerchantDO merchantDO = merchantService.getMerchant(order.getMerchantId());
|
||||
PayAppDO appDO = appService.getApp(order.getAppId());
|
||||
PayChannelEnum channelEnum = PayChannelEnum.getByCode(order.getChannelCode());
|
||||
|
||||
PayOrderDetailsRespVO respVO = PayOrderConvert.INSTANCE.orderDetailConvert(order);
|
||||
respVO.setMerchantName(ObjectUtil.isNotNull(merchantDO) ? merchantDO.getName() : "未知商户");
|
||||
respVO.setAppName(ObjectUtil.isNotNull(appDO) ? appDO.getName() : "未知应用");
|
||||
respVO.setChannelCodeName(ObjectUtil.isNotNull(channelEnum) ? channelEnum.getName() : "未知渠道");
|
||||
|
||||
PayOrderExtensionDO extensionDO = orderExtensionService.getOrderExtension(order.getSuccessExtensionId());
|
||||
if (ObjectUtil.isNotNull(extensionDO)) {
|
||||
respVO.setPayOrderExtension(PayOrderConvert.INSTANCE.orderDetailExtensionConvert(extensionDO));
|
||||
}
|
||||
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得支付订单分页")
|
||||
@PreAuthorize("@ss.hasPermission('pay:order:query')")
|
||||
public CommonResult<PageResult<PayOrderPageItemRespVO>> getOrderPage(@Valid PayOrderPageReqVO pageVO) {
|
||||
PageResult<PayOrderDO> pageResult = orderService.getOrderPage(pageVO);
|
||||
if (CollectionUtil.isEmpty(pageResult.getList())) {
|
||||
return success(new PageResult<>(pageResult.getTotal()));
|
||||
}
|
||||
|
||||
// 处理商户ID数据
|
||||
Map<Long, PayMerchantDO> merchantMap = merchantService.getMerchantMap(
|
||||
CollectionUtils.convertList(pageResult.getList(), PayOrderDO::getMerchantId));
|
||||
// 处理应用ID数据
|
||||
Map<Long, PayAppDO> appMap = appService.getAppMap(
|
||||
CollectionUtils.convertList(pageResult.getList(), PayOrderDO::getAppId));
|
||||
|
||||
List<PayOrderPageItemRespVO> pageList = new ArrayList<>(pageResult.getList().size());
|
||||
pageResult.getList().forEach(c -> {
|
||||
PayMerchantDO merchantDO = merchantMap.get(c.getMerchantId());
|
||||
PayAppDO appDO = appMap.get(c.getAppId());
|
||||
PayChannelEnum channelEnum = PayChannelEnum.getByCode(c.getChannelCode());
|
||||
|
||||
PayOrderPageItemRespVO orderItem = PayOrderConvert.INSTANCE.pageConvertItemPage(c);
|
||||
orderItem.setMerchantName(ObjectUtil.isNotNull(merchantDO) ? merchantDO.getName() : "未知商户");
|
||||
orderItem.setAppName(ObjectUtil.isNotNull(appDO) ? appDO.getName() : "未知应用");
|
||||
orderItem.setChannelCodeName(ObjectUtil.isNotNull(channelEnum) ? channelEnum.getName() : "未知渠道");
|
||||
pageList.add(orderItem);
|
||||
});
|
||||
return success(new PageResult<>(pageList, pageResult.getTotal()));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出支付订单Excel")
|
||||
@PreAuthorize("@ss.hasPermission('pay:order:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportOrderExcel(@Valid PayOrderExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
|
||||
List<PayOrderDO> list = orderService.getOrderList(exportReqVO);
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
ExcelUtils.write(response, "支付订单.xls", "数据",
|
||||
PayOrderExcelVO.class, new ArrayList<>());
|
||||
}
|
||||
|
||||
// 处理商户ID数据
|
||||
Map<Long, PayMerchantDO> merchantMap = merchantService.getMerchantMap(
|
||||
CollectionUtils.convertList(list, PayOrderDO::getMerchantId));
|
||||
// 处理应用ID数据
|
||||
Map<Long, PayAppDO> appMap = appService.getAppMap(
|
||||
CollectionUtils.convertList(list, PayOrderDO::getAppId));
|
||||
// 处理扩展订单数据
|
||||
Map<Long, PayOrderExtensionDO> orderExtensionMap = orderExtensionService
|
||||
.getOrderExtensionMap(CollectionUtils.convertList(list, PayOrderDO::getSuccessExtensionId));
|
||||
|
||||
List<PayOrderExcelVO> excelDatum = new ArrayList<>(list.size());
|
||||
list.forEach(c -> {
|
||||
PayMerchantDO merchantDO = merchantMap.get(c.getMerchantId());
|
||||
PayAppDO appDO = appMap.get(c.getAppId());
|
||||
PayChannelEnum channelEnum = PayChannelEnum.getByCode(c.getChannelCode());
|
||||
PayOrderExtensionDO orderExtensionDO = orderExtensionMap.get(c.getSuccessExtensionId());
|
||||
|
||||
PayOrderExcelVO excelItem = PayOrderConvert.INSTANCE.excelConvert(c);
|
||||
excelItem.setMerchantName(ObjectUtil.isNotNull(merchantDO) ? merchantDO.getName() : "未知商户");
|
||||
excelItem.setAppName(ObjectUtil.isNotNull(appDO) ? appDO.getName() : "未知应用");
|
||||
excelItem.setChannelCodeName(ObjectUtil.isNotNull(channelEnum) ? channelEnum.getName() : "未知渠道");
|
||||
excelItem.setNo(ObjectUtil.isNotNull(orderExtensionDO) ? orderExtensionDO.getNo() : "");
|
||||
excelDatum.add(excelItem);
|
||||
});
|
||||
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "支付订单.xls", "数据", PayOrderExcelVO.class, excelDatum);
|
||||
}
|
||||
|
||||
}
|
@@ -1,174 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo.*;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.convert.refund.PayRefundConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.app.PayAppService;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.merchant.PayMerchantService;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.order.PayOrderService;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.order.PayRefundService;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayRefundDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
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 javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
/**
|
||||
* 退款订单 Controller 组件
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Api(tags = "退款订单")
|
||||
@RestController
|
||||
@RequestMapping("/pay/refund")
|
||||
@Validated
|
||||
public class PayRefundController {
|
||||
|
||||
@Resource
|
||||
private PayRefundService refundService;
|
||||
|
||||
/**
|
||||
* 商户 service 组件
|
||||
*/
|
||||
@Resource
|
||||
private PayMerchantService merchantService;
|
||||
|
||||
/**
|
||||
* 应用 service 组件
|
||||
*/
|
||||
@Resource
|
||||
private PayAppService appService;
|
||||
|
||||
/**
|
||||
* 订单 service 组件
|
||||
*/
|
||||
@Resource
|
||||
private PayOrderService orderService;
|
||||
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得退款订单")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('pay:refund:query')")
|
||||
public CommonResult<PayRefundDetailsRespVO> getRefund(@RequestParam("id") Long id) {
|
||||
PayRefundDO refund = refundService.getRefund(id);
|
||||
if (ObjectUtil.isNull(refund)) {
|
||||
return success(new PayRefundDetailsRespVO());
|
||||
}
|
||||
|
||||
PayMerchantDO merchantDO = merchantService.getMerchant(refund.getMerchantId());
|
||||
PayAppDO appDO = appService.getApp(refund.getAppId());
|
||||
PayChannelEnum channelEnum = PayChannelEnum.getByCode(refund.getChannelCode());
|
||||
PayOrderDO orderDO = orderService.getOrder(refund.getOrderId());
|
||||
|
||||
PayRefundDetailsRespVO refundDetail = PayRefundConvert.INSTANCE.refundDetailConvert(refund);
|
||||
refundDetail.setMerchantName(ObjectUtil.isNotNull(merchantDO) ? merchantDO.getName() : "未知商户");
|
||||
refundDetail.setAppName(ObjectUtil.isNotNull(appDO) ? appDO.getName() : "未知应用");
|
||||
refundDetail.setChannelCodeName(ObjectUtil.isNotNull(channelEnum) ? channelEnum.getName() : "未知渠道");
|
||||
refundDetail.setSubject(orderDO.getSubject());
|
||||
|
||||
return success(refundDetail);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得退款订单分页")
|
||||
@PreAuthorize("@ss.hasPermission('pay:refund:query')")
|
||||
public CommonResult<PageResult<PayRefundPageItemRespVO>> getRefundPage(@Valid PayRefundPageReqVO pageVO) {
|
||||
PageResult<PayRefundDO> pageResult = refundService.getRefundPage(pageVO);
|
||||
if (CollectionUtil.isEmpty(pageResult.getList())) {
|
||||
return success(new PageResult<>(pageResult.getTotal()));
|
||||
}
|
||||
|
||||
// 处理商户ID数据
|
||||
Map<Long, PayMerchantDO> merchantMap = merchantService.getMerchantMap(
|
||||
CollectionUtils.convertList(pageResult.getList(), PayRefundDO::getMerchantId));
|
||||
// 处理应用ID数据
|
||||
Map<Long, PayAppDO> appMap = appService.getAppMap(
|
||||
CollectionUtils.convertList(pageResult.getList(), PayRefundDO::getAppId));
|
||||
List<PayRefundPageItemRespVO> list = new ArrayList<>(pageResult.getList().size());
|
||||
pageResult.getList().forEach(c -> {
|
||||
PayMerchantDO merchantDO = merchantMap.get(c.getMerchantId());
|
||||
PayAppDO appDO = appMap.get(c.getAppId());
|
||||
PayChannelEnum channelEnum = PayChannelEnum.getByCode(c.getChannelCode());
|
||||
|
||||
PayRefundPageItemRespVO item = PayRefundConvert.INSTANCE.pageItemConvert(c);
|
||||
|
||||
item.setMerchantName(ObjectUtil.isNotNull(merchantDO) ? merchantDO.getName() : "未知商户");
|
||||
item.setAppName(ObjectUtil.isNotNull(appDO) ? appDO.getName() : "未知应用");
|
||||
item.setChannelCodeName(ObjectUtil.isNotNull(channelEnum) ? channelEnum.getName() : "未知渠道");
|
||||
list.add(item);
|
||||
});
|
||||
|
||||
return success(new PageResult<>(list, pageResult.getTotal()));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出退款订单 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('pay:refund:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportRefundExcel(@Valid PayRefundExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
|
||||
List<PayRefundDO> list = refundService.getRefundList(exportReqVO);
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
ExcelUtils.write(response, "退款订单.xls", "数据",
|
||||
PayRefundExcelVO.class, new ArrayList<>());
|
||||
}
|
||||
|
||||
// 处理商户ID数据
|
||||
Map<Long, PayMerchantDO> merchantMap = merchantService.getMerchantMap(
|
||||
CollectionUtils.convertList(list, PayRefundDO::getMerchantId));
|
||||
// 处理应用ID数据
|
||||
Map<Long, PayAppDO> appMap = appService.getAppMap(
|
||||
CollectionUtils.convertList(list, PayRefundDO::getAppId));
|
||||
|
||||
List<PayRefundExcelVO> excelDatum = new ArrayList<>(list.size());
|
||||
// 处理商品名称数据
|
||||
Map<Long, PayOrderDO> orderMap = orderService.getOrderSubjectMap(
|
||||
CollectionUtils.convertList(list, PayRefundDO::getOrderId));
|
||||
|
||||
list.forEach(c -> {
|
||||
PayMerchantDO merchantDO = merchantMap.get(c.getMerchantId());
|
||||
PayAppDO appDO = appMap.get(c.getAppId());
|
||||
PayChannelEnum channelEnum = PayChannelEnum.getByCode(c.getChannelCode());
|
||||
|
||||
PayRefundExcelVO excelItem = PayRefundConvert.INSTANCE.excelConvert(c);
|
||||
excelItem.setMerchantName(ObjectUtil.isNotNull(merchantDO) ? merchantDO.getName() : "未知商户");
|
||||
excelItem.setAppName(ObjectUtil.isNotNull(appDO) ? appDO.getName() : "未知应用");
|
||||
excelItem.setChannelCodeName(ObjectUtil.isNotNull(channelEnum) ? channelEnum.getName() : "未知渠道");
|
||||
excelItem.setSubject(orderMap.get(c.getOrderId()).getSubject());
|
||||
|
||||
excelDatum.add(excelItem);
|
||||
});
|
||||
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "退款订单.xls", "数据", PayRefundExcelVO.class, excelDatum);
|
||||
}
|
||||
|
||||
}
|
@@ -1,108 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 支付订单
|
||||
* Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Data
|
||||
public class PayOrderBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "商户编号", required = true)
|
||||
@NotNull(message = "商户编号不能为空")
|
||||
private Long merchantId;
|
||||
|
||||
@ApiModelProperty(value = "应用编号", required = true)
|
||||
@NotNull(message = "应用编号不能为空")
|
||||
private Long appId;
|
||||
|
||||
@ApiModelProperty(value = "渠道编号")
|
||||
private Long channelId;
|
||||
|
||||
@ApiModelProperty(value = "渠道编码")
|
||||
private String channelCode;
|
||||
|
||||
@ApiModelProperty(value = "商户订单编号", required = true)
|
||||
@NotNull(message = "商户订单编号不能为空")
|
||||
private String merchantOrderId;
|
||||
|
||||
@ApiModelProperty(value = "商品标题", required = true)
|
||||
@NotNull(message = "商品标题不能为空")
|
||||
private String subject;
|
||||
|
||||
@ApiModelProperty(value = "商品描述", required = true)
|
||||
@NotNull(message = "商品描述不能为空")
|
||||
private String body;
|
||||
|
||||
@ApiModelProperty(value = "异步通知地址", required = true)
|
||||
@NotNull(message = "异步通知地址不能为空")
|
||||
private String notifyUrl;
|
||||
|
||||
@ApiModelProperty(value = "通知商户支付结果的回调状态", required = true)
|
||||
@NotNull(message = "通知商户支付结果的回调状态不能为空")
|
||||
private Integer notifyStatus;
|
||||
|
||||
@ApiModelProperty(value = "支付金额,单位:分", required = true)
|
||||
@NotNull(message = "支付金额,单位:分不能为空")
|
||||
private Long amount;
|
||||
|
||||
@ApiModelProperty(value = "渠道手续费,单位:百分比")
|
||||
private Double channelFeeRate;
|
||||
|
||||
@ApiModelProperty(value = "渠道手续金额,单位:分")
|
||||
private Long channelFeeAmount;
|
||||
|
||||
@ApiModelProperty(value = "支付状态", required = true)
|
||||
@NotNull(message = "支付状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "用户 IP", required = true)
|
||||
@NotNull(message = "用户 IP不能为空")
|
||||
private String userIp;
|
||||
|
||||
@ApiModelProperty(value = "订单失效时间", required = true)
|
||||
@NotNull(message = "订单失效时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date expireTime;
|
||||
|
||||
@ApiModelProperty(value = "订单支付成功时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date successTime;
|
||||
|
||||
@ApiModelProperty(value = "订单支付通知时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date notifyTime;
|
||||
|
||||
@ApiModelProperty(value = "支付成功的订单拓展单编号")
|
||||
private Long successExtensionId;
|
||||
|
||||
@ApiModelProperty(value = "退款状态", required = true)
|
||||
@NotNull(message = "退款状态不能为空")
|
||||
private Integer refundStatus;
|
||||
|
||||
@ApiModelProperty(value = "退款次数", required = true)
|
||||
@NotNull(message = "退款次数不能为空")
|
||||
private Integer refundTimes;
|
||||
|
||||
@ApiModelProperty(value = "退款总金额,单位:分", required = true)
|
||||
@NotNull(message = "退款总金额,单位:分不能为空")
|
||||
private Long refundAmount;
|
||||
|
||||
@ApiModelProperty(value = "渠道用户编号")
|
||||
private String channelUserId;
|
||||
|
||||
@ApiModelProperty(value = "渠道订单号")
|
||||
private String channelOrderNo;
|
||||
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 支付订单详细信息,由支付订单和支付订单扩展信息组成
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@ApiModel("支付订单详细信息 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayOrderDetailsRespVO extends PayOrderBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "支付订单编号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "商户名称")
|
||||
private String merchantName;
|
||||
|
||||
@ApiModelProperty(value = "应用名称")
|
||||
private String appName;
|
||||
|
||||
@ApiModelProperty(value = "渠道编号名称")
|
||||
private String channelCodeName;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 支付订单扩展
|
||||
*/
|
||||
private PayOrderExtension payOrderExtension;
|
||||
|
||||
@Data
|
||||
@ApiModel("支付订单扩展")
|
||||
public static class PayOrderExtension {
|
||||
|
||||
@ApiModelProperty(value = "支付订单号")
|
||||
private String no;
|
||||
|
||||
@ApiModelProperty(value = "支付异步通知的内容")
|
||||
private String channelNotifyData;
|
||||
}
|
||||
|
||||
}
|
@@ -1,91 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order;
|
||||
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 支付订单Excel VO
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Data
|
||||
public class PayOrderExcelVO {
|
||||
|
||||
@ExcelProperty("支付订单编号")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty(value = "商户名称")
|
||||
private String merchantName;
|
||||
|
||||
@ExcelProperty(value = "应用名称")
|
||||
private String appName;
|
||||
|
||||
@ExcelProperty("商品标题")
|
||||
private String subject;
|
||||
|
||||
@ExcelProperty("商户订单编号")
|
||||
private String merchantOrderId;
|
||||
|
||||
@ExcelProperty("渠道订单号")
|
||||
private String channelOrderNo;
|
||||
|
||||
@ExcelProperty(value = "支付订单号")
|
||||
private String no;
|
||||
|
||||
@ExcelProperty("支付金额,单位:元")
|
||||
private String amount;
|
||||
|
||||
@ExcelProperty("渠道手续金额,单位:元")
|
||||
private String channelFeeAmount;
|
||||
|
||||
@ExcelProperty("渠道手续费,单位:百分比")
|
||||
private String channelFeeRate;
|
||||
|
||||
@DictFormat(DictTypeConstants.PAY_ORDER_STATUS)
|
||||
@ExcelProperty(value = "支付状态", converter = DictConvert.class)
|
||||
private Integer status;
|
||||
|
||||
@DictFormat(DictTypeConstants.PAY_ORDER_NOTIFY_STATUS)
|
||||
@ExcelProperty(value = "通知商户支付结果的回调状态", converter = DictConvert.class)
|
||||
private Integer notifyStatus;
|
||||
|
||||
@ExcelProperty("异步通知地址")
|
||||
private String notifyUrl;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ExcelProperty("订单支付成功时间")
|
||||
private Date successTime;
|
||||
|
||||
@ExcelProperty("订单失效时间")
|
||||
private Date expireTime;
|
||||
|
||||
@ExcelProperty("订单支付通知时间")
|
||||
private Date notifyTime;
|
||||
|
||||
@ExcelProperty(value = "渠道编号名称")
|
||||
private String channelCodeName;
|
||||
|
||||
@ExcelProperty("用户 IP")
|
||||
private String userIp;
|
||||
|
||||
@DictFormat(DictTypeConstants.PAY_ORDER_REFUND_STATUS)
|
||||
@ExcelProperty(value = "退款状态", converter = DictConvert.class)
|
||||
private Integer refundStatus;
|
||||
|
||||
@ExcelProperty("退款次数")
|
||||
private Integer refundTimes;
|
||||
|
||||
@ExcelProperty("退款总金额,单位:元")
|
||||
private String refundAmount;
|
||||
|
||||
@ExcelProperty("商品描述")
|
||||
private String body;
|
||||
|
||||
}
|
@@ -1,112 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 支付订单 Excel 导出 Request VO
|
||||
* @author aquan
|
||||
*/
|
||||
@ApiModel(value = "支付订单 Excel 导出 Request VO", description = "参数和 PayOrderPageReqVO 是一致的")
|
||||
@Data
|
||||
public class PayOrderExportReqVO {
|
||||
|
||||
@ApiModelProperty(value = "商户编号")
|
||||
private Long merchantId;
|
||||
|
||||
@ApiModelProperty(value = "应用编号")
|
||||
private Long appId;
|
||||
|
||||
@ApiModelProperty(value = "渠道编号")
|
||||
private Long channelId;
|
||||
|
||||
@ApiModelProperty(value = "渠道编码")
|
||||
private String channelCode;
|
||||
|
||||
@ApiModelProperty(value = "商户订单编号")
|
||||
private String merchantOrderId;
|
||||
|
||||
@ApiModelProperty(value = "商品标题")
|
||||
private String subject;
|
||||
|
||||
@ApiModelProperty(value = "商品描述")
|
||||
private String body;
|
||||
|
||||
@ApiModelProperty(value = "异步通知地址")
|
||||
private String notifyUrl;
|
||||
|
||||
@ApiModelProperty(value = "通知商户支付结果的回调状态")
|
||||
private Integer notifyStatus;
|
||||
|
||||
@ApiModelProperty(value = "支付金额,单位:分")
|
||||
private Long amount;
|
||||
|
||||
@ApiModelProperty(value = "渠道手续费,单位:百分比")
|
||||
private Double channelFeeRate;
|
||||
|
||||
@ApiModelProperty(value = "渠道手续金额,单位:分")
|
||||
private Long channelFeeAmount;
|
||||
|
||||
@ApiModelProperty(value = "支付状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "用户 IP")
|
||||
private String userIp;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始订单失效时间")
|
||||
private Date beginExpireTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束订单失效时间")
|
||||
private Date endExpireTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始订单支付成功时间")
|
||||
private Date beginSuccessTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束订单支付成功时间")
|
||||
private Date endSuccessTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始订单支付通知时间")
|
||||
private Date beginNotifyTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束订单支付通知时间")
|
||||
private Date endNotifyTime;
|
||||
|
||||
@ApiModelProperty(value = "支付成功的订单拓展单编号")
|
||||
private Long successExtensionId;
|
||||
|
||||
@ApiModelProperty(value = "退款状态")
|
||||
private Integer refundStatus;
|
||||
|
||||
@ApiModelProperty(value = "退款次数")
|
||||
private Integer refundTimes;
|
||||
|
||||
@ApiModelProperty(value = "退款总金额,单位:分")
|
||||
private Long refundAmount;
|
||||
|
||||
@ApiModelProperty(value = "渠道用户编号")
|
||||
private String channelUserId;
|
||||
|
||||
@ApiModelProperty(value = "渠道订单号")
|
||||
private String channelOrderNo;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始创建时间")
|
||||
private Date beginCreateTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束创建时间")
|
||||
private Date endCreateTime;
|
||||
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 支付订单分页 Request VO
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@ApiModel("支付订单分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayOrderPageItemRespVO extends PayOrderBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "支付订单编号", required = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "商户名称")
|
||||
private String merchantName;
|
||||
|
||||
@ApiModelProperty(value = "应用名称")
|
||||
private String appName;
|
||||
|
||||
@ApiModelProperty(value = "渠道名称")
|
||||
private String channelCodeName;
|
||||
|
||||
@ApiModelProperty(value = "支付订单号")
|
||||
private String no;
|
||||
|
||||
|
||||
}
|
@@ -1,118 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 支付订单分页 Request VO
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@ApiModel("支付订单分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayOrderPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "商户编号")
|
||||
private Long merchantId;
|
||||
|
||||
@ApiModelProperty(value = "应用编号")
|
||||
private Long appId;
|
||||
|
||||
@ApiModelProperty(value = "渠道编号")
|
||||
private Long channelId;
|
||||
|
||||
@ApiModelProperty(value = "渠道编码")
|
||||
private String channelCode;
|
||||
|
||||
@ApiModelProperty(value = "商户订单编号")
|
||||
private String merchantOrderId;
|
||||
|
||||
@ApiModelProperty(value = "商品标题")
|
||||
private String subject;
|
||||
|
||||
@ApiModelProperty(value = "商品描述")
|
||||
private String body;
|
||||
|
||||
@ApiModelProperty(value = "异步通知地址")
|
||||
private String notifyUrl;
|
||||
|
||||
@ApiModelProperty(value = "通知商户支付结果的回调状态")
|
||||
private Integer notifyStatus;
|
||||
|
||||
@ApiModelProperty(value = "支付金额,单位:分")
|
||||
private Long amount;
|
||||
|
||||
@ApiModelProperty(value = "渠道手续费,单位:百分比")
|
||||
private Double channelFeeRate;
|
||||
|
||||
@ApiModelProperty(value = "渠道手续金额,单位:分")
|
||||
private Long channelFeeAmount;
|
||||
|
||||
@ApiModelProperty(value = "支付状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "用户 IP")
|
||||
private String userIp;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始订单失效时间")
|
||||
private Date beginExpireTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束订单失效时间")
|
||||
private Date endExpireTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始订单支付成功时间")
|
||||
private Date beginSuccessTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束订单支付成功时间")
|
||||
private Date endSuccessTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始订单支付通知时间")
|
||||
private Date beginNotifyTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束订单支付通知时间")
|
||||
private Date endNotifyTime;
|
||||
|
||||
@ApiModelProperty(value = "支付成功的订单拓展单编号")
|
||||
private Long successExtensionId;
|
||||
|
||||
@ApiModelProperty(value = "退款状态")
|
||||
private Integer refundStatus;
|
||||
|
||||
@ApiModelProperty(value = "退款次数")
|
||||
private Integer refundTimes;
|
||||
|
||||
@ApiModelProperty(value = "退款总金额,单位:分")
|
||||
private Long refundAmount;
|
||||
|
||||
@ApiModelProperty(value = "渠道用户编号")
|
||||
private String channelUserId;
|
||||
|
||||
@ApiModelProperty(value = "渠道订单号")
|
||||
private String channelOrderNo;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始创建时间")
|
||||
private Date beginCreateTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束创建时间")
|
||||
private Date endCreateTime;
|
||||
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 支付订单 Response VO
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@ApiModel("支付订单 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayOrderRespVO extends PayOrderBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "支付订单编号", required = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
@@ -1,110 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 退款订单 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class PayRefundBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "商户编号", required = true)
|
||||
@NotNull(message = "商户编号不能为空")
|
||||
private Long merchantId;
|
||||
|
||||
@ApiModelProperty(value = "应用编号", required = true)
|
||||
@NotNull(message = "应用编号不能为空")
|
||||
private Long appId;
|
||||
|
||||
@ApiModelProperty(value = "渠道编号", required = true)
|
||||
@NotNull(message = "渠道编号不能为空")
|
||||
private Long channelId;
|
||||
|
||||
@ApiModelProperty(value = "渠道编码", required = true)
|
||||
@NotNull(message = "渠道编码不能为空")
|
||||
private String channelCode;
|
||||
|
||||
@ApiModelProperty(value = "支付订单编号 pay_order 表id", required = true)
|
||||
@NotNull(message = "支付订单编号 pay_order 表id不能为空")
|
||||
private Long orderId;
|
||||
|
||||
@ApiModelProperty(value = "交易订单号 pay_extension 表no 字段", required = true)
|
||||
@NotNull(message = "交易订单号 pay_extension 表no 字段不能为空")
|
||||
private String tradeNo;
|
||||
|
||||
@ApiModelProperty(value = "商户订单编号(商户系统生成)", required = true)
|
||||
@NotNull(message = "商户订单编号(商户系统生成)不能为空")
|
||||
private String merchantOrderId;
|
||||
|
||||
@ApiModelProperty(value = "商户退款订单号(商户系统生成)", required = true)
|
||||
@NotNull(message = "商户退款订单号(商户系统生成)不能为空")
|
||||
private String merchantRefundNo;
|
||||
|
||||
@ApiModelProperty(value = "异步通知商户地址", required = true)
|
||||
@NotNull(message = "异步通知商户地址不能为空")
|
||||
private String notifyUrl;
|
||||
|
||||
@ApiModelProperty(value = "通知商户退款结果的回调状态", required = true)
|
||||
@NotNull(message = "通知商户退款结果的回调状态不能为空")
|
||||
private Integer notifyStatus;
|
||||
|
||||
@ApiModelProperty(value = "退款状态", required = true)
|
||||
@NotNull(message = "退款状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "退款类型(部分退款,全部退款)", required = true)
|
||||
@NotNull(message = "退款类型(部分退款,全部退款)不能为空")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "支付金额,单位分", required = true)
|
||||
@NotNull(message = "支付金额,单位分不能为空")
|
||||
private Long payAmount;
|
||||
|
||||
@ApiModelProperty(value = "退款金额,单位分", required = true)
|
||||
@NotNull(message = "退款金额,单位分不能为空")
|
||||
private Long refundAmount;
|
||||
|
||||
@ApiModelProperty(value = "退款原因", required = true)
|
||||
@NotNull(message = "退款原因不能为空")
|
||||
private String reason;
|
||||
|
||||
@ApiModelProperty(value = "用户 IP")
|
||||
private String userIp;
|
||||
|
||||
@ApiModelProperty(value = "渠道订单号,pay_order 中的channel_order_no 对应", required = true)
|
||||
@NotNull(message = "渠道订单号,pay_order 中的channel_order_no 对应不能为空")
|
||||
private String channelOrderNo;
|
||||
|
||||
@ApiModelProperty(value = "渠道退款单号,渠道返回")
|
||||
private String channelRefundNo;
|
||||
|
||||
@ApiModelProperty(value = "渠道调用报错时,错误码")
|
||||
private String channelErrorCode;
|
||||
|
||||
@ApiModelProperty(value = "渠道调用报错时,错误信息")
|
||||
private String channelErrorMsg;
|
||||
|
||||
@ApiModelProperty(value = "支付渠道的额外参数")
|
||||
private String channelExtras;
|
||||
|
||||
@ApiModelProperty(value = "退款失效时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date expireTime;
|
||||
|
||||
@ApiModelProperty(value = "退款成功时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date successTime;
|
||||
|
||||
@ApiModelProperty(value = "退款通知时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date notifyTime;
|
||||
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
@ApiModel("退款订单创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayRefundCreateReqVO extends PayRefundBaseVO {
|
||||
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 退款订单详情 Response VO
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@ApiModel("退款订单详情 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayRefundDetailsRespVO extends PayRefundBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "支付退款编号", required = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "商户名称")
|
||||
private String merchantName;
|
||||
|
||||
@ApiModelProperty(value = "应用名称")
|
||||
private String appName;
|
||||
|
||||
@ApiModelProperty(value = "渠道编号名称")
|
||||
private String channelCodeName;
|
||||
|
||||
@NotNull(message = "商品标题不能为空")
|
||||
private String subject;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
}
|
@@ -1,88 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 退款订单 Excel VO
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Data
|
||||
public class PayRefundExcelVO {
|
||||
|
||||
@ExcelProperty("支付退款编号")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("商品名称")
|
||||
private String subject;
|
||||
|
||||
@ExcelProperty(value = "商户名称")
|
||||
private String merchantName;
|
||||
|
||||
@ExcelProperty(value = "应用名称")
|
||||
private String appName;
|
||||
|
||||
@ExcelProperty(value = "渠道编号名称")
|
||||
private String channelCodeName;
|
||||
|
||||
@ExcelProperty("交易订单号")
|
||||
private String tradeNo;
|
||||
|
||||
@ExcelProperty("商户订单编号")
|
||||
private String merchantOrderId;
|
||||
|
||||
@ExcelProperty("商户退款订单号")
|
||||
private String merchantRefundNo;
|
||||
|
||||
@ExcelProperty("异步通知商户地址")
|
||||
private String notifyUrl;
|
||||
|
||||
@DictFormat(DictTypeConstants.PAY_ORDER_NOTIFY_STATUS)
|
||||
@ExcelProperty(value = "商户退款结果回调状态", converter = DictConvert.class)
|
||||
private Integer notifyStatus;
|
||||
|
||||
@DictFormat(DictTypeConstants.PAY_REFUND_ORDER_STATUS)
|
||||
@ExcelProperty(value = "退款状态", converter = DictConvert.class)
|
||||
private Integer status;
|
||||
|
||||
@DictFormat(DictTypeConstants.PAY_REFUND_ORDER_TYPE)
|
||||
@ExcelProperty(value = "退款类型", converter = DictConvert.class)
|
||||
private Integer type;
|
||||
|
||||
@ExcelProperty("支付金额,单位:元")
|
||||
private String payAmount;
|
||||
|
||||
@ExcelProperty("退款金额,单位:元")
|
||||
private String refundAmount;
|
||||
|
||||
@ExcelProperty("退款原因")
|
||||
private String reason;
|
||||
|
||||
@ExcelProperty("用户付款 IP")
|
||||
private String userIp;
|
||||
|
||||
@ExcelProperty("渠道订单号")
|
||||
private String channelOrderNo;
|
||||
|
||||
@ExcelProperty("渠道退款单号")
|
||||
private String channelRefundNo;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ExcelProperty("退款成功时间")
|
||||
private Date successTime;
|
||||
|
||||
@ExcelProperty("退款通知时间")
|
||||
private Date notifyTime;
|
||||
|
||||
@ExcelProperty("退款失效时间")
|
||||
private Date expireTime;
|
||||
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel(value = "退款订单 Excel 导出 Request VO", description = "参数和 PayRefundPageReqVO 是一致的")
|
||||
@Data
|
||||
public class PayRefundExportReqVO {
|
||||
|
||||
@ApiModelProperty(value = "商户编号")
|
||||
private Long merchantId;
|
||||
|
||||
@ApiModelProperty(value = "应用编号")
|
||||
private Long appId;
|
||||
|
||||
@ApiModelProperty(value = "渠道编号")
|
||||
private Long channelId;
|
||||
|
||||
@ApiModelProperty(value = "渠道编码")
|
||||
private String channelCode;
|
||||
|
||||
@ApiModelProperty(value = "支付订单编号 pay_order 表id")
|
||||
private Long orderId;
|
||||
|
||||
@ApiModelProperty(value = "交易订单号 pay_extension 表no 字段")
|
||||
private String tradeNo;
|
||||
|
||||
@ApiModelProperty(value = "商户订单编号(商户系统生成)")
|
||||
private String merchantOrderId;
|
||||
|
||||
@ApiModelProperty(value = "商户退款订单号(商户系统生成)")
|
||||
private String merchantRefundNo;
|
||||
|
||||
@ApiModelProperty(value = "异步通知商户地址")
|
||||
private String notifyUrl;
|
||||
|
||||
@ApiModelProperty(value = "通知商户退款结果的回调状态")
|
||||
private Integer notifyStatus;
|
||||
|
||||
@ApiModelProperty(value = "退款状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "退款类型(部分退款,全部退款)")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "支付金额,单位分")
|
||||
private Long payAmount;
|
||||
|
||||
@ApiModelProperty(value = "退款金额,单位分")
|
||||
private Long refundAmount;
|
||||
|
||||
@ApiModelProperty(value = "退款原因")
|
||||
private String reason;
|
||||
|
||||
@ApiModelProperty(value = "用户 IP")
|
||||
private String userIp;
|
||||
|
||||
@ApiModelProperty(value = "渠道订单号,pay_order 中的channel_order_no 对应")
|
||||
private String channelOrderNo;
|
||||
|
||||
@ApiModelProperty(value = "渠道退款单号,渠道返回")
|
||||
private String channelRefundNo;
|
||||
|
||||
@ApiModelProperty(value = "渠道调用报错时,错误码")
|
||||
private String channelErrorCode;
|
||||
|
||||
@ApiModelProperty(value = "渠道调用报错时,错误信息")
|
||||
private String channelErrorMsg;
|
||||
|
||||
@ApiModelProperty(value = "支付渠道的额外参数")
|
||||
private String channelExtras;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始退款失效时间")
|
||||
private Date beginExpireTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束退款失效时间")
|
||||
private Date endExpireTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始退款成功时间")
|
||||
private Date beginSuccessTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束退款成功时间")
|
||||
private Date endSuccessTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始退款通知时间")
|
||||
private Date beginNotifyTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束退款通知时间")
|
||||
private Date endNotifyTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始创建时间")
|
||||
private Date beginCreateTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束创建时间")
|
||||
private Date endCreateTime;
|
||||
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 退款订单分页查询 Response VO
|
||||
* @author aquan
|
||||
*/
|
||||
@ApiModel("退款订单分页查询 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayRefundPageItemRespVO extends PayRefundBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "支付订单编号", required = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "商户名称")
|
||||
private String merchantName;
|
||||
|
||||
@ApiModelProperty(value = "应用名称")
|
||||
private String appName;
|
||||
|
||||
@ApiModelProperty(value = "渠道名称")
|
||||
private String channelCodeName;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
@@ -1,116 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("退款订单分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayRefundPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "商户编号")
|
||||
private Long merchantId;
|
||||
|
||||
@ApiModelProperty(value = "应用编号")
|
||||
private Long appId;
|
||||
|
||||
@ApiModelProperty(value = "渠道编号")
|
||||
private Long channelId;
|
||||
|
||||
@ApiModelProperty(value = "渠道编码")
|
||||
private String channelCode;
|
||||
|
||||
@ApiModelProperty(value = "支付订单编号 pay_order 表id")
|
||||
private Long orderId;
|
||||
|
||||
@ApiModelProperty(value = "交易订单号 pay_extension 表no 字段")
|
||||
private String tradeNo;
|
||||
|
||||
@ApiModelProperty(value = "商户订单编号(商户系统生成)")
|
||||
private String merchantOrderId;
|
||||
|
||||
@ApiModelProperty(value = "商户退款订单号(商户系统生成)")
|
||||
private String merchantRefundNo;
|
||||
|
||||
@ApiModelProperty(value = "异步通知商户地址")
|
||||
private String notifyUrl;
|
||||
|
||||
@ApiModelProperty(value = "通知商户退款结果的回调状态")
|
||||
private Integer notifyStatus;
|
||||
|
||||
@ApiModelProperty(value = "退款状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "退款类型(部分退款,全部退款)")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "支付金额,单位分")
|
||||
private Long payAmount;
|
||||
|
||||
@ApiModelProperty(value = "退款金额,单位分")
|
||||
private Long refundAmount;
|
||||
|
||||
@ApiModelProperty(value = "退款原因")
|
||||
private String reason;
|
||||
|
||||
@ApiModelProperty(value = "用户 IP")
|
||||
private String userIp;
|
||||
|
||||
@ApiModelProperty(value = "渠道订单号,pay_order 中的channel_order_no 对应")
|
||||
private String channelOrderNo;
|
||||
|
||||
@ApiModelProperty(value = "渠道退款单号,渠道返回")
|
||||
private String channelRefundNo;
|
||||
|
||||
@ApiModelProperty(value = "渠道调用报错时,错误码")
|
||||
private String channelErrorCode;
|
||||
|
||||
@ApiModelProperty(value = "渠道调用报错时,错误信息")
|
||||
private String channelErrorMsg;
|
||||
|
||||
@ApiModelProperty(value = "支付渠道的额外参数")
|
||||
private String channelExtras;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始退款失效时间")
|
||||
private Date beginExpireTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束退款失效时间")
|
||||
private Date endExpireTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始退款成功时间")
|
||||
private Date beginSuccessTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束退款成功时间")
|
||||
private Date endSuccessTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始退款通知时间")
|
||||
private Date beginNotifyTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束退款通知时间")
|
||||
private Date endNotifyTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始创建时间")
|
||||
private Date beginCreateTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束创建时间")
|
||||
private Date endCreateTime;
|
||||
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("退款订单 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayRefundRespVO extends PayRefundBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "支付退款编号", required = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@ApiModel("退款订单更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PayRefundUpdateReqVO extends PayRefundBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "支付退款编号", required = true)
|
||||
@NotNull(message = "支付退款编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.convert.app;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.*;
|
||||
|
||||
/**
|
||||
* 支付应用信息 Convert
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Mapper
|
||||
public interface PayAppConvert {
|
||||
|
||||
PayAppConvert INSTANCE = Mappers.getMapper(PayAppConvert.class);
|
||||
|
||||
PayAppPageItemRespVO pageConvert (PayAppDO bean);
|
||||
|
||||
PayAppPageItemRespVO.PayMerchant convert(PayMerchantDO bean);
|
||||
|
||||
PayAppDO convert(PayAppCreateReqVO bean);
|
||||
|
||||
PayAppDO convert(PayAppUpdateReqVO bean);
|
||||
|
||||
PayAppRespVO convert(PayAppDO bean);
|
||||
|
||||
List<PayAppRespVO> convertList(List<PayAppDO> list);
|
||||
|
||||
PageResult<PayAppRespVO> convertPage(PageResult<PayAppDO> page);
|
||||
|
||||
List<PayAppExcelVO> convertList02(List<PayAppDO> list);
|
||||
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.convert.channel;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.*;
|
||||
|
||||
/**
|
||||
* 支付渠道
|
||||
Convert
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Mapper
|
||||
public interface PayChannelConvert {
|
||||
|
||||
PayChannelConvert INSTANCE = Mappers.getMapper(PayChannelConvert.class);
|
||||
|
||||
@Mapping(target = "config",ignore = true)
|
||||
PayChannelDO convert(PayChannelCreateReqVO bean);
|
||||
|
||||
@Mapping(target = "config",ignore = true)
|
||||
PayChannelDO convert(PayChannelUpdateReqVO bean);
|
||||
|
||||
@Mapping(target = "config",expression = "java(cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString(bean.getConfig()))")
|
||||
PayChannelRespVO convert(PayChannelDO bean);
|
||||
|
||||
List<PayChannelRespVO> convertList(List<PayChannelDO> list);
|
||||
|
||||
PageResult<PayChannelRespVO> convertPage(PageResult<PayChannelDO> page);
|
||||
|
||||
List<PayChannelExcelVO> convertList02(List<PayChannelDO> list);
|
||||
|
||||
|
||||
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.convert.merchant;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.*;
|
||||
|
||||
/**
|
||||
* 支付商户信息 Convert
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Mapper
|
||||
public interface PayMerchantConvert {
|
||||
|
||||
PayMerchantConvert INSTANCE = Mappers.getMapper(PayMerchantConvert.class);
|
||||
|
||||
PayMerchantDO convert(PayMerchantCreateReqVO bean);
|
||||
|
||||
PayMerchantDO convert(PayMerchantUpdateReqVO bean);
|
||||
|
||||
PayMerchantRespVO convert(PayMerchantDO bean);
|
||||
|
||||
List<PayMerchantRespVO> convertList(List<PayMerchantDO> list);
|
||||
|
||||
PageResult<PayMerchantRespVO> convertPage(PageResult<PayMerchantDO> page);
|
||||
|
||||
List<PayMerchantExcelVO> convertList02(List<PayMerchantDO> list);
|
||||
|
||||
}
|
@@ -1,104 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.convert.order;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order.PayOrderDetailsRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order.PayOrderExcelVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order.PayOrderPageItemRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order.PayOrderRespVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderExtensionDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付订单 Convert
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Mapper
|
||||
public interface PayOrderConvert {
|
||||
|
||||
PayOrderConvert INSTANCE = Mappers.getMapper(PayOrderConvert.class);
|
||||
|
||||
|
||||
|
||||
PayOrderRespVO convert(PayOrderDO bean);
|
||||
|
||||
/**
|
||||
* 订单DO 转换为 详细订单 RespVO
|
||||
*
|
||||
* @param bean 订单DO
|
||||
* @return 详细订单 RespVO
|
||||
*/
|
||||
PayOrderDetailsRespVO orderDetailConvert(PayOrderDO bean);
|
||||
|
||||
/**
|
||||
* 订单扩展DO 转换为 详细订单扩展 RespVO
|
||||
*
|
||||
* @param bean 订单扩展DO
|
||||
* @return 详细订单扩展 RespVO
|
||||
*/
|
||||
PayOrderDetailsRespVO.PayOrderExtension orderDetailExtensionConvert(PayOrderExtensionDO bean);
|
||||
|
||||
List<PayOrderRespVO> convertList(List<PayOrderDO> list);
|
||||
|
||||
PageResult<PayOrderRespVO> convertPage(PageResult<PayOrderDO> page);
|
||||
|
||||
List<PayOrderExcelVO> convertList02(List<PayOrderDO> list);
|
||||
|
||||
/**
|
||||
* 订单DO转自定义分页对象
|
||||
*
|
||||
* @param bean 订单DO
|
||||
* @return 分页对象
|
||||
*/
|
||||
PayOrderPageItemRespVO pageConvertItemPage(PayOrderDO bean);
|
||||
|
||||
/**
|
||||
* 订单DO 转 订单导出excel VO
|
||||
*
|
||||
* @param bean 订单 DO
|
||||
* @return 订单导出excel VO
|
||||
*/
|
||||
default PayOrderExcelVO excelConvert(PayOrderDO bean) {
|
||||
if (bean == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PayOrderExcelVO payOrderExcelVO = new PayOrderExcelVO();
|
||||
|
||||
payOrderExcelVO.setId(bean.getId());
|
||||
payOrderExcelVO.setSubject(bean.getSubject());
|
||||
payOrderExcelVO.setMerchantOrderId(bean.getMerchantOrderId());
|
||||
payOrderExcelVO.setChannelOrderNo(bean.getChannelOrderNo());
|
||||
payOrderExcelVO.setStatus(bean.getStatus());
|
||||
payOrderExcelVO.setNotifyStatus(bean.getNotifyStatus());
|
||||
payOrderExcelVO.setNotifyUrl(bean.getNotifyUrl());
|
||||
payOrderExcelVO.setCreateTime(bean.getCreateTime());
|
||||
payOrderExcelVO.setSuccessTime(bean.getSuccessTime());
|
||||
payOrderExcelVO.setExpireTime(bean.getExpireTime());
|
||||
payOrderExcelVO.setNotifyTime(bean.getNotifyTime());
|
||||
payOrderExcelVO.setUserIp(bean.getUserIp());
|
||||
payOrderExcelVO.setRefundStatus(bean.getRefundStatus());
|
||||
payOrderExcelVO.setRefundTimes(bean.getRefundTimes());
|
||||
payOrderExcelVO.setBody(bean.getBody());
|
||||
|
||||
BigDecimal multiple = new BigDecimal(100);
|
||||
|
||||
payOrderExcelVO.setAmount(BigDecimal.valueOf(bean.getAmount())
|
||||
.divide(multiple, 2, RoundingMode.HALF_UP).toString());
|
||||
|
||||
payOrderExcelVO.setChannelFeeAmount(BigDecimal.valueOf(bean.getChannelFeeAmount())
|
||||
.divide(multiple, 2, RoundingMode.HALF_UP).toString());
|
||||
payOrderExcelVO.setChannelFeeRate(java.math.BigDecimal.valueOf(bean.getChannelFeeRate())
|
||||
.multiply(multiple).toString());
|
||||
payOrderExcelVO.setRefundAmount(BigDecimal.valueOf(bean.getRefundAmount())
|
||||
.divide(multiple, 2, RoundingMode.HALF_UP).toString());
|
||||
|
||||
return payOrderExcelVO;
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
/**
|
||||
* 提供 POJO 类的实体转换
|
||||
*
|
||||
* 目前使用 MapStruct 框架
|
||||
*/
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.convert;
|
@@ -1,90 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.convert.refund;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo.*;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayRefundDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 退款订单 Convert
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Mapper
|
||||
public interface PayRefundConvert {
|
||||
|
||||
PayRefundConvert INSTANCE = Mappers.getMapper(PayRefundConvert.class);
|
||||
|
||||
PayRefundDO convert(PayRefundCreateReqVO bean);
|
||||
|
||||
PayRefundDO convert(PayRefundUpdateReqVO bean);
|
||||
|
||||
PayRefundRespVO convert(PayRefundDO bean);
|
||||
|
||||
/**
|
||||
* 退款订单 DO 转 退款详情订单 VO
|
||||
*
|
||||
* @param bean 退款订单 DO
|
||||
* @return 退款详情订单 VO
|
||||
*/
|
||||
PayRefundDetailsRespVO refundDetailConvert(PayRefundDO bean);
|
||||
|
||||
/**
|
||||
* 退款订单DO 转 分页退款条目VO
|
||||
*
|
||||
* @param bean 退款订单DO
|
||||
* @return 分页退款条目VO
|
||||
*/
|
||||
PayRefundPageItemRespVO pageItemConvert(PayRefundDO bean);
|
||||
|
||||
List<PayRefundRespVO> convertList(List<PayRefundDO> list);
|
||||
|
||||
PageResult<PayRefundRespVO> convertPage(PageResult<PayRefundDO> page);
|
||||
|
||||
List<PayRefundExcelVO> convertList02(List<PayRefundDO> list);
|
||||
|
||||
/**
|
||||
* 退款订单DO 转 导出excel VO
|
||||
*
|
||||
* @param bean 退款订单DO
|
||||
* @return 导出 excel VO
|
||||
*/
|
||||
default PayRefundExcelVO excelConvert(PayRefundDO bean) {
|
||||
if (bean == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PayRefundExcelVO payRefundExcelVO = new PayRefundExcelVO();
|
||||
|
||||
payRefundExcelVO.setId(bean.getId());
|
||||
payRefundExcelVO.setTradeNo(bean.getTradeNo());
|
||||
payRefundExcelVO.setMerchantOrderId(bean.getMerchantOrderId());
|
||||
payRefundExcelVO.setMerchantRefundNo(bean.getMerchantRefundNo());
|
||||
payRefundExcelVO.setNotifyUrl(bean.getNotifyUrl());
|
||||
payRefundExcelVO.setNotifyStatus(bean.getNotifyStatus());
|
||||
payRefundExcelVO.setStatus(bean.getStatus());
|
||||
payRefundExcelVO.setType(bean.getType());
|
||||
payRefundExcelVO.setReason(bean.getReason());
|
||||
payRefundExcelVO.setUserIp(bean.getUserIp());
|
||||
payRefundExcelVO.setChannelOrderNo(bean.getChannelOrderNo());
|
||||
payRefundExcelVO.setChannelRefundNo(bean.getChannelRefundNo());
|
||||
payRefundExcelVO.setExpireTime(bean.getExpireTime());
|
||||
payRefundExcelVO.setSuccessTime(bean.getSuccessTime());
|
||||
payRefundExcelVO.setNotifyTime(bean.getNotifyTime());
|
||||
payRefundExcelVO.setCreateTime(bean.getCreateTime());
|
||||
|
||||
BigDecimal multiple = new BigDecimal(100);
|
||||
payRefundExcelVO.setPayAmount(BigDecimal.valueOf(bean.getPayAmount())
|
||||
.divide(multiple, 2, RoundingMode.HALF_UP).toString());
|
||||
payRefundExcelVO.setRefundAmount(BigDecimal.valueOf(bean.getRefundAmount())
|
||||
.divide(multiple, 2, RoundingMode.HALF_UP).toString());
|
||||
|
||||
return payRefundExcelVO;
|
||||
}
|
||||
|
||||
}
|
@@ -1 +0,0 @@
|
||||
<http://www.iocoder.cn/Spring-Boot/MapStruct/?yudao>
|
@@ -1,83 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.app;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppPageReqVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO;
|
||||
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.QueryWrapperX;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付应用信息 Mapper
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Mapper
|
||||
public interface PayAppMapper extends BaseMapperX<PayAppDO> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param reqVO 支付应用信息分页查询条件
|
||||
* @param merchantIds 商户 ID 集合
|
||||
* @return 支付应用信息
|
||||
*/
|
||||
default PageResult<PayAppDO> selectPage(PayAppPageReqVO reqVO, Collection<Long> merchantIds) {
|
||||
return selectPage(reqVO, new QueryWrapperX<PayAppDO>()
|
||||
.likeIfPresent("name", reqVO.getName())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.eqIfPresent("remark", reqVO.getRemark())
|
||||
.eqIfPresent("pay_notify_url", reqVO.getPayNotifyUrl())
|
||||
.eqIfPresent("refund_notify_url", reqVO.getRefundNotifyUrl())
|
||||
.inIfPresent("merchant_id", merchantIds)
|
||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc("id"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param reqVO 支付应用信息 Excel 导出查询条件
|
||||
* @param merchantIds 商户 ID 集合
|
||||
* @return 支付应用信息
|
||||
*/
|
||||
default List<PayAppDO> selectList(PayAppExportReqVO reqVO, Collection<Long> merchantIds) {
|
||||
return selectList(new QueryWrapperX<PayAppDO>()
|
||||
.likeIfPresent("name", reqVO.getName())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.eqIfPresent("remark", reqVO.getRemark())
|
||||
.eqIfPresent("pay_notify_url", reqVO.getPayNotifyUrl())
|
||||
.eqIfPresent("refund_notify_url", reqVO.getRefundNotifyUrl())
|
||||
.inIfPresent("merchant_id", merchantIds)
|
||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc("id"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 商户 ID 查询支付应用信息
|
||||
*
|
||||
* @param merchantId 商户 ID
|
||||
* @return 支付应用信息列表
|
||||
*/
|
||||
default List<PayAppDO> getListByMerchantId(String merchantId) {
|
||||
return selectList(new LambdaQueryWrapper<PayAppDO>()
|
||||
.select(PayAppDO::getId, PayAppDO::getName)
|
||||
.eq(PayAppDO::getMerchantId, merchantId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商户号统计存在的支付应用数量
|
||||
*
|
||||
* @param merchantId 商户 ID
|
||||
* @return 支付应用数量
|
||||
*/
|
||||
default Long selectCount(Long merchantId) {
|
||||
return selectCount(new LambdaQueryWrapper<PayAppDO>().eq(PayAppDO::getMerchantId, merchantId));
|
||||
}
|
||||
|
||||
}
|
@@ -1,91 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.channel;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelPageReqVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO;
|
||||
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.QueryWrapperX;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付渠道
|
||||
Mapper
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Mapper
|
||||
public interface PayChannelMapper extends BaseMapperX<PayChannelDO> {
|
||||
|
||||
default PageResult<PayChannelDO> selectPage(PayChannelPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<PayChannelDO>()
|
||||
.eqIfPresent("code", reqVO.getCode())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.eqIfPresent("remark", reqVO.getRemark())
|
||||
.eqIfPresent("fee_rate", reqVO.getFeeRate())
|
||||
.eqIfPresent("merchant_id", reqVO.getMerchantId())
|
||||
.eqIfPresent("app_id", reqVO.getAppId())
|
||||
// .eqIfPresent("config", reqVO.getConfig())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc("id") );
|
||||
}
|
||||
|
||||
default List<PayChannelDO> selectList(PayChannelExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<PayChannelDO>()
|
||||
.eqIfPresent("code", reqVO.getCode())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.eqIfPresent("remark", reqVO.getRemark())
|
||||
.eqIfPresent("fee_rate", reqVO.getFeeRate())
|
||||
.eqIfPresent("merchant_id", reqVO.getMerchantId())
|
||||
.eqIfPresent("app_id", reqVO.getAppId())
|
||||
// .eqIfPresent("config", reqVO.getConfig())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件获取通道
|
||||
*
|
||||
* @param merchantId 商户编号
|
||||
* @param appid 应用编号
|
||||
* @param code 通道编码
|
||||
* @return 数量
|
||||
*/
|
||||
default PayChannelDO selectOne(Long merchantId, Long appid, String code) {
|
||||
return this.selectOne((new QueryWrapper<PayChannelDO>().lambda()
|
||||
.eq(PayChannelDO::getMerchantId, merchantId)
|
||||
.eq(PayChannelDO::getAppId, appid)
|
||||
.eq(PayChannelDO::getCode, code)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据支付应用ID集合获得支付渠道列表
|
||||
*
|
||||
* @param appIds 应用编号集合
|
||||
* @return 支付渠道列表
|
||||
*/
|
||||
default List<PayChannelDO> getChannelListByAppIds(Collection<Long> appIds){
|
||||
return this.selectList(new QueryWrapper<PayChannelDO>().lambda()
|
||||
.in(PayChannelDO::getAppId, appIds));
|
||||
}
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.merchant;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantPageReqVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO;
|
||||
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.QueryWrapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付商户信息 Mapper
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Mapper
|
||||
public interface PayMerchantMapper extends BaseMapperX<PayMerchantDO> {
|
||||
|
||||
default PageResult<PayMerchantDO> selectPage(PayMerchantPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<PayMerchantDO>()
|
||||
.likeIfPresent("no", reqVO.getNo())
|
||||
.likeIfPresent("name", reqVO.getName())
|
||||
.likeIfPresent("short_name", reqVO.getShortName())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.eqIfPresent("remark", reqVO.getRemark())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc("id"));
|
||||
}
|
||||
|
||||
default List<PayMerchantDO> selectList(PayMerchantExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<PayMerchantDO>()
|
||||
.likeIfPresent("no", reqVO.getNo())
|
||||
.likeIfPresent("name", reqVO.getName())
|
||||
.likeIfPresent("short_name", reqVO.getShortName())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.eqIfPresent("remark", reqVO.getRemark())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc("id"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商户名称模糊查询商户集合
|
||||
*
|
||||
* @param merchantName 商户名称
|
||||
* @return 商户集合
|
||||
*/
|
||||
default List<PayMerchantDO> getMerchantListByName(String merchantName) {
|
||||
return this.selectList(new QueryWrapperX<PayMerchantDO>()
|
||||
.likeIfPresent("name", merchantName));
|
||||
}
|
||||
}
|
@@ -1,16 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.order;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderExtensionDO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 支付订单 Mapper
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Mapper
|
||||
public interface PayOrderExtensionMapper extends BaseMapperX<PayOrderExtensionDO> {
|
||||
|
||||
|
||||
}
|
@@ -1,79 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.order;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order.PayOrderExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order.PayOrderPageReqVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderDO;
|
||||
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.QueryWrapperX;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付订单 Mapper 组件
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Mapper
|
||||
public interface PayOrderMapper extends BaseMapperX<PayOrderDO> {
|
||||
|
||||
default PageResult<PayOrderDO> selectPage(PayOrderPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<PayOrderDO>()
|
||||
.eqIfPresent("merchant_id", reqVO.getMerchantId())
|
||||
.eqIfPresent("app_id", reqVO.getAppId())
|
||||
.eqIfPresent("channel_id", reqVO.getChannelId())
|
||||
.eqIfPresent("channel_code", reqVO.getChannelCode())
|
||||
.likeIfPresent("merchant_order_id", reqVO.getMerchantOrderId())
|
||||
.eqIfPresent("notify_status", reqVO.getNotifyStatus())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.eqIfPresent("refund_status", reqVO.getRefundStatus())
|
||||
.likeIfPresent("channel_order_no", reqVO.getChannelOrderNo())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc("id"));
|
||||
}
|
||||
|
||||
default List<PayOrderDO> selectList(PayOrderExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<PayOrderDO>()
|
||||
.eqIfPresent("merchant_id", reqVO.getMerchantId())
|
||||
.eqIfPresent("app_id", reqVO.getAppId())
|
||||
.eqIfPresent("channel_id", reqVO.getChannelId())
|
||||
.eqIfPresent("channel_code", reqVO.getChannelCode())
|
||||
.likeIfPresent("merchant_order_id", reqVO.getMerchantOrderId())
|
||||
.eqIfPresent("notify_status", reqVO.getNotifyStatus())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.eqIfPresent("refund_status", reqVO.getRefundStatus())
|
||||
.likeIfPresent("channel_order_no", reqVO.getChannelOrderNo())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc("id"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单 ID 集合查询订单商品名称
|
||||
*
|
||||
* @param idList 订单 ID 集合
|
||||
* @return 只包含商品名称和标题的订单集合对象
|
||||
*/
|
||||
default List<PayOrderDO> findByIdListQueryOrderSubject(Collection<Long> idList) {
|
||||
return selectList(new LambdaQueryWrapper<PayOrderDO>()
|
||||
.select(PayOrderDO::getId, PayOrderDO::getSubject)
|
||||
.in(PayOrderDO::getId, idList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合的订单数量
|
||||
*
|
||||
* @param appId 应用编号
|
||||
* @param status 订单状态
|
||||
* @return 条数
|
||||
*/
|
||||
default Long selectCount(Long appId, Integer status) {
|
||||
|
||||
return selectCount(new LambdaQueryWrapper<PayOrderDO>()
|
||||
.eq(PayOrderDO::getAppId, appId)
|
||||
.in(PayOrderDO::getStatus, status));
|
||||
}
|
||||
|
||||
}
|
@@ -1,61 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.order;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo.PayRefundExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo.PayRefundPageReqVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayRefundDO;
|
||||
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.QueryWrapperX;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 退款订单 Mapper
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Mapper
|
||||
public interface PayRefundMapper extends BaseMapperX<PayRefundDO> {
|
||||
|
||||
default PageResult<PayRefundDO> selectPage(PayRefundPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<PayRefundDO>()
|
||||
.eqIfPresent("merchant_id", reqVO.getMerchantId())
|
||||
.eqIfPresent("app_id", reqVO.getAppId())
|
||||
.eqIfPresent("channel_code", reqVO.getChannelCode())
|
||||
.likeIfPresent("merchant_refund_no", reqVO.getMerchantRefundNo())
|
||||
.eqIfPresent("type", reqVO.getType())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.eqIfPresent("notify_status", reqVO.getNotifyStatus())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc("id"));
|
||||
}
|
||||
|
||||
default List<PayRefundDO> selectList(PayRefundExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<PayRefundDO>()
|
||||
.eqIfPresent("merchant_id", reqVO.getMerchantId())
|
||||
.eqIfPresent("app_id", reqVO.getAppId())
|
||||
.eqIfPresent("channel_code", reqVO.getChannelCode())
|
||||
.likeIfPresent("merchant_refund_no", reqVO.getMerchantRefundNo())
|
||||
.eqIfPresent("type", reqVO.getType())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.eqIfPresent("notify_status", reqVO.getNotifyStatus())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc("id"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合的订单数量
|
||||
*
|
||||
* @param appId 应用编号
|
||||
* @param status 订单状态
|
||||
* @return 条数
|
||||
*/
|
||||
default Long selectCount(Long appId, Integer status) {
|
||||
|
||||
return selectCount(new LambdaQueryWrapper<PayRefundDO>()
|
||||
.eq(PayRefundDO::getAppId, appId)
|
||||
.eq(PayRefundDO::getStatus, status));
|
||||
}
|
||||
}
|
@@ -1 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.enums;
|
@@ -1,29 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.job.notify;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.service.notify.PayNotifyCoreService;
|
||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 支付通知 Job
|
||||
* 通过不断扫描待通知的 PayNotifyTaskDO 记录,回调业务线的回调接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class PayNotifyJob implements JobHandler {
|
||||
|
||||
@Resource
|
||||
private PayNotifyCoreService payNotifyCoreService;
|
||||
|
||||
@Override
|
||||
public String execute(String param) throws Exception {
|
||||
int notifyCount = payNotifyCoreService.executeNotify();
|
||||
return String.format("执行支付通知 %s 个", notifyCount);
|
||||
}
|
||||
|
||||
}
|
@@ -1 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.job;
|
@@ -1,7 +0,0 @@
|
||||
/**
|
||||
* pay 包下,我们放支付业务,提供业务的支付能力。
|
||||
* 例如说:商户、应用、支付、退款等等
|
||||
*
|
||||
* 缩写:pay
|
||||
*/
|
||||
package cn.iocoder.yudao.adminserver.modules.pay;
|
@@ -1,103 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.app;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppCreateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppUpdateReqVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付应用信息 Service 接口
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
public interface PayAppService {
|
||||
|
||||
/**
|
||||
* 创建支付应用信息
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createApp(@Valid PayAppCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新支付应用信息
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateApp(@Valid PayAppUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除支付应用信息
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteApp(Long id);
|
||||
|
||||
/**
|
||||
* 获得支付应用信息
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 支付应用信息
|
||||
*/
|
||||
PayAppDO getApp(Long id);
|
||||
|
||||
/**
|
||||
* 获得支付应用信息列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 支付应用信息列表
|
||||
*/
|
||||
List<PayAppDO> getAppList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得支付应用信息分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 支付应用信息分页
|
||||
*/
|
||||
PageResult<PayAppDO> getAppPage(PayAppPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得支付应用信息列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 支付应用信息列表
|
||||
*/
|
||||
List<PayAppDO> getAppList(PayAppExportReqVO exportReqVO);
|
||||
|
||||
/**
|
||||
* 修改应用信息状态
|
||||
*
|
||||
* @param id 应用编号
|
||||
* @param status 状态{@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum}
|
||||
*/
|
||||
void updateAppStatus(Long id, Integer status);
|
||||
|
||||
/**
|
||||
* 根据商户 ID 获得支付应用信息列表,
|
||||
*
|
||||
* @param merchantId 商户 ID
|
||||
* @return 支付应用信息列表
|
||||
*/
|
||||
List<PayAppDO> getListByMerchantId(String merchantId);
|
||||
|
||||
/**
|
||||
* 获得指定编号的商户 Map
|
||||
*
|
||||
* @param appIdList 应用编号集合
|
||||
* @return 商户 Map
|
||||
*/
|
||||
default Map<Long, PayAppDO> getAppMap(Collection<Long> appIdList) {
|
||||
List<PayAppDO> list = this.getAppList(appIdList);
|
||||
return CollectionUtils.convertMap(list, PayAppDO::getId);
|
||||
}
|
||||
}
|
@@ -1,189 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.app.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppCreateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppUpdateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.convert.app.PayAppConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.app.PayAppMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.merchant.PayMerchantMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.order.PayOrderMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.order.PayRefundMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.app.PayAppService;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayOrderStatusEnum;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayRefundStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.*;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
|
||||
/**
|
||||
* 支付应用信息 Service 实现类
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class PayAppServiceImpl implements PayAppService {
|
||||
|
||||
@Resource
|
||||
private PayAppMapper appMapper;
|
||||
|
||||
@Resource
|
||||
private PayMerchantMapper merchantMapper;
|
||||
|
||||
@Resource
|
||||
private PayOrderMapper orderMapper;
|
||||
|
||||
@Resource
|
||||
private PayRefundMapper refundMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public Long createApp(PayAppCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
PayAppDO app = PayAppConvert.INSTANCE.convert(createReqVO);
|
||||
appMapper.insert(app);
|
||||
// 返回
|
||||
return app.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateApp(PayAppUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validateAppExists(updateReqVO.getId());
|
||||
// 更新
|
||||
PayAppDO updateObj = PayAppConvert.INSTANCE.convert(updateReqVO);
|
||||
appMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteApp(Long id) {
|
||||
// 校验存在
|
||||
this.validateAppExists(id);
|
||||
this.validateOrderTransactionExist(id);
|
||||
|
||||
// 删除
|
||||
appMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateAppExists(Long id) {
|
||||
if (appMapper.selectById(id) == null) {
|
||||
throw exception(PAY_APP_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PayAppDO getApp(Long id) {
|
||||
return appMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayAppDO> getAppList(Collection<Long> ids) {
|
||||
return appMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<PayAppDO> getAppPage(PayAppPageReqVO pageReqVO) {
|
||||
Set<Long> merchantIdList = this.getMerchantCondition(pageReqVO.getMerchantName());
|
||||
if (StrUtil.isNotBlank(pageReqVO.getMerchantName()) && CollectionUtil.isEmpty(merchantIdList)) {
|
||||
return new PageResult<>();
|
||||
}
|
||||
return appMapper.selectPage(pageReqVO, merchantIdList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayAppDO> getAppList(PayAppExportReqVO exportReqVO) {
|
||||
Set<Long> merchantIdList = this.getMerchantCondition(exportReqVO.getMerchantName());
|
||||
if (StrUtil.isNotBlank(exportReqVO.getMerchantName()) && CollectionUtil.isEmpty(merchantIdList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return appMapper.selectList(exportReqVO, merchantIdList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商户编号集合,根据商户名称模糊查询得到所有的商户编号集合
|
||||
*
|
||||
* @param merchantName 商户名称
|
||||
* @return 商户编号集合
|
||||
*/
|
||||
private Set<Long> getMerchantCondition(String merchantName) {
|
||||
if (StrUtil.isBlank(merchantName)) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return convertSet(merchantMapper.getMerchantListByName(merchantName), PayMerchantDO::getId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改应用信息状态
|
||||
*
|
||||
* @param id 应用编号
|
||||
* @param status 状态{@link CommonStatusEnum}
|
||||
*/
|
||||
@Override
|
||||
public void updateAppStatus(Long id, Integer status) {
|
||||
// 校验商户存在
|
||||
this.checkAppExists(id);
|
||||
// 更新状态
|
||||
PayAppDO app = new PayAppDO();
|
||||
app.setId(id);
|
||||
app.setStatus(status);
|
||||
appMapper.updateById(app);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商户 ID 获得支付应用信息列表,
|
||||
*
|
||||
* @param merchantId 商户 ID
|
||||
* @return 支付应用信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<PayAppDO> getListByMerchantId(String merchantId) {
|
||||
return appMapper.getListByMerchantId(merchantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查商户是否存在
|
||||
*
|
||||
* @param id 商户编号
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public void checkAppExists(Long id) {
|
||||
if (id == null) {
|
||||
return;
|
||||
}
|
||||
PayAppDO payApp = appMapper.selectById(id);
|
||||
if (payApp == null) {
|
||||
throw exception(PAY_APP_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证是否存在交易中或者退款中等处理中状态的订单
|
||||
*
|
||||
* @param appId 应用 ID
|
||||
*/
|
||||
private void validateOrderTransactionExist(Long appId) {
|
||||
// 查看交易订单
|
||||
if (orderMapper.selectCount(appId, PayOrderStatusEnum.WAITING.getStatus()) > 0) {
|
||||
throw exception(PAY_APP_EXIST_TRANSACTION_ORDER_CANT_DELETE);
|
||||
}
|
||||
// 查看退款订单
|
||||
if (refundMapper.selectCount(appId, PayRefundStatusEnum.CREATE.getStatus()) > 0) {
|
||||
throw exception(PAY_APP_EXIST_TRANSACTION_ORDER_CANT_DELETE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,107 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.channel;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.*;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付渠道 Service 接口
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
public interface PayChannelService {
|
||||
|
||||
/**
|
||||
* 创建支付渠道
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createChannel(@Valid PayChannelCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新支付渠道
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateChannel(@Valid PayChannelUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除支付渠道
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteChannel(Long id);
|
||||
|
||||
/**
|
||||
* 获得支付渠道
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 支付渠道
|
||||
*/
|
||||
PayChannelDO getChannel(Long id);
|
||||
|
||||
/**
|
||||
* 获得支付渠道
|
||||
* 列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 支付渠道
|
||||
* 列表
|
||||
*/
|
||||
List<PayChannelDO> getChannelList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得支付渠道
|
||||
* 分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 支付渠道
|
||||
* 分页
|
||||
*/
|
||||
PageResult<PayChannelDO> getChannelPage(PayChannelPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得支付渠道
|
||||
* 列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 支付渠道列表
|
||||
*/
|
||||
List<PayChannelDO> getChannelList(PayChannelExportReqVO exportReqVO);
|
||||
|
||||
/**
|
||||
* 根据支付应用ID集合获得支付渠道列表
|
||||
*
|
||||
* @param appIds 应用编号集合
|
||||
* @return 支付渠道列表
|
||||
*/
|
||||
List<PayChannelDO> getChannelListByAppIds(Collection<Long> appIds);
|
||||
|
||||
/**
|
||||
* 根据条件获取通道数量
|
||||
*
|
||||
* @param merchantId 商户编号
|
||||
* @param appid 应用编号
|
||||
* @param code 通道编码
|
||||
* @return 数量
|
||||
*/
|
||||
Integer getChannelCountByConditions(Long merchantId, Long appid, String code);
|
||||
|
||||
/**
|
||||
* 根据条件获取通道
|
||||
*
|
||||
* @param merchantId 商户编号
|
||||
* @param appid 应用编号
|
||||
* @param code 通道编码
|
||||
* @return 数量
|
||||
*/
|
||||
PayChannelDO getChannelByConditions(Long merchantId, Long appid, String code);
|
||||
|
||||
|
||||
}
|
@@ -1,161 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.channel.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelCreateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelUpdateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.convert.channel.PayChannelConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.channel.PayChannelMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.channel.PayChannelService;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig;
|
||||
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Validator;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.CHANNEL_EXIST_SAME_CHANNEL_ERROR;
|
||||
import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.CHANNEL_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 支付渠道 Service 实现类
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Validated
|
||||
public class PayChannelServiceImpl implements PayChannelService {
|
||||
|
||||
@Resource
|
||||
private PayChannelMapper channelMapper;
|
||||
|
||||
@Resource
|
||||
private Validator validator;
|
||||
|
||||
@Override
|
||||
public Long createChannel(PayChannelCreateReqVO reqVO) {
|
||||
// 断言是否有重复的
|
||||
PayChannelDO channelDO = this.getChannelByConditions(reqVO.getMerchantId(), reqVO.getAppId(), reqVO.getCode());
|
||||
if (ObjectUtil.isNotNull(channelDO)) {
|
||||
throw exception(CHANNEL_EXIST_SAME_CHANNEL_ERROR);
|
||||
}
|
||||
|
||||
// 新增渠道
|
||||
PayChannelDO channel = PayChannelConvert.INSTANCE.convert(reqVO);
|
||||
settingConfigAndCheckParam(channel, reqVO.getConfig());
|
||||
channelMapper.insert(channel);
|
||||
return channel.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateChannel(PayChannelUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validateChannelExists(updateReqVO.getId());
|
||||
// 更新
|
||||
PayChannelDO channel = PayChannelConvert.INSTANCE.convert(updateReqVO);
|
||||
settingConfigAndCheckParam(channel, updateReqVO.getConfig());
|
||||
channelMapper.updateById(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteChannel(Long id) {
|
||||
// 校验存在
|
||||
this.validateChannelExists(id);
|
||||
// 删除
|
||||
channelMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateChannelExists(Long id) {
|
||||
if (channelMapper.selectById(id) == null) {
|
||||
throw exception(CHANNEL_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PayChannelDO getChannel(Long id) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayChannelDO> getChannelList(PayChannelExportReqVO exportReqVO) {
|
||||
return channelMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据支付应用ID集合获得支付渠道列表
|
||||
*
|
||||
* @param appIds 应用编号集合
|
||||
* @return 支付渠道列表
|
||||
*/
|
||||
@Override
|
||||
public List<PayChannelDO> getChannelListByAppIds(Collection<Long> appIds) {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件获取通道
|
||||
*
|
||||
* @param merchantId 商户编号
|
||||
* @param appid 应用编号
|
||||
* @param code 通道编码
|
||||
* @return 数量
|
||||
*/
|
||||
@Override
|
||||
public PayChannelDO getChannelByConditions(Long merchantId, Long appid, String code) {
|
||||
return this.channelMapper.selectOne(merchantId, appid, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置渠道配置以及参数校验
|
||||
*
|
||||
* @param channel 渠道
|
||||
* @param configStr 配置
|
||||
*/
|
||||
private void settingConfigAndCheckParam(PayChannelDO channel, String configStr) {
|
||||
// 得到这个渠道是微信的还是支付宝的
|
||||
Class<? extends PayClientConfig> payClass = PayChannelEnum.getByCode(channel.getCode()).getConfigClass();
|
||||
if (ObjectUtil.isNull(payClass)) {
|
||||
throw exception(CHANNEL_NOT_EXISTS);
|
||||
}
|
||||
PayClientConfig config = JSONUtil.toBean(configStr, payClass);
|
||||
|
||||
// 验证参数
|
||||
config.validate(validator);
|
||||
channel.setConfig(config);
|
||||
}
|
||||
|
||||
}
|
@@ -1,104 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.merchant;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantCreateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantUpdateReqVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付商户信息 Service 接口
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
public interface PayMerchantService {
|
||||
|
||||
/**
|
||||
* 创建支付商户信息
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createMerchant(@Valid PayMerchantCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新支付商户信息
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateMerchant(@Valid PayMerchantUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除支付商户信息
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteMerchant(Long id);
|
||||
|
||||
/**
|
||||
* 获得支付商户信息
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 支付商户信息
|
||||
*/
|
||||
PayMerchantDO getMerchant(Long id);
|
||||
|
||||
/**
|
||||
* 获得支付商户信息列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 支付商户信息列表
|
||||
*/
|
||||
List<PayMerchantDO> getMerchantList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得支付商户信息分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 支付商户信息分页
|
||||
*/
|
||||
PageResult<PayMerchantDO> getMerchantPage(PayMerchantPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得支付商户信息列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 支付商户信息列表
|
||||
*/
|
||||
List<PayMerchantDO> getMerchantList(PayMerchantExportReqVO exportReqVO);
|
||||
|
||||
/**
|
||||
* 修改商户状态
|
||||
*
|
||||
* @param id 商户编号
|
||||
* @param status 状态
|
||||
*/
|
||||
void updateMerchantStatus(Long id, Integer status);
|
||||
|
||||
/**
|
||||
* 根据商户名称模糊查询商户集合
|
||||
*
|
||||
* @param merchantName 商户名称
|
||||
* @return 商户集合
|
||||
*/
|
||||
List<PayMerchantDO> getMerchantListByName(String merchantName);
|
||||
|
||||
/**
|
||||
* 获得指定编号的商户 Map
|
||||
*
|
||||
* @param merchantIds 商户编号数组
|
||||
* @return 商户 Map
|
||||
*/
|
||||
default Map<Long, PayMerchantDO> getMerchantMap(Collection<Long> merchantIds) {
|
||||
List<PayMerchantDO> list = this.getMerchantList(merchantIds);
|
||||
return CollectionUtils.convertMap(list, PayMerchantDO::getId);
|
||||
}
|
||||
|
||||
}
|
@@ -1,150 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.merchant.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantCreateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantUpdateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.convert.merchant.PayMerchantConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.app.PayAppMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.merchant.PayMerchantMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.merchant.PayMerchantService;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.PAY_MERCHANT_EXIST_APP_CANT_DELETE;
|
||||
import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.PAY_MERCHANT_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 支付商户信息 Service 实现类
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class PayMerchantServiceImpl implements PayMerchantService {
|
||||
|
||||
@Resource
|
||||
private PayMerchantMapper merchantMapper;
|
||||
|
||||
@Resource
|
||||
private PayAppMapper appMapper;
|
||||
|
||||
@Override
|
||||
public Long createMerchant(PayMerchantCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
PayMerchantDO merchant = PayMerchantConvert.INSTANCE.convert(createReqVO);
|
||||
merchant.setNo(this.generateMerchantNo());
|
||||
merchantMapper.insert(merchant);
|
||||
// 返回
|
||||
return merchant.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMerchant(PayMerchantUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validateMerchantExists(updateReqVO.getId());
|
||||
// 更新
|
||||
PayMerchantDO updateObj = PayMerchantConvert.INSTANCE.convert(updateReqVO);
|
||||
merchantMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMerchant(Long id) {
|
||||
// 校验
|
||||
this.validateMerchantExists(id);
|
||||
this.validateAppExists(id);
|
||||
// 删除
|
||||
merchantMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PayMerchantDO getMerchant(Long id) {
|
||||
return merchantMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayMerchantDO> getMerchantList(Collection<Long> ids) {
|
||||
return merchantMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<PayMerchantDO> getMerchantPage(PayMerchantPageReqVO pageReqVO) {
|
||||
return merchantMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayMerchantDO> getMerchantList(PayMerchantExportReqVO exportReqVO) {
|
||||
return merchantMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMerchantStatus(Long id, Integer status) {
|
||||
// 校验商户存在
|
||||
this.checkMerchantExists(id);
|
||||
// 更新状态
|
||||
PayMerchantDO merchant = new PayMerchantDO();
|
||||
merchant.setId(id);
|
||||
merchant.setStatus(status);
|
||||
merchantMapper.updateById(merchant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayMerchantDO> getMerchantListByName(String merchantName) {
|
||||
return this.merchantMapper.getMerchantListByName(merchantName);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void checkMerchantExists(Long id) {
|
||||
if (id == null) {
|
||||
return;
|
||||
}
|
||||
PayMerchantDO merchant = merchantMapper.selectById(id);
|
||||
if (merchant == null) {
|
||||
throw exception(PAY_MERCHANT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验商户是否存在
|
||||
*
|
||||
* @param id 商户 ID
|
||||
*/
|
||||
private void validateMerchantExists(Long id) {
|
||||
if (ObjectUtil.isNull(merchantMapper.selectById(id))) {
|
||||
throw exception(PAY_MERCHANT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验商户是否还存在支付应用
|
||||
*
|
||||
* @param id 商户ID
|
||||
*/
|
||||
private void validateAppExists(Long id) {
|
||||
if (appMapper.selectCount(id) > 0) {
|
||||
throw exception(PAY_MERCHANT_EXIST_APP_CANT_DELETE);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO @芋艿:后续增加下合适的算法
|
||||
/**
|
||||
* 根据年月日时分秒毫秒生成商户号
|
||||
*
|
||||
* @return 商户号
|
||||
*/
|
||||
private String generateMerchantNo() {
|
||||
return "M" + DateUtil.format(LocalDateTime.now(), "yyyyMMddHHmmssSSS");
|
||||
}
|
||||
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.order;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderExtensionDO;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付订单 Service 接口
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
public interface PayOrderExtensionService {
|
||||
|
||||
/**
|
||||
* 获得支付订单
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 支付订单
|
||||
*/
|
||||
PayOrderExtensionDO getOrderExtension(Long id);
|
||||
|
||||
/**
|
||||
* 获得支付订单
|
||||
* 列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 支付订单
|
||||
* 列表
|
||||
*/
|
||||
List<PayOrderExtensionDO> getOrderExtensionList(Collection<Long> ids);
|
||||
|
||||
|
||||
/**
|
||||
* 根据订单成功的 扩展订单ID 查询所有的扩展订单转 成 map 返回
|
||||
*
|
||||
* @param successExtensionIdList 订单 ID 集合
|
||||
* @return 订单扩展 map 集合
|
||||
*/
|
||||
default Map<Long, PayOrderExtensionDO> getOrderExtensionMap(Collection<Long> successExtensionIdList) {
|
||||
List<PayOrderExtensionDO> list = this.getOrderExtensionList(successExtensionIdList);
|
||||
return CollectionUtils.convertMap(list, PayOrderExtensionDO::getId);
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,67 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.order;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order.PayOrderExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order.PayOrderPageReqVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付订单 Service 接口
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
public interface PayOrderService {
|
||||
|
||||
/**
|
||||
* 获得支付订单
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 支付订单
|
||||
*/
|
||||
PayOrderDO getOrder(Long id);
|
||||
|
||||
/**
|
||||
* 获得支付订单
|
||||
* 分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 支付订单
|
||||
* 分页
|
||||
*/
|
||||
PageResult<PayOrderDO> getOrderPage(PayOrderPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得支付订单
|
||||
* 列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 支付订单
|
||||
* 列表
|
||||
*/
|
||||
List<PayOrderDO> getOrderList(PayOrderExportReqVO exportReqVO);
|
||||
|
||||
/**
|
||||
* 根据 ID 集合获取只包含商品名称的订单集合
|
||||
*
|
||||
* @param idList 订单 ID 集合
|
||||
* @return 只包含商品名称的订单集合
|
||||
*/
|
||||
List<PayOrderDO> getOrderSubjectList(Collection<Long> idList);
|
||||
|
||||
/**
|
||||
* 根据订单 ID 集合获取订单商品名称Map集合
|
||||
*
|
||||
* @param idList 订单 ID 集合
|
||||
* @return 订单商品 map 集合
|
||||
*/
|
||||
default Map<Long, PayOrderDO> getOrderSubjectMap(Collection<Long> idList) {
|
||||
List<PayOrderDO> list = getOrderSubjectList(idList);
|
||||
return CollectionUtils.convertMap(list, PayOrderDO::getId);
|
||||
}
|
||||
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.order;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo.PayRefundExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo.PayRefundPageReqVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayRefundDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 退款订单 Service 接口
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
public interface PayRefundService {
|
||||
|
||||
/**
|
||||
* 获得退款订单
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 退款订单
|
||||
*/
|
||||
PayRefundDO getRefund(Long id);
|
||||
|
||||
/**
|
||||
* 获得退款订单分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 退款订单分页
|
||||
*/
|
||||
PageResult<PayRefundDO> getRefundPage(PayRefundPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得退款订单列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 退款订单列表
|
||||
*/
|
||||
List<PayRefundDO> getRefundList(PayRefundExportReqVO exportReqVO);
|
||||
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.order.impl;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.order.PayOrderExtensionMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.order.PayOrderExtensionService;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderExtensionDO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付订单 Service 实现类
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class PayOrderExtensionServiceImpl implements PayOrderExtensionService {
|
||||
|
||||
@Resource
|
||||
private PayOrderExtensionMapper orderExtensionMapper;
|
||||
|
||||
@Override
|
||||
public PayOrderExtensionDO getOrderExtension(Long id) {
|
||||
return orderExtensionMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayOrderExtensionDO> getOrderExtensionList(Collection<Long> ids) {
|
||||
return orderExtensionMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
}
|
@@ -1,54 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.order.impl;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order.PayOrderExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order.PayOrderPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.order.PayOrderMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.order.PayOrderService;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付订单 Service 实现类
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class PayOrderServiceImpl implements PayOrderService {
|
||||
|
||||
@Resource
|
||||
private PayOrderMapper orderMapper;
|
||||
|
||||
@Override
|
||||
public PayOrderDO getOrder(Long id) {
|
||||
return orderMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<PayOrderDO> getOrderPage(PayOrderPageReqVO pageReqVO) {
|
||||
return orderMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayOrderDO> getOrderList(PayOrderExportReqVO exportReqVO) {
|
||||
return orderMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 ID 集合获取只包含商品名称的订单集合
|
||||
*
|
||||
* @param idList 订单 ID 集合
|
||||
* @return 只包含商品名称的订单集合
|
||||
*/
|
||||
@Override
|
||||
public List<PayOrderDO> getOrderSubjectList(Collection<Long> idList) {
|
||||
return orderMapper.findByIdListQueryOrderSubject(idList);
|
||||
}
|
||||
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.order.impl;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo.PayRefundExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo.PayRefundPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.order.PayRefundMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.order.PayRefundService;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayRefundDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 退款订单 Service 实现类
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class PayRefundServiceImpl implements PayRefundService {
|
||||
|
||||
@Resource
|
||||
private PayRefundMapper refundMapper;
|
||||
|
||||
@Override
|
||||
public PayRefundDO getRefund(Long id) {
|
||||
return refundMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<PayRefundDO> getRefundPage(PayRefundPageReqVO pageReqVO) {
|
||||
return refundMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayRefundDO> getRefundList(PayRefundExportReqVO exportReqVO) {
|
||||
return refundMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.config.RedisTestConfiguration;
|
||||
import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration;
|
||||
import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration;
|
||||
import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration;
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
||||
import org.redisson.spring.starter.RedissonAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
/**
|
||||
* 依赖内存 DB + Redis 的单元测试
|
||||
*
|
||||
* 相比 {@link BaseDbUnitTest} 来说,额外增加了内存 Redis
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbAndRedisUnitTest.Application.class)
|
||||
@ActiveProfiles("unit-test") // 设置使用 application-unit-test 配置文件
|
||||
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) // 每个单元测试结束后,清理 DB
|
||||
public class BaseDbAndRedisUnitTest {
|
||||
|
||||
@Import({
|
||||
// DB 配置类
|
||||
YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类
|
||||
DataSourceAutoConfiguration.class, // Spring DB 自动配置类
|
||||
DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类
|
||||
DruidDataSourceAutoConfigure.class, // Druid 自动配置类
|
||||
// MyBatis 配置类
|
||||
YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类
|
||||
MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类
|
||||
// Redis 配置类
|
||||
RedisTestConfiguration.class, // Redis 测试配置类,用于启动 RedisServer
|
||||
RedisAutoConfiguration.class, // Spring Redis 自动配置类
|
||||
YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类
|
||||
RedissonAutoConfiguration.class, // Redisson 自动高配置类
|
||||
})
|
||||
public static class Application {
|
||||
}
|
||||
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver;
|
||||
|
||||
import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration;
|
||||
import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration;
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
/**
|
||||
* 依赖内存 DB 的单元测试
|
||||
*
|
||||
* 注意,Service 层同样适用。对于 Service 层的单元测试,我们针对自己模块的 Mapper 走的是 H2 内存数据库,针对别的模块的 Service 走的是 Mock 方法
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbUnitTest.Application.class)
|
||||
@ActiveProfiles("unit-test") // 设置使用 application-unit-test 配置文件
|
||||
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) // 每个单元测试结束后,清理 DB
|
||||
public class BaseDbUnitTest {
|
||||
|
||||
@Import({
|
||||
// DB 配置类
|
||||
YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类
|
||||
DataSourceAutoConfiguration.class, // Spring DB 自动配置类
|
||||
DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类
|
||||
DruidDataSourceAutoConfigure.class, // Druid 自动配置类
|
||||
// MyBatis 配置类
|
||||
YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类
|
||||
MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类
|
||||
})
|
||||
public static class Application {
|
||||
}
|
||||
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.config.RedisTestConfiguration;
|
||||
import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration;
|
||||
import cn.iocoder.yudao.framework.tracer.config.YudaoTracerAutoConfiguration;
|
||||
import org.redisson.spring.starter.RedissonAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
/**
|
||||
* 依赖内存 Redis 的单元测试
|
||||
*
|
||||
* 相比 {@link BaseDbUnitTest} 来说,从内存 DB 改成了内存 Redis
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseRedisUnitTest.Application.class)
|
||||
@ActiveProfiles("unit-test") // 设置使用 application-unit-test 配置文件
|
||||
public class BaseRedisUnitTest {
|
||||
|
||||
@Import({
|
||||
// Redis 配置类
|
||||
RedisTestConfiguration.class, // Redis 测试配置类,用于启动 RedisServer
|
||||
RedisAutoConfiguration.class, // Spring Redis 自动配置类
|
||||
YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类
|
||||
RedissonAutoConfiguration.class, // Redisson 自动高配置类
|
||||
})
|
||||
public static class Application {
|
||||
}
|
||||
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.config;
|
||||
|
||||
import com.github.fppt.jedismock.RedisServer;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Lazy(false) // 禁止延迟加载
|
||||
@EnableConfigurationProperties(RedisProperties.class)
|
||||
public class RedisTestConfiguration {
|
||||
|
||||
/**
|
||||
* 创建模拟的 Redis Server 服务器
|
||||
*/
|
||||
@Bean
|
||||
public RedisServer redisServer(RedisProperties properties) throws IOException {
|
||||
RedisServer redisServer = new RedisServer(properties.getPort());
|
||||
// TODO 芋艿:一次执行多个单元测试时,貌似创建多个 spring 容器,导致不进行 stop。这样,就导致端口被占用,无法启动。。。
|
||||
try {
|
||||
redisServer.start();
|
||||
} catch (Exception ignore) {}
|
||||
return redisServer;
|
||||
}
|
||||
|
||||
}
|
@@ -1,245 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.app;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.iocoder.yudao.adminserver.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppCreateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.app.vo.PayAppUpdateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.app.PayAppMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.merchant.PayMerchantMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.app.impl.PayAppServiceImpl;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.PAY_APP_NOT_FOUND;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* {@link PayAppServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Import(PayAppServiceImpl.class)
|
||||
public class PayAppServiceTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private PayAppServiceImpl appService;
|
||||
|
||||
@Resource
|
||||
private PayAppMapper appMapper;
|
||||
|
||||
@MockBean(name = "payMerchantMapper")
|
||||
private PayMerchantMapper payMerchantMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateApp_success() {
|
||||
// 准备参数
|
||||
PayAppCreateReqVO reqVO = randomPojo(PayAppCreateReqVO.class, o ->
|
||||
o.setStatus((RandomUtil.randomEle(CommonStatusEnum.values()).getStatus())));
|
||||
|
||||
// 调用
|
||||
Long appId = appService.createApp(reqVO);
|
||||
// 断言
|
||||
assertNotNull(appId);
|
||||
// 校验记录的属性是否正确
|
||||
PayAppDO app = appMapper.selectById(appId);
|
||||
assertPojoEquals(reqVO, app);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateApp_success() {
|
||||
// mock 数据
|
||||
PayAppDO dbApp = randomPojo(PayAppDO.class, o ->
|
||||
o.setStatus(CommonStatusEnum.DISABLE.getStatus()));
|
||||
appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
PayAppUpdateReqVO reqVO = randomPojo(PayAppUpdateReqVO.class, o -> {
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setId(dbApp.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
appService.updateApp(reqVO);
|
||||
// 校验是否更新正确
|
||||
PayAppDO app = appMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, app);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateApp_notExists() {
|
||||
// 准备参数
|
||||
PayAppUpdateReqVO reqVO = randomPojo(PayAppUpdateReqVO.class, o ->
|
||||
o.setStatus((RandomUtil.randomEle(CommonStatusEnum.values()).getStatus())));
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> appService.updateApp(reqVO), PAY_APP_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteApp_success() {
|
||||
// mock 数据
|
||||
PayAppDO dbApp = randomPojo(PayAppDO.class, o ->
|
||||
o.setStatus((RandomUtil.randomEle(CommonStatusEnum.values()).getStatus())));
|
||||
appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbApp.getId();
|
||||
|
||||
// 调用
|
||||
appService.deleteApp(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(appMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteApp_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> appService.deleteApp(id), PAY_APP_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAppPage() {
|
||||
Long merchantId = 1L;
|
||||
Long mismatchMerchantId = 2L;
|
||||
|
||||
// mock 数据
|
||||
PayAppDO dbApp = randomPojo(PayAppDO.class, o -> { // 等会查询到
|
||||
o.setName("灿灿姐的杂货铺");
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setRemark("敏敏姐的小卖铺");
|
||||
o.setPayNotifyUrl("https://www.hc.com");
|
||||
o.setRefundNotifyUrl("https://www.xm.com");
|
||||
o.setMerchantId(merchantId);
|
||||
o.setCreateTime(buildTime(2021,11,20));
|
||||
});
|
||||
|
||||
// mock 数据
|
||||
PayMerchantDO dbMerchant = randomPojo(PayMerchantDO.class, o -> { // 等会查询到
|
||||
o.setId(merchantId);
|
||||
o.setNo("M1008611");
|
||||
o.setName("灿哥的杂货铺");
|
||||
o.setShortName("灿灿子");
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setRemark("灿哥的杂货铺");
|
||||
o.setCreateTime(buildTime(2021,11,3));
|
||||
});
|
||||
|
||||
Mockito.when(payMerchantMapper.getMerchantListByName(dbMerchant.getName()))
|
||||
.thenReturn(Collections.singletonList(dbMerchant));
|
||||
|
||||
appMapper.insert(dbApp);
|
||||
// 测试 name 不匹配
|
||||
appMapper.insert(cloneIgnoreId(dbApp, o -> o.setName("敏敏姐的杂货铺")));
|
||||
// 测试 status 不匹配
|
||||
appMapper.insert(cloneIgnoreId(dbApp, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())));
|
||||
// 测试 remark 不匹配
|
||||
appMapper.insert(cloneIgnoreId(dbApp, o -> o.setRemark("灿灿姐的小卖部")));
|
||||
// 测试 payNotifyUrl 不匹配
|
||||
appMapper.insert(cloneIgnoreId(dbApp, o -> o.setPayNotifyUrl("xm.com")));
|
||||
// 测试 refundNotifyUrl 不匹配
|
||||
appMapper.insert(cloneIgnoreId(dbApp, o -> o.setRefundNotifyUrl("hc.com")));
|
||||
// 测试 merchantId 不匹配
|
||||
appMapper.insert(cloneIgnoreId(dbApp, o -> o.setMerchantId(mismatchMerchantId)));
|
||||
// 测试 createTime 不匹配
|
||||
appMapper.insert(cloneIgnoreId(dbApp, o -> o.setCreateTime(buildTime(2021,12,21))));
|
||||
// 准备参数
|
||||
PayAppPageReqVO reqVO = new PayAppPageReqVO();
|
||||
reqVO.setName("灿灿姐的杂货铺");
|
||||
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
reqVO.setRemark("敏敏姐的小卖铺");
|
||||
reqVO.setPayNotifyUrl("https://www.hc.com");
|
||||
reqVO.setRefundNotifyUrl("https://www.xm.com");
|
||||
reqVO.setMerchantName(dbMerchant.getName());
|
||||
reqVO.setBeginCreateTime(buildTime(2021,11,19));
|
||||
reqVO.setEndCreateTime(buildTime(2021,11,21));
|
||||
|
||||
// 调用
|
||||
PageResult<PayAppDO> pageResult = appService.getAppPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbApp, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test // TODO 请修改 null 为需要的值
|
||||
public void testGetAppList() {
|
||||
Long merchantId = 1L;
|
||||
Long mismatchMerchantId = 2L;
|
||||
|
||||
// mock 数据
|
||||
PayAppDO dbApp = randomPojo(PayAppDO.class, o -> { // 等会查询到
|
||||
o.setName("灿灿姐的杂货铺");
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setRemark("敏敏姐的小卖铺");
|
||||
o.setPayNotifyUrl("https://www.hc.com");
|
||||
o.setRefundNotifyUrl("https://www.xm.com");
|
||||
o.setMerchantId(merchantId);
|
||||
o.setCreateTime(buildTime(2021,11,20));
|
||||
});
|
||||
|
||||
// mock 数据
|
||||
PayMerchantDO dbMerchant = randomPojo(PayMerchantDO.class, o -> { // 等会查询到
|
||||
o.setId(merchantId);
|
||||
o.setNo("M1008611");
|
||||
o.setName("灿哥的杂货铺");
|
||||
o.setShortName("灿灿子");
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setRemark("灿哥的杂货铺");
|
||||
o.setCreateTime(buildTime(2021,11,3));
|
||||
});
|
||||
|
||||
Mockito.when(payMerchantMapper.getMerchantListByName(dbMerchant.getName()))
|
||||
.thenReturn(Collections.singletonList(dbMerchant));
|
||||
|
||||
appMapper.insert(dbApp);
|
||||
// 测试 name 不匹配
|
||||
appMapper.insert(cloneIgnoreId(dbApp, o -> o.setName("敏敏姐的杂货铺")));
|
||||
// 测试 status 不匹配
|
||||
appMapper.insert(cloneIgnoreId(dbApp, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())));
|
||||
// 测试 remark 不匹配
|
||||
appMapper.insert(cloneIgnoreId(dbApp, o -> o.setRemark("灿灿姐的小卖部")));
|
||||
// 测试 payNotifyUrl 不匹配
|
||||
appMapper.insert(cloneIgnoreId(dbApp, o -> o.setPayNotifyUrl("xm.com")));
|
||||
// 测试 refundNotifyUrl 不匹配
|
||||
appMapper.insert(cloneIgnoreId(dbApp, o -> o.setRefundNotifyUrl("hc.com")));
|
||||
// 测试 merchantId 不匹配
|
||||
appMapper.insert(cloneIgnoreId(dbApp, o -> o.setMerchantId(mismatchMerchantId)));
|
||||
// 测试 createTime 不匹配
|
||||
appMapper.insert(cloneIgnoreId(dbApp, o -> o.setCreateTime(buildTime(2021,12,21))));
|
||||
// 准备参数
|
||||
PayAppExportReqVO reqVO = new PayAppExportReqVO();
|
||||
reqVO.setName("灿灿姐的杂货铺");
|
||||
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
reqVO.setRemark("敏敏姐的小卖铺");
|
||||
reqVO.setPayNotifyUrl("https://www.hc.com");
|
||||
reqVO.setRefundNotifyUrl("https://www.xm.com");
|
||||
reqVO.setMerchantName(dbMerchant.getName());
|
||||
reqVO.setBeginCreateTime(buildTime(2021,11,19));
|
||||
reqVO.setEndCreateTime(buildTime(2021,11,21));
|
||||
|
||||
// 调用
|
||||
List<PayAppDO> list = appService.getAppList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbApp, list.get(0));
|
||||
}
|
||||
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.channel;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.validation.Validation;
|
||||
import javax.validation.Validator;
|
||||
|
||||
/**
|
||||
* 用于初始化 validator Bean 对象
|
||||
* @author aquan
|
||||
*/
|
||||
@Configuration
|
||||
public class PayChannelConfig {
|
||||
|
||||
@Bean
|
||||
public Validator validator(){
|
||||
return Validation.buildDefaultValidatorFactory().getValidator();
|
||||
}
|
||||
}
|
@@ -1,404 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.channel;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelCreateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.channel.vo.PayChannelUpdateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.channel.PayChannelMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.channel.impl.PayChannelServiceImpl;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig;
|
||||
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.CHANNEL_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* {@link PayChannelServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Import({
|
||||
PayChannelServiceImpl.class,
|
||||
PayChannelConfig.class
|
||||
})
|
||||
public class PayChannelServiceTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private PayChannelServiceImpl channelService;
|
||||
|
||||
@Resource
|
||||
private PayChannelMapper channelMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateWechatVersion2Channel_success() {
|
||||
// 准备参数
|
||||
|
||||
WXPayClientConfig v2Config = getV2Config();
|
||||
PayChannelCreateReqVO reqVO = randomPojo(PayChannelCreateReqVO.class, o -> {
|
||||
o.setCode(PayChannelEnum.WX_PUB.getCode());
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setConfig(JSON.toJSONString(v2Config));
|
||||
});
|
||||
|
||||
// 调用
|
||||
Long channelId = channelService.createChannel(reqVO);
|
||||
// 断言
|
||||
assertNotNull(channelId);
|
||||
// 校验记录的属性是否正确
|
||||
PayChannelDO channel = channelMapper.selectById(channelId);
|
||||
assertPojoEquals(reqVO, channel, "config");
|
||||
// 关于config 对象应该拿出来重新对比
|
||||
assertPojoEquals(v2Config, channel.getConfig());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateWechatVersion3Channel_success() {
|
||||
// 准备参数
|
||||
WXPayClientConfig v3Config = getV3Config();
|
||||
PayChannelCreateReqVO reqVO = randomPojo(PayChannelCreateReqVO.class, o -> {
|
||||
o.setCode(PayChannelEnum.WX_PUB.getCode());
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setConfig(JSON.toJSONString(v3Config));
|
||||
});
|
||||
|
||||
// 调用
|
||||
Long channelId = channelService.createChannel(reqVO);
|
||||
// 断言
|
||||
assertNotNull(channelId);
|
||||
// 校验记录的属性是否正确
|
||||
PayChannelDO channel = channelMapper.selectById(channelId);
|
||||
assertPojoEquals(reqVO, channel, "config");
|
||||
// 关于config 对象应该拿出来重新对比
|
||||
assertPojoEquals(v3Config, channel.getConfig());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAliPayPublicKeyChannel_success() {
|
||||
// 准备参数
|
||||
|
||||
AlipayPayClientConfig payClientConfig = getPublicKeyConfig();
|
||||
PayChannelCreateReqVO reqVO = randomPojo(PayChannelCreateReqVO.class, o -> {
|
||||
o.setCode(PayChannelEnum.ALIPAY_APP.getCode());
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setConfig(JSON.toJSONString(payClientConfig));
|
||||
});
|
||||
|
||||
// 调用
|
||||
Long channelId = channelService.createChannel(reqVO);
|
||||
// 断言
|
||||
assertNotNull(channelId);
|
||||
// 校验记录的属性是否正确
|
||||
PayChannelDO channel = channelMapper.selectById(channelId);
|
||||
assertPojoEquals(reqVO, channel, "config");
|
||||
// 关于config 对象应该拿出来重新对比
|
||||
assertPojoEquals(payClientConfig, channel.getConfig());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAliPayCertificateChannel_success() {
|
||||
// 准备参数
|
||||
|
||||
AlipayPayClientConfig payClientConfig = getCertificateConfig();
|
||||
PayChannelCreateReqVO reqVO = randomPojo(PayChannelCreateReqVO.class, o -> {
|
||||
o.setCode(PayChannelEnum.ALIPAY_APP.getCode());
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setConfig(JSON.toJSONString(payClientConfig));
|
||||
});
|
||||
|
||||
// 调用
|
||||
Long channelId = channelService.createChannel(reqVO);
|
||||
// 断言
|
||||
assertNotNull(channelId);
|
||||
// 校验记录的属性是否正确
|
||||
PayChannelDO channel = channelMapper.selectById(channelId);
|
||||
assertPojoEquals(reqVO, channel, "config");
|
||||
// 关于config 对象应该拿出来重新对比
|
||||
assertPojoEquals(payClientConfig, channel.getConfig());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateChannel_success() {
|
||||
// mock 数据
|
||||
AlipayPayClientConfig payClientConfig = getCertificateConfig();
|
||||
PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> {
|
||||
o.setCode(PayChannelEnum.ALIPAY_APP.getCode());
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setConfig(payClientConfig);
|
||||
});
|
||||
channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
AlipayPayClientConfig payClientPublicKeyConfig = getPublicKeyConfig();
|
||||
PayChannelUpdateReqVO reqVO = randomPojo(PayChannelUpdateReqVO.class, o -> {
|
||||
o.setCode(dbChannel.getCode());
|
||||
o.setStatus(dbChannel.getStatus());
|
||||
o.setConfig(JSON.toJSONString(payClientPublicKeyConfig));
|
||||
o.setId(dbChannel.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
channelService.updateChannel(reqVO);
|
||||
// 校验是否更新正确
|
||||
PayChannelDO channel = channelMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, channel, "config");
|
||||
assertPojoEquals(payClientPublicKeyConfig, channel.getConfig());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateChannel_notExists() {
|
||||
// 准备参数
|
||||
AlipayPayClientConfig payClientPublicKeyConfig = getPublicKeyConfig();
|
||||
PayChannelUpdateReqVO reqVO = randomPojo(PayChannelUpdateReqVO.class, o -> {
|
||||
o.setCode(PayChannelEnum.ALIPAY_APP.getCode());
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setConfig(JSON.toJSONString(payClientPublicKeyConfig));
|
||||
});
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> channelService.updateChannel(reqVO), CHANNEL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteChannel_success() {
|
||||
// mock 数据
|
||||
AlipayPayClientConfig payClientConfig = getCertificateConfig();
|
||||
PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> {
|
||||
o.setCode(PayChannelEnum.ALIPAY_APP.getCode());
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setConfig(payClientConfig);
|
||||
});
|
||||
channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbChannel.getId();
|
||||
|
||||
// 调用
|
||||
channelService.deleteChannel(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(channelMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteChannel_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> channelService.deleteChannel(id), CHANNEL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test // TODO 请修改 null 为需要的值
|
||||
public void testGetChannelPage() {
|
||||
// mock 数据
|
||||
AlipayPayClientConfig payClientConfig = getCertificateConfig();
|
||||
PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { // 等会查询到
|
||||
o.setCode(PayChannelEnum.ALIPAY_APP.getCode());
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setRemark("灿灿子的支付渠道");
|
||||
o.setFeeRate(0.03);
|
||||
o.setMerchantId(1L);
|
||||
o.setAppId(1L);
|
||||
o.setConfig(payClientConfig);
|
||||
o.setCreateTime(buildTime(2021,11,20));
|
||||
});
|
||||
channelMapper.insert(dbChannel);
|
||||
// 执行拷贝的时候会出现异常,所以在插入后要重置为null 后续在写入新的
|
||||
dbChannel.setConfig(null);
|
||||
// 测试 code 不匹配
|
||||
channelMapper.insert(cloneIgnoreId(dbChannel, o -> {
|
||||
o.setConfig(payClientConfig);
|
||||
o.setCode(PayChannelEnum.WX_PUB.getCode());
|
||||
}));
|
||||
// 测试 status 不匹配
|
||||
channelMapper.insert(cloneIgnoreId(dbChannel, o -> {
|
||||
o.setConfig(payClientConfig);
|
||||
o.setStatus(CommonStatusEnum.DISABLE.getStatus());
|
||||
}));
|
||||
// 测试 remark 不匹配
|
||||
channelMapper.insert(cloneIgnoreId(dbChannel, o ->{
|
||||
o.setConfig(payClientConfig);
|
||||
o.setRemark("敏敏子的渠道");
|
||||
}));
|
||||
// 测试 feeRate 不匹配
|
||||
channelMapper.insert(cloneIgnoreId(dbChannel, o -> {
|
||||
o.setConfig(payClientConfig);
|
||||
o.setFeeRate(1.23);
|
||||
}));
|
||||
// 测试 merchantId 不匹配
|
||||
channelMapper.insert(cloneIgnoreId(dbChannel, o -> {
|
||||
o.setConfig(payClientConfig);
|
||||
o.setMerchantId(2L);
|
||||
}));
|
||||
// 测试 appId 不匹配
|
||||
channelMapper.insert(cloneIgnoreId(dbChannel, o -> {
|
||||
o.setConfig(payClientConfig);
|
||||
o.setAppId(2L);
|
||||
}));
|
||||
// 测试 createTime 不匹配
|
||||
channelMapper.insert(cloneIgnoreId(dbChannel, o -> {
|
||||
o.setConfig(payClientConfig);
|
||||
o.setCreateTime(buildTime(2021, 10, 20));
|
||||
}));
|
||||
// 准备参数
|
||||
PayChannelPageReqVO reqVO = new PayChannelPageReqVO();
|
||||
reqVO.setCode(PayChannelEnum.ALIPAY_APP.getCode());
|
||||
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
reqVO.setRemark("灿灿子的支付渠道");
|
||||
reqVO.setFeeRate(0.03);
|
||||
reqVO.setMerchantId(1L);
|
||||
reqVO.setAppId(1L);
|
||||
reqVO.setConfig(JSON.toJSONString(payClientConfig));
|
||||
reqVO.setBeginCreateTime(buildTime(2021,11,19));
|
||||
reqVO.setEndCreateTime(buildTime(2021,11,21));
|
||||
|
||||
// 调用
|
||||
PageResult<PayChannelDO> pageResult = channelService.getChannelPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbChannel, pageResult.getList().get(0), "config");
|
||||
assertPojoEquals(payClientConfig, pageResult.getList().get(0).getConfig());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChannelList() {
|
||||
// mock 数据
|
||||
AlipayPayClientConfig payClientConfig = getCertificateConfig();
|
||||
PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { // 等会查询到
|
||||
o.setCode(PayChannelEnum.ALIPAY_APP.getCode());
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setRemark("灿灿子的支付渠道");
|
||||
o.setFeeRate(0.03);
|
||||
o.setMerchantId(1L);
|
||||
o.setAppId(1L);
|
||||
o.setConfig(payClientConfig);
|
||||
o.setCreateTime(buildTime(2021,11,20));
|
||||
});
|
||||
channelMapper.insert(dbChannel);
|
||||
// 执行拷贝的时候会出现异常,所以在插入后要重置为null 后续在写入新的
|
||||
dbChannel.setConfig(null);
|
||||
// 测试 code 不匹配
|
||||
channelMapper.insert(cloneIgnoreId(dbChannel, o -> {
|
||||
o.setConfig(payClientConfig);
|
||||
o.setCode(PayChannelEnum.WX_PUB.getCode());
|
||||
}));
|
||||
// 测试 status 不匹配
|
||||
channelMapper.insert(cloneIgnoreId(dbChannel, o -> {
|
||||
o.setConfig(payClientConfig);
|
||||
o.setStatus(CommonStatusEnum.DISABLE.getStatus());
|
||||
}));
|
||||
// 测试 remark 不匹配
|
||||
channelMapper.insert(cloneIgnoreId(dbChannel, o ->{
|
||||
o.setConfig(payClientConfig);
|
||||
o.setRemark("敏敏子的渠道");
|
||||
}));
|
||||
// 测试 feeRate 不匹配
|
||||
channelMapper.insert(cloneIgnoreId(dbChannel, o -> {
|
||||
o.setConfig(payClientConfig);
|
||||
o.setFeeRate(1.23);
|
||||
}));
|
||||
// 测试 merchantId 不匹配
|
||||
channelMapper.insert(cloneIgnoreId(dbChannel, o -> {
|
||||
o.setConfig(payClientConfig);
|
||||
o.setMerchantId(2L);
|
||||
}));
|
||||
// 测试 appId 不匹配
|
||||
channelMapper.insert(cloneIgnoreId(dbChannel, o -> {
|
||||
o.setConfig(payClientConfig);
|
||||
o.setAppId(2L);
|
||||
}));
|
||||
// 测试 createTime 不匹配
|
||||
channelMapper.insert(cloneIgnoreId(dbChannel, o -> {
|
||||
o.setConfig(payClientConfig);
|
||||
o.setCreateTime(buildTime(2021, 10, 20));
|
||||
}));
|
||||
// 准备参数
|
||||
PayChannelExportReqVO reqVO = new PayChannelExportReqVO();
|
||||
reqVO.setCode(PayChannelEnum.ALIPAY_APP.getCode());
|
||||
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
reqVO.setRemark("灿灿子的支付渠道");
|
||||
reqVO.setFeeRate(0.03);
|
||||
reqVO.setMerchantId(1L);
|
||||
reqVO.setAppId(1L);
|
||||
reqVO.setConfig(JSON.toJSONString(payClientConfig));
|
||||
reqVO.setBeginCreateTime(buildTime(2021,11,19));
|
||||
reqVO.setEndCreateTime(buildTime(2021,11,21));
|
||||
|
||||
// 调用
|
||||
List<PayChannelDO> list = channelService.getChannelList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbChannel, list.get(0), "config");
|
||||
assertPojoEquals(payClientConfig, list.get(0).getConfig());
|
||||
}
|
||||
|
||||
|
||||
public WXPayClientConfig getV2Config() {
|
||||
return new WXPayClientConfig()
|
||||
.setAppId("APP00001")
|
||||
.setMchId("MCH00001")
|
||||
.setApiVersion(WXPayClientConfig.API_VERSION_V2)
|
||||
.setMchKey("dsa1d5s6a1d6sa16d1sa56d15a61das6")
|
||||
.setApiV3Key("")
|
||||
.setPrivateCertContent("")
|
||||
.setPrivateKeyContent("");
|
||||
}
|
||||
|
||||
public WXPayClientConfig getV3Config() {
|
||||
return new WXPayClientConfig()
|
||||
.setAppId("APP00001")
|
||||
.setMchId("MCH00001")
|
||||
.setApiVersion(WXPayClientConfig.API_VERSION_V3)
|
||||
.setMchKey("")
|
||||
.setApiV3Key("sdadasdsadadsa")
|
||||
.setPrivateKeyContent("dsa445das415d15asd16ad156as")
|
||||
.setPrivateCertContent("dsadasd45asd4s5a");
|
||||
|
||||
}
|
||||
|
||||
public AlipayPayClientConfig getPublicKeyConfig() {
|
||||
return new AlipayPayClientConfig()
|
||||
.setServerUrl(AlipayPayClientConfig.SERVER_URL_PROD)
|
||||
.setAppId("APP00001")
|
||||
.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT)
|
||||
.setMode(AlipayPayClientConfig.MODE_PUBLIC_KEY)
|
||||
.setPrivateKey("13131321312")
|
||||
.setAlipayPublicKey("13321321321")
|
||||
.setAppCertContent("")
|
||||
.setAlipayPublicCertContent("")
|
||||
.setRootCertContent("");
|
||||
}
|
||||
|
||||
public AlipayPayClientConfig getCertificateConfig() {
|
||||
return new AlipayPayClientConfig()
|
||||
.setServerUrl(AlipayPayClientConfig.SERVER_URL_PROD)
|
||||
.setAppId("APP00001")
|
||||
.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT)
|
||||
.setMode(AlipayPayClientConfig.MODE_CERTIFICATE)
|
||||
.setPrivateKey("")
|
||||
.setAlipayPublicKey("")
|
||||
.setAppCertContent("13321321321sda")
|
||||
.setAlipayPublicCertContent("13321321321aqeqw")
|
||||
.setRootCertContent("13321321321dsad");
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,193 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.merchant;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.iocoder.yudao.adminserver.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantCreateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.merchant.vo.PayMerchantUpdateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.merchant.PayMerchantMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.merchant.impl.PayMerchantServiceImpl;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeCoreConstants.PAY_MERCHANT_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* {@link PayMerchantServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Import(PayMerchantServiceImpl.class)
|
||||
public class PayMerchantServiceTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private PayMerchantServiceImpl merchantService;
|
||||
|
||||
@Resource
|
||||
private PayMerchantMapper merchantMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateMerchant_success() {
|
||||
// 准备参数
|
||||
PayMerchantCreateReqVO reqVO = randomPojo(PayMerchantCreateReqVO.class,o ->
|
||||
o.setStatus(RandomUtil.randomEle(CommonStatusEnum.values()).getStatus()));
|
||||
|
||||
// 调用
|
||||
Long merchantId = merchantService.createMerchant(reqVO);
|
||||
// 断言
|
||||
assertNotNull(merchantId);
|
||||
// 校验记录的属性是否正确
|
||||
PayMerchantDO merchant = merchantMapper.selectById(merchantId);
|
||||
assertPojoEquals(reqVO, merchant);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateMerchant_success() {
|
||||
// mock 数据
|
||||
PayMerchantDO dbMerchant = randomPojo(PayMerchantDO.class, o ->
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
||||
merchantMapper.insert(dbMerchant);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
PayMerchantUpdateReqVO reqVO = randomPojo(PayMerchantUpdateReqVO.class, o -> {
|
||||
o.setId(dbMerchant.getId()); // 设置更新的 ID
|
||||
o.setStatus(CommonStatusEnum.DISABLE.getStatus());
|
||||
});
|
||||
|
||||
// 调用
|
||||
merchantService.updateMerchant(reqVO);
|
||||
// 校验是否更新正确
|
||||
PayMerchantDO merchant = merchantMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, merchant);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateMerchant_notExists() {
|
||||
// 准备参数
|
||||
PayMerchantUpdateReqVO reqVO = randomPojo(PayMerchantUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> merchantService.updateMerchant(reqVO), PAY_MERCHANT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteMerchant_success() {
|
||||
// mock 数据
|
||||
PayMerchantDO dbMerchant = randomPojo(PayMerchantDO.class,
|
||||
o-> o.setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
||||
merchantMapper.insert(dbMerchant);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbMerchant.getId();
|
||||
|
||||
// 调用
|
||||
merchantService.deleteMerchant(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(merchantMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteMerchant_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> merchantService.deleteMerchant(id), PAY_MERCHANT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMerchantPage() {
|
||||
// mock 数据
|
||||
PayMerchantDO dbMerchant = randomPojo(PayMerchantDO.class, o -> { // 等会查询到
|
||||
o.setNo("M1008611");
|
||||
o.setName("灿哥的杂货铺");
|
||||
o.setShortName("灿灿子");
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setRemark("灿哥的杂货铺");
|
||||
o.setCreateTime(buildTime(2021,11,3));
|
||||
});
|
||||
merchantMapper.insert(dbMerchant);
|
||||
// 测试 no 不匹配
|
||||
merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setNo("M200000")));
|
||||
// 测试 name 不匹配
|
||||
merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setName("斌哥的杂货铺")));
|
||||
// 测试 shortName 不匹配
|
||||
merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setShortName("斌斌子")));
|
||||
// 测试 status 不匹配
|
||||
merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())));
|
||||
// 测试 remark 不匹配
|
||||
merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setRemark("斌哥的杂货铺")));
|
||||
// 测试 createTime 不匹配
|
||||
merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setCreateTime(buildTime(2022,12,4))));
|
||||
// 准备参数
|
||||
PayMerchantPageReqVO reqVO = new PayMerchantPageReqVO();
|
||||
reqVO.setNo("M1008611");
|
||||
reqVO.setName("灿哥的杂货铺");
|
||||
reqVO.setShortName("灿灿子");
|
||||
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
reqVO.setRemark("灿哥的杂货铺");
|
||||
reqVO.setBeginCreateTime(buildTime(2021,11,2));
|
||||
reqVO.setEndCreateTime(buildTime(2021,11,4));
|
||||
|
||||
// 调用
|
||||
PageResult<PayMerchantDO> pageResult = merchantService.getMerchantPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbMerchant, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMerchantList() {
|
||||
// mock 数据
|
||||
PayMerchantDO dbMerchant = randomPojo(PayMerchantDO.class, o -> { // 等会查询到
|
||||
o.setNo("M1008611");
|
||||
o.setName("灿哥的杂货铺");
|
||||
o.setShortName("灿灿子");
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setRemark("灿哥的杂货铺");
|
||||
o.setCreateTime(buildTime(2021,11,3));
|
||||
});
|
||||
merchantMapper.insert(dbMerchant);
|
||||
// 测试 no 不匹配
|
||||
merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setNo("M200000")));
|
||||
// 测试 name 不匹配
|
||||
merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setName("斌哥的杂货铺")));
|
||||
// 测试 shortName 不匹配
|
||||
merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setShortName("斌斌子")));
|
||||
// 测试 status 不匹配
|
||||
merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())));
|
||||
// 测试 remark 不匹配
|
||||
merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setRemark("斌哥的杂货铺")));
|
||||
// 测试 createTime 不匹配
|
||||
merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setCreateTime(buildTime(2022,12,4))));
|
||||
// 准备参数
|
||||
PayMerchantExportReqVO reqVO = new PayMerchantExportReqVO();
|
||||
reqVO.setNo("M1008611");
|
||||
reqVO.setName("灿哥的杂货铺");
|
||||
reqVO.setShortName("灿灿子");
|
||||
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
reqVO.setRemark("灿哥的杂货铺");
|
||||
reqVO.setBeginCreateTime(buildTime(2021,11,2));
|
||||
reqVO.setEndCreateTime(buildTime(2021,11,4));
|
||||
|
||||
// 调用
|
||||
List<PayMerchantDO> list = merchantService.getMerchantList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbMerchant, list.get(0));
|
||||
}
|
||||
|
||||
}
|
@@ -1,196 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.order;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.iocoder.yudao.adminserver.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order.PayOrderExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.order.PayOrderPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.order.PayOrderMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.order.impl.PayOrderServiceImpl;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayOrderNotifyStatusEnum;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayOrderStatusEnum;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayRefundTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* {@link PayOrderServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Import(PayOrderServiceImpl.class)
|
||||
public class PayOrderServiceTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private PayOrderServiceImpl orderService;
|
||||
|
||||
@Resource
|
||||
private PayOrderMapper orderMapper;
|
||||
|
||||
public String generateNo() {
|
||||
return DateUtil.format(new Date(), "yyyyMMddHHmmss") + RandomUtil.randomInt(100000, 999999);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOrderPage() {
|
||||
|
||||
String merchantOrderId = generateNo();
|
||||
String channelOrderId = generateNo();
|
||||
|
||||
// mock 数据
|
||||
PayOrderDO dbOrder = randomPojo(PayOrderDO.class, o -> { // 等会查询到
|
||||
o.setMerchantId(1L);
|
||||
o.setAppId(1L);
|
||||
o.setChannelId(1L);
|
||||
o.setChannelCode(PayChannelEnum.WX_PUB.getCode());
|
||||
o.setMerchantOrderId(merchantOrderId);
|
||||
o.setSubject("灿灿子的炸弹猫");
|
||||
o.setBody("斌斌子送给灿灿子的炸弹猫");
|
||||
o.setNotifyUrl("https://hc.com/lbh");
|
||||
o.setNotifyStatus(PayOrderNotifyStatusEnum.SUCCESS.getStatus());
|
||||
o.setAmount(10000L);
|
||||
o.setChannelFeeRate(0.01);
|
||||
o.setChannelFeeAmount(1L);
|
||||
o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus());
|
||||
o.setUserIp("127.0.0.1");
|
||||
o.setCreateTime(DateUtils.buildTime(2018, 1, 1, 10, 1, 0));
|
||||
o.setExpireTime(DateUtils.buildTime(2018, 1, 1, 10, 30, 0));
|
||||
o.setSuccessTime(DateUtils.buildTime(2018, 1, 1, 10, 10, 2));
|
||||
o.setNotifyTime(DateUtils.buildTime(2018, 1, 1, 10, 10, 15));
|
||||
o.setSuccessExtensionId(1L);
|
||||
o.setRefundStatus(PayRefundTypeEnum.NO.getStatus());
|
||||
o.setRefundTimes(0);
|
||||
o.setRefundAmount(0L);
|
||||
o.setChannelUserId("1008611");
|
||||
o.setChannelOrderNo(channelOrderId);
|
||||
o.setUpdateTime(DateUtils.buildTime(2018, 1, 1, 10, 10, 15));
|
||||
});
|
||||
orderMapper.insert(dbOrder);
|
||||
// 测试 merchantId 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setMerchantId(2L)));
|
||||
// 测试 appId 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setAppId(2L)));
|
||||
// 测试 channelId 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setChannelId(2L)));
|
||||
// 测试 channelCode 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())));
|
||||
// 测试 merchantOrderId 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setMerchantOrderId(generateNo())));
|
||||
// 测试 notifyStatus 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setNotifyStatus(PayOrderNotifyStatusEnum.FAILURE.getStatus())));
|
||||
// 测试 status 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus())));
|
||||
// 测试 refundStatus 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setRefundStatus(PayRefundTypeEnum.ALL.getStatus())));
|
||||
// 测试 createTime 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setCreateTime(DateUtils.buildTime(2019, 1, 1, 10, 10,
|
||||
1))));
|
||||
// 准备参数
|
||||
PayOrderPageReqVO reqVO = new PayOrderPageReqVO();
|
||||
reqVO.setMerchantId(1L);
|
||||
reqVO.setAppId(1L);
|
||||
reqVO.setChannelId(1L);
|
||||
reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode());
|
||||
reqVO.setMerchantOrderId(merchantOrderId);
|
||||
reqVO.setNotifyStatus(PayOrderNotifyStatusEnum.SUCCESS.getStatus());
|
||||
reqVO.setStatus(PayOrderStatusEnum.SUCCESS.getStatus());
|
||||
reqVO.setRefundStatus(PayRefundTypeEnum.NO.getStatus());
|
||||
reqVO.setBeginCreateTime(DateUtils.buildTime(2018, 1, 1, 10, 1, 0));
|
||||
reqVO.setEndCreateTime(DateUtils.buildTime(2018, 1, 1, 10, 1, 0));
|
||||
|
||||
// 调用
|
||||
PageResult<PayOrderDO> pageResult = orderService.getOrderPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbOrder, pageResult.getList().get(0));
|
||||
// assertEquals(0, dbOrder.getUpdateTime().compareTo(pageResult.getList().get(0).getUpdateTime()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOrderList() {
|
||||
// mock 数据
|
||||
String merchantOrderId = generateNo();
|
||||
String channelOrderId = generateNo();
|
||||
PayOrderDO dbOrder = randomPojo(PayOrderDO.class, o -> { // 等会查询到
|
||||
o.setMerchantId(1L);
|
||||
o.setAppId(1L);
|
||||
o.setChannelId(1L);
|
||||
o.setChannelCode(PayChannelEnum.WX_PUB.getCode());
|
||||
o.setMerchantOrderId(merchantOrderId);
|
||||
o.setSubject("灿灿子的炸弹猫");
|
||||
o.setBody("斌斌子送给灿灿子的炸弹猫");
|
||||
o.setNotifyUrl("https://hc.com/lbh");
|
||||
o.setNotifyStatus(PayOrderNotifyStatusEnum.SUCCESS.getStatus());
|
||||
o.setAmount(10000L);
|
||||
o.setChannelFeeRate(0.01);
|
||||
o.setChannelFeeAmount(1L);
|
||||
o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus());
|
||||
o.setUserIp("127.0.0.1");
|
||||
o.setCreateTime(DateUtils.buildTime(2018, 1, 1, 10, 1, 0));
|
||||
o.setExpireTime(DateUtils.buildTime(2018, 1, 1, 10, 30, 0));
|
||||
o.setSuccessTime(DateUtils.buildTime(2018, 1, 1, 10, 10, 2));
|
||||
o.setNotifyTime(DateUtils.buildTime(2018, 1, 1, 10, 10, 15));
|
||||
o.setSuccessExtensionId(1L);
|
||||
o.setRefundStatus(PayRefundTypeEnum.NO.getStatus());
|
||||
o.setRefundTimes(0);
|
||||
o.setRefundAmount(0L);
|
||||
o.setChannelUserId("1008611");
|
||||
o.setChannelOrderNo(channelOrderId);
|
||||
o.setUpdateTime(DateUtils.buildTime(2018, 1, 1, 10, 10, 15));
|
||||
|
||||
});
|
||||
orderMapper.insert(dbOrder);
|
||||
// 测试 merchantId 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setMerchantId(2L)));
|
||||
// 测试 appId 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setAppId(2L)));
|
||||
// 测试 channelId 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setChannelId(2L)));
|
||||
// 测试 channelCode 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())));
|
||||
// 测试 merchantOrderId 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setMerchantOrderId(generateNo())));
|
||||
// 测试 notifyStatus 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setNotifyStatus(PayOrderNotifyStatusEnum.FAILURE.getStatus())));
|
||||
// 测试 status 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus())));
|
||||
// 测试 refundStatus 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setRefundStatus(PayRefundTypeEnum.ALL.getStatus())));
|
||||
// 测试 createTime 不匹配
|
||||
orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setCreateTime(DateUtils.buildTime(2019, 1, 1, 10, 10,
|
||||
1))));
|
||||
// 准备参数
|
||||
PayOrderExportReqVO reqVO = new PayOrderExportReqVO();
|
||||
reqVO.setMerchantId(1L);
|
||||
reqVO.setAppId(1L);
|
||||
reqVO.setChannelId(1L);
|
||||
reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode());
|
||||
reqVO.setMerchantOrderId(merchantOrderId);
|
||||
reqVO.setNotifyStatus(PayOrderNotifyStatusEnum.SUCCESS.getStatus());
|
||||
reqVO.setStatus(PayOrderStatusEnum.SUCCESS.getStatus());
|
||||
reqVO.setRefundStatus(PayRefundTypeEnum.NO.getStatus());
|
||||
reqVO.setBeginCreateTime(DateUtils.buildTime(2018, 1, 1, 10, 1, 0));
|
||||
reqVO.setEndCreateTime(DateUtils.buildTime(2018, 1, 1, 10, 1, 0));
|
||||
|
||||
// 调用
|
||||
List<PayOrderDO> list = orderService.getOrderList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbOrder, list.get(0));
|
||||
}
|
||||
|
||||
}
|
@@ -1,183 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.pay.service.refund;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo.PayRefundExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.controller.order.vo.refund.vo.PayRefundPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.dal.mysql.order.PayRefundMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.pay.service.order.impl.PayRefundServiceImpl;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayRefundDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayOrderNotifyStatusEnum;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayRefundStatusEnum;
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayRefundTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
|
||||
/**
|
||||
* {@link PayRefundServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author aquan
|
||||
*/
|
||||
@Import(PayRefundServiceImpl.class)
|
||||
public class PayRefundServiceTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private PayRefundServiceImpl refundService;
|
||||
|
||||
@Resource
|
||||
private PayRefundMapper refundMapper;
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetRefundPage() {
|
||||
// mock 数据
|
||||
PayRefundDO dbRefund = randomPojo(PayRefundDO.class, o -> { // 等会查询到
|
||||
o.setMerchantId(1L);
|
||||
o.setAppId(1L);
|
||||
o.setChannelId(1L);
|
||||
o.setChannelCode(PayChannelEnum.WX_PUB.getCode());
|
||||
o.setOrderId(1L);
|
||||
o.setTradeNo("OT0000001");
|
||||
o.setMerchantOrderId("MOT0000001");
|
||||
o.setMerchantRefundNo("MRF0000001");
|
||||
o.setNotifyUrl("https://www.cancanzi.com");
|
||||
o.setNotifyStatus(PayOrderNotifyStatusEnum.SUCCESS.getStatus());
|
||||
o.setStatus(PayRefundStatusEnum.SUCCESS.getStatus());
|
||||
o.setType(PayRefundTypeEnum.SOME.getStatus());
|
||||
o.setPayAmount(100L);
|
||||
o.setRefundAmount(500L);
|
||||
o.setReason("就是想退款了,你有意见吗");
|
||||
o.setUserIp("127.0.0.1");
|
||||
o.setChannelOrderNo("CH0000001");
|
||||
o.setChannelRefundNo("CHR0000001");
|
||||
o.setChannelErrorCode("");
|
||||
o.setChannelErrorMsg("");
|
||||
o.setChannelExtras("");
|
||||
o.setExpireTime(DateUtils.buildTime(2021, 1, 1, 10, 10, 30));
|
||||
o.setSuccessTime(DateUtils.buildTime(2021, 1, 1, 10, 10, 15));
|
||||
o.setNotifyTime(DateUtils.buildTime(2021, 1, 1, 10, 10, 20));
|
||||
o.setCreateTime(DateUtils.buildTime(2021, 1, 1, 10, 10, 10));
|
||||
o.setUpdateTime(DateUtils.buildTime(2021, 1, 1, 10, 10, 35));
|
||||
});
|
||||
refundMapper.insert(dbRefund);
|
||||
// 测试 merchantId 不匹配
|
||||
refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantId(2L)));
|
||||
// 测试 appId 不匹配
|
||||
refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setAppId(2L)));
|
||||
// 测试 channelCode 不匹配
|
||||
refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())));
|
||||
// 测试 merchantRefundNo 不匹配
|
||||
refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantRefundNo("MRF1111112")));
|
||||
// 测试 notifyStatus 不匹配
|
||||
refundMapper.insert(
|
||||
cloneIgnoreId(dbRefund, o -> o.setNotifyStatus(PayOrderNotifyStatusEnum.FAILURE.getStatus())));
|
||||
// 测试 status 不匹配
|
||||
refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setStatus(PayRefundStatusEnum.CLOSE.getStatus())));
|
||||
// 测试 type 不匹配
|
||||
refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setType(PayRefundTypeEnum.ALL.getStatus())));
|
||||
// 测试 createTime 不匹配
|
||||
refundMapper.insert(cloneIgnoreId(dbRefund, o ->
|
||||
o.setCreateTime(DateUtils.buildTime(2022, 1, 1, 10, 10, 10))));
|
||||
// 准备参数
|
||||
PayRefundPageReqVO reqVO = new PayRefundPageReqVO();
|
||||
reqVO.setMerchantId(1L);
|
||||
reqVO.setAppId(1L);
|
||||
reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode());
|
||||
reqVO.setMerchantRefundNo("MRF0000001");
|
||||
reqVO.setNotifyStatus(PayOrderNotifyStatusEnum.SUCCESS.getStatus());
|
||||
reqVO.setStatus(PayRefundStatusEnum.SUCCESS.getStatus());
|
||||
reqVO.setType(PayRefundTypeEnum.SOME.getStatus());
|
||||
reqVO.setBeginCreateTime(DateUtils.buildTime(2021, 1, 1, 10, 10, 10));
|
||||
reqVO.setEndCreateTime(DateUtils.buildTime(2021, 1, 1, 10, 10, 12));
|
||||
|
||||
|
||||
// 调用
|
||||
PageResult<PayRefundDO> pageResult = refundService.getRefundPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbRefund, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRefundList() {
|
||||
// mock 数据
|
||||
PayRefundDO dbRefund = randomPojo(PayRefundDO.class, o -> { // 等会查询到
|
||||
o.setMerchantId(1L);
|
||||
o.setAppId(1L);
|
||||
o.setChannelId(1L);
|
||||
o.setChannelCode(PayChannelEnum.WX_PUB.getCode());
|
||||
o.setOrderId(1L);
|
||||
o.setTradeNo("OT0000001");
|
||||
o.setMerchantOrderId("MOT0000001");
|
||||
o.setMerchantRefundNo("MRF0000001");
|
||||
o.setNotifyUrl("https://www.cancanzi.com");
|
||||
o.setNotifyStatus(PayOrderNotifyStatusEnum.SUCCESS.getStatus());
|
||||
o.setStatus(PayRefundStatusEnum.SUCCESS.getStatus());
|
||||
o.setType(PayRefundTypeEnum.SOME.getStatus());
|
||||
o.setPayAmount(100L);
|
||||
o.setRefundAmount(500L);
|
||||
o.setReason("就是想退款了,你有意见吗");
|
||||
o.setUserIp("127.0.0.1");
|
||||
o.setChannelOrderNo("CH0000001");
|
||||
o.setChannelRefundNo("CHR0000001");
|
||||
o.setChannelErrorCode("");
|
||||
o.setChannelErrorMsg("");
|
||||
o.setChannelExtras("");
|
||||
o.setExpireTime(DateUtils.buildTime(2021, 1, 1, 10, 10, 30));
|
||||
o.setSuccessTime(DateUtils.buildTime(2021, 1, 1, 10, 10, 15));
|
||||
o.setNotifyTime(DateUtils.buildTime(2021, 1, 1, 10, 10, 20));
|
||||
o.setCreateTime(DateUtils.buildTime(2021, 1, 1, 10, 10, 10));
|
||||
o.setUpdateTime(DateUtils.buildTime(2021, 1, 1, 10, 10, 35));
|
||||
});
|
||||
refundMapper.insert(dbRefund);
|
||||
// 测试 merchantId 不匹配
|
||||
refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantId(2L)));
|
||||
// 测试 appId 不匹配
|
||||
refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setAppId(2L)));
|
||||
// 测试 channelCode 不匹配
|
||||
refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())));
|
||||
// 测试 merchantRefundNo 不匹配
|
||||
refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantRefundNo("MRF1111112")));
|
||||
// 测试 notifyStatus 不匹配
|
||||
refundMapper.insert(
|
||||
cloneIgnoreId(dbRefund, o -> o.setNotifyStatus(PayOrderNotifyStatusEnum.FAILURE.getStatus())));
|
||||
// 测试 status 不匹配
|
||||
refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setStatus(PayRefundStatusEnum.CLOSE.getStatus())));
|
||||
// 测试 type 不匹配
|
||||
refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setType(PayRefundTypeEnum.ALL.getStatus())));
|
||||
// 测试 createTime 不匹配
|
||||
refundMapper.insert(cloneIgnoreId(dbRefund, o ->
|
||||
o.setCreateTime(DateUtils.buildTime(2022, 1, 1, 10, 10, 10))));
|
||||
|
||||
// 准备参数
|
||||
PayRefundExportReqVO reqVO = new PayRefundExportReqVO();
|
||||
reqVO.setMerchantId(1L);
|
||||
reqVO.setAppId(1L);
|
||||
reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode());
|
||||
reqVO.setMerchantRefundNo("MRF0000001");
|
||||
reqVO.setNotifyStatus(PayOrderNotifyStatusEnum.SUCCESS.getStatus());
|
||||
reqVO.setStatus(PayRefundStatusEnum.SUCCESS.getStatus());
|
||||
reqVO.setType(PayRefundTypeEnum.SOME.getStatus());
|
||||
reqVO.setBeginCreateTime(DateUtils.buildTime(2021, 1, 1, 10, 10, 10));
|
||||
reqVO.setEndCreateTime(DateUtils.buildTime(2021, 1, 1, 10, 10, 12));
|
||||
|
||||
// 调用
|
||||
List<PayRefundDO> list = refundService.getRefundList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbRefund, list.get(0));
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user