mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 21:32:07 +08:00
1、充值活动controller单元测试完善;2、充值明细无用方法移除、service/controller单元测试完善;
This commit is contained in:
-29
@@ -1,29 +1,17 @@
|
||||
package com.cf.imes.module.system.controller.admin.funds.recharge;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.excel.core.util.ExcelUtils;
|
||||
import com.cf.imes.framework.operatelog.core.annotations.OperateLog;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeDetailRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeDetailsBalanceInfoRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeDetailsPageReqVO;
|
||||
import com.cf.imes.module.system.service.funds.recharge.RechargeDetailsService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
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.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
import static com.cf.imes.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
@@ -38,23 +26,6 @@ public class RechargeDetailsController {
|
||||
@Resource
|
||||
private RechargeDetailsService rechargeDetailsService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获取充值明细分页")
|
||||
public CommonResult<PageResult<RechargeDetailRespVO>> getRechargeDetailsPage(@Valid RechargeDetailsPageReqVO pageReqVO) {
|
||||
return success(rechargeDetailsService.getRechargeDetailsPage(pageReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/export")
|
||||
@Operation(summary = "导出充值明细")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportRechargeDetails(@Valid RechargeDetailsPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<RechargeDetailRespVO> list = rechargeDetailsService.getRechargeDetailsPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "充值明细表.xls", "数据", RechargeDetailRespVO.class, list);
|
||||
}
|
||||
|
||||
@GetMapping("/balance")
|
||||
@Operation(summary = "获取管理端充值明细余额信息")
|
||||
public CommonResult<RechargeDetailsBalanceInfoRespVO> getManageRechargeDetailsBalanceInfo() {
|
||||
|
||||
-10
@@ -1,12 +1,9 @@
|
||||
package com.cf.imes.module.system.dal.mysql.pay;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeDetailsPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.statistics.vo.OrgStatusGroupStatisticsReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.statistics.FundsTradeTypeGroupStatisticsDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.pay.PayOrderDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.pay.PayOrderRechargeDetailDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -21,13 +18,6 @@ import java.util.List;
|
||||
*/
|
||||
@Mapper
|
||||
public interface PayOrderMapper extends BaseMapper<PayOrderDO> {
|
||||
/**
|
||||
* 获取充值明细分页
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
IPage<PayOrderRechargeDetailDO> getRechargeDetailsPage(@Param("page") IPage<PayOrderRechargeDetailDO> page, @Param("reqVO") RechargeDetailsPageReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 查询充值总额
|
||||
|
||||
-9
@@ -1,9 +1,6 @@
|
||||
package com.cf.imes.module.system.service.funds.recharge;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeDetailRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeDetailsBalanceInfoRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeDetailsPageReqVO;
|
||||
|
||||
/**
|
||||
* 充值明细 Service 接口
|
||||
@@ -12,12 +9,6 @@ import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeDeta
|
||||
* @since 2025/9/11 16:20
|
||||
*/
|
||||
public interface RechargeDetailsService {
|
||||
/**
|
||||
* 查询充值明细分页
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
PageResult<RechargeDetailRespVO> getRechargeDetailsPage(RechargeDetailsPageReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 获取管理端充值余额信息
|
||||
|
||||
-8
@@ -1,9 +1,6 @@
|
||||
package com.cf.imes.module.system.service.funds.recharge;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeDetailRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeDetailsBalanceInfoRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeDetailsPageReqVO;
|
||||
import com.cf.imes.module.system.service.funds.purchase.PurchaseService;
|
||||
import com.cf.imes.module.system.service.pay.PayOrderService;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -23,11 +20,6 @@ public class RechargeDetailsServiceImpl implements RechargeDetailsService {
|
||||
@Resource
|
||||
private PurchaseService purchaseService;
|
||||
|
||||
@Override
|
||||
public PageResult<RechargeDetailRespVO> getRechargeDetailsPage(RechargeDetailsPageReqVO reqVO) {
|
||||
return payOrderService.getRechargeDetailsPage(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RechargeDetailsBalanceInfoRespVO getManageRechargeDetailsBalanceInfo() {
|
||||
RechargeDetailsBalanceInfoRespVO rechargeDetailsBalanceInfoRespVO = new RechargeDetailsBalanceInfoRespVO();
|
||||
|
||||
-11
@@ -1,9 +1,6 @@
|
||||
package com.cf.imes.module.system.service.pay;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeDetailRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeDetailsPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.pay.vo.PayProductOrderUnifiedReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.pay.vo.PayRechargeOrderReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.pay.PayOrderDO;
|
||||
@@ -73,14 +70,6 @@ public interface PayOrderService {
|
||||
*/
|
||||
int expirePayOrder();
|
||||
|
||||
/**
|
||||
* 查询充值明细分页
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
PageResult<RechargeDetailRespVO> getRechargeDetailsPage(RechargeDetailsPageReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 管理端查询充值总额
|
||||
*
|
||||
|
||||
+1
-76
@@ -8,16 +8,12 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.Assert.AssertUtils;
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.common.util.validation.ValidationUtils;
|
||||
import com.cf.imes.framework.id.core.util.SnowflakeSerialNoWorker3rd;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
@@ -28,8 +24,6 @@ import com.cf.imes.framework.redis.config.ChenfengCacheProperties;
|
||||
import com.cf.imes.framework.redis.constants.RedisKeyConstants;
|
||||
import com.cf.imes.framework.redis.util.RedisLockUtil;
|
||||
import com.cf.imes.module.system.controller.admin.funds.delay.vo.PreviouProductDelayRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeDetailRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.recharge.vo.RechargeDetailsPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.pay.vo.PayOrderUnifiedReqDTO;
|
||||
import com.cf.imes.framework.common.exception.PayException;
|
||||
import com.cf.imes.framework.pay.core.enums.order.PayOrderStatusRespEnum;
|
||||
@@ -37,8 +31,6 @@ import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.OrganRechargeAmountRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.product.ProductProcessorRespVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.delay.ProductDelayRecordDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.organ.OrganizationDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.pay.PayOrderRechargeDetailDO;
|
||||
import com.cf.imes.module.system.enums.pay.PayProductChannelCodeEnumNew;
|
||||
import com.cf.imes.module.system.enums.pay.ProductDurationUnitEnum;
|
||||
import com.cf.imes.module.system.service.funds.delay.ProductDelayService;
|
||||
@@ -79,7 +71,6 @@ import jakarta.validation.Validator;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -111,9 +102,6 @@ import static com.cf.imes.module.system.enums.ErrorCodeConstants.PAY_RECHARGE_OR
|
||||
@Slf4j
|
||||
public class PayOrderServiceImpl implements PayOrderService {
|
||||
|
||||
// 外部payNo正则
|
||||
private static final Pattern pattern = Pattern.compile("P(\\d+)O");
|
||||
|
||||
// 自动生成定价id正则
|
||||
private static final Pattern productMonthDetailIdPattern = Pattern.compile("^1759029544(\\d+)$");
|
||||
private static final Pattern productYearDetailIdPattern = Pattern.compile("^1759993429(\\d+)$");
|
||||
@@ -528,7 +516,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
throw exception(PAY_ORDER_NOT_EXIST, outTradeNo);
|
||||
}
|
||||
// 订单已被更新成功,直接支付成功了
|
||||
if (PayOrderStatusEnum.SUCCESS.getStatus().equals(payOrderDO.getStatus())) {
|
||||
if (PayOrderStatusEnum.SUCCESS.equals(payOrderDO.getStatus())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -585,22 +573,6 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从payNo中解析组织id
|
||||
*
|
||||
* @param outTradeNo
|
||||
* @return
|
||||
*/
|
||||
private Long getOrganIdFromPayNo(String outTradeNo) {
|
||||
Matcher matcher = pattern.matcher(outTradeNo);
|
||||
|
||||
if (matcher.find()) {
|
||||
return Long.valueOf(matcher.group(1)); // 提取 P 和 O 中间的数字
|
||||
} else {
|
||||
throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付成功回调处理
|
||||
*
|
||||
@@ -850,20 +822,6 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验获取当前token请求下的组织id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private Long validOrganId() {
|
||||
// 校验token
|
||||
Long organId = OrganContextHolder.getOrganId();
|
||||
if (ObjectUtil.isNull(organId)) {
|
||||
throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED);
|
||||
}
|
||||
return organId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int expirePayOrder() {
|
||||
// 1、查询过期的待支付订单
|
||||
@@ -935,39 +893,6 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<RechargeDetailRespVO> getRechargeDetailsPage(RechargeDetailsPageReqVO reqVO) {
|
||||
// 分页查询
|
||||
Page<PayOrderRechargeDetailDO> page = new Page<>(reqVO.getPageNo(), reqVO.getPageSize());
|
||||
IPage<PayOrderRechargeDetailDO> rechargeDetailsPage = payOrderMapper.getRechargeDetailsPage(page, reqVO);
|
||||
|
||||
// 构建回调数据
|
||||
List<RechargeDetailRespVO> resultList = new ArrayList<>();
|
||||
for (PayOrderRechargeDetailDO detailDO : rechargeDetailsPage.getRecords()) {
|
||||
RechargeDetailRespVO respVO = BeanUtils.toBean(detailDO, RechargeDetailRespVO.class);
|
||||
|
||||
// 根据是否关联购买记录判断是充值还是购买软件
|
||||
if (ObjectUtil.isNotNull(detailDO.getPurchaseId())) {
|
||||
respVO.setTradeType(TradeTypeEnum.PRODUCT.getCode());
|
||||
// 产品购买有充值记录的,充值支付就是支付单的金额
|
||||
respVO.setRechargeSpent(detailDO.getPrice());
|
||||
} else {
|
||||
respVO.setTradeType(TradeTypeEnum.RECHARGE.getCode());
|
||||
BigDecimal zero = BigDecimal.ZERO;
|
||||
respVO.setRechargeSpent(zero);
|
||||
respVO.setTotalAmount(zero);
|
||||
respVO.setAccountBalanceSpent(zero);
|
||||
respVO.setGiftMoneySpent(zero);
|
||||
}
|
||||
OrganizationDO organ = organService.getOrganWithDeleted(detailDO.getOrganId());
|
||||
if (ObjectUtil.isNotNull(organ)) {
|
||||
respVO.setOrganName(organ.getName());
|
||||
}
|
||||
resultList.add(respVO);
|
||||
}
|
||||
return new PageResult<>(resultList, rechargeDetailsPage.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getRechargeTotalAmount() {
|
||||
return payOrderMapper.getRechargeTotalAmount();
|
||||
|
||||
-21
@@ -1,27 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.cf.imes.module.system.dal.mysql.pay.PayOrderMapper">
|
||||
<select id="getRechargeDetailsPage" resultType="com.cf.imes.module.system.dal.dataobject.pay.PayOrderRechargeDetailDO">
|
||||
select o.id, o.organ_id, o.pay_no, o.price, o.purchase_id, o.channel_code, o.creator, o.create_time, p.total_amount, p.account_balance_spent, p.gift_money_spent, p.payment_method
|
||||
from pay_order o
|
||||
left join purchase_record p on o.purchase_id = p.id
|
||||
where o.status = '${@com.cf.imes.module.system.enums.pay.PayOrderStatusEnum@SUCCESS.status}'
|
||||
|
||||
<if test="reqVO.organId != null">
|
||||
AND o.organ_id = #{reqVO.organId}
|
||||
</if>
|
||||
<if test="reqVO.productPrice != null">
|
||||
AND p.total_amount = #{reqVO.productPrice}
|
||||
</if>
|
||||
<if test="reqVO.operator != null and reqVO.operator != ''">
|
||||
AND o.creator = #{reqVO.operator}
|
||||
</if>
|
||||
<if test="reqVO.createTime != null and reqVO.createTime.length == 2">
|
||||
AND o.create_time >= #{reqVO.createTime[0]}
|
||||
AND o.create_time <= #{reqVO.createTime[1]}
|
||||
</if>
|
||||
order by o.id desc;
|
||||
</select>
|
||||
|
||||
<select id="getRechargeTotalAmount" resultType="java.math.BigDecimal">
|
||||
select sum(price) from pay_order
|
||||
|
||||
Reference in New Issue
Block a user