From 7bebbf990850862c2d498f4deb18987931558d72 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期三, 25 十二月 2024 14:52:32 +0800
Subject: [PATCH] 门店
---
manage/src/main/java/com/jilongda/manage/controller/TAppUserController.java | 90 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 88 insertions(+), 2 deletions(-)
diff --git a/manage/src/main/java/com/jilongda/manage/controller/TAppUserController.java b/manage/src/main/java/com/jilongda/manage/controller/TAppUserController.java
index 366dd41..262af59 100644
--- a/manage/src/main/java/com/jilongda/manage/controller/TAppUserController.java
+++ b/manage/src/main/java/com/jilongda/manage/controller/TAppUserController.java
@@ -1,9 +1,31 @@
package com.jilongda.manage.controller;
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.jilongda.common.basic.ApiResult;
+import com.jilongda.common.basic.PageInfo;
+import com.jilongda.manage.model.TAppUser;
+import com.jilongda.manage.model.TCouponReceive;
+import com.jilongda.manage.model.TOptometry;
+import com.jilongda.manage.model.TOrder;
+import com.jilongda.manage.query.TAppUserCouponQuery;
+import com.jilongda.manage.query.TAppUserQuery;
+import com.jilongda.manage.query.TOptometristQuery;
+import com.jilongda.manage.service.TAppUserService;
+import com.jilongda.manage.service.TCouponReceiveService;
+import com.jilongda.manage.service.TOptometryService;
+import com.jilongda.manage.service.TOrderService;
+import com.jilongda.manage.vo.TAppUserCouponVO;
+import com.jilongda.manage.vo.TAppUserVO;
+import com.jilongda.manage.vo.TOptometristVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
-import org.springframework.web.bind.annotation.RestController;
+import javax.annotation.Resource;
+import java.math.BigDecimal;
/**
* <p>
@@ -14,8 +36,72 @@
* @since 2024-12-09
*/
@RestController
+@Api(tags = "用户管理")
@RequestMapping("/t-app-user")
public class TAppUserController {
+ @Resource
+ private TAppUserService appUserService;
+ @Resource
+ private TOrderService orderService;
+ @Resource
+ private TOptometryService tOptometryService;
+ @Resource
+ private TCouponReceiveService couponReceiveService;
+ @ApiOperation(value = "用户列表")
+ @PostMapping(value = "/pageList")
+ public ApiResult<PageInfo<TAppUserVO>> pageList(@RequestBody TAppUserQuery query) {
+ if (StringUtils.hasLength(query.getStartTime())){
+ query.setStartTime(query.getStartTime()+" 00:00:00");
+ query.setEndTime(query.getEndTime()+" 23:59:59");
+ }
+ PageInfo<TAppUserVO> appUserVOPageInfo = appUserService.pageList(query);
+ return ApiResult.success(appUserVOPageInfo);
+ }
+ @ApiOperation(value = "启用/禁用")
+ @GetMapping(value = "/updateState")
+ public ApiResult updateState(Integer id) {
+ TAppUser byId = appUserService.getById(id);
+ if (byId.getStatus()==1){
+ byId.setStatus(2);
+ }else{
+ byId.setStatus(1);
+ }
+ appUserService.updateById(byId);
+ return ApiResult.success();
+ }
+ @ApiOperation(value = "用户详情")
+ @GetMapping(value = "/getDetailById")
+ public ApiResult<TAppUserVO> getDetailById(Integer id) {
+ TAppUser byId = appUserService.getById(id);
+ TAppUserVO tAppUserVO = new TAppUserVO();
+ BeanUtils.copyProperties(byId, tAppUserVO);
+ // 查询消费次数
+ long l = orderService.count(new LambdaQueryWrapper<TOrder>()
+ .eq(TOrder::getUserId, tAppUserVO.getId()));
+ tAppUserVO.setSalesCount((int) l);
+ // 查询验光次数
+ int size = tOptometryService.lambdaQuery().eq(TOptometry::getUserId, tAppUserVO.getId())
+ .eq(TOptometry::getStatus, 3).list().size();
+ tAppUserVO.setOptometryCount(size);
+ // 查询最后消费时间
+ tAppUserVO.setSalesTime(orderService.lambdaQuery().eq(TOrder::getUserId, tAppUserVO.getId())
+ .orderByDesc(TOrder::getCreateTime).last("limit 1").one().getCreateTime());
+ // 查询最后验光时间
+ tAppUserVO.setOptometryTime(tOptometryService.lambdaQuery().eq(TOptometry::getUserId, tAppUserVO.getId())
+ .eq(TOptometry::getStatus, 3).orderByDesc(TOptometry::getCreateTime).last("limit 1").one().getCreateTime());
+ // 查询订单总额
+ BigDecimal reduce = orderService.lambdaQuery().eq(TOrder::getUserId, byId.getId()).list().stream().map(TOrder::getPayMoney)
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+ tAppUserVO.setSalesAmount(reduce);
+
+ return ApiResult.success(tAppUserVO);
+ }
+ @ApiOperation(value = "用户详情-查看优惠券")
+ @GetMapping(value = "/getCouponDetailById")
+ public ApiResult<PageInfo<TAppUserCouponVO>> getCouponDetailById(@RequestBody TAppUserCouponQuery query) {
+ PageInfo<TAppUserCouponVO> appUserVOPageInfo = couponReceiveService.pageList(query);
+ return ApiResult.success(appUserVOPageInfo);
+ }
}
--
Gitblit v1.7.1