店铺营业时间可到次日

This commit is contained in:
墨大叔 2024-10-08 10:46:27 +08:00
parent 9f7aadd2c3
commit 085050cbdc
4 changed files with 29 additions and 6 deletions

View File

@ -83,7 +83,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where>
<include refid="searchCondition"/>
</where>
order by ss.group_sort asc, ss.create_time asc
</select>
<select id="selectSmStoreById" parameterType="Long" resultMap="SmStoreResult">

View File

@ -301,12 +301,31 @@ public class StoreValidatorImpl extends BaseValidator implements StoreValidator
return false;
}
/**
* 判断是否营业时间
* @param store
* @param time
* @return
*/
@Override
public boolean isBusinessTime(StoreVo store, LocalTime time) {
if (store.getUseOutTime() == null || store.getUseOutTime()) {
return true;
}
return time.isAfter(store.getBusinessTimeStart()) && time.isBefore(store.getBusinessTimeEnd());
// 验证时间不为null
LocalTime start = store.getBusinessTimeStart();
LocalTime end = store.getBusinessTimeEnd();
if (start == null || end == null) {
return false;
}
// 正常时间
if (end.isAfter(start)) {
return time.isAfter(start) && time.isBefore(end);
}
// 隔天
else {
return time.isAfter(start) || time.isBefore(end);
}
}
@ -320,9 +339,9 @@ public class StoreValidatorImpl extends BaseValidator implements StoreValidator
return error("不允许单独设置营业时间的起始或结束");
}
// 判断起始时间是否在结束时间前
if (start.isAfter(end)) {
return error("营业时间(起始)不允许晚于营业时间(结束)");
}
// if (start.isAfter(end)) {
// return error("营业时间(起始)不允许晚于营业时间(结束)");
// }
}
return success();
}

View File

@ -71,7 +71,10 @@ public class TransactionBillValidatorImpl extends BaseValidator implements Trans
if (store != null) {
LocalTime now = LocalTime.now();
if (!storeValidator.isBusinessTime(store, now)) {
return error(String.format("请在营业时间内使用该设备!营业时间:%s - %s", store.getBusinessTimeStart(), store.getBusinessTimeEnd()));
return error(String.format("请在营业时间内使用该设备!%s - %s%s",
store.getBusinessTimeStart(),
store.getBusinessTimeEnd().isAfter(store.getBusinessTimeStart()) ? "" : "次日",
store.getBusinessTimeEnd()));
}
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.web.controller.app;
import com.fasterxml.jackson.annotation.JsonView;
import com.github.pagehelper.PageHelper;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -49,6 +50,7 @@ public class AppStoreController extends BaseController {
@GetMapping("/list")
public TableDataInfo list(@Validated(ValidGroup.Query.class) StoreQuery store) {
startPage();
PageHelper.orderBy("ss.group_sort asc, ss.create_time asc");
store.setUserId(getUserId());
List<StoreVo> list = storeService.selectSmStoreList(store);
// 拼接设备数量