修改支持备注

This commit is contained in:
SongZhang 2024-09-27 11:39:54 +08:00
parent a2ccfb0628
commit 5bf555c8a9
3 changed files with 31 additions and 87 deletions

View File

@ -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<Object> 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<Object> 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<Object> 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<Object> 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<Object> getPendingCart(
@RequestParam Integer shopId,
@RequestParam(required = false) String tableId,
@RequestParam String useType
) {
public ResponseEntity<Object> 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<Object> getMasterId(
@RequestParam Integer shopId,
@RequestParam String tableId,
@RequestParam(defaultValue = "") String useType
) {
public ResponseEntity<Object> 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<Object> createOrder(
@RequestBody CreateOrderDTO createOrderDTO
) {
public ResponseEntity<Object> createOrder(@RequestBody CreateOrderDTO createOrderDTO ) {
return ResponseEntity.ok(tbShopTableService.createOrder(createOrderDTO, !createOrderDTO.isPostPay(), true));
}
@AnonymousAccess
@PostMapping("/pending")
@Log("代客下单 查询购物车")
@ApiOperation("代客下单 查询购物车 /shop/table")
public ResponseEntity<Object> pending(
@RequestBody PendingDTO pendingDTO
) {
public ResponseEntity<Object> pending(@RequestBody PendingDTO pendingDTO) {
return ResponseEntity.ok(tbShopTableService.pending(pendingDTO));
}
@AnonymousAccess
@GetMapping("/payType")
@Log("代客下单 查询购物车")
@ApiOperation("代客下单 查询购物车 /shop/table")
@Log("代客下单 获取支付类型")
@ApiOperation("代客下单 获取支付类型")
public ResponseEntity<Object> getPayType(
@RequestParam Integer shopId
) {
return ResponseEntity.ok(tbShopTableService.getPayType(shopId));
}
@AnonymousAccess
@DeleteMapping("/order")
@Log("代客下单 删除订单")
@ApiOperation("代客下单 查询购物车 /shop/table")
@ApiOperation("代客下单 删除订单")
public ResponseEntity<Object> delete(
@Validated @RequestBody DeleteOrderDTO deleteOrderDTO
) {
return ResponseEntity.ok(tbShopTableService.deleteOrder(deleteOrderDTO));
}
@AnonymousAccess
@PutMapping("/pay")
@Log("代客下单 查询购物车")
@ApiOperation("代客下单 查询购物车 /shop/table")
@Log("代客下单 支付订单")
@ApiOperation("代客下单 支付订单")
public ResponseEntity<Object> 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<Object> 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<Object> 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<Object> printOrder(
@Validated @RequestBody BaseTableDTO baseTableDTO
) {
return ResponseEntity.ok(tbShopTableService.printOrder(baseTableDTO));
}
@AnonymousAccess
@PostMapping("/printDishes")
@Log("代客下单 打印菜品单")
@ApiOperation("代客下单 打印菜品单 /shop/table")
@ApiOperation("代客下单 打印菜品单")
public ResponseEntity<Object> 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()));
}

View File

@ -19,5 +19,6 @@ public class UpdateCartDTO {
@NotNull
@Min(0)
private Integer num;
private String note;
}

View File

@ -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 {