新增创建订单 切换就餐模式接口

This commit is contained in:
2024-09-29 16:10:40 +08:00
parent 4569a799c0
commit 82ded64290
2 changed files with 14 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ package com.chaozhanggui.system.cashierservice.controller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
import com.chaozhanggui.system.cashierservice.entity.dto.ChoseCountDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.ChoseEatModelDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.QuerySpecDTO;
@@ -16,6 +17,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@CrossOrigin(origins = "*")
@@ -113,7 +117,15 @@ public class ProductController {
@PostMapping("/choseEatModel")
public Result choseEatModel(@Validated @RequestBody ChoseEatModelDTO choseEatModelDTO) {
return Result.success(CodeEnum.SUCCESS, cartService.choseEatModel(choseEatModelDTO));
List<TbCashierCart> cashierCartList = cartService.choseEatModel(choseEatModelDTO);
BigDecimal amount = BigDecimal.ZERO;
for (TbCashierCart item : cashierCartList) {
amount = amount.add(item.getTotalAmount());
}
HashMap<String, Object> data = new HashMap<>();
data.put("amount", amount);
data.put("info", cashierCartList);
return Result.success(CodeEnum.SUCCESS, data);
}
@PostMapping("cleanCart")

View File

@@ -1581,7 +1581,7 @@ public class CartService {
}
}
public Object choseEatModel(ChoseEatModelDTO choseEatModelDTO) {
public List<TbCashierCart> choseEatModel(ChoseEatModelDTO choseEatModelDTO) {
Integer userId = TokenUtil.getUserId();
// 查询购物车所有信息
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()