新建预约必填与默认值调整:款式名称必填加星标,价格空值默认0、时长空值默认60,移除名称为空回退客户姓名/散客款式,非必填标签统一(选填)
自动发布开发环境 Nacos 配置 / publish (push) Successful in 26s

This commit is contained in:
2026-11-08 02:08:54 +08:00
parent 338283090b
commit b8904d92d1
7 changed files with 95 additions and 47 deletions
@@ -809,14 +809,11 @@ public class PlanningServiceImpl implements PlanningService {
String title = trimToNull(dto.getManualProductTitle());
String imageFileIds = trimToNull(dto.getManualProductImageFileIds());
if (!hasText(title)) {
title = firstNonBlank(dto.getCustomerName(), hasText(imageFileIds) ? "散客款式" : null);
}
if (!hasText(title) && !hasText(imageFileIds)) {
throw new RuntimeException("请填写美甲款式名称或上传款式图片");
throw new RuntimeException("请填写美甲款式名称");
}
BigDecimal price = dto.getManualProductPrice() == null ? dto.getAmount() : dto.getManualProductPrice();
if (price == null) {
throw new RuntimeException("成交金额不能为空");
price = BigDecimal.ZERO;
}
if (price.compareTo(BigDecimal.ZERO) < 0) {
throw new RuntimeException("成交金额不能小于0");
@@ -451,7 +451,7 @@ class PlanningServiceImplTest {
}
@Test
void createsWalkInAppointmentWithoutCustomerUsingWalkInStyleTitle() {
void createsWalkInAppointmentWithManualStyleTitle() {
service = spy(service);
UserDO operator = new UserDO();
operator.setType(2);
@@ -481,6 +481,7 @@ class PlanningServiceImplTest {
PlanningAppointmentCreateDTO dto = new PlanningAppointmentCreateDTO();
dto.setCreateCustomerRecord(false);
dto.setManualProductTitle("手绘款");
dto.setManualProductImageFileIds("file-43");
dto.setAmount(java.math.BigDecimal.valueOf(88));
dto.setAppointmentDate(java.time.LocalDate.now().plusDays(2).toString());
@@ -491,7 +492,7 @@ class PlanningServiceImplTest {
ArgumentCaptor<ProductDO> productCaptor = ArgumentCaptor.forClass(ProductDO.class);
verify(productMapper).insert(productCaptor.capture());
assertEquals("散客款式", productCaptor.getValue().getTitle());
assertEquals("手绘款", productCaptor.getValue().getTitle());
ArgumentCaptor<OrderDO> orderCaptor = ArgumentCaptor.forClass(OrderDO.class);
verify(orderMapper).insert(orderCaptor.capture());
+36 -19
View File
@@ -1306,32 +1306,42 @@ Page({
},
confirmManualProduct() {
if (!this.data.form.productId) {
const hasTitle = Boolean(String(this.data.form.manualProductTitle || '').trim())
const hasImage = (this.data.form.manualProductImages || []).length > 0 || Boolean(String(this.data.form.manualProductImageFileIds || '').trim())
const hasFallbackName = Boolean(String(this.data.form.customerName || '').trim())
if (!hasTitle && !hasImage && !hasFallbackName) {
wx.showToast({ title: '请填写款式名称或添加图片', icon: 'none' })
const form = this.data.form
if (!form.productId) {
const hasTitle = Boolean(String(form.manualProductTitle || '').trim())
if (!hasTitle) {
wx.showToast({ title: '请填写款式名称', icon: 'none' })
return
}
}
const amountText = String(this.data.form.amount === undefined || this.data.form.amount === null ? '' : this.data.form.amount).trim()
const amount = Number(amountText)
if (!amountText || !Number.isFinite(amount) || amount < 0) {
const amountText = String(form.amount === undefined || form.amount === null ? '' : form.amount).trim()
const amount = amountText ? Number(amountText) : 0
if (amountText && (!Number.isFinite(amount) || amount < 0)) {
wx.showToast({ title: '请输入不小于0的预约金额', icon: 'none' })
return
}
if (!normalizeDuration(this.data.form.durationMinutes)) {
const durationText = String(form.durationMinutes === undefined || form.durationMinutes === null ? '' : form.durationMinutes).trim()
const durationMinutes = durationText ? normalizeDuration(durationText) : 60
if (!durationMinutes) {
wx.showToast({ title: '请输入大于0分钟的预计时长', icon: 'none' })
return
}
if (this.data.form.productId) {
this.setData({ manualProductSheetVisible: false })
const defaults = {}
if (!amountText) defaults['form.amount'] = '0'
if (!durationText) defaults['form.durationMinutes'] = '60'
if (form.productId) {
this.setData({ ...defaults, manualProductSheetVisible: false })
this.refreshAvailableTimes()
this.checkAvailability()
return
}
this.setData({ 'form.productId': '', selectedProduct: {}, selectedProductPriceText: '', manualProductSheetVisible: false })
this.setData({
...defaults,
'form.productId': '',
selectedProduct: {},
selectedProductPriceText: '',
manualProductSheetVisible: false
})
this.refreshAvailableTimes()
this.checkAvailability()
},
@@ -1971,16 +1981,19 @@ Page({
return
}
const manualProductTitle = String(form.manualProductTitle || '').trim()
const manualProductImageFileIds = String(form.manualProductImageFileIds || '').trim()
const hasManualProduct = Boolean(manualProductTitle || manualProductImageFileIds || String(form.customerName || '').trim())
const amountText = String(form.amount === undefined || form.amount === null ? '' : form.amount).trim()
const amount = Number(amountText)
const durationMinutes = normalizeDuration(form.durationMinutes)
if ((!form.productId && !hasManualProduct) || !form.appointmentDate || !form.appointmentTime || !amountText) {
const amount = amountText ? Number(amountText) : 0
const durationText = String(form.durationMinutes === undefined || form.durationMinutes === null ? '' : form.durationMinutes).trim()
const durationMinutes = durationText ? normalizeDuration(durationText) : 60
if (!form.productId && !manualProductTitle) {
wx.showToast({ title: '请填写款式名称', icon: 'none' })
return
}
if (!form.appointmentDate || !form.appointmentTime) {
wx.showToast({ title: '请补全预约信息', icon: 'none' })
return
}
if (!Number.isFinite(amount) || amount < 0) {
if (amountText && (!Number.isFinite(amount) || amount < 0)) {
wx.showToast({ title: '请输入不小于0的成交金额', icon: 'none' })
return
}
@@ -1996,6 +2009,10 @@ Page({
wx.showToast({ title: '请填写预约时长', icon: 'none' })
return
}
const defaults = {}
if (!amountText) defaults['form.amount'] = '0'
if (!durationText) defaults['form.durationMinutes'] = '60'
if (Object.keys(defaults).length) this.setData(defaults)
const availability = await this.checkAvailability()
if (!availability.ok) {
wx.showToast({ title: availability.tip || '该时段已被预约', icon: 'none' })
@@ -20,7 +20,7 @@
<view class="field-text">
<text wx:if="{{form.manualProductTitle}}" class="field-value">{{form.manualProductTitle}}</text>
<text wx:elif="{{form.manualProductImages.length}}" class="field-value">已添加 {{form.manualProductImages.length}} 张款式图片</text>
<text wx:else class="field-value placeholder">填写款式名称或添加图片</text>
<text wx:else class="field-value placeholder">填写款式名称</text>
<text wx:if="{{form.amount || form.durationMinutes}}" class="field-meta">{{form.amount || '待填'}} 元 · 预计 {{form.durationMinutes || '60'}} 分钟</text>
<text class="field-label">{{form.manualProductImages.length ? '已添加 ' + form.manualProductImages.length + ' 张图片 · 点击可编辑' : '点击可手动录入,提交后自动保存到本店款式库'}}</text>
</view>
@@ -32,7 +32,7 @@
<view class="selected-style-copy"><text class="selected-style-title">{{selectedProduct.title}}</text><text class="selected-style-meta">参考价 {{selectedProductPriceText || '待定'}} · 本次 {{form.amount || '待填'}} 元 · {{form.durationMinutes || '60'}} 分钟</text></view>
<button class="switch-manual-action" catchtap="openManualProduct">调整</button>
</view>
<text class="style-hint">名称和图片至少填写一项;名称为空时会使用客户姓名或“散客款式”。</text>
<text class="style-hint">款式名称为必填项;款式图片可按需添加。</text>
<text class="style-hint">手动录入款式在预约提交成功后自动保存到本店款式库,仅门店可见,不会公开展示。</text>
</view>
@@ -43,18 +43,18 @@
<picker mode="date" value="{{form.appointmentDate}}" bindchange="onDateChange">
<view class="field-card appointment-field-card">
<view class="field-icon">▣</view>
<view class="field-text"><text class="field-label">预约日期</text><text class="field-value">{{appointmentDateLong}}</text></view>
<view class="field-text"><text class="field-label"><text class="required-mark required-mark-before">*</text>预约日期</text><text class="field-value">{{appointmentDateLong}}</text></view>
<text class="chevron">›</text>
</view>
</picker>
<view class="field-card appointment-field-card" bindtap="openTimeSheet">
<view class="field-icon">◷</view>
<view class="field-text"><text class="field-label">预约时间</text><text wx:if="{{form.appointmentTime}}" class="field-value">{{appointmentDayLabel}} {{form.appointmentTime}} · {{form.durationMinutes}}分钟</text><text wx:else class="field-value placeholder">{{timeSelectTip}}</text><text wx:if="{{form.appointmentTime}}" class="field-meta">{{selectedArtist.name || '暂不分配美甲师'}}</text></view>
<view class="field-text"><text class="field-label"><text class="required-mark required-mark-before">*</text>预约时间</text><text wx:if="{{form.appointmentTime}}" class="field-value">{{appointmentDayLabel}} {{form.appointmentTime}} · {{form.durationMinutes}}分钟</text><text wx:else class="field-value placeholder">{{timeSelectTip}}</text><text wx:if="{{form.appointmentTime}}" class="field-meta">{{selectedArtist.name || '暂不分配美甲师'}}</text></view>
<text class="chevron">›</text>
</view>
<view class="field-card appointment-field-card" bindtap="openArtistSheet">
<view class="field-icon">♙</view>
<view class="field-text"><text class="field-label">服务美甲师</text><text wx:if="{{selectedArtist.id === '__unassigned__'}}" class="field-value">已选择暂不分配美甲师</text><text wx:else class="field-value {{selectedArtist.name ? '' : 'placeholder'}}">{{selectedArtist.name || '请选择美甲师或暂不分配'}}</text></view>
<view class="field-text"><text class="field-label">服务美甲师(选填)</text><text wx:if="{{selectedArtist.id === '__unassigned__'}}" class="field-value">已选择暂不分配美甲师</text><text wx:else class="field-value {{selectedArtist.name ? '' : 'placeholder'}}">{{selectedArtist.name || '请选择美甲师或暂不分配'}}</text></view>
<text class="chevron">›</text>
</view>
</view>
@@ -65,9 +65,9 @@
</view>
<view class="customer-entry">
<view class="customer-fields">
<input class="customer-name-input" value="{{form.customerName}}" data-field="customerName" bindinput="onCustomerInput" placeholder="客户姓名(可选)" />
<input class="customer-wechat-input" value="{{form.wechatId}}" data-field="wechatId" bindinput="onCustomerInput" placeholder="微信号(可选)" />
<input class="customer-phone-input" value="{{form.phone}}" data-field="phone" bindinput="onCustomerInput" type="number" maxlength="11" placeholder="手机号(可选)" />
<input class="customer-name-input" value="{{form.customerName}}" data-field="customerName" bindinput="onCustomerInput" placeholder="客户姓名(选填)" />
<input class="customer-wechat-input" value="{{form.wechatId}}" data-field="wechatId" bindinput="onCustomerInput" placeholder="微信号(选填)" />
<input class="customer-phone-input" value="{{form.phone}}" data-field="phone" bindinput="onCustomerInput" type="number" maxlength="11" placeholder="手机号(选填)" />
</view>
<button class="customer-library-btn" aria-label="选择已有客户" catchtap="openCustomerSheet"><text class="customer-library-icon">⌕</text></button>
</view>
@@ -84,27 +84,26 @@
<view wx:if="{{manualProductSheetVisible}}" class="modal-mask manual-product-mask" bindtap="closeManualProduct" catchtouchmove="stopTouchMove">
<view class="manual-style-sheet" catchtap="stopTap" catchtouchmove="stopTouchMove">
<view class="modal-head"><view><text class="modal-title">{{form.productId ? '调整预约款式' : '录入本次美甲款式'}}</text><text class="modal-subtitle">{{form.productId ? '可调整本次价格和预计时长' : '名称或图片至少填写一项 · 可添加多张图片'}}</text></view><view class="modal-close" bindtap="closeManualProduct" aria-label="关闭款式录入"></view></view>
<view class="modal-head"><view><text class="modal-title">{{form.productId ? '调整预约款式' : '录入本次美甲款式'}}</text><text class="modal-subtitle">{{form.productId ? '可调整本次价格和预计时长' : '款式名称为必填项 · 可添加多张图片'}}</text></view><view class="modal-close" bindtap="closeManualProduct" aria-label="关闭款式录入"></view></view>
<scroll-view class="manual-style-content" scroll-y enhanced show-scrollbar="{{false}}">
<view class="manual-style-name-field">
<view class="manual-style-field-heading"><text>名称</text><text class="manual-style-character-count">
<view class="manual-style-field-heading"><text class="required-mark required-mark-before">*</text><text>款式名称</text><text class="manual-style-character-count">
{{manualProductTitleLength}} / 100</text></view>
<input class="manual-style-title-input" value="{{form.productId ? selectedProduct.title : form.manualProductTitle}}" maxlength="100" disabled="{{form.productId}}" bindinput="onStyleTitleInput" placeholder="留空时默认使用客户姓名" />
<input class="manual-style-title-input" value="{{form.productId ? selectedProduct.title : form.manualProductTitle}}" maxlength="100" disabled="{{form.productId}}" bindinput="onStyleTitleInput" placeholder="请输入款式名称" />
</view>
<text class="manual-style-hint">没有填写名称时,会使用客户姓名;没有选择客户时,会采取散客预约模式,名称采用“散客款式”。</text>
<view class="manual-style-price-duration-row">
<view class="manual-style-compact-field">
<text class="manual-style-field-label">价格</text>
<text class="manual-style-field-label">价格(选填)</text>
<view class="manual-style-input-wrap"><input type="digit" value="{{form.amount}}" data-field="amount" bindinput="onInput" placeholder="例如 268" /><text>元</text></view>
</view>
<view class="manual-style-compact-field">
<text class="manual-style-field-label">预计时长</text>
<text class="manual-style-field-label">预计时长(选填)</text>
<view class="manual-style-input-wrap"><input type="number" value="{{form.durationMinutes}}" data-field="durationMinutes" bindinput="onInput" placeholder="60" /><text>分钟</text></view>
</view>
</view>
<view class="manual-style-images">
<view class="manual-style-image-heading"><text>款式图片</text><text class="manual-style-image-count">{{form.manualProductImages.length}} / 9</text></view>
<view class="manual-style-image-heading"><text>款式图片(选填)</text><text class="manual-style-image-count">{{form.manualProductImages.length}} / 9</text></view>
<scroll-view class="manual-style-image-scroll" scroll-x="true" enhanced="true" show-scrollbar="false">
<view class="manual-style-image-grid">
<view wx:for="{{form.manualProductImages}}" wx:key="fileId" class="manual-style-image-tile">
@@ -122,7 +121,7 @@
<textarea value="{{unifiedStyleDescription}}" bindinput="onUnifiedStyleDescriptionInput" placeholder="可填写颜色、工艺、特殊要求等备注" maxlength="500" />
</view>
<view class="manual-style-more">
<view class="manual-style-more-toggle" bindtap="toggleManualProductMore"><text>点击展开补充信息</text><text class="manual-style-more-arrow">{{manualProductMoreVisible ? '⌃' : '⌄'}}</text></view>
<view class="manual-style-more-toggle" bindtap="toggleManualProductMore"><text>点击展开补充信息(选填)</text><text class="manual-style-more-arrow">{{manualProductMoreVisible ? '⌃' : '⌄'}}</text></view>
<view wx:if="{{manualProductMoreVisible}}" class="manual-style-more-fields">
<input value="{{form.manualProductTags}}" data-field="manualProductTags" bindinput="onInput" placeholder="标签,多个用逗号分隔" />
<input value="{{form.manualProductTargetAudience}}" data-field="manualProductTargetAudience" bindinput="onInput" placeholder="适合人群" />
@@ -783,6 +783,11 @@ button.link-action {
font-weight: 800;
}
.required-mark-before {
margin-left: 0;
margin-right: 5rpx;
}
.link-action {
min-width: 144rpx;
max-width: none;
@@ -114,16 +114,19 @@ page.data.form.manualProductImageFileIds = ''
page.openManualProduct()
page.confirmManualProduct()
assert.strictEqual(page.data.manualProductSheetVisible, true)
assert.strictEqual(toastMessages.pop(), '请填写款式名称或添加图片')
assert.strictEqual(toastMessages.pop(), '请填写款式名称')
page.data.form.manualProductTitle = '手绘款'
page.data.form.amount = ''
page.data.form.durationMinutes = ''
page.openManualProduct()
page.confirmManualProduct()
assert.strictEqual(page.data.manualProductSheetVisible, true)
assert.strictEqual(toastMessages.pop(), '请输入不小于0的预约金额')
assert.strictEqual(page.data.manualProductSheetVisible, false)
assert.strictEqual(page.data.form.amount, '0')
assert.strictEqual(page.data.form.durationMinutes, '60')
page.data.form.amount = '128'
page.data.form.durationMinutes = '0'
page.openManualProduct()
page.confirmManualProduct()
assert.strictEqual(page.data.manualProductSheetVisible, true)
assert.strictEqual(toastMessages.pop(), '请输入大于0分钟的预计时长')
@@ -136,14 +139,17 @@ const wxss = require('fs').readFileSync(require('path').join(__dirname, 'index.w
assert.ok(wxml.indexOf('美甲款式') < wxml.indexOf('预约信息'))
assert.ok(wxml.indexOf('预约信息') < wxml.indexOf('>客户</text>'))
assert.match(wxml, /class="appointment-hero"/)
assert.match(wxml, /placeholder="留空时默认使用客户姓名"/)
assert.match(wxml, /placeholder="请输入款式名称"/)
assert.match(wxml, /appointmentDateBadge/)
assert.match(wxml, /class="customer-fields"/)
assert.match(wxml, /class="manual-style-sheet"/)
assert.match(wxml, /名称<\/text><text class="manual-style-character-count">\s*\{\{manualProductTitleLength\}\} \/ 100/)
assert.match(wxml, /class="required-mark required-mark-before">\*<\/text><text>款式名称<\/text><text class="manual-style-character-count">\s*\{\{manualProductTitleLength\}\} \/ 100/)
assert.match(wxml, /maxlength="100"[^>]*bindinput="onStyleTitleInput"/)
assert.match(wxml, /disabled="\{\{form\.productId\}\}" bindinput="onStyleTitleInput"/)
assert.match(wxml, /class="manual-style-price-duration-row"/)
assert.match(wxml, /价格(选填)/)
assert.match(wxml, /预计时长(选填)/)
assert.match(wxml, /款式图片(选填)/)
assert.match(wxml, /data-field="amount" bindinput="onInput" placeholder="例如 268" \/><text>元/)
assert.match(wxml, /data-field="durationMinutes" bindinput="onInput" placeholder="60" \/><text>分钟/)
assert.match(wxml, /class="manual-style-description-field"/)
@@ -182,6 +182,29 @@ async function run() {
assert.strictEqual(walkInPayload.createCustomerRecord, false)
assert.strictEqual(walkInPayload.artistId, undefined)
assert.strictEqual(walkInPayload.appointmentTime, '15:00')
const manualDefaultPage = createPage()
manualDefaultPage.data.businessStartTime = '09:30'
manualDefaultPage.data.businessEndTime = '18:00'
Object.assign(manualDefaultPage.data.form, {
productId: '',
manualProductTitle: '手绘款',
appointmentDate: futureDate,
appointmentTime: '16:00',
amount: '',
durationMinutes: '',
artistId: ''
})
let manualDefaultPayload
planningApi.createAppointment = async payload => {
manualDefaultPayload = payload
return { orderItemId: 63 }
}
await manualDefaultPage.submit()
assert.strictEqual(manualDefaultPayload.amount, 0)
assert.strictEqual(manualDefaultPayload.durationMinutes, 60)
assert.strictEqual(manualDefaultPayload.manualProductTitle, '手绘款')
}
run().catch(error => {