|
|
|
|
@@ -50,10 +50,7 @@ import cn.ysk.cashier.service.impl.TbPayServiceImpl;
|
|
|
|
|
import cn.ysk.cashier.service.order.TbOrderInfoService;
|
|
|
|
|
import cn.ysk.cashier.service.shop.TbShopTableService;
|
|
|
|
|
import cn.ysk.cashier.utils.*;
|
|
|
|
|
import cn.ysk.cashier.vo.ActivateInInfoVO;
|
|
|
|
|
import cn.ysk.cashier.vo.OrderInfoUserCouponVo;
|
|
|
|
|
import cn.ysk.cashier.vo.PendingCountVO;
|
|
|
|
|
import cn.ysk.cashier.vo.TbUserCouponVo;
|
|
|
|
|
import cn.ysk.cashier.vo.*;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
|
@@ -449,6 +446,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
throw new BadRequestException("商品不存在或已下架, id: " + updateCartDTO.getSkuId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resetGroupProductCart(updateCartDTO.getGroupProductIdList(), product, tbCashierCart);
|
|
|
|
|
tbCashierCart.setCoverImg(product.getCoverImg());
|
|
|
|
|
tbCashierCart.setIsSku(product.getTypeEnum());
|
|
|
|
|
tbCashierCart.setName(product.getName());
|
|
|
|
|
@@ -494,6 +492,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
if (tbCashierCart.getOrderId() != null && StrUtil.isNotBlank(updateCartDTO.getNote())) {
|
|
|
|
|
orderDetailMapper.update(null, new LambdaUpdateWrapper<TbOrderDetail>()
|
|
|
|
|
.eq(TbOrderDetail::getCartId, tbCashierCart.getId())
|
|
|
|
|
.set(TbOrderDetail::getProGroupInfo, tbCashierCart.getProGroupInfo())
|
|
|
|
|
.set(TbOrderDetail::getIsWaitCall, updateCartDTO.getIsWaitCall())
|
|
|
|
|
.set(TbOrderDetail::getNote, updateCartDTO.getNote()));
|
|
|
|
|
}
|
|
|
|
|
@@ -512,6 +511,51 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
return orderInfo == null ? 1 : orderInfo.getPlaceNum() + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 重置购物车套餐商品信息
|
|
|
|
|
*/
|
|
|
|
|
private void resetGroupProductCart(List<Integer> productIds, TbProduct product, TbCashierCart cashierCart) {
|
|
|
|
|
boolean isChoseGroup = TableConstant.Product.Type.PACKAGE.equalsVals(product.getType()) && product.getGroupType() == 1;
|
|
|
|
|
boolean isFixGroup = TableConstant.Product.Type.PACKAGE.equalsVals(product.getType()) && product.getGroupType() == 0;
|
|
|
|
|
if (isChoseGroup && productIds != null && !productIds.isEmpty()) {
|
|
|
|
|
String groupSnap = product.getGroupSnap();
|
|
|
|
|
if (StrUtil.isNotBlank(groupSnap)) {
|
|
|
|
|
ArrayList<ProductGroupVo.Food> foods = new ArrayList<>();
|
|
|
|
|
HashMap<String, ProductGroupVo.Food> groupVoHashMap = new HashMap<>();
|
|
|
|
|
JSONObject.parseArray(groupSnap).forEach(item -> {
|
|
|
|
|
ProductGroupVo productGroupVo = ((JSONObject) item).toJavaObject(ProductGroupVo.class);
|
|
|
|
|
productGroupVo.getGoods().forEach(goods -> {
|
|
|
|
|
groupVoHashMap.put(goods.getProId().toString(), goods);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
productIds.forEach(item -> {
|
|
|
|
|
ProductGroupVo.Food food = groupVoHashMap.get(item.toString());
|
|
|
|
|
if (food == null) {
|
|
|
|
|
throw new BadRequestException("存在无效套餐商品");
|
|
|
|
|
}
|
|
|
|
|
foods.add(food);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
cashierCart.setProGroupInfo(JSONObject.toJSONString(foods));
|
|
|
|
|
}
|
|
|
|
|
}else if (isFixGroup) {
|
|
|
|
|
String groupSnap = product.getGroupSnap();
|
|
|
|
|
if (StrUtil.isNotBlank(groupSnap)) {
|
|
|
|
|
ArrayList<ProductGroupVo.Food> foods = new ArrayList<>();
|
|
|
|
|
HashMap<String, ProductGroupVo.Food> groupVoHashMap = new HashMap<>();
|
|
|
|
|
JSONObject.parseArray(groupSnap).forEach(item -> {
|
|
|
|
|
ProductGroupVo productGroupVo = ((JSONObject) item).toJavaObject(ProductGroupVo.class);
|
|
|
|
|
productGroupVo.getGoods().forEach(goods -> {
|
|
|
|
|
groupVoHashMap.put(goods.getProId().toString(), goods);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
cashierCart.setProGroupInfo(JSONObject.toJSONString(groupVoHashMap.values()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public TbCashierCart addCartForUser(AddCartDTO addCartDTO) {
|
|
|
|
|
addCartDTO.setTableId(OrderUseTypeEnum.TAKEOUT.getValue().equals(addCartDTO.getUseType()) ? null : addCartDTO.getTableId());
|
|
|
|
|
@@ -528,6 +572,11 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
throw new BadRequestException(product.getName() + "商品库存不足");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boolean isChoseGroup = TableConstant.Product.Type.PACKAGE.equalsVals(product.getType()) && product.getGroupType() == 1;
|
|
|
|
|
if (isChoseGroup && (addCartDTO.getGroupProductIdList() == null || addCartDTO.getGroupProductIdList().isEmpty())) {
|
|
|
|
|
throw new BadRequestException("可选套餐,清先选择套餐商品");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<TbCashierCart> query = new LambdaQueryWrapper<TbCashierCart>()
|
|
|
|
|
.eq(TbCashierCart::getShopId, addCartDTO.getShopId())
|
|
|
|
|
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
|
|
|
|
@@ -555,6 +604,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
// 首次加入
|
|
|
|
|
if (tbCashierCart == null) {
|
|
|
|
|
tbCashierCart = new TbCashierCart();
|
|
|
|
|
resetGroupProductCart(addCartDTO.getGroupProductIdList(), product, tbCashierCart);
|
|
|
|
|
|
|
|
|
|
tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType());
|
|
|
|
|
tbCashierCart.setCoverImg(product.getCoverImg());
|
|
|
|
|
tbCashierCart.setCreatedAt(System.currentTimeMillis());
|
|
|
|
|
@@ -598,6 +649,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
mpCashierCartService.save(tbCashierCart);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
resetGroupProductCart(addCartDTO.getGroupProductIdList(), product, tbCashierCart);
|
|
|
|
|
tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : addCartDTO.getVipUserId() == null ? 0 : 1);
|
|
|
|
|
tbCashierCart.setNote(addCartDTO.getNote());
|
|
|
|
|
tbCashierCart.setTotalAmount(addCartDTO.getNum().multiply(productSku.getSalePrice()));
|
|
|
|
|
@@ -1612,6 +1664,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
orderDetail.setProductId(Integer.valueOf(cashierCart.getProductId()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
orderDetail.setProGroupInfo(cashierCart.getProGroupInfo());
|
|
|
|
|
orderDetail.setDiscountSaleAmount(cashierCart.getDiscountSaleAmount());
|
|
|
|
|
orderDetail.setIsWaitCall(cashierCart.getIsWaitCall());
|
|
|
|
|
orderDetail.setUserCouponId(cashierCart.getUserCouponId());
|
|
|
|
|
|