|
|
@@ -0,0 +1,173 @@
|
|
|
+package com.etotem.cfc.controller.admin;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.etotem.cfc.common.Result;
|
|
|
+import com.etotem.cfc.entity.ButlerCommissionSettlement;
|
|
|
+import com.etotem.cfc.entity.ButlerProfile;
|
|
|
+import com.etotem.cfc.entity.ButlerServiceRecord;
|
|
|
+import com.etotem.cfc.mapper.ButlerCommissionSettlementMapper;
|
|
|
+import com.etotem.cfc.mapper.ButlerProfileMapper;
|
|
|
+import com.etotem.cfc.mapper.ButlerServiceRecordMapper;
|
|
|
+import com.etotem.cfc.service.ButlerService;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/admin/butler")
|
|
|
+public class AdminButlerController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ButlerService butlerService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ButlerProfileMapper butlerProfileMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ButlerServiceRecordMapper butlerServiceRecordMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ButlerCommissionSettlementMapper butlerCommissionSettlementMapper;
|
|
|
+
|
|
|
+ @PostMapping("/list")
|
|
|
+ public Result<Map<String, Object>> list(@RequestBody Map<String, Object> params,
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
+ return Result.error("权限不足");
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 status = (String) params.get("status");
|
|
|
+ String tier = (String) params.get("tier");
|
|
|
+
|
|
|
+ Page<ButlerProfile> pageParam = new Page<>(page, size);
|
|
|
+ LambdaQueryWrapper<ButlerProfile> wrapper = new LambdaQueryWrapper<>();
|
|
|
+
|
|
|
+ if (status != null && !status.isEmpty()) {
|
|
|
+ wrapper.eq(ButlerProfile::getStatus, status);
|
|
|
+ }
|
|
|
+ if (tier != null && !tier.isEmpty()) {
|
|
|
+ wrapper.eq(ButlerProfile::getTier, tier);
|
|
|
+ }
|
|
|
+ wrapper.orderByDesc(ButlerProfile::getCreatedAt);
|
|
|
+
|
|
|
+ Page<ButlerProfile> result = butlerProfileMapper.selectPage(pageParam, wrapper);
|
|
|
+
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
+ data.put("list", result.getRecords());
|
|
|
+ data.put("total", result.getTotal());
|
|
|
+ data.put("page", page);
|
|
|
+ data.put("size", size);
|
|
|
+ return Result.success(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/review")
|
|
|
+ public Result<String> review(@RequestBody Map<String, Object> params,
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
+ return Result.error("权限不足");
|
|
|
+ }
|
|
|
+
|
|
|
+ Long userId = params.get("userId") != null
|
|
|
+ ? Long.valueOf(params.get("userId").toString())
|
|
|
+ : null;
|
|
|
+ String action = (String) params.get("action");
|
|
|
+ String reason = (String) params.getOrDefault("reason", "");
|
|
|
+
|
|
|
+ if (userId == null) {
|
|
|
+ return Result.error("userId不能为空");
|
|
|
+ }
|
|
|
+ if (action == null || (!"approve".equals(action) && !"reject".equals(action))) {
|
|
|
+ return Result.error("action必须为 approve 或 reject");
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("approve".equals(action)) {
|
|
|
+ return butlerService.approve(userId, null);
|
|
|
+ } else {
|
|
|
+ return butlerService.reject(userId, reason);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/assign-member")
|
|
|
+ public Result<String> assignMember(@RequestBody Map<String, Object> params,
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
+ return Result.error("权限不足");
|
|
|
+ }
|
|
|
+
|
|
|
+ Long profileId = params.get("profileId") != null
|
|
|
+ ? Long.valueOf(params.get("profileId").toString())
|
|
|
+ : null;
|
|
|
+ Long memberId = params.get("memberId") != null
|
|
|
+ ? Long.valueOf(params.get("memberId").toString())
|
|
|
+ : null;
|
|
|
+
|
|
|
+ if (profileId == null || memberId == null) {
|
|
|
+ return Result.error("profileId和memberId不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ return butlerService.assignMemberToButler(profileId, memberId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/service-records")
|
|
|
+ public Result<Map<String, Object>> serviceRecords(@RequestBody Map<String, Object> params,
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
+ return Result.error("权限不足");
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 serviceType = (String) params.get("serviceType");
|
|
|
+
|
|
|
+ Page<ButlerServiceRecord> pageParam = new Page<>(page, size);
|
|
|
+ LambdaQueryWrapper<ButlerServiceRecord> wrapper = new LambdaQueryWrapper<>();
|
|
|
+
|
|
|
+ if (serviceType != null && !serviceType.isEmpty()) {
|
|
|
+ wrapper.eq(ButlerServiceRecord::getServiceType, serviceType);
|
|
|
+ }
|
|
|
+ wrapper.orderByDesc(ButlerServiceRecord::getCreatedAt);
|
|
|
+
|
|
|
+ Page<ButlerServiceRecord> result = butlerServiceRecordMapper.selectPage(pageParam, wrapper);
|
|
|
+
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
+ data.put("list", result.getRecords());
|
|
|
+ data.put("total", result.getTotal());
|
|
|
+ data.put("page", page);
|
|
|
+ data.put("size", size);
|
|
|
+ return Result.success(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/settlements")
|
|
|
+ public Result<Map<String, Object>> settlements(@RequestBody Map<String, Object> params,
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
+ return Result.error("权限不足");
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 status = (String) params.get("status");
|
|
|
+
|
|
|
+ Page<ButlerCommissionSettlement> pageParam = new Page<>(page, size);
|
|
|
+ LambdaQueryWrapper<ButlerCommissionSettlement> wrapper = new LambdaQueryWrapper<>();
|
|
|
+
|
|
|
+ if (status != null && !status.isEmpty()) {
|
|
|
+ wrapper.eq(ButlerCommissionSettlement::getStatus, status);
|
|
|
+ }
|
|
|
+ wrapper.orderByDesc(ButlerCommissionSettlement::getCreatedAt);
|
|
|
+
|
|
|
+ Page<ButlerCommissionSettlement> result = butlerCommissionSettlementMapper.selectPage(pageParam, wrapper);
|
|
|
+
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
+ data.put("list", result.getRecords());
|
|
|
+ data.put("total", result.getTotal());
|
|
|
+ data.put("page", page);
|
|
|
+ data.put("size", size);
|
|
|
+ return Result.success(data);
|
|
|
+ }
|
|
|
+}
|