店铺状态

This commit is contained in:
Jack 2025-11-11 21:05:06 +08:00
parent 41dbafffab
commit af9cce0db1
11 changed files with 192 additions and 135 deletions

View File

@ -129,10 +129,12 @@ public class CommonConstant {
public final static Integer MIN_DELAY_MINUTES_FOR_BOOKING_ORDER = 50;
// 店铺营业状态1-营业中2-已打烊3-开业(活动)筹备中
//1-营业中
// 店铺营业状态1-开业营业中且在营业时间内12-开业打烊中但在营业时间外2-停业中3-开业或活动筹备中
// 1-开业营业中且在营业时间内
public final static Integer Store_Biz_State_Opening = 1;
//2-已打烊
// 12-开业打烊中但在营业时间外
public final static Integer Store_Biz_State_Opening2 = 12;
//2-停业中
public final static Integer Store_Biz_State_Closed = 2;
//3-开业(活动)筹备中
public final static Integer Store_Biz_State_PreActivity = 3;

View File

@ -80,7 +80,7 @@ public class ShopStoreBase implements Serializable {
@ApiModelProperty(value = "店铃声开关1-开启2-关闭;")
private Integer ringtone_is_enable;
@ApiModelProperty(value = "店铺营业状态1-营业中2-已打烊3-开业(活动)筹备中;")
@ApiModelProperty(value = "店铺营业状态1-开业营业中且在营业时间内12-开业打烊中但在营业时间外2-停业中3-开业(或活动)筹备中;")
private Integer store_biz_state;
@ApiModelProperty(value = "开业(活动)筹备日期 yyyy-MM-dd")

View File

@ -744,7 +744,7 @@ public class ShopActivityCutpriceServiceImpl extends BaseServiceImpl<ShopActivit
log.debug("更新操作2未匹配到任何记录");
}
// 3砍价活动结束后定时更改3-砍价助力进行中和6-砍价助力已完成待下单的状态为 4-砍价过期失效和2-砍价未下单已取消
/// 3砍价活动结束后定时更改3-砍价助力进行中和6-砍价助力已完成待下单的状态为 4-砍价过期失效和2-砍价未下单已取消
// 处理状态3(砍价助力进行中) -> 状态4(砍价过期失效)
updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("state", CommonConstant.CutPrice_Order_State_ING)

View File

@ -169,32 +169,44 @@ public class ShopBaseConfigServiceImpl extends BaseServiceImpl<ShopBaseConfigMap
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
// 产生验证码图片的图片的宽是116高是36验证码的长度是4干扰线的条数是20
// 参数校验
String verify_token = getParameter("verify_token", String.class);
if (StrUtil.isBlank(verify_token)) {
logger.warn("验证码缺少 verify_token 参数");
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return;
}
// 产生验证码图片
LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(120, 40, 4, 20);
// 拼接时间戳
String verify_token = getParameter("verify_token", String.class);
//获取验证码图片中的字符串
// 生成Redis键
String code = RedisConstant.Verifycode_NameSpace + verify_token + lineCaptcha.getCode();
redisService.set(code, "", 60); // 有效期一分钟
//获取到response的响应流
// 写入Redis并检查结果
redisService.set(code, "", 60);
// 输出图片
BufferedImage image = lineCaptcha.getImage();
OutputStream os = null;
try {
os = response.getOutputStream();
ImageIO.write(image, "png", os);
os.flush();
} catch (IOException e) {
logger.error("获取验证码响应异常!" + e.getMessage(), e);
logger.error("获取验证码响应异常: {}", e.getMessage(), e);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
} finally {
try {
assert os != null;
os.close();
} catch (IOException e) {
logger.error("获取验证码响应异常!" + e.getMessage(), e);
if (os != null) {
try {
os.close();
} catch (IOException e) {
logger.error("关闭输出流异常:{}", e.getMessage(), e);
}
}
}
}
}

View File

