Merge pull request 'Dev' (#99) from dev into sit
自动发布测试环境 Nacos 配置 / publish (push) Successful in 30s
自动发布测试环境 Nacos 配置 / publish (push) Successful in 30s
Reviewed-on: #99
This commit was merged in pull request #99.
This commit is contained in:
@@ -110,6 +110,15 @@
|
|||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Spring Boot manages the Flyway version; migrations run against the Nacos-configured datasource. -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.flywaydb</groupId>
|
||||||
|
<artifactId>flyway-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.flywaydb</groupId>
|
||||||
|
<artifactId>flyway-mysql</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
|||||||
-1
@@ -25,7 +25,6 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
"com.xiaowang.jayucloud.artlist.core.modules.content.mapper",
|
"com.xiaowang.jayucloud.artlist.core.modules.content.mapper",
|
||||||
"com.xiaowang.jayucloud.artlist.core.modules.file.mapper",
|
"com.xiaowang.jayucloud.artlist.core.modules.file.mapper",
|
||||||
"com.xiaowang.jayucloud.artlist.core.modules.integration.mapper",
|
"com.xiaowang.jayucloud.artlist.core.modules.integration.mapper",
|
||||||
"com.xiaowang.jayucloud.artlist.core.modules.inventory.mapper",
|
|
||||||
"com.xiaowang.jayucloud.artlist.core.modules.marketing.mapper",
|
"com.xiaowang.jayucloud.artlist.core.modules.marketing.mapper",
|
||||||
"com.xiaowang.jayucloud.artlist.core.modules.message.mapper",
|
"com.xiaowang.jayucloud.artlist.core.modules.message.mapper",
|
||||||
"com.xiaowang.jayucloud.artlist.core.modules.order.mapper",
|
"com.xiaowang.jayucloud.artlist.core.modules.order.mapper",
|
||||||
|
|||||||
-450
@@ -1,450 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.analytics.controller.front;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.annotation.RequirePermission;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.common.Result;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.config.AppCacheProperties;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.content.entity.CommentDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.OrderDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.OrderItemDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.product.entity.ProductDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.user.entity.UserDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.content.mapper.CommentMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderItemMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.product.mapper.ProductMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.shop.mapper.ShopMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.user.mapper.UserMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.analytics.service.OperationsAnalyticsService;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.security.support.AdminScopeHelper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.support.OrderStatus;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.shop.support.UserShopBindingSupport;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.support.cache.MultiLevelCacheService;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.analytics.vo.DashboardStatsVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.product.vo.HotProductVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.analytics.vo.OperationsAnalyticsVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.analytics.vo.RecentActivityVO;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/admin/dashboard")
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
/**
|
|
||||||
* DashboardController exposes HTTP endpoints. Start here to learn the request path, parameter names, and which service method is called.
|
|
||||||
* Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class.
|
|
||||||
*/
|
|
||||||
public class DashboardController {
|
|
||||||
/**
|
|
||||||
* Variable `userMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
|
||||||
*/
|
|
||||||
private final UserMapper userMapper;
|
|
||||||
/**
|
|
||||||
* Variable `productMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
|
||||||
*/
|
|
||||||
private final ProductMapper productMapper;
|
|
||||||
/**
|
|
||||||
* Variable `shopMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
|
||||||
*/
|
|
||||||
private final ShopMapper shopMapper;
|
|
||||||
/**
|
|
||||||
* Variable `commentMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
|
||||||
*/
|
|
||||||
private final CommentMapper commentMapper;
|
|
||||||
/**
|
|
||||||
* Variable `orderMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
|
||||||
*/
|
|
||||||
private final OrderMapper orderMapper;
|
|
||||||
/**
|
|
||||||
* Variable `orderItemMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
|
||||||
*/
|
|
||||||
private final OrderItemMapper orderItemMapper;
|
|
||||||
/**
|
|
||||||
* Variable `adminScopeHelper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
|
||||||
*/
|
|
||||||
private final AdminScopeHelper adminScopeHelper;
|
|
||||||
/**
|
|
||||||
* Variable `userShopBindingSupport`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
|
||||||
*/
|
|
||||||
private final UserShopBindingSupport userShopBindingSupport;
|
|
||||||
/**
|
|
||||||
* Variable `multiLevelCacheService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
|
||||||
*/
|
|
||||||
private final MultiLevelCacheService multiLevelCacheService;
|
|
||||||
/**
|
|
||||||
* Variable `appCacheProperties`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
|
||||||
*/
|
|
||||||
private final AppCacheProperties appCacheProperties;
|
|
||||||
private final OperationsAnalyticsService operationsAnalyticsService;
|
|
||||||
|
|
||||||
@GetMapping("/stats")
|
|
||||||
@RequirePermission("dashboard:view")
|
|
||||||
/**
|
|
||||||
* Load data by the supplied parameter.
|
|
||||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
|
||||||
* @param request parameter `request` supplied by the caller
|
|
||||||
* @return Result<DashboardStatsVO> result consumed by the caller or returned to the frontend
|
|
||||||
*/
|
|
||||||
public Result<DashboardStatsVO> getDashboardStats(HttpServletRequest request) {
|
|
||||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
|
||||||
Long shopIdScope = resolveShopScope(currentUser);
|
|
||||||
String cacheScope = currentUser == null ? "anonymous" : (shopIdScope == null ? "admin" : "shop:" + shopIdScope);
|
|
||||||
AppCacheProperties.CacheSpec cacheSpec = appCacheProperties.getDashboard();
|
|
||||||
DashboardStatsVO stats = multiLevelCacheService.getOrLoad(
|
|
||||||
"cache:dashboard:stats:" + cacheScope,
|
|
||||||
Duration.ofSeconds(cacheSpec.getLocalTtlSeconds()),
|
|
||||||
Duration.ofSeconds(cacheSpec.getRedisTtlSeconds()),
|
|
||||||
new TypeReference<DashboardStatsVO>() {
|
|
||||||
},
|
|
||||||
() -> buildDashboardStats(currentUser, shopIdScope)
|
|
||||||
);
|
|
||||||
return Result.success(stats);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/analytics")
|
|
||||||
@RequirePermission("analytics:view")
|
|
||||||
public Result<OperationsAnalyticsVO> getAnalytics(HttpServletRequest request) {
|
|
||||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
|
||||||
Long shopIdScope = resolveShopScope(currentUser);
|
|
||||||
Long artistScope = currentUser != null && Integer.valueOf(3).equals(currentUser.getType()) ? currentUser.getId() : null;
|
|
||||||
return Result.success(operationsAnalyticsService.getDashboardAnalytics(shopIdScope, artistScope));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run business method `buildDashboardStats`.
|
|
||||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
|
||||||
* @param currentUser parameter `currentUser` supplied by the caller
|
|
||||||
* @param shopIdScope parameter `shopIdScope` supplied by the caller
|
|
||||||
* @return private DashboardStatsVO result consumed by the caller or returned to the frontend
|
|
||||||
*/
|
|
||||||
private DashboardStatsVO buildDashboardStats(UserDO currentUser, Long shopIdScope) {
|
|
||||||
DashboardStatsVO stats = new DashboardStatsVO();
|
|
||||||
Long artistScope = currentUser != null && Integer.valueOf(3).equals(currentUser.getType()) ? currentUser.getId() : null;
|
|
||||||
|
|
||||||
if (currentUser != null) {
|
|
||||||
// 根据用户类型显示不同的数据
|
|
||||||
if (currentUser.getType() == 4) { // 管理员
|
|
||||||
stats.setTotalUsers(userMapper.selectCount(null));
|
|
||||||
stats.setTotalProducts(productMapper.selectCount(null));
|
|
||||||
stats.setTotalShops(shopMapper.selectCount(null));
|
|
||||||
stats.setTodayOrders(getTodayOrders(null));
|
|
||||||
stats.setTotalCustomers(countUsers(null, 0, null, null));
|
|
||||||
stats.setTotalArtists(countUsers(null, 3, null, null));
|
|
||||||
} else { // 店长或美甲师
|
|
||||||
Long shopId = currentUser.getShopId();
|
|
||||||
if (shopId != null) {
|
|
||||||
shopIdScope = shopId;
|
|
||||||
// 只显示当前店铺的数据
|
|
||||||
stats.setTotalUsers(userShopBindingSupport.countUsersByShopId(shopId, false));
|
|
||||||
stats.setTotalProducts(productMapper.selectCount(new LambdaQueryWrapper<ProductDO>().eq(ProductDO::getShopId, shopId)));
|
|
||||||
stats.setTotalShops(0L); // 非管理员不显示店铺数量
|
|
||||||
stats.setTodayOrders(getTodayOrders(shopId));
|
|
||||||
stats.setTotalCustomers(countUsers(shopId, 0, null, null));
|
|
||||||
stats.setTotalArtists(countUsers(shopId, 3, null, null));
|
|
||||||
} else {
|
|
||||||
// 没有店铺ID的情况
|
|
||||||
stats.setTotalUsers(0L);
|
|
||||||
stats.setTotalProducts(0L);
|
|
||||||
stats.setTotalShops(0L);
|
|
||||||
stats.setTodayOrders(0L);
|
|
||||||
stats.setTotalCustomers(0L);
|
|
||||||
stats.setTotalArtists(0L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 无法获取用户信息的情况
|
|
||||||
stats.setTotalUsers(0L);
|
|
||||||
stats.setTotalProducts(0L);
|
|
||||||
stats.setTotalShops(0L);
|
|
||||||
stats.setTodayOrders(0L);
|
|
||||||
stats.setTotalCustomers(0L);
|
|
||||||
stats.setTotalArtists(0L);
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalDateTime todayStart = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
||||||
LocalDateTime weekStart = todayStart.minusDays(6);
|
|
||||||
stats.setTotalOrderAmount(sumOrderAmount(shopIdScope, artistScope, null, null));
|
|
||||||
stats.setTodayOrderAmount(sumOrderAmount(shopIdScope, artistScope, todayStart, null));
|
|
||||||
stats.setWeekOrderAmount(sumOrderAmount(shopIdScope, artistScope, weekStart, null));
|
|
||||||
stats.setNewCustomersToday(countUsers(shopIdScope, 0, todayStart, null));
|
|
||||||
stats.setNewCustomers7Days(countUsers(shopIdScope, 0, weekStart, null));
|
|
||||||
stats.setNewOrders7Days(countOrders(shopIdScope, artistScope, null, weekStart, null));
|
|
||||||
long priceConfirmingOrders = countOrders(shopIdScope, artistScope, OrderStatus.PRICE_CONFIRMING.getCode(), null, null);
|
|
||||||
long pendingServiceOrders = countOrders(shopIdScope, artistScope, OrderStatus.PENDING_SERVICE.getCode(), null, null);
|
|
||||||
stats.setPendingOrders(priceConfirmingOrders + pendingServiceOrders);
|
|
||||||
stats.setCompletedOrders(countOrders(shopIdScope, artistScope, OrderStatus.COMPLETED.getCode(), null, null));
|
|
||||||
|
|
||||||
stats.setHotProducts(getHotProducts(shopIdScope));
|
|
||||||
stats.setRecentActivities(getRecentActivities(shopIdScope));
|
|
||||||
|
|
||||||
return stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run business method `resolveShopScope`.
|
|
||||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
|
||||||
* @param currentUser parameter `currentUser` supplied by the caller
|
|
||||||
* @return private Long result consumed by the caller or returned to the frontend
|
|
||||||
*/
|
|
||||||
private Long resolveShopScope(UserDO currentUser) {
|
|
||||||
if (currentUser == null || currentUser.getType() == 4) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return currentUser.getShopId();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Purpose: countUsers supports DashboardController.java by holding or executing the count users business role.
|
|
||||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private Long countUsers(Long shopId, Integer type, LocalDateTime from, LocalDateTime to) {
|
|
||||||
LambdaQueryWrapper<UserDO> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
if (type != null) {
|
|
||||||
wrapper.eq(UserDO::getType, type);
|
|
||||||
}
|
|
||||||
if (from != null) {
|
|
||||||
wrapper.ge(UserDO::getCreateTime, from);
|
|
||||||
}
|
|
||||||
if (to != null) {
|
|
||||||
wrapper.le(UserDO::getCreateTime, to);
|
|
||||||
}
|
|
||||||
if (shopId != null) {
|
|
||||||
List<Long> userIds = userShopBindingSupport.listUserIdsByShopId(shopId, false);
|
|
||||||
if (userIds.isEmpty()) {
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
wrapper.in(UserDO::getId, userIds);
|
|
||||||
}
|
|
||||||
return userMapper.selectCount(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Purpose: countOrders supports DashboardController.java by holding or executing the count orders business role.
|
|
||||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private Long countOrders(Long shopId, Long artistId, Integer status, LocalDateTime from, LocalDateTime to) {
|
|
||||||
return (long) listScopedOrders(shopId, artistId, status, from, to).size();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Purpose: sumOrderAmount supports DashboardController.java by holding or executing the sum order amount business role.
|
|
||||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private BigDecimal sumOrderAmount(Long shopId, Long artistId, LocalDateTime from, LocalDateTime to) {
|
|
||||||
return listScopedOrders(shopId, artistId, null, from, to).stream()
|
|
||||||
.map(order -> order.getActualAmount() != null ? order.getActualAmount() : order.getTotalAmount())
|
|
||||||
.filter(amount -> amount != null)
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Purpose: listScopedOrders supports DashboardController.java by holding or executing the list scoped orders business role.
|
|
||||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private List<OrderDO> listScopedOrders(Long shopId, Long artistId, Integer status, LocalDateTime from, LocalDateTime to) {
|
|
||||||
LambdaQueryWrapper<OrderDO> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
if (shopId != null) {
|
|
||||||
wrapper.eq(OrderDO::getShopId, shopId);
|
|
||||||
}
|
|
||||||
if (status != null) {
|
|
||||||
wrapper.eq(OrderDO::getStatus, status);
|
|
||||||
}
|
|
||||||
if (from != null) {
|
|
||||||
wrapper.ge(OrderDO::getCreateTime, from);
|
|
||||||
}
|
|
||||||
if (to != null) {
|
|
||||||
wrapper.le(OrderDO::getCreateTime, to);
|
|
||||||
}
|
|
||||||
if (artistId != null) {
|
|
||||||
Set<Long> orderIds = listOrderIdsByArtist(artistId);
|
|
||||||
if (orderIds.isEmpty()) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
wrapper.in(OrderDO::getId, orderIds);
|
|
||||||
}
|
|
||||||
return orderMapper.selectList(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Purpose: listOrderIdsByArtist supports DashboardController.java by holding or executing the list order ids by artist business role.
|
|
||||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private Set<Long> listOrderIdsByArtist(Long artistId) {
|
|
||||||
List<OrderItemDO> items = orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>()
|
|
||||||
.select(OrderItemDO::getOrderId)
|
|
||||||
.eq(OrderItemDO::getArtistId, artistId));
|
|
||||||
return items.stream()
|
|
||||||
.map(OrderItemDO::getOrderId)
|
|
||||||
.filter(id -> id != null)
|
|
||||||
.collect(Collectors.toCollection(HashSet::new));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load data by the supplied parameter.
|
|
||||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
|
||||||
* @param shopId parameter `shopId` supplied by the caller
|
|
||||||
* @return private Long result consumed by the caller or returned to the frontend
|
|
||||||
*/
|
|
||||||
private Long getTodayOrders(Long shopId) {
|
|
||||||
// 获取今天的开始时间
|
|
||||||
LocalDateTime todayStart = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
||||||
String todayStartStr = todayStart.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
||||||
|
|
||||||
if (shopId != null) {
|
|
||||||
// 非管理员只查询自己店铺的订单,通过订单商品关联到商品,再关联到店铺
|
|
||||||
java.util.Map<String, Object> result = orderItemMapper.countTodayOrdersByShopId(shopId, todayStartStr);
|
|
||||||
return result != null && result.get("count") != null ? Long.valueOf(result.get("count").toString()) : 0L;
|
|
||||||
} else {
|
|
||||||
// 管理员查询所有订单
|
|
||||||
java.util.Map<String, Object> result = orderItemMapper.countTodayOrders(todayStartStr);
|
|
||||||
return result != null && result.get("count") != null ? Long.valueOf(result.get("count").toString()) : 0L;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load data by the supplied parameter.
|
|
||||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
|
||||||
* @param shopId parameter `shopId` supplied by the caller
|
|
||||||
* @return private List<HotProductVO> result consumed by the caller or returned to the frontend
|
|
||||||
*/
|
|
||||||
private List<HotProductVO> getHotProducts(Long shopId) {
|
|
||||||
// 通过订单商品表统计每个商品的订单数量,按订单数量排序
|
|
||||||
// 使用SQL查询获取商品及其订单数量
|
|
||||||
List<Map<String, Object>> productOrderCounts = orderItemMapper.selectMaps(
|
|
||||||
new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<OrderItemDO>()
|
|
||||||
.select("product_id, COUNT(*) as order_count")
|
|
||||||
.groupBy("product_id")
|
|
||||||
.orderByDesc("order_count")
|
|
||||||
.last("LIMIT 5")
|
|
||||||
);
|
|
||||||
|
|
||||||
List<HotProductVO> hotProducts = new ArrayList<>();
|
|
||||||
|
|
||||||
// 遍历查询结果,获取商品详情
|
|
||||||
for (Map<String, Object> map : productOrderCounts) {
|
|
||||||
Long productId = Long.valueOf(map.get("product_id").toString());
|
|
||||||
ProductDO product = productMapper.selectById(productId);
|
|
||||||
|
|
||||||
if (product != null && (shopId == null || shopId.equals(product.getShopId()))) {
|
|
||||||
HotProductVO vo = new HotProductVO();
|
|
||||||
BeanUtils.copyProperties(product, vo);
|
|
||||||
vo.setLikeCount(product.getLikeCount() != null ? product.getLikeCount() : 0);
|
|
||||||
hotProducts.add(vo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果按订单数量查询没有结果,使用点赞数作为备选
|
|
||||||
if (hotProducts.isEmpty()) {
|
|
||||||
LambdaQueryWrapper<ProductDO> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
if (shopId != null) {
|
|
||||||
wrapper.eq(ProductDO::getShopId, shopId);
|
|
||||||
}
|
|
||||||
wrapper.orderByDesc(ProductDO::getLikeCount)
|
|
||||||
.last("LIMIT 5");
|
|
||||||
List<ProductDO> products = productMapper.selectList(wrapper);
|
|
||||||
|
|
||||||
hotProducts = products.stream().map(product -> {
|
|
||||||
HotProductVO vo = new HotProductVO();
|
|
||||||
BeanUtils.copyProperties(product, vo);
|
|
||||||
vo.setLikeCount(product.getLikeCount() != null ? product.getLikeCount() : 0);
|
|
||||||
return vo;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
return hotProducts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load data by the supplied parameter.
|
|
||||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
|
||||||
* @param shopId parameter `shopId` supplied by the caller
|
|
||||||
* @return private List<RecentActivityVO> result consumed by the caller or returned to the frontend
|
|
||||||
*/
|
|
||||||
private List<RecentActivityVO> getRecentActivities(Long shopId) {
|
|
||||||
List<RecentActivityVO> activities = new ArrayList<>();
|
|
||||||
|
|
||||||
LambdaQueryWrapper<UserDO> userWrapper = new LambdaQueryWrapper<>();
|
|
||||||
if (shopId != null) {
|
|
||||||
List<Long> userIds = userShopBindingSupport.listUserIdsByShopId(shopId, false);
|
|
||||||
if (userIds.isEmpty()) {
|
|
||||||
userWrapper.eq(UserDO::getId, -1L);
|
|
||||||
} else {
|
|
||||||
userWrapper.in(UserDO::getId, userIds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
userWrapper.orderByDesc(UserDO::getCreateTime)
|
|
||||||
.last("LIMIT 3");
|
|
||||||
List<UserDO> recentUsers = userMapper.selectList(userWrapper);
|
|
||||||
|
|
||||||
for (UserDO user : recentUsers) {
|
|
||||||
RecentActivityVO vo = new RecentActivityVO();
|
|
||||||
vo.setId(user.getId());
|
|
||||||
vo.setType("user");
|
|
||||||
vo.setTitle("新用户注册");
|
|
||||||
vo.setDescription("用户\"" + user.getNickname() + "\"注册成功");
|
|
||||||
vo.setTime(user.getCreateTime());
|
|
||||||
vo.setColor("");
|
|
||||||
activities.add(vo);
|
|
||||||
}
|
|
||||||
|
|
||||||
LambdaQueryWrapper<ProductDO> productWrapper = new LambdaQueryWrapper<>();
|
|
||||||
if (shopId != null) {
|
|
||||||
productWrapper.eq(ProductDO::getShopId, shopId);
|
|
||||||
}
|
|
||||||
productWrapper.orderByDesc(ProductDO::getCreateTime)
|
|
||||||
.last("LIMIT 2");
|
|
||||||
List<ProductDO> recentProducts = productMapper.selectList(productWrapper);
|
|
||||||
|
|
||||||
for (ProductDO product : recentProducts) {
|
|
||||||
RecentActivityVO vo = new RecentActivityVO();
|
|
||||||
vo.setId(product.getId());
|
|
||||||
vo.setType("product");
|
|
||||||
vo.setTitle("新品上架");
|
|
||||||
vo.setDescription("新品\"" + product.getTitle() + "\"已上架");
|
|
||||||
vo.setTime(product.getCreateTime());
|
|
||||||
vo.setColor("blue");
|
|
||||||
activities.add(vo);
|
|
||||||
}
|
|
||||||
|
|
||||||
LambdaQueryWrapper<CommentDO> commentWrapper = new LambdaQueryWrapper<>();
|
|
||||||
if (shopId != null) {
|
|
||||||
commentWrapper.eq(CommentDO::getShopId, shopId);
|
|
||||||
}
|
|
||||||
commentWrapper.orderByDesc(CommentDO::getCreateTime)
|
|
||||||
.last("LIMIT 2");
|
|
||||||
List<CommentDO> recentComments = commentMapper.selectList(commentWrapper);
|
|
||||||
|
|
||||||
for (CommentDO comment : recentComments) {
|
|
||||||
RecentActivityVO vo = new RecentActivityVO();
|
|
||||||
vo.setId(comment.getId());
|
|
||||||
vo.setType("comment");
|
|
||||||
vo.setTitle("用户评论");
|
|
||||||
String content = comment.getCommentContent();
|
|
||||||
if (content != null && content.length() > 20) {
|
|
||||||
content = content.substring(0, 20) + "...";
|
|
||||||
}
|
|
||||||
vo.setDescription(content != null ? content : "用户发表了评论");
|
|
||||||
vo.setTime(comment.getCreateTime());
|
|
||||||
vo.setColor("green");
|
|
||||||
activities.add(vo);
|
|
||||||
}
|
|
||||||
|
|
||||||
activities.sort((a, b) -> b.getTime().compareTo(a.getTime()));
|
|
||||||
|
|
||||||
return activities.stream().limit(5).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.analytics.service;
|
|
||||||
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.analytics.vo.OperationsAnalyticsVO;
|
|
||||||
|
|
||||||
public interface OperationsAnalyticsService {
|
|
||||||
OperationsAnalyticsVO getDashboardAnalytics(Long shopId, Long artistId);
|
|
||||||
}
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.analytics.service;
|
|
||||||
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.analytics.vo.StoreWorkbenchVO;
|
|
||||||
|
|
||||||
public interface WorkbenchService {
|
|
||||||
StoreWorkbenchVO getWorkbench(Long shopId, Long artistId);
|
|
||||||
}
|
|
||||||
-66
@@ -1,66 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.analytics.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.OrderDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.OrderItemDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.product.entity.ProductDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.user.entity.UserGrowthRecordDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderItemMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.product.mapper.ProductMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.user.mapper.UserGrowthRecordMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.analytics.service.OperationsAnalyticsService;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.analytics.vo.OperationsAnalyticsVO;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class OperationsAnalyticsServiceImpl implements OperationsAnalyticsService {
|
|
||||||
|
|
||||||
private final OrderMapper orderMapper;
|
|
||||||
private final OrderItemMapper orderItemMapper;
|
|
||||||
private final ProductMapper productMapper;
|
|
||||||
private final UserGrowthRecordMapper userGrowthRecordMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OperationsAnalyticsVO getDashboardAnalytics(Long shopId, Long artistId) {
|
|
||||||
List<OrderDO> orders = orderMapper.selectList(new LambdaQueryWrapper<OrderDO>()
|
|
||||||
.eq(shopId != null, OrderDO::getShopId, shopId)
|
|
||||||
.eq(OrderDO::getIsDelete, 0));
|
|
||||||
if (artistId != null) {
|
|
||||||
Set<Long> orderIds = new HashSet<>();
|
|
||||||
orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>()
|
|
||||||
.eq(OrderItemDO::getArtistId, artistId)
|
|
||||||
.eq(OrderItemDO::getIsDelete, 0))
|
|
||||||
.forEach(item -> orderIds.add(item.getOrderId()));
|
|
||||||
orders = orders.stream().filter(order -> orderIds.contains(order.getId())).toList();
|
|
||||||
}
|
|
||||||
OperationsAnalyticsVO vo = new OperationsAnalyticsVO();
|
|
||||||
vo.setViewCount(productMapper.selectList(new LambdaQueryWrapper<ProductDO>()
|
|
||||||
.eq(shopId != null, ProductDO::getShopId, shopId)
|
|
||||||
.eq(ProductDO::getIsDelete, 0))
|
|
||||||
.stream().map(ProductDO::getLikeCount).filter(v -> v != null).mapToLong(Integer::longValue).sum());
|
|
||||||
vo.setFavoriteCount(productMapper.selectList(new LambdaQueryWrapper<ProductDO>()
|
|
||||||
.eq(shopId != null, ProductDO::getShopId, shopId)
|
|
||||||
.eq(ProductDO::getIsDelete, 0))
|
|
||||||
.stream().map(ProductDO::getCollectCount).filter(v -> v != null).mapToLong(Integer::longValue).sum());
|
|
||||||
vo.setCartCount(0L);
|
|
||||||
vo.setOrderCount((long) orders.size());
|
|
||||||
vo.setPaidOrderCount(orders.stream().filter(order -> "PAID".equals(order.getPaymentStatus())).count());
|
|
||||||
vo.setCompletedOrderCount(orders.stream().filter(order -> Integer.valueOf(2).equals(order.getStatus())).count());
|
|
||||||
vo.setReviewCount(userGrowthRecordMapper.selectCount(new LambdaQueryWrapper<UserGrowthRecordDO>()
|
|
||||||
.eq(UserGrowthRecordDO::getSourceType, "REVIEW")));
|
|
||||||
vo.setRebookCount(userGrowthRecordMapper.selectCount(new LambdaQueryWrapper<UserGrowthRecordDO>()
|
|
||||||
.eq(UserGrowthRecordDO::getSourceType, "REBOOK")));
|
|
||||||
vo.setTotalAmount(orders.stream()
|
|
||||||
.map(order -> order.getActualAmount() == null ? BigDecimal.ZERO : order.getActualAmount())
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-145
@@ -1,145 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.analytics.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.AfterSaleDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.entity.ArtistScheduleDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.entity.InventoryItemDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.OrderArtistChangeRequestDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.OrderDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.OrderItemDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.AfterSaleMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.mapper.ArtistScheduleMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.mapper.InventoryItemMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderArtistChangeRequestMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderArtistReviewMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderItemMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.analytics.service.WorkbenchService;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.support.OrderStatus;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.analytics.vo.StoreWorkbenchVO;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class WorkbenchServiceImpl implements WorkbenchService {
|
|
||||||
|
|
||||||
private final OrderMapper orderMapper;
|
|
||||||
private final OrderItemMapper orderItemMapper;
|
|
||||||
private final AfterSaleMapper afterSaleMapper;
|
|
||||||
private final OrderArtistChangeRequestMapper orderArtistChangeRequestMapper;
|
|
||||||
private final InventoryItemMapper inventoryItemMapper;
|
|
||||||
private final ArtistScheduleMapper artistScheduleMapper;
|
|
||||||
private final OrderArtistReviewMapper orderArtistReviewMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StoreWorkbenchVO getWorkbench(Long shopId, Long artistId) {
|
|
||||||
LocalDateTime todayStart = LocalDate.now().atStartOfDay();
|
|
||||||
LocalDateTime tomorrowStart = todayStart.plusDays(1);
|
|
||||||
List<OrderDO> orders = scopedOrders(shopId, artistId);
|
|
||||||
StoreWorkbenchVO vo = new StoreWorkbenchVO();
|
|
||||||
vo.setTodayOrderCount(orders.stream().filter(order -> between(order.getCreateTime(), todayStart, tomorrowStart)).count());
|
|
||||||
vo.setPendingOrderCount(orders.stream().filter(this::isActionableOrder).count());
|
|
||||||
vo.setPendingAfterSaleCount(countAfterSales(shopId));
|
|
||||||
vo.setPendingArtistChangeCount(countArtistChanges(shopId, artistId));
|
|
||||||
vo.setLowStockItemCount(countLowStock(shopId));
|
|
||||||
vo.setScheduleReminderCount(countMissingSchedules(shopId, artistId, todayStart.toLocalDate()));
|
|
||||||
vo.setTodayServiceCount(countTodayServices(artistId, todayStart, tomorrowStart));
|
|
||||||
vo.setCompletedServiceCount(orders.stream().filter(order -> Integer.valueOf(2).equals(order.getStatus())).count());
|
|
||||||
vo.setServiceAmount(orders.stream()
|
|
||||||
.map(order -> order.getActualAmount() == null ? BigDecimal.ZERO : order.getActualAmount())
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
||||||
vo.setAverageRating(resolveRating(artistId));
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isActionableOrder(OrderDO order) {
|
|
||||||
if (order == null || order.getStatus() == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return Integer.valueOf(OrderStatus.PRICE_CONFIRMING.getCode()).equals(order.getStatus())
|
|
||||||
|| Integer.valueOf(OrderStatus.PENDING_SERVICE.getCode()).equals(order.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<OrderDO> scopedOrders(Long shopId, Long artistId) {
|
|
||||||
List<OrderDO> orders = orderMapper.selectList(new LambdaQueryWrapper<OrderDO>()
|
|
||||||
.eq(shopId != null, OrderDO::getShopId, shopId)
|
|
||||||
.eq(OrderDO::getIsDelete, 0));
|
|
||||||
if (artistId == null) {
|
|
||||||
return orders;
|
|
||||||
}
|
|
||||||
Set<Long> orderIds = new HashSet<>();
|
|
||||||
orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>()
|
|
||||||
.eq(OrderItemDO::getArtistId, artistId)
|
|
||||||
.eq(OrderItemDO::getIsDelete, 0))
|
|
||||||
.forEach(item -> orderIds.add(item.getOrderId()));
|
|
||||||
return orders.stream().filter(order -> orderIds.contains(order.getId())).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private long countAfterSales(Long shopId) {
|
|
||||||
return afterSaleMapper.selectCount(new LambdaQueryWrapper<AfterSaleDO>()
|
|
||||||
.eq(shopId != null, AfterSaleDO::getShopId, shopId)
|
|
||||||
.eq(AfterSaleDO::getStatus, "PENDING")
|
|
||||||
.eq(AfterSaleDO::getIsDelete, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
private long countArtistChanges(Long shopId, Long artistId) {
|
|
||||||
return orderArtistChangeRequestMapper.selectCount(new LambdaQueryWrapper<OrderArtistChangeRequestDO>()
|
|
||||||
.eq(shopId != null, OrderArtistChangeRequestDO::getShopId, shopId)
|
|
||||||
.eq(artistId != null, OrderArtistChangeRequestDO::getRequesterId, artistId)
|
|
||||||
.eq(OrderArtistChangeRequestDO::getStatus, "PENDING")
|
|
||||||
.eq(OrderArtistChangeRequestDO::getIsDelete, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
private long countLowStock(Long shopId) {
|
|
||||||
return inventoryItemMapper.selectList(new LambdaQueryWrapper<InventoryItemDO>()
|
|
||||||
.eq(shopId != null, InventoryItemDO::getShopId, shopId)
|
|
||||||
.eq(InventoryItemDO::getIsDelete, 0))
|
|
||||||
.stream()
|
|
||||||
.filter(item -> item.getStockQuantity() != null
|
|
||||||
&& item.getWarningThreshold() != null
|
|
||||||
&& item.getStockQuantity().compareTo(item.getWarningThreshold()) <= 0)
|
|
||||||
.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
private long countMissingSchedules(Long shopId, Long artistId, LocalDate today) {
|
|
||||||
return artistScheduleMapper.selectCount(new LambdaQueryWrapper<ArtistScheduleDO>()
|
|
||||||
.eq(shopId != null, ArtistScheduleDO::getShopId, shopId)
|
|
||||||
.eq(artistId != null, ArtistScheduleDO::getArtistId, artistId)
|
|
||||||
.ge(ArtistScheduleDO::getWorkDate, today)
|
|
||||||
.lt(ArtistScheduleDO::getWorkDate, today.plusDays(3))
|
|
||||||
.eq(ArtistScheduleDO::getIsDelete, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
private long countTodayServices(Long artistId, LocalDateTime todayStart, LocalDateTime tomorrowStart) {
|
|
||||||
if (artistId == null) {
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
return orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>()
|
|
||||||
.eq(OrderItemDO::getArtistId, artistId)
|
|
||||||
.ge(OrderItemDO::getAppointmentTime, todayStart)
|
|
||||||
.lt(OrderItemDO::getAppointmentTime, tomorrowStart)
|
|
||||||
.eq(OrderItemDO::getIsDelete, 0))
|
|
||||||
.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
private BigDecimal resolveRating(Long artistId) {
|
|
||||||
if (artistId == null) {
|
|
||||||
return BigDecimal.ZERO.setScale(1, RoundingMode.HALF_UP);
|
|
||||||
}
|
|
||||||
BigDecimal rating = orderArtistReviewMapper.selectAverageSubmittedRatingByArtistId(artistId);
|
|
||||||
return (rating == null ? BigDecimal.ZERO : rating).setScale(1, RoundingMode.HALF_UP);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean between(LocalDateTime value, LocalDateTime start, LocalDateTime end) {
|
|
||||||
return value != null && !value.isBefore(start) && value.isBefore(end);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-89
@@ -1,89 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.analytics.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.product.vo.HotProductVO;
|
|
||||||
@Data
|
|
||||||
/**
|
|
||||||
* DashboardStatsVO is a response VO. Services build it and controllers return it to the frontend.
|
|
||||||
* Field and parameter names are kept consistent with the frontend/API payload to make tracing easier.
|
|
||||||
*/
|
|
||||||
public class DashboardStatsVO {
|
|
||||||
/**
|
|
||||||
* Field `totalUsers` (Long): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
|
||||||
*/
|
|
||||||
private Long totalUsers;
|
|
||||||
/**
|
|
||||||
* Field `totalProducts` (Long): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
|
||||||
*/
|
|
||||||
private Long totalProducts;
|
|
||||||
/**
|
|
||||||
* Field `totalShops` (Long): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
|
||||||
*/
|
|
||||||
private Long totalShops;
|
|
||||||
/**
|
|
||||||
* Field `todayOrders` (Long): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
|
||||||
*/
|
|
||||||
private Long todayOrders;
|
|
||||||
/**
|
|
||||||
* Purpose: totalOrderAmount supports DashboardStatsVO.java by holding or executing the total order amount business role.
|
|
||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private BigDecimal totalOrderAmount;
|
|
||||||
/**
|
|
||||||
* Purpose: todayOrderAmount supports DashboardStatsVO.java by holding or executing the today order amount business role.
|
|
||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private BigDecimal todayOrderAmount;
|
|
||||||
/**
|
|
||||||
* Purpose: weekOrderAmount supports DashboardStatsVO.java by holding or executing the week order amount business role.
|
|
||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private BigDecimal weekOrderAmount;
|
|
||||||
/**
|
|
||||||
* Purpose: totalCustomers supports DashboardStatsVO.java by holding or executing the total customers business role.
|
|
||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private Long totalCustomers;
|
|
||||||
/**
|
|
||||||
* Purpose: totalArtists supports DashboardStatsVO.java by holding or executing the total artists business role.
|
|
||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private Long totalArtists;
|
|
||||||
/**
|
|
||||||
* Purpose: newCustomersToday supports DashboardStatsVO.java by holding or executing the new customers today business role.
|
|
||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private Long newCustomersToday;
|
|
||||||
/**
|
|
||||||
* Purpose: newCustomers7Days supports DashboardStatsVO.java by holding or executing the new customers7 days business role.
|
|
||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private Long newCustomers7Days;
|
|
||||||
/**
|
|
||||||
* Purpose: newOrders7Days supports DashboardStatsVO.java by holding or executing the new orders7 days business role.
|
|
||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private Long newOrders7Days;
|
|
||||||
/**
|
|
||||||
* Purpose: pendingOrders supports DashboardStatsVO.java by holding or executing the pending orders business role.
|
|
||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private Long pendingOrders;
|
|
||||||
/**
|
|
||||||
* Purpose: completedOrders supports DashboardStatsVO.java by holding or executing the completed orders business role.
|
|
||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private Long completedOrders;
|
|
||||||
/**
|
|
||||||
* Field `hotProducts` (List<HotProductVO>): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
|
||||||
*/
|
|
||||||
private List<HotProductVO> hotProducts;
|
|
||||||
/**
|
|
||||||
* Field `recentActivities` (List<RecentActivityVO>): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
|
||||||
*/
|
|
||||||
private List<RecentActivityVO> recentActivities;
|
|
||||||
}
|
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.analytics.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class OperationsAnalyticsVO {
|
|
||||||
private Long viewCount;
|
|
||||||
private Long favoriteCount;
|
|
||||||
private Long cartCount;
|
|
||||||
private Long orderCount;
|
|
||||||
private Long paidOrderCount;
|
|
||||||
private Long completedOrderCount;
|
|
||||||
private Long reviewCount;
|
|
||||||
private Long rebookCount;
|
|
||||||
private BigDecimal totalAmount;
|
|
||||||
}
|
|
||||||
-37
@@ -1,37 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.analytics.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
/**
|
|
||||||
* RecentActivityVO is a response VO. Services build it and controllers return it to the frontend.
|
|
||||||
* Field and parameter names are kept consistent with the frontend/API payload to make tracing easier.
|
|
||||||
*/
|
|
||||||
public class RecentActivityVO {
|
|
||||||
/**
|
|
||||||
* Field `id` (Long): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
/**
|
|
||||||
* Field `type` (String): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
|
||||||
*/
|
|
||||||
private String type;
|
|
||||||
/**
|
|
||||||
* Field `title` (String): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
|
||||||
*/
|
|
||||||
private String title;
|
|
||||||
/**
|
|
||||||
* Field `description` (String): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
|
||||||
*/
|
|
||||||
private String description;
|
|
||||||
/**
|
|
||||||
* Field `time` (LocalDateTime): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
|
||||||
*/
|
|
||||||
private LocalDateTime time;
|
|
||||||
/**
|
|
||||||
* Field `color` (String): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
|
||||||
*/
|
|
||||||
private String color;
|
|
||||||
}
|
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.analytics.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class StoreWorkbenchVO {
|
|
||||||
private Long todayOrderCount;
|
|
||||||
private Long pendingOrderCount;
|
|
||||||
private Long pendingAfterSaleCount;
|
|
||||||
private Long pendingArtistChangeCount;
|
|
||||||
private Long lowStockItemCount;
|
|
||||||
private Long scheduleReminderCount;
|
|
||||||
private Long todayServiceCount;
|
|
||||||
private Long completedServiceCount;
|
|
||||||
private BigDecimal serviceAmount;
|
|
||||||
private BigDecimal averageRating;
|
|
||||||
}
|
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.artist.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class ArtistScheduleDTO {
|
|
||||||
private Long shopId;
|
|
||||||
private Long artistId;
|
|
||||||
private LocalDate workDate;
|
|
||||||
private LocalTime startTime;
|
|
||||||
private LocalTime endTime;
|
|
||||||
private Integer slotMinutes;
|
|
||||||
private Integer capacity;
|
|
||||||
private Integer status;
|
|
||||||
private String remark;
|
|
||||||
}
|
|
||||||
-17
@@ -1,17 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.artist.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class ArtistScheduleExceptionDTO {
|
|
||||||
private Long shopId;
|
|
||||||
private Long artistId;
|
|
||||||
private LocalDate workDate;
|
|
||||||
private String exceptionType;
|
|
||||||
private LocalTime startTime;
|
|
||||||
private LocalTime endTime;
|
|
||||||
private String remark;
|
|
||||||
}
|
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.artist.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class ArtistScheduleRuleDTO {
|
|
||||||
private Long shopId;
|
|
||||||
private Long artistId;
|
|
||||||
private String presetType;
|
|
||||||
private List<Integer> workDays;
|
|
||||||
private LocalTime startTime;
|
|
||||||
private LocalTime endTime;
|
|
||||||
private Integer status;
|
|
||||||
private String remark;
|
|
||||||
}
|
|
||||||
-24
@@ -1,24 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.artist.service;
|
|
||||||
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.dto.ArtistScheduleDTO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.dto.ArtistScheduleExceptionDTO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.dto.ArtistScheduleRuleDTO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.vo.ArtistScheduleExceptionVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.vo.ArtistScheduleRuleSettingVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.vo.ArtistScheduleRuleVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.vo.ArtistScheduleVO;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface ArtistScheduleService {
|
|
||||||
ArtistScheduleVO saveSchedule(ArtistScheduleDTO dto);
|
|
||||||
|
|
||||||
List<ArtistScheduleVO> listSchedules(Long shopId, Long artistId, LocalDate startDate, LocalDate endDate);
|
|
||||||
|
|
||||||
ArtistScheduleRuleSettingVO getRuleSetting(Long shopId, Long artistId);
|
|
||||||
|
|
||||||
ArtistScheduleRuleVO saveRule(ArtistScheduleRuleDTO dto);
|
|
||||||
|
|
||||||
ArtistScheduleExceptionVO saveException(ArtistScheduleExceptionDTO dto);
|
|
||||||
}
|
|
||||||
-423
@@ -1,423 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.artist.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.dto.ArtistScheduleDTO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.dto.ArtistScheduleExceptionDTO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.dto.ArtistScheduleRuleDTO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.entity.ArtistScheduleExceptionDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.entity.ArtistScheduleDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.entity.ArtistScheduleRuleDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.mapper.ArtistScheduleExceptionMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.mapper.ArtistScheduleMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.mapper.ArtistScheduleRuleMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.service.ArtistScheduleService;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.vo.ArtistScheduleExceptionVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.vo.ArtistScheduleRuleSettingVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.vo.ArtistScheduleRuleVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.vo.ArtistScheduleVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.mapper.AppointmentReservationMapper;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.time.DayOfWeek;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class ArtistScheduleServiceImpl implements ArtistScheduleService {
|
|
||||||
|
|
||||||
private static final int GENERATED_DAYS = 60;
|
|
||||||
private static final int DEFAULT_SLOT_MINUTES = 60;
|
|
||||||
private static final int DEFAULT_CAPACITY = 1;
|
|
||||||
private static final String PRESET_SINGLE_REST = "SINGLE_REST";
|
|
||||||
private static final String PRESET_DOUBLE_REST = "DOUBLE_REST";
|
|
||||||
private static final String PRESET_NINE_TO_FIVE = "NINE_TO_FIVE";
|
|
||||||
private static final String PRESET_LATE_SHIFT = "LATE_SHIFT";
|
|
||||||
private static final String PRESET_CUSTOM = "CUSTOM";
|
|
||||||
private static final String EXCEPTION_REST = "REST";
|
|
||||||
private static final String EXCEPTION_EXTRA_WORK = "EXTRA_WORK";
|
|
||||||
private static final String EXCEPTION_CHANGE_SHIFT = "CHANGE_SHIFT";
|
|
||||||
|
|
||||||
private final ArtistScheduleMapper artistScheduleMapper;
|
|
||||||
private final ArtistScheduleRuleMapper ruleMapper;
|
|
||||||
private final ArtistScheduleExceptionMapper exceptionMapper;
|
|
||||||
private final AppointmentReservationMapper reservationMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public ArtistScheduleVO saveSchedule(ArtistScheduleDTO dto) {
|
|
||||||
if (dto == null || dto.getShopId() == null || dto.getArtistId() == null || dto.getWorkDate() == null
|
|
||||||
|| dto.getStartTime() == null || dto.getEndTime() == null) {
|
|
||||||
throw new RuntimeException("排班信息不完整");
|
|
||||||
}
|
|
||||||
ArtistScheduleDO schedule = new ArtistScheduleDO();
|
|
||||||
BeanUtils.copyProperties(dto, schedule);
|
|
||||||
schedule.setSlotMinutes(dto.getSlotMinutes() == null ? 60 : dto.getSlotMinutes());
|
|
||||||
schedule.setCapacity(dto.getCapacity() == null || dto.getCapacity() < 1 ? 1 : dto.getCapacity());
|
|
||||||
schedule.setStatus(dto.getStatus() == null ? 1 : dto.getStatus());
|
|
||||||
schedule.setIsDelete(0);
|
|
||||||
ArtistScheduleDO existing = artistScheduleMapper.selectSlotScheduleForUpdate(dto.getShopId(), dto.getArtistId(), dto.getWorkDate(), dto.getStartTime());
|
|
||||||
if (existing == null) {
|
|
||||||
artistScheduleMapper.insert(schedule);
|
|
||||||
} else {
|
|
||||||
schedule.setId(existing.getId());
|
|
||||||
artistScheduleMapper.updateGeneratedSchedule(existing.getId(), schedule.getStartTime(), schedule.getEndTime(),
|
|
||||||
schedule.getSlotMinutes(), schedule.getCapacity(), schedule.getStatus(), schedule.getRemark());
|
|
||||||
}
|
|
||||||
return toVO(schedule);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ArtistScheduleVO> listSchedules(Long shopId, Long artistId, LocalDate startDate, LocalDate endDate) {
|
|
||||||
LambdaQueryWrapper<ArtistScheduleDO> wrapper = new LambdaQueryWrapper<ArtistScheduleDO>()
|
|
||||||
.eq(ArtistScheduleDO::getIsDelete, 0)
|
|
||||||
.orderByAsc(ArtistScheduleDO::getWorkDate)
|
|
||||||
.orderByAsc(ArtistScheduleDO::getStartTime);
|
|
||||||
if (shopId != null) {
|
|
||||||
wrapper.eq(ArtistScheduleDO::getShopId, shopId);
|
|
||||||
}
|
|
||||||
if (artistId != null) {
|
|
||||||
wrapper.eq(ArtistScheduleDO::getArtistId, artistId);
|
|
||||||
}
|
|
||||||
if (startDate != null) {
|
|
||||||
wrapper.ge(ArtistScheduleDO::getWorkDate, startDate);
|
|
||||||
}
|
|
||||||
if (endDate != null) {
|
|
||||||
wrapper.le(ArtistScheduleDO::getWorkDate, endDate);
|
|
||||||
}
|
|
||||||
return artistScheduleMapper.selectList(wrapper).stream().map(this::toVO).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArtistScheduleVO toVO(ArtistScheduleDO schedule) {
|
|
||||||
ArtistScheduleVO vo = new ArtistScheduleVO();
|
|
||||||
BeanUtils.copyProperties(schedule, vo);
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArtistScheduleRuleSettingVO getRuleSetting(Long shopId, Long artistId) {
|
|
||||||
if (shopId == null || artistId == null) {
|
|
||||||
throw new RuntimeException("排班规则查询参数不完整");
|
|
||||||
}
|
|
||||||
ArtistScheduleRuleSettingVO setting = new ArtistScheduleRuleSettingVO();
|
|
||||||
ArtistScheduleRuleDO rule = selectRule(shopId, artistId);
|
|
||||||
setting.setRule(rule == null ? defaultRuleVO(shopId, artistId) : toRuleVO(rule));
|
|
||||||
setting.setExceptions(listExceptions(shopId, artistId, LocalDate.now(), LocalDate.now().plusDays(GENERATED_DAYS - 1L))
|
|
||||||
.stream()
|
|
||||||
.map(this::toExceptionVO)
|
|
||||||
.toList());
|
|
||||||
return setting;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public ArtistScheduleRuleVO saveRule(ArtistScheduleRuleDTO dto) {
|
|
||||||
ArtistScheduleRuleDO normalized = normalizeRule(dto);
|
|
||||||
ArtistScheduleRuleDO existing = selectRule(normalized.getShopId(), normalized.getArtistId());
|
|
||||||
if (existing == null) {
|
|
||||||
ruleMapper.insert(normalized);
|
|
||||||
} else {
|
|
||||||
normalized.setId(existing.getId());
|
|
||||||
ruleMapper.updateById(normalized);
|
|
||||||
}
|
|
||||||
refreshGeneratedSchedules(normalized);
|
|
||||||
return toRuleVO(normalized);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public ArtistScheduleExceptionVO saveException(ArtistScheduleExceptionDTO dto) {
|
|
||||||
ArtistScheduleExceptionDO normalized = normalizeException(dto);
|
|
||||||
ArtistScheduleRuleDO rule = selectRule(normalized.getShopId(), normalized.getArtistId());
|
|
||||||
if (rule == null) {
|
|
||||||
rule = defaultRule(normalized.getShopId(), normalized.getArtistId());
|
|
||||||
}
|
|
||||||
ArtistScheduleExceptionDO existing = selectException(normalized.getShopId(), normalized.getArtistId(), normalized.getWorkDate());
|
|
||||||
if (existing == null) {
|
|
||||||
exceptionMapper.insert(normalized);
|
|
||||||
} else {
|
|
||||||
normalized.setId(existing.getId());
|
|
||||||
exceptionMapper.updateById(normalized);
|
|
||||||
}
|
|
||||||
refreshScheduleForDate(rule, normalized, normalized.getWorkDate());
|
|
||||||
return toExceptionVO(normalized);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArtistScheduleRuleDO normalizeRule(ArtistScheduleRuleDTO dto) {
|
|
||||||
if (dto == null || dto.getShopId() == null || dto.getArtistId() == null) {
|
|
||||||
throw new RuntimeException("排班规则信息不完整");
|
|
||||||
}
|
|
||||||
String presetType = normalizePresetType(dto.getPresetType());
|
|
||||||
LocalTime startTime = dto.getStartTime() == null ? presetStartTime(presetType) : dto.getStartTime();
|
|
||||||
LocalTime endTime = dto.getEndTime() == null ? presetEndTime(presetType) : dto.getEndTime();
|
|
||||||
validateTimeRange(startTime, endTime);
|
|
||||||
ArtistScheduleRuleDO rule = new ArtistScheduleRuleDO();
|
|
||||||
rule.setShopId(dto.getShopId());
|
|
||||||
rule.setArtistId(dto.getArtistId());
|
|
||||||
rule.setPresetType(presetType);
|
|
||||||
rule.setWorkDays(encodeWorkDays(resolveWorkDays(dto.getWorkDays(), presetType)));
|
|
||||||
rule.setStartTime(startTime);
|
|
||||||
rule.setEndTime(endTime);
|
|
||||||
rule.setSlotMinutes(DEFAULT_SLOT_MINUTES);
|
|
||||||
rule.setCapacity(DEFAULT_CAPACITY);
|
|
||||||
rule.setStatus(dto.getStatus() == null ? 1 : dto.getStatus());
|
|
||||||
rule.setRemark(trimText(dto.getRemark()));
|
|
||||||
rule.setIsDelete(0);
|
|
||||||
return rule;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArtistScheduleExceptionDO normalizeException(ArtistScheduleExceptionDTO dto) {
|
|
||||||
if (dto == null || dto.getShopId() == null || dto.getArtistId() == null || dto.getWorkDate() == null) {
|
|
||||||
throw new RuntimeException("排班例外信息不完整");
|
|
||||||
}
|
|
||||||
String exceptionType = normalizeExceptionType(dto.getExceptionType());
|
|
||||||
LocalTime startTime = dto.getStartTime();
|
|
||||||
LocalTime endTime = dto.getEndTime();
|
|
||||||
if (!EXCEPTION_REST.equals(exceptionType)) {
|
|
||||||
if (startTime == null || endTime == null) {
|
|
||||||
throw new RuntimeException("临时上班或改班必须填写开始和结束时间");
|
|
||||||
}
|
|
||||||
validateTimeRange(startTime, endTime);
|
|
||||||
}
|
|
||||||
ArtistScheduleExceptionDO exception = new ArtistScheduleExceptionDO();
|
|
||||||
exception.setShopId(dto.getShopId());
|
|
||||||
exception.setArtistId(dto.getArtistId());
|
|
||||||
exception.setWorkDate(dto.getWorkDate());
|
|
||||||
exception.setExceptionType(exceptionType);
|
|
||||||
exception.setStartTime(startTime);
|
|
||||||
exception.setEndTime(endTime);
|
|
||||||
exception.setSlotMinutes(DEFAULT_SLOT_MINUTES);
|
|
||||||
exception.setCapacity(DEFAULT_CAPACITY);
|
|
||||||
exception.setRemark(trimText(dto.getRemark()));
|
|
||||||
exception.setIsDelete(0);
|
|
||||||
return exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArtistScheduleRuleDO selectRule(Long shopId, Long artistId) {
|
|
||||||
return ruleMapper.selectOne(new LambdaQueryWrapper<ArtistScheduleRuleDO>()
|
|
||||||
.eq(ArtistScheduleRuleDO::getShopId, shopId)
|
|
||||||
.eq(ArtistScheduleRuleDO::getArtistId, artistId)
|
|
||||||
.eq(ArtistScheduleRuleDO::getIsDelete, 0)
|
|
||||||
.last("LIMIT 1"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArtistScheduleExceptionDO selectException(Long shopId, Long artistId, LocalDate workDate) {
|
|
||||||
return exceptionMapper.selectOne(new LambdaQueryWrapper<ArtistScheduleExceptionDO>()
|
|
||||||
.eq(ArtistScheduleExceptionDO::getShopId, shopId)
|
|
||||||
.eq(ArtistScheduleExceptionDO::getArtistId, artistId)
|
|
||||||
.eq(ArtistScheduleExceptionDO::getWorkDate, workDate)
|
|
||||||
.eq(ArtistScheduleExceptionDO::getIsDelete, 0)
|
|
||||||
.last("LIMIT 1"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ArtistScheduleExceptionDO> listExceptions(Long shopId, Long artistId, LocalDate start, LocalDate end) {
|
|
||||||
return exceptionMapper.selectList(new LambdaQueryWrapper<ArtistScheduleExceptionDO>()
|
|
||||||
.eq(ArtistScheduleExceptionDO::getShopId, shopId)
|
|
||||||
.eq(ArtistScheduleExceptionDO::getArtistId, artistId)
|
|
||||||
.eq(ArtistScheduleExceptionDO::getIsDelete, 0)
|
|
||||||
.between(ArtistScheduleExceptionDO::getWorkDate, start, end)
|
|
||||||
.orderByAsc(ArtistScheduleExceptionDO::getWorkDate));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshGeneratedSchedules(ArtistScheduleRuleDO rule) {
|
|
||||||
LocalDate start = LocalDate.now();
|
|
||||||
LocalDate end = start.plusDays(GENERATED_DAYS - 1L);
|
|
||||||
Map<LocalDate, ArtistScheduleExceptionDO> exceptionByDate = listExceptions(rule.getShopId(), rule.getArtistId(), start, end)
|
|
||||||
.stream()
|
|
||||||
.collect(Collectors.toMap(ArtistScheduleExceptionDO::getWorkDate, Function.identity(), (a, b) -> a));
|
|
||||||
LocalDate cursor = start;
|
|
||||||
while (!cursor.isAfter(end)) {
|
|
||||||
refreshScheduleForDate(rule, exceptionByDate.get(cursor), cursor);
|
|
||||||
cursor = cursor.plusDays(1L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshScheduleForDate(ArtistScheduleRuleDO rule, ArtistScheduleExceptionDO exception, LocalDate workDate) {
|
|
||||||
GeneratedSchedule generated = resolveGeneratedSchedule(rule, exception, workDate);
|
|
||||||
if (!generated.working()) {
|
|
||||||
assertNoActiveReservations(rule.getShopId(), rule.getArtistId(), workDate);
|
|
||||||
upsertGeneratedSchedule(rule, workDate, rule.getStartTime(), rule.getEndTime(), rule.getSlotMinutes(), rule.getCapacity(), 0, generated.remark());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
assertNoReservationsOutsideSchedule(rule.getShopId(), rule.getArtistId(), workDate, generated.startTime(), generated.endTime());
|
|
||||||
upsertGeneratedSchedule(rule, workDate, generated.startTime(), generated.endTime(), generated.slotMinutes(), generated.capacity(), 1, generated.remark());
|
|
||||||
}
|
|
||||||
|
|
||||||
private GeneratedSchedule resolveGeneratedSchedule(ArtistScheduleRuleDO rule, ArtistScheduleExceptionDO exception, LocalDate workDate) {
|
|
||||||
if (exception != null) {
|
|
||||||
if (EXCEPTION_REST.equals(exception.getExceptionType())) {
|
|
||||||
return new GeneratedSchedule(false, rule.getStartTime(), rule.getEndTime(), rule.getSlotMinutes(), rule.getCapacity(), exceptionRemark(exception));
|
|
||||||
}
|
|
||||||
if (EXCEPTION_EXTRA_WORK.equals(exception.getExceptionType()) || EXCEPTION_CHANGE_SHIFT.equals(exception.getExceptionType())) {
|
|
||||||
return new GeneratedSchedule(true, exception.getStartTime(), exception.getEndTime(), exception.getSlotMinutes(), exception.getCapacity(), exceptionRemark(exception));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
boolean workingDay = Integer.valueOf(1).equals(rule.getStatus()) && decodeWorkDays(rule.getWorkDays()).contains(workDate.getDayOfWeek().getValue());
|
|
||||||
return new GeneratedSchedule(workingDay, rule.getStartTime(), rule.getEndTime(), rule.getSlotMinutes(), rule.getCapacity(), "规则生成排班");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void upsertGeneratedSchedule(ArtistScheduleRuleDO rule, LocalDate workDate, LocalTime startTime, LocalTime endTime,
|
|
||||||
Integer slotMinutes, Integer capacity, Integer status, String remark) {
|
|
||||||
ArtistScheduleDO schedule = artistScheduleMapper.selectDayScheduleForUpdate(rule.getShopId(), rule.getArtistId(), workDate);
|
|
||||||
if (schedule == null) {
|
|
||||||
schedule = new ArtistScheduleDO();
|
|
||||||
schedule.setShopId(rule.getShopId());
|
|
||||||
schedule.setArtistId(rule.getArtistId());
|
|
||||||
schedule.setWorkDate(workDate);
|
|
||||||
schedule.setStartTime(startTime);
|
|
||||||
schedule.setEndTime(endTime);
|
|
||||||
schedule.setSlotMinutes(slotMinutes);
|
|
||||||
schedule.setCapacity(capacity);
|
|
||||||
schedule.setStatus(status);
|
|
||||||
schedule.setRemark(remark);
|
|
||||||
schedule.setIsDelete(0);
|
|
||||||
artistScheduleMapper.insert(schedule);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
artistScheduleMapper.updateGeneratedSchedule(schedule.getId(), startTime, endTime, slotMinutes, capacity, status, remark);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertNoActiveReservations(Long shopId, Long artistId, LocalDate workDate) {
|
|
||||||
int count = reservationMapper.countActiveByArtistAndDateForUpdate(shopId, artistId, workDate);
|
|
||||||
if (count > 0) {
|
|
||||||
throw new RuntimeException("该日期已有预约,不能设置为休假:" + workDate + ",预约数:" + count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertNoReservationsOutsideSchedule(Long shopId, Long artistId, LocalDate workDate, LocalTime startTime, LocalTime endTime) {
|
|
||||||
int count = reservationMapper.countActiveOutsideScheduleForUpdate(shopId, artistId, workDate, startTime, endTime);
|
|
||||||
if (count > 0) {
|
|
||||||
throw new RuntimeException("该日期已有预约超出新的排班时间:" + workDate + ",冲突预约数:" + count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArtistScheduleRuleVO defaultRuleVO(Long shopId, Long artistId) {
|
|
||||||
return toRuleVO(defaultRule(shopId, artistId));
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArtistScheduleRuleDO defaultRule(Long shopId, Long artistId) {
|
|
||||||
ArtistScheduleRuleDO rule = new ArtistScheduleRuleDO();
|
|
||||||
rule.setShopId(shopId);
|
|
||||||
rule.setArtistId(artistId);
|
|
||||||
rule.setPresetType(PRESET_DOUBLE_REST);
|
|
||||||
rule.setWorkDays(encodeWorkDays(List.of(1, 2, 3, 4, 5)));
|
|
||||||
rule.setStartTime(LocalTime.of(9, 0));
|
|
||||||
rule.setEndTime(LocalTime.of(17, 0));
|
|
||||||
rule.setSlotMinutes(DEFAULT_SLOT_MINUTES);
|
|
||||||
rule.setCapacity(DEFAULT_CAPACITY);
|
|
||||||
rule.setStatus(1);
|
|
||||||
rule.setIsDelete(0);
|
|
||||||
return rule;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArtistScheduleRuleVO toRuleVO(ArtistScheduleRuleDO rule) {
|
|
||||||
ArtistScheduleRuleVO vo = new ArtistScheduleRuleVO();
|
|
||||||
BeanUtils.copyProperties(rule, vo);
|
|
||||||
vo.setWorkDays(decodeWorkDays(rule.getWorkDays()));
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArtistScheduleExceptionVO toExceptionVO(ArtistScheduleExceptionDO exception) {
|
|
||||||
ArtistScheduleExceptionVO vo = new ArtistScheduleExceptionVO();
|
|
||||||
BeanUtils.copyProperties(exception, vo);
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String normalizePresetType(String presetType) {
|
|
||||||
String value = trimText(presetType);
|
|
||||||
if (value == null || value.isBlank()) {
|
|
||||||
return PRESET_CUSTOM;
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String normalizeExceptionType(String exceptionType) {
|
|
||||||
String value = trimText(exceptionType);
|
|
||||||
if (EXCEPTION_REST.equals(value) || EXCEPTION_EXTRA_WORK.equals(value) || EXCEPTION_CHANGE_SHIFT.equals(value)) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
throw new RuntimeException("不支持的排班例外类型:" + value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Integer> resolveWorkDays(List<Integer> inputWorkDays, String presetType) {
|
|
||||||
List<Integer> presetDays = switch (presetType) {
|
|
||||||
case PRESET_DOUBLE_REST, PRESET_NINE_TO_FIVE -> List.of(1, 2, 3, 4, 5);
|
|
||||||
case PRESET_SINGLE_REST, PRESET_LATE_SHIFT -> List.of(1, 2, 3, 4, 5, 6);
|
|
||||||
default -> inputWorkDays;
|
|
||||||
};
|
|
||||||
Set<Integer> normalized = new LinkedHashSet<>();
|
|
||||||
for (Integer day : presetDays == null ? List.<Integer>of() : presetDays) {
|
|
||||||
if (day != null && day >= DayOfWeek.MONDAY.getValue() && day <= DayOfWeek.SUNDAY.getValue()) {
|
|
||||||
normalized.add(day);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (normalized.isEmpty()) {
|
|
||||||
throw new RuntimeException("请至少选择一个工作日");
|
|
||||||
}
|
|
||||||
return normalized.stream().sorted().toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String encodeWorkDays(List<Integer> workDays) {
|
|
||||||
return workDays.stream()
|
|
||||||
.sorted()
|
|
||||||
.map(String::valueOf)
|
|
||||||
.collect(Collectors.joining(","));
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Integer> decodeWorkDays(String workDays) {
|
|
||||||
if (workDays == null || workDays.isBlank()) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
return List.of(workDays.split(",")).stream()
|
|
||||||
.map(String::trim)
|
|
||||||
.filter(value -> !value.isBlank())
|
|
||||||
.map(Integer::valueOf)
|
|
||||||
.sorted()
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private LocalTime presetStartTime(String presetType) {
|
|
||||||
if (PRESET_NINE_TO_FIVE.equals(presetType)) {
|
|
||||||
return LocalTime.of(9, 0);
|
|
||||||
}
|
|
||||||
return LocalTime.of(10, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private LocalTime presetEndTime(String presetType) {
|
|
||||||
if (PRESET_NINE_TO_FIVE.equals(presetType)) {
|
|
||||||
return LocalTime.of(17, 0);
|
|
||||||
}
|
|
||||||
return LocalTime.of(22, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateTimeRange(LocalTime startTime, LocalTime endTime) {
|
|
||||||
if (startTime == null || endTime == null || !startTime.isBefore(endTime)) {
|
|
||||||
throw new RuntimeException("排班开始时间必须早于结束时间");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String trimText(String value) {
|
|
||||||
return value == null ? null : value.trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String exceptionRemark(ArtistScheduleExceptionDO exception) {
|
|
||||||
if (exception.getRemark() != null && !exception.getRemark().isBlank()) {
|
|
||||||
return exception.getRemark();
|
|
||||||
}
|
|
||||||
return "例外排班:" + exception.getExceptionType();
|
|
||||||
}
|
|
||||||
|
|
||||||
private record GeneratedSchedule(boolean working, LocalTime startTime, LocalTime endTime, Integer slotMinutes,
|
|
||||||
Integer capacity, String remark) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.artist.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class ArtistScheduleExceptionVO {
|
|
||||||
private Long id;
|
|
||||||
private Long shopId;
|
|
||||||
private Long artistId;
|
|
||||||
private LocalDate workDate;
|
|
||||||
private String exceptionType;
|
|
||||||
private LocalTime startTime;
|
|
||||||
private LocalTime endTime;
|
|
||||||
private String remark;
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
}
|
|
||||||
-11
@@ -1,11 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.artist.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class ArtistScheduleRuleSettingVO {
|
|
||||||
private ArtistScheduleRuleVO rule;
|
|
||||||
private List<ArtistScheduleExceptionVO> exceptions;
|
|
||||||
}
|
|
||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.artist.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class ArtistScheduleRuleVO {
|
|
||||||
private Long id;
|
|
||||||
private Long shopId;
|
|
||||||
private Long artistId;
|
|
||||||
private String presetType;
|
|
||||||
private List<Integer> workDays;
|
|
||||||
private LocalTime startTime;
|
|
||||||
private LocalTime endTime;
|
|
||||||
private Integer status;
|
|
||||||
private String remark;
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
}
|
|
||||||
-22
@@ -1,22 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.artist.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class ArtistScheduleVO {
|
|
||||||
private Long id;
|
|
||||||
private Long shopId;
|
|
||||||
private Long artistId;
|
|
||||||
private LocalDate workDate;
|
|
||||||
private LocalTime startTime;
|
|
||||||
private LocalTime endTime;
|
|
||||||
private Integer slotMinutes;
|
|
||||||
private Integer capacity;
|
|
||||||
private Integer status;
|
|
||||||
private String remark;
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
}
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.inventory.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class InventoryAdjustDTO {
|
|
||||||
private String changeType;
|
|
||||||
private BigDecimal changeQuantity;
|
|
||||||
private String remark;
|
|
||||||
}
|
|
||||||
-16
@@ -1,16 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.inventory.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class InventoryItemDTO {
|
|
||||||
private Long shopId;
|
|
||||||
private String category;
|
|
||||||
private String itemName;
|
|
||||||
private String unit;
|
|
||||||
private BigDecimal stockQuantity;
|
|
||||||
private BigDecimal warningThreshold;
|
|
||||||
private Integer status;
|
|
||||||
}
|
|
||||||
-33
@@ -1,33 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.inventory.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.common.entity.BaseEntity;
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@TableName("t_inventory_item")
|
|
||||||
public class InventoryItemDO extends BaseEntity {
|
|
||||||
@TableField("shop_id")
|
|
||||||
private Long shopId;
|
|
||||||
@TableField("category")
|
|
||||||
private String category;
|
|
||||||
@TableField("item_name")
|
|
||||||
private String itemName;
|
|
||||||
@TableField("unit")
|
|
||||||
private String unit;
|
|
||||||
@TableField("stock_quantity")
|
|
||||||
private BigDecimal stockQuantity;
|
|
||||||
@TableField("warning_threshold")
|
|
||||||
private BigDecimal warningThreshold;
|
|
||||||
@TableField("status")
|
|
||||||
private Integer status;
|
|
||||||
@TableField("is_delete")
|
|
||||||
@TableLogic
|
|
||||||
private Integer isDelete;
|
|
||||||
}
|
|
||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.inventory.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.common.entity.BaseEntity;
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@TableName("t_inventory_record")
|
|
||||||
public class InventoryRecordDO extends BaseEntity {
|
|
||||||
@TableField("inventory_item_id")
|
|
||||||
private Long inventoryItemId;
|
|
||||||
@TableField("shop_id")
|
|
||||||
private Long shopId;
|
|
||||||
@TableField("change_type")
|
|
||||||
private String changeType;
|
|
||||||
@TableField("change_quantity")
|
|
||||||
private BigDecimal changeQuantity;
|
|
||||||
@TableField("before_quantity")
|
|
||||||
private BigDecimal beforeQuantity;
|
|
||||||
@TableField("after_quantity")
|
|
||||||
private BigDecimal afterQuantity;
|
|
||||||
@TableField("operator_id")
|
|
||||||
private Long operatorId;
|
|
||||||
@TableField("remark")
|
|
||||||
private String remark;
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.inventory.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.entity.InventoryItemDO;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface InventoryItemMapper extends BaseMapper<InventoryItemDO> {
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.inventory.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.entity.InventoryRecordDO;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface InventoryRecordMapper extends BaseMapper<InventoryRecordDO> {
|
|
||||||
}
|
|
||||||
-14
@@ -1,14 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.inventory.service;
|
|
||||||
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.dto.InventoryAdjustDTO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.dto.InventoryItemDTO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.vo.InventoryItemVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.common.vo.PageResultVO;
|
|
||||||
|
|
||||||
public interface InventoryService {
|
|
||||||
InventoryItemVO saveItem(InventoryItemDTO dto);
|
|
||||||
|
|
||||||
InventoryItemVO adjustStock(Long operatorId, Long itemId, InventoryAdjustDTO dto);
|
|
||||||
|
|
||||||
PageResultVO<InventoryItemVO> listItems(Long shopId, Integer page, Integer size);
|
|
||||||
}
|
|
||||||
-99
@@ -1,99 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.inventory.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.dto.InventoryAdjustDTO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.dto.InventoryItemDTO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.entity.InventoryItemDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.entity.InventoryRecordDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.mapper.InventoryItemMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.mapper.InventoryRecordMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.service.InventoryService;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.vo.InventoryItemVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.common.vo.PageResultVO;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class InventoryServiceImpl implements InventoryService {
|
|
||||||
|
|
||||||
private final InventoryItemMapper inventoryItemMapper;
|
|
||||||
private final InventoryRecordMapper inventoryRecordMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public InventoryItemVO saveItem(InventoryItemDTO dto) {
|
|
||||||
if (dto == null || dto.getShopId() == null || dto.getItemName() == null || dto.getItemName().isBlank()) {
|
|
||||||
throw new RuntimeException("库存物料信息不完整");
|
|
||||||
}
|
|
||||||
InventoryItemDO item = new InventoryItemDO();
|
|
||||||
BeanUtils.copyProperties(dto, item);
|
|
||||||
item.setStockQuantity(dto.getStockQuantity() == null ? BigDecimal.ZERO : dto.getStockQuantity());
|
|
||||||
item.setWarningThreshold(dto.getWarningThreshold() == null ? BigDecimal.ZERO : dto.getWarningThreshold());
|
|
||||||
item.setStatus(dto.getStatus() == null ? 1 : dto.getStatus());
|
|
||||||
item.setIsDelete(0);
|
|
||||||
inventoryItemMapper.insert(item);
|
|
||||||
return toVO(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public InventoryItemVO adjustStock(Long operatorId, Long itemId, InventoryAdjustDTO dto) {
|
|
||||||
InventoryItemDO item = inventoryItemMapper.selectById(itemId);
|
|
||||||
if (item == null || Integer.valueOf(1).equals(item.getIsDelete())) {
|
|
||||||
throw new RuntimeException("库存物料不存在");
|
|
||||||
}
|
|
||||||
BigDecimal before = item.getStockQuantity() == null ? BigDecimal.ZERO : item.getStockQuantity();
|
|
||||||
BigDecimal delta = dto == null || dto.getChangeQuantity() == null ? BigDecimal.ZERO : dto.getChangeQuantity();
|
|
||||||
BigDecimal after = before.add(delta);
|
|
||||||
if (after.compareTo(BigDecimal.ZERO) < 0) {
|
|
||||||
throw new RuntimeException("库存不能小于 0");
|
|
||||||
}
|
|
||||||
item.setStockQuantity(after);
|
|
||||||
inventoryItemMapper.updateById(item);
|
|
||||||
InventoryRecordDO record = new InventoryRecordDO();
|
|
||||||
record.setInventoryItemId(item.getId());
|
|
||||||
record.setShopId(item.getShopId());
|
|
||||||
record.setChangeType(dto == null ? null : dto.getChangeType());
|
|
||||||
record.setChangeQuantity(delta);
|
|
||||||
record.setBeforeQuantity(before);
|
|
||||||
record.setAfterQuantity(after);
|
|
||||||
record.setOperatorId(operatorId);
|
|
||||||
record.setRemark(dto == null ? null : dto.getRemark());
|
|
||||||
inventoryRecordMapper.insert(record);
|
|
||||||
return toVO(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PageResultVO<InventoryItemVO> listItems(Long shopId, Integer page, Integer size) {
|
|
||||||
int current = page == null || page < 1 ? 1 : page;
|
|
||||||
int pageSize = size == null || size < 1 ? 10 : size;
|
|
||||||
LambdaQueryWrapper<InventoryItemDO> wrapper = new LambdaQueryWrapper<InventoryItemDO>()
|
|
||||||
.eq(InventoryItemDO::getIsDelete, 0)
|
|
||||||
.orderByDesc(InventoryItemDO::getCreateTime);
|
|
||||||
if (shopId != null) {
|
|
||||||
wrapper.eq(InventoryItemDO::getShopId, shopId);
|
|
||||||
}
|
|
||||||
Page<InventoryItemDO> result = inventoryItemMapper.selectPage(new Page<>(current, pageSize), wrapper);
|
|
||||||
PageResultVO<InventoryItemVO> vo = new PageResultVO<>();
|
|
||||||
vo.setList(result.getRecords().stream().map(this::toVO).toList());
|
|
||||||
vo.setTotal(result.getTotal());
|
|
||||||
vo.setPage(current);
|
|
||||||
vo.setSize(pageSize);
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private InventoryItemVO toVO(InventoryItemDO item) {
|
|
||||||
InventoryItemVO vo = new InventoryItemVO();
|
|
||||||
BeanUtils.copyProperties(item, vo);
|
|
||||||
BigDecimal stock = item.getStockQuantity() == null ? BigDecimal.ZERO : item.getStockQuantity();
|
|
||||||
BigDecimal warning = item.getWarningThreshold() == null ? BigDecimal.ZERO : item.getWarningThreshold();
|
|
||||||
vo.setWarning(stock.compareTo(warning) <= 0);
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.inventory.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class InventoryItemVO {
|
|
||||||
private Long id;
|
|
||||||
private Long shopId;
|
|
||||||
private String category;
|
|
||||||
private String itemName;
|
|
||||||
private String unit;
|
|
||||||
private BigDecimal stockQuantity;
|
|
||||||
private BigDecimal warningThreshold;
|
|
||||||
private Boolean warning;
|
|
||||||
private Integer status;
|
|
||||||
}
|
|
||||||
-17
@@ -1,17 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.manager.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.Pattern;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class ManagerCustomerCreateDTO {
|
|
||||||
|
|
||||||
@NotBlank(message = "客户姓名不能为空")
|
|
||||||
private String nickname;
|
|
||||||
|
|
||||||
@NotBlank(message = "手机号不能为空")
|
|
||||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
|
|
||||||
private String phone;
|
|
||||||
}
|
|
||||||
-6
@@ -23,10 +23,4 @@ public class PaymentController {
|
|||||||
Long userId = (Long) request.getAttribute("userId");
|
Long userId = (Long) request.getAttribute("userId");
|
||||||
return Result.success(paymentService.prepareOrderPayment(userId, orderId));
|
return Result.success(paymentService.prepareOrderPayment(userId, orderId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/order/{orderId}/mock-success")
|
|
||||||
public Result<PaymentOrderVO> mockSuccess(HttpServletRequest request, @PathVariable Long orderId) {
|
|
||||||
Long userId = (Long) request.getAttribute("userId");
|
|
||||||
return Result.success(paymentService.manualConfirmOrderPaid(userId, orderId, "mock-success"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-2
@@ -6,7 +6,5 @@ import com.xiaowang.jayucloud.artlist.core.modules.payment.vo.RefundOrderVO;
|
|||||||
public interface PaymentService {
|
public interface PaymentService {
|
||||||
PaymentOrderVO prepareOrderPayment(Long userId, Long orderId);
|
PaymentOrderVO prepareOrderPayment(Long userId, Long orderId);
|
||||||
|
|
||||||
PaymentOrderVO manualConfirmOrderPaid(Long operatorId, Long orderId, String remark);
|
|
||||||
|
|
||||||
RefundOrderVO manualRefundOrder(Long operatorId, Long orderId, Long afterSaleId, String remark);
|
RefundOrderVO manualRefundOrder(Long operatorId, Long orderId, Long afterSaleId, String remark);
|
||||||
}
|
}
|
||||||
|
|||||||
-28
@@ -60,34 +60,6 @@ public class PaymentServiceImpl implements PaymentService {
|
|||||||
return toVO(payment);
|
return toVO(payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public PaymentOrderVO manualConfirmOrderPaid(Long operatorId, Long orderId, String remark) {
|
|
||||||
OrderDO order = requirePayableOrder(null, orderId);
|
|
||||||
PaymentOrderDO payment = paymentOrderMapper.selectLatestByOrderId(orderId);
|
|
||||||
if (payment == null) {
|
|
||||||
prepareOrderPayment(order.getUserId(), orderId);
|
|
||||||
payment = paymentOrderMapper.selectLatestByOrderId(orderId);
|
|
||||||
}
|
|
||||||
if (payment == null) {
|
|
||||||
throw new RuntimeException("支付单创建失败");
|
|
||||||
}
|
|
||||||
payment.setStatus(STATUS_PAID);
|
|
||||||
payment.setPaidAmount(payment.getPayAmount());
|
|
||||||
payment.setPayTime(LocalDateTime.now());
|
|
||||||
payment.setOperatorId(operatorId);
|
|
||||||
payment.setRemark(remark);
|
|
||||||
paymentOrderMapper.updateById(payment);
|
|
||||||
|
|
||||||
order.setPaymentStatus(STATUS_PAID);
|
|
||||||
order.setPaidAmount(payment.getPayAmount());
|
|
||||||
order.setPayTime(payment.getPayTime());
|
|
||||||
order.setPaymentMethod(payment.getChannel());
|
|
||||||
order.setPaymentOrderNo(payment.getPayNo());
|
|
||||||
orderMapper.updateById(order);
|
|
||||||
return toVO(payment);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public RefundOrderVO manualRefundOrder(Long operatorId, Long orderId, Long afterSaleId, String remark) {
|
public RefundOrderVO manualRefundOrder(Long operatorId, Long orderId, Long afterSaleId, String remark) {
|
||||||
|
|||||||
-28
@@ -1,28 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.planning.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class PlanningAppointmentCreateDTO {
|
|
||||||
private Long customerUserId;
|
|
||||||
private String customerName;
|
|
||||||
private String phone;
|
|
||||||
private Long productId;
|
|
||||||
private Integer quantity;
|
|
||||||
private Long artistId;
|
|
||||||
private String appointmentDate;
|
|
||||||
private String appointmentTime;
|
|
||||||
private String appointmentStartTime;
|
|
||||||
private Integer durationMinutes;
|
|
||||||
private String manualProductTitle;
|
|
||||||
private BigDecimal manualProductPrice;
|
|
||||||
private String manualProductDescription;
|
|
||||||
private String manualProductTags;
|
|
||||||
private String manualProductTargetAudience;
|
|
||||||
private String manualProductPrecautions;
|
|
||||||
private String manualProductImageFileIds;
|
|
||||||
private String remark;
|
|
||||||
private String clientRequestId;
|
|
||||||
}
|
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.planning.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class PlanningAppointmentMoveDTO {
|
|
||||||
private Long artistId;
|
|
||||||
private String appointmentDate;
|
|
||||||
private String appointmentTime;
|
|
||||||
private String appointmentStartTime;
|
|
||||||
private Integer durationMinutes;
|
|
||||||
private String clientRequestId;
|
|
||||||
}
|
|
||||||
-8
@@ -1,8 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.planning.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class PlanningAppointmentStatusDTO {
|
|
||||||
private Integer status;
|
|
||||||
}
|
|
||||||
-22
@@ -1,22 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.planning.service;
|
|
||||||
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.dto.PlanningAppointmentCreateDTO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.dto.PlanningAppointmentMoveDTO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.dto.PlanningAppointmentStatusDTO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.user.entity.UserDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.vo.PlanningAppointmentVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.vo.PlanningCalendarVO;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
|
|
||||||
public interface PlanningService {
|
|
||||||
PlanningCalendarVO getCalendar(UserDO currentUser, LocalDate startDate, LocalDate endDate, Long artistId);
|
|
||||||
|
|
||||||
PlanningAppointmentVO createAppointment(UserDO currentUser, PlanningAppointmentCreateDTO dto);
|
|
||||||
|
|
||||||
PlanningAppointmentVO getAppointment(UserDO currentUser, Long orderItemId);
|
|
||||||
|
|
||||||
PlanningAppointmentVO moveAppointment(UserDO currentUser, Long orderItemId, PlanningAppointmentMoveDTO dto);
|
|
||||||
|
|
||||||
Boolean updateStatus(UserDO currentUser, Long orderId, PlanningAppointmentStatusDTO dto);
|
|
||||||
}
|
|
||||||
-901
@@ -1,901 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.planning.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.dto.PlanningAppointmentCreateDTO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.dto.PlanningAppointmentMoveDTO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.dto.PlanningAppointmentStatusDTO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.entity.AppointmentReservationDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.entity.ArtistScheduleDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.entity.NailArtistInfoDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.OrderDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.entity.OrderItemDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.product.entity.ProductDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.shop.entity.ShopDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.user.entity.UserDO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.mapper.AppointmentReservationMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.mapper.ArtistScheduleMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.artist.mapper.NailArtistInfoMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderItemMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.mapper.OrderMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.product.mapper.ProductMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.shop.mapper.ShopMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.user.mapper.UserMapper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.service.AppointmentCapacityService;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.service.OrderService;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.service.PlanningService;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.security.support.AdminScopeHelper;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.support.OrderStatus;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.support.PlanningCalendarSupport;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.support.id.TimeOrderedSnowflakeIdGenerator;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.vo.PlanningAppointmentVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.vo.PlanningArtistCountVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.vo.PlanningArtistVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.vo.PlanningCalendarVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.vo.PlanningDaySummaryVO;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.planning.vo.PlanningScheduleVO;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.time.format.DateTimeParseException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class PlanningServiceImpl implements PlanningService {
|
|
||||||
|
|
||||||
private static final int DEFAULT_SLOT_MINUTES = 30;
|
|
||||||
private static final int DEFAULT_DURATION_MINUTES = 60;
|
|
||||||
private static final int MONTH_AVAILABLE_MINUTES = 90;
|
|
||||||
private static final String RESERVATION_PENDING_QUOTE = "PENDING_QUOTE";
|
|
||||||
private static final String RESERVATION_CONFIRMED = "CONFIRMED";
|
|
||||||
private static final String PRODUCT_SOURCE_TYPE_MANAGER_APPOINTMENT = "MANAGER_APPOINTMENT";
|
|
||||||
private static final String ENCODED_UNSET_PASSWORD = "$2a$10$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW";
|
|
||||||
private static final List<String> ACTIVE_RESERVATION_STATUS = List.of("LOCKED", RESERVATION_PENDING_QUOTE, RESERVATION_CONFIRMED);
|
|
||||||
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
||||||
private static final List<String> ARTIST_COLORS = List.of(
|
|
||||||
"#7BA7C7", "#8FB89A", "#A894C7", "#D7A86E", "#D98DA5", "#79A6A3", "#B9A16B", "#9BA9C8"
|
|
||||||
);
|
|
||||||
|
|
||||||
private final AdminScopeHelper adminScopeHelper;
|
|
||||||
private final UserMapper userMapper;
|
|
||||||
private final NailArtistInfoMapper nailArtistInfoMapper;
|
|
||||||
private final ArtistScheduleMapper artistScheduleMapper;
|
|
||||||
private final AppointmentReservationMapper appointmentReservationMapper;
|
|
||||||
private final OrderMapper orderMapper;
|
|
||||||
private final OrderItemMapper orderItemMapper;
|
|
||||||
private final ProductMapper productMapper;
|
|
||||||
private final ShopMapper shopMapper;
|
|
||||||
private final AppointmentCapacityService appointmentCapacityService;
|
|
||||||
private final OrderService orderService;
|
|
||||||
private final TimeOrderedSnowflakeIdGenerator snowflakeIdGenerator;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PlanningCalendarVO getCalendar(UserDO currentUser, LocalDate startDate, LocalDate endDate, Long artistId) {
|
|
||||||
LocalDate start = startDate == null ? LocalDate.now() : startDate;
|
|
||||||
LocalDate end = endDate == null ? start : endDate;
|
|
||||||
if (end.isBefore(start)) {
|
|
||||||
end = start;
|
|
||||||
}
|
|
||||||
if (start.plusDays(61).isBefore(end)) {
|
|
||||||
end = start.plusDays(61);
|
|
||||||
}
|
|
||||||
|
|
||||||
Long shopId = requirePlanningShopId(currentUser);
|
|
||||||
ShopDO shop = shopMapper.selectById(shopId);
|
|
||||||
PlanningCalendarSupport.BusinessHours businessHours = PlanningCalendarSupport.parseBusinessHours(
|
|
||||||
shop == null ? null : shop.getBusinessHours()
|
|
||||||
);
|
|
||||||
|
|
||||||
List<PlanningArtistVO> artists = listArtists(shopId, artistId);
|
|
||||||
List<ArtistScheduleDO> schedules = listSchedules(shopId, start, end, artistId);
|
|
||||||
List<PlanningScheduleVO> scheduleVos = schedules.stream()
|
|
||||||
.map(schedule -> toScheduleVO(schedule, artists))
|
|
||||||
.sorted(Comparator.comparing(PlanningScheduleVO::getDate)
|
|
||||||
.thenComparing(PlanningScheduleVO::getStartTime)
|
|
||||||
.thenComparing(PlanningScheduleVO::getArtistName, Comparator.nullsLast(String::compareTo)))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
LocalDateTime rangeStart = start.atStartOfDay();
|
|
||||||
LocalDateTime rangeEnd = end.plusDays(1).atStartOfDay();
|
|
||||||
List<PlanningAppointmentVO> appointments = listAppointments(shopId, rangeStart, rangeEnd, artistId, artists);
|
|
||||||
Map<Long, Long> countByArtist = appointments.stream()
|
|
||||||
.filter(appointment -> appointment.getArtistId() != null)
|
|
||||||
.collect(Collectors.groupingBy(PlanningAppointmentVO::getArtistId, Collectors.counting()));
|
|
||||||
artists.forEach(artist -> artist.setRangeCount(countByArtist.getOrDefault(artist.getId(), 0L).intValue()));
|
|
||||||
|
|
||||||
PlanningCalendarVO vo = new PlanningCalendarVO();
|
|
||||||
vo.setBusinessStartTime(businessHours.start().toString());
|
|
||||||
vo.setBusinessEndTime(businessHours.end().toString());
|
|
||||||
vo.setSlotMinutes(DEFAULT_SLOT_MINUTES);
|
|
||||||
vo.setArtists(artists);
|
|
||||||
vo.setSchedules(scheduleVos);
|
|
||||||
vo.setAppointments(appointments);
|
|
||||||
vo.setDaySummaries(buildDaySummaries(start, end, artists, schedules, appointments));
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public PlanningAppointmentVO createAppointment(UserDO currentUser, PlanningAppointmentCreateDTO dto) {
|
|
||||||
if (dto == null) {
|
|
||||||
throw new RuntimeException("预约信息不能为空");
|
|
||||||
}
|
|
||||||
if (Integer.valueOf(3).equals(currentUser.getType())) {
|
|
||||||
throw new RuntimeException("美甲师账号只能查看预约,不能新建预约");
|
|
||||||
}
|
|
||||||
Long shopId = requirePlanningShopId(currentUser);
|
|
||||||
requireAppointmentDuration(dto.getDurationMinutes());
|
|
||||||
ProductDO product = resolveAppointmentProduct(dto, shopId);
|
|
||||||
UserDO artist = requireActiveArtist(dto.getArtistId(), shopId);
|
|
||||||
UserDO customer = resolveCustomer(shopId, dto);
|
|
||||||
|
|
||||||
int quantity = dto.getQuantity() == null || dto.getQuantity() <= 0 ? 1 : dto.getQuantity();
|
|
||||||
int durationMinutes = resolveDurationMinutes(product, dto.getDurationMinutes()) * quantity;
|
|
||||||
LocalDateTime startTime = parseAppointmentStart(dto.getAppointmentStartTime(), dto.getAppointmentDate(), dto.getAppointmentTime());
|
|
||||||
LocalDateTime endTime = startTime.plusMinutes(durationMinutes);
|
|
||||||
ensureWithinBusinessHours(shopId, startTime, endTime);
|
|
||||||
|
|
||||||
BigDecimal unitPrice = product.getPrice() == null ? BigDecimal.ZERO : product.getPrice();
|
|
||||||
BigDecimal amount = unitPrice.multiply(BigDecimal.valueOf(quantity));
|
|
||||||
|
|
||||||
OrderDO order = new OrderDO();
|
|
||||||
order.setOrderNo("ORD" + snowflakeIdGenerator.nextIdString());
|
|
||||||
order.setUserId(customer.getId());
|
|
||||||
order.setShopId(shopId);
|
|
||||||
order.setTotalAmount(amount);
|
|
||||||
order.setActualAmount(amount);
|
|
||||||
order.setCustomerRemark(trimToNull(dto.getRemark()));
|
|
||||||
order.setQuoteStatus("CONFIRMED");
|
|
||||||
order.setQuoteUserConfirmed(1);
|
|
||||||
order.setQuoteShopConfirmed(1);
|
|
||||||
order.setQuoteConfirmedTime(LocalDateTime.now());
|
|
||||||
order.setPaymentStatus("UNPAID");
|
|
||||||
order.setPayAmount(amount);
|
|
||||||
order.setPaidAmount(BigDecimal.ZERO);
|
|
||||||
order.setStatus(OrderStatus.PENDING_SERVICE.getCode());
|
|
||||||
order.setIsDelete(0);
|
|
||||||
orderMapper.insert(order);
|
|
||||||
|
|
||||||
OrderItemDO item = new OrderItemDO();
|
|
||||||
item.setOrderId(order.getId());
|
|
||||||
item.setProductId(product.getId());
|
|
||||||
item.setQuantity(quantity);
|
|
||||||
item.setPrice(unitPrice);
|
|
||||||
item.setArtistId(artist.getId());
|
|
||||||
item.setAppointmentTime(startTime);
|
|
||||||
item.setIsDelete(0);
|
|
||||||
orderItemMapper.insert(item);
|
|
||||||
|
|
||||||
appointmentCapacityService.reserveConfirmedOrThrow(
|
|
||||||
order.getId(),
|
|
||||||
item.getId(),
|
|
||||||
shopId,
|
|
||||||
artist.getId(),
|
|
||||||
product.getTitle(),
|
|
||||||
startTime,
|
|
||||||
endTime,
|
|
||||||
trimToNull(dto.getClientRequestId())
|
|
||||||
);
|
|
||||||
|
|
||||||
return getAppointment(currentUser, item.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PlanningAppointmentVO getAppointment(UserDO currentUser, Long orderItemId) {
|
|
||||||
if (orderItemId == null) {
|
|
||||||
throw new RuntimeException("预约ID不能为空");
|
|
||||||
}
|
|
||||||
OrderItemDO item = orderItemMapper.selectById(orderItemId);
|
|
||||||
if (item == null || Integer.valueOf(1).equals(item.getIsDelete())) {
|
|
||||||
throw new RuntimeException("预约不存在");
|
|
||||||
}
|
|
||||||
OrderDO order = requireAccessibleOrder(currentUser, item.getOrderId());
|
|
||||||
ProductDO product = item.getProductId() == null ? null : productMapper.selectById(item.getProductId());
|
|
||||||
AppointmentReservationDO reservation = findActiveReservation(orderItemId);
|
|
||||||
Map<Long, PlanningArtistVO> artistMap = listArtists(order.getShopId(), item.getArtistId()).stream()
|
|
||||||
.collect(Collectors.toMap(PlanningArtistVO::getId, Function.identity(), (a, b) -> a));
|
|
||||||
Map<Long, UserDO> customerMap = loadUsers(Set.of(order.getUserId()));
|
|
||||||
return toAppointmentVO(reservation, item, order, product, customerMap.get(order.getUserId()), artistMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public PlanningAppointmentVO moveAppointment(UserDO currentUser, Long orderItemId, PlanningAppointmentMoveDTO dto) {
|
|
||||||
if (orderItemId == null || dto == null) {
|
|
||||||
throw new RuntimeException("改派信息不能为空");
|
|
||||||
}
|
|
||||||
OrderItemDO item = orderItemMapper.selectByIdForUpdate(orderItemId);
|
|
||||||
if (item == null || Integer.valueOf(1).equals(item.getIsDelete())) {
|
|
||||||
throw new RuntimeException("预约不存在");
|
|
||||||
}
|
|
||||||
OrderDO order = requireAccessibleOrder(currentUser, item.getOrderId());
|
|
||||||
ProductDO product = requireActiveProduct(item.getProductId(), order.getShopId());
|
|
||||||
Long targetArtistId = dto.getArtistId() == null ? item.getArtistId() : dto.getArtistId();
|
|
||||||
UserDO artist = requireActiveArtist(targetArtistId, order.getShopId());
|
|
||||||
int durationMinutes = resolveDurationMinutes(product, dto.getDurationMinutes()) *
|
|
||||||
Math.max(1, item.getQuantity() == null ? 1 : item.getQuantity());
|
|
||||||
LocalDateTime startTime = hasText(dto.getAppointmentStartTime()) || hasText(dto.getAppointmentDate()) || hasText(dto.getAppointmentTime())
|
|
||||||
? parseAppointmentStart(dto.getAppointmentStartTime(), dto.getAppointmentDate(), dto.getAppointmentTime())
|
|
||||||
: item.getAppointmentTime();
|
|
||||||
if (startTime == null) {
|
|
||||||
throw new RuntimeException("预约时间不能为空");
|
|
||||||
}
|
|
||||||
LocalDateTime endTime = startTime.plusMinutes(durationMinutes);
|
|
||||||
ensureWithinBusinessHours(order.getShopId(), startTime, endTime);
|
|
||||||
|
|
||||||
appointmentCapacityService.moveReservationForArtistChange(
|
|
||||||
order.getId(),
|
|
||||||
item.getId(),
|
|
||||||
order.getShopId(),
|
|
||||||
item.getArtistId(),
|
|
||||||
artist.getId(),
|
|
||||||
product.getTitle(),
|
|
||||||
startTime,
|
|
||||||
endTime
|
|
||||||
);
|
|
||||||
|
|
||||||
item.setArtistId(artist.getId());
|
|
||||||
item.setAppointmentTime(startTime);
|
|
||||||
orderItemMapper.updateById(item);
|
|
||||||
return getAppointment(currentUser, item.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public Boolean updateStatus(UserDO currentUser, Long orderId, PlanningAppointmentStatusDTO dto) {
|
|
||||||
if (orderId == null || dto == null || dto.getStatus() == null) {
|
|
||||||
throw new RuntimeException("预约状态不能为空");
|
|
||||||
}
|
|
||||||
OrderDO order = requireAccessibleOrder(currentUser, orderId);
|
|
||||||
int targetStatus = dto.getStatus();
|
|
||||||
if (targetStatus == OrderStatus.PENDING_SERVICE.getCode()) {
|
|
||||||
if (!Integer.valueOf(OrderStatus.PENDING_SERVICE.getCode()).equals(order.getStatus())) {
|
|
||||||
orderMapper.updateStatusIfCurrent(order.getId(), order.getStatus(), OrderStatus.PENDING_SERVICE.getCode());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
orderService.processOrder(orderId, targetStatus);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Long requirePlanningShopId(UserDO currentUser) {
|
|
||||||
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
|
||||||
if (shopId == null || shopId <= 0) {
|
|
||||||
throw new RuntimeException("请先选择店铺后再查看规划");
|
|
||||||
}
|
|
||||||
return shopId;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<PlanningArtistVO> listArtists(Long shopId, Long artistId) {
|
|
||||||
QueryWrapper<UserDO> wrapper = new QueryWrapper<>();
|
|
||||||
wrapper.eq("shop_id", shopId)
|
|
||||||
.eq("type", 3)
|
|
||||||
.eq("is_delete", 0)
|
|
||||||
.orderByAsc("id");
|
|
||||||
if (artistId != null && artistId > 0) {
|
|
||||||
wrapper.eq("id", artistId);
|
|
||||||
}
|
|
||||||
List<UserDO> artists = userMapper.selectList(wrapper);
|
|
||||||
if (artists == null || artists.isEmpty()) {
|
|
||||||
return List.of();
|
|
||||||
}
|
|
||||||
Set<Long> artistIds = artists.stream().map(UserDO::getId).collect(Collectors.toCollection(HashSet::new));
|
|
||||||
Map<Long, NailArtistInfoDO> infoMap = loadArtistInfo(artistIds);
|
|
||||||
List<PlanningArtistVO> result = new ArrayList<>();
|
|
||||||
for (int i = 0; i < artists.size(); i++) {
|
|
||||||
UserDO user = artists.get(i);
|
|
||||||
NailArtistInfoDO info = infoMap.get(user.getId());
|
|
||||||
PlanningArtistVO vo = new PlanningArtistVO();
|
|
||||||
vo.setId(user.getId());
|
|
||||||
vo.setName(firstNonBlank(user.getNickname(), user.getAccount(), "美甲师" + (i + 1)));
|
|
||||||
vo.setShortName(PlanningCalendarSupport.shortName(vo.getName()));
|
|
||||||
vo.setPhone(firstNonBlank(user.getContactPhone(), user.getPhone(), ""));
|
|
||||||
vo.setAvatar(user.getAvatar());
|
|
||||||
vo.setColor(colorForArtist(user.getId(), i));
|
|
||||||
vo.setStatus(info == null || info.getStatus() == null ? user.getStatus() : info.getStatus());
|
|
||||||
vo.setStatusText(Integer.valueOf(0).equals(vo.getStatus()) ? "休息" : "可预约");
|
|
||||||
vo.setWorkStartTime(info == null || info.getWorkStartTime() == null ? null : info.getWorkStartTime().toString());
|
|
||||||
vo.setWorkEndTime(info == null || info.getWorkEndTime() == null ? null : info.getWorkEndTime().toString());
|
|
||||||
vo.setRangeCount(0);
|
|
||||||
result.add(vo);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<Long, NailArtistInfoDO> loadArtistInfo(Set<Long> artistIds) {
|
|
||||||
if (artistIds == null || artistIds.isEmpty()) {
|
|
||||||
return Map.of();
|
|
||||||
}
|
|
||||||
QueryWrapper<NailArtistInfoDO> wrapper = new QueryWrapper<>();
|
|
||||||
wrapper.in("user_id", artistIds).eq("is_delete", 0);
|
|
||||||
return nailArtistInfoMapper.selectList(wrapper).stream()
|
|
||||||
.collect(Collectors.toMap(NailArtistInfoDO::getUserId, Function.identity(), (a, b) -> a));
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ArtistScheduleDO> listSchedules(Long shopId, LocalDate start, LocalDate end, Long artistId) {
|
|
||||||
QueryWrapper<ArtistScheduleDO> wrapper = new QueryWrapper<>();
|
|
||||||
wrapper.eq("shop_id", shopId)
|
|
||||||
.between("work_date", start, end)
|
|
||||||
.eq("is_delete", 0)
|
|
||||||
.orderByAsc("work_date")
|
|
||||||
.orderByAsc("start_time");
|
|
||||||
if (artistId != null && artistId > 0) {
|
|
||||||
wrapper.eq("artist_id", artistId);
|
|
||||||
}
|
|
||||||
return artistScheduleMapper.selectList(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private PlanningScheduleVO toScheduleVO(ArtistScheduleDO schedule, List<PlanningArtistVO> artists) {
|
|
||||||
Map<Long, String> artistNames = artists.stream()
|
|
||||||
.collect(Collectors.toMap(PlanningArtistVO::getId, PlanningArtistVO::getName, (a, b) -> a));
|
|
||||||
PlanningScheduleVO vo = new PlanningScheduleVO();
|
|
||||||
vo.setId(schedule.getId());
|
|
||||||
vo.setArtistId(schedule.getArtistId());
|
|
||||||
vo.setArtistName(artistNames.get(schedule.getArtistId()));
|
|
||||||
vo.setDate(schedule.getWorkDate() == null ? null : schedule.getWorkDate().toString());
|
|
||||||
vo.setStartTime(schedule.getStartTime() == null ? null : schedule.getStartTime().toString());
|
|
||||||
vo.setEndTime(schedule.getEndTime() == null ? null : schedule.getEndTime().toString());
|
|
||||||
vo.setCapacity(schedule.getCapacity());
|
|
||||||
vo.setStatus(schedule.getStatus());
|
|
||||||
vo.setStatusText(Integer.valueOf(1).equals(schedule.getStatus()) ? "可预约" : "请假");
|
|
||||||
vo.setRemark(schedule.getRemark());
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<PlanningAppointmentVO> listAppointments(Long shopId, LocalDateTime rangeStart, LocalDateTime rangeEnd,
|
|
||||||
Long artistId, List<PlanningArtistVO> artists) {
|
|
||||||
QueryWrapper<AppointmentReservationDO> reservationWrapper = new QueryWrapper<>();
|
|
||||||
reservationWrapper.eq("shop_id", shopId)
|
|
||||||
.eq("is_delete", 0)
|
|
||||||
.in("status", ACTIVE_RESERVATION_STATUS)
|
|
||||||
.lt("appointment_start_time", rangeEnd)
|
|
||||||
.gt("appointment_end_time", rangeStart)
|
|
||||||
.orderByAsc("appointment_start_time");
|
|
||||||
if (artistId != null && artistId > 0) {
|
|
||||||
reservationWrapper.eq("artist_id", artistId);
|
|
||||||
}
|
|
||||||
List<AppointmentReservationDO> reservations = appointmentReservationMapper.selectList(reservationWrapper);
|
|
||||||
|
|
||||||
QueryWrapper<OrderItemDO> itemWrapper = new QueryWrapper<>();
|
|
||||||
itemWrapper.eq("is_delete", 0)
|
|
||||||
.isNotNull("appointment_time")
|
|
||||||
.ge("appointment_time", rangeStart)
|
|
||||||
.lt("appointment_time", rangeEnd)
|
|
||||||
.orderByAsc("appointment_time");
|
|
||||||
if (artistId != null && artistId > 0) {
|
|
||||||
itemWrapper.eq("artist_id", artistId);
|
|
||||||
}
|
|
||||||
List<OrderItemDO> fallbackItems = orderItemMapper.selectList(itemWrapper);
|
|
||||||
|
|
||||||
return buildAppointmentList(shopId, reservations, fallbackItems, artists);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<PlanningAppointmentVO> buildAppointmentList(Long shopId, List<AppointmentReservationDO> reservations,
|
|
||||||
List<OrderItemDO> fallbackItems, List<PlanningArtistVO> artists) {
|
|
||||||
Set<Long> itemIds = new HashSet<>();
|
|
||||||
Set<Long> orderIds = new HashSet<>();
|
|
||||||
for (AppointmentReservationDO reservation : safeList(reservations)) {
|
|
||||||
if (reservation.getOrderItemId() != null) {
|
|
||||||
itemIds.add(reservation.getOrderItemId());
|
|
||||||
}
|
|
||||||
if (reservation.getOrderId() != null) {
|
|
||||||
orderIds.add(reservation.getOrderId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (OrderItemDO item : safeList(fallbackItems)) {
|
|
||||||
if (item.getId() != null) {
|
|
||||||
itemIds.add(item.getId());
|
|
||||||
}
|
|
||||||
if (item.getOrderId() != null) {
|
|
||||||
orderIds.add(item.getOrderId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<Long, OrderItemDO> itemMap = loadOrderItems(itemIds);
|
|
||||||
Map<Long, OrderDO> orderMap = loadOrders(orderIds);
|
|
||||||
Set<Long> productIds = itemMap.values().stream()
|
|
||||||
.map(OrderItemDO::getProductId)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
Set<Long> customerIds = orderMap.values().stream()
|
|
||||||
.map(OrderDO::getUserId)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
Map<Long, ProductDO> productMap = loadProducts(productIds);
|
|
||||||
Map<Long, UserDO> customerMap = loadUsers(customerIds);
|
|
||||||
Map<Long, PlanningArtistVO> artistMap = artists.stream()
|
|
||||||
.collect(Collectors.toMap(PlanningArtistVO::getId, Function.identity(), (a, b) -> a));
|
|
||||||
|
|
||||||
List<PlanningAppointmentVO> result = new ArrayList<>();
|
|
||||||
Set<Long> reservationItemIds = new HashSet<>();
|
|
||||||
for (AppointmentReservationDO reservation : safeList(reservations)) {
|
|
||||||
OrderItemDO item = itemMap.get(reservation.getOrderItemId());
|
|
||||||
OrderDO order = orderMap.get(reservation.getOrderId());
|
|
||||||
if (!isVisibleOrder(order, shopId)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ProductDO product = item == null ? null : productMap.get(item.getProductId());
|
|
||||||
UserDO customer = customerMap.get(order.getUserId());
|
|
||||||
result.add(toAppointmentVO(reservation, item, order, product, customer, artistMap));
|
|
||||||
if (reservation.getOrderItemId() != null) {
|
|
||||||
reservationItemIds.add(reservation.getOrderItemId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (OrderItemDO item : safeList(fallbackItems)) {
|
|
||||||
if (item.getId() != null && reservationItemIds.contains(item.getId())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
OrderDO order = orderMap.get(item.getOrderId());
|
|
||||||
if (!isVisibleOrder(order, shopId)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ProductDO product = productMap.get(item.getProductId());
|
|
||||||
UserDO customer = customerMap.get(order.getUserId());
|
|
||||||
result.add(toAppointmentVO(null, item, order, product, customer, artistMap));
|
|
||||||
}
|
|
||||||
result.sort(Comparator.comparing(PlanningAppointmentVO::getStartTime, Comparator.nullsLast(String::compareTo))
|
|
||||||
.thenComparing(PlanningAppointmentVO::getArtistName, Comparator.nullsLast(String::compareTo)));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private PlanningAppointmentVO toAppointmentVO(AppointmentReservationDO reservation, OrderItemDO item, OrderDO order,
|
|
||||||
ProductDO product, UserDO customer, Map<Long, PlanningArtistVO> artistMap) {
|
|
||||||
LocalDateTime start = reservation == null ? null : reservation.getAppointmentStartTime();
|
|
||||||
if (start == null && item != null) {
|
|
||||||
start = item.getAppointmentTime();
|
|
||||||
}
|
|
||||||
int durationMinutes = resolveDurationMinutes(product, null) * Math.max(1, item == null || item.getQuantity() == null ? 1 : item.getQuantity());
|
|
||||||
LocalDateTime end = reservation == null ? null : reservation.getAppointmentEndTime();
|
|
||||||
if (end == null && start != null) {
|
|
||||||
end = start.plusMinutes(durationMinutes);
|
|
||||||
}
|
|
||||||
|
|
||||||
Long artistId = reservation != null && reservation.getArtistId() != null
|
|
||||||
? reservation.getArtistId()
|
|
||||||
: item == null ? null : item.getArtistId();
|
|
||||||
PlanningArtistVO artist = artistId == null ? null : artistMap.get(artistId);
|
|
||||||
|
|
||||||
PlanningAppointmentVO vo = new PlanningAppointmentVO();
|
|
||||||
vo.setOrderId(order == null ? null : order.getId());
|
|
||||||
vo.setOrderNo(order == null ? null : order.getOrderNo());
|
|
||||||
vo.setOrderItemId(item == null ? reservation == null ? null : reservation.getOrderItemId() : item.getId());
|
|
||||||
vo.setCustomerId(customer == null ? order == null ? null : order.getUserId() : customer.getId());
|
|
||||||
vo.setCustomerName(customer == null ? "到店客户" : firstNonBlank(customer.getNickname(), customer.getAccount(), "到店客户"));
|
|
||||||
vo.setCustomerPhone(customer == null ? null : firstNonBlank(customer.getContactPhone(), customer.getPhone(), ""));
|
|
||||||
vo.setProductId(product == null ? item == null ? null : item.getProductId() : product.getId());
|
|
||||||
vo.setProductTitle(reservation != null && hasText(reservation.getProductTitle())
|
|
||||||
? reservation.getProductTitle()
|
|
||||||
: product == null ? "预约作品" : product.getTitle());
|
|
||||||
vo.setArtistId(artistId);
|
|
||||||
vo.setArtistName(artist == null ? "未分配" : artist.getName());
|
|
||||||
vo.setArtistColor(artist == null ? ARTIST_COLORS.get(0) : artist.getColor());
|
|
||||||
vo.setDate(start == null ? null : start.toLocalDate().toString());
|
|
||||||
vo.setStartTime(start == null ? null : DATE_TIME_FORMATTER.format(start));
|
|
||||||
vo.setEndTime(end == null ? null : DATE_TIME_FORMATTER.format(end));
|
|
||||||
vo.setStartMinute(start == null ? null : start.toLocalTime().toSecondOfDay() / 60);
|
|
||||||
vo.setDurationMinutes(start == null || end == null ? durationMinutes : Math.toIntExact(Duration.between(start, end).toMinutes()));
|
|
||||||
vo.setStatus(order == null ? null : order.getStatus());
|
|
||||||
vo.setStatusText(statusText(order == null ? null : order.getStatus()));
|
|
||||||
String occupancyStatus = resolveOccupancyStatus(reservation, order);
|
|
||||||
vo.setOccupancyStatus(occupancyStatus);
|
|
||||||
vo.setCanEdit(canEditAppointment(order, occupancyStatus));
|
|
||||||
vo.setCanCancel(canCancelAppointment(order, occupancyStatus));
|
|
||||||
vo.setConflictReason(resolveAppointmentConflictReason(occupancyStatus));
|
|
||||||
vo.setAmount(order == null ? null : order.getActualAmount());
|
|
||||||
vo.setRemark(order == null ? null : order.getCustomerRemark());
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<PlanningDaySummaryVO> buildDaySummaries(LocalDate start, LocalDate end, List<PlanningArtistVO> artists,
|
|
||||||
List<ArtistScheduleDO> schedules, List<PlanningAppointmentVO> appointments) {
|
|
||||||
Map<String, List<PlanningAppointmentVO>> appointmentsByDate = appointments.stream()
|
|
||||||
.filter(appointment -> appointment.getDate() != null)
|
|
||||||
.collect(Collectors.groupingBy(PlanningAppointmentVO::getDate));
|
|
||||||
Map<String, List<ArtistScheduleDO>> schedulesByDate = schedules.stream()
|
|
||||||
.filter(schedule -> schedule.getWorkDate() != null)
|
|
||||||
.collect(Collectors.groupingBy(schedule -> schedule.getWorkDate().toString()));
|
|
||||||
|
|
||||||
List<PlanningDaySummaryVO> summaries = new ArrayList<>();
|
|
||||||
LocalDate cursor = start;
|
|
||||||
while (!cursor.isAfter(end)) {
|
|
||||||
String date = cursor.toString();
|
|
||||||
List<PlanningAppointmentVO> dayAppointments = appointmentsByDate.getOrDefault(date, List.of());
|
|
||||||
Map<Long, Long> countByArtist = dayAppointments.stream()
|
|
||||||
.filter(appointment -> appointment.getArtistId() != null)
|
|
||||||
.collect(Collectors.groupingBy(PlanningAppointmentVO::getArtistId, Collectors.counting()));
|
|
||||||
List<ArtistScheduleDO> daySchedules = schedulesByDate.getOrDefault(date, List.of());
|
|
||||||
Map<Long, ArtistScheduleDO> scheduleByArtist = daySchedules.stream()
|
|
||||||
.collect(Collectors.toMap(ArtistScheduleDO::getArtistId, Function.identity(), (a, b) -> a));
|
|
||||||
|
|
||||||
List<PlanningArtistCountVO> artistCounts = new ArrayList<>();
|
|
||||||
int workingArtistCount = 0;
|
|
||||||
int fullWorkingArtistCount = 0;
|
|
||||||
for (PlanningArtistVO artist : artists) {
|
|
||||||
int count = countByArtist.getOrDefault(artist.getId(), 0L).intValue();
|
|
||||||
ArtistScheduleDO schedule = scheduleByArtist.get(artist.getId());
|
|
||||||
List<PlanningAppointmentVO> artistAppointments = dayAppointments.stream()
|
|
||||||
.filter(appointment -> Objects.equals(appointment.getArtistId(), artist.getId()))
|
|
||||||
.toList();
|
|
||||||
String artistStatus = resolveArtistDayStatus(artist, schedule, artistAppointments);
|
|
||||||
if (!"rest".equals(artistStatus)) {
|
|
||||||
workingArtistCount++;
|
|
||||||
if ("full".equals(artistStatus)) {
|
|
||||||
fullWorkingArtistCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PlanningArtistCountVO countVO = new PlanningArtistCountVO();
|
|
||||||
countVO.setArtistId(artist.getId());
|
|
||||||
countVO.setArtistName(artist.getName());
|
|
||||||
countVO.setShortName(artist.getShortName());
|
|
||||||
countVO.setColor(artist.getColor());
|
|
||||||
countVO.setCount(count);
|
|
||||||
countVO.setStatus(artistStatus);
|
|
||||||
artistCounts.add(countVO);
|
|
||||||
}
|
|
||||||
int total = dayAppointments.size();
|
|
||||||
boolean hasWorkingSchedule = workingArtistCount > 0;
|
|
||||||
boolean allFull = workingArtistCount > 0 && fullWorkingArtistCount == workingArtistCount;
|
|
||||||
|
|
||||||
PlanningDaySummaryVO summary = new PlanningDaySummaryVO();
|
|
||||||
summary.setDate(date);
|
|
||||||
summary.setTotalCount(total);
|
|
||||||
summary.setArtistCounts(artistCounts);
|
|
||||||
summary.setDayStatus(PlanningCalendarSupport.resolveDayStatus(total, hasWorkingSchedule, allFull));
|
|
||||||
summaries.add(summary);
|
|
||||||
cursor = cursor.plusDays(1);
|
|
||||||
}
|
|
||||||
return summaries;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String resolveArtistDayStatus(PlanningArtistVO artist, ArtistScheduleDO schedule, List<PlanningAppointmentVO> appointments) {
|
|
||||||
if (schedule != null && !Integer.valueOf(1).equals(schedule.getStatus())) {
|
|
||||||
return "rest";
|
|
||||||
}
|
|
||||||
if (schedule == null || Integer.valueOf(0).equals(artist.getStatus())) {
|
|
||||||
return "rest";
|
|
||||||
}
|
|
||||||
if (hasContinuousFreeWindow(schedule, appointments, MONTH_AVAILABLE_MINUTES)) {
|
|
||||||
return appointments.isEmpty() ? "free" : "working";
|
|
||||||
}
|
|
||||||
return "full";
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasContinuousFreeWindow(ArtistScheduleDO schedule, List<PlanningAppointmentVO> appointments, int requiredMinutes) {
|
|
||||||
if (schedule == null || schedule.getStartTime() == null || schedule.getEndTime() == null || requiredMinutes <= 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int startMinute = schedule.getStartTime().toSecondOfDay() / 60;
|
|
||||||
int endMinute = schedule.getEndTime().toSecondOfDay() / 60;
|
|
||||||
if (endMinute - startMinute < requiredMinutes) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int cursor = startMinute;
|
|
||||||
List<TimeRange> ranges = appointments.stream()
|
|
||||||
.map(this::toTimeRange)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.filter(range -> range.endMinute() > startMinute && range.startMinute() < endMinute)
|
|
||||||
.map(range -> new TimeRange(Math.max(range.startMinute(), startMinute), Math.min(range.endMinute(), endMinute)))
|
|
||||||
.sorted(Comparator.comparing(TimeRange::startMinute).thenComparing(TimeRange::endMinute))
|
|
||||||
.toList();
|
|
||||||
for (TimeRange range : ranges) {
|
|
||||||
if (range.startMinute() - cursor >= requiredMinutes) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
cursor = Math.max(cursor, range.endMinute());
|
|
||||||
}
|
|
||||||
return endMinute - cursor >= requiredMinutes;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TimeRange toTimeRange(PlanningAppointmentVO appointment) {
|
|
||||||
if (appointment == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Integer startMinute = appointment.getStartMinute();
|
|
||||||
Integer durationMinutes = appointment.getDurationMinutes();
|
|
||||||
if (startMinute == null || durationMinutes == null || durationMinutes <= 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new TimeRange(startMinute, startMinute + durationMinutes);
|
|
||||||
}
|
|
||||||
|
|
||||||
private record TimeRange(int startMinute, int endMinute) {
|
|
||||||
}
|
|
||||||
|
|
||||||
private ProductDO requireActiveProduct(Long productId, Long shopId) {
|
|
||||||
if (productId == null) {
|
|
||||||
throw new RuntimeException("请选择预约作品");
|
|
||||||
}
|
|
||||||
ProductDO product = productMapper.selectById(productId);
|
|
||||||
if (product == null || Integer.valueOf(1).equals(product.getIsDelete()) || !shopId.equals(product.getShopId())) {
|
|
||||||
throw new RuntimeException("预约作品不存在或不属于当前店铺");
|
|
||||||
}
|
|
||||||
return product;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ProductDO resolveAppointmentProduct(PlanningAppointmentCreateDTO dto, Long shopId) {
|
|
||||||
if (dto.getProductId() != null) {
|
|
||||||
return requireActiveProduct(dto.getProductId(), shopId);
|
|
||||||
}
|
|
||||||
return createManualAppointmentProduct(dto, shopId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ProductDO createManualAppointmentProduct(PlanningAppointmentCreateDTO dto, Long shopId) {
|
|
||||||
String title = trimToNull(dto.getManualProductTitle());
|
|
||||||
if (!hasText(title)) {
|
|
||||||
throw new RuntimeException("请选择预约作品或填写手动作品名称");
|
|
||||||
}
|
|
||||||
BigDecimal price = dto.getManualProductPrice();
|
|
||||||
if (price == null || price.compareTo(BigDecimal.ZERO) < 0) {
|
|
||||||
throw new RuntimeException("手动作品价格不能小于0");
|
|
||||||
}
|
|
||||||
int durationMinutes = requireAppointmentDuration(dto.getDurationMinutes());
|
|
||||||
ProductDO product = new ProductDO();
|
|
||||||
product.setShopId(shopId);
|
|
||||||
product.setTitle(title);
|
|
||||||
product.setDescription(trimToNull(dto.getManualProductDescription()));
|
|
||||||
product.setTags(trimToNull(dto.getManualProductTags()));
|
|
||||||
product.setTargetAudience(trimToNull(dto.getManualProductTargetAudience()));
|
|
||||||
product.setPrecautions(trimToNull(dto.getManualProductPrecautions()));
|
|
||||||
product.setImageFileIds(trimToNull(dto.getManualProductImageFileIds()));
|
|
||||||
product.setPrice(price);
|
|
||||||
product.setLikeCount(0);
|
|
||||||
product.setCollectCount(0);
|
|
||||||
product.setApproximateDuration(durationMinutes + "分钟");
|
|
||||||
product.setBookableArtists(dto.getArtistId() == null ? null : String.valueOf(dto.getArtistId()));
|
|
||||||
product.setFrontVisible(0);
|
|
||||||
product.setSourceType(PRODUCT_SOURCE_TYPE_MANAGER_APPOINTMENT);
|
|
||||||
product.setIsDelete(0);
|
|
||||||
productMapper.insert(product);
|
|
||||||
return product;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int requireAppointmentDuration(Integer durationMinutes) {
|
|
||||||
if (durationMinutes == null || durationMinutes <= 0) {
|
|
||||||
throw new RuntimeException("预约时长不能为空且必须大于0分钟");
|
|
||||||
}
|
|
||||||
return durationMinutes;
|
|
||||||
}
|
|
||||||
|
|
||||||
private UserDO requireActiveArtist(Long artistId, Long shopId) {
|
|
||||||
if (artistId == null) {
|
|
||||||
throw new RuntimeException("请选择美甲师");
|
|
||||||
}
|
|
||||||
UserDO artist = userMapper.selectById(artistId);
|
|
||||||
if (artist == null || Integer.valueOf(1).equals(artist.getIsDelete())
|
|
||||||
|| !Integer.valueOf(3).equals(artist.getType()) || !shopId.equals(artist.getShopId())) {
|
|
||||||
throw new RuntimeException("美甲师不存在或不属于当前店铺");
|
|
||||||
}
|
|
||||||
return artist;
|
|
||||||
}
|
|
||||||
|
|
||||||
private UserDO resolveCustomer(Long shopId, PlanningAppointmentCreateDTO dto) {
|
|
||||||
if (dto.getCustomerUserId() != null) {
|
|
||||||
UserDO customer = userMapper.selectById(dto.getCustomerUserId());
|
|
||||||
if (customer == null || Integer.valueOf(1).equals(customer.getIsDelete())) {
|
|
||||||
throw new RuntimeException("客户不存在");
|
|
||||||
}
|
|
||||||
return customer;
|
|
||||||
}
|
|
||||||
if (!hasText(dto.getPhone())) {
|
|
||||||
throw new RuntimeException("客户手机号不能为空");
|
|
||||||
}
|
|
||||||
QueryWrapper<UserDO> wrapper = new QueryWrapper<>();
|
|
||||||
wrapper.eq("is_delete", 0)
|
|
||||||
.and(query -> query.eq("phone", dto.getPhone()).or().eq("contact_phone", dto.getPhone()))
|
|
||||||
.last("LIMIT 1");
|
|
||||||
UserDO existing = userMapper.selectOne(wrapper);
|
|
||||||
if (existing != null) {
|
|
||||||
return existing;
|
|
||||||
}
|
|
||||||
UserDO customer = new UserDO();
|
|
||||||
customer.setShopId(shopId);
|
|
||||||
customer.setNickname(firstNonBlank(dto.getCustomerName(), dto.getPhone()));
|
|
||||||
customer.setPhone(dto.getPhone());
|
|
||||||
customer.setContactPhone(dto.getPhone());
|
|
||||||
customer.setAccount(dto.getPhone());
|
|
||||||
customer.setPassword(ENCODED_UNSET_PASSWORD);
|
|
||||||
customer.setType(0);
|
|
||||||
customer.setStatus(1);
|
|
||||||
customer.setIsDelete(0);
|
|
||||||
userMapper.insert(customer);
|
|
||||||
return customer;
|
|
||||||
}
|
|
||||||
|
|
||||||
private OrderDO requireAccessibleOrder(UserDO currentUser, Long orderId) {
|
|
||||||
OrderDO order = orderMapper.selectById(orderId);
|
|
||||||
if (order == null || Integer.valueOf(1).equals(order.getIsDelete())) {
|
|
||||||
throw new RuntimeException("订单不存在");
|
|
||||||
}
|
|
||||||
adminScopeHelper.ensureShopAccessible(currentUser, order.getShopId(), "无权访问其他店铺预约");
|
|
||||||
return order;
|
|
||||||
}
|
|
||||||
|
|
||||||
private AppointmentReservationDO findActiveReservation(Long orderItemId) {
|
|
||||||
QueryWrapper<AppointmentReservationDO> wrapper = new QueryWrapper<>();
|
|
||||||
wrapper.eq("order_item_id", orderItemId)
|
|
||||||
.eq("is_delete", 0)
|
|
||||||
.in("status", ACTIVE_RESERVATION_STATUS)
|
|
||||||
.orderByDesc("id")
|
|
||||||
.last("LIMIT 1");
|
|
||||||
return appointmentReservationMapper.selectOne(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ensureWithinBusinessHours(Long shopId, LocalDateTime startTime, LocalDateTime endTime) {
|
|
||||||
ShopDO shop = shopMapper.selectById(shopId);
|
|
||||||
PlanningCalendarSupport.BusinessHours hours = PlanningCalendarSupport.parseBusinessHours(shop == null ? null : shop.getBusinessHours());
|
|
||||||
LocalTime start = startTime.toLocalTime();
|
|
||||||
LocalTime end = endTime.toLocalTime();
|
|
||||||
if (start.isBefore(hours.start()) || end.isAfter(hours.end()) || !startTime.toLocalDate().equals(endTime.toLocalDate())) {
|
|
||||||
throw new RuntimeException("预约时间超出店铺营业时间");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private LocalDateTime parseAppointmentStart(String appointmentStartTime, String appointmentDate, String appointmentTime) {
|
|
||||||
if (hasText(appointmentStartTime)) {
|
|
||||||
String normalized = appointmentStartTime.trim().replace('T', ' ');
|
|
||||||
if (normalized.length() == 16) {
|
|
||||||
normalized = normalized + ":00";
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return LocalDateTime.parse(normalized, DATE_TIME_FORMATTER);
|
|
||||||
} catch (DateTimeParseException ignored) {
|
|
||||||
return LocalDateTime.parse(appointmentStartTime.trim());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!hasText(appointmentDate) || !hasText(appointmentTime)) {
|
|
||||||
throw new RuntimeException("请选择预约日期和时间");
|
|
||||||
}
|
|
||||||
LocalDate date = LocalDate.parse(appointmentDate.trim());
|
|
||||||
LocalTime time = LocalTime.parse(appointmentTime.trim().length() == 5 ? appointmentTime.trim() + ":00" : appointmentTime.trim());
|
|
||||||
return LocalDateTime.of(date, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int resolveDurationMinutes(ProductDO product, Integer overrideMinutes) {
|
|
||||||
if (overrideMinutes != null && overrideMinutes > 0) {
|
|
||||||
return overrideMinutes;
|
|
||||||
}
|
|
||||||
return PlanningCalendarSupport.parseDurationMinutes(product == null ? null : product.getApproximateDuration(), DEFAULT_DURATION_MINUTES);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isVisibleOrder(OrderDO order, Long shopId) {
|
|
||||||
return order != null
|
|
||||||
&& !Integer.valueOf(1).equals(order.getIsDelete())
|
|
||||||
&& shopId.equals(order.getShopId())
|
|
||||||
&& !Integer.valueOf(OrderStatus.CANCELLED.getCode()).equals(order.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<Long, OrderItemDO> loadOrderItems(Set<Long> itemIds) {
|
|
||||||
if (itemIds == null || itemIds.isEmpty()) {
|
|
||||||
return Map.of();
|
|
||||||
}
|
|
||||||
return orderItemMapper.selectBatchIds(itemIds).stream()
|
|
||||||
.collect(Collectors.toMap(OrderItemDO::getId, Function.identity(), (a, b) -> a));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<Long, OrderDO> loadOrders(Set<Long> orderIds) {
|
|
||||||
if (orderIds == null || orderIds.isEmpty()) {
|
|
||||||
return Map.of();
|
|
||||||
}
|
|
||||||
return orderMapper.selectBatchIds(orderIds).stream()
|
|
||||||
.collect(Collectors.toMap(OrderDO::getId, Function.identity(), (a, b) -> a));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<Long, ProductDO> loadProducts(Set<Long> productIds) {
|
|
||||||
if (productIds == null || productIds.isEmpty()) {
|
|
||||||
return Map.of();
|
|
||||||
}
|
|
||||||
return productMapper.selectBatchIds(productIds).stream()
|
|
||||||
.collect(Collectors.toMap(ProductDO::getId, Function.identity(), (a, b) -> a));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<Long, UserDO> loadUsers(Set<Long> userIds) {
|
|
||||||
if (userIds == null || userIds.isEmpty()) {
|
|
||||||
return Map.of();
|
|
||||||
}
|
|
||||||
return userMapper.selectBatchIds(userIds).stream()
|
|
||||||
.collect(Collectors.toMap(UserDO::getId, Function.identity(), (a, b) -> a));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String colorForArtist(Long artistId, int index) {
|
|
||||||
if (artistId == null) {
|
|
||||||
return ARTIST_COLORS.get(index % ARTIST_COLORS.size());
|
|
||||||
}
|
|
||||||
int colorIndex = Math.abs(artistId.hashCode()) % ARTIST_COLORS.size();
|
|
||||||
return ARTIST_COLORS.get(colorIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String statusText(Integer status) {
|
|
||||||
if (Integer.valueOf(OrderStatus.PENDING_SERVICE.getCode()).equals(status)) {
|
|
||||||
return "已确认";
|
|
||||||
}
|
|
||||||
if (Integer.valueOf(OrderStatus.COMPLETED.getCode()).equals(status)) {
|
|
||||||
return "已完成";
|
|
||||||
}
|
|
||||||
if (Integer.valueOf(OrderStatus.CANCELLED.getCode()).equals(status)) {
|
|
||||||
return "已取消";
|
|
||||||
}
|
|
||||||
if (Integer.valueOf(OrderStatus.PRICE_CONFIRMING.getCode()).equals(status)) {
|
|
||||||
return "待确认";
|
|
||||||
}
|
|
||||||
return "未知";
|
|
||||||
}
|
|
||||||
|
|
||||||
private String resolveOccupancyStatus(AppointmentReservationDO reservation, OrderDO order) {
|
|
||||||
if (reservation != null && hasText(reservation.getStatus())) {
|
|
||||||
return reservation.getStatus();
|
|
||||||
}
|
|
||||||
if (order != null && Integer.valueOf(OrderStatus.PRICE_CONFIRMING.getCode()).equals(order.getStatus())) {
|
|
||||||
return RESERVATION_PENDING_QUOTE;
|
|
||||||
}
|
|
||||||
if (order != null && Integer.valueOf(OrderStatus.PENDING_SERVICE.getCode()).equals(order.getStatus())) {
|
|
||||||
return RESERVATION_CONFIRMED;
|
|
||||||
}
|
|
||||||
if (order != null && Integer.valueOf(OrderStatus.CANCELLED.getCode()).equals(order.getStatus())) {
|
|
||||||
return "CANCELLED";
|
|
||||||
}
|
|
||||||
if (order != null && Integer.valueOf(OrderStatus.COMPLETED.getCode()).equals(order.getStatus())) {
|
|
||||||
return "COMPLETED";
|
|
||||||
}
|
|
||||||
return "UNKNOWN";
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean canEditAppointment(OrderDO order, String occupancyStatus) {
|
|
||||||
return order != null
|
|
||||||
&& (RESERVATION_PENDING_QUOTE.equals(occupancyStatus) || RESERVATION_CONFIRMED.equals(occupancyStatus))
|
|
||||||
&& !Integer.valueOf(OrderStatus.COMPLETED.getCode()).equals(order.getStatus())
|
|
||||||
&& !Integer.valueOf(OrderStatus.CANCELLED.getCode()).equals(order.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean canCancelAppointment(OrderDO order, String occupancyStatus) {
|
|
||||||
return order != null
|
|
||||||
&& (RESERVATION_PENDING_QUOTE.equals(occupancyStatus) || RESERVATION_CONFIRMED.equals(occupancyStatus))
|
|
||||||
&& !Integer.valueOf(OrderStatus.COMPLETED.getCode()).equals(order.getStatus())
|
|
||||||
&& !Integer.valueOf(OrderStatus.CANCELLED.getCode()).equals(order.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
private String resolveAppointmentConflictReason(String occupancyStatus) {
|
|
||||||
if (RESERVATION_PENDING_QUOTE.equals(occupancyStatus)) {
|
|
||||||
return "该时段已有待报价预约占用";
|
|
||||||
}
|
|
||||||
if (RESERVATION_CONFIRMED.equals(occupancyStatus)) {
|
|
||||||
return "该时段已有已确认预约占用";
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> List<T> safeList(List<T> list) {
|
|
||||||
return list == null ? List.of() : list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String firstNonBlank(String... values) {
|
|
||||||
for (String value : values) {
|
|
||||||
if (hasText(value)) {
|
|
||||||
return value.trim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
private String trimToNull(String value) {
|
|
||||||
return hasText(value) ? value.trim() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasText(String value) {
|
|
||||||
return value != null && !value.trim().isEmpty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-83
@@ -1,83 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.planning.support;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public final class PlanningCalendarSupport {
|
|
||||||
|
|
||||||
private static final LocalTime DEFAULT_START = LocalTime.of(10, 0);
|
|
||||||
private static final LocalTime DEFAULT_END = LocalTime.of(22, 0);
|
|
||||||
private static final Pattern NUMBER_PATTERN = Pattern.compile("(\\d+(?:\\.\\d+)?)");
|
|
||||||
|
|
||||||
private PlanningCalendarSupport() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String shortName(String name) {
|
|
||||||
if (name == null || name.trim().isEmpty()) {
|
|
||||||
return "?";
|
|
||||||
}
|
|
||||||
String normalized = name.trim();
|
|
||||||
if (normalized.startsWith("小") && normalized.length() > 1) {
|
|
||||||
return normalized.substring(1, 2);
|
|
||||||
}
|
|
||||||
if (normalized.endsWith("老师") && normalized.length() > 2) {
|
|
||||||
return normalized.substring(0, 1);
|
|
||||||
}
|
|
||||||
return normalized.substring(0, 1).toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BusinessHours parseBusinessHours(String businessHours) {
|
|
||||||
if (businessHours == null || businessHours.trim().isEmpty()) {
|
|
||||||
return new BusinessHours(DEFAULT_START, DEFAULT_END);
|
|
||||||
}
|
|
||||||
String[] parts = businessHours.trim().split("-");
|
|
||||||
if (parts.length != 2) {
|
|
||||||
return new BusinessHours(DEFAULT_START, DEFAULT_END);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
LocalTime start = LocalTime.parse(parts[0].trim());
|
|
||||||
LocalTime end = LocalTime.parse(parts[1].trim());
|
|
||||||
if (!start.isBefore(end)) {
|
|
||||||
return new BusinessHours(DEFAULT_START, DEFAULT_END);
|
|
||||||
}
|
|
||||||
return new BusinessHours(start, end);
|
|
||||||
} catch (RuntimeException ignored) {
|
|
||||||
return new BusinessHours(DEFAULT_START, DEFAULT_END);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int parseDurationMinutes(String durationText, int defaultMinutes) {
|
|
||||||
if (durationText == null || durationText.trim().isEmpty()) {
|
|
||||||
return defaultMinutes;
|
|
||||||
}
|
|
||||||
Matcher matcher = NUMBER_PATTERN.matcher(durationText.trim());
|
|
||||||
if (!matcher.find()) {
|
|
||||||
return defaultMinutes;
|
|
||||||
}
|
|
||||||
BigDecimal amount = new BigDecimal(matcher.group(1));
|
|
||||||
if (durationText.contains("小时") || durationText.toLowerCase().contains("hour")) {
|
|
||||||
amount = amount.multiply(BigDecimal.valueOf(60));
|
|
||||||
}
|
|
||||||
int minutes = amount.setScale(0, RoundingMode.HALF_UP).intValue();
|
|
||||||
return minutes > 0 ? minutes : defaultMinutes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String resolveDayStatus(int totalCount, boolean hasWorkingSchedule, boolean allWorkingArtistsBusy) {
|
|
||||||
if (!hasWorkingSchedule) {
|
|
||||||
return "rest";
|
|
||||||
}
|
|
||||||
if (allWorkingArtistsBusy) {
|
|
||||||
return "full";
|
|
||||||
}
|
|
||||||
if (totalCount <= 0) {
|
|
||||||
return "free";
|
|
||||||
}
|
|
||||||
return "working";
|
|
||||||
}
|
|
||||||
|
|
||||||
public record BusinessHours(LocalTime start, LocalTime end) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-33
@@ -1,33 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.planning.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class PlanningAppointmentVO {
|
|
||||||
private Long orderId;
|
|
||||||
private String orderNo;
|
|
||||||
private Long orderItemId;
|
|
||||||
private Long customerId;
|
|
||||||
private String customerName;
|
|
||||||
private String customerPhone;
|
|
||||||
private Long productId;
|
|
||||||
private String productTitle;
|
|
||||||
private Long artistId;
|
|
||||||
private String artistName;
|
|
||||||
private String artistColor;
|
|
||||||
private String date;
|
|
||||||
private String startTime;
|
|
||||||
private String endTime;
|
|
||||||
private Integer startMinute;
|
|
||||||
private Integer durationMinutes;
|
|
||||||
private Integer status;
|
|
||||||
private String statusText;
|
|
||||||
private String occupancyStatus;
|
|
||||||
private Boolean canEdit;
|
|
||||||
private Boolean canCancel;
|
|
||||||
private String conflictReason;
|
|
||||||
private BigDecimal amount;
|
|
||||||
private String remark;
|
|
||||||
}
|
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.planning.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class PlanningArtistCountVO {
|
|
||||||
private Long artistId;
|
|
||||||
private String artistName;
|
|
||||||
private String shortName;
|
|
||||||
private String color;
|
|
||||||
private Integer count;
|
|
||||||
private String status;
|
|
||||||
}
|
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.planning.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class PlanningArtistVO {
|
|
||||||
private Long id;
|
|
||||||
private String name;
|
|
||||||
private String shortName;
|
|
||||||
private String phone;
|
|
||||||
private String avatar;
|
|
||||||
private String color;
|
|
||||||
private Integer status;
|
|
||||||
private String statusText;
|
|
||||||
private String workStartTime;
|
|
||||||
private String workEndTime;
|
|
||||||
private Integer rangeCount;
|
|
||||||
}
|
|
||||||
-16
@@ -1,16 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.planning.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class PlanningCalendarVO {
|
|
||||||
private String businessStartTime;
|
|
||||||
private String businessEndTime;
|
|
||||||
private Integer slotMinutes;
|
|
||||||
private List<PlanningArtistVO> artists;
|
|
||||||
private List<PlanningScheduleVO> schedules;
|
|
||||||
private List<PlanningAppointmentVO> appointments;
|
|
||||||
private List<PlanningDaySummaryVO> daySummaries;
|
|
||||||
}
|
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.planning.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class PlanningDaySummaryVO {
|
|
||||||
private String date;
|
|
||||||
private Integer totalCount;
|
|
||||||
private List<PlanningArtistCountVO> artistCounts;
|
|
||||||
private String dayStatus;
|
|
||||||
}
|
|
||||||
-17
@@ -1,17 +0,0 @@
|
|||||||
package com.xiaowang.jayucloud.artlist.core.modules.planning.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class PlanningScheduleVO {
|
|
||||||
private Long id;
|
|
||||||
private Long artistId;
|
|
||||||
private String artistName;
|
|
||||||
private String date;
|
|
||||||
private String startTime;
|
|
||||||
private String endTime;
|
|
||||||
private Integer capacity;
|
|
||||||
private Integer status;
|
|
||||||
private String statusText;
|
|
||||||
private String remark;
|
|
||||||
}
|
|
||||||
-1
@@ -9,7 +9,6 @@ import com.xiaowang.jayucloud.artlist.core.modules.auth.dto.*;
|
|||||||
import com.xiaowang.jayucloud.artlist.core.modules.content.dto.*;
|
import com.xiaowang.jayucloud.artlist.core.modules.content.dto.*;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.file.dto.*;
|
import com.xiaowang.jayucloud.artlist.core.modules.file.dto.*;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.integration.dto.*;
|
import com.xiaowang.jayucloud.artlist.core.modules.integration.dto.*;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.dto.*;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.marketing.dto.*;
|
import com.xiaowang.jayucloud.artlist.core.modules.marketing.dto.*;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.message.dto.*;
|
import com.xiaowang.jayucloud.artlist.core.modules.message.dto.*;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.dto.*;
|
import com.xiaowang.jayucloud.artlist.core.modules.order.dto.*;
|
||||||
|
|||||||
-1
@@ -12,7 +12,6 @@ import com.xiaowang.jayucloud.artlist.core.modules.auth.dto.*;
|
|||||||
import com.xiaowang.jayucloud.artlist.core.modules.content.dto.*;
|
import com.xiaowang.jayucloud.artlist.core.modules.content.dto.*;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.file.dto.*;
|
import com.xiaowang.jayucloud.artlist.core.modules.file.dto.*;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.integration.dto.*;
|
import com.xiaowang.jayucloud.artlist.core.modules.integration.dto.*;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.inventory.dto.*;
|
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.marketing.dto.*;
|
import com.xiaowang.jayucloud.artlist.core.modules.marketing.dto.*;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.message.dto.*;
|
import com.xiaowang.jayucloud.artlist.core.modules.message.dto.*;
|
||||||
import com.xiaowang.jayucloud.artlist.core.modules.order.dto.*;
|
import com.xiaowang.jayucloud.artlist.core.modules.order.dto.*;
|
||||||
|
|||||||
+2
-2
@@ -28,12 +28,12 @@ public class UserSessionService {
|
|||||||
* Purpose: SESSION_KEY_PREFIX supports UserSessionService.java by holding or executing the session key prefix business role.
|
* Purpose: SESSION_KEY_PREFIX supports UserSessionService.java by holding or executing the session key prefix business role.
|
||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||||
*/
|
*/
|
||||||
private static final String SESSION_KEY_PREFIX = "auth:session:";
|
private static final String SESSION_KEY_PREFIX = "artlist:auth:session:";
|
||||||
/**
|
/**
|
||||||
* Purpose: USER_SESSION_SET_PREFIX supports UserSessionService.java by holding or executing the user session set prefix business role.
|
* Purpose: USER_SESSION_SET_PREFIX supports UserSessionService.java by holding or executing the user session set prefix business role.
|
||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||||
*/
|
*/
|
||||||
private static final String USER_SESSION_SET_PREFIX = "auth:user:sessions:";
|
private static final String USER_SESSION_SET_PREFIX = "artlist:auth:user:sessions:";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: stringRedisTemplate supports UserSessionService.java by holding or executing the string redis template business role.
|
* Purpose: stringRedisTemplate supports UserSessionService.java by holding or executing the string redis template business role.
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -158,9 +158,6 @@ export interface GrowthSummaryVO {
|
|||||||
export const paymentApi = {
|
export const paymentApi = {
|
||||||
prepareOrderPayment: async (orderId: IdType): Promise<PaymentOrderVO> => {
|
prepareOrderPayment: async (orderId: IdType): Promise<PaymentOrderVO> => {
|
||||||
return await api.post<PaymentOrderVO>(`/payment/order/${orderId}/prepare`) as unknown as PaymentOrderVO
|
return await api.post<PaymentOrderVO>(`/payment/order/${orderId}/prepare`) as unknown as PaymentOrderVO
|
||||||
},
|
|
||||||
mockSuccess: async (orderId: IdType): Promise<PaymentOrderVO> => {
|
|
||||||
return await api.post<PaymentOrderVO>(`/payment/order/${orderId}/mock-success`) as unknown as PaymentOrderVO
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ const isQuoteConfirming = computed(() => isQuoteStatus(order.value?.status))
|
|||||||
const statusClass = (status?: number) => isQuoteStatus(status) ? 'quote' : status === 2 ? 'done' : status === 3 ? 'cancelled' : 'pending'
|
const statusClass = (status?: number) => isQuoteStatus(status) ? 'quote' : status === 2 ? 'done' : status === 3 ? 'cancelled' : 'pending'
|
||||||
const isOrderPaid = (target: any) => String(target?.paymentStatus || '').toUpperCase() === 'PAID'
|
const isOrderPaid = (target: any) => String(target?.paymentStatus || '').toUpperCase() === 'PAID'
|
||||||
const canPreparePayment = computed(() => !isQuoteConfirming.value && Number(order.value?.status) === 1 && !isOrderPaid(order.value))
|
const canPreparePayment = computed(() => !isQuoteConfirming.value && Number(order.value?.status) === 1 && !isOrderPaid(order.value))
|
||||||
const canMockPay = computed(() => !isQuoteConfirming.value && Number(order.value?.status) === 1 && String(order.value?.paymentStatus || '').toUpperCase() === 'PAYING')
|
|
||||||
const canApplyAfterSale = computed(() => !isQuoteConfirming.value && (Number(order.value?.status) === 2 || isOrderPaid(order.value)))
|
const canApplyAfterSale = computed(() => !isQuoteConfirming.value && (Number(order.value?.status) === 2 || isOrderPaid(order.value)))
|
||||||
|
|
||||||
const timeline = computed(() => {
|
const timeline = computed(() => {
|
||||||
@@ -206,15 +205,6 @@ const preparePayment = async () => {
|
|||||||
message.success('支付单已准备')
|
message.success('支付单已准备')
|
||||||
}
|
}
|
||||||
|
|
||||||
const mockPay = async () => {
|
|
||||||
if (!order.value?.id) return
|
|
||||||
await runWithGlobalLoading(async () => {
|
|
||||||
await paymentApi.mockSuccess(order.value.id)
|
|
||||||
await loadOrder()
|
|
||||||
})
|
|
||||||
message.success('模拟支付成功')
|
|
||||||
}
|
|
||||||
|
|
||||||
const cancelOrder = () => {
|
const cancelOrder = () => {
|
||||||
if (!order.value?.id) return
|
if (!order.value?.id) return
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
@@ -358,7 +348,6 @@ onMounted(loadOrder)
|
|||||||
|
|
||||||
<section class="action-bar">
|
<section class="action-bar">
|
||||||
<a-button v-if="canPreparePayment" @click="preparePayment">准备支付</a-button>
|
<a-button v-if="canPreparePayment" @click="preparePayment">准备支付</a-button>
|
||||||
<a-button v-if="canMockPay" type="primary" @click="mockPay">模拟支付</a-button>
|
|
||||||
<a-button v-if="canApplyAfterSale" @click="router.push({ path: '/after-sale/apply', query: { orderId } })">申请售后</a-button>
|
<a-button v-if="canApplyAfterSale" @click="router.push({ path: '/after-sale/apply', query: { orderId } })">申请售后</a-button>
|
||||||
<a-button v-if="order.status === 1" danger @click="cancelOrder">取消订单</a-button>
|
<a-button v-if="order.status === 1" danger @click="cancelOrder">取消订单</a-button>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -201,7 +201,6 @@
|
|||||||
<div class="order-card__actions">
|
<div class="order-card__actions">
|
||||||
<button v-if="orderNeedsReview(order)" type="button" class="order-action order-action--primary" @click="openReviewModal(firstPendingReview(order))">去评价</button>
|
<button v-if="orderNeedsReview(order)" type="button" class="order-action order-action--primary" @click="openReviewModal(firstPendingReview(order))">去评价</button>
|
||||||
<button v-if="canPreparePayment(order)" type="button" class="order-action order-action--primary" @click="preparePayment(order)">立即支付</button>
|
<button v-if="canPreparePayment(order)" type="button" class="order-action order-action--primary" @click="preparePayment(order)">立即支付</button>
|
||||||
<button v-if="canMockPay(order)" type="button" class="order-action order-action--primary" @click="mockPay(order)">立即支付</button>
|
|
||||||
<button type="button" class="order-action" @click="router.push(`/orders/${order.id}`)">查看详情</button>
|
<button type="button" class="order-action" @click="router.push(`/orders/${order.id}`)">查看详情</button>
|
||||||
<button v-if="canApplyAfterSale(order)" type="button" class="order-action" @click="openAfterSaleModal(order)">申请售后</button>
|
<button v-if="canApplyAfterSale(order)" type="button" class="order-action" @click="openAfterSaleModal(order)">申请售后</button>
|
||||||
<button v-if="hasRebookableItems(order)" type="button" class="order-action order-action--primary" @click="rebookOrder(order)">复刻同款</button>
|
<button v-if="hasRebookableItems(order)" type="button" class="order-action order-action--primary" @click="rebookOrder(order)">复刻同款</button>
|
||||||
@@ -471,7 +470,6 @@ const orderPaymentStatus = (order: any) => String(order.paymentStatus || order.p
|
|||||||
const isOrderPaid = (order: any) => orderPaymentStatus(order) === 'PAID'
|
const isOrderPaid = (order: any) => orderPaymentStatus(order) === 'PAID'
|
||||||
const orderNeedsPayment = (order: any) => Number(order.status) === 1 && !isOrderPaid(order)
|
const orderNeedsPayment = (order: any) => Number(order.status) === 1 && !isOrderPaid(order)
|
||||||
const canPreparePayment = (order: any) => orderNeedsPayment(order) && orderPaymentStatus(order) !== 'PAYING'
|
const canPreparePayment = (order: any) => orderNeedsPayment(order) && orderPaymentStatus(order) !== 'PAYING'
|
||||||
const canMockPay = (order: any) => Number(order.status) === 1 && orderPaymentStatus(order) === 'PAYING'
|
|
||||||
const canApplyAfterSale = (order: any) => !isQuoteConfirming(order) && (Number(order.status) === 2 || isOrderPaid(order))
|
const canApplyAfterSale = (order: any) => !isQuoteConfirming(order) && (Number(order.status) === 2 || isOrderPaid(order))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -779,18 +777,6 @@ const preparePayment = async (order: any) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mockPay = async (order: any) => {
|
|
||||||
try {
|
|
||||||
await runWithGlobalLoading(async () => {
|
|
||||||
await paymentApi.mockSuccess(order.id)
|
|
||||||
await loadOrders()
|
|
||||||
})
|
|
||||||
message.success('支付成功')
|
|
||||||
} catch (error: any) {
|
|
||||||
message.error(error?.message || '支付失败')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const submitQuoteReply = async (order: any) => {
|
const submitQuoteReply = async (order: any) => {
|
||||||
const key = quoteOrderKey(order)
|
const key = quoteOrderKey(order)
|
||||||
const remark = String(quoteReplyForms[key] || '').trim()
|
const remark = String(quoteReplyForms[key] || '').trim()
|
||||||
|
|||||||
@@ -7,13 +7,5 @@ module.exports = {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: {}
|
data: {}
|
||||||
})
|
})
|
||||||
},
|
|
||||||
|
|
||||||
mockOrderPaymentSuccess(orderId) {
|
|
||||||
return request({
|
|
||||||
url: `/payment/order/${orderId}/mock-success`,
|
|
||||||
method: 'POST',
|
|
||||||
data: {}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ const afterSaleApi = require('./after-sale')
|
|||||||
const growthApi = require('./growth')
|
const growthApi = require('./growth')
|
||||||
|
|
||||||
paymentApi.prepareOrderPayment(12)
|
paymentApi.prepareOrderPayment(12)
|
||||||
paymentApi.mockOrderPaymentSuccess(12)
|
|
||||||
afterSaleApi.applyAfterSale({ orderId: 12, reason: 'need refund' })
|
afterSaleApi.applyAfterSale({ orderId: 12, reason: 'need refund' })
|
||||||
afterSaleApi.getMyAfterSales({ page: 2, size: 5 })
|
afterSaleApi.getMyAfterSales({ page: 2, size: 5 })
|
||||||
growthApi.getGrowthSummary()
|
growthApi.getGrowthSummary()
|
||||||
@@ -32,19 +31,14 @@ assert.deepStrictEqual(calls[0], {
|
|||||||
data: {}
|
data: {}
|
||||||
})
|
})
|
||||||
assert.deepStrictEqual(calls[1], {
|
assert.deepStrictEqual(calls[1], {
|
||||||
url: '/payment/order/12/mock-success',
|
|
||||||
method: 'POST',
|
|
||||||
data: {}
|
|
||||||
})
|
|
||||||
assert.deepStrictEqual(calls[2], {
|
|
||||||
url: '/after-sale/apply',
|
url: '/after-sale/apply',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { orderId: 12, reason: 'need refund' }
|
data: { orderId: 12, reason: 'need refund' }
|
||||||
})
|
})
|
||||||
assert.deepStrictEqual(calls[3], {
|
assert.deepStrictEqual(calls[2], {
|
||||||
url: '/after-sale/my',
|
url: '/after-sale/my',
|
||||||
params: { page: 2, size: 5 }
|
params: { page: 2, size: 5 }
|
||||||
})
|
})
|
||||||
assert.deepStrictEqual(calls[4], {
|
assert.deepStrictEqual(calls[3], {
|
||||||
url: '/growth/summary'
|
url: '/growth/summary'
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
"pages/profile/index",
|
"pages/profile/index",
|
||||||
"pages/auth/index",
|
"pages/auth/index",
|
||||||
"pages/product-detail/index",
|
"pages/product-detail/index",
|
||||||
"pages/artist-profile/index",
|
|
||||||
"pages/shop-detail/index",
|
"pages/shop-detail/index",
|
||||||
"pages/orders/index",
|
"pages/orders/index",
|
||||||
"pages/order-detail/index",
|
"pages/order-detail/index",
|
||||||
@@ -15,8 +14,6 @@
|
|||||||
"pages/after-sale-apply/index",
|
"pages/after-sale-apply/index",
|
||||||
"pages/service-progress/index",
|
"pages/service-progress/index",
|
||||||
"pages/help/index",
|
"pages/help/index",
|
||||||
"pages/artist-orders/index",
|
|
||||||
"pages/artist-calendar/index",
|
|
||||||
"pages/account-settings/index",
|
"pages/account-settings/index",
|
||||||
"pages/password-settings/index",
|
"pages/password-settings/index",
|
||||||
"pages/wishlist/index",
|
"pages/wishlist/index",
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
const orderApi = require('../../api/order')
|
|
||||||
const auth = require('../../utils/auth')
|
|
||||||
const navigation = require('../../utils/navigation')
|
|
||||||
const theme = require('../../utils/theme')
|
|
||||||
const { formatDateTime, formatPrice } = require('../../utils/format')
|
|
||||||
const { runWithLoading } = require('../../utils/loading')
|
|
||||||
|
|
||||||
function safeList(value) {
|
|
||||||
return Array.isArray(value) ? value : []
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatClock(value) {
|
|
||||||
return value ? String(value).replace('T', ' ').slice(11, 16) : '--'
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatAppointment(item) {
|
|
||||||
return {
|
|
||||||
...item,
|
|
||||||
dayText: String(item.appointmentStartTime || '').slice(5, 10),
|
|
||||||
timeText: `${formatClock(item.appointmentStartTime)}-${formatClock(item.appointmentEndTime)}`,
|
|
||||||
amountText: `¥${formatPrice(item.actualAmount || item.totalAmount)}`,
|
|
||||||
dateTimeText: formatDateTime(item.appointmentStartTime)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Page({
|
|
||||||
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
|
|
||||||
loading: false,
|
|
||||||
isLoggedIn: false,
|
|
||||||
appointments: []
|
|
||||||
}),
|
|
||||||
|
|
||||||
onShow() {
|
|
||||||
this.loadAppointments()
|
|
||||||
},
|
|
||||||
|
|
||||||
handleBack() {
|
|
||||||
navigation.goBack('/pages/artist-orders/index')
|
|
||||||
},
|
|
||||||
|
|
||||||
async loadAppointments() {
|
|
||||||
const isLoggedIn = auth.isLoggedIn()
|
|
||||||
this.setData({ isLoggedIn })
|
|
||||||
if (!isLoggedIn) {
|
|
||||||
navigation.openAuth(navigation.getCurrentPageUrl())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.setData({ loading: true })
|
|
||||||
try {
|
|
||||||
const list = safeList(await orderApi.getArtistCalendarRecent(7))
|
|
||||||
this.setData({
|
|
||||||
appointments: list.map(formatAppointment)
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
wx.showToast({ title: error.message || '预约日历加载失败', icon: 'none' })
|
|
||||||
} finally {
|
|
||||||
this.setData({ loading: false })
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
openArtistOrders() {
|
|
||||||
navigation.navigate('/pages/artist-orders/index')
|
|
||||||
},
|
|
||||||
|
|
||||||
async completeOrder(event) {
|
|
||||||
const orderId = event.currentTarget.dataset.orderId
|
|
||||||
if (!orderId) return
|
|
||||||
try {
|
|
||||||
await runWithLoading(() => orderApi.completeArtistOrder(orderId))
|
|
||||||
wx.showToast({ title: '服务已完成', icon: 'none' })
|
|
||||||
await this.loadAppointments()
|
|
||||||
} catch (error) {
|
|
||||||
wx.showToast({ title: error.message || '完成服务失败', icon: 'none' })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"usingComponents": {
|
|
||||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<navigation-bar title="预约日历" showBack="{{true}}" fallbackPath="/pages/artist-orders/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
|
|
||||||
|
|
||||||
<view class="page-shell" style="{{themeVars}}">
|
|
||||||
<view class="page-content">
|
|
||||||
<view class="page-hero">
|
|
||||||
<text class="hero-kicker">未来 7 天</text>
|
|
||||||
<text class="hero-title">{{appointments.length}} 个预约</text>
|
|
||||||
<text class="hero-desc">按时间查看即将服务的客户与项目</text>
|
|
||||||
<view class="hero-action-row">
|
|
||||||
<view class="hero-action secondary" bindtap="openArtistOrders">订单列表</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view wx:if="{{loading}}" class="page-card empty-card">
|
|
||||||
<text class="empty-title">正在加载日历</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view wx:elif="{{appointments.length}}">
|
|
||||||
<view wx:for="{{appointments}}" wx:key="orderItemId" class="page-card appointment-card">
|
|
||||||
<view class="day-box">
|
|
||||||
<text>{{item.dayText}}</text>
|
|
||||||
<text>{{item.timeText}}</text>
|
|
||||||
</view>
|
|
||||||
<view class="appointment-main">
|
|
||||||
<text class="appointment-title">{{item.customerNickname || '客户'}} · {{item.productTitle}}</text>
|
|
||||||
<text class="appointment-line">{{item.orderStatusText}} · {{item.shopName || '门店'}}</text>
|
|
||||||
<text class="appointment-line">{{item.amountText}}</text>
|
|
||||||
<view wx:if="{{item.orderStatus == 1}}" class="ghost-btn" data-order-id="{{item.orderId}}" bindtap="completeOrder">完成服务</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view wx:else class="page-card empty-card">
|
|
||||||
<text class="empty-title">未来 7 天暂无预约</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
.appointment-card {
|
|
||||||
display: flex;
|
|
||||||
gap: 18rpx;
|
|
||||||
margin-top: 22rpx;
|
|
||||||
padding: 24rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.day-box {
|
|
||||||
width: 136rpx;
|
|
||||||
flex: 0 0 auto;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 8rpx;
|
|
||||||
padding: 20rpx 12rpx;
|
|
||||||
border-radius: 24rpx;
|
|
||||||
background: var(--theme-primary-soft);
|
|
||||||
color: var(--theme-primary);
|
|
||||||
text-align: center;
|
|
||||||
font-weight: 800;
|
|
||||||
}
|
|
||||||
|
|
||||||
.appointment-main {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.appointment-title,
|
|
||||||
.appointment-line {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.appointment-title {
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-size: 29rpx;
|
|
||||||
font-weight: 800;
|
|
||||||
line-height: 1.45;
|
|
||||||
}
|
|
||||||
|
|
||||||
.appointment-line {
|
|
||||||
margin-top: 8rpx;
|
|
||||||
color: #504444;
|
|
||||||
font-size: 24rpx;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ghost-btn {
|
|
||||||
margin-top: 16rpx;
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
const orderApi = require('../../api/order')
|
|
||||||
const auth = require('../../utils/auth')
|
|
||||||
const navigation = require('../../utils/navigation')
|
|
||||||
const theme = require('../../utils/theme')
|
|
||||||
const { resolveLegacyImage } = require('../../utils/file')
|
|
||||||
const { formatDateTime, formatPrice, getOrderStatusClass, getOrderStatusText } = require('../../utils/format')
|
|
||||||
const { runWithLoading } = require('../../utils/loading')
|
|
||||||
|
|
||||||
function safeList(value) {
|
|
||||||
return Array.isArray(value) ? value : []
|
|
||||||
}
|
|
||||||
|
|
||||||
async function formatOrder(order) {
|
|
||||||
return {
|
|
||||||
...order,
|
|
||||||
statusText: getOrderStatusText(order),
|
|
||||||
statusClass: getOrderStatusClass(order),
|
|
||||||
amountText: `¥${formatPrice(order && order.actualAmount)}`,
|
|
||||||
items: await Promise.all(safeList(order && order.items).map(async item => ({
|
|
||||||
...item,
|
|
||||||
productImageUrl: await resolveLegacyImage(item.productImage),
|
|
||||||
priceText: `¥${formatPrice(item.price)}`,
|
|
||||||
appointmentText: formatDateTime(item.appointmentTime)
|
|
||||||
})))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Page({
|
|
||||||
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
|
|
||||||
loading: false,
|
|
||||||
isLoggedIn: false,
|
|
||||||
orders: [],
|
|
||||||
focusOrderId: ''
|
|
||||||
}),
|
|
||||||
|
|
||||||
onLoad(options) {
|
|
||||||
this.setData({
|
|
||||||
focusOrderId: (options && options.orderId) || ''
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
onShow() {
|
|
||||||
this.loadOrders()
|
|
||||||
},
|
|
||||||
|
|
||||||
handleBack() {
|
|
||||||
navigation.goBack('/pages/profile/index')
|
|
||||||
},
|
|
||||||
|
|
||||||
async loadOrders() {
|
|
||||||
const isLoggedIn = auth.isLoggedIn()
|
|
||||||
this.setData({ isLoggedIn })
|
|
||||||
if (!isLoggedIn) {
|
|
||||||
navigation.openAuth(navigation.getCurrentPageUrl())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.setData({ loading: true })
|
|
||||||
try {
|
|
||||||
const list = safeList(await orderApi.getArtistOrders())
|
|
||||||
const orders = await Promise.all(list.map(formatOrder))
|
|
||||||
this.setData({ orders })
|
|
||||||
} catch (error) {
|
|
||||||
wx.showToast({ title: error.message || '美甲师订单加载失败', icon: 'none' })
|
|
||||||
} finally {
|
|
||||||
this.setData({ loading: false })
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
openCalendar() {
|
|
||||||
navigation.navigate('/pages/artist-calendar/index')
|
|
||||||
},
|
|
||||||
|
|
||||||
async completeOrder(event) {
|
|
||||||
const orderId = event.currentTarget.dataset.orderId
|
|
||||||
if (!orderId) return
|
|
||||||
const confirmed = await new Promise(resolve => {
|
|
||||||
wx.showModal({
|
|
||||||
title: '完成服务',
|
|
||||||
content: '确认这笔订单已经完成服务吗?',
|
|
||||||
success: res => resolve(Boolean(res.confirm))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
if (!confirmed) return
|
|
||||||
try {
|
|
||||||
await runWithLoading(() => orderApi.completeArtistOrder(orderId))
|
|
||||||
wx.showToast({ title: '服务已完成', icon: 'none' })
|
|
||||||
await this.loadOrders()
|
|
||||||
} catch (error) {
|
|
||||||
wx.showToast({ title: error.message || '完成订单失败', icon: 'none' })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"usingComponents": {
|
|
||||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<navigation-bar title="美甲师订单" showBack="{{true}}" fallbackPath="/pages/profile/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
|
|
||||||
|
|
||||||
<view class="page-shell" style="{{themeVars}}">
|
|
||||||
<view class="page-content">
|
|
||||||
<view class="page-hero">
|
|
||||||
<text class="hero-kicker">服务订单</text>
|
|
||||||
<text class="hero-title">{{orders.length}} 笔相关订单</text>
|
|
||||||
<text class="hero-desc">查看客户预约、项目和服务完成状态</text>
|
|
||||||
<view class="hero-action-row">
|
|
||||||
<view class="hero-action secondary" bindtap="openCalendar">预约日历</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view wx:if="{{loading}}" class="page-card empty-card">
|
|
||||||
<text class="empty-title">正在加载订单</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view wx:elif="{{orders.length}}">
|
|
||||||
<view wx:for="{{orders}}" wx:key="id" class="page-card order-card {{item.id == focusOrderId ? 'focus-target' : ''}}">
|
|
||||||
<view class="order-head">
|
|
||||||
<view>
|
|
||||||
<text class="order-no">{{item.orderNo}}</text>
|
|
||||||
<text class="order-line">{{item.customerNickname || '客户'}} {{item.customerPhoneMasked || ''}}</text>
|
|
||||||
</view>
|
|
||||||
<text class="chip">{{item.statusText}}</text>
|
|
||||||
</view>
|
|
||||||
<view wx:for="{{item.items}}" wx:key="id" wx:for-item="orderItem" class="item-row">
|
|
||||||
<image class="item-thumb" src="{{orderItem.productImageUrl}}" mode="aspectFill"></image>
|
|
||||||
<view class="item-main">
|
|
||||||
<text class="item-title">{{orderItem.productTitle}}</text>
|
|
||||||
<text class="item-line">{{orderItem.priceText}} x {{orderItem.quantity}}</text>
|
|
||||||
<text wx:if="{{orderItem.appointmentText}}" class="item-line">预约:{{orderItem.appointmentText}}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="order-foot">
|
|
||||||
<text class="order-amount">{{item.amountText}}</text>
|
|
||||||
<view wx:if="{{item.status == 1}}" class="ghost-btn" data-order-id="{{item.id}}" bindtap="completeOrder">完成服务</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view wx:else class="page-card empty-card">
|
|
||||||
<text class="empty-title">暂无相关订单</text>
|
|
||||||
<text class="empty-desc">有客户预约你服务的项目后会出现在这里</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
.order-card {
|
|
||||||
margin-top: 22rpx;
|
|
||||||
padding: 26rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.order-card.focus-target {
|
|
||||||
border-color: var(--theme-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.order-head,
|
|
||||||
.order-foot {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 18rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.order-no,
|
|
||||||
.order-line,
|
|
||||||
.order-amount {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.order-no {
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-size: 28rpx;
|
|
||||||
font-weight: 800;
|
|
||||||
}
|
|
||||||
|
|
||||||
.order-line {
|
|
||||||
margin-top: 8rpx;
|
|
||||||
color: #504444;
|
|
||||||
font-size: 24rpx;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.item-row {
|
|
||||||
display: flex;
|
|
||||||
gap: 18rpx;
|
|
||||||
margin-top: 22rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.item-thumb {
|
|
||||||
width: 116rpx;
|
|
||||||
height: 116rpx;
|
|
||||||
border-radius: 22rpx;
|
|
||||||
background: var(--theme-primary-soft);
|
|
||||||
}
|
|
||||||
|
|
||||||
.item-main {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.item-title {
|
|
||||||
display: block;
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-size: 28rpx;
|
|
||||||
font-weight: 800;
|
|
||||||
}
|
|
||||||
|
|
||||||
.order-foot {
|
|
||||||
margin-top: 24rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.order-amount {
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-size: 28rpx;
|
|
||||||
font-weight: 800;
|
|
||||||
}
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
const nailArtistApi = require('../../api/nail-artist')
|
|
||||||
const navigation = require('../../utils/navigation')
|
|
||||||
const { DEFAULT_PRODUCT_IMAGE } = require('../../utils/config')
|
|
||||||
|
|
||||||
function formatPrice(price) {
|
|
||||||
const value = Number(price || 0)
|
|
||||||
return value > 0 ? `¥${value.toFixed(2)}` : '到店确认'
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatDateTime(value) {
|
|
||||||
if (!value) {
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
return String(value).replace('T', ' ').slice(0, 16)
|
|
||||||
}
|
|
||||||
|
|
||||||
Page({
|
|
||||||
data: {
|
|
||||||
loading: true,
|
|
||||||
loadError: '',
|
|
||||||
artistId: '',
|
|
||||||
profile: null,
|
|
||||||
works: [],
|
|
||||||
reviews: [],
|
|
||||||
availability: [],
|
|
||||||
heroImage: DEFAULT_PRODUCT_IMAGE,
|
|
||||||
artistName: '美甲师',
|
|
||||||
artistDesc: '专注细节与稳定出品',
|
|
||||||
shopName: '门店待确认',
|
|
||||||
styleTags: [],
|
|
||||||
ratingText: '0.0',
|
|
||||||
serviceCountText: '0',
|
|
||||||
workTimeText: '到店确认'
|
|
||||||
},
|
|
||||||
|
|
||||||
onLoad(options) {
|
|
||||||
this.setData({
|
|
||||||
artistId: options && options.id ? options.id : ''
|
|
||||||
})
|
|
||||||
this.loadArtistProfile()
|
|
||||||
},
|
|
||||||
|
|
||||||
async onPullDownRefresh() {
|
|
||||||
await this.loadArtistProfile()
|
|
||||||
wx.stopPullDownRefresh()
|
|
||||||
},
|
|
||||||
|
|
||||||
async loadArtistProfile() {
|
|
||||||
if (!this.data.artistId) {
|
|
||||||
this.setData({
|
|
||||||
loading: false,
|
|
||||||
loadError: '缺少美甲师信息'
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setData({
|
|
||||||
loading: true,
|
|
||||||
loadError: ''
|
|
||||||
})
|
|
||||||
|
|
||||||
try {
|
|
||||||
const [profile, availability, reviews] = await Promise.all([
|
|
||||||
nailArtistApi.getPublicProfile(this.data.artistId),
|
|
||||||
nailArtistApi.getAvailability(this.data.artistId),
|
|
||||||
nailArtistApi.listReviews(this.data.artistId)
|
|
||||||
])
|
|
||||||
const works = (profile.works || []).map(work => ({
|
|
||||||
...work,
|
|
||||||
title: work.title || '美甲作品',
|
|
||||||
coverImageUrl: work.coverImageUrl || DEFAULT_PRODUCT_IMAGE,
|
|
||||||
priceText: formatPrice(work.price)
|
|
||||||
}))
|
|
||||||
const formattedReviews = (reviews || profile.reviews || []).map(review => ({
|
|
||||||
...review,
|
|
||||||
customerName: review.customerName || '匿名用户',
|
|
||||||
content: review.content || '这位用户没有填写文字评价',
|
|
||||||
submittedAtText: formatDateTime(review.submittedAt),
|
|
||||||
ratingText: Number(review.rating || 0).toFixed(1)
|
|
||||||
}))
|
|
||||||
const start = profile.workStartTime ? String(profile.workStartTime).slice(0, 5) : ''
|
|
||||||
const end = profile.workEndTime ? String(profile.workEndTime).slice(0, 5) : ''
|
|
||||||
|
|
||||||
this.setData({
|
|
||||||
profile,
|
|
||||||
works,
|
|
||||||
reviews: formattedReviews,
|
|
||||||
availability: availability || profile.availability || [],
|
|
||||||
heroImage: (works.find(work => work.coverImageUrl) || {}).coverImageUrl || DEFAULT_PRODUCT_IMAGE,
|
|
||||||
artistName: profile.artistName || '美甲师',
|
|
||||||
artistDesc: profile.identity || profile.signature || '专注细节与稳定出品',
|
|
||||||
shopName: profile.shopName || '门店待确认',
|
|
||||||
styleTags: (profile.styleTags || []).filter(Boolean),
|
|
||||||
ratingText: Number(profile.rating || 0).toFixed(1),
|
|
||||||
serviceCountText: String(profile.serviceCount || 0),
|
|
||||||
workTimeText: start && end ? `${start}-${end}` : '到店确认'
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
this.setData({
|
|
||||||
loadError: error.message || '美甲师个人页加载失败'
|
|
||||||
})
|
|
||||||
} finally {
|
|
||||||
this.setData({
|
|
||||||
loading: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
handleBack() {
|
|
||||||
navigation.goBack('/pages/home/index')
|
|
||||||
},
|
|
||||||
|
|
||||||
handleRetry() {
|
|
||||||
this.loadArtistProfile()
|
|
||||||
},
|
|
||||||
|
|
||||||
handleOpenShop() {
|
|
||||||
const profile = this.data.profile
|
|
||||||
if (!profile || !profile.shopId) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
wx.navigateTo({
|
|
||||||
url: `/pages/shop-detail/index?id=${profile.shopId}`
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
handleOpenWork(event) {
|
|
||||||
const id = event.currentTarget.dataset.id
|
|
||||||
if (!id) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
wx.navigateTo({
|
|
||||||
url: `/pages/product-detail/index?id=${id}`
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"navigationStyle": "custom",
|
|
||||||
"usingComponents": {}
|
|
||||||
}
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
<view class="artist-page">
|
|
||||||
<view class="page-header">
|
|
||||||
<view class="back-btn" bindtap="handleBack">‹</view>
|
|
||||||
<text class="page-title">{{artistName}}</text>
|
|
||||||
<view class="header-spacer"></view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view wx:if="{{loading}}" class="state-box">
|
|
||||||
<text>加载中...</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view wx:elif="{{loadError}}" class="state-box">
|
|
||||||
<text class="state-title">暂时无法查看个人页</text>
|
|
||||||
<text class="state-desc">{{loadError}}</text>
|
|
||||||
<view class="primary-btn" bindtap="handleRetry">重试</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<scroll-view wx:else scroll-y class="content-scroll">
|
|
||||||
<view class="hero">
|
|
||||||
<image class="hero-image" src="{{heroImage}}" mode="aspectFill"></image>
|
|
||||||
<view class="hero-mask"></view>
|
|
||||||
<view class="artist-card">
|
|
||||||
<image wx:if="{{profile.avatar}}" class="avatar" src="{{profile.avatar}}" mode="aspectFill"></image>
|
|
||||||
<view wx:else class="avatar placeholder">艺</view>
|
|
||||||
<view class="artist-main">
|
|
||||||
<text class="artist-name">{{artistName}}</text>
|
|
||||||
<text class="artist-desc">{{artistDesc}}</text>
|
|
||||||
<view class="shop-link" bindtap="handleOpenShop">{{shopName}}</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="metrics">
|
|
||||||
<view class="metric-item">
|
|
||||||
<text>评分</text>
|
|
||||||
<text class="metric-value">{{ratingText}}</text>
|
|
||||||
</view>
|
|
||||||
<view class="metric-item">
|
|
||||||
<text>服务</text>
|
|
||||||
<text class="metric-value">{{serviceCountText}}</text>
|
|
||||||
</view>
|
|
||||||
<view class="metric-item">
|
|
||||||
<text>工时</text>
|
|
||||||
<text class="metric-value">{{workTimeText}}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="section">
|
|
||||||
<view class="section-head">擅长风格</view>
|
|
||||||
<view class="tag-list" wx:if="{{styleTags.length}}">
|
|
||||||
<text class="tag" wx:for="{{styleTags}}" wx:key="*this">{{item}}</text>
|
|
||||||
</view>
|
|
||||||
<text wx:else class="empty-text">暂未设置风格标签</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="section">
|
|
||||||
<view class="section-head">近期可预约</view>
|
|
||||||
<view class="slot-grid" wx:if="{{availability.length}}">
|
|
||||||
<view class="slot" wx:for="{{availability}}" wx:key="startTime">
|
|
||||||
<text>{{item.dateText}}</text>
|
|
||||||
<text class="slot-time">{{item.timeText}}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<text wx:else class="empty-text">近期暂未放出可预约时间</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="section">
|
|
||||||
<view class="section-head">作品</view>
|
|
||||||
<view class="work-grid" wx:if="{{works.length}}">
|
|
||||||
<view class="work-card" wx:for="{{works}}" wx:key="id" data-id="{{item.id}}" bindtap="handleOpenWork">
|
|
||||||
<image src="{{item.coverImageUrl}}" mode="aspectFill"></image>
|
|
||||||
<text class="work-title">{{item.title}}</text>
|
|
||||||
<text class="work-price">{{item.priceText}}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<text wx:else class="empty-text">作品正在整理中</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="section">
|
|
||||||
<view class="section-head">评价 {{reviews.length}}</view>
|
|
||||||
<view class="review-list" wx:if="{{reviews.length}}">
|
|
||||||
<view class="review-card" wx:for="{{reviews}}" wx:key="id">
|
|
||||||
<view class="review-top">
|
|
||||||
<image wx:if="{{item.customerAvatar}}" class="review-avatar" src="{{item.customerAvatar}}" mode="aspectFill"></image>
|
|
||||||
<view wx:else class="review-avatar placeholder">客</view>
|
|
||||||
<view class="review-meta">
|
|
||||||
<text>{{item.customerName}}</text>
|
|
||||||
<text>{{item.submittedAtText}}</text>
|
|
||||||
</view>
|
|
||||||
<text class="review-score">{{item.ratingText}}</text>
|
|
||||||
</view>
|
|
||||||
<text class="review-content">{{item.content}}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<text wx:else class="empty-text">还没有公开评价</text>
|
|
||||||
</view>
|
|
||||||
</scroll-view>
|
|
||||||
</view>
|
|
||||||
@@ -1,336 +0,0 @@
|
|||||||
.artist-page {
|
|
||||||
min-height: 100vh;
|
|
||||||
background: #f6f7fb;
|
|
||||||
color: #1f2933;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-header {
|
|
||||||
position: sticky;
|
|
||||||
top: 0;
|
|
||||||
z-index: 5;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
height: 96rpx;
|
|
||||||
padding: 0 24rpx;
|
|
||||||
background: rgba(255, 255, 255, 0.95);
|
|
||||||
border-bottom: 1rpx solid #e6e9ef;
|
|
||||||
}
|
|
||||||
|
|
||||||
.back-btn,
|
|
||||||
.header-spacer {
|
|
||||||
width: 64rpx;
|
|
||||||
height: 64rpx;
|
|
||||||
line-height: 58rpx;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 48rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-title {
|
|
||||||
flex: 1;
|
|
||||||
overflow: hidden;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 32rpx;
|
|
||||||
font-weight: 700;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content-scroll {
|
|
||||||
height: calc(100vh - 96rpx);
|
|
||||||
}
|
|
||||||
|
|
||||||
.state-box {
|
|
||||||
display: flex;
|
|
||||||
min-height: 60vh;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 20rpx;
|
|
||||||
padding: 40rpx;
|
|
||||||
color: #65717f;
|
|
||||||
}
|
|
||||||
|
|
||||||
.state-title {
|
|
||||||
color: #1f2933;
|
|
||||||
font-size: 34rpx;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
.state-desc {
|
|
||||||
text-align: center;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.primary-btn {
|
|
||||||
padding: 18rpx 36rpx;
|
|
||||||
color: #fff;
|
|
||||||
background: var(--theme-primary-action);
|
|
||||||
border-radius: 12rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero {
|
|
||||||
position: relative;
|
|
||||||
height: 520rpx;
|
|
||||||
margin: 20rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
background: #222831;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-image,
|
|
||||||
.hero-mask {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-mask {
|
|
||||||
background: linear-gradient(180deg, rgba(10, 14, 20, 0.08), rgba(10, 14, 20, 0.72));
|
|
||||||
}
|
|
||||||
|
|
||||||
.artist-card {
|
|
||||||
position: absolute;
|
|
||||||
right: 28rpx;
|
|
||||||
bottom: 28rpx;
|
|
||||||
left: 28rpx;
|
|
||||||
display: flex;
|
|
||||||
gap: 22rpx;
|
|
||||||
align-items: center;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar {
|
|
||||||
width: 112rpx;
|
|
||||||
height: 112rpx;
|
|
||||||
flex: 0 0 auto;
|
|
||||||
overflow: hidden;
|
|
||||||
border: 3rpx solid rgba(255, 255, 255, 0.8);
|
|
||||||
border-radius: 56rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.placeholder {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
background: #d8dde6;
|
|
||||||
color: #5f6b7a;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
.artist-main {
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.artist-name,
|
|
||||||
.artist-desc,
|
|
||||||
.shop-link {
|
|
||||||
display: block;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.artist-name {
|
|
||||||
font-size: 44rpx;
|
|
||||||
font-weight: 800;
|
|
||||||
}
|
|
||||||
|
|
||||||
.artist-desc {
|
|
||||||
margin-top: 10rpx;
|
|
||||||
color: rgba(255, 255, 255, 0.88);
|
|
||||||
font-size: 26rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.shop-link {
|
|
||||||
max-width: 440rpx;
|
|
||||||
margin-top: 16rpx;
|
|
||||||
padding: 12rpx 18rpx;
|
|
||||||
background: rgba(255, 255, 255, 0.18);
|
|
||||||
border: 1rpx solid rgba(255, 255, 255, 0.28);
|
|
||||||
border-radius: 12rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.metrics {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(3, 1fr);
|
|
||||||
gap: 16rpx;
|
|
||||||
margin: 0 20rpx 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.metric-item {
|
|
||||||
display: flex;
|
|
||||||
min-height: 132rpx;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 10rpx;
|
|
||||||
padding: 20rpx;
|
|
||||||
background: #fff;
|
|
||||||
border: 1rpx solid #e6e9ef;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.metric-item text:first-child {
|
|
||||||
color: #65717f;
|
|
||||||
font-size: 24rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.metric-value {
|
|
||||||
overflow-wrap: anywhere;
|
|
||||||
font-size: 34rpx;
|
|
||||||
font-weight: 800;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section {
|
|
||||||
margin: 20rpx;
|
|
||||||
padding: 28rpx;
|
|
||||||
background: #fff;
|
|
||||||
border: 1rpx solid #e6e9ef;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-head {
|
|
||||||
margin-bottom: 20rpx;
|
|
||||||
font-size: 32rpx;
|
|
||||||
font-weight: 800;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag-list {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 14rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag {
|
|
||||||
padding: 10rpx 18rpx;
|
|
||||||
color: #394554;
|
|
||||||
background: #eef1f5;
|
|
||||||
border-radius: 999rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty-text {
|
|
||||||
color: #7b8794;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.slot-grid,
|
|
||||||
.work-grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
||||||
gap: 16rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.slot {
|
|
||||||
display: flex;
|
|
||||||
min-height: 104rpx;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 8rpx;
|
|
||||||
padding: 18rpx;
|
|
||||||
background: #f6f7fb;
|
|
||||||
border: 1rpx solid #dfe4ea;
|
|
||||||
border-radius: 14rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.slot text:first-child {
|
|
||||||
color: #65717f;
|
|
||||||
font-size: 24rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.slot-time {
|
|
||||||
font-size: 32rpx;
|
|
||||||
font-weight: 800;
|
|
||||||
}
|
|
||||||
|
|
||||||
.work-card {
|
|
||||||
overflow: hidden;
|
|
||||||
background: #fff;
|
|
||||||
border: 1rpx solid #e6e9ef;
|
|
||||||
border-radius: 14rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.work-card image {
|
|
||||||
width: 100%;
|
|
||||||
height: 210rpx;
|
|
||||||
background: #eef1f5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.work-title,
|
|
||||||
.work-price {
|
|
||||||
display: block;
|
|
||||||
overflow: hidden;
|
|
||||||
padding: 0 16rpx;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.work-title {
|
|
||||||
margin-top: 14rpx;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
.work-price {
|
|
||||||
margin: 8rpx 0 16rpx;
|
|
||||||
color: var(--theme-primary-action);
|
|
||||||
font-weight: 800;
|
|
||||||
}
|
|
||||||
|
|
||||||
.review-list {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 18rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.review-card {
|
|
||||||
padding: 22rpx;
|
|
||||||
background: #f8fafc;
|
|
||||||
border: 1rpx solid #e6e9ef;
|
|
||||||
border-radius: 14rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.review-top {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 16rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.review-avatar {
|
|
||||||
width: 72rpx;
|
|
||||||
height: 72rpx;
|
|
||||||
border-radius: 36rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.review-meta {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.review-meta text {
|
|
||||||
display: block;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.review-meta text:last-child {
|
|
||||||
margin-top: 4rpx;
|
|
||||||
color: #7b8794;
|
|
||||||
font-size: 22rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.review-score {
|
|
||||||
color: var(--theme-primary-action);
|
|
||||||
font-weight: 800;
|
|
||||||
}
|
|
||||||
|
|
||||||
.review-content {
|
|
||||||
display: block;
|
|
||||||
margin-top: 18rpx;
|
|
||||||
color: #3f4a56;
|
|
||||||
line-height: 1.7;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
}
|
|
||||||
@@ -862,23 +862,8 @@ Page({
|
|||||||
await runWithLoading(() => paymentApi.prepareOrderPayment(orderId), {
|
await runWithLoading(() => paymentApi.prepareOrderPayment(orderId), {
|
||||||
title: '准备支付'
|
title: '准备支付'
|
||||||
})
|
})
|
||||||
const confirmed = await new Promise(resolve => {
|
|
||||||
wx.showModal({
|
|
||||||
title: '模拟支付',
|
|
||||||
content: `本次需支付 ${order.paymentInfo.amountText},确认模拟支付成功吗?`,
|
|
||||||
confirmText: '确认支付',
|
|
||||||
success: res => resolve(Boolean(res.confirm)),
|
|
||||||
fail: () => resolve(false)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
if (!confirmed) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
await runWithLoading(() => paymentApi.mockOrderPaymentSuccess(orderId), {
|
|
||||||
title: '确认支付'
|
|
||||||
})
|
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
title: '支付已确认',
|
title: '支付单已准备,请完成支付',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
await this.loadOrders()
|
await this.loadOrders()
|
||||||
|
|||||||
@@ -113,14 +113,6 @@ function normalizeActionPath(value) {
|
|||||||
return `/pages/help/index${query}`
|
return `/pages/help/index${query}`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pathOnly === '/artist-orders') {
|
|
||||||
return `/pages/artist-orders/index${query}`
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathOnly === '/artist-calendar') {
|
|
||||||
return `/pages/artist-calendar/index${query}`
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathOnly === '/settings/account') {
|
if (pathOnly === '/settings/account') {
|
||||||
return `/pages/account-settings/index${query}`
|
return `/pages/account-settings/index${query}`
|
||||||
}
|
}
|
||||||
|
|||||||
+19
@@ -3,6 +3,8 @@ package com.xiaowang.jayucloud.salon.core.modules.order.controller.admin;
|
|||||||
import com.xiaowang.jayucloud.salon.core.annotation.RequirePermission;
|
import com.xiaowang.jayucloud.salon.core.annotation.RequirePermission;
|
||||||
import com.xiaowang.jayucloud.salon.core.annotation.OperationGuard;
|
import com.xiaowang.jayucloud.salon.core.annotation.OperationGuard;
|
||||||
import com.xiaowang.jayucloud.salon.core.common.Result;
|
import com.xiaowang.jayucloud.salon.core.common.Result;
|
||||||
|
import com.xiaowang.jayucloud.salon.core.common.BusinessException;
|
||||||
|
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderOfflinePaymentDTO;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderQuoteSubmitDTO;
|
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderQuoteSubmitDTO;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.user.entity.UserDO;
|
import com.xiaowang.jayucloud.salon.core.modules.user.entity.UserDO;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.order.service.OrderService;
|
import com.xiaowang.jayucloud.salon.core.modules.order.service.OrderService;
|
||||||
@@ -160,4 +162,21 @@ public class AdminOrderController {
|
|||||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||||
return Result.success(orderService.confirmShopQuote(id, currentUser.getId(), currentUser.getType()));
|
return Result.success(orderService.confirmShopQuote(id, currentUser.getId(), currentUser.getType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店长登记线下收款。当前仅支持 payMethod=OFFLINE,实收金额必须等于订单应付金额。
|
||||||
|
*/
|
||||||
|
@PostMapping("/{orderId}/offline-payment")
|
||||||
|
@RequirePermission("order:process")
|
||||||
|
@OperationGuard(action = "admin-order-offline-payment", ttlSeconds = 10, message = "收款登记处理中,请勿重复提交")
|
||||||
|
public Result<OrderVO> registerOfflinePayment(HttpServletRequest request,
|
||||||
|
@PathVariable Long orderId,
|
||||||
|
@RequestBody OrderOfflinePaymentDTO dto) {
|
||||||
|
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||||
|
if (Integer.valueOf(3).equals(currentUser.getType())) {
|
||||||
|
throw new BusinessException(403, "美甲师账号不能登记线下收款");
|
||||||
|
}
|
||||||
|
Long scopedShopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
||||||
|
return Result.success(orderService.registerOfflinePayment(orderId, currentUser.getId(), scopedShopId, dto));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package com.xiaowang.jayucloud.salon.core.modules.order.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 线下收款登记入参。
|
||||||
|
* 当前仅支持 payMethod=OFFLINE,paidAmount 必须与订单应付金额一致。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OrderOfflinePaymentDTO {
|
||||||
|
private String payMethod;
|
||||||
|
private BigDecimal paidAmount;
|
||||||
|
private LocalDateTime paidAt;
|
||||||
|
private String paidRemark;
|
||||||
|
}
|
||||||
+3
@@ -56,6 +56,9 @@ public class OrderDO extends BaseEntity {
|
|||||||
private String paymentMethod;
|
private String paymentMethod;
|
||||||
private String paymentOrderNo;
|
private String paymentOrderNo;
|
||||||
private String refundStatus;
|
private String refundStatus;
|
||||||
|
private Long paidBy;
|
||||||
|
private String paidByType;
|
||||||
|
private String paidRemark;
|
||||||
private String customerRemark;
|
private String customerRemark;
|
||||||
private String cancelReason;
|
private String cancelReason;
|
||||||
private String customerNameSnapshot;
|
private String customerNameSnapshot;
|
||||||
|
|||||||
+3
@@ -21,6 +21,9 @@ public interface OrderMapper extends BaseMapper<OrderDO> {
|
|||||||
@Select("SELECT * FROM t_order WHERE order_no = #{orderNo}")
|
@Select("SELECT * FROM t_order WHERE order_no = #{orderNo}")
|
||||||
OrderDO selectByOrderNo(@Param("orderNo") String orderNo);
|
OrderDO selectByOrderNo(@Param("orderNo") String orderNo);
|
||||||
|
|
||||||
|
@Select("SELECT * FROM t_order WHERE id = #{orderId} FOR UPDATE")
|
||||||
|
OrderDO selectByIdForUpdate(@Param("orderId") Long orderId);
|
||||||
|
|
||||||
@Select("SELECT DISTINCT o.* FROM t_order o " +
|
@Select("SELECT DISTINCT o.* FROM t_order o " +
|
||||||
"INNER JOIN t_order_item oi ON o.id = oi.order_id " +
|
"INNER JOIN t_order_item oi ON o.id = oi.order_id " +
|
||||||
"WHERE oi.artist_id = #{artistId} AND o.is_delete = 0 " +
|
"WHERE oi.artist_id = #{artistId} AND o.is_delete = 0 " +
|
||||||
|
|||||||
+6
@@ -4,6 +4,7 @@ import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderDTO;
|
|||||||
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderArtistChangeRejectDTO;
|
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderArtistChangeRejectDTO;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderArtistChangeRequestDTO;
|
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderArtistChangeRequestDTO;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderArtistReviewSubmitDTO;
|
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderArtistReviewSubmitDTO;
|
||||||
|
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderOfflinePaymentDTO;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderQuoteReplyDTO;
|
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderQuoteReplyDTO;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderQuoteSubmitDTO;
|
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderQuoteSubmitDTO;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.artist.vo.ArtistCalendarAppointmentVO;
|
import com.xiaowang.jayucloud.salon.core.modules.artist.vo.ArtistCalendarAppointmentVO;
|
||||||
@@ -130,6 +131,11 @@ public interface OrderService {
|
|||||||
|
|
||||||
OrderVO confirmShopQuote(Long orderId, Long operatorId, Integer operatorType);
|
OrderVO confirmShopQuote(Long orderId, Long operatorId, Integer operatorType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登记线下收款。operatorShopId 为当前操作人的门店作用域,为空表示平台管理员。
|
||||||
|
*/
|
||||||
|
OrderVO registerOfflinePayment(Long orderId, Long operatorId, Long operatorShopId, OrderOfflinePaymentDTO dto);
|
||||||
|
|
||||||
OrderVO replyQuote(Long orderId, Long userId, OrderQuoteReplyDTO dto);
|
OrderVO replyQuote(Long orderId, Long userId, OrderQuoteReplyDTO dto);
|
||||||
|
|
||||||
OrderVO confirmUserQuote(Long orderId, Long userId);
|
OrderVO confirmUserQuote(Long orderId, Long userId);
|
||||||
|
|||||||
+95
-1
@@ -9,6 +9,7 @@ import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderArtistChangeReje
|
|||||||
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderArtistChangeRequestDTO;
|
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderArtistChangeRequestDTO;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderArtistReviewSubmitDTO;
|
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderArtistReviewSubmitDTO;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderItemDTO;
|
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderItemDTO;
|
||||||
|
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderOfflinePaymentDTO;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderQuoteItemDTO;
|
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderQuoteItemDTO;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderQuoteReplyDTO;
|
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderQuoteReplyDTO;
|
||||||
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderQuoteSubmitDTO;
|
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderQuoteSubmitDTO;
|
||||||
@@ -133,6 +134,10 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
*/
|
*/
|
||||||
private static final String COUPON_SOURCE_SYSTEM_VIP = "SYSTEM_VIP";
|
private static final String COUPON_SOURCE_SYSTEM_VIP = "SYSTEM_VIP";
|
||||||
private static final int BOOKING_UNAVAILABLE_CODE = 409;
|
private static final int BOOKING_UNAVAILABLE_CODE = 409;
|
||||||
|
private static final String PAYMENT_STATUS_UNPAID = "UNPAID";
|
||||||
|
private static final String PAYMENT_STATUS_PAID = "PAID";
|
||||||
|
private static final String PAYMENT_METHOD_OFFLINE = "OFFLINE";
|
||||||
|
private static final String PAID_BY_TYPE_SHOP_MANAGER = "SHOP_MANAGER";
|
||||||
private static final String ISSUE_ORDER_ITEM = "ORDER_ITEM";
|
private static final String ISSUE_ORDER_ITEM = "ORDER_ITEM";
|
||||||
private static final String ISSUE_PRODUCT_UNAVAILABLE = "PRODUCT_UNAVAILABLE";
|
private static final String ISSUE_PRODUCT_UNAVAILABLE = "PRODUCT_UNAVAILABLE";
|
||||||
private static final String ISSUE_SHOP_MISMATCH = "SHOP_MISMATCH";
|
private static final String ISSUE_SHOP_MISMATCH = "SHOP_MISMATCH";
|
||||||
@@ -1454,6 +1459,9 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
&& !"HISTORICAL_BACKFILL".equals(order.getOrderSource())) {
|
&& !"HISTORICAL_BACKFILL".equals(order.getOrderSource())) {
|
||||||
throw new RuntimeException("普通预约不能进入服务中状态");
|
throw new RuntimeException("普通预约不能进入服务中状态");
|
||||||
}
|
}
|
||||||
|
if (targetStatus == OrderStatus.COMPLETED) {
|
||||||
|
ensurePaidBeforeCompletion(order);
|
||||||
|
}
|
||||||
if (!Integer.valueOf(OrderStatus.PENDING_SERVICE.getCode()).equals(order.getStatus())
|
if (!Integer.valueOf(OrderStatus.PENDING_SERVICE.getCode()).equals(order.getStatus())
|
||||||
&& !(Integer.valueOf(OrderStatus.IN_SERVICE.getCode()).equals(order.getStatus())
|
&& !(Integer.valueOf(OrderStatus.IN_SERVICE.getCode()).equals(order.getStatus())
|
||||||
&& (status == OrderStatus.COMPLETED.getCode() || status == OrderStatus.CANCELLED.getCode()))
|
&& (status == OrderStatus.COMPLETED.getCode() || status == OrderStatus.CANCELLED.getCode()))
|
||||||
@@ -1534,6 +1542,7 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
*/
|
*/
|
||||||
throw new RuntimeException("当前订单状态不允许完成");
|
throw new RuntimeException("当前订单状态不允许完成");
|
||||||
}
|
}
|
||||||
|
ensurePaidBeforeCompletion(order);
|
||||||
|
|
||||||
List<OrderItemDO> activeItems = orderItemMapper.selectByOrderId(orderId).stream()
|
List<OrderItemDO> activeItems = orderItemMapper.selectByOrderId(orderId).stream()
|
||||||
.filter(item -> !Integer.valueOf(1).equals(item.getIsDelete()))
|
.filter(item -> !Integer.valueOf(1).equals(item.getIsDelete()))
|
||||||
@@ -1808,6 +1817,75 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
return buildOrderVO(orderMapper.selectById(order.getId()));
|
return buildOrderVO(orderMapper.selectById(order.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public OrderVO registerOfflinePayment(Long orderId, Long operatorId, Long operatorShopId, OrderOfflinePaymentDTO dto) {
|
||||||
|
if (orderId == null) {
|
||||||
|
throw new RuntimeException("订单ID不能为空");
|
||||||
|
}
|
||||||
|
if (dto == null) {
|
||||||
|
throw new RuntimeException("收款登记信息不能为空");
|
||||||
|
}
|
||||||
|
String payMethod = dto.getPayMethod() == null ? "" : dto.getPayMethod().trim().toUpperCase();
|
||||||
|
if (!PAYMENT_METHOD_OFFLINE.equals(payMethod)) {
|
||||||
|
throw new RuntimeException("当前仅支持线下收款,payMethod 只能为 OFFLINE");
|
||||||
|
}
|
||||||
|
if (dto.getPaidAmount() == null) {
|
||||||
|
throw new RuntimeException("实收金额不能为空");
|
||||||
|
}
|
||||||
|
if (dto.getPaidAmount().compareTo(BigDecimal.ZERO) < 0) {
|
||||||
|
throw new RuntimeException("实收金额不能小于0");
|
||||||
|
}
|
||||||
|
String paidRemark = trimToNull(dto.getPaidRemark());
|
||||||
|
if (paidRemark != null && paidRemark.length() > 500) {
|
||||||
|
throw new RuntimeException("收款备注不能超过500个字符");
|
||||||
|
}
|
||||||
|
|
||||||
|
OrderDO order = orderMapper.selectByIdForUpdate(orderId);
|
||||||
|
if (order == null || Integer.valueOf(1).equals(order.getIsDelete())) {
|
||||||
|
throw new RuntimeException("订单不存在");
|
||||||
|
}
|
||||||
|
if (operatorShopId != null && !operatorShopId.equals(order.getShopId())) {
|
||||||
|
throw new BusinessException(403, "无权处理其他店铺订单");
|
||||||
|
}
|
||||||
|
if (Integer.valueOf(OrderStatus.CANCELLED.getCode()).equals(order.getStatus())) {
|
||||||
|
throw new RuntimeException("订单已取消,不能登记收款");
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal expectedAmount = order.getPayAmount() == null ? order.getActualAmount() : order.getPayAmount();
|
||||||
|
if (expectedAmount == null) {
|
||||||
|
expectedAmount = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
if (dto.getPaidAmount().compareTo(expectedAmount) != 0) {
|
||||||
|
throw new RuntimeException("实收金额必须等于订单应付金额 "
|
||||||
|
+ expectedAmount.stripTrailingZeros().toPlainString() + " 元");
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalDateTime paidAt = (dto.getPaidAt() == null ? LocalDateTime.now() : dto.getPaidAt()).withNano(0);
|
||||||
|
if (PAYMENT_STATUS_PAID.equals(order.getPaymentStatus())) {
|
||||||
|
boolean sameMethod = PAYMENT_METHOD_OFFLINE.equals(order.getPaymentMethod());
|
||||||
|
boolean sameAmount = order.getPaidAmount() != null && order.getPaidAmount().compareTo(dto.getPaidAmount()) == 0;
|
||||||
|
boolean sameTime = order.getPayTime() != null && order.getPayTime().withNano(0).equals(paidAt);
|
||||||
|
if (sameMethod && sameAmount && sameTime) {
|
||||||
|
return buildOrderVO(order);
|
||||||
|
}
|
||||||
|
throw new RuntimeException("该订单已登记线下收款,金额或收款时间与首次登记不一致,不能重复登记");
|
||||||
|
}
|
||||||
|
if (order.getPaymentStatus() != null && !PAYMENT_STATUS_UNPAID.equals(order.getPaymentStatus())) {
|
||||||
|
throw new RuntimeException("订单当前支付状态为 " + order.getPaymentStatus() + ",不能登记线下收款");
|
||||||
|
}
|
||||||
|
|
||||||
|
order.setPaymentStatus(PAYMENT_STATUS_PAID);
|
||||||
|
order.setPaymentMethod(PAYMENT_METHOD_OFFLINE);
|
||||||
|
order.setPaidAmount(dto.getPaidAmount());
|
||||||
|
order.setPayTime(paidAt);
|
||||||
|
order.setPaidBy(operatorId);
|
||||||
|
order.setPaidByType(PAID_BY_TYPE_SHOP_MANAGER);
|
||||||
|
order.setPaidRemark(paidRemark);
|
||||||
|
orderMapper.updateById(order);
|
||||||
|
return buildOrderVO(order);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public OrderVO replyQuote(Long orderId, Long userId, OrderQuoteReplyDTO dto) {
|
public OrderVO replyQuote(Long orderId, Long userId, OrderQuoteReplyDTO dto) {
|
||||||
@@ -2258,9 +2336,18 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: trimToNull supports OrderServiceImpl.java by holding or executing the trim to null business role.
|
* 完成订单前强制校验收款状态:未收款不得完成,不设任何豁免。
|
||||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* 完成订单前强制校验收款状态:未收款不得完成,不设任何豁免。
|
||||||
|
*/
|
||||||
|
private void ensurePaidBeforeCompletion(OrderDO order) {
|
||||||
|
if (!PAYMENT_STATUS_PAID.equals(order.getPaymentStatus())) {
|
||||||
|
throw new RuntimeException("订单未收款,不能完成;请先登记线下收款");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String trimToNull(String value) {
|
private String trimToNull(String value) {
|
||||||
if (!StringUtils.hasText(value)) {
|
if (!StringUtils.hasText(value)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -3284,6 +3371,13 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
orderVO.setPaymentMethod(order.getPaymentMethod());
|
orderVO.setPaymentMethod(order.getPaymentMethod());
|
||||||
orderVO.setPaymentOrderNo(order.getPaymentOrderNo());
|
orderVO.setPaymentOrderNo(order.getPaymentOrderNo());
|
||||||
orderVO.setRefundStatus(order.getRefundStatus());
|
orderVO.setRefundStatus(order.getRefundStatus());
|
||||||
|
orderVO.setPaidBy(order.getPaidBy());
|
||||||
|
orderVO.setPaidByType(order.getPaidByType());
|
||||||
|
orderVO.setPaidRemark(order.getPaidRemark());
|
||||||
|
if (order.getPaidBy() != null) {
|
||||||
|
UserDO payer = getUserFromCache(order.getPaidBy(), userCache);
|
||||||
|
orderVO.setPaidByName(payer == null ? null : payer.getNickname());
|
||||||
|
}
|
||||||
orderVO.setCustomerRemark(order.getCustomerRemark());
|
orderVO.setCustomerRemark(order.getCustomerRemark());
|
||||||
orderVO.setQuoteStatus(order.getQuoteStatus());
|
orderVO.setQuoteStatus(order.getQuoteStatus());
|
||||||
orderVO.setQuoteStatusText(resolveQuoteStatusText(order.getQuoteStatus(), order.getStatus()));
|
orderVO.setQuoteStatusText(resolveQuoteStatusText(order.getQuoteStatus(), order.getStatus()));
|
||||||
|
|||||||
+4
@@ -64,6 +64,10 @@ public class OrderVO {
|
|||||||
private String paymentMethod;
|
private String paymentMethod;
|
||||||
private String paymentOrderNo;
|
private String paymentOrderNo;
|
||||||
private String refundStatus;
|
private String refundStatus;
|
||||||
|
private Long paidBy;
|
||||||
|
private String paidByName;
|
||||||
|
private String paidByType;
|
||||||
|
private String paidRemark;
|
||||||
private String customerRemark;
|
private String customerRemark;
|
||||||
private String quoteStatus;
|
private String quoteStatus;
|
||||||
private String orderSource;
|
private String orderSource;
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
-- 订单线下收款登记:记录收款人、收款人类型与收款备注
|
||||||
|
-- 说明:pay_time、payment_method、paid_amount、payment_status 已存在,本次不重复新增。
|
||||||
|
|
||||||
|
SET @column_exists = (
|
||||||
|
SELECT COUNT(1) FROM information_schema.columns
|
||||||
|
WHERE table_schema = DATABASE() AND table_name = 't_order' AND column_name = 'paid_by'
|
||||||
|
);
|
||||||
|
SET @migration_sql = IF(
|
||||||
|
@column_exists = 0,
|
||||||
|
'ALTER TABLE t_order ADD COLUMN paid_by BIGINT UNSIGNED NULL COMMENT ''收款登记人用户ID'' AFTER refund_status',
|
||||||
|
'SELECT 1'
|
||||||
|
);
|
||||||
|
PREPARE migration_statement FROM @migration_sql;
|
||||||
|
EXECUTE migration_statement;
|
||||||
|
DEALLOCATE PREPARE migration_statement;
|
||||||
|
|
||||||
|
SET @column_exists = (
|
||||||
|
SELECT COUNT(1) FROM information_schema.columns
|
||||||
|
WHERE table_schema = DATABASE() AND table_name = 't_order' AND column_name = 'paid_by_type'
|
||||||
|
);
|
||||||
|
SET @migration_sql = IF(
|
||||||
|
@column_exists = 0,
|
||||||
|
'ALTER TABLE t_order ADD COLUMN paid_by_type VARCHAR(20) NULL COMMENT ''收款登记人类型,线下收款固定为 SHOP_MANAGER'' AFTER paid_by',
|
||||||
|
'SELECT 1'
|
||||||
|
);
|
||||||
|
PREPARE migration_statement FROM @migration_sql;
|
||||||
|
EXECUTE migration_statement;
|
||||||
|
DEALLOCATE PREPARE migration_statement;
|
||||||
|
|
||||||
|
SET @column_exists = (
|
||||||
|
SELECT COUNT(1) FROM information_schema.columns
|
||||||
|
WHERE table_schema = DATABASE() AND table_name = 't_order' AND column_name = 'paid_remark'
|
||||||
|
);
|
||||||
|
SET @migration_sql = IF(
|
||||||
|
@column_exists = 0,
|
||||||
|
'ALTER TABLE t_order ADD COLUMN paid_remark VARCHAR(500) NULL COMMENT ''收款登记备注'' AFTER paid_by_type',
|
||||||
|
'SELECT 1'
|
||||||
|
);
|
||||||
|
PREPARE migration_statement FROM @migration_sql;
|
||||||
|
EXECUTE migration_statement;
|
||||||
|
DEALLOCATE PREPARE migration_statement;
|
||||||
+111
@@ -0,0 +1,111 @@
|
|||||||
|
package com.xiaowang.jayucloud.salon.core.modules.order.service.impl;
|
||||||
|
|
||||||
|
import com.xiaowang.jayucloud.salon.core.modules.order.dto.OrderOfflinePaymentDTO;
|
||||||
|
import com.xiaowang.jayucloud.salon.core.modules.order.entity.OrderDO;
|
||||||
|
import com.xiaowang.jayucloud.salon.core.modules.order.mapper.OrderMapper;
|
||||||
|
import com.xiaowang.jayucloud.salon.core.modules.order.support.OrderStatus;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockito.InjectMocks;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
class OrderServiceImplOfflinePaymentTest {
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private OrderMapper orderMapper;
|
||||||
|
|
||||||
|
@InjectMocks
|
||||||
|
private OrderServiceImpl service;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsNonOfflinePaymentMethod() {
|
||||||
|
OrderOfflinePaymentDTO dto = offlinePayment(new BigDecimal("100"), LocalDateTime.now());
|
||||||
|
dto.setPayMethod("WECHAT");
|
||||||
|
|
||||||
|
RuntimeException error = assertThrows(RuntimeException.class,
|
||||||
|
() -> service.registerOfflinePayment(1L, 9L, 2L, dto));
|
||||||
|
|
||||||
|
assertEquals("当前仅支持线下收款,payMethod 只能为 OFFLINE", error.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsAmountMismatch() {
|
||||||
|
OrderDO order = order(1L, OrderStatus.PENDING_SERVICE.getCode(), "UNPAID");
|
||||||
|
order.setPayAmount(new BigDecimal("100.00"));
|
||||||
|
when(orderMapper.selectByIdForUpdate(1L)).thenReturn(order);
|
||||||
|
OrderOfflinePaymentDTO dto = offlinePayment(new BigDecimal("90"), LocalDateTime.now());
|
||||||
|
|
||||||
|
RuntimeException error = assertThrows(RuntimeException.class,
|
||||||
|
() -> service.registerOfflinePayment(1L, 9L, 2L, dto));
|
||||||
|
|
||||||
|
assertEquals("实收金额必须等于订单应付金额 100 元", error.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsCancelledOrder() {
|
||||||
|
OrderDO order = order(1L, OrderStatus.CANCELLED.getCode(), "UNPAID");
|
||||||
|
order.setPayAmount(new BigDecimal("100"));
|
||||||
|
when(orderMapper.selectByIdForUpdate(1L)).thenReturn(order);
|
||||||
|
OrderOfflinePaymentDTO dto = offlinePayment(new BigDecimal("100"), LocalDateTime.now());
|
||||||
|
|
||||||
|
RuntimeException error = assertThrows(RuntimeException.class,
|
||||||
|
() -> service.registerOfflinePayment(1L, 9L, 2L, dto));
|
||||||
|
|
||||||
|
assertEquals("订单已取消,不能登记收款", error.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsRepeatedRegistrationWithDifferentTime() {
|
||||||
|
OrderDO order = order(1L, OrderStatus.PENDING_SERVICE.getCode(), "PAID");
|
||||||
|
order.setPayAmount(new BigDecimal("100"));
|
||||||
|
order.setPaymentMethod("OFFLINE");
|
||||||
|
order.setPaidAmount(new BigDecimal("100"));
|
||||||
|
order.setPayTime(LocalDateTime.of(2026, 11, 4, 10, 0, 0));
|
||||||
|
when(orderMapper.selectByIdForUpdate(1L)).thenReturn(order);
|
||||||
|
OrderOfflinePaymentDTO dto = offlinePayment(new BigDecimal("100"), LocalDateTime.of(2026, 11, 4, 11, 0, 0));
|
||||||
|
|
||||||
|
RuntimeException error = assertThrows(RuntimeException.class,
|
||||||
|
() -> service.registerOfflinePayment(1L, 9L, 2L, dto));
|
||||||
|
|
||||||
|
assertEquals("该订单已登记线下收款,金额或收款时间与首次登记不一致,不能重复登记", error.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsCompletingUnpaidOrder() {
|
||||||
|
OrderDO order = order(1L, OrderStatus.PENDING_SERVICE.getCode(), "UNPAID");
|
||||||
|
order.setOrderSource("NORMAL");
|
||||||
|
when(orderMapper.selectById(1L)).thenReturn(order);
|
||||||
|
|
||||||
|
RuntimeException error = assertThrows(RuntimeException.class,
|
||||||
|
() -> service.processOrder(1L, OrderStatus.COMPLETED.getCode()));
|
||||||
|
|
||||||
|
assertEquals("订单未收款,不能完成;请先登记线下收款", error.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
private OrderOfflinePaymentDTO offlinePayment(BigDecimal amount, LocalDateTime paidAt) {
|
||||||
|
OrderOfflinePaymentDTO dto = new OrderOfflinePaymentDTO();
|
||||||
|
dto.setPayMethod("OFFLINE");
|
||||||
|
dto.setPaidAmount(amount);
|
||||||
|
dto.setPaidAt(paidAt);
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
private OrderDO order(Long id, Integer status, String paymentStatus) {
|
||||||
|
OrderDO order = new OrderDO();
|
||||||
|
order.setId(id);
|
||||||
|
order.setShopId(2L);
|
||||||
|
order.setStatus(status);
|
||||||
|
order.setPaymentStatus(paymentStatus);
|
||||||
|
order.setIsDelete(0);
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,151 +1,200 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="system-settings">
|
<div class="system-settings">
|
||||||
<header class="settings-header">
|
<div class="settings-topbar">
|
||||||
<div>
|
<nav class="settings-tabs" role="tablist" aria-label="系统设置">
|
||||||
<span class="settings-eyebrow">SALON ADMIN</span>
|
|
||||||
<h1>系统设置</h1>
|
|
||||||
<p>集中管理后台运行参数、服务接入和当前账号。</p>
|
|
||||||
</div>
|
|
||||||
<span class="settings-health"><i />当前环境设置</span>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div class="settings-layout">
|
|
||||||
<nav class="settings-nav" aria-label="系统设置分类">
|
|
||||||
<span class="settings-nav__label">设置目录</span>
|
|
||||||
<button
|
<button
|
||||||
v-for="item in sections"
|
v-for="item in sections"
|
||||||
:key="item.key"
|
:key="item.key"
|
||||||
type="button"
|
type="button"
|
||||||
:aria-pressed="activeSection === item.key"
|
role="tab"
|
||||||
:class="['settings-nav__item', { 'is-active': activeSection === item.key }]"
|
:aria-selected="activeSection === item.key"
|
||||||
|
:class="['settings-tab', { 'is-active': activeSection === item.key }]"
|
||||||
@click="activeSection = item.key"
|
@click="activeSection = item.key"
|
||||||
>
|
>{{ item.label }}</button>
|
||||||
<span class="settings-nav__icon"><component :is="item.icon" /></span>
|
|
||||||
<span>{{ item.label }}</span>
|
|
||||||
</button>
|
|
||||||
<p class="settings-nav__hint">复杂业务继续在独立页面管理,这里只保留影响后台运行的设置。</p>
|
|
||||||
</nav>
|
</nav>
|
||||||
|
<span class="settings-health"><i />当前环境设置</span>
|
||||||
<main class="settings-pane" :aria-busy="loading">
|
|
||||||
<section v-if="activeSection === 'runtime'" class="settings-section-panel">
|
|
||||||
<div class="pane-head">
|
|
||||||
<div>
|
|
||||||
<h2>运行参数</h2>
|
|
||||||
<p>控制账号创建和店长登录后的默认行为。</p>
|
|
||||||
</div>
|
|
||||||
<span />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="setting-group">
|
<main class="settings-body" :aria-busy="loading">
|
||||||
<div class="setting-group__head setting-group__head--with-action"><strong>账号默认值</strong><span>USER</span><a-button size="small" type="primary" :loading="savingDefaultPassword" @click="saveDefaultPassword">保存密码设置</a-button></div>
|
<aside class="settings-subnav" aria-label="页内分组导航">
|
||||||
<div class="setting-row setting-row--last">
|
<span class="settings-subnav__label">分组导航</span>
|
||||||
<div class="setting-copy">
|
<button
|
||||||
<strong>后台新增用户默认密码</strong>
|
v-for="item in groupNavItems"
|
||||||
<span>新增或重置店长账号时使用,不影响已有账号。</span>
|
:key="item.id"
|
||||||
|
type="button"
|
||||||
|
:class="['settings-subnav__item', { 'is-active': activeGroup === item.id }]"
|
||||||
|
@click="scrollToGroup(item.id)"
|
||||||
|
>
|
||||||
|
<span>{{ item.label }}</span>
|
||||||
|
<em v-if="item.badge">{{ item.badge }}</em>
|
||||||
|
</button>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<div class="settings-content">
|
||||||
|
<div v-if="activeSection === 'runtime'" class="settings-groups">
|
||||||
|
<section id="settings-group-account" class="settings-group">
|
||||||
|
<header class="settings-group__head">
|
||||||
|
<div class="settings-group__head-main">
|
||||||
|
<div class="settings-group__title"><h2>账号与登录</h2></div>
|
||||||
|
<p class="settings-group__desc">控制账号创建和店长登录后的默认行为,三项参数分别独立保存。</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-control setting-control--password">
|
<span class="meta">3 项参数</span>
|
||||||
|
</header>
|
||||||
|
<div class="settings-group__body">
|
||||||
|
<div class="field-grid cols-3">
|
||||||
|
|
||||||
|
<article class="field">
|
||||||
|
<div class="field__head"><span class="field__label">后台新增用户默认密码</span><span class="tag">USER</span></div>
|
||||||
|
<p class="field__desc">新增或重置店长账号时使用,不影响已有账号。</p>
|
||||||
|
<div class="field__control field__control--password">
|
||||||
<a-input-password v-model:value="defaultPasswordForm.configValue" autocomplete="new-password" placeholder="请输入 8-32 位强密码" />
|
<a-input-password v-model:value="defaultPasswordForm.configValue" autocomplete="new-password" placeholder="请输入 8-32 位强密码" />
|
||||||
<span class="control-note">{{ defaultPasswordForm.configValue ? '已填写' : '未设置' }}</span>
|
|
||||||
<a-switch v-model:checked="defaultPasswordEnabled" checked-children="启用" un-checked-children="停用" />
|
<a-switch v-model:checked="defaultPasswordEnabled" checked-children="启用" un-checked-children="停用" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field__foot">
|
||||||
<span :class="['status-pill', { 'is-muted': !defaultPasswordEnabled }]">{{ defaultPasswordEnabled ? '启用' : '停用' }}</span>
|
<span :class="['status-pill', { 'is-muted': !defaultPasswordEnabled }]">{{ defaultPasswordEnabled ? '启用' : '停用' }}</span>
|
||||||
|
<span class="control-note">{{ defaultPasswordForm.configValue ? '已填写' : '未设置' }}</span>
|
||||||
|
<a-button class="field__save" size="small" type="primary" :loading="savingDefaultPassword" @click="saveDefaultPassword">保存密码设置</a-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</article>
|
||||||
|
|
||||||
<div class="setting-group">
|
<article class="field">
|
||||||
<div class="setting-group__head setting-group__head--with-action"><strong>店长登录提醒</strong><span>WORKBENCH</span><a-button size="small" type="primary" :loading="savingReviewNotice" @click="saveReviewNotice">保存提醒设置</a-button></div>
|
<div class="field__head"><span class="field__label">店长员工审核提醒</span><span class="tag">WORKBENCH</span></div>
|
||||||
<div class="setting-row setting-row--last">
|
<p class="field__desc">店长登录小程序时提醒处理待审核员工申请。</p>
|
||||||
<div class="setting-copy">
|
<div class="field__control">
|
||||||
<strong>店长员工审核提醒</strong>
|
|
||||||
<span>店长登录小程序时提醒处理待审核员工申请。</span>
|
|
||||||
</div>
|
|
||||||
<div class="setting-control">
|
|
||||||
<a-switch v-model:checked="reviewNoticeEnabled" checked-children="显示" un-checked-children="隐藏" />
|
<a-switch v-model:checked="reviewNoticeEnabled" checked-children="显示" un-checked-children="隐藏" />
|
||||||
<span class="control-note">登录时{{ reviewNoticeEnabled ? '显示' : '不显示' }}</span>
|
<span class="control-note">登录时{{ reviewNoticeEnabled ? '显示' : '不显示' }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field__foot">
|
||||||
<span :class="['status-pill', { 'is-muted': !reviewNoticeEnabled }]">{{ reviewNoticeEnabled ? '启用' : '停用' }}</span>
|
<span :class="['status-pill', { 'is-muted': !reviewNoticeEnabled }]">{{ reviewNoticeEnabled ? '启用' : '停用' }}</span>
|
||||||
|
<a-button class="field__save" size="small" type="primary" :loading="savingReviewNotice" @click="saveReviewNotice">保存提醒设置</a-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</article>
|
||||||
|
|
||||||
<div class="setting-group">
|
<article class="field">
|
||||||
<div class="setting-group__head setting-group__head--with-action"><strong>店长注册审核</strong><span>WORKBENCH</span><a-button size="small" type="primary" :loading="savingManagerReviewMode" @click="saveManagerReviewMode">保存审核模式</a-button></div>
|
<div class="field__head"><span class="field__label">内容审核通过后自动批准</span><span class="tag">WORKBENCH</span></div>
|
||||||
<div class="setting-row setting-row--last">
|
<p class="field__desc">开启后仅在店长申请绑定的门店资料内容审核通过时自动通过;关闭后由管理员人工复核。</p>
|
||||||
<div class="setting-copy">
|
<div class="field__control">
|
||||||
<strong>内容审核通过后自动批准</strong>
|
|
||||||
<span>开启后仅在店长申请绑定的门店资料内容审核通过时自动通过;关闭后由管理员人工复核。</span>
|
|
||||||
</div>
|
|
||||||
<div class="setting-control">
|
|
||||||
<a-switch v-model:checked="managerAutoApproveEnabled" checked-children="自动" un-checked-children="人工" />
|
<a-switch v-model:checked="managerAutoApproveEnabled" checked-children="自动" un-checked-children="人工" />
|
||||||
<span class="control-note">{{ managerAutoApproveEnabled ? '自动批准' : '人工复核' }}</span>
|
<span class="control-note">{{ managerAutoApproveEnabled ? '自动批准' : '人工复核' }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field__foot">
|
||||||
<span :class="['status-pill', { 'is-muted': !managerAutoApproveEnabled }]">{{ managerAutoApproveEnabled ? '自动审核' : '人工审核' }}</span>
|
<span :class="['status-pill', { 'is-muted': !managerAutoApproveEnabled }]">{{ managerAutoApproveEnabled ? '自动审核' : '人工审核' }}</span>
|
||||||
|
<a-button class="field__save" size="small" type="primary" :loading="savingManagerReviewMode" @click="saveManagerReviewMode">保存审核模式</a-button>
|
||||||
</div>
|
</div>
|
||||||
|
</article>
|
||||||
</div>
|
</div>
|
||||||
|
<p class="settings-group__footnote">默认密码仍按后台账号接口校验;员工审核入口和数量角标不受登录提醒开关影响。</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<div class="setting-group">
|
<section id="settings-group-shop" class="settings-group">
|
||||||
<div class="setting-group__head setting-group__head--with-action"><strong>门店经营有效期</strong><span>SHOP</span><a-button size="small" type="primary" :loading="savingShopValidity" @click="saveShopValidity">保存有效期</a-button></div>
|
<header class="settings-group__head">
|
||||||
<div class="setting-row setting-row--last">
|
<div class="settings-group__head-main">
|
||||||
<div class="setting-copy">
|
<div class="settings-group__title"><h2>门店经营</h2><span class="tag">SHOP</span></div>
|
||||||
|
<p class="settings-group__desc">新门店默认经营有效期,按审核通过当天起算。</p>
|
||||||
|
</div>
|
||||||
|
<span class="meta">1 项参数</span>
|
||||||
|
</header>
|
||||||
|
<div class="settings-group__body">
|
||||||
|
<div class="inline-field">
|
||||||
|
<div class="inline-field__copy">
|
||||||
<strong>新门店默认有效期</strong>
|
<strong>新门店默认有效期</strong>
|
||||||
<span>店长注册审核通过当天计为第 1 天;单个门店可在门店管理中单独调整到期日。</span>
|
<span>店长注册审核通过当天计为第 1 天;单个门店可在门店管理中单独调整到期日。</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-control setting-control--number">
|
<div class="inline-field__control">
|
||||||
<a-input v-model:value="shopDefaultValidDays" type="number" :min="1" :max="3650" addon-after="天" />
|
<a-input v-model:value="shopDefaultValidDays" type="number" :min="1" :max="3650" addon-after="天" />
|
||||||
</div>
|
|
||||||
<span class="control-note">1–3650 天</span>
|
<span class="control-note">1–3650 天</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="inline-field__foot">
|
||||||
|
<a-button size="small" type="primary" :loading="savingShopValidity" @click="saveShopValidity">保存有效期</a-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p class="settings-group__footnote">门店到期只限制新增普通预约,不影响既有预约与历史数据。</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else-if="activeSection === 'services'" class="settings-groups">
|
||||||
|
<section id="settings-group-probe" class="settings-group">
|
||||||
|
<header class="settings-group__head">
|
||||||
|
<div class="settings-group__head-main">
|
||||||
|
<div class="settings-group__title"><h2>接入诊断</h2><span class="tag">TEST</span></div>
|
||||||
|
<p class="settings-group__desc">配置保存后再测试;点击状态芯片可展开检查项明细,真实发送会产生外部副作用。</p>
|
||||||
|
</div>
|
||||||
|
<div class="settings-group__actions">
|
||||||
|
<span v-if="probeFailCount" class="pill pill--fail">{{ probeFailCount }} 项失败</span>
|
||||||
|
<span v-if="probeWarnCount" class="pill pill--warn">{{ probeWarnCount }} 项需关注</span>
|
||||||
|
<a-button size="small" :loading="refreshingProbeResults" @click="refreshProbeResults">刷新最近结果</a-button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div class="settings-group__body">
|
||||||
|
|
||||||
|
<div class="svc-grid">
|
||||||
|
<article v-for="card in probeCardsView" :key="card.service" class="svc">
|
||||||
|
<div class="svc__head">
|
||||||
|
<span class="svc__name">{{ card.label }}</span>
|
||||||
|
<span class="svc__desc" :title="card.description">{{ card.description }}</span>
|
||||||
|
<span :class="['pill', `pill--${card.summary.kind}`]">{{ card.summary.text }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="chips">
|
||||||
|
<button
|
||||||
|
v-for="operation in card.operations"
|
||||||
|
:key="operation.code"
|
||||||
|
type="button"
|
||||||
|
:class="['chip', `chip--${operation.status.kind}`, { 'is-open': expandedProbe === `${card.service}:${operation.code}` }]"
|
||||||
|
:aria-expanded="expandedProbe === `${card.service}:${operation.code}`"
|
||||||
|
@click="toggleProbeDetail(card.service, operation.code)"
|
||||||
|
>
|
||||||
|
<span :class="['chip__dot', `chip__dot--${operation.status.kind}`]" />
|
||||||
|
<span class="chip__label">{{ operation.label }}</span>
|
||||||
|
<span class="chip__status">{{ operation.status.label }}</span>
|
||||||
|
<span v-if="operation.result" class="chip__time">{{ formatProbeTime(operation.result.checkedAt) }}</span>
|
||||||
|
<DownOutlined class="chip__chev" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div v-if="card.operations.some(operation => expandedProbe === `${card.service}:${operation.code}`)" class="svc__detail">
|
||||||
|
<template v-for="operation in card.operations" :key="operation.code">
|
||||||
|
<div v-if="expandedProbe === `${card.service}:${operation.code}`" class="probe-detail">
|
||||||
|
<div class="probe-detail__head">
|
||||||
|
<span>{{ card.label }} · {{ operation.label }} · {{ formatProbeTime(operation.result?.checkedAt) }}</span>
|
||||||
|
<a-button size="small" :loading="testingProbe === `${card.service}:${operation.code}`" @click="runCardOperation(card.service, operation.code)">运行测试</a-button>
|
||||||
|
</div>
|
||||||
|
<p class="probe-detail__summary">{{ operation.result?.summary || '尚未测试,运行测试后可查看检查项。' }}</p>
|
||||||
|
<div v-for="check in operation.result?.checks || []" :key="`${check.name}-${check.status}`" class="check-row">
|
||||||
|
<span>{{ check.name }}</span>
|
||||||
|
<em :class="`check-row__status--${check.status.toLowerCase()}`">{{ probeStatusLabel(check.status) }}</em>
|
||||||
|
<small>{{ check.detail }}</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
<p class="settings-group__footnote">短信和订阅消息默认只诊断,真实发送会产生外部副作用并要求二次确认;对象存储测试文件会自动清理。微信图片测试提交后显示等待回调,不会把异步结果误报为失败。</p>
|
||||||
</div>
|
</div>
|
||||||
<p class="section-footnote">默认密码仍按后台账号接口校验;员工审核入口和数量角标不受登录提醒开关影响。门店到期只限制新增普通预约。</p>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section v-else-if="activeSection === 'services'" class="settings-section-panel">
|
<section id="settings-group-map" class="settings-group">
|
||||||
<div class="pane-head">
|
<header class="settings-group__head">
|
||||||
<div>
|
<div class="settings-group__head-main">
|
||||||
<h2>服务接入</h2>
|
<div class="settings-group__title"><h2>地图服务</h2><span class="tag">安全接入</span></div>
|
||||||
<p>维护加密保存的地图密钥、微信审核回调和短信服务渠道。</p>
|
<p class="settings-group__desc">密钥加密保存,接口不回传密钥;保存后再进行接入诊断。</p>
|
||||||
</div>
|
</div>
|
||||||
<span />
|
<div class="settings-group__actions">
|
||||||
|
<a-button size="small" type="primary" :loading="savingMap || confirmingMap" @click="saveMapConfig">保存地图设置</a-button>
|
||||||
</div>
|
</div>
|
||||||
|
</header>
|
||||||
<div class="setting-group probe-group">
|
<div class="settings-group__body">
|
||||||
<div class="setting-group__head setting-group__head--with-action"><strong>接入诊断</strong><span>TEST</span><a-button size="small" :loading="refreshingProbeResults" @click="refreshProbeResults">刷新最近结果</a-button></div>
|
<div class="field-grid cols-2">
|
||||||
<div class="probe-list">
|
<article class="field">
|
||||||
<div v-for="card in probeCards" :key="card.service" class="probe-row">
|
<div class="field__head"><span class="field__label">默认地图渠道</span></div>
|
||||||
<div class="probe-row__copy">
|
<p class="field__desc">店铺选点和后台地图展示使用的默认渠道。</p>
|
||||||
<strong>{{ card.label }}</strong>
|
<div class="field__control"><a-select v-model:value="mapProvider" :options="mapProviderOptions" /></div>
|
||||||
<span>{{ card.description }}</span>
|
<div class="field__foot"><span class="status-pill" :class="{ 'is-muted': !mapEnabled }">{{ mapEnabled ? '启用' : '停用' }}</span></div>
|
||||||
</div>
|
</article>
|
||||||
<div class="probe-actions">
|
<article v-for="item in mapKeyRows" :key="item.key" class="field">
|
||||||
<div v-for="operation in card.operations" :key="operation.code" class="probe-action">
|
<div class="field__head">
|
||||||
<a-button size="small" :loading="testingProbe === `${card.service}:${operation.code}`" @click="runCardOperation(card.service, operation.code)">{{ operation.label }}</a-button>
|
<span class="field__label">{{ item.label }}</span>
|
||||||
<span v-if="probeFor(card.service, operation.code)" :class="['status-pill', `probe-status--${probeFor(card.service, operation.code)?.status.toLowerCase()}`]">{{ probeStatusLabel(probeFor(card.service, operation.code)?.status) }}</span>
|
|
||||||
<span v-else class="status-pill is-muted">未测试</span>
|
|
||||||
<small v-if="probeFor(card.service, operation.code)">{{ probeFor(card.service, operation.code)?.summary }} · {{ formatProbeTime(probeFor(card.service, operation.code)?.checkedAt) }}</small>
|
|
||||||
<a-collapse v-if="probeFor(card.service, operation.code)?.checks?.length" class="probe-details" ghost>
|
|
||||||
<a-collapse-panel key="checks" header="查看检查项">
|
|
||||||
<div v-for="check in probeFor(card.service, operation.code)?.checks" :key="`${check.name}-${check.status}`" class="probe-check">
|
|
||||||
<span>{{ check.name }}</span><em :class="`probe-check--${check.status.toLowerCase()}`">{{ probeStatusLabel(check.status) }}</em><small>{{ check.detail }}</small>
|
|
||||||
</div>
|
|
||||||
</a-collapse-panel>
|
|
||||||
</a-collapse>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p class="secure-note">配置保存后再测试。短信和订阅消息默认只诊断,真实发送会产生外部副作用并要求二次确认;对象存储测试文件会自动清理。微信图片测试提交后显示等待回调,不会把异步结果误报为失败。</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="setting-group">
|
|
||||||
<div class="setting-group__head setting-group__head--with-action"><strong>地图服务</strong><span>安全接入</span><a-button size="small" type="primary" :loading="savingMap || confirmingMap" @click="saveMapConfig">保存地图设置</a-button></div>
|
|
||||||
<div class="setting-row">
|
|
||||||
<div class="setting-copy"><strong>默认地图渠道</strong><span>店铺选点和后台地图展示使用的默认渠道。</span></div>
|
|
||||||
<div class="setting-control"><a-select v-model:value="mapProvider" :options="mapProviderOptions" /></div>
|
|
||||||
<span class="status-pill" :class="{ 'is-muted': !mapEnabled }">{{ mapEnabled ? '启用' : '停用' }}</span>
|
|
||||||
</div>
|
|
||||||
<div v-for="item in mapKeyRows" :key="item.key" class="setting-row">
|
|
||||||
<div class="setting-copy">
|
|
||||||
<strong>
|
|
||||||
{{ item.label }}
|
|
||||||
<a
|
<a
|
||||||
class="setting-copy__link"
|
class="setting-copy__link"
|
||||||
:href="item.url"
|
:href="item.url"
|
||||||
@@ -156,59 +205,91 @@
|
|||||||
获取 Key
|
获取 Key
|
||||||
<ExportOutlined />
|
<ExportOutlined />
|
||||||
</a>
|
</a>
|
||||||
</strong>
|
|
||||||
<span>{{ item.description }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-control setting-control--password">
|
<p class="field__desc">{{ item.description }}</p>
|
||||||
|
<div class="field__control field__control--password">
|
||||||
<a-input-password v-model:value="mapSecrets[item.key]" :placeholder="mapKeyPlaceholder(item.key, item.placeholder)" autocomplete="new-password" @update:value="clearMapSecrets[item.key] = false" />
|
<a-input-password v-model:value="mapSecrets[item.key]" :placeholder="mapKeyPlaceholder(item.key, item.placeholder)" autocomplete="new-password" @update:value="clearMapSecrets[item.key] = false" />
|
||||||
<a-button v-if="mapKeyStoredConfigured(item.key)" size="small" type="text" danger @click="toggleMapSecretClear(item.key)">{{ clearMapSecrets[item.key] ? '撤销清除' : '清除' }}</a-button>
|
<a-button v-if="mapKeyStoredConfigured(item.key)" size="small" type="text" danger @click="toggleMapSecretClear(item.key)">{{ clearMapSecrets[item.key] ? '撤销清除' : '清除' }}</a-button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field__foot">
|
||||||
<span class="status-pill" :class="{ 'is-muted': !mapConfigured(item.key) || clearMapSecrets[item.key] }">{{ clearMapSecrets[item.key] ? '保存后清除' : mapConfigured(item.key) ? '已配置' : '待配置' }}</span>
|
<span class="status-pill" :class="{ 'is-muted': !mapConfigured(item.key) || clearMapSecrets[item.key] }">{{ clearMapSecrets[item.key] ? '保存后清除' : mapConfigured(item.key) ? '已配置' : '待配置' }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-row setting-row--last">
|
</article>
|
||||||
<div class="setting-copy"><strong>地图服务状态</strong><span>停用后店铺地图选点不会调用已保存的渠道。</span></div>
|
<article class="field">
|
||||||
<div class="setting-control"><a-switch v-model:checked="mapEnabled" checked-children="启用" un-checked-children="停用" /></div>
|
<div class="field__head"><span class="field__label">地图服务状态</span></div>
|
||||||
<span :class="['status-pill', { 'is-muted': !mapEnabled }]">{{ mapEnabled ? '启用' : '停用' }}</span>
|
<p class="field__desc">停用后店铺地图选点不会调用已保存的渠道。</p>
|
||||||
|
<div class="field__control"><a-switch v-model:checked="mapEnabled" checked-children="启用" un-checked-children="停用" /></div>
|
||||||
|
<div class="field__foot"><span :class="['status-pill', { 'is-muted': !mapEnabled }]">{{ mapEnabled ? '启用' : '停用' }}</span></div>
|
||||||
|
</article>
|
||||||
</div>
|
</div>
|
||||||
<p class="secure-note">密钥以 AES-256-GCM 加密保存在当前环境数据库,设置接口不回传密钥。地图打开时才通过管理员认证接口按当前渠道读取;Web Key 会在浏览器地图 SDK 请求中使用,请在地图开放平台限制可用域名,并为 DEV、SIT、PROD 分别创建 Key。<span v-if="secureStatus && !secureStatus.encryptionKeyConfigured" class="secure-note__warning">服务端加密主密钥尚未配置,需先由部署维护人员设置后才能保存。</span><span v-else-if="secureStatus?.mapLegacyMigrationPending" class="secure-note__warning">检测到旧版地图参数尚未完成加密迁移;主密钥配置后重新打开本页,系统会自动转存并清空旧明文值,请核对各 Key 显示为已配置后再启用地图。</span></p>
|
<p class="secure-note">密钥以 AES-256-GCM 加密保存在当前环境数据库,设置接口不回传密钥。地图打开时才通过管理员认证接口按当前渠道读取;Web Key 会在浏览器地图 SDK 请求中使用,请在地图开放平台限制可用域名,并为 DEV、SIT、PROD 分别创建 Key。<span v-if="secureStatus && !secureStatus.encryptionKeyConfigured" class="secure-note__warning">服务端加密主密钥尚未配置,需先由部署维护人员设置后才能保存。</span><span v-else-if="secureStatus?.mapLegacyMigrationPending" class="secure-note__warning">检测到旧版地图参数尚未完成加密迁移;主密钥配置后重新打开本页,系统会自动转存并清空旧明文值,请核对各 Key 显示为已配置后再启用地图。</span></p>
|
||||||
</div>
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<div class="setting-group">
|
<section id="settings-group-moderation" class="settings-group">
|
||||||
<div class="setting-group__head setting-group__head--with-action"><strong>微信内容审核</strong><span>安全回调</span><a-button size="small" type="primary" :loading="savingModeration || confirmingModeration" @click="saveModerationConfig">保存审核设置</a-button></div>
|
<header class="settings-group__head">
|
||||||
<div class="setting-row">
|
<div class="settings-group__head-main">
|
||||||
<div class="setting-copy"><strong>审核渠道</strong><span>未启用或配置不完整时,内容保持隔离,不会自动放行。</span></div>
|
<div class="settings-group__title"><h2>微信内容审核</h2><span class="tag">安全回调</span></div>
|
||||||
<div class="setting-control"><a-select v-model:value="moderationProvider" :options="moderationProviderOptions" /></div>
|
<p class="settings-group__desc">回调凭据加密保存,改为完整配置后保存;填写顺序见下方指引。</p>
|
||||||
|
</div>
|
||||||
|
<div class="settings-group__actions">
|
||||||
|
<a-button size="small" type="primary" :loading="savingModeration || confirmingModeration" @click="saveModerationConfig">保存审核设置</a-button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div class="settings-group__body">
|
||||||
|
<div class="field-grid cols-2">
|
||||||
|
<article class="field">
|
||||||
|
<div class="field__head"><span class="field__label">审核渠道</span></div>
|
||||||
|
<p class="field__desc">未启用或配置不完整时,内容保持隔离,不会自动放行。</p>
|
||||||
|
<div class="field__control"><a-select v-model:value="moderationProvider" :options="moderationProviderOptions" /></div>
|
||||||
|
<div class="field__foot">
|
||||||
<span class="status-pill" :class="{ 'is-muted': !secureStatus?.moderationReady }">{{ secureStatus?.moderationReady ? '已就绪' : '待配置' }}</span>
|
<span class="status-pill" :class="{ 'is-muted': !secureStatus?.moderationReady }">{{ secureStatus?.moderationReady ? '已就绪' : '待配置' }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-row">
|
</article>
|
||||||
<div class="setting-copy"><strong>小程序凭据</strong><span>服务端需配置当前环境的 AppID 与 AppSecret,用于请求微信审核接口。</span></div>
|
<article class="field">
|
||||||
<div class="setting-value">{{ secureStatus?.wechatMiniAppConfigured ? `${secureStatus.wechatMiniAppId} · AppSecret 已配置` : `${secureStatus?.wechatMiniAppId || 'AppID 未配置'} · AppSecret 待配置` }}</div>
|
<div class="field__head"><span class="field__label">小程序凭据</span></div>
|
||||||
|
<p class="field__desc">服务端需配置当前环境的 AppID 与 AppSecret,用于请求微信审核接口。</p>
|
||||||
|
<div class="field__control">
|
||||||
|
<span class="field__value">{{ secureStatus?.wechatMiniAppConfigured ? `${secureStatus.wechatMiniAppId} · AppSecret 已配置` : `${secureStatus?.wechatMiniAppId || 'AppID 未配置'} · AppSecret 待配置` }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="field__foot">
|
||||||
<span class="status-pill" :class="{ 'is-muted': !secureStatus?.wechatMiniAppConfigured }">{{ secureStatus?.wechatMiniAppConfigured ? '已就绪' : '待配置' }}</span>
|
<span class="status-pill" :class="{ 'is-muted': !secureStatus?.wechatMiniAppConfigured }">{{ secureStatus?.wechatMiniAppConfigured ? '已就绪' : '待配置' }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-row">
|
</article>
|
||||||
<div class="setting-copy"><strong>微信服务器回调 URL</strong><span>复制到微信公众平台「开发管理 → 开发设置 → 消息推送」的 URL。</span></div>
|
<article class="field field--wide">
|
||||||
<div class="setting-control setting-control--joined">
|
<div class="field__head"><span class="field__label">微信服务器回调 URL</span></div>
|
||||||
|
<p class="field__desc">复制到微信公众平台「开发管理 → 开发设置 → 消息推送」的 URL。</p>
|
||||||
|
<div class="field__control">
|
||||||
<a-input v-model:value="moderationCallbackUrl" :placeholder="defaultCallbackUrl()" />
|
<a-input v-model:value="moderationCallbackUrl" :placeholder="defaultCallbackUrl()" />
|
||||||
<a-button @click="copyCallbackUrl"><CopyOutlined />复制</a-button>
|
<a-button @click="copyCallbackUrl"><CopyOutlined />复制</a-button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field__foot">
|
||||||
<span class="status-pill" :class="{ 'is-muted': !isPublicHttpsCallback }">{{ isPublicHttpsCallback ? '公网 HTTPS' : '需填写公网地址' }}</span>
|
<span class="status-pill" :class="{ 'is-muted': !isPublicHttpsCallback }">{{ isPublicHttpsCallback ? '公网 HTTPS' : '需填写公网地址' }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-row">
|
</article>
|
||||||
<div class="setting-copy"><strong>回调 Token</strong><span>3-32 位英文字母或数字;留空表示不修改已保存值。</span></div>
|
<article class="field">
|
||||||
<div class="setting-control setting-control--password">
|
<div class="field__head"><span class="field__label">回调 Token</span></div>
|
||||||
|
<p class="field__desc">3-32 位英文字母或数字;留空表示不修改已保存值。</p>
|
||||||
|
<div class="field__control field__control--password">
|
||||||
<a-input-password v-model:value="moderationSecrets.callbackToken" autocomplete="new-password" :placeholder="secureStatus?.moderationCallbackTokenConfigured && !clearModerationSecrets.callbackToken ? '••••••••' : '填写新的 Token,留空保持原值'" @update:value="clearModerationSecrets.callbackToken = false" />
|
<a-input-password v-model:value="moderationSecrets.callbackToken" autocomplete="new-password" :placeholder="secureStatus?.moderationCallbackTokenConfigured && !clearModerationSecrets.callbackToken ? '••••••••' : '填写新的 Token,留空保持原值'" @update:value="clearModerationSecrets.callbackToken = false" />
|
||||||
<a-button v-if="secureStatus?.moderationCallbackTokenConfigured" size="small" type="text" danger @click="toggleModerationSecretClear('callbackToken')">{{ clearModerationSecrets.callbackToken ? '撤销清除' : '清除' }}</a-button>
|
<a-button v-if="secureStatus?.moderationCallbackTokenConfigured" size="small" type="text" danger @click="toggleModerationSecretClear('callbackToken')">{{ clearModerationSecrets.callbackToken ? '撤销清除' : '清除' }}</a-button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field__foot">
|
||||||
<span class="status-pill" :class="{ 'is-muted': !secureStatus?.moderationCallbackTokenConfigured || clearModerationSecrets.callbackToken }">{{ clearModerationSecrets.callbackToken ? '保存后清除' : secureStatus?.moderationCallbackTokenConfigured ? '已配置' : '待配置' }}</span>
|
<span class="status-pill" :class="{ 'is-muted': !secureStatus?.moderationCallbackTokenConfigured || clearModerationSecrets.callbackToken }">{{ clearModerationSecrets.callbackToken ? '保存后清除' : secureStatus?.moderationCallbackTokenConfigured ? '已配置' : '待配置' }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-row setting-row--last">
|
</article>
|
||||||
<div class="setting-copy"><strong>EncodingAESKey</strong><span>微信平台生成的 43 位密钥;消息加密方式必须选择「安全模式」。</span></div>
|
<article class="field">
|
||||||
<div class="setting-control setting-control--password">
|
<div class="field__head"><span class="field__label">EncodingAESKey</span></div>
|
||||||
|
<p class="field__desc">微信平台生成的 43 位密钥;消息加密方式必须选择「安全模式」。</p>
|
||||||
|
<div class="field__control field__control--password">
|
||||||
<a-input-password v-model:value="moderationSecrets.encodingAesKey" autocomplete="new-password" :placeholder="secureStatus?.moderationEncodingAesKeyConfigured && !clearModerationSecrets.encodingAesKey ? '••••••••' : '填写 43 位 EncodingAESKey,留空保持原值'" @update:value="clearModerationSecrets.encodingAesKey = false" />
|
<a-input-password v-model:value="moderationSecrets.encodingAesKey" autocomplete="new-password" :placeholder="secureStatus?.moderationEncodingAesKeyConfigured && !clearModerationSecrets.encodingAesKey ? '••••••••' : '填写 43 位 EncodingAESKey,留空保持原值'" @update:value="clearModerationSecrets.encodingAesKey = false" />
|
||||||
<a-button v-if="secureStatus?.moderationEncodingAesKeyConfigured" size="small" type="text" danger @click="toggleModerationSecretClear('encodingAesKey')">{{ clearModerationSecrets.encodingAesKey ? '撤销清除' : '清除' }}</a-button>
|
<a-button v-if="secureStatus?.moderationEncodingAesKeyConfigured" size="small" type="text" danger @click="toggleModerationSecretClear('encodingAesKey')">{{ clearModerationSecrets.encodingAesKey ? '撤销清除' : '清除' }}</a-button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field__foot">
|
||||||
<span class="status-pill" :class="{ 'is-muted': !secureStatus?.moderationEncodingAesKeyConfigured || clearModerationSecrets.encodingAesKey }">{{ clearModerationSecrets.encodingAesKey ? '保存后清除' : secureStatus?.moderationEncodingAesKeyConfigured ? '已配置' : '待配置' }}</span>
|
<span class="status-pill" :class="{ 'is-muted': !secureStatus?.moderationEncodingAesKeyConfigured || clearModerationSecrets.encodingAesKey }">{{ clearModerationSecrets.encodingAesKey ? '保存后清除' : secureStatus?.moderationEncodingAesKeyConfigured ? '已配置' : '待配置' }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
<div class="secure-guide">
|
<div class="secure-guide">
|
||||||
<strong>微信平台填写指引</strong>
|
<strong>微信平台填写指引</strong>
|
||||||
<ol>
|
<ol>
|
||||||
@@ -226,11 +307,24 @@
|
|||||||
<span v-if="secureStatus && !secureStatus.encryptionKeyConfigured" class="secure-note__warning">安全接入加密主密钥尚未配置,Token 与 AESKey 不会保存。</span>
|
<span v-if="secureStatus && !secureStatus.encryptionKeyConfigured" class="secure-note__warning">安全接入加密主密钥尚未配置,Token 与 AESKey 不会保存。</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<div class="setting-group">
|
<section id="settings-group-storage" class="settings-group">
|
||||||
<div class="setting-group__head setting-group__head--with-action"><strong>对象存储读取顺序</strong><span>FILE</span><a-button size="small" type="primary" :loading="savingStorageReadOrder" @click="saveStorageReadOrder">保存读取顺序</a-button></div>
|
<header class="settings-group__head">
|
||||||
<div class="setting-row setting-row--last storage-order-row">
|
<div class="settings-group__head-main">
|
||||||
<div class="setting-copy"><strong>MinIO、七牛云、阿里云 OSS</strong><span>头像、作品等资源都按此顺序生成签名访问地址并回退可用副本;不改变上传首选、三副本要求和副本修复顺序。</span></div>
|
<div class="settings-group__title"><h2>对象存储读取顺序</h2><span class="tag">FILE</span></div>
|
||||||
|
<p class="settings-group__desc">头像、作品等资源按此顺序生成签名访问地址并回退可用副本。</p>
|
||||||
|
</div>
|
||||||
|
<div class="settings-group__actions">
|
||||||
|
<a-button size="small" type="primary" :loading="savingStorageReadOrder" @click="saveStorageReadOrder">保存读取顺序</a-button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div class="settings-group__body">
|
||||||
|
<div class="storage-row">
|
||||||
|
<div class="inline-field__copy">
|
||||||
|
<strong>MinIO、七牛云、阿里云 OSS</strong>
|
||||||
|
<span>不改变上传首选、三副本要求和副本修复顺序;用上下按钮调整读取优先级。</span>
|
||||||
|
</div>
|
||||||
<div class="storage-order-list" aria-label="对象存储读取优先级">
|
<div class="storage-order-list" aria-label="对象存储读取优先级">
|
||||||
<div v-for="(provider, index) in storageReadOrder" :key="provider.code" class="storage-order-item">
|
<div v-for="(provider, index) in storageReadOrder" :key="provider.code" class="storage-order-item">
|
||||||
<span class="storage-order-index">{{ index + 1 }}</span>
|
<span class="storage-order-index">{{ index + 1 }}</span>
|
||||||
@@ -244,47 +338,72 @@
|
|||||||
<span class="control-note">最多 30 秒同步至其他服务实例</span>
|
<span class="control-note">最多 30 秒同步至其他服务实例</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<div class="setting-group">
|
<section id="settings-group-sms" class="settings-group">
|
||||||
<div class="setting-group__head setting-group__head--with-action"><strong>短信服务</strong><span>SMS</span><a-button size="small" type="primary" :loading="savingSmsProvider" @click="saveSmsProvider">保存短信设置</a-button></div>
|
<header class="settings-group__head">
|
||||||
<div class="setting-row setting-row--last">
|
<div class="settings-group__head-main">
|
||||||
<div class="setting-copy"><strong>短信供应商</strong><span>统一控制登录、绑定和找回密码的验证码通道。</span></div>
|
<div class="settings-group__title"><h2>短信服务</h2><span class="tag">SMS</span></div>
|
||||||
<div class="setting-control"><a-select v-model:value="smsProviderForm.configValue" :options="smsProviderOptions" /></div>
|
<p class="settings-group__desc">统一控制登录、绑定和找回密码的验证码通道。</p>
|
||||||
|
</div>
|
||||||
|
<div class="settings-group__actions">
|
||||||
|
<a-button size="small" type="primary" :loading="savingSmsProvider" @click="saveSmsProvider">保存短信设置</a-button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div class="settings-group__body">
|
||||||
|
<div class="inline-field">
|
||||||
|
<div class="inline-field__copy">
|
||||||
|
<strong>短信供应商</strong>
|
||||||
|
<span>保存后会同步全部短信验证码场景的模板、通道和发送方式。</span>
|
||||||
|
</div>
|
||||||
|
<div class="inline-field__control">
|
||||||
|
<a-select v-model:value="smsProviderForm.configValue" :options="smsProviderOptions" />
|
||||||
|
</div>
|
||||||
|
<div class="inline-field__foot">
|
||||||
<span class="warning-note">切换会影响全部验证码</span>
|
<span class="warning-note">切换会影响全部验证码</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
|
||||||
|
|
||||||
<section v-else class="settings-section-panel">
|
|
||||||
<div class="pane-head">
|
|
||||||
<div>
|
|
||||||
<h2>管理员账号</h2>
|
|
||||||
<p>查看后台登录账号与当前会话状态。</p>
|
|
||||||
</div>
|
|
||||||
<span class="account-status"><i />会话正常</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="setting-group">
|
|
||||||
<div class="setting-group__head"><strong>账号信息</strong><span>ACCOUNT</span></div>
|
|
||||||
<div class="setting-row">
|
|
||||||
<div class="setting-copy"><strong>登录账号</strong><span>用于进入后台的账号标识。</span></div>
|
|
||||||
<div class="setting-value">{{ userInfo?.account || '--' }}</div>
|
|
||||||
<span class="status-pill">当前账号</span>
|
|
||||||
</div>
|
|
||||||
<div class="setting-row">
|
|
||||||
<div class="setting-copy"><strong>显示昵称</strong><span>后台顶部和操作记录中使用的昵称。</span></div>
|
|
||||||
<div class="setting-value">{{ userInfo?.nickname || '未设置昵称' }}</div>
|
|
||||||
<span class="control-note">只读</span>
|
|
||||||
</div>
|
|
||||||
<div class="setting-row setting-row--last">
|
|
||||||
<div class="setting-copy"><strong>后台会话</strong><span>后台请求使用管理员身份校验,退出登录后当前会话立即失效。</span></div>
|
|
||||||
<div class="setting-value">{{ userInfo?.id ? '已登录' : '状态未知' }}</div>
|
|
||||||
<span class="status-pill" :class="{ 'is-muted': !userInfo?.id }">{{ userInfo?.id ? '正常' : '待验证' }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="settings-groups">
|
||||||
|
<section id="settings-group-account-info" class="settings-group">
|
||||||
|
<header class="settings-group__head">
|
||||||
|
<div class="settings-group__head-main">
|
||||||
|
<div class="settings-group__title"><h2>账号信息</h2><span class="tag">ACCOUNT</span></div>
|
||||||
|
<p class="settings-group__desc">查看后台登录账号与当前会话状态。</p>
|
||||||
|
</div>
|
||||||
|
<div class="settings-group__actions">
|
||||||
|
<span class="pill pill--pass">会话正常</span>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div class="settings-group__body">
|
||||||
|
<div class="account-grid">
|
||||||
|
<div class="account-tile">
|
||||||
|
<span class="account-tile__label">登录账号</span>
|
||||||
|
<strong>{{ userInfo?.account || '--' }}</strong>
|
||||||
|
<div class="account-tile__foot"><span class="status-pill">当前账号</span></div>
|
||||||
|
</div>
|
||||||
|
<div class="account-tile">
|
||||||
|
<span class="account-tile__label">显示昵称</span>
|
||||||
|
<strong>{{ userInfo?.nickname || '未设置昵称' }}</strong>
|
||||||
|
<div class="account-tile__foot"><span class="control-note">只读</span></div>
|
||||||
|
</div>
|
||||||
|
<div class="account-tile">
|
||||||
|
<span class="account-tile__label">后台会话</span>
|
||||||
|
<strong>{{ userInfo?.id ? '已登录' : '状态未知' }}</strong>
|
||||||
|
<div class="account-tile__foot">
|
||||||
|
<span :class="['status-pill', { 'is-muted': !userInfo?.id }]">{{ userInfo?.id ? '正常' : '待验证' }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p class="settings-group__footnote">后台请求使用管理员身份校验,退出登录后当前会话立即失效。</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
|
||||||
|
|
||||||
<a-modal v-model:open="realProbeOpen" title="确认真实接入测试" :confirm-loading="realProbeLoading" :mask-closable="false" ok-text="确认发送" cancel-text="取消" @ok="submitRealProbe">
|
<a-modal v-model:open="realProbeOpen" title="确认真实接入测试" :confirm-loading="realProbeLoading" :mask-closable="false" ok-text="确认发送" cancel-text="取消" @ok="submitRealProbe">
|
||||||
<template v-if="realProbeService === 'SMS'">
|
<template v-if="realProbeService === 'SMS'">
|
||||||
@@ -301,10 +420,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { message, Modal } from 'ant-design-vue'
|
import { message, Modal } from 'ant-design-vue'
|
||||||
import { ApiOutlined, ArrowDownOutlined, ArrowUpOutlined, CopyOutlined, ExportOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons-vue'
|
import { ArrowDownOutlined, ArrowUpOutlined, CopyOutlined, DownOutlined, ExportOutlined } from '@ant-design/icons-vue'
|
||||||
import { adminSecureIntegrationConfigApi, adminSystemParameterConfigApi, type IntegrationProbeResultVO, type SecureIntegrationConfigVO, type SystemParameterConfigVO } from '@/api/admin'
|
import { adminSecureIntegrationConfigApi, adminSystemParameterConfigApi, type IntegrationProbeResultVO, type SecureIntegrationConfigVO, type SystemParameterConfigVO } from '@/api/admin'
|
||||||
import { ADMIN_API_BASE_URL } from '@/config/api'
|
import { ADMIN_API_BASE_URL } from '@/config/api'
|
||||||
import { loadCachedAdminUserInfo } from '@/utils/admin-session'
|
import { loadCachedAdminUserInfo } from '@/utils/admin-session'
|
||||||
@@ -389,9 +508,9 @@ const isPublicHttpsCallback = computed(() => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
const sections = [
|
const sections = [
|
||||||
{ key: 'runtime' as const, label: '运行参数', icon: SettingOutlined },
|
{ key: 'runtime' as const, label: '运行参数' },
|
||||||
{ key: 'services' as const, label: '服务接入', icon: ApiOutlined },
|
{ key: 'services' as const, label: '服务接入' },
|
||||||
{ key: 'account' as const, label: '当前账号', icon: UserOutlined }
|
{ key: 'account' as const, label: '当前账号' }
|
||||||
]
|
]
|
||||||
const probeCards = [
|
const probeCards = [
|
||||||
{ service: 'CONTENT_MODERATION', label: '微信内容审核', description: '检查当前 Provider、凭据和回调;文本使用固定无害内容,图片需等待回调。', operations: [{ code: 'CONFIG', label: '配置诊断' }, { code: 'TEXT', label: '文本接口测试' }, { code: 'IMAGE_CALLBACK', label: '图片回调测试' }] },
|
{ service: 'CONTENT_MODERATION', label: '微信内容审核', description: '检查当前 Provider、凭据和回调;文本使用固定无害内容,图片需等待回调。', operations: [{ code: 'CONFIG', label: '配置诊断' }, { code: 'TEXT', label: '文本接口测试' }, { code: 'IMAGE_CALLBACK', label: '图片回调测试' }] },
|
||||||
@@ -407,7 +526,7 @@ const mapKeyRows: Array<{ key: MapKey; label: string; description: string; place
|
|||||||
]
|
]
|
||||||
|
|
||||||
const defaultPasswordForm = reactive<SystemParameterConfigVO>({
|
const defaultPasswordForm = reactive<SystemParameterConfigVO>({
|
||||||
configGroup: 'USER', configKey: 'DEFAULT_PASSWORD', configName: '后台新增用户默认密码', configValue: 'Fingertip@123', enabled: 1,
|
configGroup: 'USER', configKey: 'DEFAULT_PASSWORD', configName: '后台新增用户默认密码', configValue: '', enabled: 1,
|
||||||
remark: '后台新增用户不填写密码时使用;需满足 8-32 位且至少包含数字、小写字母、大写字母、特殊符号中的 3 类'
|
remark: '后台新增用户不填写密码时使用;需满足 8-32 位且至少包含数字、小写字母、大写字母、特殊符号中的 3 类'
|
||||||
})
|
})
|
||||||
const reviewNoticeForm = reactive<SystemParameterConfigVO>({
|
const reviewNoticeForm = reactive<SystemParameterConfigVO>({
|
||||||
@@ -529,6 +648,74 @@ const probeFor = (service: string, operation?: string) => probeResults.value
|
|||||||
.sort((a, b) => String(b.checkedAt || '').localeCompare(String(a.checkedAt || '')))[0]
|
.sort((a, b) => String(b.checkedAt || '').localeCompare(String(a.checkedAt || '')))[0]
|
||||||
const formatProbeTime = (time?: string) => time ? new Date(time).toLocaleString('zh-CN', { hour12: false }) : '暂无时间'
|
const formatProbeTime = (time?: string) => time ? new Date(time).toLocaleString('zh-CN', { hour12: false }) : '暂无时间'
|
||||||
const probeStatusLabel = (status?: string) => ({ PASS: '通过', WARN: '需关注', FAIL: '失败', PENDING: '等待回调' } as Record<string, string>)[status || ''] || '未知'
|
const probeStatusLabel = (status?: string) => ({ PASS: '通过', WARN: '需关注', FAIL: '失败', PENDING: '等待回调' } as Record<string, string>)[status || ''] || '未知'
|
||||||
|
const probeStatusKind = (status?: string) => ({ PASS: 'pass', WARN: 'warn', FAIL: 'fail', PENDING: 'pending' } as Record<string, string>)[status || ''] || 'idle'
|
||||||
|
const probeCardsView = computed(() => probeCards.map(card => {
|
||||||
|
const operations = card.operations.map(operation => {
|
||||||
|
const result = probeFor(card.service, operation.code)
|
||||||
|
return { ...operation, result, status: { kind: probeStatusKind(result?.status), label: probeStatusLabel(result?.status) } }
|
||||||
|
})
|
||||||
|
let pass = 0, warn = 0, fail = 0, pending = 0, idle = 0
|
||||||
|
operations.forEach(operation => {
|
||||||
|
if (operation.status.kind === 'pass') pass += 1
|
||||||
|
else if (operation.status.kind === 'warn') warn += 1
|
||||||
|
else if (operation.status.kind === 'fail') fail += 1
|
||||||
|
else if (operation.status.kind === 'pending') pending += 1
|
||||||
|
else idle += 1
|
||||||
|
})
|
||||||
|
const parts = [pass ? `${pass} 通过` : '', warn ? `${warn} 需关注` : '', fail ? `${fail} 失败` : '', pending ? `${pending} 等待回调` : '', idle ? `${idle} 未测试` : ''].filter(Boolean)
|
||||||
|
return { ...card, operations, summary: { kind: fail ? 'fail' : warn ? 'warn' : pass ? 'pass' : 'idle', text: parts.join(' · ') } }
|
||||||
|
}))
|
||||||
|
const probeFailCount = computed(() => probeCardsView.value.reduce((total, card) => total + card.operations.filter(operation => operation.status.kind === 'fail').length, 0))
|
||||||
|
const probeWarnCount = computed(() => probeCardsView.value.reduce((total, card) => total + card.operations.filter(operation => operation.status.kind === 'warn').length, 0))
|
||||||
|
const expandedProbe = ref('')
|
||||||
|
const toggleProbeDetail = (service: string, operation: string) => {
|
||||||
|
const key = `${service}:${operation}`
|
||||||
|
expandedProbe.value = expandedProbe.value === key ? '' : key
|
||||||
|
}
|
||||||
|
|
||||||
|
const activeGroup = ref('')
|
||||||
|
const groupNavItems = computed<Array<{ id: string; label: string; badge?: string }>>(() => {
|
||||||
|
if (activeSection.value === 'runtime') {
|
||||||
|
return [{ id: 'settings-group-account', label: '账号与登录' }, { id: 'settings-group-shop', label: '门店经营' }]
|
||||||
|
}
|
||||||
|
if (activeSection.value === 'services') {
|
||||||
|
return [
|
||||||
|
{ id: 'settings-group-probe', label: '接入诊断', badge: String(probeCards.length) },
|
||||||
|
{ id: 'settings-group-map', label: '地图服务' },
|
||||||
|
{ id: 'settings-group-moderation', label: '微信内容审核' },
|
||||||
|
{ id: 'settings-group-storage', label: '对象存储读取顺序' },
|
||||||
|
{ id: 'settings-group-sms', label: '短信服务' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
return [{ id: 'settings-group-account-info', label: '账号信息' }]
|
||||||
|
})
|
||||||
|
const syncActiveGroup = () => {
|
||||||
|
const items = groupNavItems.value
|
||||||
|
if (!items.length) {
|
||||||
|
activeGroup.value = ''
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let current = items[0]?.id || ''
|
||||||
|
items.forEach(item => {
|
||||||
|
const element = document.getElementById(item.id)
|
||||||
|
if (element && element.getBoundingClientRect().top <= 120) current = item.id
|
||||||
|
})
|
||||||
|
activeGroup.value = current
|
||||||
|
}
|
||||||
|
const scrollToGroup = (id: string) => {
|
||||||
|
const element = document.getElementById(id)
|
||||||
|
if (!element) return
|
||||||
|
window.scrollTo({ top: element.getBoundingClientRect().top + window.scrollY - 16, behavior: 'smooth' })
|
||||||
|
activeGroup.value = id
|
||||||
|
}
|
||||||
|
let scrollFrame = 0
|
||||||
|
const handleWindowScroll = () => {
|
||||||
|
if (scrollFrame) return
|
||||||
|
scrollFrame = window.requestAnimationFrame(() => {
|
||||||
|
scrollFrame = 0
|
||||||
|
syncActiveGroup()
|
||||||
|
})
|
||||||
|
}
|
||||||
const runProbe = async (service: string, operation: string) => {
|
const runProbe = async (service: string, operation: string) => {
|
||||||
const key = `${service}:${operation}`
|
const key = `${service}:${operation}`
|
||||||
testingProbe.value = key
|
testingProbe.value = key
|
||||||
@@ -819,91 +1006,129 @@ const saveStorageReadOrder = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
void load()
|
void load().then(() => nextTick(syncActiveGroup))
|
||||||
|
nextTick(syncActiveGroup)
|
||||||
|
window.addEventListener('scroll', handleWindowScroll, { passive: true })
|
||||||
|
window.addEventListener('resize', syncActiveGroup)
|
||||||
|
})
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
window.removeEventListener('scroll', handleWindowScroll)
|
||||||
|
window.removeEventListener('resize', syncActiveGroup)
|
||||||
|
})
|
||||||
|
watch(activeSection, () => {
|
||||||
|
nextTick(() => {
|
||||||
|
activeGroup.value = groupNavItems.value[0]?.id || ''
|
||||||
|
syncActiveGroup()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.system-settings { display: grid; gap: 22px; color: var(--admin-mobile-ink); }
|
.system-settings { display: grid; gap: 14px; color: var(--admin-mobile-ink); }
|
||||||
.settings-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
|
.settings-topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 10px; border-bottom: 1px solid var(--admin-mobile-border); }
|
||||||
.settings-eyebrow { color: var(--theme-primary-action); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
|
.settings-tabs { display: flex; align-items: center; gap: 26px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
|
||||||
.settings-header h1 { margin: 7px 0 4px; font-size: 27px; }
|
.settings-tabs::-webkit-scrollbar { display: none; }
|
||||||
.settings-header p, .pane-head p { margin: 0; color: var(--admin-mobile-muted); font-size: 13px; }
|
.settings-tab { position: relative; padding: 8px 1px 9px; border: 0; background: none; color: var(--admin-mobile-muted); font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
|
||||||
.settings-health, .account-status { display: inline-flex; align-items: center; gap: 7px; color: var(--admin-mobile-muted); font-size: 12px; white-space: nowrap; }
|
.settings-tab:hover { color: var(--theme-primary-action); }
|
||||||
.settings-health i, .account-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--theme-primary); }
|
.settings-tab.is-active { color: var(--admin-mobile-ink); font-weight: 600; }
|
||||||
.settings-layout { display: grid; grid-template-columns: 214px minmax(0, 1fr); gap: 22px; align-items: start; }
|
.settings-tab.is-active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -11px; height: 2px; border-radius: 2px; background: var(--theme-primary); }
|
||||||
.settings-nav { padding: 9px; border: 1px solid var(--admin-mobile-border); border-radius: 16px; background: color-mix(in srgb, var(--theme-card-bg) 84%, transparent); }
|
.settings-health { display: inline-flex; align-items: center; gap: 7px; color: var(--admin-mobile-muted); font-size: 12px; white-space: nowrap; }
|
||||||
.settings-nav__label { display: block; padding: 7px 10px 8px; color: var(--admin-mobile-muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
|
.settings-health i { width: 7px; height: 7px; border-radius: 50%; background: var(--theme-primary); }
|
||||||
.settings-nav__item { display: flex; width: 100%; align-items: center; gap: 9px; padding: 11px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--admin-mobile-muted); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
|
.settings-body { display: grid; grid-template-columns: 194px minmax(0, 1fr); gap: 18px; align-items: start; }
|
||||||
.settings-nav__item:hover, .settings-nav__item.is-active { background: var(--admin-mobile-accent-soft); color: var(--theme-primary-action); font-weight: 700; }
|
.settings-subnav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 2px; padding: 8px; border: 1px solid var(--admin-mobile-border); border-radius: 12px; background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent); }
|
||||||
.settings-nav__icon { display: inline-flex; width: 22px; justify-content: center; color: var(--theme-primary); }
|
.settings-subnav__label { padding: 6px 8px 8px; color: var(--admin-mobile-muted); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
|
||||||
.settings-nav__hint { margin: 13px 8px 5px; padding-top: 12px; border-top: 1px solid var(--admin-mobile-border); color: var(--admin-mobile-muted); font-size: 11px; line-height: 1.55; }
|
.settings-subnav__item { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px; min-height: 34px; padding: 7px 9px; border: 0; border-radius: 7px; background: none; color: var(--admin-mobile-muted); font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
|
||||||
.settings-pane, .settings-section-panel { min-width: 0; }
|
.settings-subnav__item:hover { background: color-mix(in srgb, var(--theme-primary) 6%, transparent); color: var(--theme-primary-action); }
|
||||||
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 2px 0 14px; border-bottom: 1px solid var(--admin-mobile-border); }
|
.settings-subnav__item.is-active { background: var(--admin-mobile-accent-soft); color: var(--theme-primary-action); font-weight: 700; }
|
||||||
.pane-head h2 { margin: 0 0 5px; font-size: 18px; }
|
.settings-subnav__item em { flex: none; min-width: 18px; height: 18px; padding: 0 5px; border: 1px solid var(--admin-mobile-border); border-radius: 9px; background: var(--theme-card-bg); color: var(--admin-mobile-muted); font-size: 10px; font-style: normal; line-height: 16px; text-align: center; }
|
||||||
.setting-group { margin-top: 17px; border-top: 1px solid var(--admin-mobile-border); }
|
.settings-content { min-width: 0; }
|
||||||
.setting-group__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 13px 2px 8px; }
|
.settings-groups { display: flex; flex-direction: column; gap: 14px; }
|
||||||
.setting-group__head--with-action { align-items: center; }
|
.settings-group { min-width: 0; scroll-margin-top: 16px; border: 1px solid var(--admin-mobile-border); border-radius: 14px; background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent); box-shadow: 0 1px 2px rgba(23, 33, 31, .03); }
|
||||||
.setting-group__head--with-action .ant-btn { margin-left: auto; }
|
.settings-group__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 15px 18px 12px; border-bottom: 1px solid var(--admin-mobile-border); }
|
||||||
.setting-group__head strong { font-size: 13px; }
|
.settings-group__head-main { min-width: 0; }
|
||||||
.setting-group__head span { color: var(--admin-mobile-muted); font-size: 11px; letter-spacing: .08em; }
|
.settings-group__title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
||||||
.setting-row { display: grid; grid-template-columns: minmax(170px, 1fr) minmax(220px, 1.35fr) auto; align-items: center; gap: 18px; min-height: 72px; padding: 10px 14px; border-bottom: 1px solid color-mix(in srgb, var(--admin-mobile-border) 70%, transparent); background: color-mix(in srgb, var(--theme-card-bg) 82%, transparent); }
|
.settings-group__title h2 { margin: 0; font-size: 15px; font-weight: 600; }
|
||||||
.setting-row:first-of-type { border-radius: 10px 10px 0 0; }
|
.settings-group__desc { margin: 4px 0 0; color: var(--admin-mobile-muted); font-size: 11.5px; line-height: 1.55; }
|
||||||
.setting-row--last { border-radius: 0 0 10px 10px; }
|
.settings-group__actions { display: flex; flex: none; flex-wrap: wrap; align-items: center; gap: 8px; }
|
||||||
.setting-copy { display: grid; gap: 4px; min-width: 0; }
|
.settings-group__body { padding: 15px 18px 17px; }
|
||||||
.setting-copy strong { font-size: 13px; }
|
.settings-group__footnote { margin: 12px 0 0; color: var(--admin-mobile-muted); font-size: 11px; line-height: 1.65; }
|
||||||
.setting-copy__link { display: inline-flex; align-items: center; gap: 3px; margin-left: 7px; color: var(--theme-primary-action); font-size: 11px; font-weight: 650; text-decoration: none; white-space: nowrap; }
|
.tag { flex: none; padding: 1px 6px; border: 1px solid var(--admin-mobile-border); border-radius: 5px; background: color-mix(in srgb, var(--theme-primary) 5%, var(--theme-card-bg)); color: var(--admin-mobile-muted); font-size: 10px; font-weight: 600; letter-spacing: .08em; }
|
||||||
|
.meta { flex: none; color: var(--admin-mobile-muted); font-size: 11px; white-space: nowrap; }
|
||||||
|
.field-grid { display: grid; gap: 12px; }
|
||||||
|
.field-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||||
|
.field-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
||||||
|
.field { display: flex; flex-direction: column; min-width: 0; padding: 12px 14px 11px; border: 1px solid var(--admin-mobile-border); border-radius: 10px; background: color-mix(in srgb, var(--theme-primary) 2%, var(--theme-card-bg)); }
|
||||||
|
.field--wide { grid-column: span 2; }
|
||||||
|
.field__head { display: flex; align-items: center; gap: 7px; min-width: 0; }
|
||||||
|
.field__label { font-size: 13px; font-weight: 600; }
|
||||||
|
.field__desc { min-height: 32px; margin: 3px 0 10px; color: var(--admin-mobile-muted); font-size: 11px; line-height: 1.5; overflow: hidden; }
|
||||||
|
.field__control { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; margin-top: auto; }
|
||||||
|
.field__control :deep(.ant-select) { width: 100%; }
|
||||||
|
.field__control--password > :deep(.ant-input-affix-wrapper) { flex: 1; width: auto; min-width: 100px; }
|
||||||
|
.field__value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--admin-mobile-ink); font-size: 13px; font-weight: 650; }
|
||||||
|
.field__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 10px; padding-top: 9px; border-top: 1px dashed color-mix(in srgb, var(--admin-mobile-border) 80%, transparent); }
|
||||||
|
.field__save { margin-left: auto; }
|
||||||
|
.inline-field { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(220px, .85fr) auto; gap: 16px; align-items: center; }
|
||||||
|
.inline-field__copy { display: grid; gap: 3px; min-width: 0; }
|
||||||
|
.inline-field__copy strong { font-size: 13px; }
|
||||||
|
.inline-field__copy span { color: var(--admin-mobile-muted); font-size: 11px; line-height: 1.5; }
|
||||||
|
.inline-field__control { display: flex; align-items: center; gap: 8px; min-width: 0; }
|
||||||
|
.inline-field__control :deep(.ant-select) { width: 100%; }
|
||||||
|
.inline-field__control > :deep(.ant-input-group-wrapper) { width: min(240px, 100%); }
|
||||||
|
.inline-field__foot { display: flex; align-items: center; gap: 8px; }
|
||||||
|
.setting-copy__link { display: inline-flex; align-items: center; gap: 3px; color: var(--theme-primary-action); font-size: 11px; font-weight: 650; text-decoration: none; white-space: nowrap; }
|
||||||
.setting-copy__link:hover { text-decoration: underline; }
|
.setting-copy__link:hover { text-decoration: underline; }
|
||||||
.setting-copy__link:focus-visible { outline: 2px solid color-mix(in srgb, var(--theme-primary) 55%, transparent); outline-offset: 2px; border-radius: 3px; }
|
.setting-copy__link:focus-visible { outline: 2px solid color-mix(in srgb, var(--theme-primary) 55%, transparent); outline-offset: 2px; border-radius: 3px; }
|
||||||
.setting-copy__link :deep(.anticon) { font-size: 10px; }
|
.setting-copy__link :deep(.anticon) { font-size: 10px; }
|
||||||
.setting-copy span { color: var(--admin-mobile-muted); font-size: 11px; line-height: 1.45; }
|
|
||||||
.setting-control { display: flex; align-items: center; gap: 9px; min-width: 0; }
|
|
||||||
.setting-control > :deep(.ant-select) { width: 100%; }
|
|
||||||
.setting-control--password > :deep(.ant-input-affix-wrapper) { flex: 1; width: auto; min-width: 100px; }
|
|
||||||
.setting-control--password { min-width: 0; }
|
|
||||||
.setting-control--joined { min-width: 0; }
|
|
||||||
.setting-control--joined > :deep(.ant-input) { flex: 1; min-width: 0; }
|
|
||||||
.setting-control--joined > :deep(.ant-btn) { flex: 0 0 auto; }
|
|
||||||
.setting-control--number { width: min(220px, 100%); }
|
|
||||||
.storage-order-row { grid-template-columns: minmax(170px, 1fr) minmax(220px, 1.35fr) auto; }
|
|
||||||
.storage-order-list { display: grid; gap: 5px; min-width: 0; }
|
|
||||||
.storage-order-item { display: flex; align-items: center; gap: 9px; min-height: 34px; padding: 3px 7px; border: 1px solid var(--admin-mobile-border); border-radius: 7px; background: var(--theme-card-bg); }
|
|
||||||
.storage-order-index { display: inline-flex; width: 20px; height: 20px; align-items: center; justify-content: center; border-radius: 50%; background: var(--admin-mobile-accent-soft); color: var(--theme-primary-action); font-size: 11px; font-weight: 750; }
|
|
||||||
.storage-order-item strong { flex: 1; color: var(--admin-mobile-ink); font-size: 12px; }
|
|
||||||
.storage-order-actions { display: flex; }
|
|
||||||
.storage-order-actions :deep(.ant-btn) { width: 26px; height: 26px; padding: 0; }
|
|
||||||
.control-note { color: var(--admin-mobile-muted); font-size: 11px; white-space: nowrap; }
|
.control-note { color: var(--admin-mobile-muted); font-size: 11px; white-space: nowrap; }
|
||||||
.setting-row > .control-note { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
|
|
||||||
.setting-value { min-width: 0; color: var(--admin-mobile-ink); font-size: 13px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
||||||
.status-pill { display: inline-flex; align-items: center; gap: 5px; color: var(--theme-primary-action); font-size: 11px; white-space: nowrap; }
|
.status-pill { display: inline-flex; align-items: center; gap: 5px; color: var(--theme-primary-action); font-size: 11px; white-space: nowrap; }
|
||||||
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--theme-primary); }
|
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--theme-primary); }
|
||||||
.status-pill.is-muted { color: var(--admin-mobile-muted); }
|
.status-pill.is-muted { color: var(--admin-mobile-muted); }
|
||||||
.status-pill.is-muted::before { background: var(--admin-mobile-muted); }
|
.status-pill.is-muted::before { background: var(--admin-mobile-muted); }
|
||||||
.warning-note { display: inline-flex; align-items: center; gap: 5px; color: #a66d22; font-size: 11px; white-space: nowrap; }
|
.warning-note { display: inline-flex; align-items: center; gap: 5px; color: #a66d22; font-size: 11px; white-space: nowrap; }
|
||||||
.warning-note::before { content: '!'; display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; background: #fff3d9; font-size: 10px; font-weight: 800; }
|
.warning-note::before { content: '!'; display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; background: #fff3d9; font-size: 10px; font-weight: 800; }
|
||||||
.secure-note { margin: 0; padding: 12px 14px; color: var(--admin-mobile-muted); font-size: 12px; line-height: 1.65; background: color-mix(in srgb, var(--theme-primary) 7%, var(--theme-card-bg)); }
|
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; background: color-mix(in srgb, var(--admin-mobile-muted) 8%, var(--theme-card-bg)); color: var(--admin-mobile-muted); font-size: 11px; white-space: nowrap; }
|
||||||
.probe-group { overflow: hidden; }
|
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
|
||||||
.probe-list { display: grid; gap: 8px; }
|
.pill--pass { background: var(--admin-mobile-accent-soft); color: var(--theme-primary-action); }
|
||||||
.probe-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px 14px; align-items: center; padding: 11px 14px; border: 1px solid var(--admin-mobile-border); border-radius: 10px; background: color-mix(in srgb, var(--theme-card-bg) 82%, transparent); }
|
.pill--warn, .pill--pending { background: #FFF7E6; color: #AD6800; }
|
||||||
.probe-row__copy { display: grid; gap: 3px; min-width: 0; }
|
.pill--fail { background: #FFF1F0; color: var(--ant-color-error); }
|
||||||
.probe-row__copy strong { font-size: 13px; }
|
.pill--idle { background: color-mix(in srgb, var(--admin-mobile-muted) 8%, var(--theme-card-bg)); color: var(--admin-mobile-muted); }
|
||||||
.probe-row__copy span, .probe-row__copy small { color: var(--admin-mobile-muted); font-size: 11px; line-height: 1.4; }
|
.svc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
|
||||||
.probe-row__copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
.svc { display: flex; flex-direction: column; gap: 9px; min-width: 0; padding: 12px 14px; border: 1px solid var(--admin-mobile-border); border-radius: 10px; background: color-mix(in srgb, var(--theme-primary) 2%, var(--theme-card-bg)); }
|
||||||
.probe-actions { display: grid; gap: 8px; min-width: min(100%, 410px); }
|
.svc__head { display: flex; align-items: center; gap: 8px; min-width: 0; }
|
||||||
.probe-action { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 5px 9px; align-items: center; padding-top: 7px; border-top: 1px solid var(--admin-mobile-border); }
|
.svc__name { flex: none; font-size: 13px; font-weight: 600; white-space: nowrap; }
|
||||||
.probe-action:first-child { padding-top: 0; border-top: 0; }
|
.svc__desc { flex: 1 1 auto; min-width: 0; color: var(--admin-mobile-muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||||
.probe-action > small { grid-column: 1 / -1; color: var(--admin-mobile-muted); font-size: 10px; line-height: 1.4; overflow-wrap: anywhere; }
|
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||||
.probe-details { grid-column: 1 / -1; margin: -2px 0 -5px; }
|
.chip { display: inline-flex; align-items: center; gap: 5px; height: 29px; padding: 0 8px; border: 1px solid var(--admin-mobile-border); border-radius: 8px; background: var(--theme-card-bg); color: var(--admin-mobile-ink); font: inherit; font-size: 11px; cursor: pointer; transition: border-color .15s, background .15s; }
|
||||||
.probe-details :deep(.ant-collapse-header) { padding: 4px 0 !important; color: var(--theme-primary-action) !important; font-size: 11px; }
|
.chip:hover { border-color: color-mix(in srgb, var(--theme-primary) 40%, var(--admin-mobile-border)); background: color-mix(in srgb, var(--theme-primary) 4%, var(--theme-card-bg)); }
|
||||||
.probe-details :deep(.ant-collapse-content-box) { padding: 4px 0 0 !important; }
|
.chip.is-open { border-color: var(--theme-primary); background: var(--admin-mobile-accent-soft); }
|
||||||
.probe-check { display: grid; grid-template-columns: minmax(90px, 150px) 56px minmax(0, 1fr); gap: 8px; align-items: baseline; padding: 4px 0; border-top: 1px dashed var(--admin-mobile-border); font-size: 11px; }
|
.chip__dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: #A9B4AE; }
|
||||||
.probe-check em { font-style: normal; font-weight: 700; }
|
.chip__dot--pass { background: var(--theme-primary); }
|
||||||
.probe-check small { min-width: 0; color: var(--admin-mobile-muted); overflow-wrap: anywhere; }
|
.chip__dot--warn, .chip__dot--pending { background: #D48806; }
|
||||||
.probe-check--pass { color: var(--theme-primary-action); }
|
.chip__dot--fail { background: var(--ant-color-error); }
|
||||||
.probe-check--warn, .probe-check--pending { color: #a66d22; }
|
.chip__dot--idle { background: #B7C1BC; }
|
||||||
.probe-check--fail { color: var(--ant-color-error); }
|
.chip__status { font-weight: 600; }
|
||||||
|
.chip--pass .chip__status { color: var(--theme-primary-action); }
|
||||||
|
.chip--warn .chip__status, .chip--pending .chip__status { color: #AD6800; }
|
||||||
|
.chip--fail .chip__status { color: var(--ant-color-error); }
|
||||||
|
.chip--idle .chip__status { color: var(--admin-mobile-muted); font-weight: 500; }
|
||||||
|
.chip__time { color: var(--admin-mobile-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
|
||||||
|
.chip__chev { display: inline-flex; color: #9AA7A1; transition: transform .15s; }
|
||||||
|
.chip.is-open .chip__chev { transform: rotate(180deg); color: var(--theme-primary-action); }
|
||||||
|
.svc__detail { padding: 8px 10px 9px; border: 1px solid var(--admin-mobile-border); border-radius: 8px; background: color-mix(in srgb, var(--theme-primary) 3%, var(--theme-card-bg)); }
|
||||||
|
.probe-detail + .probe-detail { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--admin-mobile-border); }
|
||||||
|
.probe-detail__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--admin-mobile-muted); font-size: 10.5px; }
|
||||||
|
.probe-detail__summary { margin: 4px 0 0; color: var(--admin-mobile-muted); font-size: 11px; }
|
||||||
|
.check-row { display: grid; grid-template-columns: minmax(88px, 132px) 56px minmax(0, 1fr); gap: 8px; align-items: baseline; padding: 5px 0; border-top: 1px dashed color-mix(in srgb, var(--admin-mobile-border) 80%, transparent); font-size: 11px; }
|
||||||
|
.check-row:first-of-type, .probe-detail__summary + .check-row { border-top: 0; }
|
||||||
|
.check-row em { font-style: normal; font-weight: 600; }
|
||||||
|
.check-row small { min-width: 0; color: var(--admin-mobile-muted); overflow-wrap: anywhere; }
|
||||||
|
.check-row__status--pass { color: var(--theme-primary-action); }
|
||||||
|
.check-row__status--warn, .check-row__status--pending { color: #AD6800; }
|
||||||
|
.check-row__status--fail { color: var(--ant-color-error); }
|
||||||
|
.secure-note { margin: 0; padding: 12px 14px; color: var(--admin-mobile-muted); font-size: 12px; line-height: 1.65; background: color-mix(in srgb, var(--theme-primary) 7%, var(--theme-card-bg)); border-radius: 8px; }
|
||||||
.secure-note__warning { display: block; margin-top: 6px; color: #8a4b0d; font-weight: 650; }
|
.secure-note__warning { display: block; margin-top: 6px; color: #8a4b0d; font-weight: 650; }
|
||||||
.secure-guide { margin: 0 12px 12px; padding: 14px 16px; background: color-mix(in srgb, var(--admin-mobile-accent-soft) 55%, var(--theme-card-bg)); color: var(--admin-mobile-ink); font-size: 12px; line-height: 1.65; }
|
.secure-guide { margin: 14px 0 0; padding: 14px 16px; border-radius: 8px; background: color-mix(in srgb, var(--admin-mobile-accent-soft) 55%, var(--theme-card-bg)); color: var(--admin-mobile-ink); font-size: 12px; line-height: 1.65; }
|
||||||
.secure-guide > strong { font-size: 13px; }
|
.secure-guide > strong { font-size: 13px; }
|
||||||
.secure-guide ol { margin: 8px 0 10px; padding-left: 19px; color: var(--admin-mobile-muted); }
|
.secure-guide ol { margin: 8px 0 10px; padding-left: 19px; color: var(--admin-mobile-muted); }
|
||||||
.secure-guide li + li { margin-top: 4px; }
|
.secure-guide li + li { margin-top: 4px; }
|
||||||
@@ -911,25 +1136,50 @@ onMounted(() => {
|
|||||||
.secure-guide__links a { display: inline-flex; align-items: center; gap: 5px; color: var(--theme-primary-action); text-decoration: none; }
|
.secure-guide__links a { display: inline-flex; align-items: center; gap: 5px; color: var(--theme-primary-action); text-decoration: none; }
|
||||||
.secure-guide__links a:hover { text-decoration: underline; }
|
.secure-guide__links a:hover { text-decoration: underline; }
|
||||||
.secure-guide__links a:focus-visible { outline: 2px solid color-mix(in srgb, var(--theme-primary) 55%, transparent); outline-offset: 2px; }
|
.secure-guide__links a:focus-visible { outline: 2px solid color-mix(in srgb, var(--theme-primary) 55%, transparent); outline-offset: 2px; }
|
||||||
.section-footnote { margin: 12px 2px 0; color: var(--admin-mobile-muted); font-size: 11px; }
|
.storage-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 1.1fr) auto; gap: 18px; align-items: center; }
|
||||||
|
.storage-order-list { display: grid; gap: 5px; min-width: 0; }
|
||||||
|
.storage-order-item { display: flex; align-items: center; gap: 9px; min-height: 34px; padding: 3px 7px; border: 1px solid var(--admin-mobile-border); border-radius: 7px; background: var(--theme-card-bg); }
|
||||||
|
.storage-order-index { display: inline-flex; width: 20px; height: 20px; align-items: center; justify-content: center; border-radius: 50%; background: var(--admin-mobile-accent-soft); color: var(--theme-primary-action); font-size: 11px; font-weight: 750; }
|
||||||
|
.storage-order-item strong { flex: 1; color: var(--admin-mobile-ink); font-size: 12px; }
|
||||||
|
.storage-order-actions { display: flex; }
|
||||||
|
.storage-order-actions :deep(.ant-btn) { width: 26px; height: 26px; padding: 0; }
|
||||||
|
.account-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
|
||||||
|
.account-tile { display: flex; flex-direction: column; gap: 7px; min-width: 0; padding: 13px 15px; border: 1px solid var(--admin-mobile-border); border-radius: 10px; background: color-mix(in srgb, var(--theme-primary) 2%, var(--theme-card-bg)); }
|
||||||
|
.account-tile__label { color: var(--admin-mobile-muted); font-size: 11px; }
|
||||||
|
.account-tile strong { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
|
.account-tile__foot { display: flex; align-items: center; gap: 8px; }
|
||||||
|
@media (max-width: 1280px) {
|
||||||
|
.field-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||||
|
.field--wide { grid-column: auto; }
|
||||||
|
}
|
||||||
|
@media (max-width: 1180px) {
|
||||||
|
.settings-body { grid-template-columns: 1fr; gap: 12px; }
|
||||||
|
.settings-subnav { position: static; flex-direction: row; align-items: center; gap: 4px; padding: 7px; overflow-x: auto; scrollbar-width: none; }
|
||||||
|
.settings-subnav::-webkit-scrollbar { display: none; }
|
||||||
|
.settings-subnav__label { display: none; }
|
||||||
|
.settings-subnav__item { width: auto; flex: none; min-height: 30px; padding: 5px 10px; white-space: nowrap; }
|
||||||
|
}
|
||||||
|
@media (max-width: 960px) {
|
||||||
|
.field-grid.cols-2, .field-grid.cols-3 { grid-template-columns: 1fr; }
|
||||||
|
.field__desc { min-height: 0; }
|
||||||
|
.svc-grid { grid-template-columns: 1fr; }
|
||||||
|
.inline-field { grid-template-columns: 1fr; gap: 10px; }
|
||||||
|
.inline-field__foot { justify-self: start; }
|
||||||
|
.storage-row { grid-template-columns: 1fr; gap: 10px; }
|
||||||
|
.account-grid { grid-template-columns: 1fr; }
|
||||||
|
.account-tile strong { font-size: 15px; }
|
||||||
|
.check-row { grid-template-columns: 1fr auto; }
|
||||||
|
.check-row small { grid-column: 1 / -1; }
|
||||||
|
}
|
||||||
@media (max-width: 760px) {
|
@media (max-width: 760px) {
|
||||||
.settings-header { align-items: flex-start; }
|
.settings-health { display: none; }
|
||||||
.settings-health, .account-status { display: none; }
|
.settings-tabs { gap: 18px; }
|
||||||
.settings-layout { grid-template-columns: 1fr; gap: 14px; }
|
.settings-tab { font-size: 13px; }
|
||||||
.settings-nav { display: flex; gap: 4px; overflow-x: auto; padding: 6px; }
|
.settings-group__head { flex-wrap: wrap; padding: 13px 14px 11px; }
|
||||||
.settings-nav__label, .settings-nav__hint { display: none; }
|
.settings-group__actions { width: 100%; justify-content: flex-end; }
|
||||||
.settings-nav__item { width: auto; flex: 0 0 auto; white-space: nowrap; }
|
.settings-group__body { padding: 13px 14px 15px; }
|
||||||
.pane-head { align-items: flex-start; flex-direction: column; }
|
.svc__desc { white-space: normal; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
|
||||||
.pane-head .ant-btn { width: 100%; }
|
.field__save { margin-left: 0; }
|
||||||
.setting-group__head--with-action { flex-wrap: wrap; }
|
|
||||||
.setting-group__head--with-action .ant-btn { width: 100%; margin-left: 0; }
|
|
||||||
.setting-row { grid-template-columns: 1fr; gap: 9px; padding: 13px 12px; }
|
|
||||||
.setting-control { width: 100%; }
|
|
||||||
.storage-order-row { grid-template-columns: 1fr; }
|
|
||||||
.status-pill, .warning-note, .control-note { justify-self: start; }
|
|
||||||
.probe-row { grid-template-columns: 1fr; }
|
|
||||||
.probe-actions { min-width: 0; }
|
|
||||||
.probe-check { grid-template-columns: 1fr auto; }
|
|
||||||
.probe-check small { grid-column: 1 / -1; }
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,16 @@
|
|||||||
spring:
|
spring:
|
||||||
datasource:
|
datasource:
|
||||||
url: jdbc:mysql://192.168.5.15:3306/jayucloud_artlist?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
url: jdbc:mysql://192.168.5.15:3306/jayucloud_artlist?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
||||||
|
flyway:
|
||||||
|
enabled: true
|
||||||
|
locations: classpath:db/migration
|
||||||
|
schemas: [jayucloud_artlist]
|
||||||
|
default-schema: jayucloud_artlist
|
||||||
|
create-schemas: false
|
||||||
|
baseline-on-migrate: false
|
||||||
|
validate-on-migrate: true
|
||||||
|
clean-disabled: true
|
||||||
|
out-of-order: false
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
max-file-size: 5MB
|
max-file-size: 5MB
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ spring:
|
|||||||
redis:
|
redis:
|
||||||
host: 192.168.5.15
|
host: 192.168.5.15
|
||||||
port: 6379
|
port: 6379
|
||||||
database: 0
|
database: 1
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
addresses: 192.168.5.15:5672
|
addresses: 192.168.5.15:5672
|
||||||
virtual-host: /jayucloud-artlist-dev
|
virtual-host: /jayucloud-artlist-dev
|
||||||
|
|||||||
@@ -1,6 +1,16 @@
|
|||||||
spring:
|
spring:
|
||||||
datasource:
|
datasource:
|
||||||
url: jdbc:mysql://192.168.10.200:6033/jayucloud_artlist?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
url: jdbc:mysql://192.168.10.200:6033/jayucloud_artlist?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
||||||
|
flyway:
|
||||||
|
enabled: true
|
||||||
|
locations: classpath:db/migration
|
||||||
|
schemas: [jayucloud_artlist]
|
||||||
|
default-schema: jayucloud_artlist
|
||||||
|
create-schemas: false
|
||||||
|
baseline-on-migrate: false
|
||||||
|
validate-on-migrate: true
|
||||||
|
clean-disabled: true
|
||||||
|
out-of-order: false
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
max-file-size: 5MB
|
max-file-size: 5MB
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ spring:
|
|||||||
sentinel:
|
sentinel:
|
||||||
master: mymaster
|
master: mymaster
|
||||||
nodes: 192.168.10.17:26379,192.168.10.18:26379,192.168.10.19:26379,192.168.20.13:26379,10.66.0.4:26379
|
nodes: 192.168.10.17:26379,192.168.10.18:26379,192.168.10.19:26379,192.168.20.13:26379,10.66.0.4:26379
|
||||||
database: 0
|
database: 1
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
addresses: mq-prod.internal:5672
|
addresses: mq-prod.internal:5672
|
||||||
virtual-host: /jayucloud-artlist
|
virtual-host: /jayucloud-artlist
|
||||||
|
|||||||
@@ -1,6 +1,16 @@
|
|||||||
spring:
|
spring:
|
||||||
datasource:
|
datasource:
|
||||||
url: jdbc:mysql://192.168.10.11:3306/jayucloud_artlist?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
url: jdbc:mysql://192.168.10.11:3306/jayucloud_artlist?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
||||||
|
flyway:
|
||||||
|
enabled: true
|
||||||
|
locations: classpath:db/migration
|
||||||
|
schemas: [jayucloud_artlist]
|
||||||
|
default-schema: jayucloud_artlist
|
||||||
|
create-schemas: false
|
||||||
|
baseline-on-migrate: false
|
||||||
|
validate-on-migrate: true
|
||||||
|
clean-disabled: true
|
||||||
|
out-of-order: false
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
max-file-size: 5MB
|
max-file-size: 5MB
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ spring:
|
|||||||
redis:
|
redis:
|
||||||
host: 192.168.10.12
|
host: 192.168.10.12
|
||||||
port: 6379
|
port: 6379
|
||||||
database: 0
|
database: 1
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
addresses: 192.168.10.13:5672
|
addresses: 192.168.10.13:5672
|
||||||
virtual-host: /jayucloud-artlist-sit
|
virtual-host: /jayucloud-artlist-sit
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
# ArtList 数据迁移与会话隔离配置说明
|
||||||
|
|
||||||
|
- 日期:2026-11-04
|
||||||
|
- 范围:`JC-ArtList-Core` 的 Flyway 数据库迁移接入、Redis 会话库隔离
|
||||||
|
- 涉及配置:`nacos/namespaces/{dev,sit,prod}/jayucloud-artlist/DEFAULT_GROUP/core.yaml`、同目录 `infra.yaml`
|
||||||
|
|
||||||
|
## 一、本次改了什么
|
||||||
|
|
||||||
|
1. **接入 Flyway(dev/sit/prod 三环境一致)**
|
||||||
|
- `JC-ArtList-Core/pom.xml` 增加 `flyway-core`、`flyway-mysql`,版本由 Spring Boot 2.7.18 统一管理(与 `JC-Salon-Core` 相同,不单独指定版本)。
|
||||||
|
- `core.yaml` 新增 `spring.flyway`:
|
||||||
|
- `enabled=true`、`locations=classpath:db/migration`
|
||||||
|
- `schemas=[jayucloud_artlist]`、`default-schema=jayucloud_artlist`、`create-schemas=false`
|
||||||
|
- `baseline-on-migrate=false`(**不使用 baseline**,空库直接从 `V1` 全量执行;不再配置 `baseline-version`,该属性仅在 baseline 时生效,保留只会误导后来人)
|
||||||
|
- `validate-on-migrate=true`、`clean-disabled=true`、`out-of-order=false`
|
||||||
|
- 新增迁移 `JC-ArtList-Core/src/main/resources/db/migration/V1__ArtList基线冻结_20261104.sql`,由 `docs/scripts/sql/init/jayucloud-artlist.sql` 规范化而来:建表 `IF NOT EXISTS`、索引经幂等存储过程创建、种子数据可重复执行、删除重复 DDL。**`V1` 即空库初始化脚本,后续结构/数据变更一律以版本化增量文件(`V2`、`V3`…)追加,不得修改或删除已执行的迁移文件。**
|
||||||
|
|
||||||
|
> **口径:不做数据迁移,空库从 V1 全量初始化。** 三个环境均按此口径执行,不存在“把存量库 baseline 到 V1”的场景。
|
||||||
|
|
||||||
|
2. **Redis 会话库迁移**
|
||||||
|
- ArtList 的 `spring.redis.database` 从 `0` 改为 `1`,与 Salon 的 `0` 分开,避免两者会话 key 空间互相干扰。
|
||||||
|
- 会话 key 前缀统一为 `artlist:auth:session:` 与 `artlist:auth:user:sessions:`,覆盖登录校验、刷新令牌、踢下线等全部读写路径。
|
||||||
|
|
||||||
|
## 二、三环境配置差异与同步状态
|
||||||
|
|
||||||
|
| 环境 | Flyway 配置 | Redis database | 同步状态 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| dev | 已配置,`baseline-on-migrate=false`(空库从 V1 初始化) | 1(本机 Redis,单机) | 已同步 |
|
||||||
|
| sit | 已配置,`baseline-on-migrate=false`(空库从 V1 初始化) | 1(本机 Redis,单机) | 已同步 |
|
||||||
|
| prod | 已配置,`baseline-on-migrate=false`(空库从 V1 初始化) | 1(Sentinel 集群,仅库号变化) | 已同步 |
|
||||||
|
|
||||||
|
结构差异说明:dev/sit 的 Redis 为 `host + port` 单机配置,prod 为 `sentinel` 哨兵配置;本次仅改 `database` 数值,未改动连接方式与其他项。三个环境均无第二处 Redis 库号配置(`secret.yaml` 中只有账号密码,不涉及库号)。
|
||||||
|
|
||||||
|
## 三、上线影响
|
||||||
|
|
||||||
|
1. **Flyway 采用“空库初始化”口径**
|
||||||
|
- 空库(schema 存在但无表、无 `flyway_schema_history`):启动后从 `V1` 全量执行建表与种子数据,并创建 `flyway_schema_history`。
|
||||||
|
- **指向“已有表但没有 `flyway_schema_history`”的库**:`baseline-on-migrate=false` 时 Flyway 会做校验并发现 V1 与库中现状不一致,**validate 失败并拒绝启动**。这是预期行为,不是故障,也不代表配置写错。
|
||||||
|
- 出现上述拒绝启动时,**正确做法是先清空/重建 `jayucloud_artlist` 再启动**(步骤见第四节),不要通过改回 baseline、删 `flyway_schema_history` 或手工填 history 来绕过。
|
||||||
|
- `create-schemas=false`:schema 必须事先存在;`clean-disabled=true` 已禁止 Flyway 通过命令清库;`validate-on-migrate=true` 会在校验和不一致时阻止启动。
|
||||||
|
|
||||||
|
2. **Redis 换库会导致所有已登录用户掉线**
|
||||||
|
- 切换后旧库(db 0)中的会话不再被读取,已登录用户需重新登录。
|
||||||
|
- 本地 Caffeine 缓存随换库冷启动,首屏可能出现一次回源延迟。
|
||||||
|
- 旧库中的历史会话 key 不会被自动清理,可按需手工清理。
|
||||||
|
|
||||||
|
## 四、dev 环境清库初始化步骤(操作建议,需人工执行)
|
||||||
|
|
||||||
|
> 本节仅为文档化操作建议,不会由任何流水线自动执行;执行前请确认目标实例与环境,避免误连 sit/prod。
|
||||||
|
|
||||||
|
1. **备份(不迁移数据,但建议留一份兜底)**
|
||||||
|
```bash
|
||||||
|
mysqldump -h <dev-mysql-host> -P <port> -u <user> -p \
|
||||||
|
--single-transaction --routines --triggers --no-data \
|
||||||
|
jayucloud_artlist > jayucloud_artlist_dev_struct_20261104.sql
|
||||||
|
mysqldump -h <dev-mysql-host> -P <port> -u <user> -p \
|
||||||
|
--single-transaction jayucloud_artlist > jayucloud_artlist_dev_full_20261104.sql
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **清空并重建 schema**
|
||||||
|
```sql
|
||||||
|
DROP DATABASE IF EXISTS jayucloud_artlist;
|
||||||
|
CREATE DATABASE jayucloud_artlist
|
||||||
|
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||||
|
```
|
||||||
|
说明:`create-schemas=false`,Flyway 不会自动建库,必须先手工创建空 schema。
|
||||||
|
|
||||||
|
3. **发布配置并重启 `JC-ArtList-Core`**
|
||||||
|
- 确认 Nacos 中 dev 的 `core.yaml` 已是 `baseline-on-migrate: false` 且不含 `baseline-version`。
|
||||||
|
- 重启后 Flyway 从 `V1` 全量初始化。
|
||||||
|
|
||||||
|
4. **重启后确认**
|
||||||
|
```sql
|
||||||
|
SHOW TABLES FROM jayucloud_artlist LIKE 'flyway_schema_history';
|
||||||
|
SELECT installed_rank, version, description, type, success
|
||||||
|
FROM jayucloud_artlist.flyway_schema_history ORDER BY installed_rank;
|
||||||
|
SELECT COUNT(*) FROM information_schema.tables
|
||||||
|
WHERE table_schema = 'jayucloud_artlist' AND table_type = 'BASE TABLE';
|
||||||
|
```
|
||||||
|
预期:`flyway_schema_history` 存在;其中 `V1` 一条且 `success = 1`;业务表数量与 V1 建表数一致(表总数 = 业务表 + `flyway_schema_history`)。
|
||||||
|
|
||||||
|
## 五、回退方式
|
||||||
|
|
||||||
|
1. **数据库**:应用回退不会自动回滚数据库。如需撤销已执行的迁移,必须新增向前兼容的补偿迁移(新增 `V{n}` 脚本),禁止依赖 Flyway `clean`、重新 baseline 或重跑初始化脚本。
|
||||||
|
2. **Redis**:将 `spring.redis.database` 改回 `0` 即可回退到旧库;回退同样会造成一次全员掉线(新库中的会话不再被读取)。
|
||||||
|
3. **配置回退**:dev/sit/prod 的 Nacos 配置可通过仓库内各自的 Nacos 回退工作流恢复到上一个快照。
|
||||||
|
|
||||||
|
## 六、验证步骤
|
||||||
|
|
||||||
|
1. 推送配置后确认 Nacos 中对应环境的 `core.yaml`:`baseline-on-migrate=false`、无 `baseline-version`,其余 Flyway 项与本文第一节一致;`infra.yaml` 的 `database` 为 `1`。
|
||||||
|
2. 在测试环境使用临时空库验证 `V1` 可完整执行(参考做法:新建临时库,以 `locations=classpath:db/migration` 运行 Flyway,确认建表数量与种子数据后删除临时库)。
|
||||||
|
3. 启动 `JC-ArtList-Core`,检查日志中 Flyway 迁移记录与 `flyway_schema_history` 内容。
|
||||||
|
4. 重新登录一次,确认会话写入 Redis `db 1`(`INFO keyspace` 或 `KEYS artlist:auth:session:*` 使用 `-n 1`)。
|
||||||
|
5. 验证旧登录态确实失效(使用旧 token 请求应返回未登录)。
|
||||||
Reference in New Issue
Block a user