订单管理

This commit is contained in:
gaowdong 2025-06-03 14:54:33 +08:00
parent 939c73f96d
commit efeb4be4c2
12 changed files with 42 additions and 30 deletions

View File

@ -1,16 +1,24 @@
package com.bonus.canteen.core.common.utils; package com.bonus.canteen.core.common.utils;
import com.bonus.canteen.core.order.business.OrderBusiness;
import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.exception.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class ObjectUtils { public class ObjectUtils {
private static final Logger log = LoggerFactory.getLogger(ObjectUtils.class);
public static void setAllFieldsToNull(Object obj) { public static void setAllFieldsToNull(Object obj) {
for (Field field : obj.getClass().getDeclaredFields()) { for (Field field : obj.getClass().getDeclaredFields()) {
if("serialVersionUID".equals(field.getName())) {
continue;
}
field.setAccessible(true); field.setAccessible(true);
try { try {
field.set(obj, null); field.set(obj, null);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
log.error("setAllFieldsToNull error", e);
throw new ServiceException("系统异常"); throw new ServiceException("系统异常");
} }
} }

View File

@ -75,7 +75,7 @@ public class OrderBusiness {
} }
CookRecipeDishes menuRecipeDishes = new CookRecipeDishes(); CookRecipeDishes menuRecipeDishes = new CookRecipeDishes();
ObjectUtils.setAllFieldsToNull(menuRecipeDishes); ObjectUtils.setAllFieldsToNull(menuRecipeDishes);
menuRecipeDishes.setRecipeDetailId(orderDetail.getMenuDetailId()); menuRecipeDishes.setRecipeDetailId(orderDetail.getRecipeDetailId());
menuRecipeDishes.setDishesId(orderDetail.getGoodsId()); menuRecipeDishes.setDishesId(orderDetail.getGoodsId());
cookRecipeDishesService.reduceMenuRecipeDishesSupplyNum(menuRecipeDishes, orderDetail.getQuantity()); cookRecipeDishesService.reduceMenuRecipeDishesSupplyNum(menuRecipeDishes, orderDetail.getQuantity());
} }
@ -89,7 +89,7 @@ public class OrderBusiness {
} }
CookRecipeDishes menuRecipeDishes = new CookRecipeDishes(); CookRecipeDishes menuRecipeDishes = new CookRecipeDishes();
ObjectUtils.setAllFieldsToNull(menuRecipeDishes); ObjectUtils.setAllFieldsToNull(menuRecipeDishes);
menuRecipeDishes.setRecipeDetailId(orderDetail.getMenuDetailId()); menuRecipeDishes.setRecipeDetailId(orderDetail.getRecipeDetailId());
menuRecipeDishes.setDishesId(orderDetail.getGoodsId()); menuRecipeDishes.setDishesId(orderDetail.getGoodsId());
cookRecipeDishesService.addMenuRecipeDishesSupplyNum(menuRecipeDishes, orderDetail.getQuantity()); cookRecipeDishesService.addMenuRecipeDishesSupplyNum(menuRecipeDishes, orderDetail.getQuantity());
} }

View File

@ -133,12 +133,14 @@ public class OrderInfoController extends BaseController
try { try {
orderInfoService.insertCanteenOrderInfo(orderAddParam); orderInfoService.insertCanteenOrderInfo(orderAddParam);
}catch (ServiceException ex) { }catch (ServiceException ex) {
logger.error("h5下单异常: {}", ex.getMessage(), ex);
if(Integer.valueOf(500001).equals(ex.getCode())) { if(Integer.valueOf(500001).equals(ex.getCode())) {
return AjaxResult.success(ex.getMessage()); return AjaxResult.success(ex.getMessage());
}else { }else {
return AjaxResult.error(ex.getMessage()); return AjaxResult.error(ex.getMessage());
} }
}catch (Exception ex) { }catch (Exception ex) {
logger.error("h5下单失败: {}", ex.getMessage(), ex);
return AjaxResult.error("下单失败"); return AjaxResult.error("下单失败");
} }
return AjaxResult.success(); return AjaxResult.success();

View File

