下单总入口,打烊店铺限制下单
This commit is contained in:
parent
ff66979876
commit
f87242a929
@ -22,6 +22,7 @@ import java.io.Serializable;
|
||||
*/
|
||||
public class StoreBizTimeInfoDTO implements Serializable {
|
||||
private Integer store_id;
|
||||
private String store_name;
|
||||
private Integer store_biz_state;
|
||||
private String store_opening_hours;
|
||||
private String store_close_hours;
|
||||
|
||||
@ -6318,8 +6318,9 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
}
|
||||
|
||||
// 判断店铺是否打烊?打烊不能下单
|
||||
if (CheckUtil.isEmpty(currStoreId) || CommonConstant.Disable2.equals(shopStoreBaseService.getStoreBizState(currStoreId))) {
|
||||
throw new ApiException(I18nUtil._("店铺打烊中,不可以下单!"));
|
||||
Pair<Integer, String> storeBizState = shopStoreBaseService.getStoreBizState(currStoreId);
|
||||
if (storeBizState != null && CommonConstant.Disable2.equals(storeBizState.getFirst())) {
|
||||
throw new ApiException(I18nUtil._(storeBizState.getSecond() + ",无法提交订单。"));
|
||||
}
|
||||
|
||||
// 每个订单记录的商品列表
|
||||
|
||||
@ -47,8 +47,8 @@ public interface ShopStoreBaseMapper extends BaseMapper<ShopStoreBase> {
|
||||
* @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 " +
|
||||
@Select("SELECT ssb.store_id, ssb.store_name, ssb.store_biz_state, ssi.store_opening_hours, ssi.store_close_hours " +
|
||||
" FROM shop_store_base ssb LEFT 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);
|
||||
|
||||
|
||||
@ -243,7 +243,7 @@ public interface ShopStoreBaseService extends IBaseService<ShopStoreBase> {
|
||||
* @param storeId
|
||||
* @return
|
||||
*/
|
||||
Integer getStoreBizState(Integer storeId);
|
||||
Pair<Integer, String> getStoreBizState(Integer storeId);
|
||||
|
||||
// Page<ShopStoreBase> getMobileStoreList(Integer page, Integer rows);
|
||||
|
||||
|
||||
@ -4239,18 +4239,19 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
* @param storeId 店铺ID
|
||||
* @return 营业状态:1-营业中;2-已打烊;
|
||||
*/
|
||||
public Integer getStoreBizState(Integer storeId) {
|
||||
@Override
|
||||
public Pair<Integer, String> getStoreBizState(Integer storeId) {
|
||||
// 参数校验
|
||||
if (CheckUtil.isEmpty(storeId)) {
|
||||
log.warn("店铺ID为空,无法确定营业状态");
|
||||
return CommonConstant.Disable2;
|
||||
return Pair.of(CommonConstant.Disable2, "店铺营业状态有误");
|
||||
}
|
||||
|
||||
try {
|
||||
StoreBizTimeInfoDTO storeBizTimeInfo = baseMapper.getStoreBizTimeInfo(storeId);
|
||||
if (storeBizTimeInfo == null) {
|
||||
log.warn("未找到店铺营业时间信息,storeId: {}", storeId);
|
||||
return CommonConstant.Disable2;
|
||||
return Pair.of(CommonConstant.Disable2, "店铺营业状态有误");
|
||||
}
|
||||
|
||||
Integer storeBizState = storeBizTimeInfo.getStore_biz_state();
|
||||
@ -4266,20 +4267,25 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
// 不在营业时间内,返回已打烊状态
|
||||
log.debug("店铺当前不在营业时间内,storeId: {}, openingHours: {}, closingHours: {}",
|
||||
storeId, openingHours, closingHours);
|
||||
return CommonConstant.Disable2;
|
||||
return Pair.of(CommonConstant.Disable2, String.format("%s营业时间段%s-%s", storeBizTimeInfo.getStore_name(),
|
||||
openingHours, closingHours));
|
||||
}
|
||||
return CommonConstant.Enable;
|
||||
|
||||
return Pair.of(CommonConstant.Enable, "");
|
||||
}
|
||||
|
||||
// 返回原始营业状态(处理null情况)
|
||||
Integer resultState = storeBizState != null ? storeBizState : CommonConstant.Disable2;
|
||||
log.debug("返回店铺营业状态,storeId: {}, state: {}", storeId, resultState);
|
||||
return resultState;
|
||||
if (resultState == CommonConstant.Disable2) {
|
||||
return Pair.of(resultState, String.format("%s打烊中", storeBizTimeInfo.getStore_name()));
|
||||
}
|
||||
return Pair.of(resultState, "");
|
||||
|
||||
} catch (Exception e) {
|
||||
// 处理异常,避免影响主流程
|
||||
log.error("检查店铺营业状态时发生异常,storeId: {}", storeId, e);
|
||||
return CommonConstant.Disable2;
|
||||
log.error("检查店铺营业状态发生异常,storeId: {}", storeId, e);
|
||||
return Pair.of(CommonConstant.Disable2, "无法获取店铺营业状态");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -58,6 +58,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.util.Pair;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -1052,8 +1053,9 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
||||
// 店铺Id
|
||||
Integer storeId = Convert.toInt(product_row.get("store_id"));
|
||||
// 判断店铺是否打烊?打烊不能放入购物车
|
||||
if (CheckUtil.isEmpty(storeId) || CommonConstant.Disable2.equals(shopStoreBaseService.getStoreBizState(storeId))) {
|
||||
throw new ApiException(I18nUtil._("店铺打烊中,商品无法加入购物车!"));
|
||||
Pair<Integer, String> storeBizState = shopStoreBaseService.getStoreBizState(storeId);
|
||||
if (storeBizState != null && CommonConstant.Disable2.equals(storeBizState.getFirst())) {
|
||||
throw new ApiException(I18nUtil._(storeBizState.getSecond() + ",无法加购商品。"));
|
||||
}
|
||||
|
||||
Integer cart_type = Convert.toInt(data.get("cart_type"));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user