Parcourir la source

chore: auto bump version and changelog [skip ci]

iwt il y a 1 mois
Parent
commit
f939e9db2f

+ 61 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/CommissionDistController.java

@@ -0,0 +1,61 @@
+package com.etotem.cfc.controller.admin;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.etotem.cfc.common.Result;
+import com.etotem.cfc.entity.CommissionDistLog;
+import com.etotem.cfc.service.CommissionDistService;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * P点分润记录管理
+ * 管理端接口
+ */
+@RestController
+@RequestMapping("/api/admin/commission-dist")
+public class CommissionDistController {
+
+    @Resource
+    private CommissionDistService commissionDistService;
+
+    /**
+     * 分润记录分页列表
+     */
+    @PostMapping("/list")
+    public Result<Page<CommissionDistLog>> list(@RequestBody Map<String, Object> params) {
+        int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
+        int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
+        Long buyerId = params.get("buyerId") != null ? Long.valueOf(params.get("buyerId").toString()) : null;
+        Long levelUserId = params.get("levelUserId") != null ? Long.valueOf(params.get("levelUserId").toString()) : null;
+
+        Page<CommissionDistLog> pageParam = new Page<>(page, size);
+        Page<CommissionDistLog> result = commissionDistService.adminPage(pageParam, buyerId, levelUserId);
+        return Result.success(result);
+    }
+
+    /**
+     * 用户分润记录查询(买家或推荐人)
+     */
+    @PostMapping("/user-logs")
+    public Result<List<CommissionDistLog>> userLogs(@RequestBody Map<String, Object> params) {
+        Long userId = Long.valueOf(params.get("userId").toString());
+        List<CommissionDistLog> logs = commissionDistService.getUserDistLogs(userId, 1, 50);
+        return Result.success(logs);
+    }
+
+    /**
+     * 用户累计获得P点分润
+     */
+    @PostMapping("/user-total")
+    public Result<Integer> userTotal(@RequestBody Map<String, Object> params) {
+        Long userId = Long.valueOf(params.get("userId").toString());
+        int total = commissionDistService.getTotalDistributedPpoint(userId);
+        return Result.success(total);
+    }
+}

+ 158 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/PpointConfigAdminController.java