@ -27,7 +27,7 @@ public class OrderCart extends BaseEntity
/** 菜谱id */ /** 菜谱id */
@Excel(name = "菜谱id") @Excel(name = "菜谱id")
private Long menuId; private Long recipeId;
/** 食堂id */ /** 食堂id */
@Excel(name = "食堂id") @Excel(name = "食堂id")
@ -90,14 +90,14 @@ public class OrderCart extends BaseEntity
return userId; return userId;
} }
public void setMenuId(Long menuId) public void setRecipeId(Long recipeId)
{ {
this.menuId = menuId; this.recipeId = recipeId;
} }
public Long getMenuId() public Long getRecipeId()
{ {
return menuId; return recipeId;
} }
public void setCanteenId(Long canteenId) public void setCanteenId(Long canteenId)
@ -205,7 +205,7 @@ public class OrderCart extends BaseEntity
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("cartId", getCartId()) .append("cartId", getCartId())
.append("userId", getUserId()) .append("userId", getUserId())
.append("menuId", getMenuId()) .append("menuId", getRecipeId())
.append("canteenId", getCanteenId()) .append("canteenId", getCanteenId())
.append("stallId", getStallId()) .append("stallId", getStallId())
.append("goodsId", getGoodsId()) .append("goodsId", getGoodsId())

View File

@ -46,7 +46,7 @@ public class OrderDetail extends BaseEntity
/** 菜品详情id */ /** 菜品详情id */
@Excel(name = "菜品详情id") @Excel(name = "菜品详情id")
private Long menuDetailId; private Long recipeDetailId;
/** 售卖价格 分 */ /** 售卖价格 分 */
@Excel(name = "售卖价格 分") @Excel(name = "售卖价格 分")

View File

@ -253,7 +253,7 @@ public class OrderInfo extends BaseEntity
orderDetail.setGoodsId(orderDetailInfoAddParam.getGoodsId()); orderDetail.setGoodsId(orderDetailInfoAddParam.getGoodsId());
orderDetail.setGoodsName(orderDetailInfoAddParam.getGoodsName()); orderDetail.setGoodsName(orderDetailInfoAddParam.getGoodsName());
orderDetail.setGoodsImgUrl(orderDetailInfoAddParam.getGoodsImgUrl()); orderDetail.setGoodsImgUrl(orderDetailInfoAddParam.getGoodsImgUrl());
orderDetail.setMenuDetailId(orderDetailInfoAddParam.getMenuDetailId()); orderDetail.setRecipeDetailId(orderDetailInfoAddParam.getRecipeDetailId());
orderDetail.setSalePrice(orderDetailInfoAddParam.getSalePrice()); orderDetail.setSalePrice(orderDetailInfoAddParam.getSalePrice());
orderDetail.setDiscountPrice(orderDetailInfoAddParam.getDiscountPrice()); orderDetail.setDiscountPrice(orderDetailInfoAddParam.getDiscountPrice());
orderDetail.setFinalPrice(orderDetailInfoAddParam.getFinalPrice()); orderDetail.setFinalPrice(orderDetailInfoAddParam.getFinalPrice());
@ -345,7 +345,7 @@ public class OrderInfo extends BaseEntity
orderDetail.setGoodsId(orderDetailInfoAddParam.getGoodsId()); orderDetail.setGoodsId(orderDetailInfoAddParam.getGoodsId());
orderDetail.setGoodsName(orderDetailInfoAddParam.getGoodsName()); orderDetail.setGoodsName(orderDetailInfoAddParam.getGoodsName());
orderDetail.setGoodsImgUrl(orderDetailInfoAddParam.getGoodsImgUrl()); orderDetail.setGoodsImgUrl(orderDetailInfoAddParam.getGoodsImgUrl());
orderDetail.setMenuDetailId(orderDetailInfoAddParam.getMenuDetailId()); orderDetail.setRecipeDetailId(orderDetailInfoAddParam.getMenuDetailId());
orderDetail.setSalePrice(orderDetailInfoAddParam.getSalePrice()); orderDetail.setSalePrice(orderDetailInfoAddParam.getSalePrice());
orderDetail.setDiscountPrice(orderDetailInfoAddParam.getDiscountPrice()); orderDetail.setDiscountPrice(orderDetailInfoAddParam.getDiscountPrice());
orderDetail.setFinalPrice(orderDetailInfoAddParam.getFinalPrice()); orderDetail.setFinalPrice(orderDetailInfoAddParam.getFinalPrice());

