订单-购物车

This commit is contained in:
gaowdong 2025-04-17 15:00:16 +08:00
parent 0bfaeb6ef5
commit 1d63ce61b3
7 changed files with 25 additions and 11 deletions

View File

@ -29,6 +29,8 @@ public class OrderShoppingCartQueryParam
/** 订单类型 */ /** 订单类型 */
private Integer orderType; private Integer orderType;
private Long userId;
/** 菜谱日期 yyyy-MM-dd */ /** 菜谱日期 yyyy-MM-dd */
private List<String> menuDateList; private List<String> menuDateList;
} }

View File

@ -1,10 +1,11 @@
package com.bonus.canteen.core.order.domain.param; package com.bonus.canteen.core.order.domain.param;
import com.bonus.common.core.web.domain.BaseEntity;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
@Data @Data
public class ShoppingCartDelParam { public class ShoppingCartDelParam extends BaseEntity {
private List<Long> shoppingCartIds; private List<Long> shoppingCartIds;
} }

View File

@ -1,6 +1,7 @@
package com.bonus.canteen.core.order.mapper; package com.bonus.canteen.core.order.mapper;
import com.bonus.canteen.core.order.domain.OrderShoppingCart; import com.bonus.canteen.core.order.domain.OrderShoppingCart;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -58,5 +59,5 @@ public interface OrderShoppingCartMapper
* @param shoppingCartIds 需要删除的数据主键集合 * @param shoppingCartIds 需要删除的数据主键集合
* @return 结果 * @return 结果
*/ */
public int deleteOrderShoppingCartByShoppingCartIds(List<Long> shoppingCartIds); public int deleteOrderShoppingCartByShoppingCartIds(@Param("params") List<Long> shoppingCartIds);
} }

View File

