Просмотр исходного кода

fix: add missing PpointService for CommissionService compilation

iwt 2 месяцев назад
Родитель
Сommit
026ed3f77d
1 измененных файлов с 12 добавлено и 12 удалено
  1. 12 12
      cfc-backend/src/main/java/com/etotem/cfc/service/PpointService.java

+ 12 - 12
cfc-backend/src/main/java/com/etotem/cfc/service/PpointService.java

@@ -15,22 +15,22 @@ public class PpointService {
     private ProductPpointMapper productPpointMapper;
     private ProductPpointMapper productPpointMapper;
 
 
     /**
     /**
-     * 获取产品当前生效的P-point值
-     * 查询 date-valid 记录(startDate <= now <= endDate),按 ppoint DESC 取第一条
-     * 如果没有生效记录返回 0
+     * 获取商品当前生效的 P-point(利润点数)
+     * 从 product_ppoint 表查询日期范围内有效的配置,未配置则返回 0
      */
      */
     public int getEffectivePpoint(Long productId) {
     public int getEffectivePpoint(Long productId) {
         if (productId == null) {
         if (productId == null) {
             return 0;
             return 0;
         }
         }
         Date now = new Date();
         Date now = new Date();
-        LambdaQueryWrapper<ProductPpoint> wrapper = new LambdaQueryWrapper<ProductPpoint>()
-                .eq(ProductPpoint::getProductId, productId)
-                .le(ProductPpoint::getStartDate, now)
-                .ge(ProductPpoint::getEndDate, now)
-                .orderByDesc(ProductPpoint::getPpoint)
-                .last("LIMIT 1");
-        ProductPpoint record = productPpointMapper.selectOne(wrapper);
-        return record != null && record.getPpoint() != null ? record.getPpoint() : 0;
+        ProductPpoint pp = productPpointMapper.selectOne(
+                new LambdaQueryWrapper<ProductPpoint>()
+                        .eq(ProductPpoint::getProductId, productId)
+                        .le(ProductPpoint::getStartDate, now)
+                        .ge(ProductPpoint::getEndDate, now)
+                        .orderByDesc(ProductPpoint::getCreatedAt)
+                        .last("LIMIT 1")
+        );
+        return pp != null ? pp.getPpoint() : 0;
     }
     }
-}
+}