From 2f8e70ad2884d2b6b7443dfae0af11ae9cfc8b99 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期五, 28 二月 2025 17:44:10 +0800 Subject: [PATCH] bug修改 --- manage/src/main/java/com/jilongda/manage/controller/TAppUserController.java | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 102 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..1222643 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,86 @@ * @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); + // 查询最后消费时间 + TOrder order = orderService.lambdaQuery().eq(TOrder::getUserId, tAppUserVO.getId()) + .orderByDesc(TOrder::getCreateTime).last("limit 1").one(); + if (order!=null){ + tAppUserVO.setSalesTime(order.getCreateTime()); + } + // 查询最后验光时间 + TOptometry optometry = tOptometryService.lambdaQuery().eq(TOptometry::getUserId, tAppUserVO.getId()) + .eq(TOptometry::getStatus, 3).orderByDesc(TOptometry::getCreateTime).last("limit 1").one(); + if (optometry!=null){ + tAppUserVO.setOptometryTime(optometry.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 = "用户详情-查看优惠券") + @PostMapping(value = "/getCouponDetailById") + public ApiResult<PageInfo<TAppUserCouponVO>> getCouponDetailById(@RequestBody TAppUserCouponQuery query) { + PageInfo<TAppUserCouponVO> appUserVOPageInfo = couponReceiveService.pageList(query); + return ApiResult.success(appUserVOPageInfo); + } + + @ApiOperation(value = "用户信息修改") + @PostMapping(value = "/updateUser") + public ApiResult<String> updateUser(@RequestBody TAppUser appUser) { + appUserService.updateById(appUser); + return ApiResult.success(); + } + } -- Gitblit v1.7.1