diff --git a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/manager/controller/admin/AdminManagerController.java b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/manager/controller/admin/AdminManagerController.java index 2474ec4e..308f420a 100644 --- a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/manager/controller/admin/AdminManagerController.java +++ b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/manager/controller/admin/AdminManagerController.java @@ -141,6 +141,16 @@ public class AdminManagerController { return Result.success(result); } + @GetMapping("/customers/matches") + @RequirePermission("user:view") + public Result> customerMatches(HttpServletRequest request, + @RequestParam String nickname, + @RequestParam(required = false) String phone) { + UserDO currentUser = adminScopeHelper.getCurrentUser(request); + Long shopId = adminScopeHelper.resolveShopScope(currentUser, null); + return Result.success(userService.findCustomerMatches(nickname, phone, shopId)); + } + @GetMapping("/customers/{id}") @RequirePermission("user:view") public Result customer(HttpServletRequest request, @PathVariable Long id) { @@ -157,18 +167,7 @@ public class AdminManagerController { UserDO currentUser = adminScopeHelper.getCurrentUser(request); adminScopeHelper.requireShopContext(currentUser, "请先选择店铺后再新增客户"); Long shopId = adminScopeHelper.resolveShopScope(currentUser, null); - String phone = dto.getPhone().trim(); - UserDTO userDTO = new UserDTO(); - userDTO.setNickname(dto.getNickname().trim()); - userDTO.setPhone(phone); - userDTO.setContactPhone(phone); - userDTO.setAccount(phone); - userDTO.setType(0); - userDTO.setShopId(shopId); - userDTO.setShopIds(List.of(shopId)); - userDTO.setLevel("普通"); - userDTO.setVipId(0L); - return Result.success(userService.createUser(userDTO)); + return Result.success(userService.createManagerCustomer(dto.getNickname(), dto.getPhone(), shopId)); } @GetMapping("/employees") diff --git a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/manager/dto/ManagerCustomerCreateDTO.java b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/manager/dto/ManagerCustomerCreateDTO.java index 396e8700..43fd0742 100644 --- a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/manager/dto/ManagerCustomerCreateDTO.java +++ b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/manager/dto/ManagerCustomerCreateDTO.java @@ -3,7 +3,6 @@ package com.xiaowang.jayucloud.salon.core.modules.manager.dto; import lombok.Data; import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Pattern; @Data public class ManagerCustomerCreateDTO { @@ -11,7 +10,5 @@ public class ManagerCustomerCreateDTO { @NotBlank(message = "客户姓名不能为空") private String nickname; - @NotBlank(message = "手机号不能为空") - @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确") private String phone; } diff --git a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/planning/service/impl/PlanningServiceImpl.java b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/planning/service/impl/PlanningServiceImpl.java index 21a076f2..d7a04df9 100644 --- a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/planning/service/impl/PlanningServiceImpl.java +++ b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/planning/service/impl/PlanningServiceImpl.java @@ -23,6 +23,7 @@ import com.xiaowang.jayucloud.salon.core.modules.order.mapper.OrderMapper; import com.xiaowang.jayucloud.salon.core.modules.product.mapper.ProductMapper; import com.xiaowang.jayucloud.salon.core.modules.shop.mapper.ShopMapper; import com.xiaowang.jayucloud.salon.core.modules.user.mapper.UserMapper; +import com.xiaowang.jayucloud.salon.core.modules.user.service.UserService; import com.xiaowang.jayucloud.salon.core.modules.planning.service.AppointmentCapacityService; import com.xiaowang.jayucloud.salon.core.modules.order.service.OrderService; import com.xiaowang.jayucloud.salon.core.modules.planning.service.PlanningService; @@ -71,7 +72,6 @@ public class PlanningServiceImpl implements PlanningService { private static final String RESERVATION_UNASSIGNED = "UNASSIGNED"; private static final String ASSIGNMENT_ASSIGNED = "ASSIGNED"; 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 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 ARTIST_COLORS = List.of( @@ -80,6 +80,7 @@ public class PlanningServiceImpl implements PlanningService { private final AdminScopeHelper adminScopeHelper; private final UserMapper userMapper; + private final UserService userService; private final NailArtistInfoMapper nailArtistInfoMapper; private final ArtistScheduleMapper artistScheduleMapper; private final ArtistScheduleExceptionMapper artistScheduleExceptionMapper; @@ -780,34 +781,26 @@ public class PlanningServiceImpl implements PlanningService { 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())) { + if (customer == null || Integer.valueOf(1).equals(customer.getIsDelete()) || !Integer.valueOf(0).equals(customer.getType())) { throw new RuntimeException("客户不存在"); } return customer; } - if (!hasText(dto.getPhone())) { - throw new RuntimeException("客户手机号不能为空"); + String customerName = firstNonBlank(dto.getCustomerName(), dto.getPhone()); + if (!hasText(customerName)) { + throw new RuntimeException("客户姓名不能为空"); } - QueryWrapper 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; + String phone = trimToNull(dto.getPhone()); + List matches = + userService.findCustomerMatches(customerName, phone, shopId); + if (matches.size() > 1) { + throw new RuntimeException("存在多个匹配客户,请先选择已有客户"); } - 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; + if (!matches.isEmpty()) { + return userMapper.selectById(matches.get(0).getId()); + } + Long customerId = userService.createManagerCustomer(customerName, phone, shopId); + return userMapper.selectById(customerId); } private OrderDO requireAccessibleOrder(UserDO currentUser, Long orderId) { diff --git a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/user/service/UserService.java b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/user/service/UserService.java index e517db55..62eab615 100644 --- a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/user/service/UserService.java +++ b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/user/service/UserService.java @@ -34,6 +34,11 @@ public interface UserService extends IService { */ Long createUser(UserDTO userDTO); + Long createManagerCustomer(String nickname, String phone, Long shopId); + + List findCustomerMatches(String nickname, String phone, Long shopId); + + /** * Update an existing record. * Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result. diff --git a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/user/service/impl/UserServiceImpl.java b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/user/service/impl/UserServiceImpl.java index 7b65f92f..f703d3ee 100644 --- a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/user/service/impl/UserServiceImpl.java +++ b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/user/service/impl/UserServiceImpl.java @@ -69,6 +69,7 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; +import java.util.UUID; import java.util.stream.Collectors; import com.xiaowang.jayucloud.salon.core.modules.auth.dto.BindEmailRequestDTO; @@ -356,6 +357,10 @@ public class UserServiceImpl extends ServiceImpl implements @Override @Transactional(rollbackFor = Exception.class) public Long createUser(UserDTO userDTO) { + return createUserInternal(userDTO, false); + } + + private Long createUserInternal(UserDTO userDTO, boolean allowMissingCustomerPhone) { String validatedAccount = AccountValidationUtils.requireValidAccount(userDTO.getAccount()); // 检查账号是否已存在 UserDO existingUser = userMapper.selectOne( @@ -374,8 +379,12 @@ public class UserServiceImpl extends ServiceImpl implements List validatedShopIds = resolveValidatedShopIds(userDTO.getShopIds(), userDTO.getShopId()); Long validatedShopId = pickPrimaryShopId(validatedShopIds); - String validatedPhone = validateUserPhone(userDTO.getPhone(), null, true); Integer userType = userDTO.getType(); + String validatedPhone = validateUserPhone(userDTO.getPhone(), null, + !(allowMissingCustomerPhone && Integer.valueOf(0).equals(userType))); + if (Integer.valueOf(0).equals(userType)) { + ensureCustomerUnique(userDTO.getNickname(), validatedPhone); + } String validatedWechatId = UserProfileFieldSupport.normalizeOptionalText(userDTO.getWechatId()); UserProfileFieldSupport.requireWechatIdForServiceUser(userType, validatedWechatId); @@ -461,6 +470,68 @@ public class UserServiceImpl extends ServiceImpl implements return userDO.getId(); } + @Override + @Transactional(rollbackFor = Exception.class) + public Long createManagerCustomer(String nickname, String phone, Long shopId) { + if (!StringUtils.hasText(nickname)) { + throw new RuntimeException("客户姓名不能为空"); + } + if (shopId == null || shopId <= 0) { + throw new RuntimeException("请先选择店铺后再新增客户"); + } + String normalizedPhone = phone == null || phone.trim().isEmpty() ? null : phone.trim(); + ensureCustomerUnique(nickname, normalizedPhone); + normalizedPhone = validateUserPhone(normalizedPhone, null, false); + UserDTO customer = new UserDTO(); + customer.setNickname(nickname.trim()); + customer.setPhone(normalizedPhone); + customer.setContactPhone(normalizedPhone); + customer.setAccount(normalizedPhone == null + ? "customer" + UUID.randomUUID().toString().replace("-", "") + : normalizedPhone); + customer.setType(0); + customer.setShopId(shopId); + customer.setShopIds(List.of(shopId)); + customer.setLevel(VIP_LEVEL_NORMAL); + customer.setVipId(0L); + return createUserInternal(customer, true); + } + + @Override + public List findCustomerMatches(String nickname, String phone, Long shopId) { + if (!StringUtils.hasText(nickname)) { + return List.of(); + } + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(UserDO.class) + .eq(UserDO::getNickname, nickname.trim()) + .eq(UserDO::getType, 0) + .eq(UserDO::getIsDelete, 0); + if (StringUtils.hasText(phone)) { + String normalizedPhone = phone.trim(); + wrapper.and(query -> query.eq(UserDO::getPhone, normalizedPhone) + .or().eq(UserDO::getContactPhone, normalizedPhone)); + } + if (shopId != null && shopId > 0) { + List shopUserIds = userShopBindingSupport.listUserIdsByShopId(shopId, true); + if (shopUserIds.isEmpty()) { + wrapper.eq(UserDO::getShopId, shopId); + } else { + wrapper.and(query -> query.eq(UserDO::getShopId, shopId) + .or().in(UserDO::getId, shopUserIds)); + } + } + return userMapper.selectList(wrapper).stream().map(user -> { + UserVO customer = new UserVO(); + customer.setId(user.getId()); + customer.setNickname(user.getNickname()); + customer.setAccount(user.getAccount()); + customer.setPhone(user.getPhone()); + customer.setContactPhone(user.getContactPhone()); + customer.setAvatar(resolveAccessibleAvatar(user.getAvatar())); + return customer; + }).collect(Collectors.toList()); + } + /** * 分配默认权限 * @param userId 用户ID @@ -3047,6 +3118,23 @@ public class UserServiceImpl extends ServiceImpl implements throw new RuntimeException("手机号已被使用"); } } + + private void ensureCustomerUnique(String nickname, String phone) { + if (!StringUtils.hasText(nickname)) { + throw new RuntimeException("客户姓名不能为空"); + } + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(UserDO.class) + .eq(UserDO::getNickname, nickname.trim()) + .eq(UserDO::getType, 0) + .eq(UserDO::getIsDelete, 0); + if (StringUtils.hasText(phone)) { + wrapper.and(query -> query.eq(UserDO::getPhone, phone) + .or().eq(UserDO::getContactPhone, phone)); + } + if (userMapper.selectCount(wrapper) > 0) { + throw new RuntimeException("客户已存在,请选择已有客户"); + } + } /** * Run business method `buildRelationVO`. * Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result. diff --git a/JC-Salon-WeChat/api/customers.js b/JC-Salon-WeChat/api/customers.js index d6a2b36b..8d4c25cd 100644 --- a/JC-Salon-WeChat/api/customers.js +++ b/JC-Salon-WeChat/api/customers.js @@ -14,6 +14,13 @@ module.exports = { }) }, + matchIdentity(nickname, phone) { + return request({ + url: '/manager/customers/matches', + params: { nickname, phone } + }) + }, + create(data) { return request({ url: '/manager/customers', diff --git a/JC-Salon-WeChat/pages/appointment-form/entity-selector.test.js b/JC-Salon-WeChat/pages/appointment-form/entity-selector.test.js index 128b531b..0eba88f5 100644 --- a/JC-Salon-WeChat/pages/appointment-form/entity-selector.test.js +++ b/JC-Salon-WeChat/pages/appointment-form/entity-selector.test.js @@ -7,13 +7,17 @@ global.wx = { setStorageSync: () => {}, removeStorageSync: () => {}, showToast: () => {}, + showModal: options => options.success({ confirm: modalConfirm }), navigateTo: () => {} } global.getApp = () => ({ globalData: { userInfo: { type: 2, id: 1, shopId: 2 } } }) +let modalConfirm = true + let definition global.Page = value => { definition = value } require('./index') +const customersApi = require('../../api/customers') function createPage() { return { @@ -39,11 +43,30 @@ async function run() { assert.strictEqual(page.data.customerSheetVisible, false) page.data.form.customerUserId = 18 - page.data.manualCustomerForm = { name: '新客户', phone: '13900139000' } - page.useManualCustomer() + page.onCustomerInput({ currentTarget: { dataset: { field: 'customerName' } }, detail: { value: '新客户' } }) assert.strictEqual(page.data.form.customerUserId, '') assert.strictEqual(page.data.form.customerName, '新客户') - assert.strictEqual(page.data.form.phone, '13900139000') + assert.strictEqual(page.data.form.phone, '') + + customersApi.matchIdentity = async () => [] + customersApi.create = async payload => { + assert.strictEqual(payload.nickname, '新客户') + assert.strictEqual(payload.phone, undefined) + return '42' + } + assert.strictEqual(await page.ensureCustomerBeforeSubmit(), true) + assert.strictEqual(page.data.form.customerUserId, '42') + + page.data.form.customerUserId = '' + page.data.form.customerName = '小周' + page.data.form.phone = '13800138000' + customersApi.matchIdentity = async (name, phone) => { + assert.strictEqual(name, '小周') + assert.strictEqual(phone, '13800138000') + return [{ id: '18', nickname: '小周', phone: '13800138000' }] + } + assert.strictEqual(await page.ensureCustomerBeforeSubmit(), true) + assert.strictEqual(page.data.form.customerUserId, '18') page.data.artists = [{ id: 1, name: '小周' }, { id: 2, name: '小李' }] page.onArtistSearch({ detail: { value: '李' } }) diff --git a/JC-Salon-WeChat/pages/appointment-form/index.js b/JC-Salon-WeChat/pages/appointment-form/index.js index 2a47ba0f..68b7923d 100644 --- a/JC-Salon-WeChat/pages/appointment-form/index.js +++ b/JC-Salon-WeChat/pages/appointment-form/index.js @@ -295,8 +295,6 @@ Page({ customerKeyword: '', customerLoading: false, customerError: '', - manualCustomerVisible: false, - manualCustomerForm: { name: '', phone: '' }, products: [], filteredProducts: [], artists: [], @@ -434,6 +432,20 @@ Page({ } }, + onCustomerInput(event) { + const field = event.currentTarget.dataset.field + const patch = { + [`form.${field}`]: event.detail.value, + 'form.customerUserId': '' + } + if (field === 'customerName' && this.data.form.customerUserId) { + patch['form.phone'] = '' + } + this.setData({ + ...patch + }) + }, + openCustomerSheet() { this.setData({ customerSheetVisible: true }) this.searchCustomers(this.data.customerKeyword) @@ -491,45 +503,6 @@ Page({ }) }, - openManualCustomer() { - this.setData({ - customerSheetVisible: false, - manualCustomerVisible: true, - manualCustomerForm: { - name: this.data.form.customerName || '', - phone: this.data.form.phone || '' - } - }) - }, - - closeManualCustomer() { - this.setData({ manualCustomerVisible: false }) - }, - - onManualCustomerInput(event) { - this.setData({ [`manualCustomerForm.${event.currentTarget.dataset.field}`]: event.detail.value }) - }, - - useManualCustomer() { - const name = String(this.data.manualCustomerForm.name || '').trim() - const phone = String(this.data.manualCustomerForm.phone || '').trim() - if (!name) { - wx.showToast({ title: '请输入客户姓名', icon: 'none' }) - return - } - if (!/^1[3-9]\d{9}$/.test(phone)) { - wx.showToast({ title: '请输入正确手机号', icon: 'none' }) - return - } - this.setData({ - 'form.customerUserId': '', - 'form.customerName': name, - 'form.phone': phone, - manualCustomerVisible: false, - customerKeyword: '' - }) - }, - onUnload() { if (this._customerTimer) { clearTimeout(this._customerTimer) @@ -949,7 +922,83 @@ Page({ } }, + async ensureCustomerBeforeSubmit() { + const name = String(this.data.form.customerName || '').trim() + const phone = String(this.data.form.phone || '').trim() + if (!name) { + wx.showToast({ title: '请输入客户姓名', icon: 'none' }) + return false + } + if (phone && !/^1[3-9]\d{9}$/.test(phone)) { + wx.showToast({ title: '请输入正确手机号', icon: 'none' }) + return false + } + if (this.data.form.customerUserId) { + return true + } + + this.setData({ loading: true }) + try { + const matches = await customersApi.matchIdentity(name, phone || undefined) + if (matches.length > 1) { + this.setData({ + customerOptions: matches.map(normalizeCustomer).map(buildCustomerSelectorItem), + customerKeyword: name, + customerSheetVisible: true + }) + return false + } + if (matches.length > 0) { + const customer = normalizeCustomer(matches[0]) + const choice = await new Promise(resolve => { + wx.showModal({ + title: '客户已存在', + content: `系统中已有“${name}”${phone ? `(${phone})` : ''},是否使用该客户?`, + cancelText: '取消', + confirmText: '使用已有', + success: resolve, + fail: () => resolve({ confirm: false }) + }) + }) + if (!choice.confirm) { + return false + } + this.setData({ + 'form.customerUserId': customer.id, + 'form.customerName': customer.name, + 'form.phone': customer.phone + }) + return true + } + + const createChoice = await new Promise(resolve => { + wx.showModal({ + title: '新建客户', + content: '系统中没有匹配客户,是否新建到客户档案?', + cancelText: '不新建', + confirmText: '确认', + success: resolve, + fail: () => resolve({ confirm: false }) + }) + }) + if (!createChoice.confirm) { + return false + } + const customerId = await customersApi.create({ nickname: name, phone: phone || undefined }) + this.setData({ 'form.customerUserId': customerId }) + return true + } catch (error) { + wx.showToast({ title: error.message || '客户校验失败,请稍后重试', icon: 'none' }) + return false + } finally { + this.setData({ loading: false }) + } + }, + async submit() { + if (this.data.loading) { + return + } if (!this.data.canCreateAppointment) { wx.showToast({ title: '当前账号仅支持查看预约', icon: 'none' }) return @@ -957,11 +1006,11 @@ Page({ const form = this.data.form const hasManualProduct = String(form.manualProductTitle || '').trim() && String(form.manualProductPrice || '').trim() const durationMinutes = normalizeDuration(form.durationMinutes) - if (!form.customerName || !form.phone || (!form.productId && !hasManualProduct) || !form.appointmentDate || !form.appointmentTime) { + if (!form.customerName || (!form.productId && !hasManualProduct) || !form.appointmentDate || !form.appointmentTime) { wx.showToast({ title: '请补全预约信息', icon: 'none' }) return } - if (!/^1[3-9]\d{9}$/.test(String(form.phone).trim())) { + if (form.phone && !/^1[3-9]\d{9}$/.test(String(form.phone).trim())) { wx.showToast({ title: '请输入正确手机号', icon: 'none' }) return } @@ -987,6 +1036,9 @@ Page({ }) if (!result.confirm) return } + if (!(await this.ensureCustomerBeforeSubmit())) { + return + } this.setData({ loading: true }) try { const payload = { diff --git a/JC-Salon-WeChat/pages/appointment-form/index.wxml b/JC-Salon-WeChat/pages/appointment-form/index.wxml index b72a8f68..3ecd6fec 100644 --- a/JC-Salon-WeChat/pages/appointment-form/index.wxml +++ b/JC-Salon-WeChat/pages/appointment-form/index.wxml @@ -1,15 +1,13 @@ - - 客户 - - - {{form.customerName || '请选择客户'}} - {{form.phone || '搜索已有客户或手动录入'}} - - 已有 - › + + 客户姓名 + + + + + 已关联系统客户 预约日期 @@ -76,12 +74,10 @@ selected-id="{{form.customerUserId}}" loading="{{customerLoading}}" error-text="{{customerError}}" - empty-text="暂无匹配客户,可手动录入" - action-text="手动录入客户" + empty-text="暂无匹配客户" bind:search="onCustomerSearch" bind:select="selectCustomer" bind:retry="retryCustomerSearch" - bind:action="openManualCustomer" bind:close="closeCustomerSheet" /> @@ -103,29 +99,6 @@ bind:close="closeArtistSheet" /> - - - - - 手动录入客户 - 录入后将直接带回本次预约 - - × - - - - 客户姓名 - - - - 手机号 - - - - - - - diff --git a/JC-Salon-WeChat/pages/appointment-form/index.wxss b/JC-Salon-WeChat/pages/appointment-form/index.wxss index 8cb157d3..ed1ef6a0 100644 --- a/JC-Salon-WeChat/pages/appointment-form/index.wxss +++ b/JC-Salon-WeChat/pages/appointment-form/index.wxss @@ -4,6 +4,7 @@ } .customer-field { + display: block; align-items: stretch; padding: 18rpx 0; } @@ -13,6 +14,58 @@ align-items: center; } +.customer-entry { + display: flex; + align-items: center; + gap: 14rpx; + width: 100%; +} + +.customer-name-input { + min-width: 0; + flex: 1; + height: 78rpx; + padding: 0 18rpx; + border: 1rpx solid #e7e0d7; + border-radius: 18rpx; + background: #f8f4ee; + color: #29241f; + font-size: 27rpx; +} + +.customer-select-btn { + flex: 0 0 auto; + min-width: 176rpx; + height: 78rpx; + margin: 0; + padding: 0 18rpx; + border: 1rpx solid #d7b38e; + border-radius: 18rpx; + background: #fff7ed; + color: #9f5f2d; + font-size: 23rpx; + line-height: 78rpx; +} + +.customer-phone-input { + width: 100%; + height: 66rpx; + margin-top: 14rpx; + padding: 0 18rpx; + border: 1rpx solid #e7e0d7; + border-radius: 16rpx; + background: #fff; + color: #29241f; + font-size: 25rpx; +} + +.customer-selected-tip { + display: block; + margin-top: 10rpx; + color: #55786d; + font-size: 21rpx; +} + .reference-card, .reference-value { display: flex; @@ -215,49 +268,6 @@ background: rgba(18, 15, 12, 0.48); } -.manual-customer-sheet { - display: flex; - width: 100%; - height: 88vh; - max-height: 88vh; - flex-direction: column; - padding: 28rpx 28rpx calc(28rpx + env(safe-area-inset-bottom)); - border-radius: 34rpx 34rpx 0 0; - background: #fffaf4; - box-shadow: 0 -18rpx 40rpx rgba(41, 31, 23, 0.16); -} - -.manual-customer-form { - flex: 1; - padding-top: 12rpx; -} - -.manual-customer-field { - margin-bottom: 20rpx; - padding: 20rpx 22rpx; - border: 1rpx solid #e7e0d7; - border-radius: 20rpx; - background: #fff; -} - -.manual-customer-field text { - display: block; - margin-bottom: 10rpx; - color: #625c55; - font-size: 24rpx; - font-weight: 800; -} - -.manual-customer-field input { - height: 64rpx; - color: #29241f; - font-size: 28rpx; -} - -.manual-customer-submit { - flex: 0 0 auto; -} - .time-modal { width: 100%; max-height: 82vh; diff --git a/docs/superpowers/specs/2026-10-16-预约客户输入与选择交互-design.md b/docs/superpowers/specs/2026-10-16-预约客户输入与选择交互-design.md index efc815c7..97aaa790 100644 --- a/docs/superpowers/specs/2026-10-16-预约客户输入与选择交互-design.md +++ b/docs/superpowers/specs/2026-10-16-预约客户输入与选择交互-design.md @@ -31,7 +31,7 @@ ## 后端接口与模型 -- 扩展 `GET /manager/customers` 的姓名、手机号筛选能力,保证查询条件能够表达姓名加手机号的组合。 +- 新增 `GET /manager/customers/matches`,按姓名及可选手机号返回当前店铺的精确匹配客户;原 `GET /manager/customers` 列表接口保持不变。 - 调整 `POST /manager/customers`:手机号改为可选;无手机号时不生成手机号账号,使用系统生成的不可登录账号或现有客户创建约定;有手机号时保留现有账号兼容逻辑。 - 创建前在事务内按唯一性规则查询并拒绝重复,返回明确业务错误。 - 不修改预约提交协议,预约仍使用 `customerUserId`、`customerName` 和 `phone` 字段。 diff --git a/docs/项目变更记录.md b/docs/项目变更记录.md index a4a1c9d5..3ad56ad1 100644 --- a/docs/项目变更记录.md +++ b/docs/项目变更记录.md @@ -1,5 +1,12 @@ # 项目变更记录 +## 2026-10-16 Salon 预约客户输入与选择优化 + +- 新增预约客户字段改为“客户姓名输入框 + 选择已有客户”按钮,手机号改为可选输入,输入文本时自动解除旧客户绑定。 +- 提交前按“姓名 + 手机号”或“仅姓名”规则查询客户;已存在时引导使用已有客户,未存在时提供确认新建和不新建选择。 +- 后端新增客户匹配接口,客户创建支持无手机号并在事务内执行唯一性校验,预约接口同步支持无手机号客户解析。 +- 更新预约页选择测试和 Core 预约测试夹具;GitNexus 当前无可调用接口,使用静态引用、JavaScript 检查和 Maven 测试替代影响分析。 + ## 2026-10-16 Gitea 工作流 YAML 兼容性修复 - 问题:Gitea Actions 页面只显示工作流文件名并标记无效,推送后没有执行。