mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
新增账户可开金额/产品有效期总览接口、补充购买记录的赠送时长记录和展示
This commit is contained in:
+2
-9
@@ -5,16 +5,9 @@ import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - 组织余额信息 Response VO")
|
||||
@Schema(description = "管理后台 - 组织账户总览 Response VO")
|
||||
@Data
|
||||
public class OrganAmountRespVO {
|
||||
@Schema(description = "现金余额")
|
||||
private BigDecimal amount;
|
||||
|
||||
|
||||
@Schema(description = "赠送金余额")
|
||||
private BigDecimal giftAmount;
|
||||
|
||||
public class OrganProductOverviewRespVO {
|
||||
|
||||
@Schema(description = "可开票金额")
|
||||
private BigDecimal invoiceableAmount;
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.cf.imes.module.system.controller.admin.funds.purchase.vo;
|
||||
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.purchase.PurchaseRecordDO;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 查询组织下最早购买产品记录和关联定价规则 response vo
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2025/8/19 17:10
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class OrgEarliestPurchaseProductRespVO {
|
||||
/**
|
||||
* 购买记录
|
||||
*/
|
||||
private PurchaseRecordDO purchaseRecordDO;
|
||||
}
|
||||
+10
@@ -13,6 +13,7 @@ import com.cf.imes.framework.operatelog.core.annotations.OperateLog;
|
||||
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.cf.imes.module.system.api.user.dto.OrganAdminUserRespDTO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.delay.vo.ProductDelayRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.OrganProductOverviewRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.organ.vo.organ.*;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.purchase.PurchaseRecordDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.organ.OrganizationDO;
|
||||
@@ -21,6 +22,7 @@ import com.cf.imes.module.system.dal.mysql.organ.TenantPackageMapper;
|
||||
import com.cf.imes.module.system.enums.pay.DurationUnitEnum;
|
||||
import com.cf.imes.module.system.enums.pay.PurchaseRecordStatusEnum;
|
||||
import com.cf.imes.module.system.service.funds.delay.ProductDelayService;
|
||||
import com.cf.imes.module.system.service.funds.organamount.OrganAmountService;
|
||||
import com.cf.imes.module.system.service.funds.purchase.PurchaseService;
|
||||
import com.cf.imes.module.system.service.organ.OrganService;
|
||||
import com.cf.imes.module.system.service.user.AdminUserService;
|
||||
@@ -66,6 +68,9 @@ public class OrganController {
|
||||
@Resource
|
||||
private ProductDelayService productDelayService;
|
||||
|
||||
@Resource
|
||||
private OrganAmountService organAmountService;
|
||||
|
||||
@GetMapping("/get-id-by-name")
|
||||
@PermitAll
|
||||
@Operation(summary = "使用组织名,获得组织编号", description = "登录界面,根据用户的组织名,获得组织编号")
|
||||
@@ -261,4 +266,9 @@ public class OrganController {
|
||||
return success(organService.getSimpleOrganList(name));
|
||||
}
|
||||
|
||||
@GetMapping("/account/overview")
|
||||
@Operation(summary = "获取组织账户总览")
|
||||
public CommonResult<OrganProductOverviewRespVO> getOrganProductOverview() {
|
||||
return success(organAmountService.getOrganProductOverview());
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -79,6 +79,15 @@ public class PurchaseRecordDO extends BaseDO {
|
||||
*/
|
||||
private Integer purchaseDurationUnit;
|
||||
|
||||
/**
|
||||
* 赠送时长
|
||||
*/
|
||||
private Integer giftDuration;
|
||||
|
||||
/**
|
||||
* 赠送时长单位
|
||||
*/
|
||||
private Integer giftDurationUnit;
|
||||
|
||||
/**
|
||||
* 产品开始时间
|
||||
|
||||
+8
@@ -27,6 +27,14 @@ import java.util.List;
|
||||
*/
|
||||
@Mapper
|
||||
public interface PurchaseRecordMapper extends BaseMapperX<PurchaseRecordDO> {
|
||||
/**
|
||||
* 查询机构下可开票的金额
|
||||
*
|
||||
* @param organId
|
||||
* @return
|
||||
*/
|
||||
BigDecimal getInvoicingAmount(Long organId);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
|
||||
+8
@@ -2,6 +2,7 @@ package com.cf.imes.module.system.service.funds.organamount;
|
||||
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.ManageAmountOverviewRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.OrganFundsStatisticsReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.OrganProductOverviewRespVO;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -25,4 +26,11 @@ public interface OrganAmountService {
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getConsumptionTrend(OrganFundsStatisticsReqVO reqVO, boolean queryOrg);
|
||||
|
||||
/**
|
||||
* 获取组织账户总览
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
OrganProductOverviewRespVO getOrganProductOverview();
|
||||
}
|
||||
|
||||
+34
@@ -1,10 +1,15 @@
|
||||
package com.cf.imes.module.system.service.funds.organamount;
|
||||
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.ManageAmountOverviewRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.OrganAmountGroupByCreateTimeRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.OrganFundsStatisticsReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.OrganProductOverviewRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.TotalSalesAmountRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.OrgEarliestPurchaseProductRespVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.purchase.PurchaseRecordDO;
|
||||
import com.cf.imes.module.system.service.funds.invoice.InvoiceService;
|
||||
import com.cf.imes.module.system.service.funds.purchase.PurchaseService;
|
||||
import com.cf.imes.module.system.dal.mysql.funds.organamount.OrganAmountMapper;
|
||||
@@ -23,6 +28,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMATTER;
|
||||
import static com.cf.imes.framework.common.constants.StatisticsConstants.DATELIST_FIELD_NAME;
|
||||
import static com.cf.imes.framework.common.constants.StatisticsConstants.SERIES_FIELD_NAME;
|
||||
import static com.cf.imes.framework.common.util.time.StatisticsChangeUtils.generateDateRangeAxis;
|
||||
@@ -48,6 +54,34 @@ public class OrganAmountServiceImpl implements OrganAmountService {
|
||||
@Resource
|
||||
private PurchaseService purchaseService;
|
||||
|
||||
@Override
|
||||
public OrganProductOverviewRespVO getOrganProductOverview() {
|
||||
|
||||
Long organId = SecurityFrameworkUtils.getUserOrganId();
|
||||
|
||||
organService.validOrgan(organId);
|
||||
|
||||
OrganProductOverviewRespVO organProductOverviewRespVO = new OrganProductOverviewRespVO();
|
||||
|
||||
// 查询组织最晚还有效的产品购买记录
|
||||
OrgEarliestPurchaseProductRespVO orgEarliestProductDetail = purchaseService.getOrgEarliestProductDetail(organId);
|
||||
if (ObjectUtil.isNotNull(orgEarliestProductDetail)) {
|
||||
// 查询对应购买记录
|
||||
PurchaseRecordDO purchaseRecordDO = orgEarliestProductDetail.getPurchaseRecordDO();
|
||||
organProductOverviewRespVO.setProductEfficientDate(LocalDateTimeUtil.format(purchaseRecordDO.getEndTime(), NORM_DATETIME_FORMATTER));
|
||||
// 首购记录不展示时长
|
||||
if (!purchaseRecordDO.getInitial()) {
|
||||
organProductOverviewRespVO.setDuration(purchaseRecordDO.getPurchaseDuration());
|
||||
organProductOverviewRespVO.setDurationUnit(purchaseRecordDO.getPurchaseDurationUnit());
|
||||
}
|
||||
}
|
||||
|
||||
// 查询可开票金额
|
||||
organProductOverviewRespVO.setInvoiceableAmount(purchaseService.getInvoicingAmount(organId));
|
||||
return organProductOverviewRespVO;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManageAmountOverviewRespVO getOrganAmountAll() {
|
||||
ManageAmountOverviewRespVO respVO = new ManageAmountOverviewRespVO();
|
||||
|
||||
+18
@@ -3,6 +3,7 @@ package com.cf.imes.module.system.service.funds.purchase;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.TotalSalesAmountRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.productDetails.ProductDetailsRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.OrgEarliestPurchaseProductRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.PurchaseRecordPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.PurchaseRecordRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.SalesDetailRespVO;
|
||||
@@ -11,6 +12,7 @@ import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganCreateProd
|
||||
import com.cf.imes.module.system.controller.admin.statistics.vo.ManageSalesTotalStatisticRespVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.funds.purchase.PurchaseRecordDO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -56,6 +58,22 @@ public interface PurchaseService {
|
||||
*/
|
||||
void updateRecordInvoicable(Long purchaseRecordId, Long organId);
|
||||
|
||||
/**
|
||||
* 查询组织下最早购买产品定价规则
|
||||
*
|
||||
* @param organId
|
||||
* @return
|
||||
*/
|
||||
OrgEarliestPurchaseProductRespVO getOrgEarliestProductDetail(Long organId);
|
||||
|
||||
/**
|
||||
* 查询可开票金额
|
||||
*
|
||||
* @param organId
|
||||
* @return
|
||||
*/
|
||||
BigDecimal getInvoicingAmount(Long organId);
|
||||
|
||||
/**
|
||||
* 创建组织初始化(创建)时的购买记录
|
||||
*
|
||||
|
||||
+33
@@ -13,9 +13,11 @@ import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.date.LocalDateTimeUtils;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.system.controller.admin.funds.delay.vo.ProductDelayRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.organamount.vo.TotalSalesAmountRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.productDetails.ProductDetailsPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.products.vo.productDetails.ProductDetailsRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.OrgEarliestPurchaseProductRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.PurchaseRecordPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.PurchaseRecordRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.SalesDetailRespVO;
|
||||
@@ -33,6 +35,7 @@ import com.cf.imes.module.system.enums.pay.ProductDurationUnitEnum;
|
||||
import com.cf.imes.module.system.enums.pay.PurchaseRecordStatusEnum;
|
||||
import com.cf.imes.module.system.enums.pay.TradeTypeEnum;
|
||||
import com.cf.imes.module.system.framework.snowflake.config.MybatisIdProperties;
|
||||
import com.cf.imes.module.system.service.funds.delay.ProductDelayService;
|
||||
import com.cf.imes.module.system.service.funds.products.ProductsDetailService;
|
||||
import com.cf.imes.module.system.service.organ.OrganService;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -77,6 +80,10 @@ public class PurchaseServiceImpl implements PurchaseService {
|
||||
@Lazy
|
||||
private OrganService organService;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private ProductDelayService productDelayService;
|
||||
|
||||
@Override
|
||||
public PurchaseRecordDO getRecord(Long id) {
|
||||
return purchaseRecordMapper.selectById(id);
|
||||
@@ -140,6 +147,32 @@ public class PurchaseServiceImpl implements PurchaseService {
|
||||
.set(PurchaseRecordDO::getIsInvocing, InvoiceStatusEnum.INVOICABLE.getCode()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrgEarliestPurchaseProductRespVO getOrgEarliestProductDetail(Long organId) {
|
||||
// 查询购买记录中还有效的最晚一条
|
||||
PurchaseRecordDO purchaseRecordDO = purchaseRecordMapper.selectOne(new LambdaQueryWrapper<PurchaseRecordDO>()
|
||||
.eq(PurchaseRecordDO::getOrganId, organId)
|
||||
.eq(PurchaseRecordDO::getDeleted, false)
|
||||
.eq(PurchaseRecordDO::getStatus, PurchaseRecordStatusEnum.ACTIVE.getStatus())
|
||||
.orderByDesc(PurchaseRecordDO::getCreateTime)
|
||||
.last("limit 1"));
|
||||
if (ObjectUtil.isNotNull(purchaseRecordDO)) {
|
||||
// 查询延期记录
|
||||
List<ProductDelayRespVO> recordsByPurchaseId = productDelayService.getRecordsByPurchaseId(purchaseRecordDO.getId(), organId);
|
||||
if(CollUtil.isNotEmpty(recordsByPurchaseId)) {
|
||||
// 延期记录是按自增id逆序的,第一条的延期后时间作为产品到期时间
|
||||
purchaseRecordDO.setEndTime(recordsByPurchaseId.get(0).getDelayTime());
|
||||
}
|
||||
return new OrgEarliestPurchaseProductRespVO(purchaseRecordDO);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getInvoicingAmount(Long organId) {
|
||||
return purchaseRecordMapper.getInvoicingAmount(organId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createOrgInitProductPurchaseRecord(Long organId, List<OrganCreateProductPurchaseReqVO> productPurchaseReqVOS) {
|
||||
for (OrganCreateProductPurchaseReqVO purchaseReqVO : productPurchaseReqVOS) {
|
||||
|
||||
+11
-1
@@ -107,6 +107,12 @@ public class PayProductProcessorNew {
|
||||
// 优惠活动id
|
||||
private Long productPromotionId;
|
||||
|
||||
// 赠送时长
|
||||
private Integer giftDuration;
|
||||
|
||||
// 赠送时长单位
|
||||
private Integer giftDurationUnit;
|
||||
|
||||
// 可用的产品优惠活动列表
|
||||
private List<ProductPromotionDO> availableProductPromotionList;
|
||||
|
||||
@@ -174,6 +180,8 @@ public class PayProductProcessorNew {
|
||||
.productDetailsId(productsDetailDO.getId())
|
||||
.purchaseDuration(productsDetailDO.getDuration())
|
||||
.purchaseDurationUnit(productsDetailDO.getDurationUnit())
|
||||
.giftDuration(giftDuration)
|
||||
.giftDurationUnit(giftDurationUnit)
|
||||
.startTime(startTime)
|
||||
.endTime(endTime)
|
||||
.paymentMethod(payType)
|
||||
@@ -301,7 +309,9 @@ public class PayProductProcessorNew {
|
||||
if (availableProductPromotionOpt.isPresent()) {
|
||||
ProductPromotionDO productPromotionDO = availableProductPromotionOpt.get();
|
||||
productPromotionId = productPromotionDO.getId();
|
||||
endTime = addTime(endTime, productPromotionDO.getGiftDuration(), productPromotionDO.getGiftDurationUnit());
|
||||
giftDuration = productPromotionDO.getGiftDuration();
|
||||
giftDurationUnit = productPromotionDO.getGiftDurationUnit();
|
||||
endTime = addTime(endTime, giftDuration, giftDurationUnit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
@@ -1,6 +1,17 @@
|
||||
<?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.funds.purchase.PurchaseRecordMapper">
|
||||
<select id="getInvoicingAmount" resultType="java.math.BigDecimal">
|
||||
SELECT SUM(
|
||||
CASE
|
||||
WHEN initial = TRUE THEN total_amount
|
||||
ELSE account_balance_spent
|
||||
END
|
||||
) AS total_spent
|
||||
FROM purchase_record
|
||||
where organ_id = #{organId} and is_invocing = '${@com.cf.imes.module.system.enums.pay.InvoiceStatusEnum@INVOICABLE.code}' and deleted = false and initial != true;
|
||||
</select>
|
||||
|
||||
<!-- 查询机构下开票金额统计:可开票、开票中、已开票-->
|
||||
<select id="getOrgInvoiceAmountStatistics" resultType="com.cf.imes.module.system.controller.admin.funds.invoice.vo.InvoiceAmountRespVO">
|
||||
SELECT
|
||||
|
||||
Reference in New Issue
Block a user