完成Salon SIT整改并清理旧接口

This commit is contained in:
2026-11-01 16:21:43 +08:00
parent 9e47371442
commit fc3d38b247
14 changed files with 57 additions and 267 deletions
-81
View File
@@ -21,74 +21,11 @@ export interface OrderItem {
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
export interface CreateOrderRequest {
couponId?: IdType
couponSourceType?: string
remark?: string
clientRequestId?: string
items: OrderItem[]
}
export type CheckoutPreviewRequest = CreateOrderRequest
export interface CheckoutCouponPreview {
id: IdType
couponId?: IdType
userCouponId?: IdType
sourceType?: string
couponName: string
couponType: number
couponTypeName?: string
discountValue?: number
minAmount?: number
reduceAmount?: number
discountAmount?: number
available?: boolean
best?: boolean
vipAuto?: boolean
displayText?: string
savingText?: string
unavailableReason?: string
startTime?: string
endTime?: string
}
export interface CheckoutIssue {
code: string
message: string
itemId?: IdType
productId?: IdType
productTitle?: string
}
export interface CheckoutPreview {
subtotalAmount: number
savedAmount: number
payableAmount: number
bestCoupon?: CheckoutCouponPreview
availableCoupons: CheckoutCouponPreview[]
unavailableCoupons: CheckoutCouponPreview[]
bookingAvailable?: boolean
bookingIssues?: CheckoutIssue[]
vipTip?: string
summaryText?: string
}
export interface PaymentOrderVO {
id: IdType
payNo?: string
orderId: IdType
orderNo?: string
userId?: IdType
shopId?: IdType
channel?: string
status?: string
payAmount?: number
paidAmount?: number
payTime?: string
expireTime?: string
remark?: string
}
export interface OrderQuoteItem {
orderItemId: IdType
quotedPrice?: number
@@ -147,14 +84,6 @@ export interface PageResult<T> {
size: number
}
export interface GrowthSummaryVO {
userId?: IdType
growthValue?: number
levelName?: string
appointmentCount?: number
reviewCount?: number
}
export const afterSaleApi = {
apply: async (data: AfterSaleApplyRequest): Promise<AfterSaleVO> => {
return await api.post<AfterSaleVO>('/after-sale/apply', data) as unknown as AfterSaleVO
@@ -164,12 +93,6 @@ export const afterSaleApi = {
}
}
export const growthApi = {
getSummary: async (): Promise<GrowthSummaryVO> => {
return await api.get<GrowthSummaryVO>('/growth/summary') as unknown as GrowthSummaryVO
}
}
/**
* Purpose: ArtistCalendarAppointment supports order.ts by holding or executing the artist calendar appointment page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
@@ -329,10 +252,6 @@ export const orderApi = {
return api.post('/order/create', data)
},
checkoutPreview: async (data: CheckoutPreviewRequest): Promise<CheckoutPreview> => {
return await api.post<CheckoutPreview>('/order/checkout-preview', data) as unknown as CheckoutPreview
},
replyQuote: async (orderId: IdType, data?: OrderQuoteReplyRequest): Promise<any> => {
return await api.post(`/order/${orderId}/quote/reply`, data || {}) as unknown as any
},
+1 -1
View File
@@ -155,7 +155,7 @@ body {
}
.app-container--phone-shell :where(.nav-button, .icon-btn, .back-btn, .jayucloud-salon-icon-button) :where(.anticon),
.app-container--phone-shell :where(.header, .shop-topbar, .detail-header, .artist-topbar, .artist-list-topbar, .auth-topbar, .not-found-topbar, .cart-topbar, .vip-header) :where(.ant-btn .anticon, button .anticon),
.app-container--phone-shell :where(.header, .shop-topbar, .detail-header, .artist-topbar, .artist-list-topbar, .auth-topbar, .not-found-topbar) :where(.ant-btn .anticon, button .anticon),
.app-container--admin :where(.mobile-icon-btn, .mobile-avatar-btn) :where(.anticon) {
font-size: 21px !important;
line-height: 1;
@@ -1,19 +0,0 @@
import { describe, expect, it } from 'vitest'
import { BUY_NOW_MODE, getBuyNowProductIdFromQuery, isBuyNowCartItem } from './buy-now'
describe('buy-now checkout mode', () => {
it('reads the target product id only when cart query is in buyNow mode', () => {
expect(getBuyNowProductIdFromQuery({ mode: BUY_NOW_MODE, productId: '1001' })).toBe('1001')
expect(getBuyNowProductIdFromQuery({ mode: 'cart', productId: '1001' })).toBe('')
})
it('uses the first query value when vue-router provides array values', () => {
expect(getBuyNowProductIdFromQuery({ mode: [BUY_NOW_MODE], productId: ['2002', '3003'] })).toBe('2002')
})
it('matches numeric and string product ids for cart selection', () => {
expect(isBuyNowCartItem(1001, '1001')).toBe(true)
expect(isBuyNowCartItem('1002', '1001')).toBe(false)
})
})
-15
View File
@@ -1,15 +0,0 @@
export const BUY_NOW_MODE = 'buyNow'
type QueryValue = string | string[] | null | undefined
const firstQueryValue = (value: QueryValue) => Array.isArray(value) ? value[0] : value
export const getBuyNowProductIdFromQuery = (query: Record<string, unknown>) => {
const mode = firstQueryValue(query.mode as QueryValue)
const productId = firstQueryValue(query.productId as QueryValue)
return mode === BUY_NOW_MODE && productId ? String(productId) : ''
}
export const isBuyNowCartItem = (itemProductId: unknown, buyNowProductId: string) => {
return Boolean(buyNowProductId) && String(itemProductId || '') === String(buyNowProductId)
}
@@ -21,7 +21,7 @@ describe('request signature', () => {
const config = {
method: 'post',
baseURL: '/api',
url: '/order/checkout-preview',
url: '/order/42/quote/reply',
headers: {
'Content-Type': 'application/json'
},
@@ -36,7 +36,7 @@ describe('request signature', () => {
const payloadHash = createHash('sha256').update(JSON.stringify({ items: [] })).digest('hex')
const canonical = [
'POST',
'/order/checkout-preview',
'/order/42/quote/reply',
'1700000000000',
'1700000000000-fallback-id',
payloadHash
@@ -15,14 +15,12 @@ import adminApi, {
adminAfterSaleApi,
adminArtistScheduleApi,
adminAuthApi,
adminCampaignApi,
adminDashboardApi,
adminInventoryApi,
adminPaymentApi,
adminWorkbenchRegistrationApi
} from '../../src/api/admin'
import api from '../../src/api'
import { afterSaleApi, growthApi } from '../../src/api/order'
import { afterSaleApi } from '../../src/api/order'
type CapturedRequest = {
method?: string
@@ -85,12 +83,10 @@ describe('vNext API contracts', () => {
await adminArtistScheduleApi.listSchedules({ artistId: 9, startDate: '2026-06-01', endDate: '2026-06-07' })
await adminArtistScheduleApi.saveSchedule({ artistId: 9, workDate: '2026-06-01', startTime: '09:00', endTime: '18:00' })
await adminPaymentApi.manualConfirmOrder(42, 'cash verified')
await adminAfterSaleApi.listAfterSales({ status: 'APPLIED', page: 1, size: 20 })
await adminAfterSaleApi.approveAfterSale(5, { auditReason: 'approved' })
await adminInventoryApi.saveItem({ itemName: 'Base Gel', category: 'gel', unit: 'bottle', stockQuantity: 12 })
await adminInventoryApi.adjustStock(7, { changeType: 'IN', changeQuantity: 3, remark: 'restock' })
await adminCampaignApi.saveCampaign({ title: 'Summer Set', scene: 'HOME', status: 1 })
await adminDashboardApi.getOverview({ date: '2026-10-25', days: 7 })
await adminAuthApi.changePassword({ currentPassword: 'OldPass1!', newPassword: 'FreshPass2!' })
await adminWorkbenchRegistrationApi.list()
@@ -100,12 +96,10 @@ describe('vNext API contracts', () => {
expect(requests).toEqual([
{ method: 'get', url: '/artist-schedule/list', params: { artistId: 9, startDate: '2026-06-01', endDate: '2026-06-07' }, data: undefined },
{ method: 'post', url: '/artist-schedule/save', params: undefined, data: { artistId: 9, workDate: '2026-06-01', startTime: '09:00', endTime: '18:00' } },
{ method: 'post', url: '/payment/order/42/manual-confirm', params: { remark: 'cash verified' }, data: undefined },
{ method: 'get', url: '/after-sale/list', params: { status: 'APPLIED', page: 1, size: 20 }, data: undefined },
{ method: 'put', url: '/after-sale/5/approve', params: undefined, data: { auditReason: 'approved' } },
{ method: 'post', url: '/inventory/save', params: undefined, data: { itemName: 'Base Gel', category: 'gel', unit: 'bottle', stockQuantity: 12 } },
{ method: 'post', url: '/inventory/7/adjust', params: undefined, data: { changeType: 'IN', changeQuantity: 3, remark: 'restock' } },
{ method: 'post', url: '/campaign/save', params: undefined, data: { title: 'Summer Set', scene: 'HOME', status: 1 } },
{ method: 'get', url: '/dashboard/overview', params: { date: '2026-10-25', days: 7 }, data: undefined },
{ method: 'post', url: '/auth/password', params: undefined, data: { currentPassword: 'OldPass1!', newPassword: 'FreshPass2!' } },
{ method: 'get', url: '/user/workbench/registration/list', params: undefined, data: undefined },
@@ -120,12 +114,10 @@ describe('vNext API contracts', () => {
await afterSaleApi.apply({ orderId: 42, type: 'REFUND', reason: 'schedule changed', refundAmount: 88 })
await afterSaleApi.listMy({ page: 1, size: 5 })
await growthApi.getSummary()
expect(requests).toEqual([
{ method: 'post', url: '/after-sale/apply', params: undefined, data: { orderId: 42, type: 'REFUND', reason: 'schedule changed', refundAmount: 88 } },
{ method: 'get', url: '/after-sale/my', params: { page: 1, size: 5 }, data: undefined },
{ method: 'get', url: '/growth/summary', params: undefined, data: undefined }
{ method: 'get', url: '/after-sale/my', params: { page: 1, size: 5 }, data: undefined }
])
})
})