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

fix: PpointService null date handling + adminList keyword filter; ProductPpointManage effectiveDate→startDate field name fix

Xiaogang Liao 2 месяцев назад
Родитель
Сommit
dc0e1d311a

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

@@ -43,11 +43,11 @@ public class PpointService {
 
         Date now = new Date();
 
-        // Check product_ppoint table for a date-valid record
+        // Check product_ppoint table for a date-valid record (startDate <= now AND (endDate is null OR endDate >= now))
         LambdaQueryWrapper<ProductPpoint> wrapper = new LambdaQueryWrapper<ProductPpoint>()
                 .eq(ProductPpoint::getProductId, productId)
                 .le(ProductPpoint::getStartDate, now)
-                .ge(ProductPpoint::getEndDate, now)
+                .and(w -> w.isNull(ProductPpoint::getEndDate).or().ge(ProductPpoint::getEndDate, now))
                 .orderByDesc(ProductPpoint::getStartDate)
                 .last("LIMIT 1");
         ProductPpoint record = productPpointMapper.selectOne(wrapper);
@@ -56,10 +56,9 @@ public class PpointService {
             return record.getPpoint();
         }
 
-        // Fallback to Product.profitRate
+        // Fallback to Product.profitRate (千分比 → 基点: *100)
         Product product = productMapper.selectById(productId);
         if (product != null && product.getProfitRate() != null) {
-            // Convert profitRate (percentage-based, e.g. 10 = 10%) to basis points (1000 = 10%)
             return product.getProfitRate() * 100;
         }
 
@@ -126,6 +125,27 @@ public class PpointService {
         Page<ProductPpoint> page = productPpointMapper.selectPage(pageParam, wrapper);
         List<ProductPpoint> records = page.getRecords();
 
+        // Filter by keyword (product name) in memory
+        if (keyword != null && !keyword.trim().isEmpty()) {
+            String kw = keyword.trim().toLowerCase();
+            List<Long> matchedIds = records.stream()
+                    .map(ProductPpoint::getProductId)
+                    .distinct()
+                    .collect(Collectors.toList());
+            if (!matchedIds.isEmpty()) {
+                List<Product> products = productMapper.selectBatchIds(matchedIds);
+                List<Long> filterIds = products.stream()
+                        .filter(p -> p.getName() != null && p.getName().toLowerCase().contains(kw))
+                        .map(Product::getId)
+                        .collect(Collectors.toList());
+                records = records.stream()
+                        .filter(r -> filterIds.contains(r.getProductId()))
+                        .collect(Collectors.toList());
+            } else {
+                records = new java.util.ArrayList<>();
+            }
+        }
+
         Map<Long, Product> productMap = new HashMap<>();
         if (!records.isEmpty()) {
             List<Long> productIds = records.stream()

+ 7 - 7
cfc-web/src/api/admin.js

@@ -1038,7 +1038,7 @@ export function getSupplySystemList(params) {
   return request({
     url: '/api/admin/supply-system/list',
     method: 'post',
-    data: params || {}
+    params: params || {}
   })
 }
 
@@ -1046,7 +1046,7 @@ export function getSupplySystemDetail(id) {
   return request({
     url: '/api/admin/supply-system/detail',
     method: 'post',
-    data: { id }
+    params: { id }
   })
 }
 
@@ -1070,7 +1070,7 @@ export function toggleSupplySystemStatus(id) {
   return request({
     url: '/api/admin/supply-system/toggle-status',
     method: 'post',
-    data: { id }
+    params: { id }
   })
 }
 
@@ -1085,7 +1085,7 @@ export function getSupplySystemMembers(systemId) {
   return request({
     url: '/api/admin/supply-system/member/list',
     method: 'post',
-    data: { systemId }
+    params: { systemId }
   })
 }
 
@@ -1093,7 +1093,7 @@ export function addSupplySystemMember(systemId, userId) {
   return request({
     url: '/api/admin/supply-system/member/add',
     method: 'post',
-    data: { systemId, userId }
+    params: { systemId, userId }
   })
 }
 
@@ -1101,7 +1101,7 @@ export function removeSupplySystemMember(memberId) {
   return request({
     url: '/api/admin/supply-system/member/remove',
     method: 'post',
-    data: { memberId }
+    params: { memberId }
   })
 }
 
@@ -1109,7 +1109,7 @@ export function changeSupplySystemMemberRole(memberId, role) {
   return request({
     url: '/api/admin/supply-system/member/change-role',
     method: 'post',
-    data: { memberId, role }
+    params: { memberId, role }
   })
 }
 

+ 2 - 1
cfc-web/src/main.js

@@ -11,7 +11,7 @@ import {
   Progress, Container, Header, Aside, Main, Avatar, Scrollbar, Divider,
   Tab, Badge, Tree, ColorPicker, Tooltip, Popover,
   Slider, InputNumber, Link,
-  MessageBox
+  MessageBox, Message
 } from 'element-ui'
 import 'element-ui/lib/theme-chalk/index.css'
 import './styles/admin-tokens.css'
@@ -74,6 +74,7 @@ Vue.use(Link)
 Vue.prototype.$confirm = MessageBox.confirm
 Vue.prototype.$alert = MessageBox.alert
 Vue.prototype.$prompt = MessageBox.prompt
+Vue.prototype.$message = Message
 
 Vue.prototype.formatPrice = formatPrice
 Vue.prototype.formatPriceWithSymbol = formatPriceWithSymbol

+ 8 - 8
cfc-web/src/views/admin/ProductPpointManage.vue

@@ -44,13 +44,13 @@
       </el-table-column>
       <el-table-column label="生效日期" width="100">
         <template slot-scope="{ row }">
-          {{ row.effectiveDate || '-' }}
+          {{ row.startDate || '-' }}
         </template>
       </el-table-column>
       <el-table-column label="状态" width="80">
         <template slot-scope="{ row }">
-          <el-tag v-if="row.effectiveDate" :type="isEffectived(row.effectiveDate) ? 'success' : 'warning'" size="small">
-            {{ isEffectived(row.effectiveDate) ? '生效中' : '待生效' }}
+          <el-tag v-if="row.startDate" :type="isEffectived(row.startDate) ? 'success' : 'warning'" size="small">
+            {{ isEffectived(row.startDate) ? '生效中' : '待生效' }}
           </el-tag>
           <span v-else>-</span>
         </template>
@@ -94,7 +94,7 @@
           <div style="color:#999;font-size:12px;margin-top:4px;">10000 bps = 100%,例:1000 bps = 10%</div>
         </el-form-item>
         <el-form-item label="生效日期">
-          <el-date-picker v-model="addForm.effectiveDate" type="date" placeholder="选择日期" value-format="yyyy-MM-dd" style="width: 100%;" />
+          <el-date-picker v-model="addForm.startDate" type="date" placeholder="选择日期" value-format="yyyy-MM-dd" style="width: 100%;" />
         </el-form-item>
       </el-form>
       <div slot="footer">
@@ -123,7 +123,7 @@ export default {
       addForm: {
         productId: null,
         ppoint: 0,
-        effectiveDate: ''
+        startDate: ''
       },
       productOptions: []
     }
@@ -188,7 +188,7 @@ export default {
     },
     async openAddDialog() {
       this.addDialogVisible = true
-      this.addForm = { productId: null, ppoint: 0, effectiveDate: '' }
+      this.addForm = { productId: null, ppoint: 0, startDate: '' }
       try {
         const res = await getProductList({ status: 'online', keyword: '', productType: '' })
         this.productOptions = res.data || []
@@ -199,12 +199,12 @@ export default {
     async submitAdd() {
       if (!this.addForm.productId) return this.$message.warning('请选择商品')
       if (!this.addForm.ppoint && this.addForm.ppoint !== 0) return this.$message.warning('请设置P点')
-      if (!this.addForm.effectiveDate) return this.$message.warning('请选择生效日期')
+      if (!this.addForm.startDate) return this.$message.warning('请选择生效日期')
       try {
         await saveProductPpoint({
           productId: this.addForm.productId,
           ppoint: this.addForm.ppoint,
-          effectiveDate: this.addForm.effectiveDate
+          startDate: this.addForm.startDate
         })
         this.$message.success('添加成功')
         this.addDialogVisible = false