订单限购
This commit is contained in:
parent
fecac82f1f
commit
3f9f58ae1f
|
|
@ -1,6 +1,9 @@
|
||||||
package com.bonus.canteen.core.cook.service;
|
package com.bonus.canteen.core.cook.service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.bonus.canteen.core.cook.domain.CookRecipeDetail;
|
||||||
import com.bonus.canteen.core.cook.domain.CookRecipeDishes;
|
import com.bonus.canteen.core.cook.domain.CookRecipeDishes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -64,7 +67,8 @@ public interface ICookRecipeDishesService {
|
||||||
* @param cookRecipeDishes 菜品计划菜品关联
|
* @param cookRecipeDishes 菜品计划菜品关联
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int reduceMenuRecipeDishesSupplyNum(CookRecipeDishes cookRecipeDishes, Integer quantity);
|
public int reduceMenuRecipeDishesSupplyNum(CookRecipeDishes cookRecipeDishes, CookRecipeDetail menuRecipeDetail,
|
||||||
|
Integer quantity, Long userId, Date orderTime);
|
||||||
|
|
||||||
public int addMenuRecipeDishesSupplyNum(CookRecipeDishes cookRecipeDishes, Integer quantity);
|
public int addMenuRecipeDishesSupplyNum(CookRecipeDishes cookRecipeDishes, Integer quantity);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,14 @@
|
||||||
package com.bonus.canteen.core.cook.service.impl;
|
package com.bonus.canteen.core.cook.service.impl;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import com.bonus.canteen.core.common.utils.RedisUtil;
|
import com.bonus.canteen.core.common.utils.RedisUtil;
|
||||||
|
import com.bonus.canteen.core.cook.domain.CookRecipeDetail;
|
||||||
|
import com.bonus.canteen.core.cook.mapper.CookRecipeDetailMapper;
|
||||||
|
import com.bonus.canteen.core.order.domain.param.OrderSellNumCountParam;
|
||||||
|
import com.bonus.canteen.core.order.mapper.OrderInfoMapper;
|
||||||
import com.bonus.common.core.exception.ServiceException;
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
import com.bonus.common.core.utils.DateUtils;
|
import com.bonus.common.core.utils.DateUtils;
|
||||||
import com.bonus.common.houqin.constant.GlobalConstants;
|
import com.bonus.common.houqin.constant.GlobalConstants;
|
||||||
|
|
@ -27,6 +33,10 @@ public class CookRecipeDishesServiceImpl implements ICookRecipeDishesService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CookRecipeDishesMapper cookRecipeDishesMapper;
|
private CookRecipeDishesMapper cookRecipeDishesMapper;
|
||||||
|
@Autowired
|
||||||
|
private OrderInfoMapper orderInfoMapper;
|
||||||
|
@Autowired
|
||||||
|
private CookRecipeDetailMapper cookRecipeDetailMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询菜品计划菜品关联
|
* 查询菜品计划菜品关联
|
||||||
|
|
@ -105,7 +115,8 @@ public class CookRecipeDishesServiceImpl implements ICookRecipeDishesService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int reduceMenuRecipeDishesSupplyNum(CookRecipeDishes cookRecipeDishes, Integer quantity) {
|
public int reduceMenuRecipeDishesSupplyNum(CookRecipeDishes cookRecipeDishes, CookRecipeDetail menuRecipeDetail,
|
||||||
|
Integer quantity, Long userId, Date orderTime) {
|
||||||
log.info("扣减库存入参:{},数量:{}", JacksonUtil.writeValueAsString(cookRecipeDishes), quantity);
|
log.info("扣减库存入参:{},数量:{}", JacksonUtil.writeValueAsString(cookRecipeDishes), quantity);
|
||||||
if(cookRecipeDishes == null || cookRecipeDishes.getRecipeDetailId() == null || cookRecipeDishes.getDishesId() == null) {
|
if(cookRecipeDishes == null || cookRecipeDishes.getRecipeDetailId() == null || cookRecipeDishes.getDishesId() == null) {
|
||||||
throw new ServiceException("参数错误");
|
throw new ServiceException("参数错误");
|
||||||
|
|
@ -124,10 +135,19 @@ public class CookRecipeDishesServiceImpl implements ICookRecipeDishesService {
|
||||||
if(cookRecipeDishes.getRemanentNum() < quantity) {
|
if(cookRecipeDishes.getRemanentNum() < quantity) {
|
||||||
throw new ServiceException("菜品供应量不足");
|
throw new ServiceException("菜品供应量不足");
|
||||||
}
|
}
|
||||||
|
Long sellNumCount = orderInfoMapper.goodsSellNumCount(menuRecipeDetail, userId, orderTime, cookRecipeDishes.getDishesId());
|
||||||
|
log.info("菜品销售数量:{}", sellNumCount);
|
||||||
|
if(Objects.nonNull(cookRecipeDishes.getLimitNum()) && (sellNumCount > cookRecipeDishes.getLimitNum())) {
|
||||||
|
throw new ServiceException("菜品超过个人限购数量");
|
||||||
|
}
|
||||||
return cookRecipeDishesMapper.reduceCookRecipeDishesSupplyNum(cookRecipeDishes, quantity);
|
return cookRecipeDishesMapper.reduceCookRecipeDishesSupplyNum(cookRecipeDishes, quantity);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("修改菜谱菜品供应量失败", e);
|
log.error("修改菜谱菜品供应量失败", e);
|
||||||
|
if(e instanceof ServiceException) {
|
||||||
|
throw new ServiceException(e.getMessage());
|
||||||
|
}else {
|
||||||
throw new ServiceException("修改菜谱菜品供应量失败");
|
throw new ServiceException("修改菜谱菜品供应量失败");
|
||||||
|
}
|
||||||
}finally {
|
}finally {
|
||||||
try {
|
try {
|
||||||
RedisUtil.safeUnLock(lockKey);
|
RedisUtil.safeUnLock(lockKey);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,10 @@ import com.bonus.canteen.core.account.service.IAccWalletInfoService;
|
||||||
import com.bonus.canteen.core.common.utils.MqUtil;
|
import com.bonus.canteen.core.common.utils.MqUtil;
|
||||||
import com.bonus.canteen.core.common.utils.ObjectUtils;
|
import com.bonus.canteen.core.common.utils.ObjectUtils;
|
||||||
import com.bonus.canteen.core.common.utils.RedisUtil;
|
import com.bonus.canteen.core.common.utils.RedisUtil;
|
||||||
|
import com.bonus.canteen.core.cook.domain.CookRecipeDetail;
|
||||||
import com.bonus.canteen.core.cook.domain.CookRecipeDishes;
|
import com.bonus.canteen.core.cook.domain.CookRecipeDishes;
|
||||||
|
import com.bonus.canteen.core.cook.enums.RecipeDetailTypeEnum;
|
||||||
|
import com.bonus.canteen.core.cook.service.ICookRecipeDetailService;
|
||||||
import com.bonus.canteen.core.cook.service.ICookRecipeDishesService;
|
import com.bonus.canteen.core.cook.service.ICookRecipeDishesService;
|
||||||
import com.bonus.canteen.core.order.constants.OrderDetailStateEnum;
|
import com.bonus.canteen.core.order.constants.OrderDetailStateEnum;
|
||||||
import com.bonus.canteen.core.order.constants.OrderDetailTypeEnum;
|
import com.bonus.canteen.core.order.constants.OrderDetailTypeEnum;
|
||||||
|
|
@ -47,6 +50,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
@ -66,6 +70,8 @@ public class OrderBusiness {
|
||||||
private IAccWalletInfoService accWalletInfoService;
|
private IAccWalletInfoService accWalletInfoService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IAccTradeService accTradeService;
|
private IAccTradeService accTradeService;
|
||||||
|
@Autowired
|
||||||
|
private ICookRecipeDetailService cookRecipeDetailService;
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public List<OrderInfo> orderPlaceHandler(List<OrderInfo> orderInfoList) {
|
public List<OrderInfo> orderPlaceHandler(List<OrderInfo> orderInfoList) {
|
||||||
|
|
@ -78,13 +84,13 @@ public class OrderBusiness {
|
||||||
List<OrderDetail> orderDetailList = orderInfo.getOrderDetailList();
|
List<OrderDetail> orderDetailList = orderInfo.getOrderDetailList();
|
||||||
orderDetailList.forEach(orderDetail -> orderDetail.setOrderId(orderInfo.getOrderId()));
|
orderDetailList.forEach(orderDetail -> orderDetail.setOrderId(orderInfo.getOrderId()));
|
||||||
orderDetailService.batchInsertOrderDetail(orderDetailList);
|
orderDetailService.batchInsertOrderDetail(orderDetailList);
|
||||||
reduceMenuDishSupplyNum(orderDetailList);
|
reduceMenuDishSupplyNum(orderDetailList, orderInfo.getUserId(), orderInfo.getOrderTime());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return orderInfoList;
|
return orderInfoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reduceMenuDishSupplyNum(List<OrderDetail> orderDetailList) {
|
public void reduceMenuDishSupplyNum(List<OrderDetail> orderDetailList, Long userId, Date orderTime) {
|
||||||
log.info("订单扣减库存入参:{}", JacksonUtil.writeValueAsString(orderDetailList));
|
log.info("订单扣减库存入参:{}", JacksonUtil.writeValueAsString(orderDetailList));
|
||||||
for(OrderDetail orderDetail : orderDetailList) {
|
for(OrderDetail orderDetail : orderDetailList) {
|
||||||
if(OrderDetailTypeEnum.KEYAMOUNT.getKey().equals(orderDetail.getDetailType())) {
|
if(OrderDetailTypeEnum.KEYAMOUNT.getKey().equals(orderDetail.getDetailType())) {
|
||||||
|
|
@ -92,9 +98,20 @@ public class OrderBusiness {
|
||||||
}
|
}
|
||||||
CookRecipeDishes menuRecipeDishes = new CookRecipeDishes();
|
CookRecipeDishes menuRecipeDishes = new CookRecipeDishes();
|
||||||
ObjectUtils.setAllFieldsToNull(menuRecipeDishes);
|
ObjectUtils.setAllFieldsToNull(menuRecipeDishes);
|
||||||
menuRecipeDishes.setRecipeDetailId(orderDetail.getRecipeDetailId());
|
CookRecipeDetail menuRecipeDetail = new CookRecipeDetail();
|
||||||
|
menuRecipeDetail.setDetailType(RecipeDetailTypeEnum.DETAIL_DATA.key());
|
||||||
|
menuRecipeDetail.setRecipeId(orderDetail.getRecipeId());
|
||||||
|
menuRecipeDetail.setApplyDate(orderDetail.getOrderDate());
|
||||||
|
menuRecipeDetail.setMealtimeType(orderDetail.getMealtimeType());
|
||||||
|
log.info("菜谱详情入参:{}", JacksonUtil.writeValueAsString(menuRecipeDetail));
|
||||||
|
List<CookRecipeDetail> cookRecipeDetails = cookRecipeDetailService.selectCookRecipeDetailList(menuRecipeDetail);
|
||||||
|
if(CollUtil.isEmpty(cookRecipeDetails) || cookRecipeDetails.size() > 1) {
|
||||||
|
throw new ServiceException("菜谱详情异常");
|
||||||
|
}
|
||||||
|
menuRecipeDishes.setRecipeDetailId(cookRecipeDetails.get(0).getRecipeDetailId());
|
||||||
menuRecipeDishes.setDishesId(orderDetail.getGoodsId());
|
menuRecipeDishes.setDishesId(orderDetail.getGoodsId());
|
||||||
cookRecipeDishesService.reduceMenuRecipeDishesSupplyNum(menuRecipeDishes, orderDetail.getQuantity());
|
cookRecipeDishesService.reduceMenuRecipeDishesSupplyNum(menuRecipeDishes, menuRecipeDetail,
|
||||||
|
orderDetail.getQuantity(), userId , orderTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -30,7 +31,7 @@ public class OrderDetail extends BaseEntity
|
||||||
/** 订单日期 yyyy-MM-dd */
|
/** 订单日期 yyyy-MM-dd */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
@Excel(name = "订单日期 yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd")
|
@Excel(name = "订单日期 yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
private Date orderDate;
|
private LocalDate orderDate;
|
||||||
|
|
||||||
/** 商品菜品id */
|
/** 商品菜品id */
|
||||||
@Excel(name = "商品菜品id")
|
@Excel(name = "商品菜品id")
|
||||||
|
|
@ -104,4 +105,8 @@ public class OrderDetail extends BaseEntity
|
||||||
@Excel(name = "流水号")
|
@Excel(name = "流水号")
|
||||||
private String serialNum;
|
private String serialNum;
|
||||||
|
|
||||||
|
private Long recipeId;
|
||||||
|
|
||||||
|
private Long mealtimeType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import lombok.Data;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -81,7 +82,7 @@ public class OrderInfo extends BaseEntity
|
||||||
|
|
||||||
/** 餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵 */
|
/** 餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵 */
|
||||||
@Excel(name = "餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵")
|
@Excel(name = "餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵")
|
||||||
private Integer mealtimeType;
|
private Long mealtimeType;
|
||||||
|
|
||||||
/** 餐次名称 */
|
/** 餐次名称 */
|
||||||
@Excel(name = "餐次名称")
|
@Excel(name = "餐次名称")
|
||||||
|
|
@ -90,7 +91,7 @@ public class OrderInfo extends BaseEntity
|
||||||
/** 订单日期 yyyy-MM-dd */
|
/** 订单日期 yyyy-MM-dd */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
@Excel(name = "订单日期 yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd")
|
@Excel(name = "订单日期 yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
private Date orderDate;
|
private LocalDate orderDate;
|
||||||
|
|
||||||
/** 应付金额 分 */
|
/** 应付金额 分 */
|
||||||
@Excel(name = "应付金额 分")
|
@Excel(name = "应付金额 分")
|
||||||
|
|
@ -213,7 +214,7 @@ public class OrderInfo extends BaseEntity
|
||||||
orderInfo.setOrderDate(orderInfoAddParam.getOrderDate());
|
orderInfo.setOrderDate(orderInfoAddParam.getOrderDate());
|
||||||
orderInfo.setOrderType(orderInfoAddParam.getOrderType());
|
orderInfo.setOrderType(orderInfoAddParam.getOrderType());
|
||||||
Integer mealtimeType = orderInfoAddParam.getMealtimeType();
|
Integer mealtimeType = orderInfoAddParam.getMealtimeType();
|
||||||
orderInfo.setMealtimeType(Objects.isNull(mealtimeType) ? -1 : mealtimeType);
|
orderInfo.setMealtimeType(Objects.isNull(mealtimeType) ? -1L : mealtimeType);
|
||||||
orderInfo.setMealtimeName(orderInfoAddParam.getMealtimeName());
|
orderInfo.setMealtimeName(orderInfoAddParam.getMealtimeName());
|
||||||
orderInfo.setIsOnline(Objects.isNull(param.getIsOnline()) ? 1 : param.getIsOnline());
|
orderInfo.setIsOnline(Objects.isNull(param.getIsOnline()) ? 1 : param.getIsOnline());
|
||||||
orderInfo.setOrderState(OrderStateEnum.WAIT_PLACE.getKey());
|
orderInfo.setOrderState(OrderStateEnum.WAIT_PLACE.getKey());
|
||||||
|
|
@ -282,6 +283,8 @@ public class OrderInfo extends BaseEntity
|
||||||
orderDetail.setRefundNum(0);
|
orderDetail.setRefundNum(0);
|
||||||
orderDetail.setDeviceSn(StringUtils.defaultString(orderInfo.getDeviceSn(), StringUtils.EMPTY));
|
orderDetail.setDeviceSn(StringUtils.defaultString(orderInfo.getDeviceSn(), StringUtils.EMPTY));
|
||||||
orderDetail.setSerialNum(StringUtils.EMPTY);
|
orderDetail.setSerialNum(StringUtils.EMPTY);
|
||||||
|
orderDetail.setRecipeId(orderDetailInfoAddParam.getRecipeId());
|
||||||
|
orderDetail.setMealtimeType(orderInfo.getMealtimeType());
|
||||||
orderDetail.setCreateBy(SecurityUtils.getUsername());
|
orderDetail.setCreateBy(SecurityUtils.getUsername());
|
||||||
orderDetail.setCreateTime(DateUtils.getNowDate());
|
orderDetail.setCreateTime(DateUtils.getNowDate());
|
||||||
orderDetail.setUpdateBy(SecurityUtils.getUsername());
|
orderDetail.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
|
@ -312,7 +315,7 @@ public class OrderInfo extends BaseEntity
|
||||||
orderInfo.setOrderDate(orderInfoAddParam.getOrderDate());
|
orderInfo.setOrderDate(orderInfoAddParam.getOrderDate());
|
||||||
orderInfo.setOrderType(orderInfoAddParam.getOrderType());
|
orderInfo.setOrderType(orderInfoAddParam.getOrderType());
|
||||||
Integer mealtimeType = orderInfoAddParam.getMealtimeType();
|
Integer mealtimeType = orderInfoAddParam.getMealtimeType();
|
||||||
orderInfo.setMealtimeType(Objects.isNull(mealtimeType) ? -1 : mealtimeType);
|
orderInfo.setMealtimeType(Objects.isNull(mealtimeType) ? -1L : mealtimeType);
|
||||||
orderInfo.setMealtimeName(orderInfoAddParam.getMealtimeName());
|
orderInfo.setMealtimeName(orderInfoAddParam.getMealtimeName());
|
||||||
orderInfo.setIsOnline(Objects.isNull(param.getIsOnline()) ? 1 : param.getIsOnline());
|
orderInfo.setIsOnline(Objects.isNull(param.getIsOnline()) ? 1 : param.getIsOnline());
|
||||||
orderInfo.setOrderState(OrderStateEnum.WAIT_PLACE.getKey());
|
orderInfo.setOrderState(OrderStateEnum.WAIT_PLACE.getKey());
|
||||||
|
|
@ -374,6 +377,8 @@ public class OrderInfo extends BaseEntity
|
||||||
orderDetail.setRefundNum(0);
|
orderDetail.setRefundNum(0);
|
||||||
orderDetail.setDeviceSn(StringUtils.defaultString(orderInfo.getDeviceSn(), StringUtils.EMPTY));
|
orderDetail.setDeviceSn(StringUtils.defaultString(orderInfo.getDeviceSn(), StringUtils.EMPTY));
|
||||||
orderDetail.setSerialNum(StringUtils.EMPTY);
|
orderDetail.setSerialNum(StringUtils.EMPTY);
|
||||||
|
orderDetail.setMealtimeType(orderInfo.getMealtimeType());
|
||||||
|
orderDetail.setRecipeId(orderDetailInfoAddParam.getMenuId());
|
||||||
orderDetail.setCreateBy(SecurityUtils.getUsername());
|
orderDetail.setCreateBy(SecurityUtils.getUsername());
|
||||||
orderDetail.setCreateTime(DateUtils.getNowDate());
|
orderDetail.setCreateTime(DateUtils.getNowDate());
|
||||||
orderDetail.setUpdateBy(SecurityUtils.getUsername());
|
orderDetail.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -21,7 +22,7 @@ public class DeviceOrderInfoAddParam {
|
||||||
private String mealtimeName;
|
private String mealtimeName;
|
||||||
@NotNull(message = "订单日期不能为空")
|
@NotNull(message = "订单日期不能为空")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
private Date orderDate;
|
private LocalDate orderDate;
|
||||||
@NotNull(message = "订单类型不能为空")
|
@NotNull(message = "订单类型不能为空")
|
||||||
private Integer orderType;
|
private Integer orderType;
|
||||||
@NotNull(message = "设备订单ID不能为空")
|
@NotNull(message = "设备订单ID不能为空")
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -21,7 +22,7 @@ public class OrderInfoAddParam {
|
||||||
private String mealtimeName;
|
private String mealtimeName;
|
||||||
@NotNull(message = "订单日期不能为空")
|
@NotNull(message = "订单日期不能为空")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
private Date orderDate;
|
private LocalDate orderDate;
|
||||||
@NotNull(message = "订单类型不能为空")
|
@NotNull(message = "订单类型不能为空")
|
||||||
private Integer orderType;
|
private Integer orderType;
|
||||||
private String deviceOrderId;
|
private String deviceOrderId;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.bonus.canteen.core.order.domain.param;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OrderSellNumCountParam {
|
||||||
|
private Long userId;
|
||||||
|
private Long receptDetailId;
|
||||||
|
private Long goodsId;
|
||||||
|
private Date orderTime;
|
||||||
|
}
|
||||||
|
|
@ -86,7 +86,7 @@ public class ShopOrderAddParam {
|
||||||
orderInfo.setAccountPayAmount(param.getRealAmount());
|
orderInfo.setAccountPayAmount(param.getRealAmount());
|
||||||
orderInfo.setCanteenId(-1L);
|
orderInfo.setCanteenId(-1L);
|
||||||
orderInfo.setStallId(-1L);
|
orderInfo.setStallId(-1L);
|
||||||
orderInfo.setMealtimeType(-1);
|
orderInfo.setMealtimeType(-1L);
|
||||||
orderInfo.setIdentityVerification(orderInfoAddParam.getIdentityVerification());
|
orderInfo.setIdentityVerification(orderInfoAddParam.getIdentityVerification());
|
||||||
orderInfoList.add(orderInfo);
|
orderInfoList.add(orderInfo);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|
@ -18,7 +19,7 @@ public class ShopOrderInfoAddParam {
|
||||||
private String deviceNum;
|
private String deviceNum;
|
||||||
@NotNull(message = "订单日期不能为空")
|
@NotNull(message = "订单日期不能为空")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
private Date orderDate;
|
private LocalDate orderDate;
|
||||||
@NotNull(message = "核身方式不能为空")
|
@NotNull(message = "核身方式不能为空")
|
||||||
private Integer identityVerification;
|
private Integer identityVerification;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
package com.bonus.canteen.core.order.mapper;
|
package com.bonus.canteen.core.order.mapper;
|
||||||
|
|
||||||
|
import com.bonus.canteen.core.cook.domain.CookRecipeDetail;
|
||||||
import com.bonus.canteen.core.order.domain.OrderInfo;
|
import com.bonus.canteen.core.order.domain.OrderInfo;
|
||||||
import com.bonus.canteen.core.order.domain.OrderPayResultDTO;
|
import com.bonus.canteen.core.order.domain.OrderPayResultDTO;
|
||||||
import com.bonus.canteen.core.order.domain.OrderRefundHistoryVO;
|
import com.bonus.canteen.core.order.domain.OrderRefundHistoryVO;
|
||||||
import com.bonus.canteen.core.order.domain.param.OrderQueryParam;
|
import com.bonus.canteen.core.order.domain.param.OrderQueryParam;
|
||||||
import com.bonus.canteen.core.order.domain.param.OrderRefundHistoryParam;
|
import com.bonus.canteen.core.order.domain.param.OrderRefundHistoryParam;
|
||||||
|
import com.bonus.canteen.core.order.domain.param.OrderSellNumCountParam;
|
||||||
import com.bonus.canteen.core.order.domain.param.OrderWriteOffParam;
|
import com.bonus.canteen.core.order.domain.param.OrderWriteOffParam;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -72,4 +75,10 @@ public interface OrderInfoMapper
|
||||||
public List<OrderRefundHistoryVO> orderRefundHistory(@Param("param") OrderRefundHistoryParam param);
|
public List<OrderRefundHistoryVO> orderRefundHistory(@Param("param") OrderRefundHistoryParam param);
|
||||||
|
|
||||||
public void writeOffOrderByOrderIds(@Param("param") OrderWriteOffParam param);
|
public void writeOffOrderByOrderIds(@Param("param") OrderWriteOffParam param);
|
||||||
|
|
||||||
|
public Long goodsSellNumCount(@Param("param") CookRecipeDetail param,
|
||||||
|
@Param("userId")Long userId,
|
||||||
|
@Param("orderTime")Date orderTime,
|
||||||
|
@Param("dishesId")Long dishesId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,6 +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="recipeId != null">recipe_id,</if>
|
||||||
<if test="recipeDetailId != null">recipe_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>
|
||||||
|
|
@ -102,6 +103,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="recipeId != null">#{recipeId},</if>
|
||||||
<if test="recipeDetailId != null">#{recipeDetailId},</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>
|
||||||
|
|
@ -131,6 +133,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
goods_id,
|
goods_id,
|
||||||
goods_name,
|
goods_name,
|
||||||
goods_img_url,
|
goods_img_url,
|
||||||
|
recipe_id,
|
||||||
recipe_detail_id,
|
recipe_detail_id,
|
||||||
sale_price,
|
sale_price,
|
||||||
discount_price,
|
discount_price,
|
||||||
|
|
@ -157,6 +160,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
#{orderDetail.goodsId},
|
#{orderDetail.goodsId},
|
||||||
#{orderDetail.goodsName},
|
#{orderDetail.goodsName},
|
||||||
#{orderDetail.goodsImgUrl},
|
#{orderDetail.goodsImgUrl},
|
||||||
|
#{orderDetail.recipeId},
|
||||||
#{orderDetail.recipeDetailId},
|
#{orderDetail.recipeDetailId},
|
||||||
#{orderDetail.salePrice},
|
#{orderDetail.salePrice},
|
||||||
#{orderDetail.discountPrice},
|
#{orderDetail.discountPrice},
|
||||||
|
|
|
||||||
|
|
@ -465,4 +465,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="goodsSellNumCount" resultType="java.lang.Long">
|
||||||
|
select
|
||||||
|
COALESCE(SUM(od.quantity - od.refund_num), 0)
|
||||||
|
from
|
||||||
|
order_info oi
|
||||||
|
left join order_detail od on
|
||||||
|
oi.order_id = od.order_id
|
||||||
|
where
|
||||||
|
oi.user_id = #{userId}
|
||||||
|
and od.recipe_id = #{param.recipeId}
|
||||||
|
and od.order_date = #{param.applyDate}
|
||||||
|
and oi.mealtime_type = #{param.mealtimeType}
|
||||||
|
and od.goods_id = #{dishesId}
|
||||||
|
and oi.order_time >= #{orderTime ,jdbcType=TIMESTAMP} - 7
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue