From 8d0c63d2f96cc31dd45581ac21b8c900c200e134 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期五, 27 十二月 2024 16:44:35 +0800 Subject: [PATCH] 验光师 --- manage/src/main/java/com/jilongda/manage/controller/TOrderController.java | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 118 insertions(+), 2 deletions(-) diff --git a/manage/src/main/java/com/jilongda/manage/controller/TOrderController.java b/manage/src/main/java/com/jilongda/manage/controller/TOrderController.java index ebffdbd..9a6a437 100644 --- a/manage/src/main/java/com/jilongda/manage/controller/TOrderController.java +++ b/manage/src/main/java/com/jilongda/manage/controller/TOrderController.java @@ -1,9 +1,28 @@ package com.jilongda.manage.controller; -import org.springframework.web.bind.annotation.RequestMapping; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.jilongda.common.basic.ApiResult; +import com.jilongda.common.basic.PageInfo; +import com.jilongda.manage.authority.model.SecUser; +import com.jilongda.manage.authority.service.SecUserService; +import com.jilongda.manage.dto.TOrderDTO; +import com.jilongda.manage.model.*; +import com.jilongda.manage.query.TOptometryQuery; +import com.jilongda.manage.service.*; +import com.jilongda.manage.utils.LoginInfoUtil; +import com.jilongda.manage.vo.TOptometryVO; +import com.jilongda.manage.vo.TOrderVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; -import org.springframework.web.bind.annotation.RestController; +import java.util.*; +import java.util.stream.Collectors; /** * <p> @@ -13,9 +32,106 @@ * @author 无关风月 * @since 2024-12-09 */ +@Api(tags = "销售订单") @RestController @RequestMapping("/t-order") public class TOrderController { + @Autowired + private TAppUserService tAppUserService; + @Autowired + private SecUserService secUserService; + @Autowired + private TCouponReceiveService couponReceiveService; + @Autowired + private TCouponService couponService; + @Autowired + private TOrderService orderService; + @Autowired + private TOptometryDetailService optometryDetailService; + @Autowired + private TOrderGoodsService orderGoodsService; + @Autowired + private TFrameGoodsService frameGoodsService; + @Autowired + private TLensGoodsService lensGoodsService; + @ApiOperation(value = "查询用户信息") + @GetMapping(value = "/getUserById") + public ApiResult getUserById(@RequestParam Integer userId) { + return ApiResult.success(tAppUserService.getById(userId)); + } + + @ApiOperation(value = "查询员工信息") + @GetMapping(value = "/getStaffList") + public ApiResult getStaffList() { + List<SecUser> list = secUserService.list(Wrappers.lambdaQuery(SecUser.class) + .eq(SecUser::getUserType, 3) + .eq(SecUser::getIsDelete, 0)); + return ApiResult.success(list); + } + + @ApiOperation(value = "查询优惠券") + @GetMapping(value = "/getCouponListByUserId") + public ApiResult<List<TCouponReceive>> getCouponListByUserId(@RequestParam Integer userId, @RequestParam Integer storeId) { + List<TCouponReceive> list = couponReceiveService.list(Wrappers.lambdaQuery(TCouponReceive.class) + .eq(TCouponReceive::getUserId, userId) + .eq(TCouponReceive::getStatus, 1)); + List<TCouponReceive> tCouponReceives = new ArrayList<>(); + for (TCouponReceive tCouponReceive : list) { + TCoupon byId = couponService.getById(tCouponReceive.getCouponId()); + tCouponReceive.setCouponName(byId.getName()); + if (StringUtils.hasLength(tCouponReceive.getStoreId())){ + if (Arrays.asList(tCouponReceive.getStoreId().split(",")).contains(storeId+"")){ + tCouponReceives.add(tCouponReceive); + } + }else{ + // 通用 + tCouponReceives.add(tCouponReceive); + } + } + + return ApiResult.success(tCouponReceives); + } + + @ApiOperation(value = "添加订单") + @PostMapping(value = "/addOrder") + public ApiResult addOrder(@RequestBody TOrderDTO dto) { + + // 查询店员 + SecUser user = secUserService.getById(dto.getSysId()); + if(Objects.nonNull(user)){ + dto.setStoreId(user.getStoreId()); + } + orderService.save(dto); + List<TOptometryDetail> optometryDetails = dto.getOptometryDetails(); + if (!CollectionUtils.isEmpty(optometryDetails)){ + for (TOptometryDetail optometryDetail : optometryDetails) { + optometryDetail.setOrderId(dto.getId()); + } + optometryDetailService.saveBatch(optometryDetails); + } + List<TOrderGoods> orderGoods = dto.getOrderGoods(); + for (TOrderGoods orderGood : orderGoods) { + orderGood.setOrderId(dto.getId()); + } + // TODO 周哥 补库存 + + return ApiResult.success(); + } + + @ApiOperation(value = "销售订单详情") + @GetMapping(value = "/getOrderDetailById") + public ApiResult getOrderDetailById(@RequestParam Integer orderId) { + + TOrderVO orderVO = orderService.getOrderDetailById(orderId); + + // TODO 周哥 商品信息集合 + + // TODO 周哥 验光处方 判断是关联或者手动 + + + return ApiResult.success(orderVO); + } + } -- Gitblit v1.7.1