补齐店务端改密导出员工订单

This commit is contained in:
2026-07-16 12:00:06 +08:00
parent 08d24853a6
commit a9a23bfa6d
28 changed files with 768 additions and 33 deletions
+6
View File
@@ -193,6 +193,12 @@
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.5</version>
</dependency>
<!-- Qiniu Kodo primary object storage -->
<dependency>
<groupId>com.qiniu</groupId>
@@ -0,0 +1,47 @@
package com.xiaowang.jayucloud.core.modules.manager.controller.admin;
import com.xiaowang.jayucloud.core.annotation.RequirePermission;
import com.xiaowang.jayucloud.core.modules.manager.service.ManagerExportService;
import com.xiaowang.jayucloud.core.modules.security.support.AdminScopeHelper;
import com.xiaowang.jayucloud.core.modules.user.entity.UserDO;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ContentDisposition;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
@RestController
@RequestMapping("/admin")
@RequiredArgsConstructor
public class AdminExportController {
private final ManagerExportService managerExportService;
private final AdminScopeHelper adminScopeHelper;
@GetMapping("/export")
@RequirePermission("order:view")
public ResponseEntity<byte[]> export(HttpServletRequest request,
@RequestParam String type,
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate) {
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
byte[] content = managerExportService.export(currentUser, type, startDate, endDate);
String fileName = type + "_" + startDate + "_" + endDate + ".xlsx";
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))
.header(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition.attachment()
.filename(fileName, StandardCharsets.UTF_8)
.build()
.toString())
.body(content);
}
}
@@ -0,0 +1,41 @@
package com.xiaowang.jayucloud.core.modules.manager.controller.admin;
import com.xiaowang.jayucloud.core.annotation.RequirePermission;
import com.xiaowang.jayucloud.core.common.Result;
import com.xiaowang.jayucloud.core.modules.planning.service.PlanningService;
import com.xiaowang.jayucloud.core.modules.planning.vo.PlanningAppointmentVO;
import com.xiaowang.jayucloud.core.modules.security.support.AdminScopeHelper;
import com.xiaowang.jayucloud.core.modules.user.entity.UserDO;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.time.LocalDate;
import java.util.List;
@RestController
@RequestMapping("/admin/manager/employees")
@RequiredArgsConstructor
public class AdminManagerEmployeeOrderController {
private final PlanningService planningService;
private final AdminScopeHelper adminScopeHelper;
@GetMapping("/{userId}/orders")
@RequirePermission("order:view")
public Result<List<PlanningAppointmentVO>> orders(HttpServletRequest request,
@PathVariable Long userId,
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate) {
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
if (!adminScopeHelper.isPlatformAdmin(currentUser)) {
adminScopeHelper.ensureUserAccessibleInCurrentShop(currentUser, userId, "无权查看其他店铺员工订单");
}
return Result.success(planningService.getCalendar(currentUser, startDate, endDate, userId).getAppointments());
}
}
@@ -0,0 +1,194 @@
package com.xiaowang.jayucloud.core.modules.manager.service;
import com.xiaowang.jayucloud.core.common.vo.PageResultVO;
import com.xiaowang.jayucloud.core.modules.artist.dto.NailArtistInfoDTO;
import com.xiaowang.jayucloud.core.modules.artist.service.NailArtistInfoService;
import com.xiaowang.jayucloud.core.modules.planning.service.PlanningService;
import com.xiaowang.jayucloud.core.modules.planning.vo.PlanningAppointmentVO;
import com.xiaowang.jayucloud.core.modules.planning.vo.PlanningCalendarVO;
import com.xiaowang.jayucloud.core.modules.security.support.AdminScopeHelper;
import com.xiaowang.jayucloud.core.modules.user.entity.UserDO;
import com.xiaowang.jayucloud.core.modules.user.service.UserService;
import com.xiaowang.jayucloud.core.modules.user.vo.UserVO;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
@Service
@RequiredArgsConstructor
public class ManagerExportService {
private static final String EXPORT_TYPE_ORDER = "订单数据";
private static final String EXPORT_TYPE_CUSTOMER = "客户数据";
private static final String EXPORT_TYPE_EMPLOYEE = "员工数据";
private static final int EXPORT_LIMIT = 10000;
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private final PlanningService planningService;
private final UserService userService;
private final NailArtistInfoService nailArtistInfoService;
private final AdminScopeHelper adminScopeHelper;
public byte[] export(UserDO currentUser, String type, LocalDate startDate, LocalDate endDate) {
validateParams(type, startDate, endDate);
try (Workbook workbook = new XSSFWorkbook(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
if (EXPORT_TYPE_ORDER.equals(type)) {
writeOrders(workbook, currentUser, startDate, endDate);
} else if (EXPORT_TYPE_CUSTOMER.equals(type)) {
writeCustomers(workbook, currentUser);
} else if (EXPORT_TYPE_EMPLOYEE.equals(type)) {
writeEmployees(workbook, currentUser);
} else {
throw new RuntimeException("不支持的导出类型:" + type);
}
workbook.write(outputStream);
return outputStream.toByteArray();
} catch (IOException error) {
throw new RuntimeException("生成 Excel 文件失败:" + error.getMessage(), error);
}
}
private void validateParams(String type, LocalDate startDate, LocalDate endDate) {
if (!StringUtils.hasText(type)) {
throw new RuntimeException("导出类型不能为空");
}
if (startDate == null || endDate == null) {
throw new RuntimeException("导出开始日期和结束日期不能为空");
}
if (endDate.isBefore(startDate)) {
throw new RuntimeException("结束日期不能早于开始日期");
}
}
private void writeOrders(Workbook workbook, UserDO currentUser, LocalDate startDate, LocalDate endDate) {
PlanningCalendarVO calendar = planningService.getCalendar(currentUser, startDate, endDate, null);
Sheet sheet = createSheet(workbook, EXPORT_TYPE_ORDER, List.of("日期", "订单号", "客户", "手机号", "项目", "美甲师", "开始时间", "结束时间", "金额", "状态", "备注"));
List<PlanningAppointmentVO> appointments = calendar.getAppointments() == null ? List.of() : calendar.getAppointments();
int rowIndex = 1;
for (PlanningAppointmentVO appointment : appointments) {
Row row = sheet.createRow(rowIndex);
rowIndex++;
writeRow(row, List.of(
text(appointment.getDate()),
text(appointment.getOrderNo()),
text(appointment.getCustomerName()),
text(appointment.getCustomerPhone()),
text(appointment.getProductTitle()),
text(appointment.getArtistName()),
text(appointment.getStartTime()),
text(appointment.getEndTime()),
money(appointment.getAmount()),
text(appointment.getStatusText()),
text(appointment.getRemark())
));
}
sizeColumns(sheet, 11);
}
private void writeCustomers(Workbook workbook, UserDO currentUser) {
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
PageResultVO<UserVO> page = userService.pageUsers(1, EXPORT_LIMIT, null, shopId, 0);
Sheet sheet = createSheet(workbook, EXPORT_TYPE_CUSTOMER, List.of("客户", "账号", "手机号", "联系电话", "会员等级", "状态", "创建时间"));
List<UserVO> customers = page.getList() == null ? List.of() : page.getList();
int rowIndex = 1;
for (UserVO customer : customers) {
Row row = sheet.createRow(rowIndex);
rowIndex++;
writeRow(row, List.of(
text(firstText(customer.getNickname(), customer.getAccount(), "客户")),
text(customer.getAccount()),
text(customer.getPhone()),
text(customer.getContactPhone()),
text(customer.getVipLevel()),
text(statusText(customer.getStatus())),
dateTime(customer.getCreateTime())
));
}
sizeColumns(sheet, 7);
}
private void writeEmployees(Workbook workbook, UserDO currentUser) {
List<NailArtistInfoDTO> employees = adminScopeHelper.isPlatformAdmin(currentUser)
? nailArtistInfoService.getAllNailArtists()
: nailArtistInfoService.getByShopId(adminScopeHelper.resolveShopScope(currentUser, null));
Sheet sheet = createSheet(workbook, EXPORT_TYPE_EMPLOYEE, List.of("员工", "手机号", "联系电话", "店铺", "身份", "排班模式", "排班时间", "状态"));
List<NailArtistInfoDTO> employeeList = employees == null ? List.of() : employees;
int rowIndex = 1;
for (NailArtistInfoDTO employee : employeeList) {
Row row = sheet.createRow(rowIndex);
rowIndex++;
writeRow(row, List.of(
text(firstText(employee.getNickname(), "美甲师")),
text(employee.getPhone()),
text(employee.getContactPhone()),
text(employee.getShopName()),
text(employee.getIdentity()),
text(employee.getScheduleModeSummary()),
text(employee.getScheduleTimeSummary()),
text(statusText(employee.getStatus()))
));
}
sizeColumns(sheet, 8);
}
private Sheet createSheet(Workbook workbook, String sheetName, List<String> headers) {
Sheet sheet = workbook.createSheet(sheetName);
Row header = sheet.createRow(0);
writeRow(header, headers);
return sheet;
}
private void writeRow(Row row, List<String> values) {
for (int index = 0; index < values.size(); index++) {
Cell cell = row.createCell(index);
cell.setCellValue(values.get(index));
}
}
private void sizeColumns(Sheet sheet, int columnCount) {
for (int index = 0; index < columnCount; index++) {
sheet.autoSizeColumn(index);
sheet.setColumnWidth(index, Math.min(Math.max(sheet.getColumnWidth(index), 2800), 12000));
}
}
private String firstText(String primary, String fallback) {
return StringUtils.hasText(primary) ? primary : fallback;
}
private String firstText(String primary, String secondary, String fallback) {
if (StringUtils.hasText(primary)) {
return primary;
}
return StringUtils.hasText(secondary) ? secondary : fallback;
}
private String text(Object value) {
return value == null ? "" : String.valueOf(value);
}
private String money(BigDecimal value) {
return value == null ? "" : value.stripTrailingZeros().toPlainString();
}
private String dateTime(LocalDateTime value) {
return value == null ? "" : DATE_TIME_FORMATTER.format(value);
}
private String statusText(Integer status) {
return Integer.valueOf(0).equals(status) ? "停用" : "启用";
}
}
@@ -49,6 +49,7 @@ import com.xiaowang.jayucloud.core.utils.AccountValidationUtils;
import com.xiaowang.jayucloud.core.support.security.OperationGuardStrategy;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -954,6 +955,10 @@ public class UserController {
@OperationGuard(action = "user-update-password", ttlSeconds = 10, message = "保存处理中,请勿重复提交")
public Result<Boolean> updatePassword(HttpServletRequest request, @RequestBody PasswordDTO passwordDTO) {
Long userId = (Long) request.getAttribute("userId");
if (StringUtils.hasText(passwordDTO.getOldPassword())) {
boolean success = userService.updatePasswordWithOldPassword(userId, passwordDTO.getOldPassword(), passwordDTO.getPassword());
return Result.success(success);
}
boolean success = userService.updatePassword(userId, passwordDTO.getPassword(), passwordDTO.getVerificationCode());
return Result.success(success);
}
@@ -1059,6 +1064,7 @@ public class UserController {
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
*/
private String password;
private String oldPassword;
/**
* Purpose: verificationCode supports UserController.java by holding or executing the verification code business role.
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
@@ -402,6 +402,8 @@ public interface UserService extends IService<UserDO> {
* @return boolean result consumed by the caller or returned to the frontend
*/
boolean updatePassword(Long userId, String password, String verificationCode);
boolean updatePasswordWithOldPassword(Long userId, String oldPassword, String password);
/**
* Update an existing record.
@@ -2272,6 +2272,29 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
return updated;
}
@Override
public boolean updatePasswordWithOldPassword(Long userId, String oldPassword, String password) {
UserDO userDO = userMapper.selectById(userId);
assertUserAvailable(userDO);
if (!StringUtils.hasText(oldPassword)) {
throw new RuntimeException("原密码不能为空");
}
if (!StringUtils.hasText(userDO.getPassword())) {
throw new RuntimeException("当前账号未设置登录密码");
}
if (!passwordEncoder.matches(oldPassword, userDO.getPassword())) {
throw new RuntimeException("原密码不正确");
}
validatePasswordStrength(password);
userDO.setPassword(passwordEncoder.encode(password));
userDO.setUpdateTime(LocalDateTime.now());
boolean updated = userMapper.updateById(userDO) > 0;
if (updated) {
userSessionService.revokeAllUserSessions(userId);
}
return updated;
}
@Override
/**
* Update an existing record.
+16 -3
View File
@@ -18,12 +18,25 @@ const adminApi = axios.create({
headers: { 'Content-Type': 'application/json' }
})
const normalizeResponse = <T>(response: { data: { code?: number; message?: string; data: T } }): T => {
interface ApiResponsePayload<T> {
code?: number
message?: string
data: T
}
const isApiResponsePayload = <T>(payload: ApiResponsePayload<T> | T): payload is ApiResponsePayload<T> => (
payload !== null && payload !== undefined && typeof payload === 'object' && 'data' in payload
)
const normalizeResponse = <T>(response: { config?: { responseType?: string }; data: ApiResponsePayload<T> | T }): T => {
if (response.config?.responseType === 'blob' || response.config?.responseType === 'arraybuffer') {
return response.data as T
}
const payload = response.data
if (payload && payload.code !== undefined && payload.code !== 200) {
if (isApiResponsePayload(payload) && payload.code !== undefined && payload.code !== 200) {
throw new Error(payload.message || '请求失败')
}
return payload.data as T
return isApiResponsePayload(payload) ? payload.data : payload
}
const handleExpired = async (): Promise<void> => {
@@ -8,6 +8,7 @@ import type {
ArtistScheduleRuleSetting,
EmployeeCreateRequest
} from '@/types/manager'
import type { Appointment } from '@/types/manager'
export interface ManagerDefaultPasswordResponse {
password: string
@@ -20,6 +21,9 @@ export const managerEmployeesApi = {
detail(userId: IdType): Promise<Artist> {
return adminApi.get(`/manager/employees/${userId}`)
},
orders(userId: IdType, params: { startDate: string; endDate: string }): Promise<Appointment[]> {
return adminApi.get(`/manager/employees/${userId}/orders`, { params })
},
save(data: Partial<Artist>): Promise<Artist> {
return adminApi.post('/manager/employees', data)
},
+3
View File
@@ -16,5 +16,8 @@ export const managerShopApi = {
},
exportPreview(params: { type: string; startDate: string; endDate: string }): Promise<unknown> {
return adminApi.get('/export', { params })
},
exportData(params: { type: string; startDate: string; endDate: string }): Promise<Blob> {
return adminApi.get('/export', { params, responseType: 'blob' })
}
}
+3
View File
@@ -7,5 +7,8 @@ export const userApi = {
},
update(data: Partial<UserInfo>): Promise<boolean> {
return api.put('/user/info', data)
},
updatePassword(data: { oldPassword: string; password: string }): Promise<boolean> {
return api.put('/user/password', data)
}
}
+111 -1
View File
@@ -1,10 +1,120 @@
<template>
<MobileShell title="员工作品/订单">
<EmptyState title="暂无员工作品/订单" description="当前小程序页面为返回入口,Web 端按现状保留轻量视图。" mark="单" />
<div class="employee-orders-view">
<section class="card form-card">
<label class="field">
<span class="field-label">开始日期</span>
<DatePickerField v-model="startDate" placeholder="请选择开始日期" title="日期选择" @confirm="loadOrders" />
</label>
<label class="field">
<span class="field-label">结束日期</span>
<DatePickerField v-model="endDate" placeholder="请选择结束日期" title="日期选择" @confirm="loadOrders" />
</label>
</section>
<LoadingState v-if="loading" text="订单加载中" />
<EmptyState v-else-if="loadError" title="订单加载失败" :description="loadError" />
<EmptyState v-else-if="orders.length === 0" title="暂无员工作品/订单" description="当前日期范围内没有订单" mark="单" />
<section v-else class="order-list section">
<article v-for="order in orders" :key="String(order.orderItemId)" class="card list-card" @click="openOrder(order)">
<div>
<h2 class="list-card__title">{{ order.productTitle || '预约作品' }}</h2>
<div class="list-card__subtitle">{{ order.date || shortDate(order.startTime) }} · {{ order.customerName || '到店客户' }}</div>
<div class="list-card__meta">{{ order.artistName || '未分配' }} · {{ timeRange(order) }} · {{ order.statusText || '-' }}</div>
</div>
<strong class="amount">{{ orderAmount(order) }}</strong>
</article>
</section>
</div>
</MobileShell>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import DatePickerField from '@/components/DatePickerField.vue'
import EmptyState from '@/components/EmptyState.vue'
import LoadingState from '@/components/LoadingState.vue'
import MobileShell from '@/components/MobileShell.vue'
import { managerEmployeesApi } from '@/api/managerEmployees'
import { formatDate, startOfMonth } from '@/utils/date'
import type { Appointment } from '@/types/manager'
const route = useRoute()
const router = useRouter()
const employeeId = String(route.params.id || '')
const startDate = ref(formatDate(startOfMonth(new Date())))
const endDate = ref(formatDate(new Date()))
const orders = ref<Appointment[]>([])
const loading = ref(false)
const loadError = ref('')
const shortDate = (value: unknown): string => String(value || '').slice(0, 10) || '-'
const timeRange = (item: Appointment): string => {
const start = String(item.startTime || '').slice(11, 16)
const end = String(item.endTime || '').slice(11, 16)
if (!start && !end) {
return '-'
}
return `${start || '-'}-${end || '-'}`
}
const orderAmount = (item: Appointment): string => {
const value = item.amount ?? item.manualProductPrice
if (value === undefined || value === null || value === '') {
return '¥0'
}
const amount = Number(value)
return Number.isNaN(amount) ? `¥${value}` : `¥${amount.toFixed(2).replace(/\.00$/, '')}`
}
const loadOrders = async (): Promise<void> => {
loading.value = true
loadError.value = ''
try {
orders.value = await managerEmployeesApi.orders(employeeId, {
startDate: startDate.value,
endDate: endDate.value
})
} catch (error) {
orders.value = []
loadError.value = error instanceof Error ? error.message : '员工订单加载失败'
} finally {
loading.value = false
}
}
const openOrder = (order: Appointment): void => {
if (!order.orderItemId) {
return
}
router.push(`/appointments/${order.orderItemId}`)
}
onMounted(loadOrders)
</script>
<style scoped>
.employee-orders-view {
padding-bottom: 20px;
}
.order-list {
display: grid;
gap: 10px;
}
.list-card {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.amount {
color: #5f8f7f;
font-size: 15px;
white-space: nowrap;
}
</style>
+32 -3
View File
@@ -44,7 +44,7 @@
<div class="fixed-bottom">
<div class="fixed-bottom__inner">
<button class="primary-btn" type="button" @click="exportExcel">导出 Excel</button>
<button class="primary-btn" type="button" :disabled="exporting" @click="exportExcel">{{ exporting ? '导出中...' : '导出 Excel' }}</button>
</div>
</div>
</div>
@@ -60,6 +60,7 @@ import MobileShell from '@/components/MobileShell.vue'
import { managerCustomersApi } from '@/api/managerCustomers'
import { managerEmployeesApi } from '@/api/managerEmployees'
import { managerPlanningApi } from '@/api/managerPlanning'
import { managerShopApi } from '@/api/managerShop'
import { formatDate, startOfMonth } from '@/utils/date'
import { useToastStore } from '@/stores/toast'
import type { Appointment, Artist } from '@/types/manager'
@@ -78,6 +79,7 @@ const previewColumns = ref<string[]>([])
const previewRows = ref<PreviewRow[]>([])
const previewLoading = ref(false)
const previewError = ref('')
const exporting = ref(false)
const shortDateTime = (value: unknown): string => {
const text = String(value || '')
@@ -169,8 +171,35 @@ const loadPreview = async (): Promise<void> => {
}
}
const exportExcel = (): void => {
toast.success('导出任务已创建')
const buildExportFileName = (): string => `${type.value}_${startDate.value}_${endDate.value}.xlsx`
const downloadBlob = (blob: Blob): void => {
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = buildExportFileName()
document.body.appendChild(link)
link.click()
link.remove()
URL.revokeObjectURL(url)
}
const exportExcel = async (): Promise<void> => {
if (exporting.value) {
return
}
exporting.value = true
try {
const blob = await managerShopApi.exportData({
type: type.value,
startDate: startDate.value,
endDate: endDate.value
})
downloadBlob(blob)
toast.success('Excel 已开始下载')
} finally {
exporting.value = false
}
}
onMounted(loadPreview)
+28 -4
View File
@@ -18,7 +18,7 @@
<div class="fixed-bottom">
<div class="fixed-bottom__inner">
<button class="primary-btn" type="button" @click="save">保存密码</button>
<button class="primary-btn" type="button" :disabled="saving" @click="save">{{ saving ? '保存中...' : '保存密码' }}</button>
</div>
</div>
</div>
@@ -26,18 +26,31 @@
</template>
<script setup lang="ts">
import { reactive } from 'vue'
import { reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import { userApi } from '@/api/user'
import MobileShell from '@/components/MobileShell.vue'
import { useSessionStore } from '@/stores/session'
import { useToastStore } from '@/stores/toast'
const toast = useToastStore()
const router = useRouter()
const session = useSessionStore()
const saving = ref(false)
const form = reactive({
oldPassword: '',
newPassword: '',
confirmPassword: ''
})
const save = (): void => {
const save = async (): Promise<void> => {
if (saving.value) {
return
}
if (!form.oldPassword) {
toast.error('请填写原密码')
return
}
if (!form.newPassword || !form.confirmPassword) {
toast.error('请填写新密码')
return
@@ -46,7 +59,18 @@ const save = (): void => {
toast.error('两次密码不一致')
return
}
toast.success('已提交')
saving.value = true
try {
await userApi.updatePassword({
oldPassword: form.oldPassword,
password: form.newPassword
})
toast.success('密码已修改,请重新登录')
session.clear()
await router.replace('/login')
} finally {
saving.value = false
}
}
</script>
+7
View File
@@ -14,6 +14,13 @@ module.exports = {
})
},
orders(userId, params) {
return request({
url: `/manager/employees/${userId}/orders`,
params
})
},
save(data) {
return request({
url: '/manager/employees',
+40
View File
@@ -1,4 +1,39 @@
const request = require('../utils/request')
const { ADMIN_API_BASE_URL, REQUEST_TIMEOUT } = require('../utils/config')
function buildDownloadUrl(params) {
const query = Object.keys(params || {})
.filter(key => params[key] !== undefined && params[key] !== null && params[key] !== '')
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`)
.join('&')
return `${ADMIN_API_BASE_URL}/export${query ? `?${query}` : ''}`
}
function downloadFile(url, params) {
const header = request.buildSignatureHeaders({
url: '/export',
requestUrl: url,
method: 'GET',
params
})
return new Promise((resolve, reject) => {
wx.downloadFile({
url,
header,
timeout: REQUEST_TIMEOUT,
success(response) {
if (response.statusCode >= 200 && response.statusCode < 300 && response.tempFilePath) {
resolve(response.tempFilePath)
return
}
reject(new Error(`导出 Excel 下载失败:HTTP ${response.statusCode}`))
},
fail(error) {
reject(new Error(`导出 Excel 下载失败:${error.errMsg || '网络异常'}`))
}
})
})
}
module.exports = {
settings() {
@@ -35,5 +70,10 @@ module.exports = {
url: '/export',
params
})
},
downloadExport(params) {
const url = buildDownloadUrl(params)
return downloadFile(url, params)
}
}
+11
View File
@@ -20,5 +20,16 @@ module.exports = {
},
data
})
},
updatePassword(data) {
return request({
url: '/user/password',
method: 'PUT',
params: {
__baseUrl: API_DOMAIN
},
data
})
}
}
+79 -5
View File
@@ -1,10 +1,84 @@
const dateUtil = require('../../utils/date')
const employeesApi = require('../../api/employees')
function shortDate(value) {
return String(value || '').slice(0, 10) || '-'
}
function timeRange(item) {
const start = String(item.startTime || '').slice(11, 16)
const end = String(item.endTime || '').slice(11, 16)
if (!start && !end) return '-'
return `${start || '-'}-${end || '-'}`
}
function orderAmount(item) {
const value = item.amount !== undefined && item.amount !== null ? item.amount : item.manualProductPrice
if (value === undefined || value === null || value === '') return '0'
const amount = Number(value)
if (Number.isNaN(amount)) return String(value)
return amount.toFixed(2).replace(/\.00$/, '')
}
function toOrderRow(item, index) {
return {
id: item.orderItemId || index,
date: item.date || shortDate(item.startTime),
project: item.productTitle || '预约作品',
customer: item.customerName || '到店客户',
artist: item.artistName || '未分配',
time: timeRange(item),
status: item.statusText || '-',
amount: orderAmount(item)
}
}
Page({
data: {
orders: [
{ id: 1, date: '2026-06-01', project: '纯色美甲', customer: '王女士', amount: 168 },
{ id: 2, date: '2026-05-31', project: '猫眼延长', customer: '陈女士', amount: 268 },
{ id: 3, date: '2026-05-30', project: '手部护理', customer: '林女士', amount: 98 }
]
id: '',
startDate: dateUtil.formatDate(dateUtil.startOfMonth(new Date())),
endDate: dateUtil.formatDate(new Date()),
orders: [],
loading: false,
loadError: ''
},
onLoad(options) {
this.setData({ id: options.id || '' })
this.loadOrders()
},
onStartDate(event) {
this.setData({ startDate: event.detail.value }, () => this.loadOrders())
},
onEndDate(event) {
this.setData({ endDate: event.detail.value }, () => this.loadOrders())
},
async loadOrders() {
if (!this.data.id) {
this.setData({ orders: [], loadError: '员工ID不能为空' })
return
}
this.setData({ loading: true, loadError: '' })
try {
const list = await employeesApi.orders(this.data.id, {
startDate: this.data.startDate,
endDate: this.data.endDate
})
this.setData({
orders: (Array.isArray(list) ? list : []).map(toOrderRow)
})
} catch (error) {
this.setData({
orders: [],
loadError: error.message || '员工订单加载失败'
})
} finally {
this.setData({ loading: false })
}
},
back() { wx.navigateBack() }
})
@@ -1,9 +1,17 @@
<view class="page no-tab">
<view class="list">
<view class="card form-card">
<view class="field"><text class="field-label">开始日期</text><picker mode="date" value="{{startDate}}" bindchange="onStartDate"><view class="field-value">{{startDate}}</view></picker></view>
<view class="field"><text class="field-label">结束日期</text><picker mode="date" value="{{endDate}}" bindchange="onEndDate"><view class="field-value">{{endDate}}</view></picker></view>
</view>
<view wx:if="{{loading}}" class="empty card">订单加载中...</view>
<view wx:elif="{{loadError}}" class="empty card error">{{loadError}}</view>
<view wx:elif="{{orders.length === 0}}" class="empty card">当前日期范围内没有订单</view>
<view wx:else class="list">
<view wx:for="{{orders}}" wx:key="id" class="card list-card order-row">
<view>
<text class="order-title">{{item.project}}</text>
<text class="muted">{{item.date}} · {{item.customer}}</text>
<text class="order-meta">{{item.artist}} · {{item.time}} · {{item.status}}</text>
</view>
<text class="amount">¥{{item.amount}}</text>
</view>
@@ -15,3 +15,10 @@
color: #6f8f83;
font-weight: 900;
}
.order-meta {
display: block;
margin-top: 6rpx;
color: #8b8680;
font-size: 24rpx;
}
+28 -2
View File
@@ -2,6 +2,7 @@ const dateUtil = require('../../utils/date')
const planningApi = require('../../api/planning')
const customersApi = require('../../api/customers')
const employeesApi = require('../../api/employees')
const shopApi = require('../../api/shop')
const PREVIEW_SIZE = 10
@@ -40,7 +41,8 @@ Page({
previewColumns: [],
previewRows: [],
previewLoading: false,
previewError: ''
previewError: '',
exporting: false
},
onLoad() {
@@ -131,7 +133,31 @@ Page({
})
},
exportExcel() { wx.showToast({ title: '导出任务已创建', icon: 'none' }) },
async exportExcel() {
if (this.data.exporting) {
return
}
this.setData({ exporting: true })
try {
const filePath = await shopApi.downloadExport({
type: this.data.type,
startDate: this.data.startDate,
endDate: this.data.endDate
})
wx.openDocument({
filePath,
fileType: 'xlsx',
showMenu: true,
fail(error) {
wx.showToast({ title: error.errMsg || 'Excel 打开失败', icon: 'none' })
}
})
} catch (error) {
wx.showToast({ title: error.message || 'Excel 导出失败', icon: 'none' })
} finally {
this.setData({ exporting: false })
}
},
back() { wx.navigateBack() }
})
+1 -1
View File
@@ -42,5 +42,5 @@
</view>
</scroll-view>
</view>
<view class="fixed-bottom"><button class="primary-btn" bindtap="exportExcel">导出 Excel</button></view>
<view class="fixed-bottom"><button class="primary-btn" loading="{{exporting}}" disabled="{{exporting}}" bindtap="exportExcel">导出 Excel</button></view>
</view>
+39 -3
View File
@@ -1,12 +1,48 @@
const userApi = require('../../api/user')
function clearSessionAndGoLogin() {
const app = getApp()
if (app && typeof app.clearSession === 'function') {
app.clearSession()
}
wx.reLaunch({ url: '/pages/login/index' })
}
Page({
data: { form: { oldPassword: '', newPassword: '', confirmPassword: '' } },
data: {
form: { oldPassword: '', newPassword: '', confirmPassword: '' },
saving: false
},
onInput(event) { this.setData({ [`form.${event.currentTarget.dataset.field}`]: event.detail.value }) },
save() {
async save() {
if (this.data.saving) {
return
}
if (!this.data.form.oldPassword) {
wx.showToast({ title: '请填写原密码', icon: 'none' })
return
}
if (!this.data.form.newPassword || !this.data.form.confirmPassword) {
wx.showToast({ title: '请填写新密码', icon: 'none' })
return
}
if (this.data.form.newPassword !== this.data.form.confirmPassword) {
wx.showToast({ title: '两次密码不一致', icon: 'none' })
return
}
wx.showToast({ title: '已提交' })
this.setData({ saving: true })
try {
await userApi.updatePassword({
oldPassword: this.data.form.oldPassword,
password: this.data.form.newPassword
})
wx.showToast({ title: '密码已修改', icon: 'success' })
setTimeout(clearSessionAndGoLogin, 600)
} catch (error) {
wx.showToast({ title: error.message || '密码修改失败', icon: 'none' })
} finally {
this.setData({ saving: false })
}
},
back() { wx.navigateBack() }
})
+1 -1
View File
@@ -4,5 +4,5 @@
<view class="field"><text class="field-label">新密码</text><input password value="{{form.newPassword}}" data-field="newPassword" bindinput="onInput" /></view>
<view class="field"><text class="field-label">确认密码</text><input password value="{{form.confirmPassword}}" data-field="confirmPassword" bindinput="onInput" /></view>
</view>
<view class="fixed-bottom"><button class="primary-btn" bindtap="save">保存密码</button></view>
<view class="fixed-bottom"><button class="primary-btn" loading="{{saving}}" disabled="{{saving}}" bindtap="save">保存密码</button></view>
</view>
+6
View File
@@ -843,3 +843,9 @@ messagehub:
- 处理方式:为 5 个 dataId 的每一条配置行补齐中文注释,仅调整注释文本,不修改配置值、缩进层级、路由顺序、列表顺序和敏感字段内容。
- 敏感信息要求:`secret.yaml` 中密码、token、access key、secret key 等只保留在 Nacos 配置中心,本文档和仓库不记录任何明文值。
- 验证方式:发布后通过 Nacos API 回读 5 个 dataId 并与本地注释版逐项比对,结果均为 `sameContent=true`;配置行与注释行数量分别为 `core.yaml 97/97`、`gateway.yaml 155/155`、`infra.yaml 87/87`、`secret.yaml 75/75`、`logging.yaml 6/6`。
### 2026-07-16 店务端 Excel 导出构建依赖
- `JY-Core` 管理端导出接口 `/admin/export` 使用 `org.apache.poi:poi-ooxml:5.2.5` 生成 `.xlsx` 文件。
- 该能力只依赖 Maven 构建下载的 POI 依赖,不需要新增 Nacos 配置、数据库结构、权限种子或对象存储配置。
- 发布验证时需确认 Core 构建成功,并通过店务端导出入口实际下载或打开 Excel 文件。
+8
View File
@@ -197,3 +197,11 @@
- 网页发布:设计师端和店务端静态资源发布到 `aliyun01`,`/opt/jy-artist-frontend/current` 已切换到 `/opt/jy-artist-frontend/releases/20260716-005625/dist`;店务端继续保留在 `current/jy-salon-front`,`nginx -t` 与 reload 均通过。
- 影响范围:更新生产 Core、Gateway 和网页静态资源;不修改数据库、Nacos 配置、Nginx 配置、初始化 SQL 和小程序。
- 验证方式:6 个后端节点均为 `active`,实际 JAR SHA 与本地构建产物一致,本机 `/health/check` 均成功;公网 `https://yunail.art/health/check`、`https://salon.yunail.art/health/check`、设计师入口、店务入口和 `https://yunail.art/api/shop/list` 均返回 200;最近稳定窗口未检出 journal error 或 `Exception/ERROR/系统繁忙` 关键词。
## 2026-07-16 店务端改密、导出和员工订单真实能力补齐
- 变更原因:店务网页端与店务小程序的修改密码、导出 Excel、员工作品/订单仍停留在前端提示、预览占位或硬编码示例数据,不能形成真实业务闭环。
- 处理方式:复用现有 `/user/password` 入口,新增原密码校验改密服务方法;新增 `/admin/export` 真实 Excel 下载接口并使用 Apache POI 生成 `.xlsx`;新增 `/admin/manager/employees/{userId}/orders` 员工订单查询接口,网页端和小程序均接入真实接口。
- 依赖说明:`JY-Core` 新增 Maven 依赖 `org.apache.poi:poi-ooxml:5.2.5`,用于生成 Excel 工作簿;不新增数据库表、字段、权限种子或初始化 SQL。
- 影响范围:影响 `JY-Core` 用户改密、管理端导出、员工订单查询,以及 `JY-Salon-Front`、`JY-Salon-WeChat` 对应页面;不修改 Gateway、Nacos、生产部署脚本和数据库结构。
- 验证方式:执行 `JY-Core` 编译、店务网页端构建、小程序变更脚本语法检查,并在提交前运行 GitNexus `detect_changes` 确认影响范围。
+8
View File
@@ -1,5 +1,13 @@
# JayuCloud 踩坑与风险记忆
## 2026-07-16 Web API Blob 响应拦截器需要显式类型守卫
- 问题:为店务网页端导出 Excel 增加 `responseType: 'blob'` 后,直接把 axios 归一化函数的响应类型扩成 `ApiPayload | T`,`vue-tsc` 报 `code/data/message` 属性不存在以及 `payload` 可能为 `null`。
- 原因:普通 JSON 响应和 Blob 响应共用同一个响应拦截器;TypeScript 无法从运行时 `responseType` 分支推导后续 `payload` 一定是业务响应结构。
- 处理方式:新增 `isApiResponsePayload` 类型守卫,先对 blob/arraybuffer 直接返回,再只在确认存在 `data` 字段时读取 `code/message/data`。
- 以后避免:修改共享 axios 拦截器时,二进制响应必须先从归一化流程短路;业务 payload 字段读取必须走类型守卫,不能只依赖泛型联合类型。
- 验证方式:执行对应网页端 `npm run build`,确认 `vue-tsc` 通过。
## AGENTS.md 中文读取需要指定 UTF-8
- 问题:直接读取 `AGENTS.md` 时,部分 PowerShell 输出会把中文显示成乱码。
+8 -9
View File
@@ -2,20 +2,19 @@
## 当前任务
当前仓库代码生产发布。
店务端小程序与网页端三项真实能力补齐:修改密码、导出 Excel、员工作品/订单。
## 已完成
- 已重新构建 `JY-Core`、`JY-Gateway`、`JY-Artist-Frontend` 和 `JY-Salon-Front`。
- 已逐台确认生产 Core 实际运行 `/opt/jayu-cloud/core/JY-Core.jar`,Gateway 实际运行 `/opt/jayu-cloud/gateway/JY-Gateway.jar`。
- 已滚动发布 3 台 Core 和 3 台 Gateway;Core SHA 前缀 `190BAAC97B66`,Gateway SHA 前缀 `F4348333F146`。
- 已发布设计师端与店务端 Web 静态资源,`/opt/jy-artist-frontend/current` 指向 `/opt/jy-artist-frontend/releases/20260716-005625/dist`。
- 已验证 6 个后端服务 active、本机健康检查通过、公网入口和关键静态资源均返回 200。
- 已确认稳定后最近 3 分钟后端日志无 journal error,且无 `Exception`、`ERROR`、`系统繁忙` 关键词。
- 已完成后端 `/user/password` 原密码改密分支、`/admin/export` Excel 下载接口、`/admin/manager/employees/{userId}/orders` 员工订单接口。
- 已完成 `JY-Salon-Front` 修改密码真实提交、导出 Blob 下载、员工订单真实列表。
- 已完成 `JY-Salon-WeChat` 修改密码真实提交并重新登录、导出下载打开 Excel、员工订单真实列表。
- 已更新 `docs/项目变更记录.md` 和 `docs/运维配置与集成说明.md`,记录 POI 依赖和接口行为。
- 已通过 `JY-Core` 编译、`JY-Salon-Front` 构建、小程序变更 JS 语法检查、GitNexus `detect-changes`。
## 下一步
- 若后续继续发布,仍需先用 `systemctl cat` 或真实 Java 进程确认实际 JAR 路径,不能只依赖脚本默认路径。
- 暂存本次相关文件并创建中文 git 提交。
## 当前阻塞点
@@ -23,4 +22,4 @@
## 最近一次重要操作结果
2026-07-16 当前代码已发布到生产后端和网页端,验证通过;本次未修改数据库、Nacos、Nginx 配置、SQL 和小程序。
2026-07-16 本地验证通过;GitNexus `detect-changes` 显示 23 个文件、44 个符号、0 个流程、风险 LOW。