下单总入口,打烊店铺限制下单

This commit is contained in:
Jack 2025-10-27 15:54:05 +08:00
parent 2489bd66d0
commit 80ce73a168
5 changed files with 121 additions and 13 deletions

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2024. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
* Vestibulum commodo. Ut rhoncus gravida arcu.
*/
package com.suisung.mall.common.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
/**
* 标准的地址实体类
*/
public class StoreBizTimeInfoDTO implements Serializable {
private Integer store_id;
private Integer store_biz_state;
private String store_opening_hours;
private String store_close_hours;
}

View File

@ -1674,7 +1674,6 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
} else {
//未绑定手机返回参数封装,与前端约定该代码代表未绑定手机异常77011
return CommonResult.failed(I18nUtil._("请先绑定手机!"), 77011);
//throw new ApiException(I18nUtil._("请先绑定手机!"));
}
// 优惠券使用提醒
@ -6310,12 +6309,18 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
// 遍历多个店铺的订单记录
for (Map store_item : items) {
// 判断店铺状态关闭状态不可以下单
Integer currStoreId = Convert.toInt(store_item.get("store_id"));
Boolean store_is_open = Convert.toBool(store_item.get("store_is_open"));
if (!store_is_open) {
throw new ApiException(I18nUtil._("店铺关闭中,不可以下单!"));
}
// 判断店铺是否打烊打烊不能下单
if (CheckUtil.isEmpty(currStoreId) || CommonConstant.Disable2.equals(shopStoreBaseService.getStoreBizState(currStoreId))) {
throw new ApiException(I18nUtil._("店铺打烊中,不可以下单!"));
}
// 每个订单记录的商品列表
List<Map> item_items = (List<Map>) store_item.get("items");

View File

@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.suisung.mall.common.modules.store.ShopStoreBase;
import com.suisung.mall.common.pojo.dto.StoreBizTimeInfoDTO;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -31,10 +33,23 @@ public interface ShopStoreBaseMapper extends BaseMapper<ShopStoreBase> {
/**
* 搜索附近店铺排序从近到远 2024-12-26
*
* @param page
* @param params 省份province_id城市city_id县county_id店铺分类store_category_id分店subsite_id店铺名称关键字store_name
* @return
*/
IPage<Map> getNearShop2(Page<Map> page, @Param("params") Map params);
/**
* 获取店铺营业时间信息
*
* @param storeId
* @return
*/
@Select("SELECT ssb.store_id, ssb.store_biz_state, ssi.store_opening_hours, ssi.store_close_hours " +
" LEFT FROM shop_store_base ssb JOIN shop_store_info ssi ON ssb.store_id = ssi.store_id " +
" WHERE ssb.store_id = #{storeId} LIMIT 1")
StoreBizTimeInfoDTO getStoreBizTimeInfo(@Param("storeId") Integer storeId);
}

View File

@ -237,6 +237,14 @@ public interface ShopStoreBaseService extends IBaseService<ShopStoreBase> {
*/
Integer getStoreBizState(ShopStoreBase shopStoreBase, ShopStoreInfo shopStoreInfo);
/**
* 根据店铺Id获取店铺营业状态
*
* @param storeId
* @return
*/
Integer getStoreBizState(Integer storeId);
// Page<ShopStoreBase> getMobileStoreList(Integer page, Integer rows);
}

View File

@ -44,6 +44,7 @@ import com.suisung.mall.common.modules.store.*;
import com.suisung.mall.common.modules.user.ShopUserFavoritesStore;
import com.suisung.mall.common.pojo.dto.GpsDTO;
import com.suisung.mall.common.pojo.dto.StandardAddressDTO;
import com.suisung.mall.common.pojo.dto.StoreBizTimeInfoDTO;
import com.suisung.mall.common.service.impl.BaiduMapServiceImpl;
import com.suisung.mall.common.utils.*;
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
@ -4200,38 +4201,89 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
*/
@Override
public Integer getStoreBizState(ShopStoreBase shopStoreBase, ShopStoreInfo shopStoreInfo) {
try {
// 参数校验
if (shopStoreBase == null || shopStoreInfo == null) {
log.warn("店铺基础信息或详细信息为空,无法确定营业状态");
return CommonConstant.Enable;
}
// 参数校验
if (shopStoreBase == null || shopStoreInfo == null) {
log.warn("店铺基础信息或详细信息为空,无法确定营业状态");
return CommonConstant.Disable2;
}
try {
Integer storeBizState = shopStoreBase.getStore_biz_state();
String openingHours = shopStoreInfo.getStore_opening_hours();
String closingHours = shopStoreInfo.getStore_close_hours();
// 检查店铺是否营业中且营业时间已设置
if (CommonConstant.Enable.equals(storeBizState)
&& StrUtil.isNotEmpty(openingHours)
&& StrUtil.isNotEmpty(closingHours)) {
if (CommonConstant.Enable.equals(storeBizState) && !StrUtil.hasBlank(openingHours, closingHours)) {
// 检查当前时间是否在营业时间内
if (!DateTimeUtils.isCurrentTimeInRange(openingHours, closingHours)) {
// 不在营业时间内返回已打烊状态
return CommonConstant.Disable2;
}
return CommonConstant.Enable;
}
// 返回原始营业状态
return storeBizState;
} catch (Exception e) {
// 处理异常避免影响主流程
log.error("检查店铺营业状态时发生异常shopStoreBase: {}, shopStoreInfo: {}",
shopStoreBase, shopStoreInfo, e);
return CommonConstant.Enable;
log.error("检查店铺营业状态时发生异常storeId: {}",
shopStoreBase != null ? shopStoreBase.getStore_id() : "unknown", e);
return CommonConstant.Disable2;
}
}
/**
* 根据店铺ID获取营业状态
*
* @param storeId 店铺ID
* @return 营业状态1-营业中2-已打烊
*/
public Integer getStoreBizState(Integer storeId) {
// 参数校验
if (CheckUtil.isEmpty(storeId)) {
log.warn("店铺ID为空无法确定营业状态");
return CommonConstant.Disable2;
}
try {
StoreBizTimeInfoDTO storeBizTimeInfo = baseMapper.getStoreBizTimeInfo(storeId);
if (storeBizTimeInfo == null) {
log.warn("未找到店铺营业时间信息storeId: {}", storeId);
return CommonConstant.Disable2;
}
Integer storeBizState = storeBizTimeInfo.getStore_biz_state();
String openingHours = storeBizTimeInfo.getStore_opening_hours();
String closingHours = storeBizTimeInfo.getStore_close_hours();
// 检查店铺是否营业中且营业时间已设置
if (CommonConstant.Enable.equals(storeBizState)
&& StrUtil.isNotBlank(openingHours)
&& StrUtil.isNotBlank(closingHours)) {
// 检查当前时间是否在营业时间内
if (!DateTimeUtils.isCurrentTimeInRange(openingHours, closingHours)) {
// 不在营业时间内返回已打烊状态
log.debug("店铺当前不在营业时间内storeId: {}, openingHours: {}, closingHours: {}",
storeId, openingHours, closingHours);
return CommonConstant.Disable2;
}
return CommonConstant.Enable;
}
// 返回原始营业状态处理null情况
Integer resultState = storeBizState != null ? storeBizState : CommonConstant.Disable2;
log.debug("返回店铺营业状态storeId: {}, state: {}", storeId, resultState);
return resultState;
} catch (Exception e) {
// 处理异常避免影响主流程
log.error("检查店铺营业状态时发生异常storeId: {}", storeId, e);
return CommonConstant.Disable2;
}
}
/**
* 更新店铺分账比例
*