修复预约客户与员工管理问题

This commit is contained in:
2026-07-24 23:11:23 +08:00
parent cef84e0d01
commit cb14f3fe4a
11 changed files with 213 additions and 12 deletions
@@ -466,9 +466,9 @@ const handleClearDraft = (showMessage = true) => {
const formRules = {
identity: [{ required: true, message: '请输入身份', trigger: 'blur' }],
experience: [{ required: true, message: '请输入从业年限', trigger: 'blur' }],
skills: [{ required: true, message: '请选择技能标签', trigger: 'change' }],
skills: [],
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
portfolio: [{ required: true, message: '请选择作品作品', trigger: 'change' }]
portfolio: []
} as any
/**
@@ -33,6 +33,7 @@ import com.xiaowang.jayucloud.core.modules.order.mapper.OrderMapper;
import com.xiaowang.jayucloud.core.modules.product.mapper.ProductMapper;
import com.xiaowang.jayucloud.core.modules.shop.mapper.ShopMapper;
import com.xiaowang.jayucloud.core.modules.shop.mapper.ShopScheduleExceptionMapper;
import com.xiaowang.jayucloud.core.modules.shop.support.UserShopBindingSupport;
import com.xiaowang.jayucloud.core.modules.user.mapper.UserMapper;
import com.xiaowang.jayucloud.core.modules.planning.service.AppointmentCapacityService;
import com.xiaowang.jayucloud.core.modules.order.service.OrderService;
@@ -105,6 +106,7 @@ public class PlanningServiceImpl implements PlanningService {
private final ObjectStorageUrlSupport objectStorageUrlSupport;
private final ShopMapper shopMapper;
private final ShopScheduleExceptionMapper shopScheduleExceptionMapper;
private final UserShopBindingSupport userShopBindingSupport;
private final AppointmentCapacityService appointmentCapacityService;
private final OrderService orderService;
private final TimeOrderedSnowflakeIdGenerator snowflakeIdGenerator;
@@ -168,7 +170,7 @@ public class PlanningServiceImpl implements PlanningService {
}
Long shopId = requirePlanningShopId(currentUser);
requireAppointmentDuration(dto.getDurationMinutes());
ProductDO product = resolveAppointmentProduct(dto, shopId);
ProductDO product = resolveCreateAppointmentProduct(dto, shopId);
UserDO artist = requireActiveArtist(dto.getArtistId(), shopId);
UserDO customer = resolveCustomer(shopId, dto);
@@ -1084,6 +1086,30 @@ public class PlanningServiceImpl implements PlanningService {
return product;
}
private ProductDO resolveCreateAppointmentProduct(PlanningAppointmentCreateDTO dto, Long shopId) {
if (dto.getProductId() != null) {
return requireActiveProduct(dto.getProductId(), shopId);
}
requireManualAppointmentProduct(dto);
ProductDO product = new ProductDO();
product.setShopId(shopId);
product.setTitle(trimToNull(dto.getManualProductTitle()));
product.setDescription(trimToNull(dto.getManualProductDescription()));
product.setPrice(dto.getManualProductPrice());
product.setTags(trimToNull(dto.getManualProductTags()));
product.setPrecautions(trimToNull(dto.getManualProductPrecautions()));
product.setImageFileIds(trimToNull(dto.getManualProductImageFileIds()));
product.setApproximateDuration(String.valueOf(dto.getDurationMinutes()));
product.setBookableArtists(dto.getArtistId() == null ? null : String.valueOf(dto.getArtistId()));
product.setFrontVisible(0);
product.setSourceType("MANAGER_APPOINTMENT");
product.setLikeCount(0);
product.setCollectCount(0);
product.setIsDelete(0);
productMapper.insert(product);
return product;
}
private ProductDO resolveAppointmentProduct(PlanningAppointmentCreateDTO dto, Long shopId) {
if (dto.getProductId() != null) {
return requireActiveProduct(dto.getProductId(), shopId);
@@ -1184,12 +1210,13 @@ public class PlanningServiceImpl implements PlanningService {
customer.setNickname(firstNonBlank(customerName, phone, "到店客户"));
customer.setPhone(phone);
customer.setContactPhone(phone);
customer.setAccount("guest" + snowflakeIdGenerator.nextIdString());
customer.setAccount("tmp" + snowflakeIdGenerator.nextIdString());
customer.setPassword(ENCODED_UNSET_PASSWORD);
customer.setType(0);
customer.setStatus(1);
customer.setIsDelete(0);
userMapper.insert(customer);
userShopBindingSupport.ensureUserBoundToShop(customer.getId(), shopId);
return customer;
}
@@ -1927,7 +1927,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
throw new RuntimeException("用户类型错误");
}
if (currentUserType <= targetUserType) {
if (currentUserType < targetUserType) {
/**
* Run business method `RuntimeException`.
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
@@ -29,6 +29,7 @@ import com.xiaowang.jayucloud.core.modules.shop.entity.ShopDO;
import com.xiaowang.jayucloud.core.modules.shop.entity.ShopScheduleExceptionDO;
import com.xiaowang.jayucloud.core.modules.shop.mapper.ShopMapper;
import com.xiaowang.jayucloud.core.modules.shop.mapper.ShopScheduleExceptionMapper;
import com.xiaowang.jayucloud.core.modules.shop.support.UserShopBindingSupport;
import com.xiaowang.jayucloud.core.modules.user.entity.UserDO;
import com.xiaowang.jayucloud.core.modules.user.mapper.UserMapper;
import com.xiaowang.jayucloud.core.support.id.TimeOrderedSnowflakeIdGenerator;
@@ -96,6 +97,9 @@ class PlanningServiceImplTest {
@Mock
private ShopScheduleExceptionMapper shopScheduleExceptionMapper;
@Mock
private UserShopBindingSupport userShopBindingSupport;
@Mock
private AppointmentCapacityService appointmentCapacityService;
@@ -124,6 +128,7 @@ class PlanningServiceImplTest {
objectStorageUrlSupport,
shopMapper,
shopScheduleExceptionMapper,
userShopBindingSupport,
appointmentCapacityService,
orderService,
snowflakeIdGenerator
@@ -131,7 +136,7 @@ class PlanningServiceImplTest {
}
@Test
void createAppointmentShouldStoreManualProductSnapshotWithoutCreatingProduct() {
void createAppointmentShouldCreateManualProductAndStoreSnapshot() {
UserDO manager = user(2, 8L);
UserDO artist = user(3, 8L);
artist.setId(20L);
@@ -160,6 +165,11 @@ class PlanningServiceImplTest {
when(userMapper.selectById(30L)).thenReturn(customer);
when(shopMapper.selectById(8L)).thenReturn(shop);
when(snowflakeIdGenerator.nextIdString()).thenReturn("202606260001");
when(productMapper.insert(any(ProductDO.class))).thenAnswer(invocation -> {
ProductDO product = invocation.getArgument(0);
product.setId(100L);
return 1;
});
when(orderMapper.insert(any(OrderDO.class))).thenAnswer(invocation -> {
OrderDO order = invocation.getArgument(0);
order.setId(200L);
@@ -203,8 +213,11 @@ class PlanningServiceImplTest {
var appointment = planningService.createAppointment(manager, dto);
org.mockito.Mockito.verify(productMapper, org.mockito.Mockito.never()).insert(any(ProductDO.class));
assertThat(storedItem[0].getProductId()).isNull();
ArgumentCaptor<ProductDO> productCaptor = ArgumentCaptor.forClass(ProductDO.class);
org.mockito.Mockito.verify(productMapper).insert(productCaptor.capture());
assertThat(productCaptor.getValue().getSourceType()).isEqualTo("MANAGER_APPOINTMENT");
assertThat(productCaptor.getValue().getFrontVisible()).isZero();
assertThat(storedItem[0].getProductId()).isEqualTo(productCaptor.getValue().getId());
assertThat(storedItem[0].getAppointmentProductTitle()).isEqualTo("日落贝壳");
assertThat(storedItem[0].getAppointmentProductDescription()).isEqualTo("轻透贝壳款");
assertThat(storedItem[0].getAppointmentProductTags()).isEqualTo("贝壳");
@@ -245,6 +258,11 @@ class PlanningServiceImplTest {
when(userMapper.selectById(20L)).thenReturn(artist);
when(shopMapper.selectById(8L)).thenReturn(shop);
when(snowflakeIdGenerator.nextIdString()).thenReturn("202607200001", "202607200002");
when(productMapper.insert(any(ProductDO.class))).thenAnswer(invocation -> {
ProductDO product = invocation.getArgument(0);
product.setId(100L);
return 1;
});
when(userMapper.insert(any(UserDO.class))).thenAnswer(invocation -> {
UserDO customer = invocation.getArgument(0);
customer.setId(30L);
@@ -279,9 +297,12 @@ class PlanningServiceImplTest {
assertThat(customerCaptor.getValue().getNickname()).isEqualTo("到店王女士");
assertThat(customerCaptor.getValue().getPhone()).isNull();
assertThat(customerCaptor.getValue().getContactPhone()).isNull();
assertThat(customerCaptor.getValue().getAccount()).isEqualTo("guest202607200001");
org.mockito.Mockito.verify(productMapper, org.mockito.Mockito.never()).insert(any(ProductDO.class));
assertThat(storedItem[0].getProductId()).isNull();
ArgumentCaptor<ProductDO> productCaptor = ArgumentCaptor.forClass(ProductDO.class);
org.mockito.Mockito.verify(productMapper).insert(productCaptor.capture());
assertThat(customerCaptor.getValue().getAccount()).isEqualTo("tmp202607200001");
assertThat(productCaptor.getValue().getSourceType()).isEqualTo("MANAGER_APPOINTMENT");
assertThat(storedItem[0].getProductId()).isEqualTo(productCaptor.getValue().getId());
org.mockito.Mockito.verify(userShopBindingSupport).ensureUserBoundToShop(30L, 8L);
assertThat(storedItem[0].getAppointmentProductTitle()).isEqualTo("净色护理");
assertThat(storedItem[0].getDepositPaid()).isTrue();
assertThat(storedItem[0].getNeedRemoval()).isTrue();
+7
View File
@@ -37,6 +37,13 @@ module.exports = {
})
},
resetPassword(userId) {
return request({
url: `/manager/employees/${userId}/reset-password`,
method: 'POST'
})
},
deleteUser(userId) {
return request({
url: `/manager/employees/${userId}`,
@@ -0,0 +1,9 @@
const request = require('../utils/request')
module.exports = {
getResetDefaultPassword() {
return request({
url: '/system-parameter-config/admin/user-default-password/reset'
})
}
}
+55 -1
View File
@@ -1,4 +1,5 @@
const employeesApi = require('../../api/employees')
const systemParameterConfigApi = require('../../api/system-parameter-config')
const EMPLOYEE_COLORS = ['#7AA9C2', '#8EB99B', '#BDA7D8', '#D7B17D', '#D98D8D']
const EMPTY_FIELD_TEXT = '未填写'
@@ -18,7 +19,9 @@ Page({
employee: {},
loadError: '',
deleteConfirmVisible: false,
deletingEmployee: false
deletingEmployee: false,
resetConfirmVisible: false,
resettingPassword: false
},
onLoad(options) {
@@ -84,6 +87,57 @@ Page({
stopTap() {
},
requestResetPassword() {
if (this.data.resettingPassword) {
return
}
this.setData({ resetConfirmVisible: true })
},
closeResetConfirm() {
if (this.data.resettingPassword) {
return
}
this.setData({ resetConfirmVisible: false })
},
async confirmResetPassword() {
if (this.data.resettingPassword || !this.data.id) {
return
}
this.setData({ resettingPassword: true })
try {
const success = await employeesApi.resetPassword(this.data.id)
if (!success) {
throw new Error('密码重置失败')
}
const result = await systemParameterConfigApi.getResetDefaultPassword()
const password = String(result && result.password || '').trim()
if (!password) {
throw new Error('默认密码为空')
}
this.setData({ resetConfirmVisible: false })
wx.showModal({
title: '密码已重置',
content: `系统默认密码:${password}`,
confirmText: '复制密码',
cancelText: '关闭',
success: (modalResult) => {
if (modalResult.confirm) {
wx.setClipboardData({
data: password,
success: () => wx.showToast({ title: '密码已复制', icon: 'success' })
})
}
}
})
} catch (error) {
wx.showToast({ title: error.message || '密码重置失败', icon: 'none' })
} finally {
this.setData({ resettingPassword: false })
}
},
async confirmDeleteEmployee() {
if (this.data.deletingEmployee) {
return
@@ -76,6 +76,14 @@
</view>
</view>
<view wx:if="{{!loadError}}" class="card reset-card">
<view class="reset-copy">
<text class="reset-title">重置登录密码</text>
<text class="reset-desc">重置后使用系统默认密码登录,建议员工首次登录后修改。</text>
</view>
<button class="reset-btn" loading="{{resettingPassword}}" disabled="{{resettingPassword}}" bindtap="requestResetPassword">重置密码</button>
</view>
<view wx:if="{{!loadError}}" class="card delete-card">
<view class="delete-shell">
<view class="delete-icon">!</view>
@@ -121,4 +129,16 @@
</view>
</view>
</view>
<view wx:if="{{resetConfirmVisible}}" class="delete-confirm-mask" bindtap="closeResetConfirm">
<view class="delete-confirm-panel" catchtap="stopTap">
<view class="delete-confirm-icon">!</view>
<text class="delete-confirm-title">确认重置密码</text>
<text class="delete-confirm-desc">重置后当前员工需要使用系统默认密码登录。</text>
<view class="delete-confirm-actions">
<button class="delete-confirm-cancel" disabled="{{resettingPassword}}" bindtap="closeResetConfirm">取消</button>
<button class="delete-confirm-submit" loading="{{resettingPassword}}" disabled="{{resettingPassword}}" bindtap="confirmResetPassword">确认重置</button>
</view>
</view>
</view>
</view>
@@ -135,6 +135,54 @@
font-weight: 800;
}
.reset-card {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20rpx;
margin-top: 24rpx;
padding: 28rpx;
}
.reset-copy {
flex: 1;
min-width: 0;
}
.reset-title,
.reset-desc {
display: block;
}
.reset-title {
color: #302c27;
font-size: 28rpx;
font-weight: 800;
}
.reset-desc {
margin-top: 10rpx;
color: #7b6f66;
font-size: 22rpx;
line-height: 1.5;
}
.reset-btn {
flex: 0 0 auto;
min-width: 180rpx;
margin: 0;
border: 1rpx solid #b9d9c2;
border-radius: 14rpx;
background: #eef8f0;
color: #3f7950;
font-size: 24rpx;
font-weight: 800;
}
.reset-btn::after {
border: 0;
}
.delete-card {
margin-top: 24rpx;
padding: 28rpx;
+6
View File
@@ -529,3 +529,9 @@
- 店铺标签管理补齐展示名、场景分组、排序、前台可见和三种自定义 HEX 颜色,并保留快捷色卡。
- 预约手工作品标签改为横向滑动并隐藏滚动条,输入区和底部操作区补齐宽度约束。
- 小程序启用组件按需注入,关闭本地自动热重载,并压缩主包图标资源。
## 2026-07-24 预约客户与员工管理修复
- 变更原因:预约新增的临时客户缺少统一账号前缀和当前店铺绑定,手工预约作品没有关联 `product_id`,店长密码重置等级判断错误,后台表单存在不必要的必填校验,店务小程序缺少员工重置密码入口。
- 处理方式:临时客户账号改为 `tmp` 前缀并绑定预约门店;手工预约创建隐藏的 `MANAGER_APPOINTMENT` 商品并写入订单项;允许店长重置美甲师密码;取消手机号、作品和技能的必填规则;小程序复用现有重置接口并读取系统默认密码后展示和复制。
- 数据库说明:本次不新增 SQL、不修改初始化 SQL、不迁移历史 `guest` 客户或历史空 `product_id` 记录。
- 验证方式:执行 `JY-Core` 受影响测试和编译,执行设计师前端构建/静态检查,检查店务小程序 JS、JSON、WXML、WXSS 语法及 `git diff --check`。
+9
View File
@@ -594,3 +594,12 @@
- 处理方式:直接上传入口统一使用 `try-with-resources` 管理输入流;开发 Nacos `JayuCloud-Dev / DEFAULT_GROUP / middleware.yaml` 的 `object-storage.qiniu.kodo.zone` 改为 `z2`,不在代码中硬编码区域。
- 以后避免:检索所有 `MultipartFile.getInputStream()` 的调用方,确认资源责任明确;对象存储区域错误先对照桶实际区域和当前环境 Nacos 配置,不要只修改 SDK 映射。
- 验证方式:`JY-Core` 编译通过;Nacos 配置回读为 `z2`;上传后观察 Tomcat multipart 清理日志和七牛异步副本日志。
## 2026-07-24 GitNexus 全局依赖与 Node 版本不兼容
问题:在仓库执行 `.gitnexus/run.cjs` 时,即使切换到 Node 22/24,仍因全局 GitNexus 依赖的 `pino` 调用 `diagnostics_channel.tracingChannel` 失败,无法执行 `impact` 或 `detect_changes`。
原因:当前 PATH 指向的全局 GitNexus 安装及其依赖组合不兼容,问题不再只是微信开发者工具 Node 16 抢占 PATH。
处理方式:本次改动改用静态调用链核对并记录检测缺口;未修改全局依赖或仓库索引。
预防方式:后续先验证 `node -v`、全局 GitNexus 依赖加载和 `.gitnexus/run.cjs --help`,失败时优先使用仓库配置的 GitNexus MCP 或修复隔离的项目依赖,不要直接修改业务代码规避工具错误。