View File

@ -16,9 +16,9 @@ public class OrderDetailInfoAddParam {
private String goodsImgUrl; private String goodsImgUrl;
private String goodsName; private String goodsName;
@NotNull(message = "菜谱详情ID不能为空") @NotNull(message = "菜谱详情ID不能为空")
private Long menuDetailId; private Long recipeDetailId;
@NotNull(message = "菜谱ID不能为空") @NotNull(message = "菜谱ID不能为空")
private Long menuId; private Long recipeId;
@NotNull(message = "菜谱下单数量不能为空") @NotNull(message = "菜谱下单数量不能为空")
private Integer quantity; private Integer quantity;
private Integer restrictNum; private Integer restrictNum;

View File

@ -26,7 +26,7 @@ public class OrderCartVO extends BaseEntity
/** 菜谱id */ /** 菜谱id */
@Excel(name = "菜谱id") @Excel(name = "菜谱id")
private Long menuId; private Long recipeId;
/** 食堂id */ /** 食堂id */
@Excel(name = "食堂id") @Excel(name = "食堂id")

View File

@ -89,7 +89,7 @@ public class OrderCartServiceImpl implements IOrderCartService
try{ try{
cookRecipeDishMap = menuModule.getMenuRecipeDish(cookDishCheckDTO); cookRecipeDishMap = menuModule.getMenuRecipeDish(cookDishCheckDTO);
}catch (Exception ex) { }catch (Exception ex) {
log.info("菜单数据获取失败:" + ex.getMessage()); log.info("菜单数据获取失败:{}", ex.getMessage(), ex);
} }
for (OrderCart shoppingCart : carts) { for (OrderCart shoppingCart : carts) {

View File

@ -99,7 +99,7 @@ public class OrderCartParamChecker {
} }
private static void checkMenuId(OrderCart orderCart) { private static void checkMenuId(OrderCart orderCart) {
if (orderCart.getMenuId() == null) { if (orderCart.getRecipeId() == null) {
throw new ServiceException("菜谱ID为空"); throw new ServiceException("菜谱ID为空");
} }
} }

View File

@ -7,7 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="com.bonus.canteen.core.order.domain.OrderCart" id="OrderCartResult"> <resultMap type="com.bonus.canteen.core.order.domain.OrderCart" id="OrderCartResult">
<result property="cartId" column="cart_id" /> <result property="cartId" column="cart_id" />
<result property="userId" column="user_id" /> <result property="userId" column="user_id" />
<result property="menuId" column="menu_id" /> <result property="recipeId" column="recipe_id" />
<result property="canteenId" column="canteen_id" /> <result property="canteenId" column="canteen_id" />
<result property="stallId" column="stall_id" /> <result property="stallId" column="stall_id" />
<result property="goodsId" column="goods_id" /> <result property="goodsId" column="goods_id" />
@ -25,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectOrderShoppingCartVo"> <sql id="selectOrderShoppingCartVo">
select cart_id, user_id, menu_id, canteen_id, stall_id, goods_id, select cart_id, user_id, recipe_id, canteen_id, stall_id, goods_id,
goods_name, goods_img_url, quantity, order_type, detail_type, order_date, goods_name, goods_img_url, quantity, order_type, detail_type, order_date,
mealtime_type, create_by, create_time, update_by, update_time mealtime_type, create_by, create_time, update_by, update_time
from order_cart from order_cart
@ -35,7 +35,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectOrderShoppingCartVo"/> <include refid="selectOrderShoppingCartVo"/>
<where> <where>
<if test="userId != null "> and user_id = #{userId}</if> <if test="userId != null "> and user_id = #{userId}</if>
<if test="menuId != null "> and menu_id = #{menuId}</if> <if test="recipeId != null">
and recipe_id = #{recipeId}</if>
<if test="canteenId != null "> and canteen_id = #{canteenId}</if> <if test="canteenId != null "> and canteen_id = #{canteenId}</if>
<if test="stallId != null "> and stall_id = #{stallId}</if> <if test="stallId != null "> and stall_id = #{stallId}</if>
<if test="goodsId != null "> and goods_id = #{goodsId}</if> <if test="goodsId != null "> and goods_id = #{goodsId}</if>
@ -59,7 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="cartId != null">cart_id,</if> <if test="cartId != null">cart_id,</if>
<if test="userId != null">user_id,</if> <if test="userId != null">user_id,</if>
<if test="menuId != null">menu_id,</if> <if test="recipeId != null">recipe_id,</if>
<if test="canteenId != null">canteen_id,</if> <if test="canteenId != null">canteen_id,</if>
<if test="stallId != null">stall_id,</if> <if test="stallId != null">stall_id,</if>
<if test="goodsId != null">goods_id,</if> <if test="goodsId != null">goods_id,</if>
@ -78,7 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="cartId != null">#{cartId},</if> <if test="cartId != null">#{cartId},</if>
<if test="userId != null">#{userId},</if> <if test="userId != null">#{userId},</if>
<if test="menuId != null">#{menuId},</if> <if test="recipeId != null">#{recipeId},</if>
<if test="canteenId != null">#{canteenId},</if> <if test="canteenId != null">#{canteenId},</if>
<if test="stallId != null">#{stallId},</if> <if test="stallId != null">#{stallId},</if>
<if test="goodsId != null">#{goodsId},</if> <if test="goodsId != null">#{goodsId},</if>
@ -100,7 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update order_cart update order_cart
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if> <if test="userId != null">user_id = #{userId},</if>
<if test="menuId != null">menu_id = #{menuId},</if> <if test="recipeId != null">recipe_id = #{recipeId},</if>
<if test="canteenId != null">canteen_id = #{canteenId},</if> <if test="canteenId != null">canteen_id = #{canteenId},</if>
<if test="stallId != null">stall_id = #{stallId},</if> <if test="stallId != null">stall_id = #{stallId},</if>
<if test="goodsId != null">goods_id = #{goodsId},</if> <if test="goodsId != null">goods_id = #{goodsId},</if>

View File

@ -11,7 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="goodsId" column="goods_id" /> <result property="goodsId" column="goods_id" />
<result property="goodsName" column="goods_name" /> <result property="goodsName" column="goods_name" />
<result property="goodsImgUrl" column="goods_img_url" /> <result property="goodsImgUrl" column="goods_img_url" />
<result property="menuDetailId" column="menu_detail_id" /> <result property="recipeDetailId" column="recipe_detail_id" />
<result property="salePrice" column="sale_price" /> <result property="salePrice" column="sale_price" />
<result property="discountPrice" column="discount_price" /> <result property="discountPrice" column="discount_price" />
<result property="finalPrice" column="final_price" /> <result property="finalPrice" column="final_price" />
@ -33,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectOrderDetailVo"> <sql id="selectOrderDetailVo">
select detail_id, order_id, order_date, goods_id, goods_name, goods_img_url, menu_detail_id, sale_price, discount_price, final_price, quantity, sales_mode, detail_type, total_amount, calc_total_amount, real_amount, refund_amount, detail_state, refund_num, device_sn, serial_num, create_by, create_time, update_by, update_time from order_detail select detail_id, order_id, order_date, goods_id, goods_name, goods_img_url, recipe_detail_id, sale_price, discount_price, final_price, quantity, sales_mode, detail_type, total_amount, calc_total_amount, real_amount, refund_amount, detail_state, refund_num, device_sn, serial_num, create_by, create_time, update_by, update_time from order_detail
</sql> </sql>
<select id="selectOrderDetailList" parameterType="com.bonus.canteen.core.order.domain.OrderDetail" resultMap="OrderDetailResult"> <select id="selectOrderDetailList" parameterType="com.bonus.canteen.core.order.domain.OrderDetail" resultMap="OrderDetailResult">
@ -44,7 +44,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="goodsId != null "> and goods_id = #{goodsId}</if> <if test="goodsId != null "> and goods_id = #{goodsId}</if>
<if test="goodsName != null and goodsName != ''"> and goods_name like concat('%', #{goodsName}, '%')</if> <if test="goodsName != null and goodsName != ''"> and goods_name like concat('%', #{goodsName}, '%')</if>
<if test="goodsImgUrl != null and goodsImgUrl != ''"> and goods_img_url = #{goodsImgUrl}</if> <if test="goodsImgUrl != null and goodsImgUrl != ''"> and goods_img_url = #{goodsImgUrl}</if>
<if test="menuDetailId != null "> and menu_detail_id = #{menuDetailId}</if> <if test="recipeDetailId != null">
and recipe_detail_id = #{recipeDetailId}</if>
<if test="salePrice != null "> and sale_price = #{salePrice}</if> <if test="salePrice != null "> and sale_price = #{salePrice}</if>
<if test="discountPrice != null "> and discount_price = #{discountPrice}</if> <if test="discountPrice != null "> and discount_price = #{discountPrice}</if>
<if test="finalPrice != null "> and final_price = #{finalPrice}</if> <if test="finalPrice != null "> and final_price = #{finalPrice}</if>
@ -75,7 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="goodsId != null">goods_id,</if> <if test="goodsId != null">goods_id,</if>
<if test="goodsName != null and goodsName != ''">goods_name,</if> <if test="goodsName != null and goodsName != ''">goods_name,</if>
<if test="goodsImgUrl != null">goods_img_url,</if> <if test="goodsImgUrl != null">goods_img_url,</if>
<if test="menuDetailId != null">menu_detail_id,</if> <if test="recipeDetailId != null">recipe_detail_id,</if>
<if test="salePrice != null">sale_price,</if> <if test="salePrice != null">sale_price,</if>
<if test="discountPrice != null">discount_price,</if> <if test="discountPrice != null">discount_price,</if>
<if test="finalPrice != null">final_price,</if> <if test="finalPrice != null">final_price,</if>
@ -101,7 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="goodsId != null">#{goodsId},</if> <if test="goodsId != null">#{goodsId},</if>
<if test="goodsName != null and goodsName != ''">#{goodsName},</if> <if test="goodsName != null and goodsName != ''">#{goodsName},</if>
<if test="goodsImgUrl != null">#{goodsImgUrl},</if> <if test="goodsImgUrl != null">#{goodsImgUrl},</if>
<if test="menuDetailId != null">#{menuDetailId},</if> <if test="recipeDetailId != null">#{recipeDetailId},</if>
<if test="salePrice != null">#{salePrice},</if> <if test="salePrice != null">#{salePrice},</if>
<if test="discountPrice != null">#{discountPrice},</if> <if test="discountPrice != null">#{discountPrice},</if>
<if test="finalPrice != null">#{finalPrice},</if> <if test="finalPrice != null">#{finalPrice},</if>
@ -130,7 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
goods_id, goods_id,
goods_name, goods_name,
goods_img_url, goods_img_url,
menu_detail_id, recipe_detail_id,
sale_price, sale_price,
discount_price, discount_price,
final_price, final_price,
@ -156,7 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{orderDetail.goodsId}, #{orderDetail.goodsId},
#{orderDetail.goodsName}, #{orderDetail.goodsName},
#{orderDetail.goodsImgUrl}, #{orderDetail.goodsImgUrl},
#{orderDetail.menuDetailId}, #{orderDetail.recipeDetailId},
#{orderDetail.salePrice}, #{orderDetail.salePrice},
#{orderDetail.discountPrice}, #{orderDetail.discountPrice},
#{orderDetail.finalPrice}, #{orderDetail.finalPrice},
@ -186,7 +187,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="goodsId != null">goods_id = #{goodsId},</if> <if test="goodsId != null">goods_id = #{goodsId},</if>
<if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if> <if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if>
<if test="goodsImgUrl != null">goods_img_url = #{goodsImgUrl},</if> <if test="goodsImgUrl != null">goods_img_url = #{goodsImgUrl},</if>
<if test="menuDetailId != null">menu_detail_id = #{menuDetailId},</if> <if test="recipeDetailId != null">recipe_detail_id = #{recipeDetailId},</if>
<if test="salePrice != null">sale_price = #{salePrice},</if> <if test="salePrice != null">sale_price = #{salePrice},</if>
<if test="discountPrice != null">discount_price = #{discountPrice},</if> <if test="discountPrice != null">discount_price = #{discountPrice},</if>
<if test="finalPrice != null">final_price = #{finalPrice},</if> <if test="finalPrice != null">final_price = #{finalPrice},</if>