完善管理师预约项目与美甲师创建
This commit is contained in:
+6
-2
@@ -590,7 +590,7 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
List<NailArtistWorkVO> works = new ArrayList<>();
|
||||
for (Long productId : limitedIds) {
|
||||
ProductDO product = productMap.get(productId);
|
||||
if (product == null || isDeleted(product.getIsDelete())) {
|
||||
if (product == null || isDeleted(product.getIsDelete()) || !isFrontVisible(product)) {
|
||||
continue;
|
||||
}
|
||||
works.add(buildWorkVO(product, fileMap));
|
||||
@@ -667,7 +667,7 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
return new HashMap<>();
|
||||
}
|
||||
return products.stream()
|
||||
.filter(product -> product != null && product.getId() != null && !isDeleted(product.getIsDelete()))
|
||||
.filter(product -> product != null && product.getId() != null && !isDeleted(product.getIsDelete()) && isFrontVisible(product))
|
||||
.collect(Collectors.toMap(ProductDO::getId, product -> product, (left, right) -> left, HashMap::new));
|
||||
}
|
||||
|
||||
@@ -751,6 +751,10 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
return Integer.valueOf(1).equals(isDelete);
|
||||
}
|
||||
|
||||
private boolean isFrontVisible(ProductDO product) {
|
||||
return product != null && Integer.valueOf(1).equals(product.getFrontVisible());
|
||||
}
|
||||
|
||||
private LocalDateTime truncateToMinute(LocalDateTime value) {
|
||||
return value == null ? null : value.withSecond(0).withNano(0);
|
||||
}
|
||||
|
||||
+4
@@ -2,6 +2,8 @@ package com.xiaowang.fingertipdesigner.core.modules.planning.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class PlanningAppointmentCreateDTO {
|
||||
private Long customerUserId;
|
||||
@@ -14,6 +16,8 @@ public class PlanningAppointmentCreateDTO {
|
||||
private String appointmentTime;
|
||||
private String appointmentStartTime;
|
||||
private Integer durationMinutes;
|
||||
private String manualProductTitle;
|
||||
private BigDecimal manualProductPrice;
|
||||
private String remark;
|
||||
private String clientRequestId;
|
||||
}
|
||||
|
||||
+39
-1
@@ -65,6 +65,7 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
private static final int DEFAULT_DURATION_MINUTES = 60;
|
||||
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");
|
||||
@@ -136,8 +137,11 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
if (dto == null) {
|
||||
throw new RuntimeException("预约信息不能为空");
|
||||
}
|
||||
if (Integer.valueOf(3).equals(currentUser.getType())) {
|
||||
throw new RuntimeException("美甲师账号只能查看预约,不能新建预约");
|
||||
}
|
||||
Long shopId = requirePlanningShopId(currentUser);
|
||||
ProductDO product = requireActiveProduct(dto.getProductId(), shopId);
|
||||
ProductDO product = resolveAppointmentProduct(dto, shopId);
|
||||
UserDO artist = requireActiveArtist(dto.getArtistId(), shopId);
|
||||
UserDO customer = resolveCustomer(shopId, dto);
|
||||
|
||||
@@ -583,6 +587,40 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
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 = dto.getDurationMinutes() == null || dto.getDurationMinutes() <= 0
|
||||
? DEFAULT_DURATION_MINUTES
|
||||
: dto.getDurationMinutes();
|
||||
ProductDO product = new ProductDO();
|
||||
product.setShopId(shopId);
|
||||
product.setTitle(title);
|
||||
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 UserDO requireActiveArtist(Long artistId, Long shopId) {
|
||||
if (artistId == null) {
|
||||
throw new RuntimeException("请选择美甲师");
|
||||
|
||||
+4
-4
@@ -128,7 +128,7 @@ public class ProductController {
|
||||
* @return Result<ProductVO> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<ProductVO> getProductById(@PathVariable Long id) {
|
||||
ProductVO productVO = productService.getProductById(id);
|
||||
ProductVO productVO = productService.getPublicProductById(id);
|
||||
return Result.success(productVO);
|
||||
}
|
||||
|
||||
@@ -141,8 +141,8 @@ public class ProductController {
|
||||
public Result<List<ProductVO>> listAllProducts(HttpServletRequest request) {
|
||||
Long currentShopId = resolveOptionalCurrentShopId(request);
|
||||
List<ProductVO> productVOs = currentShopId == null
|
||||
? productService.listAllProducts()
|
||||
: productService.listProductsByShopId(currentShopId);
|
||||
? productService.listPublicProducts()
|
||||
: productService.listPublicProductsByShopId(currentShopId);
|
||||
return Result.success(productVOs);
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public class ProductController {
|
||||
* @return Result<List<ProductVO>> result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
public Result<List<ProductVO>> listProductsByShopId(@PathVariable Long shopId) {
|
||||
List<ProductVO> productVOs = productService.listProductsByShopId(shopId);
|
||||
List<ProductVO> productVOs = productService.listPublicProductsByShopId(shopId);
|
||||
return Result.success(productVOs);
|
||||
}
|
||||
|
||||
|
||||
+10
@@ -78,4 +78,14 @@ public class ProductDTO {
|
||||
* 可用的优惠券ID集合,多个ID以逗号分隔
|
||||
*/
|
||||
private String availableCoupons;
|
||||
|
||||
/**
|
||||
* 前台是否展示:0-隐藏,1-展示
|
||||
*/
|
||||
private Integer frontVisible;
|
||||
|
||||
/**
|
||||
* 来源类型
|
||||
*/
|
||||
private String sourceType;
|
||||
}
|
||||
|
||||
+12
@@ -99,6 +99,18 @@ public class ProductDO extends BaseEntity {
|
||||
@TableField("available_coupons")
|
||||
private String availableCoupons;
|
||||
|
||||
/**
|
||||
* 前台是否展示:0-隐藏,1-展示
|
||||
*/
|
||||
@TableField("front_visible")
|
||||
private Integer frontVisible;
|
||||
|
||||
/**
|
||||
* 来源类型:BACKEND-后台维护,MANAGER_APPOINTMENT-管理师端手动预约
|
||||
*/
|
||||
@TableField("source_type")
|
||||
private String sourceType;
|
||||
|
||||
/**
|
||||
* 逻辑删除标识:0-未删除,1-已删除
|
||||
*/
|
||||
|
||||
+6
@@ -67,6 +67,8 @@ public interface ProductService extends IService<ProductDO> {
|
||||
*/
|
||||
ProductVO getProductById(Long id);
|
||||
|
||||
ProductVO getPublicProductById(Long id);
|
||||
|
||||
/**
|
||||
* 查询所有商品
|
||||
*
|
||||
@@ -74,6 +76,8 @@ public interface ProductService extends IService<ProductDO> {
|
||||
*/
|
||||
List<ProductVO> listAllProducts();
|
||||
|
||||
List<ProductVO> listPublicProducts();
|
||||
|
||||
/**
|
||||
* 根据店铺ID查询商品
|
||||
*
|
||||
@@ -82,6 +86,8 @@ public interface ProductService extends IService<ProductDO> {
|
||||
*/
|
||||
List<ProductVO> listProductsByShopId(Long shopId);
|
||||
|
||||
List<ProductVO> listPublicProductsByShopId(Long shopId);
|
||||
|
||||
/**
|
||||
* 根据标签查询商品
|
||||
*
|
||||
|
||||
+82
-1
@@ -79,6 +79,8 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
|
||||
private static final int MAX_PUBLIC_PAGE_SIZE = 30;
|
||||
private static final Pattern DURATION_PATTERN = Pattern.compile("(\\d+)");
|
||||
private static final long DEFAULT_SERVICE_DURATION_MINUTES = 60L;
|
||||
private static final int FRONT_VISIBLE = 1;
|
||||
private static final String SOURCE_TYPE_BACKEND = "BACKEND";
|
||||
/**
|
||||
* Variable `productMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
@@ -137,6 +139,8 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
|
||||
productDO.setApproximateDuration(productDTO.getApproximateDuration());
|
||||
productDO.setBookableArtists(bookableArtistSupport.filterValidBookableArtists(productDTO.getShopId(), productDTO.getBookableArtists()));
|
||||
productDO.setAvailableCoupons(productDTO.getAvailableCoupons());
|
||||
productDO.setFrontVisible(resolveFrontVisible(productDTO.getFrontVisible()));
|
||||
productDO.setSourceType(resolveSourceType(productDTO.getSourceType()));
|
||||
productDO.setIsDelete(0);
|
||||
productMapper.insert(productDO);
|
||||
evictPublicProductCaches(productDO.getId());
|
||||
@@ -175,6 +179,8 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
|
||||
productDO.setApproximateDuration(productDTO.getApproximateDuration());
|
||||
productDO.setBookableArtists(bookableArtistSupport.filterValidBookableArtists(productDTO.getShopId(), productDTO.getBookableArtists()));
|
||||
productDO.setAvailableCoupons(productDTO.getAvailableCoupons());
|
||||
productDO.setFrontVisible(resolveUpdateFrontVisible(productDO.getFrontVisible(), productDTO.getFrontVisible()));
|
||||
productDO.setSourceType(resolveUpdateSourceType(productDO.getSourceType(), productDTO.getSourceType()));
|
||||
boolean updated = productMapper.updateById(productDO) > 0;
|
||||
if (updated) {
|
||||
/**
|
||||
@@ -287,6 +293,27 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductVO getPublicProductById(Long id) {
|
||||
AppCacheProperties.CacheSpec cacheSpec = appCacheProperties.getProductDetail();
|
||||
return multiLevelCacheService.getOrLoad(
|
||||
PRODUCT_DETAIL_CACHE_PREFIX + "public:" + id,
|
||||
Duration.ofSeconds(cacheSpec.getLocalTtlSeconds()),
|
||||
Duration.ofSeconds(cacheSpec.getRedisTtlSeconds()),
|
||||
new TypeReference<ProductVO>() {
|
||||
},
|
||||
() -> {
|
||||
ProductDO productDO = productMapper.selectById(id);
|
||||
if (productDO == null
|
||||
|| Integer.valueOf(1).equals(productDO.getIsDelete())
|
||||
|| !Integer.valueOf(FRONT_VISIBLE).equals(productDO.getFrontVisible())) {
|
||||
return null;
|
||||
}
|
||||
return convertToVO(productDO);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
@@ -342,6 +369,33 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductVO> listPublicProducts() {
|
||||
AppCacheProperties.CacheSpec cacheSpec = appCacheProperties.getProductList();
|
||||
return multiLevelCacheService.getOrLoad(
|
||||
PRODUCT_LIST_CACHE_PREFIX + "public:all",
|
||||
Duration.ofSeconds(cacheSpec.getLocalTtlSeconds()),
|
||||
Duration.ofSeconds(cacheSpec.getRedisTtlSeconds()),
|
||||
new TypeReference<List<ProductVO>>() {
|
||||
},
|
||||
() -> toProductVOList(productMapper.selectList(buildFrontQuery(null, null, null)))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductVO> listPublicProductsByShopId(Long shopId) {
|
||||
AppCacheProperties.CacheSpec cacheSpec = appCacheProperties.getProductList();
|
||||
Long scopedShopId = normalizeShopId(shopId);
|
||||
return multiLevelCacheService.getOrLoad(
|
||||
PRODUCT_LIST_CACHE_PREFIX + buildShopCacheSegment(scopedShopId) + "public",
|
||||
Duration.ofSeconds(cacheSpec.getLocalTtlSeconds()),
|
||||
Duration.ofSeconds(cacheSpec.getRedisTtlSeconds()),
|
||||
new TypeReference<List<ProductVO>>() {
|
||||
},
|
||||
() -> toProductVOList(productMapper.selectList(buildFrontQuery(null, null, null, scopedShopId)))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* List records for the current query or current user scope.
|
||||
@@ -464,6 +518,8 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
|
||||
productVO.setAvailableBookableArtistCount(countBookableArtists(validBookableArtists));
|
||||
productVO.setBookableArtistRestricted(StringUtils.hasText(productDO.getBookableArtists()));
|
||||
productVO.setAvailableCoupons(productDO.getAvailableCoupons());
|
||||
productVO.setFrontVisible(productDO.getFrontVisible());
|
||||
productVO.setSourceType(productDO.getSourceType());
|
||||
productVO.setCreateTime(productDO.getCreateTime());
|
||||
productVO.setUpdateTime(productDO.getUpdateTime());
|
||||
|
||||
@@ -831,6 +887,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
|
||||
}
|
||||
LambdaQueryWrapper<ProductDO> wrapper = Wrappers.lambdaQuery(ProductDO.class)
|
||||
.eq(ProductDO::getIsDelete, 0)
|
||||
.eq(ProductDO::getFrontVisible, FRONT_VISIBLE)
|
||||
.orderByDesc(ProductDO::getCreateTime);
|
||||
if (shopId != null) {
|
||||
wrapper.eq(ProductDO::getShopId, shopId);
|
||||
@@ -927,7 +984,8 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
|
||||
*/
|
||||
private LambdaQueryWrapper<ProductDO> buildFrontQuery(String keyword, String tag, Set<String> exactTagIds, Set<String> selectedTagIds, Long shopId) {
|
||||
LambdaQueryWrapper<ProductDO> wrapper = Wrappers.lambdaQuery(ProductDO.class)
|
||||
.eq(ProductDO::getIsDelete, 0);
|
||||
.eq(ProductDO::getIsDelete, 0)
|
||||
.eq(ProductDO::getFrontVisible, FRONT_VISIBLE);
|
||||
if (shopId != null) {
|
||||
wrapper.eq(ProductDO::getShopId, shopId);
|
||||
}
|
||||
@@ -949,6 +1007,28 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
private Integer resolveFrontVisible(Integer frontVisible) {
|
||||
return Integer.valueOf(0).equals(frontVisible) ? 0 : FRONT_VISIBLE;
|
||||
}
|
||||
|
||||
private String resolveSourceType(String sourceType) {
|
||||
return StringUtils.hasText(sourceType) ? sourceType.trim() : SOURCE_TYPE_BACKEND;
|
||||
}
|
||||
|
||||
private Integer resolveUpdateFrontVisible(Integer currentFrontVisible, Integer nextFrontVisible) {
|
||||
if (nextFrontVisible != null) {
|
||||
return resolveFrontVisible(nextFrontVisible);
|
||||
}
|
||||
return currentFrontVisible == null ? FRONT_VISIBLE : currentFrontVisible;
|
||||
}
|
||||
|
||||
private String resolveUpdateSourceType(String currentSourceType, String nextSourceType) {
|
||||
if (StringUtils.hasText(nextSourceType)) {
|
||||
return resolveSourceType(nextSourceType);
|
||||
}
|
||||
return StringUtils.hasText(currentSourceType) ? currentSourceType : SOURCE_TYPE_BACKEND;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `applyKeywordFilter`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
@@ -1214,6 +1294,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
|
||||
private void evictPublicProductCaches(Long productId) {
|
||||
if (productId != null) {
|
||||
multiLevelCacheService.evict(PRODUCT_DETAIL_CACHE_PREFIX + productId);
|
||||
multiLevelCacheService.evict(PRODUCT_DETAIL_CACHE_PREFIX + "public:" + productId);
|
||||
}
|
||||
multiLevelCacheService.evictByPrefix(PRODUCT_LIST_CACHE_PREFIX);
|
||||
multiLevelCacheService.evictByPrefix(PRODUCT_SEARCH_CACHE_PREFIX);
|
||||
|
||||
+10
@@ -126,6 +126,16 @@ public class ProductVO {
|
||||
*/
|
||||
private String availableCoupons;
|
||||
|
||||
/**
|
||||
* 前台是否展示:0-隐藏,1-展示
|
||||
*/
|
||||
private Integer frontVisible;
|
||||
|
||||
/**
|
||||
* 来源类型
|
||||
*/
|
||||
private String sourceType;
|
||||
|
||||
/**
|
||||
* 商品创建时间
|
||||
*/
|
||||
|
||||
+6
-6
@@ -46,12 +46,12 @@ class ProductControllerTest {
|
||||
@Test
|
||||
void listAllProductsShouldUseCurrentShopFromValidToken() {
|
||||
MockHttpServletRequest request = authenticatedShopRequest(7L, 3L);
|
||||
when(productService.listProductsByShopId(3L)).thenReturn(List.of(new ProductVO()));
|
||||
when(productService.listPublicProductsByShopId(3L)).thenReturn(List.of(new ProductVO()));
|
||||
|
||||
controller.listAllProducts(request);
|
||||
|
||||
verify(productService).listProductsByShopId(3L);
|
||||
verify(productService, never()).listAllProducts();
|
||||
verify(productService).listPublicProductsByShopId(3L);
|
||||
verify(productService, never()).listPublicProducts();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,12 +68,12 @@ class ProductControllerTest {
|
||||
@Test
|
||||
void listAllProductsShouldRemainPublicWithoutToken() {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
when(productService.listAllProducts()).thenReturn(List.of(new ProductVO()));
|
||||
when(productService.listPublicProducts()).thenReturn(List.of(new ProductVO()));
|
||||
|
||||
controller.listAllProducts(request);
|
||||
|
||||
verify(productService).listAllProducts();
|
||||
verify(productService, never()).listProductsByShopId(3L);
|
||||
verify(productService).listPublicProducts();
|
||||
verify(productService, never()).listPublicProductsByShopId(3L);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+27
@@ -22,6 +22,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Duration;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
@@ -95,6 +96,8 @@ class ProductServiceImplTest {
|
||||
org.mockito.Mockito.verify(productMapper).insert(captor.capture());
|
||||
assertEquals("Short nails, daily office style", captor.getValue().getTargetAudience());
|
||||
assertEquals("Avoid long hot baths within 24 hours", captor.getValue().getPrecautions());
|
||||
assertEquals(1, captor.getValue().getFrontVisible());
|
||||
assertEquals("BACKEND", captor.getValue().getSourceType());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -123,4 +126,28 @@ class ProductServiceImplTest {
|
||||
assertEquals("Short nails, daily office style", productVO.getTargetAudience());
|
||||
assertEquals("Avoid long hot baths within 24 hours", productVO.getPrecautions());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getPublicProductByIdShouldHideInvisibleProduct() {
|
||||
ProductDO product = new ProductDO();
|
||||
product.setId(99L);
|
||||
product.setShopId(3L);
|
||||
product.setTitle("Manual appointment item");
|
||||
product.setDescription("hidden");
|
||||
product.setPrice(new BigDecimal("88.00"));
|
||||
product.setFrontVisible(0);
|
||||
product.setIsDelete(0);
|
||||
when(productMapper.selectById(99L)).thenReturn(product);
|
||||
when(multiLevelCacheService.getOrLoad(
|
||||
anyString(),
|
||||
any(Duration.class),
|
||||
any(Duration.class),
|
||||
any(),
|
||||
any()
|
||||
)).thenAnswer(invocation -> ((java.util.function.Supplier<?>) invocation.getArgument(4)).get());
|
||||
|
||||
ProductVO productVO = productService.getPublicProductById(99L);
|
||||
|
||||
assertNull(productVO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -738,6 +738,8 @@ export interface Product {
|
||||
imageUrls?: string[]
|
||||
bookableArtists?: string
|
||||
availableCoupons?: string
|
||||
frontVisible?: number
|
||||
sourceType?: string
|
||||
likeCount?: number
|
||||
collectCount?: number
|
||||
createTime: string
|
||||
|
||||
@@ -289,6 +289,9 @@
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="前台展示" name="frontVisible">
|
||||
<a-switch v-model:checked="formState.frontVisible" :checked-value="1" :un-checked-value="0" />
|
||||
</a-form-item>
|
||||
<a-form-item label="标签" name="tags">
|
||||
<a-select
|
||||
v-model:value="formState.tags"
|
||||
@@ -472,6 +475,9 @@
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="前台展示">
|
||||
<a-switch v-model:checked="viewFormState.frontVisible" :checked-value="1" :un-checked-value="0" disabled />
|
||||
</a-form-item>
|
||||
<a-form-item label="标签">
|
||||
<a-select
|
||||
v-model:value="viewFormState.tags"
|
||||
@@ -751,6 +757,7 @@ const viewFormState = reactive({
|
||||
collectCount: 0,
|
||||
tags: [] as string[],
|
||||
approximateDuration: undefined,
|
||||
frontVisible: 1,
|
||||
bookableArtists: [] as string[],
|
||||
availableCoupons: [] as string[]
|
||||
})
|
||||
@@ -777,6 +784,7 @@ const formState = reactive({
|
||||
collectCount: 0,
|
||||
tags: [] as string[],
|
||||
approximateDuration: undefined,
|
||||
frontVisible: 1,
|
||||
bookableArtists: [] as string[],
|
||||
availableCoupons: [] as string[]
|
||||
})
|
||||
@@ -1117,6 +1125,7 @@ const showAddModal = async () => {
|
||||
collectCount: 0,
|
||||
tags: [],
|
||||
approximateDuration: '',
|
||||
frontVisible: 1,
|
||||
bookableArtists: [],
|
||||
availableCoupons: []
|
||||
})
|
||||
@@ -1147,6 +1156,7 @@ const showEditModal = async (record: Product | Record<string, any>) => {
|
||||
const recordCollectCount = 'collectCount' in record ? record.collectCount : (record as any).collectCount
|
||||
const recordTags = 'tags' in record ? record.tags : (record as any).tags
|
||||
const recordApproximateDuration = 'approximateDuration' in record ? record.approximateDuration : (record as any).approximateDuration
|
||||
const recordFrontVisible = 'frontVisible' in record ? record.frontVisible : (record as any).frontVisible
|
||||
const recordBookableArtists = 'bookableArtists' in record ? record.bookableArtists : (record as any).bookableArtists
|
||||
const recordAvailableCoupons = 'availableCoupons' in record ? record.availableCoupons : (record as any).availableCoupons
|
||||
|
||||
@@ -1171,6 +1181,7 @@ const showEditModal = async (record: Product | Record<string, any>) => {
|
||||
collectCount: normalizeInteractionCount(recordCollectCount),
|
||||
tags: tagsArray,
|
||||
approximateDuration: durationNumber,
|
||||
frontVisible: recordFrontVisible ?? 1,
|
||||
bookableArtists: artistsArray,
|
||||
availableCoupons: couponsArray
|
||||
})
|
||||
@@ -1207,6 +1218,7 @@ const showViewModal = async (record: Product | Record<string, any>) => {
|
||||
const recordCollectCount = 'collectCount' in record ? record.collectCount : (record as any).collectCount
|
||||
const recordTags = 'tags' in record ? record.tags : (record as any).tags
|
||||
const recordApproximateDuration = 'approximateDuration' in record ? record.approximateDuration : (record as any).approximateDuration
|
||||
const recordFrontVisible = 'frontVisible' in record ? record.frontVisible : (record as any).frontVisible
|
||||
const recordBookableArtists = 'bookableArtists' in record ? record.bookableArtists : (record as any).bookableArtists
|
||||
const recordAvailableCoupons = 'availableCoupons' in record ? record.availableCoupons : (record as any).availableCoupons
|
||||
|
||||
@@ -1231,6 +1243,7 @@ const showViewModal = async (record: Product | Record<string, any>) => {
|
||||
collectCount: normalizeInteractionCount(recordCollectCount),
|
||||
tags: tagsArray,
|
||||
approximateDuration: durationNumber,
|
||||
frontVisible: recordFrontVisible ?? 1,
|
||||
bookableArtists: artistsArray,
|
||||
availableCoupons: couponsArray
|
||||
})
|
||||
@@ -1275,6 +1288,7 @@ const buildDraftPayload = () => ({
|
||||
collectCount: formState.collectCount,
|
||||
tags: [...formState.tags],
|
||||
approximateDuration: formState.approximateDuration,
|
||||
frontVisible: formState.frontVisible,
|
||||
bookableArtists: [...formState.bookableArtists],
|
||||
availableCoupons: [...formState.availableCoupons]
|
||||
},
|
||||
@@ -1464,6 +1478,7 @@ const handleModalOk = async () => {
|
||||
tags: tagsString,
|
||||
bookableArtists: artistsString,
|
||||
availableCoupons: couponsString,
|
||||
frontVisible: formState.frontVisible,
|
||||
approximateDuration: durationString,
|
||||
shopId: formState.shopId || 0
|
||||
}
|
||||
|
||||
@@ -194,7 +194,11 @@ Page({
|
||||
* Purpose: shopId supports index.js by holding or executing the shop id page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
shopId: ''
|
||||
shopId: '',
|
||||
/**
|
||||
* 前台展示开关,手动预约项目补全前保持隐藏。
|
||||
*/
|
||||
frontVisible: 1
|
||||
}
|
||||
},
|
||||
|
||||
@@ -279,7 +283,11 @@ Page({
|
||||
* Purpose: shopId supports index.js by holding or executing the shop id page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
shopId: currentProduct.shopId || ''
|
||||
shopId: currentProduct.shopId || '',
|
||||
/**
|
||||
* 编辑时回填前台展示开关。
|
||||
*/
|
||||
frontVisible: currentProduct.frontVisible === 0 ? 0 : 1
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -503,6 +511,13 @@ Page({
|
||||
this.scheduleProductDraft()
|
||||
},
|
||||
|
||||
handleFrontVisibleChange(event) {
|
||||
this.setData({
|
||||
'form.frontVisible': event.detail.value ? 1 : 0
|
||||
})
|
||||
this.scheduleProductDraft()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleShopChange supports index.js by holding or executing the handle shop change page or API role.
|
||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -769,7 +784,11 @@ Page({
|
||||
* Purpose: availableCoupons supports index.js by holding or executing the available coupons page or API role.
|
||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
availableCoupons: this._selectedCouponIds.join(',') || undefined
|
||||
availableCoupons: this._selectedCouponIds.join(',') || undefined,
|
||||
/**
|
||||
* 后台补全后可手动发布到用户端。
|
||||
*/
|
||||
frontVisible: this.data.form.frontVisible === 0 ? 0 : 1
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -42,6 +42,12 @@
|
||||
<text class="field-label">收藏数量</text>
|
||||
<input class="field-input" type="number" value="{{form.collectCount}}" data-field="collectCount" bindinput="handleInputChange"></input>
|
||||
</view>
|
||||
<view class="field-group switch-field">
|
||||
<view>
|
||||
<text class="field-label">前台展示</text>
|
||||
</view>
|
||||
<switch checked="{{form.frontVisible === 1}}" bindchange="handleFrontVisibleChange"></switch>
|
||||
</view>
|
||||
|
||||
<view class="field-group">
|
||||
<text class="field-label">作品图片</text>
|
||||
|
||||
@@ -3,3 +3,10 @@ checkbox {
|
||||
transform: scale(0.75);
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
|
||||
.switch-field {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 24rpx;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,14 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
createUser(data) {
|
||||
return request({
|
||||
url: '/user/create',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
},
|
||||
|
||||
schedules(params) {
|
||||
return request({
|
||||
url: '/artist-schedule/list',
|
||||
|
||||
@@ -14,6 +14,45 @@ function findArtist(artists, artistId) {
|
||||
return artists.find(item => String(item.id) === String(artistId)) || {}
|
||||
}
|
||||
|
||||
function canCreateAppointment() {
|
||||
const app = getApp()
|
||||
const userInfo = app.globalData.userInfo || {}
|
||||
return Number(userInfo.type) !== 3
|
||||
}
|
||||
|
||||
function parseProductTags(product) {
|
||||
if (Array.isArray(product.tagList) && product.tagList.length > 0) {
|
||||
return product.tagList
|
||||
}
|
||||
if (Array.isArray(product.tagInfos) && product.tagInfos.length > 0) {
|
||||
return product.tagInfos.map(item => item.tagName).filter(Boolean)
|
||||
}
|
||||
return String(product.tags || '')
|
||||
.split(/[;,,、]/)
|
||||
.map(item => item.trim())
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
function normalizeProduct(product, artists) {
|
||||
const imageUrls = Array.isArray(product.imageUrls) ? product.imageUrls : []
|
||||
const bookableArtists = String(product.bookableArtists || '')
|
||||
.split(',')
|
||||
.map(item => item.trim())
|
||||
.filter(Boolean)
|
||||
const artistNames = bookableArtists
|
||||
.map(id => findArtist(artists, id).name)
|
||||
.filter(Boolean)
|
||||
const durationText = product.approximateDuration || (product.serviceDurationMinutes ? `${product.serviceDurationMinutes}分钟` : '')
|
||||
return {
|
||||
...product,
|
||||
coverImage: imageUrls[0] || '',
|
||||
tagList: parseProductTags(product).slice(0, 4),
|
||||
artistText: artistNames.length > 0 ? artistNames.join('、') : '全部美甲师',
|
||||
priceText: product.price || product.price === 0 ? `¥${product.price}` : '价格待定',
|
||||
durationText
|
||||
}
|
||||
}
|
||||
|
||||
function isScheduleCoveringTime(schedule, form, startMinute, endMinute) {
|
||||
if (!schedule || String(schedule.artistId) !== String(form.artistId) || schedule.date !== form.appointmentDate) {
|
||||
return false
|
||||
@@ -34,24 +73,36 @@ Page({
|
||||
appointmentDate: dateUtil.formatDate(new Date()),
|
||||
appointmentTime: '13:00',
|
||||
productId: '',
|
||||
manualProductTitle: '',
|
||||
manualProductPrice: '',
|
||||
durationMinutes: '',
|
||||
artistId: '',
|
||||
remark: ''
|
||||
},
|
||||
products: [],
|
||||
filteredProducts: [],
|
||||
artists: [],
|
||||
selectedProduct: {},
|
||||
selectedArtist: {},
|
||||
productModalVisible: false,
|
||||
productKeyword: '',
|
||||
conflictTip: '',
|
||||
conflictLevel: 'free',
|
||||
canCreateAppointment: true,
|
||||
loading: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
const creatable = canCreateAppointment()
|
||||
this.setData({
|
||||
canCreateAppointment: creatable,
|
||||
'form.appointmentDate': options.date || dateUtil.formatDate(new Date()),
|
||||
'form.artistId': options.artistId || ''
|
||||
})
|
||||
if (!creatable) {
|
||||
wx.showToast({ title: '美甲师账号只能查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.loadOptions()
|
||||
},
|
||||
|
||||
@@ -69,6 +120,7 @@ Page({
|
||||
this.setData({ products: fallbackProducts })
|
||||
}
|
||||
await this.loadArtists()
|
||||
this.refreshProductCards()
|
||||
this.checkAvailability()
|
||||
},
|
||||
|
||||
@@ -80,6 +132,7 @@ Page({
|
||||
const artists = getCalendarArtists(calendar)
|
||||
const selectedArtist = this.data.form.artistId ? findArtist(artists, this.data.form.artistId) : {}
|
||||
this.setData({ artists, selectedArtist })
|
||||
this.refreshProductCards()
|
||||
},
|
||||
|
||||
onInput(event) {
|
||||
@@ -99,13 +152,62 @@ Page({
|
||||
this.checkAvailability()
|
||||
},
|
||||
|
||||
onProductChange(event) {
|
||||
const selectedProduct = this.data.products[Number(event.detail.value)] || {}
|
||||
refreshProductCards() {
|
||||
const keyword = this.data.productKeyword.trim().toLowerCase()
|
||||
const products = this.data.products
|
||||
.map(product => normalizeProduct(product, this.data.artists))
|
||||
.filter(product => {
|
||||
if (!keyword) return true
|
||||
return [product.title, product.artistText, product.priceText, product.durationText, ...(product.tagList || [])]
|
||||
.some(value => String(value || '').toLowerCase().includes(keyword))
|
||||
})
|
||||
this.setData({ filteredProducts: products })
|
||||
},
|
||||
|
||||
openProductModal() {
|
||||
this.refreshProductCards()
|
||||
this.setData({ productModalVisible: true })
|
||||
},
|
||||
|
||||
closeProductModal() {
|
||||
this.setData({ productModalVisible: false })
|
||||
},
|
||||
|
||||
stopTap() {
|
||||
},
|
||||
|
||||
onProductSearch(event) {
|
||||
this.setData({ productKeyword: event.detail.value })
|
||||
this.refreshProductCards()
|
||||
},
|
||||
|
||||
selectProduct(event) {
|
||||
const selectedProduct = this.data.filteredProducts.find(item => String(item.id) === String(event.currentTarget.dataset.id)) || {}
|
||||
this.setData({
|
||||
selectedProduct,
|
||||
'form.productId': selectedProduct.id,
|
||||
'form.manualProductTitle': '',
|
||||
'form.manualProductPrice': '',
|
||||
'form.durationMinutes': String(parseInt(selectedProduct.approximateDuration, 10) || this.data.form.durationMinutes || 60)
|
||||
})
|
||||
this.closeProductModal()
|
||||
this.checkAvailability()
|
||||
},
|
||||
|
||||
useManualProduct() {
|
||||
const title = String(this.data.form.manualProductTitle || '').trim()
|
||||
const price = Number(this.data.form.manualProductPrice)
|
||||
if (!title || Number.isNaN(price) || price < 0) {
|
||||
wx.showToast({ title: '请填写手动项目名称和价格', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
selectedProduct: {},
|
||||
'form.productId': '',
|
||||
'form.manualProductTitle': title,
|
||||
'form.manualProductPrice': String(price)
|
||||
})
|
||||
this.closeProductModal()
|
||||
this.checkAvailability()
|
||||
},
|
||||
|
||||
@@ -170,8 +272,13 @@ Page({
|
||||
},
|
||||
|
||||
async submit() {
|
||||
if (!this.data.canCreateAppointment) {
|
||||
wx.showToast({ title: '美甲师账号只能查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const form = this.data.form
|
||||
if (!form.customerName || !form.phone || !form.productId || !form.artistId) {
|
||||
const hasManualProduct = String(form.manualProductTitle || '').trim() && String(form.manualProductPrice || '').trim()
|
||||
if (!form.customerName || !form.phone || (!form.productId && !hasManualProduct) || !form.artistId) {
|
||||
wx.showToast({ title: '请补全预约信息', icon: 'none' })
|
||||
return
|
||||
}
|
||||
@@ -182,13 +289,22 @@ Page({
|
||||
}
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const result = await planningApi.createAppointment({
|
||||
const payload = {
|
||||
...form,
|
||||
productId: String(form.productId),
|
||||
artistId: String(form.artistId),
|
||||
durationMinutes: Number(form.durationMinutes || 0) || undefined,
|
||||
clientRequestId: buildClientRequestId('manager-appointment')
|
||||
})
|
||||
}
|
||||
if (form.productId) {
|
||||
payload.productId = String(form.productId)
|
||||
payload.manualProductTitle = undefined
|
||||
payload.manualProductPrice = undefined
|
||||
} else {
|
||||
payload.productId = undefined
|
||||
payload.manualProductTitle = String(form.manualProductTitle || '').trim()
|
||||
payload.manualProductPrice = Number(form.manualProductPrice)
|
||||
}
|
||||
const result = await planningApi.createAppointment(payload)
|
||||
wx.redirectTo({ url: `/pages/appointment-detail/index?id=${result.orderItemId}` })
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '保存失败', icon: 'none' })
|
||||
|
||||
@@ -22,9 +22,10 @@
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">项目内容</text>
|
||||
<picker range="{{products}}" range-key="title" bindchange="onProductChange">
|
||||
<view class="field-value">{{selectedProduct.title || '请选择项目'}}</view>
|
||||
</picker>
|
||||
<view class="field-value product-value" bindtap="openProductModal">
|
||||
<text>{{selectedProduct.title || form.manualProductTitle || '请选择项目'}}</text>
|
||||
<text wx:if="{{form.manualProductTitle && !form.productId}}" class="manual-badge">手动</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">预计时长</text>
|
||||
@@ -53,7 +54,44 @@
|
||||
<text class="tip-text">{{conflictTip}}</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{productModalVisible}}" class="modal-mask" bindtap="closeProductModal">
|
||||
<view class="product-modal" catchtap="stopTap">
|
||||
<view class="modal-head">
|
||||
<view>
|
||||
<text class="modal-title">选择项目内容</text>
|
||||
</view>
|
||||
<button class="modal-close" bindtap="closeProductModal">×</button>
|
||||
</view>
|
||||
<input class="product-search" value="{{productKeyword}}" bindinput="onProductSearch" placeholder="搜索作品、标签、美甲师" />
|
||||
<scroll-view class="product-list" scroll-y>
|
||||
<view wx:for="{{filteredProducts}}" wx:key="id" class="product-option {{form.productId == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="selectProduct">
|
||||
<image wx:if="{{item.coverImage}}" class="product-cover" src="{{item.coverImage}}" mode="aspectFill"></image>
|
||||
<view wx:else class="product-cover placeholder">图</view>
|
||||
<view class="product-info">
|
||||
<view class="product-title-row">
|
||||
<text class="product-title">{{item.title}}</text>
|
||||
<text class="product-price">{{item.priceText}}</text>
|
||||
</view>
|
||||
<text class="product-meta">{{item.artistText}} · {{item.durationText || '时长待定'}}</text>
|
||||
<view class="tag-row">
|
||||
<text wx:for="{{item.tagList}}" wx:for-item="tag" wx:key="*this" class="tag-pill">{{tag}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{filteredProducts.length === 0}}" class="product-empty">暂无匹配作品</view>
|
||||
</scroll-view>
|
||||
<view class="manual-panel">
|
||||
<text class="manual-title">手动新增项目</text>
|
||||
<view class="manual-grid">
|
||||
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="项目名称" />
|
||||
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" type="digit" placeholder="价格" />
|
||||
</view>
|
||||
<button class="secondary-btn manual-btn" bindtap="useManualProduct">使用手动项目</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="fixed-bottom">
|
||||
<button class="primary-btn" loading="{{loading}}" bindtap="submit">保存预约</button>
|
||||
<button wx:if="{{canCreateAppointment}}" class="primary-btn" loading="{{loading}}" bindtap="submit">保存预约</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -3,6 +3,23 @@
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.product-value {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.manual-badge {
|
||||
flex: 0 0 auto;
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #fff2df;
|
||||
color: #a26428;
|
||||
font-size: 22rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.textarea-field {
|
||||
align-items: flex-start;
|
||||
}
|
||||
@@ -58,3 +75,202 @@
|
||||
.availability-tip.danger .tip-title {
|
||||
color: #c36a6a;
|
||||
}
|
||||
|
||||
.modal-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 80;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
background: rgba(18, 15, 12, 0.48);
|
||||
}
|
||||
|
||||
.product-modal {
|
||||
width: 100%;
|
||||
max-height: 88vh;
|
||||
padding: 28rpx 28rpx calc(28rpx + env(safe-area-inset-bottom));
|
||||
border-radius: 28rpx 28rpx 0 0;
|
||||
background: #fffaf4;
|
||||
box-shadow: 0 -18rpx 40rpx rgba(41, 31, 23, 0.16);
|
||||
}
|
||||
|
||||
.modal-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
color: #27211d;
|
||||
font-size: 34rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
width: 58rpx;
|
||||
height: 58rpx;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-radius: 50%;
|
||||
background: #f2e7da;
|
||||
color: #61554c;
|
||||
font-size: 40rpx;
|
||||
line-height: 58rpx;
|
||||
}
|
||||
|
||||
.product-search {
|
||||
height: 74rpx;
|
||||
padding: 0 24rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #f5eee6;
|
||||
color: #2a2521;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.product-list {
|
||||
max-height: 560rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.product-option {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
gap: 18rpx;
|
||||
min-height: 156rpx;
|
||||
margin-bottom: 16rpx;
|
||||
padding: 14rpx;
|
||||
border: 2rpx solid transparent;
|
||||
border-radius: 18rpx;
|
||||
background: #fff;
|
||||
box-shadow: 0 10rpx 24rpx rgba(92, 66, 43, 0.08);
|
||||
}
|
||||
|
||||
.product-option.active {
|
||||
border-color: #c9874d;
|
||||
background: #fff8ef;
|
||||
}
|
||||
|
||||
.product-cover {
|
||||
flex: 0 0 auto;
|
||||
width: 132rpx;
|
||||
height: 132rpx;
|
||||
border-radius: 14rpx;
|
||||
background: #efe5da;
|
||||
}
|
||||
|
||||
.product-cover.placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #b79b82;
|
||||
font-size: 28rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.product-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.product-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.product-title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: #2a2521;
|
||||
font-size: 28rpx;
|
||||
font-weight: 900;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.product-price {
|
||||
flex: 0 0 auto;
|
||||
color: #c56f36;
|
||||
font-size: 28rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.product-meta {
|
||||
overflow: hidden;
|
||||
color: #8c8177;
|
||||
font-size: 24rpx;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.tag-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8rpx;
|
||||
min-height: 34rpx;
|
||||
}
|
||||
|
||||
.tag-pill {
|
||||
max-width: 160rpx;
|
||||
padding: 4rpx 12rpx;
|
||||
overflow: hidden;
|
||||
border-radius: 999rpx;
|
||||
background: #f3e9df;
|
||||
color: #826c5b;
|
||||
font-size: 22rpx;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.product-empty {
|
||||
padding: 44rpx 0;
|
||||
color: #9a9288;
|
||||
font-size: 26rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.manual-panel {
|
||||
margin-top: 12rpx;
|
||||
padding: 20rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #f7efe7;
|
||||
}
|
||||
|
||||
.manual-title {
|
||||
display: block;
|
||||
margin-bottom: 14rpx;
|
||||
color: #4e4740;
|
||||
font-size: 26rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.manual-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 180rpx;
|
||||
gap: 14rpx;
|
||||
}
|
||||
|
||||
.manual-grid input {
|
||||
height: 70rpx;
|
||||
padding: 0 18rpx;
|
||||
border-radius: 14rpx;
|
||||
background: #fffaf4;
|
||||
color: #302923;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.manual-btn {
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
function canCreateAppointment() {
|
||||
const app = getApp()
|
||||
const userInfo = app.globalData.userInfo || {}
|
||||
return Number(userInfo.type) !== 3
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
id: '',
|
||||
canCreateAppointment: true,
|
||||
avatarText: '客',
|
||||
customer: { name: '王女士', phone: '138****1201' },
|
||||
stats: { orderCount: 12, amount: 2860, lastTime: '06-01' },
|
||||
@@ -12,10 +19,17 @@ Page({
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({ id: options.id || '' })
|
||||
this.setData({
|
||||
id: options.id || '',
|
||||
canCreateAppointment: canCreateAppointment()
|
||||
})
|
||||
},
|
||||
|
||||
createAppointment() {
|
||||
if (!this.data.canCreateAppointment) {
|
||||
wx.showToast({ title: '美甲师账号只能查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
wx.navigateTo({ url: '/pages/appointment-form/index' })
|
||||
},
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<text class="customer-phone">{{customer.phone}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<button class="small-action" bindtap="createAppointment">新预约</button>
|
||||
<button wx:if="{{canCreateAppointment}}" class="small-action" bindtap="createAppointment">新预约</button>
|
||||
</view>
|
||||
|
||||
<view class="stats">
|
||||
|
||||
@@ -3,7 +3,16 @@ const mock = require('../../utils/mock')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
employees: []
|
||||
employees: [],
|
||||
createModalVisible: false,
|
||||
creating: false,
|
||||
createForm: {
|
||||
nickname: '',
|
||||
phone: '',
|
||||
account: '',
|
||||
password: '888888',
|
||||
wechatId: ''
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
@@ -39,6 +48,73 @@ Page({
|
||||
},
|
||||
|
||||
addEmployee() {
|
||||
wx.showToast({ title: '员工创建沿用后台账号', icon: 'none' })
|
||||
this.setData({ createModalVisible: true })
|
||||
},
|
||||
|
||||
closeCreateModal() {
|
||||
if (this.data.creating) {
|
||||
return
|
||||
}
|
||||
this.setData({ createModalVisible: false })
|
||||
},
|
||||
|
||||
stopTap() {
|
||||
},
|
||||
|
||||
onCreateInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
const value = event.detail.value
|
||||
const updates = {
|
||||
[`createForm.${field}`]: value
|
||||
}
|
||||
if (field === 'phone' && !this.data.createForm.account) {
|
||||
updates['createForm.account'] = value
|
||||
}
|
||||
this.setData(updates)
|
||||
},
|
||||
|
||||
resetCreateForm() {
|
||||
this.setData({
|
||||
createForm: {
|
||||
nickname: '',
|
||||
phone: '',
|
||||
account: '',
|
||||
password: '888888',
|
||||
wechatId: ''
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
async submitEmployee() {
|
||||
const form = this.data.createForm
|
||||
const nickname = String(form.nickname || '').trim()
|
||||
const phone = String(form.phone || '').trim()
|
||||
const account = String(form.account || '').trim()
|
||||
const password = String(form.password || '').trim()
|
||||
const wechatId = String(form.wechatId || '').trim()
|
||||
if (!nickname || !phone || !account || !password || !wechatId) {
|
||||
wx.showToast({ title: '请补全美甲师信息', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ creating: true })
|
||||
try {
|
||||
await employeesApi.createUser({
|
||||
nickname,
|
||||
phone,
|
||||
contactPhone: phone,
|
||||
account,
|
||||
password,
|
||||
wechatId,
|
||||
type: 3
|
||||
})
|
||||
wx.showToast({ title: '美甲师已新增', icon: 'success' })
|
||||
this.resetCreateForm()
|
||||
this.setData({ createModalVisible: false })
|
||||
await this.loadEmployees()
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '新增失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ creating: false })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -16,4 +16,38 @@
|
||||
<view class="color-pill" style="background: {{item.color}};"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{createModalVisible}}" class="modal-mask" bindtap="closeCreateModal">
|
||||
<view class="employee-modal" catchtap="stopTap">
|
||||
<view class="modal-head">
|
||||
<view>
|
||||
<text class="modal-title">新增美甲师</text>
|
||||
</view>
|
||||
<button class="modal-close" bindtap="closeCreateModal">×</button>
|
||||
</view>
|
||||
<view class="form-grid">
|
||||
<view class="modal-field">
|
||||
<text>姓名</text>
|
||||
<input value="{{createForm.nickname}}" data-field="nickname" bindinput="onCreateInput" placeholder="请输入姓名" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text>手机号</text>
|
||||
<input value="{{createForm.phone}}" data-field="phone" bindinput="onCreateInput" type="number" placeholder="请输入手机号" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text>登录账号</text>
|
||||
<input value="{{createForm.account}}" data-field="account" bindinput="onCreateInput" placeholder="请输入账号" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text>初始密码</text>
|
||||
<input value="{{createForm.password}}" data-field="password" bindinput="onCreateInput" password placeholder="请输入密码" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text>微信号</text>
|
||||
<input value="{{createForm.wechatId}}" data-field="wechatId" bindinput="onCreateInput" placeholder="请输入微信号" />
|
||||
</view>
|
||||
</view>
|
||||
<button class="primary-btn modal-submit" loading="{{creating}}" bindtap="submitEmployee">保存美甲师</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -64,3 +64,81 @@
|
||||
height: 18rpx;
|
||||
border-radius: 999rpx;
|
||||
}
|
||||
|
||||
.modal-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 80;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
background: rgba(18, 15, 12, 0.48);
|
||||
}
|
||||
|
||||
.employee-modal {
|
||||
width: 100%;
|
||||
padding: 28rpx 28rpx calc(28rpx + env(safe-area-inset-bottom));
|
||||
border-radius: 28rpx 28rpx 0 0;
|
||||
background: #fffaf4;
|
||||
box-shadow: 0 -18rpx 40rpx rgba(41, 31, 23, 0.16);
|
||||
}
|
||||
|
||||
.modal-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
color: #27211d;
|
||||
font-size: 34rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
width: 58rpx;
|
||||
height: 58rpx;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-radius: 50%;
|
||||
background: #f2e7da;
|
||||
color: #61554c;
|
||||
font-size: 40rpx;
|
||||
line-height: 58rpx;
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.modal-field {
|
||||
padding: 16rpx 18rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #f7efe7;
|
||||
}
|
||||
|
||||
.modal-field text {
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
color: #6c5f54;
|
||||
font-size: 24rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.modal-field input {
|
||||
height: 58rpx;
|
||||
color: #2c2722;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.modal-submit {
|
||||
margin-top: 22rpx;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,12 @@ const planningApi = require('../../api/planning')
|
||||
const dateUtil = require('../../utils/date')
|
||||
const mock = require('../../utils/mock')
|
||||
|
||||
function canCreateAppointment() {
|
||||
const app = getApp()
|
||||
const userInfo = app.globalData.userInfo || {}
|
||||
return Number(userInfo.type) !== 3
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
viewMode: 'month',
|
||||
@@ -40,10 +46,12 @@ Page({
|
||||
dayTotal: 0,
|
||||
freeArtistCount: 0,
|
||||
pendingCount: 0,
|
||||
canCreateAppointment: true,
|
||||
loading: false
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.setData({ canCreateAppointment: canCreateAppointment() })
|
||||
this.loadCalendar()
|
||||
},
|
||||
|
||||
@@ -327,6 +335,10 @@ Page({
|
||||
},
|
||||
|
||||
createAppointment() {
|
||||
if (!this.data.canCreateAppointment) {
|
||||
wx.showToast({ title: '美甲师账号只能查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
wx.navigateTo({
|
||||
url: `/pages/appointment-form/index?date=${this.data.currentDateText}&artistId=${this.data.selectedArtistId || ''}`
|
||||
})
|
||||
|
||||
@@ -139,5 +139,5 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button class="fab" bindtap="createAppointment">+</button>
|
||||
<button wx:if="{{canCreateAppointment}}" class="fab" bindtap="createAppointment">+</button>
|
||||
</view>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
USE `FingertipDesigner`;
|
||||
|
||||
SET @front_visible_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 't_product'
|
||||
AND COLUMN_NAME = 'front_visible'
|
||||
);
|
||||
|
||||
SET @add_front_visible_sql := IF(
|
||||
@front_visible_exists = 0,
|
||||
'ALTER TABLE `t_product` ADD COLUMN `front_visible` tinyint NOT NULL DEFAULT 1 COMMENT ''前台是否展示:0-隐藏,1-展示'' AFTER `available_coupons`',
|
||||
'SELECT 1'
|
||||
);
|
||||
|
||||
PREPARE add_front_visible_stmt FROM @add_front_visible_sql;
|
||||
EXECUTE add_front_visible_stmt;
|
||||
DEALLOCATE PREPARE add_front_visible_stmt;
|
||||
|
||||
SET @source_type_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 't_product'
|
||||
AND COLUMN_NAME = 'source_type'
|
||||
);
|
||||
|
||||
SET @add_source_type_sql := IF(
|
||||
@source_type_exists = 0,
|
||||
'ALTER TABLE `t_product` ADD COLUMN `source_type` varchar(64) NOT NULL DEFAULT ''BACKEND'' COMMENT ''来源类型:BACKEND-后台维护,MANAGER_APPOINTMENT-管理师端手动预约'' AFTER `front_visible`',
|
||||
'SELECT 1'
|
||||
);
|
||||
|
||||
PREPARE add_source_type_stmt FROM @add_source_type_sql;
|
||||
EXECUTE add_source_type_stmt;
|
||||
DEALLOCATE PREPARE add_source_type_stmt;
|
||||
|
||||
UPDATE `t_product`
|
||||
SET `front_visible` = 1
|
||||
WHERE `front_visible` IS NULL;
|
||||
|
||||
UPDATE `t_product`
|
||||
SET `source_type` = 'BACKEND'
|
||||
WHERE `source_type` IS NULL
|
||||
OR `source_type` = '';
|
||||
Reference in New Issue
Block a user