|
|
@@ -0,0 +1,57 @@
|
|
|
+package com.etotem.cfc.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.etotem.cfc.common.Result;
|
|
|
+import com.etotem.cfc.entity.CfRateTier;
|
|
|
+import com.etotem.cfc.entity.PlatformBalanceLog;
|
|
|
+import com.etotem.cfc.service.CfReferralService;
|
|
|
+import com.etotem.cfc.service.PlatformPointsService;
|
|
|
+import com.etotem.cfc.service.PromotionTierService;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestAttribute;
|
|
|
+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.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/commission/cf")
|
|
|
+public class CfCommissionController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private CfReferralService cfReferralService;
|
|
|
+ @Resource
|
|
|
+ private PlatformPointsService platformPointsService;
|
|
|
+ @Resource
|
|
|
+ private PromotionTierService promotionTierService;
|
|
|
+
|
|
|
+ /** 我的团队规模 + 当前返佣比例 + 档位名 */
|
|
|
+ @PostMapping("/rate")
|
|
|
+ public Result<Map<String, Object>> rate(@RequestAttribute("userId") Long userId) {
|
|
|
+ int teamSize = cfReferralService.getTotalTeamSize(userId);
|
|
|
+ CfRateTier tier = cfReferralService.matchRateTier(teamSize);
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
+ data.put("totalTeamSize", teamSize);
|
|
|
+ data.put("ratePercent", tier == null ? 0 : tier.getRatePercent());
|
|
|
+ data.put("tierName", tier == null ? "未入档" : tier.getTierName());
|
|
|
+ return Result.success(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 我的 CF 钱包汇总 */
|
|
|
+ @PostMapping("/summary")
|
|
|
+ public Result<Map<String, Object>> summary(@RequestAttribute("userId") Long userId) {
|
|
|
+ return Result.success(platformPointsService.getBalance(userId));
|
|
|
+ }
|
|
|
+
|
|
|
+ /** CF 流水(分页) */
|
|
|
+ @PostMapping("/list")
|
|
|
+ public Result<Page<PlatformBalanceLog>> list(@RequestAttribute("userId") Long userId,
|
|
|
+ @RequestBody Map<String, Integer> params) {
|
|
|
+ int page = params.getOrDefault("page", 1);
|
|
|
+ int size = params.getOrDefault("size", 20);
|
|
|
+ return Result.success(platformPointsService.getLogs(userId, page, size));
|
|
|
+ }
|
|
|
+}
|