From 5bf555c8a948545591b10170c9a3b30883e25f20 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Fri, 27 Sep 2024 11:39:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=94=AF=E6=8C=81=E5=A4=87?= =?UTF-8?q?=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/product/TbPlaceController.java | 116 +++++------------- .../cashier/dto/shoptable/UpdateCartDTO.java | 1 + .../impl/shopimpl/TbShopTableServiceImpl.java | 1 + 3 files changed, 31 insertions(+), 87 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java index a8941fc1..948c1000 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java @@ -2,58 +2,42 @@ package cn.ysk.cashier.controller.product; import cn.ysk.cashier.annotation.AnonymousAccess; import cn.ysk.cashier.annotation.Log; -import cn.ysk.cashier.cons.rabbit.RabbitConstants; import cn.ysk.cashier.dto.shoptable.*; import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.service.product.TbProductService; import cn.ysk.cashier.service.shop.TbShopTableService; import cn.ysk.cashier.utils.RabbitMsgUtils; -import com.alibaba.fastjson.JSONObject; import io.swagger.annotations.ApiOperation; -import org.springframework.amqp.rabbit.connection.CorrelationData; -import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.validation.Validator; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; -import java.util.UUID; @RestController @RequestMapping("/api/place") public class TbPlaceController { - private final TbShopTableService tbShopTableService; - private final TbProductService tbProductService; - private final Validator validator; private final RabbitMsgUtils rabbitMsgUtils; - - @AnonymousAccess @GetMapping("/activate") @ApiOperation("查询/product") - public ResponseEntity queryActivateTbProductInfo( - @RequestParam(defaultValue = "0") Integer page, - @RequestParam(defaultValue = "30") Integer size, - @RequestParam(required = false) Integer categoryId, - @RequestParam Integer shopId, - @RequestParam(required = false) Integer productId - ) { + public ResponseEntity queryActivateTbProductInfo(@RequestParam(defaultValue = "0") Integer page, + @RequestParam(defaultValue = "30") Integer size, + @RequestParam(required = false) Integer categoryId, + @RequestParam Integer shopId, + @RequestParam(required = false) Integer productId) { return new ResponseEntity<>(tbProductService.activateProduct(page, size, categoryId, shopId, productId), HttpStatus.OK); } - public TbPlaceController(TbShopTableService tbShopTableService, TbProductService tbProductService, Validator validator, RabbitTemplate rabbitTemplate, RabbitMsgUtils rabbitMsgUtils) { + public TbPlaceController(TbShopTableService tbShopTableService, TbProductService tbProductService,RabbitMsgUtils rabbitMsgUtils) { this.tbShopTableService = tbShopTableService; this.tbProductService = tbProductService; - this.validator = validator; - this.rabbitTemplate = rabbitTemplate; this.rabbitMsgUtils = rabbitMsgUtils; } - @AnonymousAccess @PostMapping("/addCart") @Log("代客下单:#addCartDTO.tableId") @ApiOperation("代客下单/shop/table") @@ -61,7 +45,6 @@ public class TbPlaceController { return ResponseEntity.ok(tbShopTableService.addCartForUser(addCartDTO)); } - @AnonymousAccess @PutMapping("/choseModel") @Log("代客下单:#addCartDTO.tableId") @ApiOperation("代客下单/shop/table") @@ -69,7 +52,6 @@ public class TbPlaceController { return ResponseEntity.ok(tbShopTableService.choseModel(choseModelDTO)); } - @AnonymousAccess @PutMapping("/updateCart") @Log("代客下单") @ApiOperation("代客下单/shop/table") @@ -77,7 +59,6 @@ public class TbPlaceController { return ResponseEntity.ok(tbShopTableService.updateCart(updateCartDTO)); } - @AnonymousAccess @PutMapping("/pack") @Log("代客下单") @ApiOperation("代客下单/shop/table") @@ -86,7 +67,6 @@ public class TbPlaceController { return ResponseEntity.ok(null); } - @AnonymousAccess @DeleteMapping("/removeCart") @Log("代客下单 删除购物车商品") @ApiOperation("代客下单 清空购物车 /shop/table") @@ -95,7 +75,6 @@ public class TbPlaceController { return new ResponseEntity<>(HttpStatus.OK); } - @AnonymousAccess @PutMapping("/returnCart") @Log("代客下单 退单") @ApiOperation("代客下单 清空购物车 /shop/table") @@ -104,8 +83,6 @@ public class TbPlaceController { return new ResponseEntity<>(HttpStatus.OK); } - @AnonymousAccess - @DeleteMapping("/clearCart") @Log("代客下单 清空购物车") @ApiOperation("代客下单 清空购物车 /shop/table"/**/) @@ -114,92 +91,71 @@ public class TbPlaceController { return new ResponseEntity<>(HttpStatus.OK); } - @AnonymousAccess - @GetMapping("/cart") @Log("代客下单 查询购物车") @ApiOperation("代客下单 查询购物车 /shop/table") - public ResponseEntity getCart( - @RequestParam(defaultValue = "1") Integer page, - @RequestParam(defaultValue = "10") Integer size, - @RequestParam(required = false) String tableId, - @RequestParam Integer shopId, - @RequestParam String masterId, - @RequestParam String useType - ) { + public ResponseEntity getCart(@RequestParam(defaultValue = "1") Integer page, + @RequestParam(defaultValue = "10") Integer size, + @RequestParam(required = false) String tableId, + @RequestParam Integer shopId, + @RequestParam String masterId, + @RequestParam String useType) { return ResponseEntity.ok(tbShopTableService.getCart(tableId, page, size, shopId, masterId, useType)); } - @AnonymousAccess @GetMapping("/pending/cart") @Log("代客下单 查询购物车") @ApiOperation("代客下单 查询购物车 /shop/table") - public ResponseEntity getPendingCart( - @RequestParam Integer shopId, - @RequestParam(required = false) String tableId, - @RequestParam String useType - ) { + public ResponseEntity getPendingCart(@RequestParam Integer shopId, + @RequestParam(required = false) String tableId, + @RequestParam String useType) { return ResponseEntity.ok(tbShopTableService.getCar(shopId, tableId, useType)); } - @AnonymousAccess @GetMapping("/masterId") @Log("代客下单 查询购物车") @ApiOperation("代客下单 ") - public ResponseEntity getMasterId( - @RequestParam Integer shopId, - @RequestParam String tableId, - @RequestParam(defaultValue = "") String useType - ) { + public ResponseEntity getMasterId(@RequestParam Integer shopId, + @RequestParam String tableId, + @RequestParam(defaultValue = "") String useType) { return ResponseEntity.ok(tbShopTableService.getMasterId(shopId, tableId, useType)); } - @AnonymousAccess @PostMapping("/order") @Log("代客下单 查询购物车") @ApiOperation("代客下单 查询购物车 /shop/table") - public ResponseEntity createOrder( - @RequestBody CreateOrderDTO createOrderDTO - ) { + public ResponseEntity createOrder(@RequestBody CreateOrderDTO createOrderDTO ) { return ResponseEntity.ok(tbShopTableService.createOrder(createOrderDTO, !createOrderDTO.isPostPay(), true)); } - @AnonymousAccess @PostMapping("/pending") @Log("代客下单 查询购物车") @ApiOperation("代客下单 查询购物车 /shop/table") - public ResponseEntity pending( - @RequestBody PendingDTO pendingDTO - ) { + public ResponseEntity pending(@RequestBody PendingDTO pendingDTO) { return ResponseEntity.ok(tbShopTableService.pending(pendingDTO)); } - @AnonymousAccess @GetMapping("/payType") - @Log("代客下单 查询购物车") - @ApiOperation("代客下单 查询购物车 /shop/table") + @Log("代客下单 获取支付类型") + @ApiOperation("代客下单 获取支付类型") public ResponseEntity getPayType( @RequestParam Integer shopId ) { return ResponseEntity.ok(tbShopTableService.getPayType(shopId)); } - @AnonymousAccess - @DeleteMapping("/order") @Log("代客下单 删除订单") - @ApiOperation("代客下单 查询购物车 /shop/table") + @ApiOperation("代客下单 删除订单") public ResponseEntity delete( @Validated @RequestBody DeleteOrderDTO deleteOrderDTO ) { return ResponseEntity.ok(tbShopTableService.deleteOrder(deleteOrderDTO)); } - @AnonymousAccess - @PutMapping("/pay") - @Log("代客下单 查询购物车") - @ApiOperation("代客下单 查询购物车 /shop/table") + @Log("代客下单 支付订单") + @ApiOperation("代客下单 支付订单") public ResponseEntity pay( @Validated @RequestBody PayDTO payDTO ) { @@ -207,11 +163,9 @@ public class TbPlaceController { return ResponseEntity.ok(tbShopTableService.pay(payDTO)); } - @AnonymousAccess - @PutMapping("/choseTable") @Log("代客下单 选择台桌") - @ApiOperation("代客下单 选择台桌 /shop/table") + @ApiOperation("代客下单 选择台桌") public ResponseEntity choseTable( @Validated @RequestBody ChoseTableDTO choseTableDTO ) { @@ -219,11 +173,9 @@ public class TbPlaceController { return ResponseEntity.ok(tbShopTableService.choseTable(choseTableDTO)); } - @AnonymousAccess - @PutMapping("/choseCount") @Log("代客下单 选择用餐人数") - @ApiOperation("代客下单 选择台桌 /shop/table") + @ApiOperation("代客下单 选择用餐人数") public ResponseEntity choseCount( @Validated @RequestBody ChoseCountDTO choseCountDTO ) { @@ -231,7 +183,6 @@ public class TbPlaceController { return ResponseEntity.ok(tbShopTableService.choseCount(choseCountDTO)); } - @AnonymousAccess @PutMapping("/updateVip") @Log("代客下单 查询购物车") @ApiOperation("代客下单 查询购物车 /shop/table") @@ -241,39 +192,30 @@ public class TbPlaceController { return ResponseEntity.ok(tbShopTableService.updateVip(updateVipDTO)); } - @AnonymousAccess @PostMapping("/printOrder") @Log("代客下单 打印订单") - @ApiOperation("代客下单 查询购物车 /shop/table") + @ApiOperation("代客下单 打印订单") public ResponseEntity printOrder( @Validated @RequestBody BaseTableDTO baseTableDTO ) { return ResponseEntity.ok(tbShopTableService.printOrder(baseTableDTO)); } - @AnonymousAccess @PostMapping("/printDishes") @Log("代客下单 打印菜品单") - @ApiOperation("代客下单 打印菜品单 /shop/table") + @ApiOperation("代客下单 打印菜品单") public ResponseEntity printDishes( @Validated @RequestBody BaseTableDTO baseTableDTO ) { return ResponseEntity.ok(tbShopTableService.printDishes(baseTableDTO)); } - private final RabbitTemplate rabbitTemplate; - @AnonymousAccess @GetMapping("/test") public void test( @RequestParam Integer id ) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("type", "create"); - jsonObject.put("orderId", id); -// rabbitTemplate.convertAndSend(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, jsonObject.toJSONString(), new CorrelationData(UUID.randomUUID().toString())); rabbitMsgUtils.printTicket(String.valueOf(id)); -// rabbitTemplate.convertAndSend(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, id, new CorrelationData(UUID.randomUUID().toString())); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java index 27b70561..4e3aad7b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java @@ -19,5 +19,6 @@ public class UpdateCartDTO { @NotNull @Min(0) private Integer num; + private String note; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index a96099f8..a6ca2ebc 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -355,6 +355,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setStatus("create"); tbCashierCart.setSalePrice(productSku.getSalePrice()); tbCashierCart.setTotalAmount(new BigDecimal(updateCartDTO.getNum()).multiply(productSku.getSalePrice())); + tbCashierCart.setNote(updateCartDTO.getNote()); if (tbCashierCart.getIsPack().equals("false")) { tbCashierCart.setPackFee(BigDecimal.ZERO); } else {