@ -2333,6 +2333,8 @@ public class LakalaApiServiceImpl implements LakalaApiService {
if (CheckUtil.isEmpty(refCanSeparateAmt)) {
log.warn("[分账操作] 拉卡拉可分账金额为空或为0将使用系统计算金额, orderId={}, merchantNo={}",
orderId, lklMerchantNo);
} else {
log.error("[分账操作] 注意:拉卡拉提供的可分账金额无效:{}", refCanSeparateAmt);
}
}
@ -2420,12 +2422,13 @@ public class LakalaApiServiceImpl implements LakalaApiService {
// 更新分账计算结果
shopOrderLkl.setSeparate_remark(lklSeparateDTO.toString()); // 写入分账具体情况
if (CheckUtil.isEmpty(refCanSeparateAmt)) {
// 如果拉卡拉参考可分账金额无效使用程序的计算结果的可分账金额
refCanSeparateAmt = lklSeparateDTO.getCanSeparateAmount();
}
shopOrderLkl.setSplit_amt_ref(refCanSeparateAmt);
// 可分账金额校验
if (CheckUtil.isEmpty(refCanSeparateAmt) || refCanSeparateAmt <= 0) {
if (CheckUtil.isEmpty(refCanSeparateAmt)) {
String errorMsg = String.format("[分账操作] 可分账金额低于1分钱跳过分账, orderId=%s, merchantNo=%s, amount=%d",
orderId, merchantNo, refCanSeparateAmt);
log.error(errorMsg);
@ -3712,8 +3715,10 @@ public class LakalaApiServiceImpl implements LakalaApiService {
orderPayAmount, shippingFeeInner, mchSplitRatioRaw, platSplitRatio,
agent1stRatio, agent2ndRatio, refCanSeparateAmt);
String errMsg = "";
// 参数校验
if (orderPayAmount == null || orderPayAmount <= 0) {
// errMsg = String.format("订单支付金额参数无效: orderPayAmount={}", orderPayAmount);
log.warn("[分账参数计算] 订单支付金额参数无效: orderPayAmount={}", orderPayAmount);
return Pair.of(false, null);
}
@ -3760,9 +3765,11 @@ public class LakalaApiServiceImpl implements LakalaApiService {
}
// 设置参考可分账金额
if (refCanSeparateAmt != null && refCanSeparateAmt > 0) {
if (CheckUtil.isNotEmpty(refCanSeparateAmt)) {
lklSeparateDTO.setRefCanSeparateAmount(refCanSeparateAmt);
log.debug("[分账参数计算] 设置参考可分账金额: {}", refCanSeparateAmt);
log.debug("[分账参数计算] 拉卡拉的参考可分账金额: {}", refCanSeparateAmt);
} else {
log.error("[分账参数计算] 注意:拉卡拉的参考可分账金额无效:{}", refCanSeparateAmt);
}
try {

View File

@ -5323,7 +5323,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
ShopProductItem shopProductItem = shopProductItemService.get(item_id);
if (shopProductItem != null) {
logger.info("无法获取订单中的商品,请检查!");//商品存在才执行库存扣减
// throw new ApiException(I18nUtil._("无法获取订单中的商品,请检查!"));
// throw new ApiException(I18nUtil._("无法获取订单中的商品,请检查!"));
Integer item_quantity_frozen = shopProductItem.getItem_quantity_frozen();
int quantity_frozen = item_quantity_frozen - order_item_quantity;
shopProductItem.setItem_quantity_frozen(quantity_frozen > 0 ? quantity_frozen : 0);
@ -6325,9 +6325,9 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
throw new ApiException(I18nUtil._("店铺关闭中,不可以下单!"));
}
// 判断店铺是否打烊打烊不能下单
// 判断店铺是否已歇业不能下单
Pair<Integer, String> storeBizState = shopStoreBaseService.getStoreBizState(currStoreId);
if (storeBizState != null && CommonConstant.Disable2.equals(storeBizState.getFirst())) {
if (storeBizState != null && CommonConstant.Store_Biz_State_Closed.equals(storeBizState.getFirst())) {
throw new ApiException(I18nUtil._(storeBizState.getSecond() + ",无法提交订单。"));
}

View File

@ -26,6 +26,7 @@ import com.suisung.mall.common.modules.order.ShopOrderStateLog;
import com.suisung.mall.common.modules.pay.PayPlantformResource;
import com.suisung.mall.common.modules.plantform.ShopPlantformFeedback;
import com.suisung.mall.common.modules.product.ShopProductComment;
import com.suisung.mall.common.modules.store.ShopStoreBase;
import com.suisung.mall.common.modules.store.ShopStoreInfo;
import com.suisung.mall.common.pojo.dto.BookingArgDTO;
import com.suisung.mall.common.pojo.res.ThirdApiRes;
@ -59,6 +60,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
@ -967,16 +969,24 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
return Pair.of(false, "[预约单校验] 开始时间不能晚于截止时间");
}
ShopStoreBase shopStoreBase = shopStoreBaseService.getById(storeId);
// 5. 店铺信息检查
ShopStoreInfo shopStoreInfo = shopStoreInfoService.getShopStoreInfoByStoreId(storeId);
if (shopStoreInfo == null) {
if (shopStoreBase == null || shopStoreInfo == null) {
return Pair.of(false, "[预约单校验] 店铺信息有误");
}
if (CheckUtil.isEmpty(shopStoreBase.getStore_is_open())
|| CommonConstant.Store_Biz_State_Closed.equals(shopStoreBase.getStore_biz_state())) {
return Pair.of(false, "[预约单校验] 店铺已歇业,无法下单");
}
if (StrUtil.isBlank(shopStoreInfo.getStore_opening_hours()) || StrUtil.isBlank(shopStoreInfo.getStore_close_hours())) {
shopStoreInfo.setStore_opening_hours("00:00");
shopStoreInfo.setStore_close_hours("23:59");
logger.warn("[预约单校验] 店铺营业时间未设置,请联系商家,默认指定 {}-{}", shopStoreInfo.getStore_opening_hours(), shopStoreInfo.getStore_close_hours());
// shopStoreInfo.setStore_opening_hours("00:00");
// shopStoreInfo.setStore_close_hours("23:59");
// logger.warn("[预约单校验] 店铺营业时间未设置,请联系商家,默认指定 {}-{}", shopStoreInfo.getStore_opening_hours(), shopStoreInfo.getStore_close_hours());
logger.warn("[预约单校验] 店铺营业时间未设置,请联系商家{}", shopStoreInfo.getStore_id());
return Pair.of(false, "[预约单校验] 店铺营业时间未设置,请联系商家");
}
@ -1035,7 +1045,7 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|| StrUtil.isBlank(storeBizTimeRange.getFirst())
|| StrUtil.isBlank(storeBizTimeRange.getSecond())) {
// 没有具体的营业时间段
logger.info("[生成预约参数] 未找到营业时间");
logger.info("[生成预约参数] 未找到店铺相关营业时间");
return Collections.emptyList();
}
@ -1252,10 +1262,22 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
return Collections.emptyList();
}
// 3. 批量获取店铺信息
// 3. 先获取符合条件的 store_id 列表,关联shop_store_base表要求store_is_open=1开启且store_biz_state!=2非关闭状态
QueryWrapper<ShopStoreBase> storeBaseQueryWrapper = new QueryWrapper<>();
storeBaseQueryWrapper.select("store_id")
.eq("store_is_open", CommonConstant.Enable)
.ne("store_biz_state", CommonConstant.Store_Biz_State_Closed)
.in("store_id", uniqueStoreIds);
List<Serializable> validStoreIds = shopStoreBaseService.findKey(storeBaseQueryWrapper);
if (validStoreIds.isEmpty()) {
return Collections.emptyList();
}
QueryWrapper<ShopStoreInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.select("store_opening_hours", "store_close_hours"); // 只查询必要字段
queryWrapper.in("store_id", storeIds);
queryWrapper.in("store_id", validStoreIds);
List<ShopStoreInfo> shopStoreInfos = shopStoreInfoService.find(queryWrapper);
// 4. 转换为营业时间映射列表

View File

@ -478,13 +478,13 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
BigDecimal item_unit_points = Convert.toBigDecimal(productItemMap.get("item_unit_points"));
BigDecimal item_unit_price = Convert.toBigDecimal(productItemMap.get("item_unit_price"));
Integer item_quantity = Convert.toInt(productItemMap.get("item_quantity"));
String is_open_automatic=Convert.toStr(productItemMap.get("is_open_automatic"),DicEnum.YESORNO_0.getCode());
if(is_open_automatic.equals(DicEnum.YESORNO_1.getCode())){
Integer automatic=Convert.toInt(productItemMap.get("automatic"),0);
if(automatic<item_quantity){
String is_open_automatic = Convert.toStr(productItemMap.get("is_open_automatic"), DicEnum.YESORNO_0.getCode());
if (is_open_automatic.equals(DicEnum.YESORNO_1.getCode())) {
Integer automatic = Convert.toInt(productItemMap.get("automatic"), 0);
if (automatic < item_quantity) {
throw new ApiException("次日补全不能小于库存");
}
if(automatic<1){
if (automatic < 1) {
throw new ApiException("次日补全必须大于0");
}
item.setAutomatic(automatic);
@ -2066,6 +2066,12 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
Integer product_sale_num = Convert.toInt(product_index_row.get("product_sale_num"));
// if (product_base_row != null) {
// // 获取店铺营业状态1-开业营业中且在营业时间内12-开业打烊中但在营业时间外 2-停业中3-开业或活动筹备中
// Pair<Integer, String> store_biz_state = shopStoreBaseService.getStoreBizState(Convert.toInt(product_base_row.get("store_id")));
// product_base_row.put("store_biz_state", store_biz_state.getFirst());
// }
//虚拟销量
// todo 是否为商家后台访问
if (null == user || !(user.isAdmin())) {
@ -5377,7 +5383,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
// shopProductIndexList.get(i).setProduct_unit_points(BigDecimal.ZERO);
shopProductIndexList.get(i).setProduct_unit_price_max(base.getProduct_market_price());
shopProductIndexList.get(i).setProduct_unit_sp(Convert.toBigDecimal(base.getProduct_unit_sp()));
// shopProductIndexList.get(i).setProduct_sale_time(base.getProduct_sale_time().getTime());
// shopProductIndexList.get(i).setProduct_sale_time(base.getProduct_sale_time().getTime());
shopProductIndexList.get(i).setProduct_verify_id(base.getProduct_verify_id());
shopProductIndexList.get(i).setProduct_state_id(base.getProduct_state_id());
shopProductIndexList.get(i).setProduct_src_id(existId);
@ -5512,8 +5518,8 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
// 1. 批量新增
if (CollUtil.isNotEmpty(newProducts)) {
// 4. 批量生成新商品的ID
List<Long> newIds=new ArrayList<>();
synchronized (this){
List<Long> newIds = new ArrayList<>();
synchronized (this) {
newIds = shopNumberSeqService.batchCreateNextNo("product_id", newProducts.size());
}
if (newIds == null || newIds.size() != newProducts.size()) {
@ -5936,8 +5942,8 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
List<ShopProductInfo> newShopProductInfoList) {
List<Serializable> itemIds = new ArrayList<>();
if (CollUtil.isEmpty(items)) return itemIds;
List<Long> generatedIds =new ArrayList<>();
synchronized (this){
List<Long> generatedIds = new ArrayList<>();
synchronized (this) {
generatedIds = shopNumberSeqService.batchCreateNextNo("item_id", items.size());
}
// Map<String,String> cacheMap=new HashMap<>();
@ -6460,99 +6466,99 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
@Override
public List<ShopProductBase> findPageMapping(Integer store_id, Integer pageNum, Integer pageSize) {
return shopProductBaseMapper.findPageMapping(store_id,(pageNum-1)*pageSize,pageSize);
return shopProductBaseMapper.findPageMapping(store_id, (pageNum - 1) * pageSize, pageSize);
}
@Override
public Map getProductByProductNumber(String productNumber) {
UserDto userDto= ContextUtil.getCurrentUser();
String store_id=userDto.getStore_id();
UserDto userDto = ContextUtil.getCurrentUser();
String store_id = userDto.getStore_id();
Map data = new HashMap();
QueryWrapper<ShopProductIndex> cond_row = new QueryWrapper<>();
if (StrUtil.isNotBlank(productNumber)) {
cond_row.eq("product_number", productNumber);
}
cond_row.eq("store_id",store_id);
cond_row.eq("store_id", store_id);
List<ShopProductIndex> lists = shopProductIndexService.list(cond_row);
if(lists.isEmpty()){
if (lists.isEmpty()) {
return null;
}
ShopProductIndex shopProductIndexFind=lists.get(0);
ShopProductIndex shopProductIndexFind = lists.get(0);
// todo lc
// data.put("productBase",shopProductIndexFind);
// data.put("productBase",shopProductIndexFind);
//判断是否为商家且开启供应商判断是否已经加入分销中
Long productId= shopProductIndexFind.getProduct_id();
List<Integer> product_ids= Collections.singletonList(Math.toIntExact(productId));
data.put("baseInfo", getProduct(product_ids));
List<Map> baseInfo = (List<Map>) data.get("baseInfo");
Long productId = shopProductIndexFind.getProduct_id();
List<Integer> product_ids = Collections.singletonList(Math.toIntExact(productId));
data.put("baseInfo", getProduct(product_ids));
List<Map> baseInfo = (List<Map>) data.get("baseInfo");
baseInfo.forEach(s -> {
String str_product_spec = (String) s.get("product_spec");
if (StrUtil.isNotBlank(str_product_spec) && StrUtil.equals(str_product_spec, "[]")) {
s.put("product_spec", JSONUtil.parseArray(str_product_spec));
}
String str_product_assist = (String) s.get("product_assist");
if (StrUtil.isNotBlank(str_product_assist) && StrUtil.equals(str_product_assist, "{}")) {
s.put("product_assist", JSONUtil.parseObj(str_product_assist));
}
});
QueryWrapper<ShopProductItem> itemQueryWrapper = new QueryWrapper<>();
itemQueryWrapper.eq("product_id", productId);
List<ShopProductItem> productItems = shopProductItemService.find(itemQueryWrapper);
if (CollectionUtil.isNotEmpty(productItems)) {
for (Map item : baseInfo) {
List<ShopProductItem> shopProductItems = productItems.stream().filter(s -> ObjectUtil.equal(s.getProduct_id(), productId)).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(shopProductItems)) {
BigDecimal product_advice_price = shopProductItems.stream().map(ShopProductItem::getItem_advice_price).min(BigDecimal::compareTo).get();
item.put("product_advice_price", product_advice_price);
}
}
baseInfo.forEach(s -> {
String str_product_spec = (String) s.get("product_spec");
if (StrUtil.isNotBlank(str_product_spec) && StrUtil.equals(str_product_spec, "[]")) {
s.put("product_spec", JSONUtil.parseArray(str_product_spec));
}
List<ShopProductItem> productItemS = productItems.stream().filter(distinctByKey(o -> o.getProduct_id())).collect(Collectors.toList());
data.put("items",productItemS);//商品规格列表
// shop_product_info
ShopProductInfo shopProductInfo = shopProductInfoService.get(productId);
// shop_product_detail
ShopProductDetail shopProductDetail = shopProductDetailService.get(productId);
// shop_product_index
ShopProductIndex shopProductIndex = shopProductIndexService.get(productId);
// shop_product_image
QueryWrapper<ShopProductImage> imageQueryWrapper = new QueryWrapper<>();
imageQueryWrapper.eq("product_id", productId);
List<ShopProductImage> shopProductImages = shopProductImageService.find(imageQueryWrapper);
// shop_product_assist_index
QueryWrapper<ShopProductAssistIndex> indexQueryWrapper = new QueryWrapper<>();
indexQueryWrapper.eq("product_id", productId);
List<ShopProductAssistIndex> assistIndexList = assistIndexService.find(indexQueryWrapper);
HashMap<String, Object> map = new HashMap<>();
if(com.suisung.mall.common.utils.StringUtils.isEmpty(shopProductInfo.getProduct_spec())){
shopProductInfo.setProduct_spec("[]");
String str_product_assist = (String) s.get("product_assist");
if (StrUtil.isNotBlank(str_product_assist) && StrUtil.equals(str_product_assist, "{}")) {
s.put("product_assist", JSONUtil.parseObj(str_product_assist));
}
map.put("shop_product_info", shopProductInfo);
map.put("shop_product_image", shopProductImages);
map.put("shop_product_detail", shopProductDetail);
map.put("shop_product_index", shopProductIndex);
map.put("shop_product_assist_index", assistIndexList);
});
// 虚拟商品信息表
Integer kind_id = shopProductIndex.getKind_id();
if (ObjectUtil.equal(kind_id, StateCode.PRODUCT_KIND_FUWU)) {
ShopProductValidPeriod validPeriod = shopProductValidPeriodService.get(productId);
map.put("shop_product_valid_period", validPeriod);
QueryWrapper<ShopProductItem> itemQueryWrapper = new QueryWrapper<>();
itemQueryWrapper.eq("product_id", productId);
List<ShopProductItem> productItems = shopProductItemService.find(itemQueryWrapper);
if (CollectionUtil.isNotEmpty(productItems)) {
for (Map item : baseInfo) {
List<ShopProductItem> shopProductItems = productItems.stream().filter(s -> ObjectUtil.equal(s.getProduct_id(), productId)).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(shopProductItems)) {
BigDecimal product_advice_price = shopProductItems.stream().map(ShopProductItem::getItem_advice_price).min(BigDecimal::compareTo).get();
item.put("product_advice_price", product_advice_price);
}
}
data.put("productInfo",map);
Integer category_id=productItems.get(0).getCategory_id();
ShopBaseProductCategory shopBaseProductCategory= shopBaseProductCategoryService.get(category_id);
data.put("category",shopBaseProductCategory);
Integer typeId=shopBaseProductCategory.getType_id();
data.put("shopBaseProductType",shopBaseProductTypeService.getType(String.valueOf(typeId), productId)) ;
}
List<ShopProductItem> productItemS = productItems.stream().filter(distinctByKey(o -> o.getProduct_id())).collect(Collectors.toList());
data.put("items", productItemS);//商品规格列表
// shop_product_info
ShopProductInfo shopProductInfo = shopProductInfoService.get(productId);
// shop_product_detail
ShopProductDetail shopProductDetail = shopProductDetailService.get(productId);
// shop_product_index
ShopProductIndex shopProductIndex = shopProductIndexService.get(productId);
// shop_product_image
QueryWrapper<ShopProductImage> imageQueryWrapper = new QueryWrapper<>();
imageQueryWrapper.eq("product_id", productId);
List<ShopProductImage> shopProductImages = shopProductImageService.find(imageQueryWrapper);
// shop_product_assist_index
QueryWrapper<ShopProductAssistIndex> indexQueryWrapper = new QueryWrapper<>();
indexQueryWrapper.eq("product_id", productId);
List<ShopProductAssistIndex> assistIndexList = assistIndexService.find(indexQueryWrapper);
HashMap<String, Object> map = new HashMap<>();
if (com.suisung.mall.common.utils.StringUtils.isEmpty(shopProductInfo.getProduct_spec())) {
shopProductInfo.setProduct_spec("[]");
}
map.put("shop_product_info", shopProductInfo);
map.put("shop_product_image", shopProductImages);
map.put("shop_product_detail", shopProductDetail);
map.put("shop_product_index", shopProductIndex);
map.put("shop_product_assist_index", assistIndexList);
// 虚拟商品信息表
Integer kind_id = shopProductIndex.getKind_id();
if (ObjectUtil.equal(kind_id, StateCode.PRODUCT_KIND_FUWU)) {
ShopProductValidPeriod validPeriod = shopProductValidPeriodService.get(productId);
map.put("shop_product_valid_period", validPeriod);
}
data.put("productInfo", map);
Integer category_id = productItems.get(0).getCategory_id();
ShopBaseProductCategory shopBaseProductCategory = shopBaseProductCategoryService.get(category_id);
data.put("category", shopBaseProductCategory);
Integer typeId = shopBaseProductCategory.getType_id();
data.put("shopBaseProductType", shopBaseProductTypeService.getType(String.valueOf(typeId), productId));
return data;
}

View File

@ -487,7 +487,7 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl<ShopProductItemM
data.put("product_analytics", analytics_row);
// 营业时间段直接影响到 营业状态字段
// store_biz_state 店铺营业状态1-营业中2-已打烊3-开业(活动)筹备中
// store_biz_state 店铺营业状态1-开业营业中且在营业时间内12-开业打烊中但在营业时间外2-停业中3-开业或活动筹备中
baseMap.put("store_biz_state", shopStoreBaseService.getStoreBizState(shopStoreBase, shopStoreInfo));
data.put("store_info", baseMap);
@ -2281,7 +2281,7 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl<ShopProductItemM
queryWrapper.or(q -> q.eq("store_id", store_id).eq("item_number", productNumber));
});
queryWrapper.eq("store_id", store_id);
queryWrapper.groupBy("product_id","category_id");
queryWrapper.groupBy("product_id", "category_id");
List<ShopProductItem> shopProductItems = this.list(queryWrapper);
// Map map=shopProductItems.stream().collect(Collectors.toMap(ShopProductItem::getProduct_id,shopProductItem->shopProductItem.getMergedItemId()
// +"_"+shopProductItem.getMergedUnitPrices()));

View File

@ -312,8 +312,12 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
row.put("item_id", Convert.toList(Long.class, row.get("item_id")));
row.put("store_latitude", Convert.toDouble(row.get("store_latitude")));
row.put("store_longitude", Convert.toDouble(row.get("store_longitude")));
}
// store_biz_state 店铺营业状态1-开业营业中且在营业时间内12-开业打烊中但在营业时间外 2-停业中3-开业或活动筹备中
Pair<Integer, String> retPair = getStoreBizState(Convert.toInt(row.get("store_id")));
row.put("store_biz_state", retPair.getFirst());
}
String default_image = accountBaseConfigService.getConfig("default_image");
if (CollUtil.isNotEmpty(rows)) {
@ -1504,7 +1508,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
store_id = Convert.toInt(user.getStore_id());
}
if (ObjectUtil.isEmpty(store_id)) {
if (CheckUtil.isEmpty(store_id)) {
logger.warn("店铺Id{} 空值,无法获取店铺数据!", store_id);
return new HashMap();
}
@ -2370,7 +2374,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
base.setSubsite_id(subsite_id);
}
// 店铺营业状态1-营业中2-已打烊3-开业活动筹备中
// 店铺营业状态1-开业营业中且在营业时间内12-开业打烊中但在营业时间外 2-停业中3-开业活动筹备中
Integer storeBizState = Convert.toInt(getParameter("store_biz_state"));
if (storeBizState != null && storeBizState <= 3 && storeBizState >= 1) {
base.setStore_biz_state(storeBizState);
@ -2542,7 +2546,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
}
}
// 店铺营业状态1-营业中2-已打烊3-开业活动筹备中
// 店铺营业状态1-开业营业中且在营业时间内12-开业打烊中但在营业时间外 2-停业中3-开业活动筹备中
Integer storeBizState = Convert.toInt(getParameter("store_biz_state"));
if (storeBizState != null && storeBizState <= 3 && storeBizState >= 1) {
base.setStore_biz_state(storeBizState);
@ -4213,14 +4217,14 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
*
* @param shopStoreBase 店铺基础信息
* @param shopStoreInfo 店铺详细信息
* @return 店铺营业状态1-营业中2-已打烊3-开业(活动)筹备中
* @return 店铺营业状态1-开业营业中且在营业时间内12-开业打烊中但在营业时间外2-停业中3-开业或活动筹备中
*/
@Override
public Integer getStoreBizState(ShopStoreBase shopStoreBase, ShopStoreInfo shopStoreInfo) {
// 参数校验
if (shopStoreBase == null || shopStoreInfo == null) {
log.warn("店铺信息为空,未知营业状态");
return CommonConstant.Disable2;
return CommonConstant.Store_Biz_State_Closed;
}
try {
@ -4232,20 +4236,24 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
if (CommonConstant.Enable.equals(storeBizState) && !StrUtil.hasBlank(openingHours, closingHours)) {
// 检查当前时间是否在营业时间内
if (DateTimeUtils.isCurrentTimeInRange(openingHours, closingHours) != 0) {
// 不在营业时间内返回已打烊状态
return CommonConstant.Disable2;
// 12-开业打烊中但在营业时间外
return CommonConstant.Store_Biz_State_Opening2;
}
return CommonConstant.Enable;
return CommonConstant.Store_Biz_State_Opening;
}
// 返回原始营业状态
Integer resultState = storeBizState != null ? storeBizState : CommonConstant.Store_Biz_State_Closed;
log.debug("返回店铺营业状态storeId: {}, state: {}", shopStoreBase.getStore_id(), resultState);
// 返回原始营业状态
return storeBizState;
} catch (Exception e) {
// 处理异常避免影响主流程
log.error("检查店铺营业状态时发生异常storeId: {}",
shopStoreBase != null ? shopStoreBase.getStore_id() : "unknown", e);
return CommonConstant.Disable2;
return CommonConstant.Store_Biz_State_Closed;
}
}
@ -4253,7 +4261,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
* 根据店铺ID获取营业状态
*
* @param storeId 店铺ID
* @return 营业状态1-营业中2-已打烊3-开业(活动)筹备中
* @return 店铺营业状态1-开业营业中且在营业时间内12-开业打烊中但在营业时间外 2-停业中3-开业或活动筹备中
*/
@Override
public Pair<Integer, String> getStoreBizState(Integer storeId) {
@ -4283,18 +4291,18 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
// 不在营业时间内返回已打烊状态
log.debug("店铺当前不在营业时间内storeId: {}, openingHours: {}, closingHours: {}",
storeId, openingHours, closingHours);
return Pair.of(CommonConstant.Store_Biz_State_Closed, String.format("%s营业时间%s-%s", storeBizTimeInfo.getStore_name(),
return Pair.of(CommonConstant.Store_Biz_State_Opening2, String.format("%s营业时间%s-%s", storeBizTimeInfo.getStore_name(),
openingHours, closingHours));
}
return Pair.of(CommonConstant.Store_Biz_State_Opening, "");
}
// 返回原始营业状态处理null情况
// 返回原始营业状态
Integer resultState = storeBizState != null ? storeBizState : CommonConstant.Store_Biz_State_Closed;
log.debug("返回店铺营业状态storeId: {}, state: {}", storeId, resultState);
if (resultState == CommonConstant.Store_Biz_State_Closed) {
return Pair.of(resultState, String.format("%s打烊", storeBizTimeInfo.getStore_name()));
if (CommonConstant.Store_Biz_State_Closed.equals(resultState)) {
return Pair.of(resultState, String.format("%s歇业", storeBizTimeInfo.getStore_name()));
}
// 返回原始营业状态
@ -4307,7 +4315,6 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
}
}
/**
* 更新店铺分账比例
*

View File

@ -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,11 +1053,11 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
// 店铺Id
Integer storeId = Convert.toInt(product_row.get("store_id"));
// 判断店铺是否打烊打烊不能放入购物车 RMK 已移至统一放到下单支付的时候校验
// Pair<Integer, String> storeBizState = shopStoreBaseService.getStoreBizState(storeId);
// if (storeBizState != null && CommonConstant.Disable2.equals(storeBizState.getFirst())) {
// throw new ApiException(I18nUtil._(storeBizState.getSecond() + ",无法加购商品。"));
// }
// 判断店铺是否歇业停业歇业不能放入购物车
Pair<Integer, String> storeBizState = shopStoreBaseService.getStoreBizState(storeId);
if (storeBizState != null && CommonConstant.Store_Biz_State_Closed.equals(storeBizState.getFirst())) {
throw new ApiException(I18nUtil._(storeBizState.getSecond() + ",无法加购商品。"));
}
Integer cart_type = Convert.toInt(data.get("cart_type"));
// 判断是新增还是更新