@ -1,6 +1,7 @@
package com.bonus.canteen.core.order.module; package com.bonus.canteen.core.order.module;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import com.bonus.canteen.core.menu.domain.MenuRecipe; import com.bonus.canteen.core.menu.domain.MenuRecipe;
import com.bonus.canteen.core.menu.enums.MenuRecipeSortEnum; import com.bonus.canteen.core.menu.enums.MenuRecipeSortEnum;
import com.bonus.canteen.core.menu.service.IMenuRecipeService; import com.bonus.canteen.core.menu.service.IMenuRecipeService;
@ -23,8 +24,8 @@ public class MenuModule {
public Map<Integer, List<MenuRecipeDishesVO>> getMenuRecipeDish(MenuDishCheckDTO menuDishCheckDTO) { public Map<Integer, List<MenuRecipeDishesVO>> getMenuRecipeDish(MenuDishCheckDTO menuDishCheckDTO) {
MenuRecipe menuRecipe = new MenuRecipe(); MenuRecipe menuRecipe = new MenuRecipe();
menuRecipe.setApplyDate(menuDishCheckDTO.getApplyDate()); menuRecipe.setApplyDate(menuDishCheckDTO.getApplyDate());
menuRecipe.setCanteenId(menuDishCheckDTO.getCanteenId()); menuRecipe.setCanteenIds(ListUtil.toList(menuDishCheckDTO.getCanteenId().toString()));
menuRecipe.setStallId(menuDishCheckDTO.getStallId()); menuRecipe.setStallIds(ListUtil.toList(menuDishCheckDTO.getStallId().toString()));
menuRecipe.setKey(menuDishCheckDTO.getApplyType()); menuRecipe.setKey(menuDishCheckDTO.getApplyType());
Map<Integer, List<MenuRecipeDishesVO>> mealTimeTypeMap = new HashMap<>(); Map<Integer, List<MenuRecipeDishesVO>> mealTimeTypeMap = new HashMap<>();
List<MenuRecipeVO> menuRecipeList = menuRecipeService.selectMenuRecipeList(menuRecipe); List<MenuRecipeVO> menuRecipeList = menuRecipeService.selectMenuRecipeList(menuRecipe);

View File

@ -3,6 +3,7 @@ package com.bonus.canteen.core.order.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
@ -18,6 +19,7 @@ import com.bonus.canteen.core.order.mapper.OrderShoppingCartMapper;
import com.bonus.canteen.core.order.module.MenuModule; import com.bonus.canteen.core.order.module.MenuModule;
import com.bonus.canteen.core.order.service.IOrderShoppingCartService; import com.bonus.canteen.core.order.service.IOrderShoppingCartService;
import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.houqin.utils.id.Id;
import com.bonus.common.security.utils.SecurityUtils; import com.bonus.common.security.utils.SecurityUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -61,7 +63,7 @@ public class OrderShoppingCartServiceImpl implements IOrderShoppingCartService
orderShoppingCartQuery.setCanteenId(orderShoppingCart.getCanteenId()); orderShoppingCartQuery.setCanteenId(orderShoppingCart.getCanteenId());
orderShoppingCartQuery.setStallId(orderShoppingCart.getStallId()); orderShoppingCartQuery.setStallId(orderShoppingCart.getStallId());
orderShoppingCartQuery.setOrderType(orderShoppingCart.getOrderType()); orderShoppingCartQuery.setOrderType(orderShoppingCart.getOrderType());
orderShoppingCartQuery.setUserId(SecurityUtils.getUserId()); orderShoppingCartQuery.setUserId(orderShoppingCart.getUserId());
List<OrderShoppingCart> orderShoppingCartList = orderShoppingCartMapper.selectOrderShoppingCartList(orderShoppingCartQuery); List<OrderShoppingCart> orderShoppingCartList = orderShoppingCartMapper.selectOrderShoppingCartList(orderShoppingCartQuery);
if (CollUtil.isEmpty(orderShoppingCartList)) { if (CollUtil.isEmpty(orderShoppingCartList)) {
return new ArrayList<>(); return new ArrayList<>();
@ -127,8 +129,14 @@ public class OrderShoppingCartServiceImpl implements IOrderShoppingCartService
@Override @Override
public int insertOrderShoppingCart(OrderShoppingCart orderShoppingCart) public int insertOrderShoppingCart(OrderShoppingCart orderShoppingCart)
{ {
orderShoppingCart.setCreateBy(SecurityUtils.getUsername()); if(Objects.nonNull(orderShoppingCart.getShoppingCartId())) {
return orderShoppingCartMapper.insertOrderShoppingCart(orderShoppingCart); return updateOrderShoppingCart(orderShoppingCart);
}else {
orderShoppingCart.setShoppingCartId(Id.next());
orderShoppingCart.setCreateBy(SecurityUtils.getUsername());
orderShoppingCart.setUpdateBy(SecurityUtils.getUsername());
return orderShoppingCartMapper.insertOrderShoppingCart(orderShoppingCart);
}
} }
/** /**
@ -140,6 +148,7 @@ public class OrderShoppingCartServiceImpl implements IOrderShoppingCartService
@Override @Override
public int updateOrderShoppingCart(OrderShoppingCart orderShoppingCart) public int updateOrderShoppingCart(OrderShoppingCart orderShoppingCart)
{ {
orderShoppingCart.setUpdateTime(DateUtils.getNowDate());
orderShoppingCart.setUpdateTime(DateUtils.getNowDate()); orderShoppingCart.setUpdateTime(DateUtils.getNowDate());
return orderShoppingCartMapper.updateOrderShoppingCart(orderShoppingCart); return orderShoppingCartMapper.updateOrderShoppingCart(orderShoppingCart);
} }

View File

@ -43,7 +43,7 @@ public class ShoppingCartParamChecker {
} }
private static void checkShoppingCartId(OrderShoppingCart orderShoppingCart) { private static void checkShoppingCartId(OrderShoppingCart orderShoppingCart) {
if (orderShoppingCart.getShoppingCartId() == null) { if (orderShoppingCart.getShoppingCartId() == null) {
throw new ServiceException("餐品ID为空"); throw new ServiceException("车ID为空");
} }
} }
@ -93,7 +93,7 @@ public class ShoppingCartParamChecker {
if (orderShoppingCart.getDetailType() == null) { if (orderShoppingCart.getDetailType() == null) {
throw new ServiceException("订单明细类别为空"); throw new ServiceException("订单明细类别为空");
} }
if(OrderDetailTypeEnum.isValidKey(orderShoppingCart.getDetailType())) { if(!OrderDetailTypeEnum.isValidKey(orderShoppingCart.getDetailType())) {
throw new ServiceException("订单明细类别错误"); throw new ServiceException("订单明细类别错误");
} }
} }
@ -107,7 +107,7 @@ public class ShoppingCartParamChecker {
if (orderType == null) { if (orderType == null) {
throw new ServiceException("订单类型为空"); throw new ServiceException("订单类型为空");
} }
if(OrderTypeEnum.isValidKey(orderType)) { if(!OrderTypeEnum.isValidKey(orderType)) {
throw new ServiceException("订单类型错误"); throw new ServiceException("订单类型错误");
} }
} }

View File

@ -122,7 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<delete id="deleteOrderShoppingCartByShoppingCartIds" parameterType="String"> <delete id="deleteOrderShoppingCartByShoppingCartIds" parameterType="String">
delete from order_shopping_cart where shopping_cart_id in delete from order_shopping_cart where shopping_cart_id in
<foreach item="shoppingCartId" collection="array" open="(" separator="," close=")"> <foreach item="shoppingCartId" collection="params" open="(" separator="," close=")">
#{shoppingCartId} #{shoppingCartId}
</foreach> </foreach>
</delete> </delete>