diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/AllocCanteenApi.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/AllocCanteenApi.java index f7837bfe..7b219ab9 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/AllocCanteenApi.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/AllocCanteenApi.java @@ -74,10 +74,10 @@ public class AllocCanteenApi { // return (AllocArea)this.allocAreaService.getOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(AllocArea.class).eq(AllocArea::getAreaNum, "99")).last(" limit 1 ")); // } // } -// -// public AllocCanteen getAllocCanteen(Long canteenId) { -// return this.allocCanteenService.getAllocCanteenCache(canteenId); -// } + + public AllocCanteen getAllocCanteen(Long canteenId) { + return this.allocCanteenService.getAllocCanteenCache(canteenId); + } // // public void checkCanteenBusinessState(Long canteenId, LocalTime checkTime) { // if (!LeNumUtil.isValidId(canteenId)) { diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/AllocCanteenService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/AllocCanteenService.java index 3c4d4ce1..50a2e616 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/AllocCanteenService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/AllocCanteenService.java @@ -15,4 +15,6 @@ public interface AllocCanteenService extends IService { List listAllCanteenStall(); void checkAndDelReserveCanteen(List reserveCanteenList); + + AllocCanteen getAllocCanteenCache(Long canteenId); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/impl/AllocCanteenServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/impl/AllocCanteenServiceImpl.java index 1162d252..896b2bc3 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/impl/AllocCanteenServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/impl/AllocCanteenServiceImpl.java @@ -1,6 +1,9 @@ package com.bonus.core.allocation.canteen.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.support.SFunction; @@ -15,6 +18,8 @@ import com.bonus.core.allocation.canteen.service.AllocAreaService; import com.bonus.core.allocation.canteen.service.AllocCanteenService; import com.bonus.core.allocation.canteen.vo.AllocCanteenStallVO; import com.bonus.core.common.enums.AllocCanteenTypeEnum; +import com.bonus.core.common.redis.RedisUtil; +import com.bonus.core.common.utils.TenantContextHolder; import com.bonus.core.menu.vo.AppletReserveCanteenVO; import com.bonus.core.menu.vo.AppletReserveStallVO; import org.slf4j.Logger; @@ -133,4 +138,26 @@ public class AllocCanteenServiceImpl extends ServiceImpl { @@ -89,13 +104,14 @@ public class ShoppingCartBusinessImpl implements ShoppingCartBusiness { addDTO.setOrderDate((LocalDate)null); addDTO.setMealtimeType((Integer)null); } + this.orderShoppingCartService.insert(entity); } } finally { try { -// if (lock.isHeldByCurrentThread() && lock.isLocked()) { -// lock.unlock(); -// } + if (lock.isHeldByCurrentThread() && lock.isLocked()) { + lock.unlock(); + } } catch (Exception var11) { log.error("解锁异常", var11); } @@ -134,7 +150,7 @@ public class ShoppingCartBusinessImpl implements ShoppingCartBusiness { JavaxValidateUtils.validate(searchDTO); List orderShoppingCarts = this.orderShoppingCartService.listByCust(searchDTO); LogUtil.infoFieldsX("查询购物车_结果", orderShoppingCarts, OrderShoppingCart.logFields()); - List voList = (List)orderShoppingCarts.stream().map(OrderShoppingCartListMobileVO::of).collect(Collectors.toList()); + List voList = orderShoppingCarts.stream().map(OrderShoppingCartListMobileVO::of).collect(Collectors.toList()); if (CollUtil.isEmpty(voList)) { return voList; } else { @@ -146,24 +162,22 @@ public class ShoppingCartBusinessImpl implements ShoppingCartBusiness { protected void fillVo(List voList, Integer orderType, Long custId) { if (!CollUtil.isEmpty(voList)) { if (OrderTypeEnum.isShopCategory(orderType)) { - Map> voGroupBySupermarket = (Map)voList.stream().collect(Collectors.groupingBy(OrderShoppingCartListMobileVO::getCanteenId)); + Map> voGroupBySupermarket = voList.stream().collect(Collectors.groupingBy(OrderShoppingCartListMobileVO::getCanteenId)); voGroupBySupermarket.forEach((supermarketId, vos) -> { - List goodsIds = (List)vos.stream().map(OrderShoppingCartListMobileVO::getGoodsDishesId).collect(Collectors.toList()); + List goodsIds = vos.stream().map(OrderShoppingCartListMobileVO::getGoodsDishesId).collect(Collectors.toList()); SupermarketNotRemovedProductListDTO dto = new SupermarketNotRemovedProductListDTO(); dto.setSupermarketId(supermarketId); dto.setMaterialIdList(goodsIds); dto.setCustId(custId); - Map productMap =null; -// (Map)this.supermarketApi.listNotRemovedProduct(dto).stream().collect(Collectors.toMap(SupermarketNotRemovedProductListVO::getMaterialId, Function.identity())); + Map productMap = this.supermarketApi.listNotRemovedProduct(dto).stream().collect(Collectors.toMap(SupermarketNotRemovedProductListVO::getMaterialId, Function.identity())); vos.forEach((s) -> { - s.fillSupermarketProductInfo((SupermarketNotRemovedProductListVO)productMap.get(s.getGoodsDishesId())); + s.fillSupermarketProductInfo(productMap.get(s.getGoodsDishesId())); }); }); } else if (OrderTypeEnum.isCanteenCategory(orderType)) { if (OrderTypeEnum.isCurrMealType(orderType)) { voList.forEach((s) -> { - AllocMealtimeModel nowMealtime = null; -// this.orderModuleClient.mealtimeQuery(MealtimeQueryParam.ofAssignTime(LocalTime.now(), s.getCanteenId(), s.getStallId())); + AllocMealtimeModel nowMealtime = this.orderModuleClient.mealtimeQuery(MealtimeQueryParam.ofAssignTime(LocalTime.now(), s.getCanteenId(), s.getStallId())); if (nowMealtime != null) { s.setOrderDate(LocalDate.now()); s.setMealtimeType(nowMealtime.getMealtimeType()); @@ -221,14 +235,12 @@ public class ShoppingCartBusinessImpl implements ShoppingCartBusiness { if (LeNumUtil.isValidId(vo.getCanteenId())) { if (!canteenNameMapById.containsKey(vo.getCanteenId())) { if (OrderTypeEnum.isShopCategory(vo.getOrderType())) { - SupermarketInfo supermarketInfo = null; -// this.supermarketApi.getSupermarketInfoById(vo.getCanteenId()); + SupermarketInfo supermarketInfo = this.supermarketApi.getSupermarketInfoById(vo.getCanteenId()); if (supermarketInfo != null) { canteenNameMapById.put(vo.getCanteenId(), supermarketInfo.getSupermarketName()); } } else { - AllocCanteen allocCanteen = null; -// this.allocCanteenApi.getAllocCanteen(vo.getCanteenId()); + AllocCanteen allocCanteen = this.allocCanteenApi.getAllocCanteen(vo.getCanteenId()); if (allocCanteen != null) { canteenNameMapById.put(vo.getCanteenId(), allocCanteen.getCanteenName()); } @@ -241,53 +253,52 @@ public class ShoppingCartBusinessImpl implements ShoppingCartBusiness { if (LeNumUtil.isValidId(vo.getStallId())) { AllocStall allocStall; if (stallMapById.containsKey(vo.getStallId())) { - allocStall =null; -// this.allocStallApi.getAllocStall(vo.getStallId()); + allocStall = this.allocStallApi.getAllocStall(vo.getStallId()); if (allocStall != null) { stallMapById.put(vo.getStallId(), allocStall); } } - allocStall =null; -// this.allocStallApi.getAllocStall(vo.getStallId()); + allocStall = this.allocStallApi.getAllocStall(vo.getStallId()); if (allocStall != null) { vo.setStallName(allocStall.getStallName()); } } } + } - protected void checkSubmitParam(OrderShoppingCartAddDTO addDTO) throws Exception { + protected void checkSubmitParam(OrderShoppingCartAddDTO addDTO) { JavaxValidateUtils.validate(addDTO); if (!this.supportOrderTypes().contains(addDTO.getOrderType())) { - throw new Exception(I18n.getMessage("order.un-support-order-type", new Object[0])); + throw new ServiceException(I18n.getMessage("order.un-support-order-type", new Object[0])); } else { if (OrderTypeEnum.isCanteenCategory(addDTO.getOrderType())) { if (addDTO.getOrderDate() == null || !LeNumUtil.isValidId(addDTO.getMealtimeType())) { - throw new Exception(I18n.getMessage("order.mobile.cart-need-date-mealtime", new Object[0])); + throw new ServiceException(I18n.getMessage("order.mobile.cart-need-date-mealtime", new Object[0])); } if (!DetailTypeEnum.isDishesCategory(addDTO.getDetailType())) { - throw new Exception(I18n.getMessage("order.un-support-detail-type", new Object[0])); + throw new ServiceException(I18n.getMessage("order.un-support-detail-type", new Object[0])); } if (!LeNumUtil.isValidId(addDTO.getMenuId())) { - throw new Exception(OrderTips.paramIllegal(":menuId(菜谱id)")); + throw new ServiceException(OrderTips.paramIllegal(":menuId(菜谱id)")); } if (!LeNumUtil.isValidId(addDTO.getCanteenId())) { - throw new Exception(OrderTips.paramIllegal(":canteenId(食堂id)")); + throw new ServiceException(OrderTips.paramIllegal(":canteenId(食堂id)")); } if (!LeNumUtil.isValidId(addDTO.getStallId())) { - throw new Exception(OrderTips.paramIllegal(":stallId(档口id)")); + throw new ServiceException(OrderTips.paramIllegal(":stallId(档口id)")); } } else if (OrderTypeEnum.isShopCategory(addDTO.getOrderType())) { if (!DetailTypeEnum.isProductType(addDTO.getDetailType())) { - throw new Exception(I18n.getMessage("order.un-support-detail-type", new Object[0])); + throw new ServiceException(I18n.getMessage("order.un-support-detail-type", new Object[0])); } if (!LeNumUtil.isValidId(addDTO.getCanteenId())) { - throw new Exception(OrderTips.paramIllegal(":canteenId(超市id)")); + throw new ServiceException(OrderTips.paramIllegal(":canteenId(超市id)")); } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/supermarket/api/SupermarketApi.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/supermarket/api/SupermarketApi.java index 3652c9be..9808ab06 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/supermarket/api/SupermarketApi.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/supermarket/api/SupermarketApi.java @@ -21,6 +21,7 @@ import com.bonus.core.supermarket.mapper.SupermarketProductMapper; import com.bonus.core.supermarket.model.SupermarketInfo; import com.bonus.core.supermarket.po.GoodsBuyLimitModel; import com.bonus.core.supermarket.po.WarehouseModel; +import com.bonus.core.supermarket.vo.SupermarketNotRemovedProductListVO; import com.bonus.core.supermarket.vo.SupermarketProductInfoImageVO; import com.bonus.core.supermarket.vo.SupermarketQueryProductInfoVO; import com.bonus.i18n.I18n; @@ -32,6 +33,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Iterator; @@ -321,29 +323,29 @@ public class SupermarketApi { return this.supermarketProductMapper.getProductImg(goodsIdList); } -// public List listNotRemovedProduct(SupermarketNotRemovedProductListDTO content) { -// log.info("[商超]_购物车_获取上架商品_入参:{}", content); -// if (!ObjectUtil.isEmpty(content.getSupermarketId()) && !CollUtil.isEmpty(content.getMaterialIdList())) { -// boolean ifRelateDrp = this.ifRelateDrp(content.getSupermarketId()); -// List resultList; -// if (ifRelateDrp) { -// resultList = this.supermarketProductMapper.listNotRemovedProduct(content, 1); -// } else { -// resultList = this.supermarketProductMapper.listNotRemovedProduct(content, (Integer)null); -// } -// -// boolean ifSupermarketMember = this.ifSupermarketMember(content.getCustId(), content.getSupermarketId()); -// if (!ifSupermarketMember) { -// resultList.forEach((s) -> { -// s.setPrefPrice((BigDecimal)null); -// }); -// } -// -// return resultList; -// } else { -// throw new LeException(I18n.getMessage("supermarket.shop-cert-material-not-null", new Object[0])); -// } -// } + public List listNotRemovedProduct(SupermarketNotRemovedProductListDTO content) { + log.info("[商超]_购物车_获取上架商品_入参:{}", content); + if (!ObjectUtil.isEmpty(content.getSupermarketId()) && !CollUtil.isEmpty(content.getMaterialIdList())) { + boolean ifRelateDrp = this.ifRelateDrp(content.getSupermarketId()); + List resultList; + if (ifRelateDrp) { + resultList = this.supermarketProductMapper.listNotRemovedProduct(content, 1); + } else { + resultList = this.supermarketProductMapper.listNotRemovedProduct(content, (Integer)null); + } + + boolean ifSupermarketMember = this.ifSupermarketMember(content.getCustId(), content.getSupermarketId()); + if (!ifSupermarketMember) { + resultList.forEach((s) -> { + s.setPrefPrice((BigDecimal)null); + }); + } + + return resultList; + } else { + throw new ServiceException(I18n.getMessage("supermarket.shop-cert-material-not-null", new Object[0])); + } + } public void checkProductLimitBuy(SmtCheckProductLimitBuyDTO content) { log.info("[商超]_限购校验_入参:{}", content); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/supermarket/mapper/SupermarketProductMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/supermarket/mapper/SupermarketProductMapper.java index 3bbb6b46..360517dd 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/supermarket/mapper/SupermarketProductMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/supermarket/mapper/SupermarketProductMapper.java @@ -2,10 +2,12 @@ package com.bonus.core.supermarket.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bonus.core.supermarket.dto.SupermarketNotRemovedProductListDTO; import com.bonus.core.supermarket.dto.SupermarketQueryProductInfoDTO; import com.bonus.core.supermarket.model.SupermarketProduct; import com.bonus.core.supermarket.po.GoodsBuyLimitModel; import com.bonus.core.supermarket.po.InventoryNumModel; +import com.bonus.core.supermarket.vo.SupermarketNotRemovedProductListVO; import com.bonus.core.supermarket.vo.SupermarketProductInfoImageVO; import com.bonus.core.supermarket.vo.SupermarketQueryProductInfoVO; import org.apache.ibatis.annotations.Mapper; @@ -59,8 +61,8 @@ public interface SupermarketProductMapper extends BaseMapper InventoryNumModel getProductInventory(@Param("supermarketId") Long supermarketId, @Param("supermarketDetailId") Long supermarketDetailId); // // List getPriceByMaterialIds(@Param("materialIds") List materialIds, @Param("warehouseId") Long warehouseId); -// -// List listNotRemovedProduct(@Param("content") SupermarketNotRemovedProductListDTO content, @Param("ifRelateDrp") Integer ifRelateDrp); + + List listNotRemovedProduct(@Param("content") SupermarketNotRemovedProductListDTO content, @Param("ifRelateDrp") Integer ifRelateDrp); List getProductImg(@Param("goodsIdList") List goodsIdList); diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/supermarket/SupermarketProductMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/supermarket/SupermarketProductMapper.xml index bbb0f36a..f9388cc1 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/supermarket/SupermarketProductMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/supermarket/SupermarketProductMapper.xml @@ -526,43 +526,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +