保存客户与美甲师表单改造检查点

This commit is contained in:
2026-10-29 17:02:57 +08:00
parent bb3d00c51e
commit b3a8c7e01c
24 changed files with 425 additions and 60 deletions
@@ -39,6 +39,9 @@ public class NailArtistInfoDTO {
*/
private String skills;
/** 规划页使用的专属颜色。 */
private String color;
/**
* 评分
*/
@@ -37,6 +37,9 @@ public class NailArtistInfoDO extends BaseEntity {
*/
private String skills;
/** 规划页使用的专属颜色。 */
private String color;
/**
* 评分
*/
@@ -331,6 +331,7 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
if (dto.getIdentity() != null) target.setIdentity(dto.getIdentity());
if (dto.getExperience() != null) target.setExperience(dto.getExperience());
if (dto.getSkills() != null) target.setSkills(dto.getSkills());
if (dto.getColor() != null) target.setColor(dto.getColor());
if (dto.getRating() != null) target.setRating(dto.getRating());
if (dto.getStatus() != null) target.setStatus(dto.getStatus());
if (dto.getParticipateProduction() != null) target.setParticipateProduction(dto.getParticipateProduction());
@@ -167,7 +167,7 @@ public class AdminManagerController {
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
adminScopeHelper.requireShopContext(currentUser, "请先选择店铺后再新增客户");
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
return Result.success(userService.createManagerCustomer(dto.getNickname(), dto.getPhone(), shopId));
return Result.success(userService.createManagerCustomer(dto.getNickname(), dto.getWechatId(), dto.getPhone(), shopId));
}
@GetMapping("/employees")
@@ -10,5 +10,7 @@ public class ManagerCustomerCreateDTO {
@NotBlank(message = "客户姓名不能为空")
private String nickname;
private String wechatId;
private String phone;
}
@@ -406,7 +406,8 @@ public class PlanningServiceImpl implements PlanningService {
vo.setShortName(PlanningCalendarSupport.shortName(vo.getName()));
vo.setPhone(firstNonBlank(user.getContactPhone(), user.getPhone(), ""));
vo.setAvatar(user.getAvatar());
vo.setColor(colorForArtist(user.getId(), i));
vo.setColor(info != null && StringUtils.hasText(info.getColor())
? info.getColor() : 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());
@@ -88,6 +88,9 @@ public class UserDTO {
*/
private String wechatId;
/** 美甲师在规划页展示的专属颜色(#RRGGBB)。 */
private String color;
/**
* 微信二维码
*/
@@ -73,6 +73,10 @@ public class UserDO extends BaseEntity {
@TableField(value = "contact_phone_hash", fill = FieldFill.INSERT_UPDATE)
private String contactPhoneHash;
/** 客户姓名、微信号和手机号的组合HMAC,用于原子去重。 */
@TableField("customer_identity_hash")
private String customerIdentityHash;
/**
* 生日
*/
@@ -22,7 +22,7 @@ public interface UserMapper extends BaseMapper<UserDO> {
@Select("SELECT id FROM t_user WHERE account = #{account} AND account_hash IS NULL AND is_delete = 0 LIMIT 1")
Long findLegacyIdByAccount(@Param("account") String account);
@Select("SELECT id FROM t_user WHERE phone = #{phone} AND phone_hash IS NULL AND is_delete = 0 LIMIT 1")
@Select("SELECT id FROM t_user WHERE phone = #{phone} AND phone_hash IS NULL AND is_delete = 0 AND type <> 0 LIMIT 1")
Long findLegacyIdByPhone(@Param("phone") String phone);
@Select("SELECT id FROM t_user WHERE contact_phone = #{phone} AND contact_phone_hash IS NULL AND is_delete = 0 LIMIT 1")
@@ -36,6 +36,8 @@ public interface UserService extends IService<UserDO> {
Long createManagerCustomer(String nickname, String phone, Long shopId);
Long createManagerCustomer(String nickname, String wechatId, String phone, Long shopId);
List<UserVO> findCustomerMatches(String nickname, String phone, Long shopId);
@@ -389,12 +389,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
List<Long> validatedShopIds = resolveValidatedShopIds(userDTO.getShopIds(), userDTO.getShopId());
Long validatedShopId = pickPrimaryShopId(validatedShopIds);
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 validatedPhone = Integer.valueOf(0).equals(userType)
? validateCustomerPhone(userDTO.getPhone(), !(allowMissingCustomerPhone && Integer.valueOf(0).equals(userType)))
: validateUserPhone(userDTO.getPhone(), null, true);
String validatedWechatId = UserProfileFieldSupport.normalizeOptionalText(userDTO.getWechatId());
if (Integer.valueOf(0).equals(userType)) {
ensureCustomerUnique(userDTO.getNickname(), validatedWechatId, validatedPhone);
}
UserProfileFieldSupport.requireWechatIdForServiceUser(userType, validatedWechatId);
/**
@@ -409,7 +410,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
// 创建用户实体并设置属性
UserDO userDO = new UserDO();
userDO.setShopId(validatedShopId);
userDO.setNickname(userDTO.getNickname());
userDO.setNickname(Integer.valueOf(0).equals(userType) && userDTO.getNickname() != null
? userDTO.getNickname().trim() : userDTO.getNickname());
userDO.setAccount(validatedAccount);
String resolvedPassword = AdminDefaultPasswordSupport.resolveCreatePassword(
userDTO.getPassword(),
@@ -418,6 +420,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
validatePasswordStrength(resolvedPassword);
userDO.setPassword(passwordEncoder.encode(resolvedPassword));
userDO.setPhone(validatedPhone);
if (Integer.valueOf(0).equals(userType)) {
userDO.setCustomerIdentityHash(customerIdentityHash(userDO.getNickname(), validatedWechatId, validatedPhone));
}
userDO.setContactPhone(UserProfileFieldSupport.normalizeOptionalText(userDTO.getContactPhone()));
userDO.setBirthday(userDTO.getBirthday());
userDO.setWechatId(validatedWechatId);
@@ -490,6 +495,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
nailArtistInfoDTO.setRating(DEFAULT_NAIL_ARTIST_RATING); // 默认评分为4.5
nailArtistInfoDTO.setStatus(1); // 默认状态为营业中
nailArtistInfoDTO.setPortfolio(""); // 默认作品集为空
nailArtistInfoDTO.setColor(normalizeArtistColor(userDTO.getColor()));
nailArtistInfoService.saveOrUpdateNailArtistInfo(nailArtistInfoDTO);
}
@@ -499,6 +505,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
@Override
@Transactional(rollbackFor = Exception.class)
public Long createManagerCustomer(String nickname, String phone, Long shopId) {
return createManagerCustomer(nickname, null, phone, shopId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Long createManagerCustomer(String nickname, String wechatId, String phone, Long shopId) {
if (!StringUtils.hasText(nickname)) {
throw new RuntimeException("客户姓名不能为空");
}
@@ -506,15 +518,15 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
throw new RuntimeException("请先选择店铺后再新增客户");
}
String normalizedPhone = phone == null || phone.trim().isEmpty() ? null : phone.trim();
ensureCustomerUnique(nickname, normalizedPhone);
normalizedPhone = validateUserPhone(normalizedPhone, null, false);
normalizedPhone = validateCustomerPhone(normalizedPhone, false);
String normalizedWechatId = UserProfileFieldSupport.normalizeOptionalText(wechatId);
ensureCustomerUnique(nickname, normalizedWechatId, normalizedPhone);
UserDTO customer = new UserDTO();
customer.setNickname(nickname.trim());
customer.setWechatId(normalizedWechatId);
customer.setPhone(normalizedPhone);
customer.setContactPhone(normalizedPhone);
customer.setAccount(normalizedPhone == null
? "customer" + UUID.randomUUID().toString().replace("-", "")
: normalizedPhone);
customer.setAccount("customer" + UUID.randomUUID().toString().replace("-", ""));
customer.setType(0);
customer.setShopId(shopId);
customer.setShopIds(List.of(shopId));
@@ -532,8 +544,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
.eq(UserDO::getNickname, nickname.trim())
.eq(UserDO::getType, 0)
.eq(UserDO::getIsDelete, 0);
if (StringUtils.hasText(phone)) {
String normalizedPhone = phone.trim();
String normalizedName = nickname.trim();
String normalizedPhone = StringUtils.hasText(phone) ? phone.trim() : null;
if (normalizedPhone != null) {
addPhoneMatch(wrapper, normalizedPhone);
}
if (shopId != null && shopId > 0) {
@@ -545,7 +558,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
.or().in(UserDO::getId, shopUserIds));
}
}
return userMapper.selectList(wrapper).stream().map(user -> {
return userMapper.selectList(wrapper).stream()
.filter(user -> java.util.Objects.equals(normalizedName, user.getNickname()))
.filter(user -> normalizedPhone == null || java.util.Objects.equals(normalizedPhone, decryptPhone(user.getPhone())))
.map(user -> {
UserVO customer = new UserVO();
customer.setId(user.getId());
customer.setNickname(user.getNickname());
@@ -641,7 +657,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
userDO.setShopId(validateAndNormalizeShopId(userDTO.getShopId()));
}
if (userDTO.getNickname() != null) {
userDO.setNickname(userDTO.getNickname());
userDO.setNickname(Integer.valueOf(0).equals(userDO.getType())
? userDTO.getNickname().trim() : userDTO.getNickname());
}
if (userDTO.getPassword() != null) {
validatePasswordStrength(userDTO.getPassword());
@@ -710,6 +727,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
}
Integer targetUserType = userDO.getType();
UserProfileFieldSupport.requireWechatIdForServiceUser(targetUserType, userDO.getWechatId());
if (Integer.valueOf(0).equals(targetUserType)) {
String customerPhone = validateCustomerPhone(userDO.getPhone(), false);
ensureCustomerUnique(userDO.getNickname(), userDO.getWechatId(), customerPhone, id);
userDO.setCustomerIdentityHash(customerIdentityHash(userDO.getNickname(), userDO.getWechatId(), customerPhone));
} else {
userDO.setCustomerIdentityHash(null);
}
List<Long> validatedShopIds = null;
boolean shopBindingChanged = userDTO.getShopIds() != null || userDTO.getShopId() != null;
if (shopBindingChanged) {
@@ -3229,7 +3253,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
}
}
private void ensureCustomerUnique(String nickname, String phone) {
private void ensureCustomerUnique(String nickname, String wechatId, String phone) {
ensureCustomerUnique(nickname, wechatId, phone, null);
}
private void ensureCustomerUnique(String nickname, String wechatId, String phone, Long ignoredCustomerId) {
if (!StringUtils.hasText(nickname)) {
throw new RuntimeException("客户姓名不能为空");
}
@@ -3237,14 +3265,57 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
.eq(UserDO::getNickname, nickname.trim())
.eq(UserDO::getType, 0)
.eq(UserDO::getIsDelete, 0);
if (StringUtils.hasText(phone)) {
addPhoneMatch(wrapper, phone);
}
if (userMapper.selectCount(wrapper) > 0) {
String normalizedWechatId = UserProfileFieldSupport.normalizeOptionalText(wechatId);
String normalizedPhone = StringUtils.hasText(phone) ? phone.trim() : null;
boolean duplicate = userMapper.selectList(wrapper).stream().anyMatch(existing ->
!java.util.Objects.equals(ignoredCustomerId, existing.getId())
&& java.util.Objects.equals(normalizedWechatId, UserProfileFieldSupport.normalizeOptionalText(existing.getWechatId()))
&& java.util.Objects.equals(normalizedPhone, decryptPhone(existing.getPhone())));
if (duplicate) {
throw new RuntimeException("客户已存在,请选择已有客户");
}
}
private String decryptPhone(String value) {
return StringUtils.hasText(value) ? phoneCrypto.decrypt(value).trim() : null;
}
private String validateCustomerPhone(String phone, boolean required) {
String normalizedPhone = phone == null ? null : phone.trim();
if (!StringUtils.hasText(normalizedPhone)) {
if (required) throw new RuntimeException("手机号不能为空");
return null;
}
if (!normalizedPhone.matches(PHONE_REGEX)) {
throw new RuntimeException("手机号格式不正确");
}
return normalizedPhone;
}
private String customerIdentityHash(String nickname, String wechatId, String phone) {
String normalizedName = StringUtils.hasText(nickname) ? nickname.trim() : "";
String normalizedWechatId = UserProfileFieldSupport.normalizeOptionalText(wechatId);
String normalizedPhone = StringUtils.hasText(phone) ? phone.trim() : null;
return phoneCrypto.index(identityPart(normalizedName)
+ identityPart(normalizedWechatId == null ? "" : normalizedWechatId)
+ identityPart(normalizedPhone == null ? "" : normalizedPhone));
}
private String identityPart(String value) {
return value.length() + ":" + value;
}
private String normalizeArtistColor(String color) {
if (!StringUtils.hasText(color)) {
return null;
}
String value = color.trim().toUpperCase(java.util.Locale.ROOT);
if (!value.matches("#[0-9A-F]{6}")) {
throw new RuntimeException("美甲师专属颜色格式不正确");
}
return value;
}
private void addPhoneMatch(LambdaQueryWrapper<UserDO> wrapper, String phone) {
String hash = phoneCrypto.index(phone.trim());
List<Long> legacyIds = new ArrayList<>();
@@ -0,0 +1,110 @@
-- 客户允许重名及重复手机号;仅姓名、微信号、手机号组合完全相同时拒绝创建。
-- 美甲师专属颜色持久化到资料表,规划页与员工页面共用同一颜色。
DROP PROCEDURE IF EXISTS salon_v8_add_column_if_missing;
DROP PROCEDURE IF EXISTS salon_v8_add_index_if_missing;
DROP PROCEDURE IF EXISTS salon_v8_add_unique_index_if_missing;
DROP PROCEDURE IF EXISTS salon_v8_drop_index_if_exists;
DELIMITER $$
CREATE PROCEDURE salon_v8_add_column_if_missing(
IN p_table_name VARCHAR(64),
IN p_column_name VARCHAR(64),
IN p_definition TEXT
)
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = p_table_name
AND COLUMN_NAME = p_column_name
) THEN
SET @salon_v8_sql = CONCAT('ALTER TABLE `', p_table_name, '` ADD COLUMN `', p_column_name, '` ', p_definition);
PREPARE salon_v8_stmt FROM @salon_v8_sql;
EXECUTE salon_v8_stmt;
DEALLOCATE PREPARE salon_v8_stmt;
END IF;
END$$
CREATE PROCEDURE salon_v8_add_index_if_missing(
IN p_table_name VARCHAR(64),
IN p_index_name VARCHAR(64),
IN p_columns TEXT
)
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.STATISTICS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = p_table_name
AND INDEX_NAME = p_index_name
) THEN
SET @salon_v8_sql = CONCAT('ALTER TABLE `', p_table_name, '` ADD INDEX `', p_index_name, '` ', p_columns);
PREPARE salon_v8_stmt FROM @salon_v8_sql;
EXECUTE salon_v8_stmt;
DEALLOCATE PREPARE salon_v8_stmt;
END IF;
END$$
CREATE PROCEDURE salon_v8_add_unique_index_if_missing(
IN p_table_name VARCHAR(64),
IN p_index_name VARCHAR(64),
IN p_columns TEXT
)
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.STATISTICS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = p_table_name
AND INDEX_NAME = p_index_name
) THEN
SET @salon_v8_sql = CONCAT('ALTER TABLE `', p_table_name, '` ADD UNIQUE INDEX `', p_index_name, '` ', p_columns);
PREPARE salon_v8_stmt FROM @salon_v8_sql;
EXECUTE salon_v8_stmt;
DEALLOCATE PREPARE salon_v8_stmt;
END IF;
END$$
CREATE PROCEDURE salon_v8_drop_index_if_exists(
IN p_table_name VARCHAR(64),
IN p_index_name VARCHAR(64)
)
BEGIN
IF EXISTS (
SELECT 1 FROM information_schema.STATISTICS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = p_table_name
AND INDEX_NAME = p_index_name
) THEN
SET @salon_v8_sql = CONCAT('ALTER TABLE `', p_table_name, '` DROP INDEX `', p_index_name, '`');
PREPARE salon_v8_stmt FROM @salon_v8_sql;
EXECUTE salon_v8_stmt;
DEALLOCATE PREPARE salon_v8_stmt;
END IF;
END$$
DELIMITER ;
CALL salon_v8_add_column_if_missing(
't_user', 'customer_identity_hash',
'char(64) NULL COMMENT ''客户姓名、微信号和手机号组合HMAC'''
);
CALL salon_v8_add_column_if_missing(
't_user', 'active_customer_identity_hash',
'char(64) GENERATED ALWAYS AS (CASE WHEN type = 0 AND COALESCE(is_delete, 0) = 0 THEN customer_identity_hash ELSE NULL END) STORED COMMENT ''有效客户组合身份索引'''
);
CALL salon_v8_add_column_if_missing(
't_nail_artist_info', 'color',
'varchar(7) NULL COMMENT ''美甲师规划专属颜色'''
);
CALL salon_v8_drop_index_if_exists('t_user', 'uk_user_phone_hash');
CALL salon_v8_add_index_if_missing('t_user', 'idx_user_phone_hash', '(`phone_hash`)');
CALL salon_v8_add_unique_index_if_missing(
't_user', 'uk_user_active_customer_identity_hash', '(`active_customer_identity_hash`)'
);
DROP PROCEDURE IF EXISTS salon_v8_add_column_if_missing;
DROP PROCEDURE IF EXISTS salon_v8_add_index_if_missing;
DROP PROCEDURE IF EXISTS salon_v8_add_unique_index_if_missing;
DROP PROCEDURE IF EXISTS salon_v8_drop_index_if_exists;
+7 -4
View File
@@ -9,6 +9,7 @@ Page({
creating: false,
createForm: {
nickname: '',
wechatId: '',
phone: ''
}
},
@@ -72,6 +73,7 @@ Page({
this.setData({
createForm: {
nickname: '',
wechatId: '',
phone: ''
}
})
@@ -80,18 +82,19 @@ Page({
async submitCustomer() {
const form = this.data.createForm
const nickname = String(form.nickname || '').trim()
const wechatId = String(form.wechatId || '').trim()
const phone = String(form.phone || '').trim()
if (!nickname || !phone) {
wx.showToast({ title: '请填写客户姓名和手机号', icon: 'none' })
if (!nickname) {
wx.showToast({ title: '请填写客户姓名', icon: 'none' })
return
}
if (!/^1[3-9]\d{9}$/.test(phone)) {
if (phone && !/^1[3-9]\d{9}$/.test(phone)) {
wx.showToast({ title: '请输入正确手机号', icon: 'none' })
return
}
this.setData({ creating: true })
try {
await customersApi.create({ nickname, phone })
await customersApi.create({ nickname, wechatId: wechatId || undefined, phone: phone || undefined })
wx.showToast({ title: '客户已新增', icon: 'success' })
this.resetCreateForm()
this.setData({ createModalVisible: false })
@@ -0,0 +1,49 @@
const assert = require('assert')
const customersApi = require('../../api/customers')
let definition
global.Page = value => { definition = value }
global.wx = {
showToast: () => {},
navigateTo: () => {}
}
require('./index')
function createPage() {
return {
...definition,
data: JSON.parse(JSON.stringify(definition.data)),
setData(values) {
Object.entries(values).forEach(([key, value]) => {
const parts = key.split('.')
let target = this.data
for (let index = 0; index < parts.length - 1; index += 1) target = target[parts[index]]
target[parts[parts.length - 1]] = value
})
}
}
}
async function run() {
const page = createPage()
let submitted
let toast
global.wx.showToast = options => { toast = options.title }
customersApi.create = async value => { submitted = value }
customersApi.list = async () => ({ list: [] })
page.setData({ 'createForm.nickname': '小周', 'createForm.wechatId': 'wx_zhou' })
await page.submitCustomer()
assert.deepStrictEqual(submitted, { nickname: '小周', wechatId: 'wx_zhou', phone: undefined })
submitted = undefined
page.setData({ 'createForm.nickname': '', 'createForm.phone': '' })
await page.submitCustomer()
assert.strictEqual(submitted, undefined)
assert.strictEqual(toast, '请填写客户姓名')
}
run().catch(error => {
console.error(error)
process.exitCode = 1
})
+6 -2
View File
@@ -34,8 +34,12 @@
<input value="{{createForm.nickname}}" data-field="nickname" bindinput="onCreateInput" placeholder="请输入客户姓名" />
</view>
<view class="modal-field">
<text class="required-label">手机号</text>
<input value="{{createForm.phone}}" data-field="phone" bindinput="onCreateInput" type="number" maxlength="11" placeholder="请输入手机号" />
<text>微信号</text>
<input value="{{createForm.wechatId}}" data-field="wechatId" bindinput="onCreateInput" placeholder="选填" />
</view>
<view class="modal-field">
<text>手机号</text>
<input value="{{createForm.phone}}" data-field="phone" bindinput="onCreateInput" type="number" maxlength="11" placeholder="选填" />
</view>
</view>
<button class="primary-btn modal-submit" loading="{{creating}}" bindtap="submitCustomer">保存客户</button>
+37 -3
View File
@@ -2,11 +2,13 @@ const employeesApi = require('../../api/employees')
const { chooseImageFilePath, uploadObjectFile } = require('../../utils/upload')
const DEFAULT_EMPLOYEE_PASSWORD = 'Fingertip@123'
const EMPLOYEE_COLORS = ['#7BA7C7', '#8FB89A', '#A894C7', '#D7A86E', '#D98DA5', '#79A6A3', '#B9A16B', '#9BA9C8']
Page({
data: {
pickerMode: false,
appointmentContext: { date: '', time: '', durationMinutes: '' },
employeeColors: EMPLOYEE_COLORS,
onboardingVisible: false,
createdEmployee: null,
form: {
@@ -15,6 +17,7 @@ Page({
account: '',
password: DEFAULT_EMPLOYEE_PASSWORD,
wechatId: '',
color: '#8FB89A',
avatar: '',
avatarUrl: ''
},
@@ -37,10 +40,15 @@ Page({
const field = event.currentTarget.dataset.field
const value = event.detail.value
const updates = { [`form.${field}`]: value }
if (field === 'phone' && !this.data.form.account) updates['form.account'] = value
if (field === 'account') this._accountManuallyEdited = true
if (field === 'phone' && !this._accountManuallyEdited) updates['form.account'] = value
this.setData(updates)
},
selectColor(event) {
this.setData({ 'form.color': event.currentTarget.dataset.color })
},
async chooseAvatar() {
if (this.data.avatarUploading || this.data.creating) return
try {
@@ -74,7 +82,7 @@ Page({
const account = String(form.account || '').trim()
const password = String(form.password || '').trim()
const wechatId = String(form.wechatId || '').trim()
if (!nickname || !phone || !account || !password || !wechatId) {
if (!nickname || !phone || !account || !password) {
wx.showToast({ title: '请补全美甲师信息', icon: 'none' })
return
}
@@ -91,6 +99,7 @@ Page({
account,
password,
wechatId,
color: form.color,
avatar: form.avatar || undefined,
type: 3
})
@@ -127,7 +136,32 @@ Page({
},
skipFirstSchedule() {
this.finishCreated(!this.data.pickerMode, false)
if (this.data.savingDefaultSchedule || !this.data.createdEmployee) return
this.setData({ savingDefaultSchedule: true })
employeesApi.saveScheduleRule({
artistId: this.data.createdEmployee.id,
presetType: 'CUSTOM',
workDays: [1, 2, 3, 4, 5, 6, 7],
startTime: '00:00',
endTime: '23:59',
status: 1,
remark: '新建美甲师默认全天可预约,可在排班设置中调整'
}).then(() => {
this.finishCreated(!this.data.pickerMode, false)
}).catch(error => {
wx.showModal({
title: '默认排班设置失败',
content: error.message || '未设置排班前,该美甲师暂不可预约。请重试或返回排班设置。',
confirmText: '重试',
cancelText: '稍后设置',
success: result => {
if (result.confirm) this.skipFirstSchedule()
else this.setData({ savingDefaultSchedule: false })
}
})
}).finally(() => {
if (this.data.onboardingVisible) this.setData({ savingDefaultSchedule: false })
})
},
finishCreated(autoSelect, scheduleSaved) {
@@ -34,19 +34,33 @@ const page = {
async function run() {
page.onInput({ currentTarget: { dataset: { field: 'phone' } }, detail: { value: '13800138000' } })
assert.strictEqual(page.data.form.account, '13800138000')
page.onInput({ currentTarget: { dataset: { field: 'account' } }, detail: { value: 'staff_zhou' } })
page.onInput({ currentTarget: { dataset: { field: 'phone' } }, detail: { value: '13900139000' } })
assert.strictEqual(page.data.form.account, 'staff_zhou')
assert.strictEqual(page.data.form.color, '#8FB89A')
Object.assign(page.data.form, {
nickname: '小周',
phone: '13800138000',
account: '13800138000',
password: 'Fingertip@123',
wechatId: 'wx_zhou'
wechatId: ''
})
employeesApi.createUser = async () => 88
employeesApi.createUser = async payload => {
assert.strictEqual(payload.wechatId, '')
assert.strictEqual(payload.color, '#8FB89A')
return 88
}
await page.submit()
assert.strictEqual(page.data.onboardingVisible, true)
assert.strictEqual(emitted, undefined)
page.data.pickerMode = true
employeesApi.saveScheduleRule = async payload => {
assert.deepStrictEqual(payload.workDays, [1, 2, 3, 4, 5, 6, 7])
assert.strictEqual(payload.startTime, '00:00')
assert.strictEqual(payload.endTime, '23:59')
}
page.skipFirstSchedule()
await new Promise(resolve => setImmediate(resolve))
assert.strictEqual(emitted.name, 'employeeCreated')
assert.deepStrictEqual(emitted.value, { id: 88, name: '小周', title: '小周', avatar: '', autoSelect: false, scheduleSaved: false })
assert.strictEqual(navigatedBack, true)
@@ -33,8 +33,14 @@
<input value="{{form.password}}" data-field="password" bindinput="onInput" password placeholder="请输入初始密码" />
</view>
<view class="field">
<text class="field-label required">微信号</text>
<input value="{{form.wechatId}}" data-field="wechatId" bindinput="onInput" placeholder="请输入微信号" />
<text class="field-label">微信号</text>
<input value="{{form.wechatId}}" data-field="wechatId" bindinput="onInput" placeholder="选填" />
</view>
<view class="field color-field">
<text class="field-label required">专属颜色</text>
<view class="color-options">
<view wx:for="{{employeeColors}}" wx:key="*this" class="color-option {{form.color === item ? 'selected' : ''}}" style="background: {{item}};" data-color="{{item}}" bindtap="selectColor"></view>
</view>
</view>
</view>
@@ -47,8 +53,8 @@
<view class="onboarding-icon">✓</view>
<text class="onboarding-title">美甲师已创建</text>
<text class="onboarding-desc">{{pickerMode ? '设置常规排班后,可继续把当前预约分配给该美甲师。' : '为新美甲师设置首个常规排班,之后即可正常承接预约。'}}</text>
<button class="primary-btn onboarding-primary" bindtap="setupFirstSchedule">{{pickerMode ? '设置排班并分配' : '立即设置排班'}}</button>
<button class="onboarding-skip" bindtap="skipFirstSchedule">{{pickerMode ? '暂不设置' : '稍后设置'}}</button>
<button class="primary-btn onboarding-primary" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="setupFirstSchedule">{{pickerMode ? '设置排班并分配' : '立即设置排班'}}</button>
<button class="onboarding-skip" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="skipFirstSchedule">{{pickerMode ? '暂不设置' : '稍后设置(默认全天可约)'}}</button>
</view>
</view>
</view>
@@ -80,6 +80,25 @@
width: 176rpx;
}
.color-options {
display: flex;
flex-wrap: wrap;
gap: 18rpx;
padding: 10rpx 0;
}
.color-option {
width: 44rpx;
height: 44rpx;
border: 4rpx solid #fff;
border-radius: 50%;
box-shadow: 0 0 0 1rpx #d9e3dd;
}
.color-option.selected {
box-shadow: 0 0 0 4rpx #287a62;
}
.onboarding-mask {
position: fixed;
z-index: 50;
+9 -6
View File
@@ -466,16 +466,17 @@ Page({
},
buildDayView(calendar) {
const minuteScale = 4
const startMinute = dateUtil.minutesOfDay(calendar.businessStartTime || '10:00')
const endMinute = dateUtil.minutesOfDay(calendar.businessEndTime || '22:00')
const timelineHeight = Math.max(560, endMinute - startMinute)
const timelineHeight = Math.max(560, (endMinute - startMinute) * minuteScale)
const laneHeaderHeight = 54
const hours = []
for (let cursor = startMinute; cursor <= endMinute; cursor += 60) {
hours.push({
value: cursor,
label: dateUtil.timeFromMinutes(cursor),
top: cursor - startMinute + laneHeaderHeight
top: (cursor - startMinute) * minuteScale + laneHeaderHeight
})
}
const filteredArtists = this.data.selectedArtistId
@@ -491,8 +492,9 @@ Page({
const itemStart = resolveAppointmentStartMinute(item)
return {
...item,
top: Math.max(0, itemStart - startMinute) + laneHeaderHeight,
height: Math.max(64, item.durationMinutes || 60),
top: Math.max(0, itemStart - startMinute) * minuteScale + laneHeaderHeight,
height: Math.max(100, (item.durationMinutes || 60) * minuteScale),
compact: Number(item.durationMinutes || 60) <= 15,
timeText: resolveAppointmentTimeText(item)
}
})
@@ -505,8 +507,9 @@ Page({
const itemStart = resolveAppointmentStartMinute(item)
return {
...item,
top: Math.max(0, itemStart - startMinute) + laneHeaderHeight,
height: Math.max(64, item.durationMinutes || 60),
top: Math.max(0, itemStart - startMinute) * minuteScale + laneHeaderHeight,
height: Math.max(100, (item.durationMinutes || 60) * minuteScale),
compact: Number(item.durationMinutes || 60) <= 15,
timeText: resolveAppointmentTimeText(item)
}
})
@@ -87,6 +87,11 @@ async function run() {
assert.strictEqual(dayState.dayLanes[0].artistId, '__unassigned__')
assert.strictEqual(dayState.dayLanes[0].blocks.length, 1)
assert.strictEqual(dayState.unassignedCount, 1)
assert.strictEqual(dayState.timelineHeight, 2934)
assert.strictEqual(dayState.hours.find(item => item.label === '14:00').top, 1014)
assert.strictEqual(dayState.dayLanes[0].blocks[0].height, 240)
assert.match(planningWxss, /background-size:\s*100% 240rpx/)
assert.match(planningWxss, /\.control-card\s*\{[^}]*padding:\s*12rpx 16rpx;/)
const requestPage = createPage({ viewMode: 'day', currentDateText: '2026-10-11' })
let calendarRequests = 0
+1 -1
View File
@@ -95,7 +95,7 @@
<view class="chip-dot" style="background: {{item.color}};"></view>
<text>{{item.name}}</text>
</view>
<view wx:for="{{item.blocks}}" wx:for-item="block" wx:key="orderItemId" class="appointment-block {{block.status === 0 ? 'pending' : ''}}" style="top: {{block.top}}rpx; height: {{block.height}}rpx; border-left-color: {{item.color}};" data-id="{{block.orderItemId}}" bindtap="openAppointment">
<view wx:for="{{item.blocks}}" wx:for-item="block" wx:key="orderItemId" class="appointment-block {{block.status === 0 ? 'pending' : ''}} {{block.compact ? 'compact' : ''}}" style="top: {{block.top}}rpx; height: {{block.height}}rpx; border-left-color: {{item.color}};" data-id="{{block.orderItemId}}" bindtap="openAppointment">
<text class="block-title">{{block.customerName}}</text>
<text class="block-meta">{{block.timeText}} · {{block.productTitle}}</text>
<text class="block-status">{{block.statusText}}</text>
+35 -15
View File
@@ -72,7 +72,7 @@
}
.control-card {
padding: 18rpx;
padding: 12rpx 16rpx;
}
.calendar-error-card {
@@ -175,8 +175,8 @@
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 8rpx;
margin-top: 18rpx;
padding: 8rpx;
margin-top: 10rpx;
padding: 6rpx;
border-radius: 12px;
background: #f1ece4;
}
@@ -185,7 +185,7 @@
display: flex;
align-items: center;
justify-content: center;
height: 58rpx;
height: 46rpx;
border-radius: 10px;
color: #7d756c;
font-size: 24rpx;
@@ -203,7 +203,7 @@
.artist-filter {
display: flex;
width: 100%;
margin-top: 16rpx;
margin-top: 10rpx;
white-space: nowrap;
}
@@ -291,13 +291,13 @@
.day-board {
height: 820rpx;
margin-top: 18rpx;
margin-top: 12rpx;
overflow: hidden;
}
.timeline-wrap {
position: relative;
min-height: 720rpx;
min-height: 774rpx;
}
.time-axis {
@@ -344,7 +344,7 @@
flex-shrink: 0;
border-right: 1rpx solid #e7ece9;
background-image: linear-gradient(to bottom, rgba(203, 220, 213, 0.45) 1rpx, transparent 1rpx);
background-size: 100% 60rpx;
background-size: 100% 240rpx;
}
.lane-head {
@@ -367,9 +367,9 @@
left: 12rpx;
display: flex;
flex-direction: column;
gap: 4rpx;
gap: 2rpx;
overflow: hidden;
padding: 12rpx 12rpx;
padding: 6rpx 10rpx;
border-left: 8rpx solid #7ba7c7;
border-radius: 10px;
background: #fff7ee;
@@ -389,28 +389,48 @@
.block-title {
color: #17211f;
font-size: 24rpx;
font-size: 22rpx;
font-weight: 800;
}
.block-meta,
.block-status {
color: #7e756b;
font-size: 20rpx;
font-size: 18rpx;
line-height: 1.25;
}
.block-actions {
display: flex;
gap: 10rpx;
margin-top: 6rpx;
margin-top: 2rpx;
color: #247b63;
font-size: 20rpx;
font-size: 18rpx;
font-weight: 800;
}
.block-actions text {
padding: 2rpx 6rpx;
padding: 0 5rpx;
}
.appointment-block.compact {
gap: 0;
padding: 2rpx 8rpx;
}
.appointment-block.compact .block-title {
font-size: 20rpx;
line-height: 1.05;
}
.appointment-block.compact .block-meta {
font-size: 16rpx;
line-height: 1.05;
}
.appointment-block.compact .block-status,
.appointment-block.compact .block-actions {
display: none;
}
.lane-empty {
+8
View File
@@ -1,5 +1,13 @@
# 项目变更记录
## 2026-10-29 Salon 客户建档与员工默认排班优化
- 规划日视图时间轴放大为每分钟4rpx,使30分钟预约卡片获得完整信息高度;收紧日期控制区和视图切换区的垂直留白。
- 客户新增姓名必填、微信号和手机号选填并按姓名/微信号/手机号排列;客户可重名或复用联系方式,仅姓名、微信号、手机号组合完全相同时禁止建档,联系方式匹配按密文解密后的精确值校验。
- 新建美甲师表单增加专属颜色,颜色保存在员工资料并显示到规划日历;微信号选填,登录账号随手机号自动带入,手动编辑账号后不再覆盖。
- 跳过首次排班引导时先写入每周七天00:00–23:59的常规规则,成功后才返回。
- 新增 Flyway V8 `JC-Salon-Core/src/main/resources/db/migration/V8__客户联系方式去重和美甲师专属颜色_20261029.sql`,移除客户手机号全局唯一索引,增加客户组合身份活动记录唯一索引及员工颜色字段;不修改冻结初始化 SQL。
## 2026-10-26 Salon 店长注册审核模式与门店经营有效期
- 店长注册审核支持后台配置自动批准或人工复核;自动批准仅在该申请关联的门店资料内容审核通过后执行,店员原审核流程保持不变,并增加独立事务补偿检查。