@@ -0,0 +1,158 @@
+package com.etotem.cfc.controller.admin;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.etotem.cfc.common.Result;
+import com.etotem.cfc.entity.CategoryPpoint;
+import com.etotem.cfc.entity.ProductPpoint;
+import com.etotem.cfc.service.PpointConfigService;
+import com.etotem.cfc.service.PpointService;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * P点配置管理(品类级比例 + 商品级固定值)
+ * 管理端接口
+ */
+@RestController
+@RequestMapping("/api/admin/ppoint-config")
+public class PpointConfigAdminController {
+
+    @Resource
+    private PpointConfigService ppointConfigService;
+
+    @Resource
+    private PpointService ppointService;
+
+    // ======================== 品类级P点比例 ========================
+
+    @PostMapping("/category/list")
+    public Result<Map<String, Object>> categoryList(@RequestBody Map<String, Object> params) {
+        int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
+        int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
+        String keyword = (String) params.get("keyword");
+
+        Page<CategoryPpoint> pageParam = new Page<>(page, size);
+        Map<String, Object> result = ppointConfigService.adminCategoryList(pageParam, keyword);
+        return Result.success(result);
+    }
+
+    @PostMapping("/category/save")
+    public Result<Void> categorySave(@RequestBody Map<String, Object> params) {
+        Long categoryId = Long.valueOf(params.get("categoryId").toString());
+        Integer ratio = Integer.valueOf(params.get("ratio").toString());
+        String startDateStr = (String) params.get("startDate");
+        String endDateStr = (String) params.get("endDate");
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        java.util.Date startDate = null;
+        java.util.Date endDate = null;
+        try {
+            if (startDateStr != null && !startDateStr.isEmpty()) {
+                startDate = sdf.parse(startDateStr);
+            }
+            if (endDateStr != null && !endDateStr.isEmpty()) {
+                endDate = sdf.parse(endDateStr);
+            }
+        } catch (Exception e) {
+            return Result.error("日期格式错误,请使用yyyy-MM-dd");
+        }
+
+        if (ratio < 0 || ratio > 1000) {
+            return Result.error("P点比例取值范围为0-1000(即0%-100%)");
+        }
+
+        ppointConfigService.saveCategoryRatio(categoryId, ratio, startDate, endDate, null);
+        return Result.success(null);
+    }
+
+    @PostMapping("/category/delete")
+    public Result<Void> categoryDelete(@RequestBody Map<String, Object> params) {
+        Long id = Long.valueOf(params.get("id").toString());
+        ppointConfigService.deleteCategoryRatio(id);
+        return Result.success(null);
+    }
+
+    @PostMapping("/category/by-category")
+    public Result<List<CategoryPpoint>> categoryByCategory(@RequestBody Map<String, Object> params) {
+        Long categoryId = Long.valueOf(params.get("categoryId").toString());
+        List<CategoryPpoint> records = ppointConfigService.getByCategoryId(categoryId);
+        return Result.success(records);
+    }
+
+    // ======================== 商品级P点(复用PpointService) ========================
+
+    @PostMapping("/product/list")
+    public Result<Map<String, Object>> productList(@RequestBody Map<String, Object> params) {
+        int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
+        int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
+        String keyword = (String) params.get("keyword");
+        Long productId = params.get("productId") != null ? Long.valueOf(params.get("productId").toString()) : null;
+
+        Page<ProductPpoint> pageParam = new Page<>(page, size);
+        Map<String, Object> result = ppointService.adminList(pageParam, keyword, productId);
+        return Result.success(result);
+    }
+
+    @PostMapping("/product/save")
+    public Result<Void> productSave(@RequestBody Map<String, Object> params) {
+        Long productId = Long.valueOf(params.get("productId").toString());
+        Integer ppoint = Integer.valueOf(params.get("ppoint").toString());
+        String startDateStr = (String) params.get("startDate");
+        String endDateStr = (String) params.get("endDate");
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        java.util.Date startDate = null;
+        java.util.Date endDate = null;
+        try {
+            if (startDateStr != null && !startDateStr.isEmpty()) {
+                startDate = sdf.parse(startDateStr);
+            }
+            if (endDateStr != null && !endDateStr.isEmpty()) {
+                endDate = sdf.parse(endDateStr);
+            }
+        } catch (Exception e) {
+            return Result.error("日期格式错误,请使用yyyy-MM-dd");
+        }
+
+        if (ppoint < 0 || ppoint > 10000) {
+            return Result.error("P点取值范围为0-10000(即0%-100%)");
+        }
+
+        ppointService.savePpoint(productId, ppoint, startDate, endDate, null);
+        return Result.success(null);
+    }
+
+    @PostMapping("/product/delete")
+    public Result<Void> productDelete(@RequestBody Map<String, Object> params) {
+        Long id = Long.valueOf(params.get("id").toString());
+        ppointService.deleteById(id);
+        return Result.success(null);
+    }
+
+    @PostMapping("/product/by-product")
+    public Result<List<ProductPpoint>> productByProduct(@RequestBody Map<String, Object> params) {
+        Long productId = Long.valueOf(params.get("productId").toString());
+        List<ProductPpoint> records = ppointService.getByProductId(productId);
+        return Result.success(records);
+    }
+
+    // ======================== 综合查询 ========================
+
+    /**
+     * 获取商品综合有效的P点值
+     */
+    @PostMapping("/effective")
+    public Result<Integer> getEffectivePpoint(@RequestBody Map<String, Object> params) {
+        Long productId = Long.valueOf(params.get("productId").toString());
+        Long categoryId = params.get("categoryId") != null ? Long.valueOf(params.get("categoryId").toString()) : null;
+        int ppoint = ppointConfigService.getEffectivePpoint(productId, categoryId);
+        return Result.success(ppoint);
+    }
+}

+ 19 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/PromotionTierService.java

@@ -3,7 +3,9 @@ package com.etotem.cfc.service;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.etotem.cfc.entity.PromotionTier;
 import com.etotem.cfc.entity.PromotionTierChangeLog;
+import com.etotem.cfc.entity.PromotionTierConfig;
 import com.etotem.cfc.mapper.PromotionTierChangeLogMapper;
+import com.etotem.cfc.mapper.PromotionTierConfigMapper;
 import com.etotem.cfc.mapper.PromotionTierMapper;
 import org.springframework.stereotype.Service;
 
@@ -20,6 +22,9 @@ public class PromotionTierService {
     @Resource
     private PromotionTierChangeLogMapper changeLogMapper;
 
+    @Resource
+    private PromotionTierConfigMapper tierConfigMapper;
+
     /**
      * 获取用户当前推广等级
      */
@@ -39,6 +44,20 @@ public class PromotionTierService {
         return tierMapper.selectList(null);
     }
 
+    /**
+     * 按等级代码获取等级配置(含profitSharePercent P点比例)
+     * @param tierCode 等级代码: R0/R1/R2/R3/R4
+     * @return 等级配置,未找到返回null
+     */
+    public PromotionTierConfig getTierConfig(String tierCode) {
+        if (tierCode == null) return null;
+        return tierConfigMapper.selectOne(
+                new LambdaQueryWrapper<PromotionTierConfig>()
+                        .eq(PromotionTierConfig::getTierCode, tierCode)
+                        .last("LIMIT 1")
+        );
+    }
+
     /**
      * 更新团队规模(当有新推荐人加入时调用)
      */

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-e2aaac96e77a769a373e642b4f4b6222adb762f0
+5b28e0ffb7e494f619d8f4d2fb6af5dd37f481e3

+ 2 - 2
cfc-web/package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "cfc-web",
-  "version": "1.0.607",
+  "version": "1.0.608",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "cfc-web",
-      "version": "1.0.607",
+      "version": "1.0.608",
       "dependencies": {
         "@wangeditor/editor": "^5.1.23",
         "@wangeditor/editor-for-vue": "^1.0.2",