功能:新增下一阶段运营能力和生产部署
This commit is contained in:
@@ -264,6 +264,8 @@ YumiNail-Admin-Program/utils/config.local.js
|
|||||||
|
|
||||||
# Local release/test artifacts
|
# Local release/test artifacts
|
||||||
release-packages/
|
release-packages/
|
||||||
|
artifacts/full-acceptance-*/
|
||||||
|
artifacts/release/
|
||||||
.codex-run/
|
.codex-run/
|
||||||
output/
|
output/
|
||||||
.codex-temp-*
|
.codex-temp-*
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<!-- gitnexus:start -->
|
<!-- gitnexus:start -->
|
||||||
# GitNexus — Code Intelligence
|
# GitNexus — Code Intelligence
|
||||||
|
|
||||||
This project is indexed by GitNexus as **xiaowang** (12601 symbols, 25777 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
|
This project is indexed by GitNexus as **xiaowang** (14285 symbols, 29539 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
|
||||||
|
|
||||||
> If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first.
|
> If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<!-- gitnexus:start -->
|
<!-- gitnexus:start -->
|
||||||
# GitNexus — Code Intelligence
|
# GitNexus — Code Intelligence
|
||||||
|
|
||||||
This project is indexed by GitNexus as **xiaowang** (12601 symbols, 25777 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
|
This project is indexed by GitNexus as **xiaowang** (14285 symbols, 29539 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
|
||||||
|
|
||||||
> If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first.
|
> If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
const request = require('../utils/request')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
applyAfterSale(data) {
|
||||||
|
return request({
|
||||||
|
url: '/after-sale/apply',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
getMyAfterSales(params) {
|
||||||
|
return request({
|
||||||
|
url: '/after-sale/my',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
const request = require('../utils/request')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
getGrowthSummary() {
|
||||||
|
return request({
|
||||||
|
url: '/growth/summary'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
const request = require('../utils/request')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
prepareOrderPayment(orderId) {
|
||||||
|
return request({
|
||||||
|
url: `/payment/order/${orderId}/prepare`,
|
||||||
|
method: 'POST',
|
||||||
|
data: {}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
mockOrderPaymentSuccess(orderId) {
|
||||||
|
return request({
|
||||||
|
url: `/payment/order/${orderId}/mock-success`,
|
||||||
|
method: 'POST',
|
||||||
|
data: {}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
const assert = require('assert')
|
||||||
|
const Module = require('module')
|
||||||
|
|
||||||
|
const calls = []
|
||||||
|
const originalLoad = Module._load
|
||||||
|
|
||||||
|
Module._load = function mockRequestModule(request, parent, isMain) {
|
||||||
|
if (request === '../utils/request') {
|
||||||
|
return options => {
|
||||||
|
calls.push(options)
|
||||||
|
return Promise.resolve(options)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return originalLoad.apply(this, arguments)
|
||||||
|
}
|
||||||
|
|
||||||
|
const paymentApi = require('./payment')
|
||||||
|
const afterSaleApi = require('./after-sale')
|
||||||
|
const growthApi = require('./growth')
|
||||||
|
|
||||||
|
paymentApi.prepareOrderPayment(12)
|
||||||
|
paymentApi.mockOrderPaymentSuccess(12)
|
||||||
|
afterSaleApi.applyAfterSale({ orderId: 12, reason: 'need refund' })
|
||||||
|
afterSaleApi.getMyAfterSales({ page: 2, size: 5 })
|
||||||
|
growthApi.getGrowthSummary()
|
||||||
|
|
||||||
|
Module._load = originalLoad
|
||||||
|
|
||||||
|
assert.deepStrictEqual(calls[0], {
|
||||||
|
url: '/payment/order/12/prepare',
|
||||||
|
method: 'POST',
|
||||||
|
data: {}
|
||||||
|
})
|
||||||
|
assert.deepStrictEqual(calls[1], {
|
||||||
|
url: '/payment/order/12/mock-success',
|
||||||
|
method: 'POST',
|
||||||
|
data: {}
|
||||||
|
})
|
||||||
|
assert.deepStrictEqual(calls[2], {
|
||||||
|
url: '/after-sale/apply',
|
||||||
|
method: 'POST',
|
||||||
|
data: { orderId: 12, reason: 'need refund' }
|
||||||
|
})
|
||||||
|
assert.deepStrictEqual(calls[3], {
|
||||||
|
url: '/after-sale/my',
|
||||||
|
params: { page: 2, size: 5 }
|
||||||
|
})
|
||||||
|
assert.deepStrictEqual(calls[4], {
|
||||||
|
url: '/growth/summary'
|
||||||
|
})
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
*/
|
*/
|
||||||
const orderApi = require('../../api/order')
|
const orderApi = require('../../api/order')
|
||||||
|
const paymentApi = require('../../api/payment')
|
||||||
|
const afterSaleApi = require('../../api/after-sale')
|
||||||
const cartApi = require('../../api/cart')
|
const cartApi = require('../../api/cart')
|
||||||
/**
|
/**
|
||||||
* Purpose: auth supports index.js by holding or executing the auth page or API role.
|
* Purpose: auth supports index.js by holding or executing the auth page or API role.
|
||||||
@@ -35,6 +37,19 @@ const { buildRecoveryState, clearRecoveryState } = require('../../utils/recovery
|
|||||||
*/
|
*/
|
||||||
const REVIEW_SCORE_OPTIONS = [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5]
|
const REVIEW_SCORE_OPTIONS = [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5]
|
||||||
|
|
||||||
|
const PAYMENT_STATUS_TEXT = {
|
||||||
|
UNPAID: '待支付',
|
||||||
|
PAYING: '待确认支付',
|
||||||
|
PAID: '已支付',
|
||||||
|
REFUNDED: '已退款'
|
||||||
|
}
|
||||||
|
|
||||||
|
const AFTER_SALE_STATUS_TEXT = {
|
||||||
|
PENDING: '审核中',
|
||||||
|
APPROVED: '已通过',
|
||||||
|
REJECTED: '已拒绝'
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: toId supports index.js by holding or executing the to id page or API role.
|
* Purpose: toId supports index.js by holding or executing the to id page or API role.
|
||||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -69,6 +84,120 @@ function trimText(value) {
|
|||||||
return String(value || '').trim()
|
return String(value || '').trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeStatus(value) {
|
||||||
|
return String(value || '').trim().toUpperCase()
|
||||||
|
}
|
||||||
|
|
||||||
|
function firstFilled(values) {
|
||||||
|
return values.find(value => value !== undefined && value !== null && value !== '')
|
||||||
|
}
|
||||||
|
|
||||||
|
function toAmount(value) {
|
||||||
|
const amount = Number(value)
|
||||||
|
return isFinite(amount) ? amount : 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOrderPayAmount(order) {
|
||||||
|
return toAmount(firstFilled([
|
||||||
|
order && order.payAmount,
|
||||||
|
order && order.actualAmount,
|
||||||
|
order && order.totalAmount
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolvePaymentStatus(order) {
|
||||||
|
const status = normalizeStatus(order && (order.paymentStatus || order.payStatus || order.paymentState))
|
||||||
|
if (status) {
|
||||||
|
return status
|
||||||
|
}
|
||||||
|
if (Number(order && order.status) === 2 || getOrderPayAmount(order) <= 0) {
|
||||||
|
return 'PAID'
|
||||||
|
}
|
||||||
|
return 'UNPAID'
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildPaymentInfo(order) {
|
||||||
|
const status = resolvePaymentStatus(order)
|
||||||
|
const payAmount = getOrderPayAmount(order)
|
||||||
|
const paidAmount = toAmount(firstFilled([
|
||||||
|
order && order.paidAmount,
|
||||||
|
status === 'PAID' ? payAmount : ''
|
||||||
|
]))
|
||||||
|
return {
|
||||||
|
status,
|
||||||
|
statusText: PAYMENT_STATUS_TEXT[status] || status || '待支付',
|
||||||
|
statusClass: `payment-${status.toLowerCase() || 'unpaid'}`,
|
||||||
|
amountText: `¥${formatPrice(payAmount)}`,
|
||||||
|
paidAmountText: `¥${formatPrice(paidAmount)}`,
|
||||||
|
payNoText: (order && (order.paymentOrderNo || order.payNo)) || '',
|
||||||
|
canPay: status === 'UNPAID' || status === 'PAYING',
|
||||||
|
isPaid: status === 'PAID',
|
||||||
|
isRefunded: status === 'REFUNDED'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAfterSaleStatusText(record) {
|
||||||
|
const status = normalizeStatus(record && record.status)
|
||||||
|
return AFTER_SALE_STATUS_TEXT[status] || status || '已申请'
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildAfterSaleSummary(record) {
|
||||||
|
if (!record) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const amount = firstFilled([record.refundAmount, record.amount])
|
||||||
|
return {
|
||||||
|
...record,
|
||||||
|
status: normalizeStatus(record.status),
|
||||||
|
statusText: getAfterSaleStatusText(record),
|
||||||
|
typeText: record.type === 'REFUND' ? '退款' : (record.type || '售后'),
|
||||||
|
amountText: amount === undefined || amount === null || amount === '' ? '' : `¥${formatPrice(amount)}`,
|
||||||
|
reasonText: trimText(record.reason),
|
||||||
|
auditReasonText: trimText(record.auditReason),
|
||||||
|
createdText: formatDateTime(record.createTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function latestRecordTime(record) {
|
||||||
|
return String((record && (record.auditTime || record.updateTime || record.createTime)) || '')
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractListPayload(payload) {
|
||||||
|
if (Array.isArray(payload)) {
|
||||||
|
return payload
|
||||||
|
}
|
||||||
|
if (payload && Array.isArray(payload.list)) {
|
||||||
|
return payload.list
|
||||||
|
}
|
||||||
|
if (payload && Array.isArray(payload.records)) {
|
||||||
|
return payload.records
|
||||||
|
}
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
function indexLatestAfterSaleByOrderId(list) {
|
||||||
|
return safeList(list).reduce((result, item) => {
|
||||||
|
const orderId = toId(item && item.orderId)
|
||||||
|
if (!orderId) {
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
const current = result[orderId]
|
||||||
|
if (!current || latestRecordTime(item).localeCompare(latestRecordTime(current)) > 0) {
|
||||||
|
result[orderId] = item
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}, {})
|
||||||
|
}
|
||||||
|
|
||||||
|
function canApplyAfterSale(order, afterSaleSummary) {
|
||||||
|
const paymentInfo = order && order.paymentInfo ? order.paymentInfo : buildPaymentInfo(order)
|
||||||
|
const afterSaleStatus = normalizeStatus(afterSaleSummary && afterSaleSummary.status)
|
||||||
|
return paymentInfo.isPaid
|
||||||
|
&& Number(order && order.status) !== 3
|
||||||
|
&& afterSaleStatus !== 'PENDING'
|
||||||
|
&& afterSaleStatus !== 'APPROVED'
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: formatRating supports index.js by holding or executing the format rating page or API role.
|
* Purpose: formatRating supports index.js by holding or executing the format rating page or API role.
|
||||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -289,15 +418,20 @@ async function safeCall(factory, fallbackValue) {
|
|||||||
async function loadAssistData(orders) {
|
async function loadAssistData(orders) {
|
||||||
const pendingReviewsPromise = safeCall(() => orderApi.listMyPendingReviews(), [])
|
const pendingReviewsPromise = safeCall(() => orderApi.listMyPendingReviews(), [])
|
||||||
const pendingChangesPromise = safeCall(() => orderApi.listMyPendingArtistChangeRequests(), [])
|
const pendingChangesPromise = safeCall(() => orderApi.listMyPendingArtistChangeRequests(), [])
|
||||||
|
const afterSalesPromise = safeCall(() => afterSaleApi.getMyAfterSales({
|
||||||
|
page: 1,
|
||||||
|
size: 50
|
||||||
|
}), { list: [] })
|
||||||
const orderReviewListsPromise = Promise.all(orders.map(order => (
|
const orderReviewListsPromise = Promise.all(orders.map(order => (
|
||||||
safeCall(() => orderApi.listOrderReviews(order.id), [])
|
safeCall(() => orderApi.listOrderReviews(order.id), [])
|
||||||
)))
|
)))
|
||||||
const orderChangeListsPromise = Promise.all(orders.map(order => (
|
const orderChangeListsPromise = Promise.all(orders.map(order => (
|
||||||
safeCall(() => orderApi.listOrderArtistChangeRequests(order.id), [])
|
safeCall(() => orderApi.listOrderArtistChangeRequests(order.id), [])
|
||||||
)))
|
)))
|
||||||
const [pendingReviews, pendingChanges, orderReviewLists, orderChangeLists] = await Promise.all([
|
const [pendingReviews, pendingChanges, afterSales, orderReviewLists, orderChangeLists] = await Promise.all([
|
||||||
pendingReviewsPromise,
|
pendingReviewsPromise,
|
||||||
pendingChangesPromise,
|
pendingChangesPromise,
|
||||||
|
afterSalesPromise,
|
||||||
orderReviewListsPromise,
|
orderReviewListsPromise,
|
||||||
orderChangeListsPromise
|
orderChangeListsPromise
|
||||||
])
|
])
|
||||||
@@ -315,6 +449,7 @@ async function loadAssistData(orders) {
|
|||||||
pendingReviewByItemId: indexByOrderItemId(pendingReviews),
|
pendingReviewByItemId: indexByOrderItemId(pendingReviews),
|
||||||
submittedReviewByItemId: indexByOrderItemId(submittedReviews),
|
submittedReviewByItemId: indexByOrderItemId(submittedReviews),
|
||||||
pendingChangeByItemId: indexByOrderItemId(pendingChanges),
|
pendingChangeByItemId: indexByOrderItemId(pendingChanges),
|
||||||
|
afterSaleByOrderId: indexLatestAfterSaleByOrderId(extractListPayload(afterSales)),
|
||||||
pendingReviews,
|
pendingReviews,
|
||||||
reviewsByOrderId: safeList(orders).reduce((result, order, index) => {
|
reviewsByOrderId: safeList(orders).reduce((result, order, index) => {
|
||||||
result[toId(order && order.id)] = safeList(orderReviewLists[index])
|
result[toId(order && order.id)] = safeList(orderReviewLists[index])
|
||||||
@@ -435,6 +570,8 @@ Page({
|
|||||||
statusClass: getOrderStatusClass(order),
|
statusClass: getOrderStatusClass(order),
|
||||||
shopNameText: order.shopName ? `所属店铺:${order.shopName}` : '',
|
shopNameText: order.shopName ? `所属店铺:${order.shopName}` : '',
|
||||||
actualAmountText: `\u00a5${formatPrice(order.actualAmount)}`,
|
actualAmountText: `\u00a5${formatPrice(order.actualAmount)}`,
|
||||||
|
paymentInfo: buildPaymentInfo(order),
|
||||||
|
afterSaleSummary: buildAfterSaleSummary(order.afterSaleSummary || assistData.afterSaleByOrderId[toId(order.id)]),
|
||||||
timeline: buildOrderTimeline(order, assistData.reviewsByOrderId[toId(order.id)], assistData.changesByOrderId[toId(order.id)], assistData.pendingReviews),
|
timeline: buildOrderTimeline(order, assistData.reviewsByOrderId[toId(order.id)], assistData.changesByOrderId[toId(order.id)], assistData.pendingReviews),
|
||||||
items: await Promise.all(safeList(order.items).map(async item => {
|
items: await Promise.all(safeList(order.items).map(async item => {
|
||||||
const itemId = toId(item.id)
|
const itemId = toId(item.id)
|
||||||
@@ -461,6 +598,7 @@ Page({
|
|||||||
|
|
||||||
formattedOrders.forEach(order => {
|
formattedOrders.forEach(order => {
|
||||||
order.canRebook = Number(order.status) === 2 && getRebookableOrderItems(order).length > 0
|
order.canRebook = Number(order.status) === 2 && getRebookableOrderItems(order).length > 0
|
||||||
|
order.canApplyAfterSale = canApplyAfterSale(order, order.afterSaleSummary)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.setData({
|
this.setData({
|
||||||
@@ -708,6 +846,127 @@ Page({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async handlePayOrder(event) {
|
||||||
|
const orderId = event.currentTarget.dataset.orderId
|
||||||
|
const order = findOrderById(this.data.orders, orderId)
|
||||||
|
if (!order || !order.paymentInfo || !order.paymentInfo.canPay) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '当前订单无需支付',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await actionGuard.run(this, `order:pay:${orderId}`, async () => {
|
||||||
|
await runWithLoading(() => paymentApi.prepareOrderPayment(orderId), {
|
||||||
|
title: '准备支付'
|
||||||
|
})
|
||||||
|
const confirmed = await new Promise(resolve => {
|
||||||
|
wx.showModal({
|
||||||
|
title: '模拟支付',
|
||||||
|
content: `本次需支付 ${order.paymentInfo.amountText},确认模拟支付成功吗?`,
|
||||||
|
confirmText: '确认支付',
|
||||||
|
success: res => resolve(Boolean(res.confirm)),
|
||||||
|
fail: () => resolve(false)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
if (!confirmed) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await runWithLoading(() => paymentApi.mockOrderPaymentSuccess(orderId), {
|
||||||
|
title: '确认支付'
|
||||||
|
})
|
||||||
|
wx.showToast({
|
||||||
|
title: '支付已确认',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
await this.loadOrders()
|
||||||
|
}, {
|
||||||
|
message: '支付处理中,请勿重复点击'
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
if (actionGuard.isGuardError(error)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
wx.showToast({
|
||||||
|
title: error.message || '支付失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async handleApplyAfterSale(event) {
|
||||||
|
const orderId = event.currentTarget.dataset.orderId
|
||||||
|
const order = findOrderById(this.data.orders, orderId)
|
||||||
|
if (!order || !order.canApplyAfterSale) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '当前订单暂不可申请售后',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await actionGuard.run(this, `order:after-sale:${orderId}`, async () => {
|
||||||
|
const reason = await this.promptAfterSaleReason()
|
||||||
|
if (!reason) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await runWithLoading(() => afterSaleApi.applyAfterSale({
|
||||||
|
orderId,
|
||||||
|
type: 'REFUND',
|
||||||
|
reason,
|
||||||
|
refundAmount: getOrderPayAmount(order)
|
||||||
|
}), {
|
||||||
|
title: '提交售后'
|
||||||
|
})
|
||||||
|
wx.showToast({
|
||||||
|
title: '售后已提交',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
await this.loadOrders()
|
||||||
|
}, {
|
||||||
|
message: '售后申请提交中,请勿重复点击'
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
if (actionGuard.isGuardError(error)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
wx.showToast({
|
||||||
|
title: error.message || '售后申请失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
promptAfterSaleReason() {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
wx.showModal({
|
||||||
|
title: '申请售后',
|
||||||
|
content: '请填写售后原因,提交后门店会尽快处理。',
|
||||||
|
editable: true,
|
||||||
|
placeholderText: '例如:需要退款或调整服务',
|
||||||
|
confirmText: '提交',
|
||||||
|
success: res => {
|
||||||
|
if (!res.confirm) {
|
||||||
|
resolve('')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const reason = trimText(res.content)
|
||||||
|
if (!reason) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '请填写售后原因',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
resolve(reason)
|
||||||
|
},
|
||||||
|
fail: () => resolve('')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: promptRejectReason collects an optional customer reason before rejecting an artist-change request.
|
* Purpose: promptRejectReason collects an optional customer reason before rejecting an artist-change request.
|
||||||
* Usage: call it after the confirmation dialog and pass the returned text to rejectArtistChange.
|
* Usage: call it after the confirmation dialog and pass the returned text to rejectArtistChange.
|
||||||
|
|||||||
@@ -25,6 +25,26 @@
|
|||||||
</view>
|
</view>
|
||||||
<view wx:if="{{item.shopNameText}}" class="order-shop">{{item.shopNameText}}</view>
|
<view wx:if="{{item.shopNameText}}" class="order-shop">{{item.shopNameText}}</view>
|
||||||
|
|
||||||
|
<view class="payment-panel">
|
||||||
|
<view class="payment-copy">
|
||||||
|
<text class="assist-label">支付状态</text>
|
||||||
|
<text class="assist-main">{{item.paymentInfo.statusText}}</text>
|
||||||
|
<text wx:if="{{item.paymentInfo.payNoText}}" class="assist-desc">支付单:{{item.paymentInfo.payNoText}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="payment-amount">
|
||||||
|
<text>{{item.paymentInfo.amountText}}</text>
|
||||||
|
<text wx:if="{{item.paymentInfo.isPaid}}">实付 {{item.paymentInfo.paidAmountText}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view wx:if="{{item.afterSaleSummary}}" class="after-sale-summary">
|
||||||
|
<text class="assist-label">售后进度</text>
|
||||||
|
<text class="assist-main">{{item.afterSaleSummary.typeText}} · {{item.afterSaleSummary.statusText}}</text>
|
||||||
|
<text wx:if="{{item.afterSaleSummary.amountText}}" class="assist-desc">申请金额:{{item.afterSaleSummary.amountText}}</text>
|
||||||
|
<text wx:if="{{item.afterSaleSummary.reasonText}}" class="assist-desc">原因:{{item.afterSaleSummary.reasonText}}</text>
|
||||||
|
<text wx:if="{{item.afterSaleSummary.auditReasonText}}" class="assist-desc">处理说明:{{item.afterSaleSummary.auditReasonText}}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view wx:if="{{item.timeline && item.timeline.length}}" class="order-timeline">
|
<view wx:if="{{item.timeline && item.timeline.length}}" class="order-timeline">
|
||||||
<view
|
<view
|
||||||
wx:for="{{item.timeline}}"
|
wx:for="{{item.timeline}}"
|
||||||
@@ -104,6 +124,8 @@
|
|||||||
<view class="order-foot">
|
<view class="order-foot">
|
||||||
<text class="order-amount">总计:{{item.actualAmountText}}</text>
|
<text class="order-amount">总计:{{item.actualAmountText}}</text>
|
||||||
<view class="order-actions">
|
<view class="order-actions">
|
||||||
|
<view wx:if="{{item.paymentInfo.canPay}}" class="pay-btn" data-order-id="{{item.id}}" bindtap="handlePayOrder">去支付</view>
|
||||||
|
<view wx:if="{{item.canApplyAfterSale}}" class="after-sale-btn" data-order-id="{{item.id}}" bindtap="handleApplyAfterSale">申请售后</view>
|
||||||
<view wx:if="{{item.canRebook}}" class="rebook-btn" data-order-id="{{item.id}}" bindtap="handleRebookOrder">复刻同款</view>
|
<view wx:if="{{item.canRebook}}" class="rebook-btn" data-order-id="{{item.id}}" bindtap="handleRebookOrder">复刻同款</view>
|
||||||
<view wx:if="{{item.status == 1}}" class="cancel-btn" data-order-id="{{item.id}}" bindtap="handleCancelOrder">取消订单</view>
|
<view wx:if="{{item.status == 1}}" class="cancel-btn" data-order-id="{{item.id}}" bindtap="handleCancelOrder">取消订单</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -82,6 +82,46 @@
|
|||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.payment-panel {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 18rpx;
|
||||||
|
margin-top: 18rpx;
|
||||||
|
padding: 18rpx 20rpx;
|
||||||
|
border-radius: 18rpx;
|
||||||
|
background: var(--theme-primary-soft);
|
||||||
|
}
|
||||||
|
|
||||||
|
.payment-copy {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.payment-amount {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-end;
|
||||||
|
gap: 6rpx;
|
||||||
|
color: #2d2430;
|
||||||
|
font-size: 26rpx;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.payment-amount text:last-child {
|
||||||
|
color: #8d7a84;
|
||||||
|
font-size: 22rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.after-sale-summary {
|
||||||
|
margin-top: 16rpx;
|
||||||
|
padding: 18rpx 20rpx;
|
||||||
|
border-radius: 18rpx;
|
||||||
|
background: rgba(255, 247, 249, 0.82);
|
||||||
|
border: 2rpx solid var(--theme-border);
|
||||||
|
}
|
||||||
|
|
||||||
.order-timeline {
|
.order-timeline {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||||
@@ -230,6 +270,8 @@
|
|||||||
color: #2d2430;
|
color: #2d2430;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pay-btn,
|
||||||
|
.after-sale-btn,
|
||||||
.cancel-btn,
|
.cancel-btn,
|
||||||
.rebook-btn {
|
.rebook-btn {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
@@ -243,6 +285,17 @@
|
|||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pay-btn {
|
||||||
|
background: var(--theme-primary);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.after-sale-btn {
|
||||||
|
background: #ffffff;
|
||||||
|
border: 2rpx solid var(--theme-border);
|
||||||
|
color: #5d4b55;
|
||||||
|
}
|
||||||
|
|
||||||
.rebook-btn {
|
.rebook-btn {
|
||||||
background: var(--theme-primary);
|
background: var(--theme-primary);
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ const couponApi = require('../../api/coupon')
|
|||||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
*/
|
*/
|
||||||
const orderApi = require('../../api/order')
|
const orderApi = require('../../api/order')
|
||||||
|
const growthApi = require('../../api/growth')
|
||||||
/**
|
/**
|
||||||
* Purpose: userApi supports index.js by holding or executing the user api page or API role.
|
* Purpose: userApi supports index.js by holding or executing the user api page or API role.
|
||||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -46,6 +47,18 @@ const theme = require('../../utils/theme')
|
|||||||
const { DEFAULT_AVATAR } = require('../../utils/config')
|
const { DEFAULT_AVATAR } = require('../../utils/config')
|
||||||
const { runWithLoading } = require('../../utils/loading')
|
const { runWithLoading } = require('../../utils/loading')
|
||||||
|
|
||||||
|
function formatGrowthSummary(summary) {
|
||||||
|
if (!summary) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
levelName: summary.levelName || '成长新客',
|
||||||
|
growthValue: Number(summary.growthValue || 0),
|
||||||
|
appointmentCount: Number(summary.appointmentCount || 0),
|
||||||
|
reviewCount: Number(summary.reviewCount || 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* profile page logic.
|
* profile page logic.
|
||||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||||
@@ -61,6 +74,7 @@ Page({
|
|||||||
couponCount: 0,
|
couponCount: 0,
|
||||||
wishlistCount: 0,
|
wishlistCount: 0,
|
||||||
unreadMessageCount: 0,
|
unreadMessageCount: 0,
|
||||||
|
growthSummary: null,
|
||||||
defaultAvatar: DEFAULT_AVATAR
|
defaultAvatar: DEFAULT_AVATAR
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -91,19 +105,21 @@ Page({
|
|||||||
orderCount: 0,
|
orderCount: 0,
|
||||||
couponCount: 0,
|
couponCount: 0,
|
||||||
wishlistCount: 0,
|
wishlistCount: 0,
|
||||||
|
growthSummary: null,
|
||||||
loading: false
|
loading: false
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [userInfo, orders, coupons, wishlist, unreadMessages, pendingReviews] = await Promise.all([
|
const [userInfo, orders, coupons, wishlist, unreadMessages, pendingReviews, growthSummary] = await Promise.all([
|
||||||
userApi.getUserInfo(),
|
userApi.getUserInfo(),
|
||||||
orderApi.getOrderList(),
|
orderApi.getOrderList(),
|
||||||
couponApi.listUserCoupons(),
|
couponApi.listUserCoupons(),
|
||||||
wishlistApi.getWishlist(),
|
wishlistApi.getWishlist(),
|
||||||
userApi.getMyUnreadMessageCount(),
|
userApi.getMyUnreadMessageCount(),
|
||||||
orderApi.listMyPendingReviews().catch(() => [])
|
orderApi.listMyPendingReviews().catch(() => []),
|
||||||
|
growthApi.getGrowthSummary().catch(() => null)
|
||||||
])
|
])
|
||||||
|
|
||||||
getApp().refreshUserInfo(userInfo)
|
getApp().refreshUserInfo(userInfo)
|
||||||
@@ -113,7 +129,8 @@ Page({
|
|||||||
pendingReviewCount: Array.isArray(pendingReviews) ? pendingReviews.length : 0,
|
pendingReviewCount: Array.isArray(pendingReviews) ? pendingReviews.length : 0,
|
||||||
couponCount: Array.isArray(coupons) ? coupons.length : 0,
|
couponCount: Array.isArray(coupons) ? coupons.length : 0,
|
||||||
wishlistCount: Array.isArray(wishlist) ? wishlist.length : 0,
|
wishlistCount: Array.isArray(wishlist) ? wishlist.length : 0,
|
||||||
unreadMessageCount: Number((unreadMessages && unreadMessages.unreadCount) || 0)
|
unreadMessageCount: Number((unreadMessages && unreadMessages.unreadCount) || 0),
|
||||||
|
growthSummary: formatGrowthSummary(growthSummary)
|
||||||
})
|
})
|
||||||
await this.checkPopupMessages()
|
await this.checkPopupMessages()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -42,6 +42,27 @@
|
|||||||
<text>给服务过你的美甲师一点反馈</text>
|
<text>给服务过你的美甲师一点反馈</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view wx:if="{{growthSummary}}" class="growth-card">
|
||||||
|
<view class="growth-head">
|
||||||
|
<text class="growth-label">成长等级</text>
|
||||||
|
<text class="growth-level">{{growthSummary.levelName}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="growth-metrics">
|
||||||
|
<view>
|
||||||
|
<text>{{growthSummary.growthValue}}</text>
|
||||||
|
<text>成长值</text>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<text>{{growthSummary.appointmentCount}}</text>
|
||||||
|
<text>预约</text>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<text>{{growthSummary.reviewCount}}</text>
|
||||||
|
<text>评价</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="shop-box" bindtap="handleSwitchShop">
|
<view class="shop-box" bindtap="handleSwitchShop">
|
||||||
<view>
|
<view>
|
||||||
<view class="shop-label">当前登录门店</view>
|
<view class="shop-label">当前登录门店</view>
|
||||||
|
|||||||
@@ -111,6 +111,57 @@
|
|||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.growth-card {
|
||||||
|
margin-top: 22rpx;
|
||||||
|
padding: 22rpx 24rpx;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
background: #ffffff;
|
||||||
|
border: 2rpx solid var(--theme-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.growth-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 18rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.growth-label {
|
||||||
|
color: #8d7a84;
|
||||||
|
font-size: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.growth-level {
|
||||||
|
color: var(--theme-primary);
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.growth-metrics {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
gap: 12rpx;
|
||||||
|
margin-top: 18rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.growth-metrics view {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6rpx;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.growth-metrics text:first-child {
|
||||||
|
color: #2d2430;
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.growth-metrics text:last-child {
|
||||||
|
color: #8d7a84;
|
||||||
|
font-size: 22rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.shop-box {
|
.shop-box {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* Purpose: request sends authenticated admin mini-program calls through the shared request wrapper.
|
||||||
|
* Usage: keep after-sale endpoints aligned with /admin/after-sale on the backend.
|
||||||
|
*/
|
||||||
|
const request = require('../utils/request')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
listAfterSales(params) {
|
||||||
|
return request({
|
||||||
|
url: '/after-sale/list',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
approveAfterSale(id, data) {
|
||||||
|
return request({
|
||||||
|
url: `/after-sale/${id}/approve`,
|
||||||
|
method: 'PUT',
|
||||||
|
data: data || {}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
rejectAfterSale(id, data) {
|
||||||
|
return request({
|
||||||
|
url: `/after-sale/${id}/reject`,
|
||||||
|
method: 'PUT',
|
||||||
|
data: data || {}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* Purpose: request sends authenticated admin mini-program calls through the shared request wrapper.
|
||||||
|
* Usage: keep schedule endpoints aligned with /admin/artist-schedule on the backend.
|
||||||
|
*/
|
||||||
|
const request = require('../utils/request')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
listSchedules(params) {
|
||||||
|
return request({
|
||||||
|
url: '/artist-schedule/list',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
saveSchedule(data) {
|
||||||
|
return request({
|
||||||
|
url: '/artist-schedule/save',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* Purpose: request sends authenticated admin mini-program calls through the shared request wrapper.
|
||||||
|
* Usage: keep campaign endpoints aligned with /admin/campaign on the backend.
|
||||||
|
*/
|
||||||
|
const request = require('../utils/request')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
listCampaigns(params) {
|
||||||
|
return request({
|
||||||
|
url: '/campaign/list',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
saveCampaign(data) {
|
||||||
|
return request({
|
||||||
|
url: '/campaign/save',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,5 +13,11 @@ module.exports = {
|
|||||||
return request({
|
return request({
|
||||||
url: '/dashboard/stats'
|
url: '/dashboard/stats'
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
getAnalytics() {
|
||||||
|
return request({
|
||||||
|
url: '/dashboard/analytics'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* Purpose: request sends authenticated admin mini-program calls through the shared request wrapper.
|
||||||
|
* Usage: keep inventory endpoints aligned with /admin/inventory on the backend.
|
||||||
|
*/
|
||||||
|
const request = require('../utils/request')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
listItems(params) {
|
||||||
|
return request({
|
||||||
|
url: '/inventory/list',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
saveItem(data) {
|
||||||
|
return request({
|
||||||
|
url: '/inventory/save',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
adjustStock(id, data) {
|
||||||
|
return request({
|
||||||
|
url: `/inventory/${id}/adjust`,
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* Purpose: request sends authenticated admin mini-program calls through the shared request wrapper.
|
||||||
|
* Usage: call manual payment operations only after UI permission checks; backend remains authoritative.
|
||||||
|
*/
|
||||||
|
const request = require('../utils/request')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
manualConfirmOrder(orderId, remark) {
|
||||||
|
return request({
|
||||||
|
url: `/payment/order/${orderId}/manual-confirm`,
|
||||||
|
method: 'POST',
|
||||||
|
params: {
|
||||||
|
remark
|
||||||
|
},
|
||||||
|
data: {}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,10 @@
|
|||||||
"pages/tag-form/index",
|
"pages/tag-form/index",
|
||||||
"pages/artists/index",
|
"pages/artists/index",
|
||||||
"pages/artist-form/index",
|
"pages/artist-form/index",
|
||||||
|
"pages/schedules/index",
|
||||||
|
"pages/after-sales/index",
|
||||||
|
"pages/inventory/index",
|
||||||
|
"pages/campaigns/index",
|
||||||
"pages/shops/index",
|
"pages/shops/index",
|
||||||
"pages/shop-form/index",
|
"pages/shop-form/index",
|
||||||
"pages/permissions/index",
|
"pages/permissions/index",
|
||||||
|
|||||||
@@ -0,0 +1,166 @@
|
|||||||
|
const afterSaleApi = require('../../api/after-sale')
|
||||||
|
const navigation = require('../../utils/navigation')
|
||||||
|
const permission = require('../../utils/permission')
|
||||||
|
const format = require('../../utils/format')
|
||||||
|
const { markDirty } = require('../../utils/page-state')
|
||||||
|
|
||||||
|
const STATUS_OPTIONS = [
|
||||||
|
{ label: '全部', value: '' },
|
||||||
|
{ label: '待处理', value: 'PENDING' },
|
||||||
|
{ label: '已同意', value: 'APPROVED' },
|
||||||
|
{ label: '已驳回', value: 'REJECTED' }
|
||||||
|
]
|
||||||
|
|
||||||
|
function safeList(response) {
|
||||||
|
if (Array.isArray(response && response.list)) {
|
||||||
|
return response.list
|
||||||
|
}
|
||||||
|
if (Array.isArray(response && response.records)) {
|
||||||
|
return response.records
|
||||||
|
}
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
function statusText(status) {
|
||||||
|
if (status === 'PENDING') {
|
||||||
|
return '待处理'
|
||||||
|
}
|
||||||
|
if (status === 'APPROVED') {
|
||||||
|
return '已同意'
|
||||||
|
}
|
||||||
|
if (status === 'REJECTED') {
|
||||||
|
return '已驳回'
|
||||||
|
}
|
||||||
|
return status || '--'
|
||||||
|
}
|
||||||
|
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
loading: false,
|
||||||
|
list: [],
|
||||||
|
total: 0,
|
||||||
|
status: 'PENDING',
|
||||||
|
statusOptions: STATUS_OPTIONS,
|
||||||
|
canAudit: false
|
||||||
|
},
|
||||||
|
|
||||||
|
onShow() {
|
||||||
|
if (!navigation.ensureLogin('进入售后处理')) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||||
|
this.setData({
|
||||||
|
canAudit: permission.hasPermission(permissionCodes, 'after_sale:audit')
|
||||||
|
})
|
||||||
|
this.loadAfterSales()
|
||||||
|
},
|
||||||
|
|
||||||
|
onPullDownRefresh() {
|
||||||
|
this.loadAfterSales().finally(() => {
|
||||||
|
wx.stopPullDownRefresh()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
async loadAfterSales() {
|
||||||
|
this.setData({ loading: true })
|
||||||
|
try {
|
||||||
|
const response = await afterSaleApi.listAfterSales({
|
||||||
|
page: 1,
|
||||||
|
size: 20,
|
||||||
|
status: this.data.status || undefined
|
||||||
|
})
|
||||||
|
this.setData({
|
||||||
|
list: safeList(response).map(item => this.formatAfterSale(item)),
|
||||||
|
total: Number(response && response.total) || 0
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
wx.showToast({
|
||||||
|
title: error.message || '售后加载失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
this.setData({ loading: false })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
formatAfterSale(item) {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
displayCreateTime: format.formatDateTime(item.createTime),
|
||||||
|
displayAuditTime: format.formatDateTime(item.auditTime),
|
||||||
|
displayRefundAmount: format.formatPrice(item.refundAmount),
|
||||||
|
statusText: statusText(item.status)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleStatusChange(event) {
|
||||||
|
this.setData({
|
||||||
|
status: event.currentTarget.dataset.status || ''
|
||||||
|
})
|
||||||
|
this.loadAfterSales()
|
||||||
|
},
|
||||||
|
|
||||||
|
promptReason(title) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
wx.showModal({
|
||||||
|
title,
|
||||||
|
content: '可填写处理说明,留空也可以提交。',
|
||||||
|
editable: true,
|
||||||
|
placeholderText: '处理说明',
|
||||||
|
confirmText: '提交',
|
||||||
|
success: result => {
|
||||||
|
if (!result.confirm) {
|
||||||
|
resolve(null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resolve(String(result.content || '').trim())
|
||||||
|
},
|
||||||
|
fail: () => resolve(null)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
async handleAudit(event) {
|
||||||
|
if (!this.data.canAudit) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '当前账号没有处理售后权限',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const id = event.currentTarget.dataset.id
|
||||||
|
const action = event.currentTarget.dataset.action
|
||||||
|
if (!id || !action) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const reason = await this.promptReason(action === 'approve' ? '同意售后' : '驳回售后')
|
||||||
|
if (reason === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const data = {
|
||||||
|
auditReason: reason
|
||||||
|
}
|
||||||
|
if (action === 'approve') {
|
||||||
|
await afterSaleApi.approveAfterSale(id, data)
|
||||||
|
} else {
|
||||||
|
await afterSaleApi.rejectAfterSale(id, data)
|
||||||
|
}
|
||||||
|
markDirty('admin-workbench')
|
||||||
|
wx.showToast({
|
||||||
|
title: '售后已处理',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
this.loadAfterSales()
|
||||||
|
} catch (error) {
|
||||||
|
wx.showToast({
|
||||||
|
title: error.message || '售后处理失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleBack() {
|
||||||
|
navigation.goBack('/pages/manage/index')
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {
|
||||||
|
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||||
|
},
|
||||||
|
"enablePullDownRefresh": true
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<navigation-bar title="售后处理" back="{{true}}" bindback="handleBack" color="#f6efe7" background="#081518"></navigation-bar>
|
||||||
|
|
||||||
|
<view class="page-shell">
|
||||||
|
<view class="page-stack">
|
||||||
|
<view class="hero-panel">
|
||||||
|
<text class="hero-kicker">After Sale</text>
|
||||||
|
<text class="hero-title">售后处理</text>
|
||||||
|
<text class="hero-desc">查看待处理退款/售后申请,在手机端完成同意或驳回的最小闭环。</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="surface-card">
|
||||||
|
<text class="section-title">状态筛选</text>
|
||||||
|
<view class="chip-row">
|
||||||
|
<block wx:for="{{statusOptions}}" wx:key="value">
|
||||||
|
<view class="chip-btn {{status === item.value ? 'active' : ''}}" data-status="{{item.value}}" bindtap="handleStatusChange">{{item.label}}</view>
|
||||||
|
</block>
|
||||||
|
</view>
|
||||||
|
<text class="section-desc">共 {{total}} 条记录</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<block wx:for="{{list}}" wx:key="id">
|
||||||
|
<view class="list-card">
|
||||||
|
<view class="list-head">
|
||||||
|
<view>
|
||||||
|
<text class="list-title">{{item.afterSaleNo || ('售后 #' + item.id)}}</text>
|
||||||
|
<text class="list-subtitle">订单 {{item.orderId || '--'}} · {{item.displayCreateTime || '--'}}</text>
|
||||||
|
</view>
|
||||||
|
<text class="{{item.status === 'PENDING' ? 'badge' : 'soft-badge'}}">{{item.statusText}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="meta-grid">
|
||||||
|
<view class="meta-item">
|
||||||
|
<text class="meta-label">类型</text>
|
||||||
|
<text class="meta-value">{{item.type || '--'}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="meta-item">
|
||||||
|
<text class="meta-label">退款金额</text>
|
||||||
|
<text class="meta-value">¥{{item.displayRefundAmount}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="meta-item">
|
||||||
|
<text class="meta-label">用户 ID</text>
|
||||||
|
<text class="meta-value">{{item.userId || '--'}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="meta-item">
|
||||||
|
<text class="meta-label">审核时间</text>
|
||||||
|
<text class="meta-value">{{item.displayAuditTime || '--'}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view wx:if="{{item.reason}}" class="hint-card">{{item.reason}}</view>
|
||||||
|
<view wx:if="{{item.auditReason}}" class="hint-card">处理说明:{{item.auditReason}}</view>
|
||||||
|
<view wx:if="{{item.status === 'PENDING'}}" class="list-actions">
|
||||||
|
<view class="mini-btn primary" data-id="{{item.id}}" data-action="approve" bindtap="handleAudit">同意</view>
|
||||||
|
<view class="mini-btn danger" data-id="{{item.id}}" data-action="reject" bindtap="handleAudit">驳回</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</block>
|
||||||
|
|
||||||
|
<view wx:if="{{!list.length && !loading}}" class="empty-state">
|
||||||
|
<text class="empty-title">暂无售后单</text>
|
||||||
|
<text class="empty-desc">当前状态下没有需要展示的售后记录。</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
.page-shell {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
const campaignApi = require('../../api/campaign')
|
||||||
|
const navigation = require('../../utils/navigation')
|
||||||
|
const permission = require('../../utils/permission')
|
||||||
|
const format = require('../../utils/format')
|
||||||
|
const { markDirty } = require('../../utils/page-state')
|
||||||
|
|
||||||
|
const STATUS_OPTIONS = [
|
||||||
|
{ label: '全部', value: '' },
|
||||||
|
{ label: '启用', value: '1' },
|
||||||
|
{ label: '停用', value: '0' }
|
||||||
|
]
|
||||||
|
|
||||||
|
function safeList(response) {
|
||||||
|
if (Array.isArray(response && response.list)) {
|
||||||
|
return response.list
|
||||||
|
}
|
||||||
|
if (Array.isArray(response && response.records)) {
|
||||||
|
return response.records
|
||||||
|
}
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
loading: false,
|
||||||
|
list: [],
|
||||||
|
total: 0,
|
||||||
|
status: '',
|
||||||
|
statusOptions: STATUS_OPTIONS,
|
||||||
|
canManage: false,
|
||||||
|
form: {
|
||||||
|
title: '',
|
||||||
|
scene: 'HOME',
|
||||||
|
description: '',
|
||||||
|
sortOrder: '0'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onShow() {
|
||||||
|
if (!navigation.ensureLogin('进入活动管理')) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||||
|
this.setData({
|
||||||
|
canManage: permission.hasPermission(permissionCodes, 'campaign:manage')
|
||||||
|
})
|
||||||
|
this.loadCampaigns()
|
||||||
|
},
|
||||||
|
|
||||||
|
onPullDownRefresh() {
|
||||||
|
this.loadCampaigns().finally(() => {
|
||||||
|
wx.stopPullDownRefresh()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
async loadCampaigns() {
|
||||||
|
this.setData({ loading: true })
|
||||||
|
try {
|
||||||
|
const response = await campaignApi.listCampaigns({
|
||||||
|
page: 1,
|
||||||
|
size: 20,
|
||||||
|
status: this.data.status === '' ? undefined : Number(this.data.status)
|
||||||
|
})
|
||||||
|
this.setData({
|
||||||
|
list: safeList(response).map(item => this.formatCampaign(item)),
|
||||||
|
total: Number(response && response.total) || 0
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
wx.showToast({
|
||||||
|
title: error.message || '活动加载失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
this.setData({ loading: false })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
formatCampaign(item) {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
statusText: Number(item.status) === 0 ? '停用' : '启用',
|
||||||
|
displayStartTime: format.formatDateTime(item.startTime),
|
||||||
|
displayEndTime: format.formatDateTime(item.endTime)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleStatusChange(event) {
|
||||||
|
this.setData({
|
||||||
|
status: event.currentTarget.dataset.status
|
||||||
|
})
|
||||||
|
this.loadCampaigns()
|
||||||
|
},
|
||||||
|
|
||||||
|
handleFormInput(event) {
|
||||||
|
const field = event.currentTarget.dataset.field
|
||||||
|
if (!field) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.setData({
|
||||||
|
[`form.${field}`]: event.detail.value
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
async handleSaveCampaign() {
|
||||||
|
if (!this.data.canManage) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '当前账号没有活动管理权限',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const form = this.data.form
|
||||||
|
const title = String(form.title || '').trim()
|
||||||
|
if (!title) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '请填写活动标题',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await campaignApi.saveCampaign({
|
||||||
|
title,
|
||||||
|
scene: String(form.scene || '').trim() || 'HOME',
|
||||||
|
description: String(form.description || '').trim(),
|
||||||
|
sortOrder: Number(form.sortOrder) || 0,
|
||||||
|
status: 1
|
||||||
|
})
|
||||||
|
markDirty('admin-workbench')
|
||||||
|
wx.showToast({
|
||||||
|
title: '活动已创建',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
this.setData({
|
||||||
|
form: {
|
||||||
|
title: '',
|
||||||
|
scene: 'HOME',
|
||||||
|
description: '',
|
||||||
|
sortOrder: '0'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.loadCampaigns()
|
||||||
|
} catch (error) {
|
||||||
|
wx.showToast({
|
||||||
|
title: error.message || '活动保存失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleBack() {
|
||||||
|
navigation.goBack('/pages/manage/index')
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {
|
||||||
|
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||||
|
},
|
||||||
|
"enablePullDownRefresh": true
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<navigation-bar title="活动管理" back="{{true}}" bindback="handleBack" color="#f6efe7" background="#081518"></navigation-bar>
|
||||||
|
|
||||||
|
<view class="page-shell">
|
||||||
|
<view class="page-stack">
|
||||||
|
<view class="hero-panel">
|
||||||
|
<text class="hero-kicker">Campaign</text>
|
||||||
|
<text class="hero-title">活动管理</text>
|
||||||
|
<text class="hero-desc">查看营销活动和推荐位配置,支持在手机端快速创建启用活动。</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view wx:if="{{canManage}}" class="surface-card">
|
||||||
|
<text class="section-title">快速创建</text>
|
||||||
|
<input class="field-input compact-field" placeholder="活动标题" placeholder-class="placeholder" value="{{form.title}}" data-field="title" bindinput="handleFormInput"></input>
|
||||||
|
<view class="form-grid">
|
||||||
|
<input class="field-input" placeholder="场景,如 HOME" placeholder-class="placeholder" value="{{form.scene}}" data-field="scene" bindinput="handleFormInput"></input>
|
||||||
|
<input class="field-input" type="number" placeholder="排序" placeholder-class="placeholder" value="{{form.sortOrder}}" data-field="sortOrder" bindinput="handleFormInput"></input>
|
||||||
|
</view>
|
||||||
|
<textarea class="field-textarea compact-textarea" placeholder="活动说明,可留空" placeholder-class="placeholder" value="{{form.description}}" data-field="description" bindinput="handleFormInput"></textarea>
|
||||||
|
<button class="primary-btn compact-btn" loading="{{loading}}" bindtap="handleSaveCampaign">创建活动</button>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="surface-card">
|
||||||
|
<text class="section-title">活动列表</text>
|
||||||
|
<view class="chip-row">
|
||||||
|
<block wx:for="{{statusOptions}}" wx:key="value">
|
||||||
|
<view class="chip-btn {{status === item.value ? 'active' : ''}}" data-status="{{item.value}}" bindtap="handleStatusChange">{{item.label}}</view>
|
||||||
|
</block>
|
||||||
|
</view>
|
||||||
|
<text class="section-desc">共 {{total}} 条活动</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<block wx:for="{{list}}" wx:key="id">
|
||||||
|
<view class="list-card">
|
||||||
|
<view class="list-head">
|
||||||
|
<view>
|
||||||
|
<text class="list-title">{{item.title}}</text>
|
||||||
|
<text class="list-subtitle">{{item.scene || '未设置场景'}} · 排序 {{item.sortOrder || 0}}</text>
|
||||||
|
</view>
|
||||||
|
<text class="{{item.status === 0 ? 'soft-badge' : 'success-badge'}}">{{item.statusText}}</text>
|
||||||
|
</view>
|
||||||
|
<view wx:if="{{item.description}}" class="hint-card">{{item.description}}</view>
|
||||||
|
<view class="meta-grid">
|
||||||
|
<view class="meta-item">
|
||||||
|
<text class="meta-label">开始</text>
|
||||||
|
<text class="meta-value">{{item.displayStartTime || '--'}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="meta-item">
|
||||||
|
<text class="meta-label">结束</text>
|
||||||
|
<text class="meta-value">{{item.displayEndTime || '--'}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</block>
|
||||||
|
|
||||||
|
<view wx:if="{{!list.length && !loading}}" class="empty-state">
|
||||||
|
<text class="empty-title">暂无活动</text>
|
||||||
|
<text class="empty-desc">当前筛选条件下没有营销活动。</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
.page-shell {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compact-field,
|
||||||
|
.compact-btn,
|
||||||
|
.compact-textarea {
|
||||||
|
margin-top: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 14rpx;
|
||||||
|
margin-top: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compact-textarea {
|
||||||
|
min-height: 140rpx;
|
||||||
|
}
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
const inventoryApi = require('../../api/inventory')
|
||||||
|
const navigation = require('../../utils/navigation')
|
||||||
|
const permission = require('../../utils/permission')
|
||||||
|
const format = require('../../utils/format')
|
||||||
|
const { markDirty } = require('../../utils/page-state')
|
||||||
|
|
||||||
|
function safeList(response) {
|
||||||
|
if (Array.isArray(response && response.list)) {
|
||||||
|
return response.list
|
||||||
|
}
|
||||||
|
if (Array.isArray(response && response.records)) {
|
||||||
|
return response.records
|
||||||
|
}
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
loading: false,
|
||||||
|
list: [],
|
||||||
|
total: 0,
|
||||||
|
canManage: false,
|
||||||
|
form: {
|
||||||
|
itemName: '',
|
||||||
|
category: '',
|
||||||
|
unit: '件',
|
||||||
|
stockQuantity: '0',
|
||||||
|
warningThreshold: '1'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onShow() {
|
||||||
|
if (!navigation.ensureLogin('进入库存管理')) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||||
|
this.setData({
|
||||||
|
canManage: permission.hasPermission(permissionCodes, 'inventory:manage')
|
||||||
|
})
|
||||||
|
this.loadItems()
|
||||||
|
},
|
||||||
|
|
||||||
|
onPullDownRefresh() {
|
||||||
|
this.loadItems().finally(() => {
|
||||||
|
wx.stopPullDownRefresh()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
async loadItems() {
|
||||||
|
this.setData({ loading: true })
|
||||||
|
try {
|
||||||
|
const response = await inventoryApi.listItems({
|
||||||
|
page: 1,
|
||||||
|
size: 30
|
||||||
|
})
|
||||||
|
this.setData({
|
||||||
|
list: safeList(response).map(item => this.formatItem(item)),
|
||||||
|
total: Number(response && response.total) || 0
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
wx.showToast({
|
||||||
|
title: error.message || '库存加载失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
this.setData({ loading: false })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
formatItem(item) {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
displayStock: format.formatPrice(item.stockQuantity),
|
||||||
|
displayWarning: format.formatPrice(item.warningThreshold),
|
||||||
|
statusText: Number(item.status) === 0 ? '停用' : '启用'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleFormInput(event) {
|
||||||
|
const field = event.currentTarget.dataset.field
|
||||||
|
if (!field) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.setData({
|
||||||
|
[`form.${field}`]: event.detail.value
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
async handleSaveItem() {
|
||||||
|
if (!this.data.canManage) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '当前账号没有库存维护权限',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const form = this.data.form
|
||||||
|
if (!String(form.itemName || '').trim()) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '请填写物料名称',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await inventoryApi.saveItem({
|
||||||
|
itemName: String(form.itemName || '').trim(),
|
||||||
|
category: String(form.category || '').trim(),
|
||||||
|
unit: String(form.unit || '').trim() || '件',
|
||||||
|
stockQuantity: Number(form.stockQuantity) || 0,
|
||||||
|
warningThreshold: Number(form.warningThreshold) || 0,
|
||||||
|
status: 1
|
||||||
|
})
|
||||||
|
markDirty('admin-workbench')
|
||||||
|
wx.showToast({
|
||||||
|
title: '物料已保存',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
this.setData({
|
||||||
|
form: {
|
||||||
|
itemName: '',
|
||||||
|
category: '',
|
||||||
|
unit: '件',
|
||||||
|
stockQuantity: '0',
|
||||||
|
warningThreshold: '1'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.loadItems()
|
||||||
|
} catch (error) {
|
||||||
|
wx.showToast({
|
||||||
|
title: error.message || '物料保存失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
promptAdjust(item) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
wx.showModal({
|
||||||
|
title: `调整 ${item.itemName}`,
|
||||||
|
content: '填写正数入库,负数出库。',
|
||||||
|
editable: true,
|
||||||
|
placeholderText: '例如 5 或 -2',
|
||||||
|
confirmText: '调整',
|
||||||
|
success: result => {
|
||||||
|
if (!result.confirm) {
|
||||||
|
resolve(null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resolve(String(result.content || '').trim())
|
||||||
|
},
|
||||||
|
fail: () => resolve(null)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
async handleAdjust(event) {
|
||||||
|
if (!this.data.canManage) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '当前账号没有库存调整权限',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const item = event.currentTarget.dataset.item
|
||||||
|
if (!item) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const value = await this.promptAdjust(item)
|
||||||
|
if (value === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const quantity = Number(value)
|
||||||
|
if (!isFinite(quantity) || quantity === 0) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '请输入非 0 数量',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await inventoryApi.adjustStock(item.id, {
|
||||||
|
changeType: quantity > 0 ? 'IN' : 'OUT',
|
||||||
|
changeQuantity: quantity,
|
||||||
|
remark: '管理端小程序调整'
|
||||||
|
})
|
||||||
|
markDirty('admin-workbench')
|
||||||
|
wx.showToast({
|
||||||
|
title: '库存已调整',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
this.loadItems()
|
||||||
|
} catch (error) {
|
||||||
|
wx.showToast({
|
||||||
|
title: error.message || '库存调整失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleBack() {
|
||||||
|
navigation.goBack('/pages/manage/index')
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {
|
||||||
|
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||||
|
},
|
||||||
|
"enablePullDownRefresh": true
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<navigation-bar title="库存管理" back="{{true}}" bindback="handleBack" color="#f6efe7" background="#081518"></navigation-bar>
|
||||||
|
|
||||||
|
<view class="page-shell">
|
||||||
|
<view class="page-stack">
|
||||||
|
<view class="hero-panel">
|
||||||
|
<text class="hero-kicker">Inventory</text>
|
||||||
|
<text class="hero-title">耗材库存</text>
|
||||||
|
<text class="hero-desc">查看库存和预警项,支持手机端快速新增物料与正负数调整库存。</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view wx:if="{{canManage}}" class="surface-card">
|
||||||
|
<text class="section-title">新增物料</text>
|
||||||
|
<view class="form-grid">
|
||||||
|
<input class="field-input" placeholder="物料名称" placeholder-class="placeholder" value="{{form.itemName}}" data-field="itemName" bindinput="handleFormInput"></input>
|
||||||
|
<input class="field-input" placeholder="分类" placeholder-class="placeholder" value="{{form.category}}" data-field="category" bindinput="handleFormInput"></input>
|
||||||
|
<input class="field-input" placeholder="单位" placeholder-class="placeholder" value="{{form.unit}}" data-field="unit" bindinput="handleFormInput"></input>
|
||||||
|
<input class="field-input" type="digit" placeholder="初始库存" placeholder-class="placeholder" value="{{form.stockQuantity}}" data-field="stockQuantity" bindinput="handleFormInput"></input>
|
||||||
|
<input class="field-input" type="digit" placeholder="预警阈值" placeholder-class="placeholder" value="{{form.warningThreshold}}" data-field="warningThreshold" bindinput="handleFormInput"></input>
|
||||||
|
</view>
|
||||||
|
<button class="primary-btn compact-btn" loading="{{loading}}" bindtap="handleSaveItem">保存物料</button>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="surface-card">
|
||||||
|
<text class="section-title">库存列表</text>
|
||||||
|
<text class="section-desc">共 {{total}} 个物料,低于阈值会标记为预警。</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<block wx:for="{{list}}" wx:key="id">
|
||||||
|
<view class="list-card">
|
||||||
|
<view class="list-head">
|
||||||
|
<view>
|
||||||
|
<text class="list-title">{{item.itemName}}</text>
|
||||||
|
<text class="list-subtitle">{{item.category || '未分类'}} · {{item.statusText}}</text>
|
||||||
|
</view>
|
||||||
|
<text class="{{item.warning ? 'danger-badge' : 'success-badge'}}">{{item.warning ? '库存预警' : '正常'}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="meta-grid">
|
||||||
|
<view class="meta-item">
|
||||||
|
<text class="meta-label">当前库存</text>
|
||||||
|
<text class="meta-value">{{item.displayStock}} {{item.unit || ''}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="meta-item">
|
||||||
|
<text class="meta-label">预警阈值</text>
|
||||||
|
<text class="meta-value">{{item.displayWarning}} {{item.unit || ''}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view wx:if="{{canManage}}" class="list-actions">
|
||||||
|
<view class="mini-btn primary" data-item="{{item}}" bindtap="handleAdjust">调整库存</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</block>
|
||||||
|
|
||||||
|
<view wx:if="{{!list.length && !loading}}" class="empty-state">
|
||||||
|
<text class="empty-title">暂无库存物料</text>
|
||||||
|
<text class="empty-desc">当前店铺还没有录入耗材库存。</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
.page-shell {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 14rpx;
|
||||||
|
margin-top: 18rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compact-btn {
|
||||||
|
margin-top: 18rpx;
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
* Usage: call getOrderDetail with the current route id before displaying the order detail page.
|
* Usage: call getOrderDetail with the current route id before displaying the order detail page.
|
||||||
*/
|
*/
|
||||||
const orderApi = require('../../api/order')
|
const orderApi = require('../../api/order')
|
||||||
|
const paymentApi = require('../../api/payment')
|
||||||
|
const permission = require('../../utils/permission')
|
||||||
/**
|
/**
|
||||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -14,6 +16,20 @@ const navigation = require('../../utils/navigation')
|
|||||||
*/
|
*/
|
||||||
const format = require('../../utils/format')
|
const format = require('../../utils/format')
|
||||||
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||||
|
const { markDirty } = require('../../utils/page-state')
|
||||||
|
|
||||||
|
function getPaymentStatusText(status) {
|
||||||
|
if (status === 'PAID') {
|
||||||
|
return '已支付'
|
||||||
|
}
|
||||||
|
if (status === 'PAYING') {
|
||||||
|
return '支付中'
|
||||||
|
}
|
||||||
|
if (status === 'REFUNDED') {
|
||||||
|
return '已退款'
|
||||||
|
}
|
||||||
|
return '未支付'
|
||||||
|
}
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
/**
|
/**
|
||||||
@@ -35,7 +51,8 @@ Page({
|
|||||||
* Purpose: order supports index.js by holding or executing the order page or API role.
|
* Purpose: order supports index.js by holding or executing the order page or API role.
|
||||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
*/
|
*/
|
||||||
order: null
|
order: null,
|
||||||
|
canManualConfirmPay: false
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,11 +60,13 @@ Page({
|
|||||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
*/
|
*/
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||||
const cachedOrder = getTempRecord('currentOrder', null)
|
const cachedOrder = getTempRecord('currentOrder', null)
|
||||||
const orderId = (options && options.id) || (cachedOrder && cachedOrder.id) || ''
|
const orderId = (options && options.id) || (cachedOrder && cachedOrder.id) || ''
|
||||||
this.setData({
|
this.setData({
|
||||||
orderId,
|
orderId,
|
||||||
order: cachedOrder ? this.formatOrder(cachedOrder) : null
|
order: cachedOrder ? this.formatOrder(cachedOrder) : null,
|
||||||
|
canManualConfirmPay: permission.hasPermission(permissionCodes, 'payment:manage')
|
||||||
})
|
})
|
||||||
|
|
||||||
if (orderId) {
|
if (orderId) {
|
||||||
@@ -82,11 +101,16 @@ Page({
|
|||||||
*/
|
*/
|
||||||
formatOrder(order) {
|
formatOrder(order) {
|
||||||
const items = Array.isArray(order && order.items) ? order.items : []
|
const items = Array.isArray(order && order.items) ? order.items : []
|
||||||
|
const paymentStatus = order && order.paymentStatus ? order.paymentStatus : 'UNPAID'
|
||||||
return order ? {
|
return order ? {
|
||||||
...order,
|
...order,
|
||||||
displayStatusText: format.getOrderStatusText(order),
|
displayStatusText: format.getOrderStatusText(order),
|
||||||
|
displayPaymentStatusText: getPaymentStatusText(paymentStatus),
|
||||||
displayCreateTime: format.formatDateTime(order.createTime),
|
displayCreateTime: format.formatDateTime(order.createTime),
|
||||||
displayPayAmount: format.formatPrice(order.payAmount),
|
displayPayAmount: format.formatPrice(order.payAmount || order.actualAmount),
|
||||||
|
displayPaidAmount: format.formatPrice(order.paidAmount),
|
||||||
|
displayPayTime: format.formatDateTime(order.payTime),
|
||||||
|
canManualConfirmPay: paymentStatus !== 'PAID' && paymentStatus !== 'REFUNDED',
|
||||||
items: items.map(item => ({
|
items: items.map(item => ({
|
||||||
...item,
|
...item,
|
||||||
displayAppointmentTime: item.appointmentTime ? format.formatDateTime(item.appointmentTime) : '',
|
displayAppointmentTime: item.appointmentTime ? format.formatDateTime(item.appointmentTime) : '',
|
||||||
@@ -108,6 +132,55 @@ Page({
|
|||||||
this.loadOrderDetail(this.data.orderId)
|
this.loadOrderDetail(this.data.orderId)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async handleManualConfirmPay() {
|
||||||
|
if (!this.data.canManualConfirmPay) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '当前账号没有确认支付权限',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const order = this.data.order
|
||||||
|
if (!order) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const remark = await new Promise(resolve => {
|
||||||
|
wx.showModal({
|
||||||
|
title: '手动确认支付',
|
||||||
|
content: `确认将订单 ${order.orderNo || order.id} 标记为已支付?`,
|
||||||
|
editable: true,
|
||||||
|
placeholderText: '备注,可留空',
|
||||||
|
confirmText: '确认',
|
||||||
|
success: result => {
|
||||||
|
if (!result.confirm) {
|
||||||
|
resolve(null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resolve(String(result.content || '').trim())
|
||||||
|
},
|
||||||
|
fail: () => resolve(null)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
if (remark === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await paymentApi.manualConfirmOrder(order.id, remark)
|
||||||
|
markDirty('admin-orders')
|
||||||
|
markDirty('admin-workbench')
|
||||||
|
wx.showToast({
|
||||||
|
title: '支付已确认',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
this.loadOrderDetail(order.id)
|
||||||
|
} catch (error) {
|
||||||
|
wx.showToast({
|
||||||
|
title: error.message || '确认支付失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: onUnload supports index.js by holding or executing the on unload page or API role.
|
* Purpose: onUnload supports index.js by holding or executing the on unload page or API role.
|
||||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
|
|||||||
@@ -26,11 +26,26 @@
|
|||||||
<text class="meta-label">应付金额</text>
|
<text class="meta-label">应付金额</text>
|
||||||
<text class="meta-value">¥{{order.displayPayAmount || '--'}}</text>
|
<text class="meta-value">¥{{order.displayPayAmount || '--'}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="meta-item">
|
||||||
|
<text class="meta-label">支付状态</text>
|
||||||
|
<text class="meta-value">{{order.displayPaymentStatusText}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="meta-item">
|
||||||
|
<text class="meta-label">已付金额</text>
|
||||||
|
<text class="meta-value">¥{{order.displayPaidAmount}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="meta-item">
|
||||||
|
<text class="meta-label">支付时间</text>
|
||||||
|
<text class="meta-value">{{order.displayPayTime || '--'}}</text>
|
||||||
|
</view>
|
||||||
<view class="meta-item">
|
<view class="meta-item">
|
||||||
<text class="meta-label">备注</text>
|
<text class="meta-label">备注</text>
|
||||||
<text class="meta-value">{{order.remark || '暂无备注'}}</text>
|
<text class="meta-value">{{order.remark || '暂无备注'}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view wx:if="{{canManualConfirmPay && order.canManualConfirmPay}}" class="action-row">
|
||||||
|
<button class="primary-btn" loading="{{loading}}" bindtap="handleManualConfirmPay">手动确认支付</button>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view wx:if="{{order && order.items && order.items.length}}" class="surface-card">
|
<view wx:if="{{order && order.items && order.items.length}}" class="surface-card">
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
*/
|
*/
|
||||||
const orderApi = require('../../api/order')
|
const orderApi = require('../../api/order')
|
||||||
|
const paymentApi = require('../../api/payment')
|
||||||
/**
|
/**
|
||||||
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
||||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -78,6 +79,19 @@ function formatRating(value) {
|
|||||||
return rating % 1 === 0 ? String(rating) : rating.toFixed(1)
|
return rating % 1 === 0 ? String(rating) : rating.toFixed(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPaymentStatusText(status) {
|
||||||
|
if (status === 'PAID') {
|
||||||
|
return '已支付'
|
||||||
|
}
|
||||||
|
if (status === 'PAYING') {
|
||||||
|
return '支付中'
|
||||||
|
}
|
||||||
|
if (status === 'REFUNDED') {
|
||||||
|
return '已退款'
|
||||||
|
}
|
||||||
|
return '未支付'
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: isSubmittedReview supports index.js by holding or executing the is submitted review page or API role.
|
* Purpose: isSubmittedReview supports index.js by holding or executing the is submitted review page or API role.
|
||||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -261,11 +275,15 @@ function formatOrderItem(order, item, userInfo, assistData) {
|
|||||||
function formatOrder(order, userInfo, assistData) {
|
function formatOrder(order, userInfo, assistData) {
|
||||||
const items = safeList(order.items).map(item => formatOrderItem(order, item, userInfo, assistData))
|
const items = safeList(order.items).map(item => formatOrderItem(order, item, userInfo, assistData))
|
||||||
const orderReviewSummary = buildReviewSummary(order.reviewSummary)
|
const orderReviewSummary = buildReviewSummary(order.reviewSummary)
|
||||||
|
const paymentStatus = order.paymentStatus || 'UNPAID'
|
||||||
return {
|
return {
|
||||||
...order,
|
...order,
|
||||||
displayStatusText: format.getOrderStatusText(order),
|
displayStatusText: format.getOrderStatusText(order),
|
||||||
|
displayPaymentStatusText: getPaymentStatusText(paymentStatus),
|
||||||
displayCreateTime: format.formatDateTime(order.createTime),
|
displayCreateTime: format.formatDateTime(order.createTime),
|
||||||
displayPayAmount: format.formatPrice(order.payAmount || order.actualAmount),
|
displayPayAmount: format.formatPrice(order.payAmount || order.actualAmount),
|
||||||
|
displayPaidAmount: format.formatPrice(order.paidAmount),
|
||||||
|
canManualConfirmPay: paymentStatus !== 'PAID' && paymentStatus !== 'REFUNDED',
|
||||||
items,
|
items,
|
||||||
reviewSummary: orderReviewSummary,
|
reviewSummary: orderReviewSummary,
|
||||||
reviewStatusText: orderReviewSummary ? orderReviewSummary.displayText : ''
|
reviewStatusText: orderReviewSummary ? orderReviewSummary.displayText : ''
|
||||||
@@ -351,6 +369,7 @@ Page({
|
|||||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
*/
|
*/
|
||||||
userInfo: null,
|
userInfo: null,
|
||||||
|
canManualConfirmPay: false,
|
||||||
/**
|
/**
|
||||||
* Purpose: initialized supports index.js by holding or executing the initialized page or API role.
|
* Purpose: initialized supports index.js by holding or executing the initialized page or API role.
|
||||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -368,8 +387,10 @@ Page({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const userInfo = getApp().globalData.userInfo
|
const userInfo = getApp().globalData.userInfo
|
||||||
|
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||||
this.setData({
|
this.setData({
|
||||||
userInfo
|
userInfo,
|
||||||
|
canManualConfirmPay: permission.hasPermission(permissionCodes, 'payment:manage')
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!this.data.initialized || consumeDirty('admin-orders')) {
|
if (!this.data.initialized || consumeDirty('admin-orders')) {
|
||||||
@@ -377,6 +398,54 @@ Page({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async handleManualConfirmPay(event) {
|
||||||
|
if (!this.data.canManualConfirmPay) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '当前账号没有确认支付权限',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const order = event.currentTarget.dataset.order
|
||||||
|
if (!order) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const confirmed = await new Promise(resolve => {
|
||||||
|
wx.showModal({
|
||||||
|
title: '手动确认支付',
|
||||||
|
content: `确认将订单 ${order.orderNo || order.id} 标记为已支付?`,
|
||||||
|
editable: true,
|
||||||
|
placeholderText: '备注,可留空',
|
||||||
|
confirmText: '确认',
|
||||||
|
success: result => {
|
||||||
|
if (!result.confirm) {
|
||||||
|
resolve(null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resolve(String(result.content || '').trim())
|
||||||
|
},
|
||||||
|
fail: () => resolve(null)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
if (confirmed === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await paymentApi.manualConfirmOrder(order.id, confirmed)
|
||||||
|
markDirty('admin-workbench')
|
||||||
|
wx.showToast({
|
||||||
|
title: '支付已确认',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
this.loadOrders()
|
||||||
|
} catch (error) {
|
||||||
|
wx.showToast({
|
||||||
|
title: error.message || '确认支付失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: onPullDownRefresh supports index.js by holding or executing the on pull down refresh page or API role.
|
* Purpose: onPullDownRefresh supports index.js by holding or executing the on pull down refresh page or API role.
|
||||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
|
|||||||
@@ -35,6 +35,10 @@
|
|||||||
<text class="meta-label">订单金额</text>
|
<text class="meta-label">订单金额</text>
|
||||||
<text class="meta-value">¥{{item.displayPayAmount}}</text>
|
<text class="meta-value">¥{{item.displayPayAmount}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="meta-item">
|
||||||
|
<text class="meta-label">支付状态</text>
|
||||||
|
<text class="meta-value">{{item.displayPaymentStatusText}}</text>
|
||||||
|
</view>
|
||||||
<view class="meta-item">
|
<view class="meta-item">
|
||||||
<text class="meta-label">所属门店</text>
|
<text class="meta-label">所属门店</text>
|
||||||
<text class="meta-value">{{item.shopName || '--'}}</text>
|
<text class="meta-value">{{item.shopName || '--'}}</text>
|
||||||
@@ -71,6 +75,7 @@
|
|||||||
|
|
||||||
<view class="list-actions">
|
<view class="list-actions">
|
||||||
<view class="mini-btn" data-order="{{item}}" bindtap="handleOpenOrder">查看详情</view>
|
<view class="mini-btn" data-order="{{item}}" bindtap="handleOpenOrder">查看详情</view>
|
||||||
|
<view wx:if="{{canManualConfirmPay && item.canManualConfirmPay}}" class="mini-btn primary" data-order="{{item}}" bindtap="handleManualConfirmPay">确认支付</view>
|
||||||
<view wx:if="{{item.status !== 2}}" class="mini-btn primary" data-order="{{item}}" bindtap="handleProcessOrder">处理订单</view>
|
<view wx:if="{{item.status !== 2}}" class="mini-btn primary" data-order="{{item}}" bindtap="handleProcessOrder">处理订单</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -0,0 +1,187 @@
|
|||||||
|
const scheduleApi = require('../../api/artist-schedule')
|
||||||
|
const navigation = require('../../utils/navigation')
|
||||||
|
const permission = require('../../utils/permission')
|
||||||
|
const format = require('../../utils/format')
|
||||||
|
const { markDirty } = require('../../utils/page-state')
|
||||||
|
|
||||||
|
function todayText(offset) {
|
||||||
|
const date = new Date()
|
||||||
|
date.setDate(date.getDate() + (offset || 0))
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||||
|
const day = String(date.getDate()).padStart(2, '0')
|
||||||
|
return `${date.getFullYear()}-${month}-${day}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function safeList(value) {
|
||||||
|
return Array.isArray(value) ? value : []
|
||||||
|
}
|
||||||
|
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
loading: false,
|
||||||
|
list: [],
|
||||||
|
startDate: todayText(0),
|
||||||
|
endDate: todayText(6),
|
||||||
|
artistId: '',
|
||||||
|
canEdit: false,
|
||||||
|
form: {
|
||||||
|
artistId: '',
|
||||||
|
workDate: todayText(0),
|
||||||
|
startTime: '10:00',
|
||||||
|
endTime: '18:00',
|
||||||
|
slotMinutes: '60',
|
||||||
|
capacity: '1',
|
||||||
|
remark: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onShow() {
|
||||||
|
if (!navigation.ensureLogin('进入排班管理')) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||||
|
this.setData({
|
||||||
|
canEdit: permission.hasPermission(permissionCodes, 'schedule:edit')
|
||||||
|
})
|
||||||
|
this.loadSchedules()
|
||||||
|
},
|
||||||
|
|
||||||
|
onPullDownRefresh() {
|
||||||
|
this.loadSchedules().finally(() => {
|
||||||
|
wx.stopPullDownRefresh()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
buildQuery() {
|
||||||
|
const query = {}
|
||||||
|
;['artistId', 'startDate', 'endDate'].forEach(key => {
|
||||||
|
const value = String(this.data[key] || '').trim()
|
||||||
|
if (value) {
|
||||||
|
query[key] = value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return query
|
||||||
|
},
|
||||||
|
|
||||||
|
async loadSchedules() {
|
||||||
|
this.setData({ loading: true })
|
||||||
|
try {
|
||||||
|
const list = await scheduleApi.listSchedules(this.buildQuery())
|
||||||
|
this.setData({
|
||||||
|
list: safeList(list).map(item => this.formatSchedule(item))
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
wx.showToast({
|
||||||
|
title: error.message || '排班加载失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
this.setData({ loading: false })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
formatSchedule(item) {
|
||||||
|
const startTime = String(item.startTime || '').slice(0, 5)
|
||||||
|
const endTime = String(item.endTime || '').slice(0, 5)
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
displayDate: format.formatDate(item.workDate),
|
||||||
|
displayTime: `${startTime || '--'} - ${endTime || '--'}`,
|
||||||
|
statusText: Number(item.status) === 0 ? '停用' : '可预约'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleArtistInput(event) {
|
||||||
|
this.setData({ artistId: event.detail.value })
|
||||||
|
},
|
||||||
|
|
||||||
|
handleStartDateChange(event) {
|
||||||
|
this.setData({ startDate: event.detail.value })
|
||||||
|
this.loadSchedules()
|
||||||
|
},
|
||||||
|
|
||||||
|
handleEndDateChange(event) {
|
||||||
|
this.setData({ endDate: event.detail.value })
|
||||||
|
this.loadSchedules()
|
||||||
|
},
|
||||||
|
|
||||||
|
handleSearch() {
|
||||||
|
this.loadSchedules()
|
||||||
|
},
|
||||||
|
|
||||||
|
handleFormInput(event) {
|
||||||
|
const field = event.currentTarget.dataset.field
|
||||||
|
if (!field) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.setData({
|
||||||
|
[`form.${field}`]: event.detail.value
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
handleFormDateChange(event) {
|
||||||
|
this.setData({
|
||||||
|
'form.workDate': event.detail.value
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
handleFormStartTimeChange(event) {
|
||||||
|
this.setData({
|
||||||
|
'form.startTime': event.detail.value
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
handleFormEndTimeChange(event) {
|
||||||
|
this.setData({
|
||||||
|
'form.endTime': event.detail.value
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
async handleSaveSchedule() {
|
||||||
|
if (!this.data.canEdit) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '当前账号没有编辑排班权限',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const form = this.data.form
|
||||||
|
const artistId = String(form.artistId || '').trim()
|
||||||
|
if (!artistId) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '请填写美甲师 ID',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await scheduleApi.saveSchedule({
|
||||||
|
artistId,
|
||||||
|
workDate: form.workDate,
|
||||||
|
startTime: form.startTime,
|
||||||
|
endTime: form.endTime,
|
||||||
|
slotMinutes: Number(form.slotMinutes) || 60,
|
||||||
|
capacity: Number(form.capacity) || 1,
|
||||||
|
status: 1,
|
||||||
|
remark: String(form.remark || '').trim()
|
||||||
|
})
|
||||||
|
markDirty('admin-workbench')
|
||||||
|
wx.showToast({
|
||||||
|
title: '排班已保存',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
this.loadSchedules()
|
||||||
|
} catch (error) {
|
||||||
|
wx.showToast({
|
||||||
|
title: error.message || '排班保存失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleBack() {
|
||||||
|
navigation.goBack('/pages/manage/index')
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {
|
||||||
|
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||||
|
},
|
||||||
|
"enablePullDownRefresh": true
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<navigation-bar title="排班管理" back="{{true}}" bindback="handleBack" color="#f6efe7" background="#081518"></navigation-bar>
|
||||||
|
|
||||||
|
<view class="page-shell">
|
||||||
|
<view class="page-stack">
|
||||||
|
<view class="hero-panel">
|
||||||
|
<text class="hero-kicker">Schedule</text>
|
||||||
|
<text class="hero-title">门店排班</text>
|
||||||
|
<text class="hero-desc">按日期和美甲师查看可约班次,支持店长和管理员快速补录当天班次。</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="surface-card">
|
||||||
|
<text class="section-title">筛选</text>
|
||||||
|
<input class="field-input compact-field" placeholder="美甲师 ID,可留空" placeholder-class="placeholder" value="{{artistId}}" bindinput="handleArtistInput" confirm-type="search" bindconfirm="handleSearch"></input>
|
||||||
|
<view class="filter-row">
|
||||||
|
<picker mode="date" value="{{startDate}}" bindchange="handleStartDateChange">
|
||||||
|
<view class="field-picker">{{startDate || '开始日期'}}</view>
|
||||||
|
</picker>
|
||||||
|
<picker mode="date" value="{{endDate}}" bindchange="handleEndDateChange">
|
||||||
|
<view class="field-picker">{{endDate || '结束日期'}}</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
<button class="secondary-btn compact-btn" loading="{{loading}}" bindtap="handleSearch">查询排班</button>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view wx:if="{{canEdit}}" class="surface-card">
|
||||||
|
<text class="section-title">快速补班</text>
|
||||||
|
<view class="form-grid">
|
||||||
|
<input class="field-input" placeholder="美甲师 ID" placeholder-class="placeholder" value="{{form.artistId}}" data-field="artistId" bindinput="handleFormInput"></input>
|
||||||
|
<picker mode="date" value="{{form.workDate}}" bindchange="handleFormDateChange">
|
||||||
|
<view class="field-picker">{{form.workDate}}</view>
|
||||||
|
</picker>
|
||||||
|
<picker mode="time" value="{{form.startTime}}" bindchange="handleFormStartTimeChange">
|
||||||
|
<view class="field-picker">{{form.startTime}}</view>
|
||||||
|
</picker>
|
||||||
|
<picker mode="time" value="{{form.endTime}}" bindchange="handleFormEndTimeChange">
|
||||||
|
<view class="field-picker">{{form.endTime}}</view>
|
||||||
|
</picker>
|
||||||
|
<input class="field-input" type="number" placeholder="时段分钟" placeholder-class="placeholder" value="{{form.slotMinutes}}" data-field="slotMinutes" bindinput="handleFormInput"></input>
|
||||||
|
<input class="field-input" type="number" placeholder="容量" placeholder-class="placeholder" value="{{form.capacity}}" data-field="capacity" bindinput="handleFormInput"></input>
|
||||||
|
</view>
|
||||||
|
<textarea class="field-textarea compact-textarea" placeholder="备注,可留空" placeholder-class="placeholder" value="{{form.remark}}" data-field="remark" bindinput="handleFormInput"></textarea>
|
||||||
|
<button class="primary-btn compact-btn" loading="{{loading}}" bindtap="handleSaveSchedule">保存排班</button>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<block wx:for="{{list}}" wx:key="id">
|
||||||
|
<view class="list-card">
|
||||||
|
<view class="list-head">
|
||||||
|
<view>
|
||||||
|
<text class="list-title">{{item.displayDate}} · 美甲师 {{item.artistId}}</text>
|
||||||
|
<text class="list-subtitle">{{item.displayTime}} · {{item.slotMinutes || 60}} 分钟/档 · 容量 {{item.capacity || 1}}</text>
|
||||||
|
</view>
|
||||||
|
<text class="{{item.status === 0 ? 'soft-badge' : 'success-badge'}}">{{item.statusText}}</text>
|
||||||
|
</view>
|
||||||
|
<view wx:if="{{item.remark}}" class="hint-card">{{item.remark}}</view>
|
||||||
|
</view>
|
||||||
|
</block>
|
||||||
|
|
||||||
|
<view wx:if="{{!list.length && !loading}}" class="empty-state">
|
||||||
|
<text class="empty-title">暂无排班</text>
|
||||||
|
<text class="empty-desc">当前日期范围没有可展示班次。</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
.page-shell {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compact-field,
|
||||||
|
.compact-btn,
|
||||||
|
.compact-textarea {
|
||||||
|
margin-top: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-row picker,
|
||||||
|
.form-grid picker {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 14rpx;
|
||||||
|
margin-top: 18rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compact-textarea {
|
||||||
|
min-height: 140rpx;
|
||||||
|
}
|
||||||
@@ -26,6 +26,10 @@ const cache = require('../../utils/cache')
|
|||||||
const { CACHE_TTL } = require('../../utils/config')
|
const { CACHE_TTL } = require('../../utils/config')
|
||||||
const { consumeDirty } = require('../../utils/page-state')
|
const { consumeDirty } = require('../../utils/page-state')
|
||||||
|
|
||||||
|
function formatMoney(value) {
|
||||||
|
return Number(value || 0).toFixed(2)
|
||||||
|
}
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
/**
|
/**
|
||||||
* Purpose: data supports index.js by holding or executing the data page or API role.
|
* Purpose: data supports index.js by holding or executing the data page or API role.
|
||||||
@@ -62,6 +66,16 @@ Page({
|
|||||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
*/
|
*/
|
||||||
pendingOrders: 0,
|
pendingOrders: 0,
|
||||||
|
/**
|
||||||
|
* Purpose: analytics stores vNext operations analytics for the mobile workbench summary.
|
||||||
|
* Usage: set from dashboard analytics when the current user has analytics:view.
|
||||||
|
*/
|
||||||
|
analytics: null,
|
||||||
|
/**
|
||||||
|
* Purpose: todoStats stores lightweight operations todo counters for the workbench.
|
||||||
|
* Usage: show pending order and vNext operations counts without blocking the base dashboard.
|
||||||
|
*/
|
||||||
|
todoStats: [],
|
||||||
/**
|
/**
|
||||||
* Purpose: shoplessAdmin supports index.js by holding or executing the shopless admin page or API role.
|
* Purpose: shoplessAdmin supports index.js by holding or executing the shopless admin page or API role.
|
||||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -142,6 +156,7 @@ Page({
|
|||||||
const currentShopId = this.data.currentShop && this.data.currentShop.id ? String(this.data.currentShop.id) : 'none'
|
const currentShopId = this.data.currentShop && this.data.currentShop.id ? String(this.data.currentShop.id) : 'none'
|
||||||
const statsCacheKey = `workbench:stats:${currentShopId}`
|
const statsCacheKey = `workbench:stats:${currentShopId}`
|
||||||
const pendingCacheKey = `workbench:pending:${currentShopId}`
|
const pendingCacheKey = `workbench:pending:${currentShopId}`
|
||||||
|
const analyticsCacheKey = `workbench:analytics:${currentShopId}`
|
||||||
|
|
||||||
this.setData({
|
this.setData({
|
||||||
/**
|
/**
|
||||||
@@ -159,6 +174,8 @@ Page({
|
|||||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
*/
|
*/
|
||||||
stats: null,
|
stats: null,
|
||||||
|
analytics: null,
|
||||||
|
todoStats: [],
|
||||||
/**
|
/**
|
||||||
* Purpose: pendingOrders supports index.js by holding or executing the pending orders page or API role.
|
* Purpose: pendingOrders supports index.js by holding or executing the pending orders page or API role.
|
||||||
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
@@ -208,10 +225,31 @@ Page({
|
|||||||
*/
|
*/
|
||||||
initialized: true
|
initialized: true
|
||||||
})
|
})
|
||||||
return
|
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.loadOperationsSummary({
|
||||||
|
requestId,
|
||||||
|
force,
|
||||||
|
permissionCodes,
|
||||||
|
analyticsCacheKey,
|
||||||
|
pendingCacheKey
|
||||||
|
})
|
||||||
|
if (requestId !== this._loadRequestId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.data.initialized) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.data.analytics || this.data.todoStats.length) {
|
||||||
|
this.setData({
|
||||||
|
loading: false,
|
||||||
|
initialized: true
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (permission.hasPermission(permissionCodes, 'order:view')) {
|
if (permission.hasPermission(permissionCodes, 'order:view')) {
|
||||||
try {
|
try {
|
||||||
if (force) {
|
if (force) {
|
||||||
@@ -332,6 +370,100 @@ Page({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async loadOperationsSummary(options) {
|
||||||
|
const requestId = options.requestId
|
||||||
|
const force = options.force
|
||||||
|
const permissionCodes = options.permissionCodes || []
|
||||||
|
const analyticsCacheKey = options.analyticsCacheKey
|
||||||
|
const pendingCacheKey = options.pendingCacheKey
|
||||||
|
const tasks = []
|
||||||
|
|
||||||
|
if (permission.hasPermission(permissionCodes, 'analytics:view')) {
|
||||||
|
if (force) {
|
||||||
|
cache.removeCache(analyticsCacheKey)
|
||||||
|
}
|
||||||
|
tasks.push(cache.remember(analyticsCacheKey, CACHE_TTL.workbench, () => dashboardApi.getAnalytics())
|
||||||
|
.then(analytics => ({ key: 'analytics', value: analytics }))
|
||||||
|
.catch(() => ({ key: 'analytics', value: null })))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (permission.hasPermission(permissionCodes, 'order:view')) {
|
||||||
|
if (force) {
|
||||||
|
cache.removeCache(pendingCacheKey)
|
||||||
|
}
|
||||||
|
tasks.push(cache.remember(pendingCacheKey, CACHE_TTL.workbench, () => orderApi.listOrders({
|
||||||
|
page: 1,
|
||||||
|
size: 1,
|
||||||
|
status: 1
|
||||||
|
})).then(result => ({
|
||||||
|
key: 'pendingOrders',
|
||||||
|
value: Number(result && result.total) || 0
|
||||||
|
})).catch(() => ({
|
||||||
|
key: 'pendingOrders',
|
||||||
|
value: 0
|
||||||
|
})))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tasks.length) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const results = await Promise.all(tasks)
|
||||||
|
if (requestId !== this._loadRequestId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const nextData = {}
|
||||||
|
results.forEach(item => {
|
||||||
|
nextData[item.key] = item.value
|
||||||
|
})
|
||||||
|
const analytics = Object.prototype.hasOwnProperty.call(nextData, 'analytics') ? nextData.analytics : this.data.analytics
|
||||||
|
const pendingOrders = Object.prototype.hasOwnProperty.call(nextData, 'pendingOrders') ? nextData.pendingOrders : this.data.pendingOrders
|
||||||
|
nextData.todoStats = this.buildTodoStats(analytics, pendingOrders, permissionCodes)
|
||||||
|
nextData.analytics = analytics
|
||||||
|
nextData.pendingOrders = pendingOrders
|
||||||
|
this.setData(nextData)
|
||||||
|
},
|
||||||
|
|
||||||
|
buildTodoStats(analytics, pendingOrders, permissionCodes) {
|
||||||
|
const todos = []
|
||||||
|
if (permission.hasPermission(permissionCodes, 'order:view')) {
|
||||||
|
todos.push({
|
||||||
|
key: 'orders',
|
||||||
|
label: '待服务订单',
|
||||||
|
value: pendingOrders || 0,
|
||||||
|
note: '来自订单待服务状态',
|
||||||
|
path: '/pages/orders/index'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (permission.hasPermission(permissionCodes, 'after_sale:view')) {
|
||||||
|
todos.push({
|
||||||
|
key: 'afterSales',
|
||||||
|
label: '售后待处理',
|
||||||
|
value: '--',
|
||||||
|
note: '进入售后处理查看明细',
|
||||||
|
path: '/pages/after-sales/index'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (permission.hasPermission(permissionCodes, 'inventory:view')) {
|
||||||
|
todos.push({
|
||||||
|
key: 'inventory',
|
||||||
|
label: '库存预警',
|
||||||
|
value: '--',
|
||||||
|
note: '进入库存管理查看低库存',
|
||||||
|
path: '/pages/inventory/index'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (analytics) {
|
||||||
|
todos.push({
|
||||||
|
key: 'paid',
|
||||||
|
label: '已支付订单',
|
||||||
|
value: Number(analytics.paidOrderCount) || 0,
|
||||||
|
note: `GMV ¥${formatMoney(analytics.totalAmount)}`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return todos.slice(0, 4)
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: handleOpenModule supports index.js by holding or executing the handle open module page or API role.
|
* Purpose: handleOpenModule supports index.js by holding or executing the handle open module page or API role.
|
||||||
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
||||||
|
|||||||
@@ -34,6 +34,16 @@
|
|||||||
<text class="stat-value">{{permissionCount}}</text>
|
<text class="stat-value">{{permissionCount}}</text>
|
||||||
<text class="stat-note">前端仅做显隐,服务端仍会兜底校验</text>
|
<text class="stat-note">前端仅做显隐,服务端仍会兜底校验</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="stat-card" wx:if="{{analytics}}">
|
||||||
|
<text class="stat-label">经营订单</text>
|
||||||
|
<text class="stat-value">{{analytics.orderCount || 0}}</text>
|
||||||
|
<text class="stat-note">支付 {{analytics.paidOrderCount || 0}} · 完成 {{analytics.completedOrderCount || 0}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="stat-card" wx:if="{{analytics}}">
|
||||||
|
<text class="stat-label">收藏/加购</text>
|
||||||
|
<text class="stat-value">{{analytics.favoriteCount || 0}}/{{analytics.cartCount || 0}}</text>
|
||||||
|
<text class="stat-note">浏览 {{analytics.viewCount || 0}} · 评价 {{analytics.reviewCount || 0}}</text>
|
||||||
|
</view>
|
||||||
<view class="stat-card" wx:if="{{stats}}">
|
<view class="stat-card" wx:if="{{stats}}">
|
||||||
<text class="stat-label">用户总量</text>
|
<text class="stat-label">用户总量</text>
|
||||||
<text class="stat-value">{{stats.totalUsers || 0}}</text>
|
<text class="stat-value">{{stats.totalUsers || 0}}</text>
|
||||||
@@ -50,6 +60,20 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view wx:if="{{!shoplessAdmin && todoStats.length}}" class="surface-card">
|
||||||
|
<text class="section-title">待办与运营</text>
|
||||||
|
<text class="section-desc">同步 vNext 运营能力的轻量摘要,点有入口的待办可直接进入处理页。</text>
|
||||||
|
<view class="stats-grid">
|
||||||
|
<block wx:for="{{todoStats}}" wx:key="key">
|
||||||
|
<view class="stat-card" data-path="{{item.path}}" bindtap="handleOpenModule">
|
||||||
|
<text class="stat-label">{{item.label}}</text>
|
||||||
|
<text class="stat-value">{{item.value}}</text>
|
||||||
|
<text class="stat-note">{{item.note}}</text>
|
||||||
|
</view>
|
||||||
|
</block>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="surface-card">
|
<view class="surface-card">
|
||||||
<text class="section-title">快捷入口</text>
|
<text class="section-title">快捷入口</text>
|
||||||
<text class="section-desc">只展示当前账号真实可进入的模块,避免手机端一屏堆太多无权限入口。</text>
|
<text class="section-desc">只展示当前账号真实可进入的模块,避免手机端一屏堆太多无权限入口。</text>
|
||||||
|
|||||||
@@ -51,6 +51,38 @@ const MANAGE_MODULES = [
|
|||||||
permissionCodes: ['nail_artist:view'],
|
permissionCodes: ['nail_artist:view'],
|
||||||
requiresShopContext: true
|
requiresShopContext: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'schedules',
|
||||||
|
title: '排班管理',
|
||||||
|
description: '查看和维护美甲师班次、休息日与预约容量',
|
||||||
|
path: '/pages/schedules/index',
|
||||||
|
permissionCodes: ['schedule:view'],
|
||||||
|
requiresShopContext: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'afterSales',
|
||||||
|
title: '售后处理',
|
||||||
|
description: '查看售后申请,完成同意、驳回和处理说明',
|
||||||
|
path: '/pages/after-sales/index',
|
||||||
|
permissionCodes: ['after_sale:view'],
|
||||||
|
requiresShopContext: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'inventory',
|
||||||
|
title: '库存管理',
|
||||||
|
description: '查看耗材库存、预警并快速调整入库出库',
|
||||||
|
path: '/pages/inventory/index',
|
||||||
|
permissionCodes: ['inventory:view'],
|
||||||
|
requiresShopContext: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'campaigns',
|
||||||
|
title: '活动管理',
|
||||||
|
description: '查看营销活动、推荐位和轻量活动配置',
|
||||||
|
path: '/pages/campaigns/index',
|
||||||
|
permissionCodes: ['campaign:view'],
|
||||||
|
requiresShopContext: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'shops',
|
key: 'shops',
|
||||||
title: '店铺管理',
|
title: '店铺管理',
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|||||||
"/nail-artist/*/reviews",
|
"/nail-artist/*/reviews",
|
||||||
"/shop/get/**",
|
"/shop/get/**",
|
||||||
"/shop/trust-profile/**",
|
"/shop/trust-profile/**",
|
||||||
|
"/shop/list",
|
||||||
"/shop/list/public",
|
"/shop/list/public",
|
||||||
"/shop/list/simple",
|
"/shop/list/simple",
|
||||||
"/tag/list/all",
|
"/tag/list/all",
|
||||||
|
|||||||
+71
@@ -0,0 +1,71 @@
|
|||||||
|
package com.xiaowang.yuminailcore.controller;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||||
|
import com.xiaowang.yuminailcore.common.Result;
|
||||||
|
import com.xiaowang.yuminailcore.dto.AfterSaleAuditDTO;
|
||||||
|
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||||
|
import com.xiaowang.yuminailcore.service.AfterSaleService;
|
||||||
|
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||||
|
import com.xiaowang.yuminailcore.support.SecurityAuditActions;
|
||||||
|
import com.xiaowang.yuminailcore.support.SecurityAuditSupport;
|
||||||
|
import com.xiaowang.yuminailcore.vo.AfterSaleVO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/after-sale")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AdminAfterSaleController {
|
||||||
|
|
||||||
|
private final AfterSaleService afterSaleService;
|
||||||
|
private final AdminScopeHelper adminScopeHelper;
|
||||||
|
private final SecurityAuditSupport securityAuditSupport;
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
@RequirePermission("after_sale:view")
|
||||||
|
public Result<PageResultVO<AfterSaleVO>> list(HttpServletRequest request,
|
||||||
|
@RequestParam(required = false) String status,
|
||||||
|
@RequestParam(defaultValue = "1") Integer page,
|
||||||
|
@RequestParam(defaultValue = "10") Integer size) {
|
||||||
|
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||||
|
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
||||||
|
return Result.success(afterSaleService.listAdmin(shopId, status, page, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}/approve")
|
||||||
|
@RequirePermission("after_sale:audit")
|
||||||
|
public Result<AfterSaleVO> approve(HttpServletRequest request, @PathVariable Long id, @RequestBody(required = false) AfterSaleAuditDTO dto) {
|
||||||
|
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||||
|
try {
|
||||||
|
AfterSaleVO result = afterSaleService.approve(currentUser.getId(), id, dto);
|
||||||
|
securityAuditSupport.success(request, SecurityAuditActions.AFTER_SALE_APPROVE, "afterSaleId=" + id);
|
||||||
|
return Result.success(result);
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
securityAuditSupport.fail(request, SecurityAuditActions.AFTER_SALE_APPROVE, "afterSaleId=" + id + ",reason=" + exception.getMessage());
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}/reject")
|
||||||
|
@RequirePermission("after_sale:audit")
|
||||||
|
public Result<AfterSaleVO> reject(HttpServletRequest request, @PathVariable Long id, @RequestBody(required = false) AfterSaleAuditDTO dto) {
|
||||||
|
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||||
|
try {
|
||||||
|
AfterSaleVO result = afterSaleService.reject(currentUser.getId(), id, dto);
|
||||||
|
securityAuditSupport.success(request, SecurityAuditActions.AFTER_SALE_REJECT, "afterSaleId=" + id);
|
||||||
|
return Result.success(result);
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
securityAuditSupport.fail(request, SecurityAuditActions.AFTER_SALE_REJECT, "afterSaleId=" + id + ",reason=" + exception.getMessage());
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+59
@@ -0,0 +1,59 @@
|
|||||||
|
package com.xiaowang.yuminailcore.controller;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||||
|
import com.xiaowang.yuminailcore.common.Result;
|
||||||
|
import com.xiaowang.yuminailcore.dto.ArtistScheduleDTO;
|
||||||
|
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||||
|
import com.xiaowang.yuminailcore.service.ArtistScheduleService;
|
||||||
|
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||||
|
import com.xiaowang.yuminailcore.support.SecurityAuditActions;
|
||||||
|
import com.xiaowang.yuminailcore.support.SecurityAuditSupport;
|
||||||
|
import com.xiaowang.yuminailcore.vo.ArtistScheduleVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
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/artist-schedule")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AdminArtistScheduleController {
|
||||||
|
|
||||||
|
private final ArtistScheduleService artistScheduleService;
|
||||||
|
private final AdminScopeHelper adminScopeHelper;
|
||||||
|
private final SecurityAuditSupport securityAuditSupport;
|
||||||
|
|
||||||
|
@PostMapping("/save")
|
||||||
|
@RequirePermission("schedule:edit")
|
||||||
|
public Result<ArtistScheduleVO> save(HttpServletRequest request, @RequestBody ArtistScheduleDTO dto) {
|
||||||
|
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||||
|
dto.setShopId(adminScopeHelper.resolveShopScope(currentUser, dto.getShopId()));
|
||||||
|
try {
|
||||||
|
ArtistScheduleVO result = artistScheduleService.saveSchedule(dto);
|
||||||
|
securityAuditSupport.success(request, SecurityAuditActions.SCHEDULE_UPDATE, "artistId=" + dto.getArtistId() + ",date=" + dto.getWorkDate());
|
||||||
|
return Result.success(result);
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
securityAuditSupport.fail(request, SecurityAuditActions.SCHEDULE_UPDATE, "artistId=" + dto.getArtistId() + ",reason=" + exception.getMessage());
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
@RequirePermission("schedule:view")
|
||||||
|
public Result<List<ArtistScheduleVO>> list(HttpServletRequest request,
|
||||||
|
@RequestParam(required = false) Long artistId,
|
||||||
|
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
|
||||||
|
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate) {
|
||||||
|
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||||
|
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
||||||
|
return Result.success(artistScheduleService.listSchedules(shopId, artistId, startDate, endDate));
|
||||||
|
}
|
||||||
|
}
|
||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
package com.xiaowang.yuminailcore.controller;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||||
|
import com.xiaowang.yuminailcore.common.Result;
|
||||||
|
import com.xiaowang.yuminailcore.dto.CampaignDTO;
|
||||||
|
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||||
|
import com.xiaowang.yuminailcore.service.CampaignService;
|
||||||
|
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||||
|
import com.xiaowang.yuminailcore.support.SecurityAuditActions;
|
||||||
|
import com.xiaowang.yuminailcore.support.SecurityAuditSupport;
|
||||||
|
import com.xiaowang.yuminailcore.vo.CampaignVO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/campaign")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AdminCampaignController {
|
||||||
|
|
||||||
|
private final CampaignService campaignService;
|
||||||
|
private final AdminScopeHelper adminScopeHelper;
|
||||||
|
private final SecurityAuditSupport securityAuditSupport;
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
@RequirePermission("campaign:view")
|
||||||
|
public Result<PageResultVO<CampaignVO>> list(HttpServletRequest request,
|
||||||
|
@RequestParam(required = false) Integer status,
|
||||||
|
@RequestParam(defaultValue = "1") Integer page,
|
||||||
|
@RequestParam(defaultValue = "10") Integer size) {
|
||||||
|
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||||
|
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
||||||
|
return Result.success(campaignService.listCampaigns(shopId, status, page, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/save")
|
||||||
|
@RequirePermission("campaign:manage")
|
||||||
|
public Result<CampaignVO> save(HttpServletRequest request, @RequestBody CampaignDTO dto) {
|
||||||
|
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||||
|
dto.setShopId(adminScopeHelper.resolveShopScope(currentUser, dto.getShopId()));
|
||||||
|
try {
|
||||||
|
CampaignVO result = campaignService.saveCampaign(dto);
|
||||||
|
securityAuditSupport.success(request, SecurityAuditActions.CAMPAIGN_PUBLISH, "campaignId=" + result.getId());
|
||||||
|
return Result.success(result);
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
securityAuditSupport.fail(request, SecurityAuditActions.CAMPAIGN_PUBLISH, "reason=" + exception.getMessage());
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+59
@@ -0,0 +1,59 @@
|
|||||||
|
package com.xiaowang.yuminailcore.controller;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||||
|
import com.xiaowang.yuminailcore.common.Result;
|
||||||
|
import com.xiaowang.yuminailcore.dto.InventoryAdjustDTO;
|
||||||
|
import com.xiaowang.yuminailcore.dto.InventoryItemDTO;
|
||||||
|
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||||
|
import com.xiaowang.yuminailcore.service.InventoryService;
|
||||||
|
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||||
|
import com.xiaowang.yuminailcore.support.SecurityAuditActions;
|
||||||
|
import com.xiaowang.yuminailcore.support.SecurityAuditSupport;
|
||||||
|
import com.xiaowang.yuminailcore.vo.InventoryItemVO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/inventory")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AdminInventoryController {
|
||||||
|
|
||||||
|
private final InventoryService inventoryService;
|
||||||
|
private final AdminScopeHelper adminScopeHelper;
|
||||||
|
private final SecurityAuditSupport securityAuditSupport;
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
@RequirePermission("inventory:view")
|
||||||
|
public Result<PageResultVO<InventoryItemVO>> list(HttpServletRequest request,
|
||||||
|
@RequestParam(defaultValue = "1") Integer page,
|
||||||
|
@RequestParam(defaultValue = "10") Integer size) {
|
||||||
|
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||||
|
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
||||||
|
return Result.success(inventoryService.listItems(shopId, page, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/save")
|
||||||
|
@RequirePermission("inventory:manage")
|
||||||
|
public Result<InventoryItemVO> save(HttpServletRequest request, @RequestBody InventoryItemDTO dto) {
|
||||||
|
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||||
|
dto.setShopId(adminScopeHelper.resolveShopScope(currentUser, dto.getShopId()));
|
||||||
|
return Result.success(inventoryService.saveItem(dto));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/{id}/adjust")
|
||||||
|
@RequirePermission("inventory:manage")
|
||||||
|
public Result<InventoryItemVO> adjust(HttpServletRequest request, @PathVariable Long id, @RequestBody InventoryAdjustDTO dto) {
|
||||||
|
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||||
|
try {
|
||||||
|
InventoryItemVO result = inventoryService.adjustStock(currentUser.getId(), id, dto);
|
||||||
|
securityAuditSupport.success(request, SecurityAuditActions.INVENTORY_ADJUST, "itemId=" + id);
|
||||||
|
return Result.success(result);
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
securityAuditSupport.fail(request, SecurityAuditActions.INVENTORY_ADJUST, "itemId=" + id + ",reason=" + exception.getMessage());
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+62
@@ -0,0 +1,62 @@
|
|||||||
|
package com.xiaowang.yuminailcore.controller;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||||
|
import com.xiaowang.yuminailcore.common.Result;
|
||||||
|
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||||
|
import com.xiaowang.yuminailcore.service.PaymentService;
|
||||||
|
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||||
|
import com.xiaowang.yuminailcore.support.SecurityAuditActions;
|
||||||
|
import com.xiaowang.yuminailcore.support.SecurityAuditSupport;
|
||||||
|
import com.xiaowang.yuminailcore.vo.PaymentOrderVO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.RefundOrderVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/payment")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AdminPaymentController {
|
||||||
|
|
||||||
|
private final PaymentService paymentService;
|
||||||
|
private final AdminScopeHelper adminScopeHelper;
|
||||||
|
private final SecurityAuditSupport securityAuditSupport;
|
||||||
|
|
||||||
|
@PostMapping("/order/{orderId}/manual-confirm")
|
||||||
|
@RequirePermission("payment:manage")
|
||||||
|
public Result<PaymentOrderVO> manualConfirm(HttpServletRequest request,
|
||||||
|
@PathVariable Long orderId,
|
||||||
|
@RequestParam(required = false) String remark) {
|
||||||
|
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||||
|
try {
|
||||||
|
PaymentOrderVO result = paymentService.manualConfirmOrderPaid(currentUser.getId(), orderId, remark);
|
||||||
|
securityAuditSupport.success(request, SecurityAuditActions.PAYMENT_MANUAL_CONFIRM, "orderId=" + orderId);
|
||||||
|
return Result.success(result);
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
securityAuditSupport.fail(request, SecurityAuditActions.PAYMENT_MANUAL_CONFIRM, "orderId=" + orderId + ",reason=" + exception.getMessage());
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/order/{orderId}/manual-refund")
|
||||||
|
@RequirePermission("refund:manage")
|
||||||
|
public Result<RefundOrderVO> manualRefund(HttpServletRequest request,
|
||||||
|
@PathVariable Long orderId,
|
||||||
|
@RequestParam(required = false) Long afterSaleId,
|
||||||
|
@RequestParam(required = false) String remark) {
|
||||||
|
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||||
|
try {
|
||||||
|
RefundOrderVO result = paymentService.manualRefundOrder(currentUser.getId(), orderId, afterSaleId, remark);
|
||||||
|
securityAuditSupport.success(request, SecurityAuditActions.REFUND_MANUAL_CONFIRM, "orderId=" + orderId);
|
||||||
|
return Result.success(result);
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
securityAuditSupport.fail(request, SecurityAuditActions.REFUND_MANUAL_CONFIRM, "orderId=" + orderId + ",reason=" + exception.getMessage());
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package com.xiaowang.yuminailcore.controller;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.annotation.RequirePermission;
|
||||||
|
import com.xiaowang.yuminailcore.common.Result;
|
||||||
|
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||||
|
import com.xiaowang.yuminailcore.service.WorkbenchService;
|
||||||
|
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||||
|
import com.xiaowang.yuminailcore.vo.StoreWorkbenchVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/workbench")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AdminWorkbenchController {
|
||||||
|
|
||||||
|
private final AdminScopeHelper adminScopeHelper;
|
||||||
|
private final WorkbenchService workbenchService;
|
||||||
|
|
||||||
|
@GetMapping("/summary")
|
||||||
|
@RequirePermission("workbench:view")
|
||||||
|
public Result<StoreWorkbenchVO> summary(HttpServletRequest request) {
|
||||||
|
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||||
|
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
||||||
|
Long artistId = currentUser != null && Integer.valueOf(3).equals(currentUser.getType()) ? currentUser.getId() : null;
|
||||||
|
return Result.success(workbenchService.getWorkbench(shopId, artistId));
|
||||||
|
}
|
||||||
|
}
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package com.xiaowang.yuminailcore.controller;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.common.Result;
|
||||||
|
import com.xiaowang.yuminailcore.dto.AfterSaleApplyDTO;
|
||||||
|
import com.xiaowang.yuminailcore.service.AfterSaleService;
|
||||||
|
import com.xiaowang.yuminailcore.vo.AfterSaleVO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/after-sale")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AfterSaleController {
|
||||||
|
|
||||||
|
private final AfterSaleService afterSaleService;
|
||||||
|
|
||||||
|
@PostMapping("/apply")
|
||||||
|
public Result<AfterSaleVO> apply(HttpServletRequest request, @RequestBody AfterSaleApplyDTO dto) {
|
||||||
|
Long userId = (Long) request.getAttribute("userId");
|
||||||
|
return Result.success(afterSaleService.apply(userId, dto));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/my")
|
||||||
|
public Result<PageResultVO<AfterSaleVO>> listMy(HttpServletRequest request,
|
||||||
|
@RequestParam(defaultValue = "1") Integer page,
|
||||||
|
@RequestParam(defaultValue = "10") Integer size) {
|
||||||
|
Long userId = (Long) request.getAttribute("userId");
|
||||||
|
return Result.success(afterSaleService.listMy(userId, page, size));
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
@@ -16,11 +16,13 @@ import com.xiaowang.yuminailcore.mapper.OrderMapper;
|
|||||||
import com.xiaowang.yuminailcore.mapper.ProductMapper;
|
import com.xiaowang.yuminailcore.mapper.ProductMapper;
|
||||||
import com.xiaowang.yuminailcore.mapper.ShopMapper;
|
import com.xiaowang.yuminailcore.mapper.ShopMapper;
|
||||||
import com.xiaowang.yuminailcore.mapper.UserMapper;
|
import com.xiaowang.yuminailcore.mapper.UserMapper;
|
||||||
|
import com.xiaowang.yuminailcore.service.OperationsAnalyticsService;
|
||||||
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
import com.xiaowang.yuminailcore.support.AdminScopeHelper;
|
||||||
import com.xiaowang.yuminailcore.support.UserShopBindingSupport;
|
import com.xiaowang.yuminailcore.support.UserShopBindingSupport;
|
||||||
import com.xiaowang.yuminailcore.support.cache.MultiLevelCacheService;
|
import com.xiaowang.yuminailcore.support.cache.MultiLevelCacheService;
|
||||||
import com.xiaowang.yuminailcore.vo.DashboardStatsVO;
|
import com.xiaowang.yuminailcore.vo.DashboardStatsVO;
|
||||||
import com.xiaowang.yuminailcore.vo.HotProductVO;
|
import com.xiaowang.yuminailcore.vo.HotProductVO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.OperationsAnalyticsVO;
|
||||||
import com.xiaowang.yuminailcore.vo.RecentActivityVO;
|
import com.xiaowang.yuminailcore.vo.RecentActivityVO;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
@@ -87,6 +89,7 @@ public class DashboardController {
|
|||||||
* Variable `appCacheProperties`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
* Variable `appCacheProperties`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||||
*/
|
*/
|
||||||
private final AppCacheProperties appCacheProperties;
|
private final AppCacheProperties appCacheProperties;
|
||||||
|
private final OperationsAnalyticsService operationsAnalyticsService;
|
||||||
|
|
||||||
@GetMapping("/stats")
|
@GetMapping("/stats")
|
||||||
@RequirePermission("dashboard:view")
|
@RequirePermission("dashboard:view")
|
||||||
@@ -112,6 +115,15 @@ public class DashboardController {
|
|||||||
return Result.success(stats);
|
return Result.success(stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/analytics")
|
||||||
|
@RequirePermission("analytics:view")
|
||||||
|
public Result<OperationsAnalyticsVO> getAnalytics(HttpServletRequest request) {
|
||||||
|
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||||
|
Long shopIdScope = resolveShopScope(currentUser);
|
||||||
|
Long artistScope = currentUser != null && Integer.valueOf(3).equals(currentUser.getType()) ? currentUser.getId() : null;
|
||||||
|
return Result.success(operationsAnalyticsService.getDashboardAnalytics(shopIdScope, artistScope));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run business method `buildDashboardStats`.
|
* Run business method `buildDashboardStats`.
|
||||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||||
|
|||||||
+9
-32
@@ -16,46 +16,23 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 前台文件控制器,提供前台用户可访问的文件相关接口。
|
* Purpose: FrontendFileController exposes signed-file access only for public frontend references.
|
||||||
|
* Usage: anonymous clients call /file/get-signed-url/{fileId}; the controller verifies the file is referenced by public content before returning a URL.
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/file")
|
@RequestMapping("/file")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class FrontendFileController {
|
public class FrontendFileController {
|
||||||
/**
|
|
||||||
* Variable `objectStorageFileService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
|
||||||
*/
|
|
||||||
private final ObjectStorageFileService objectStorageFileService;
|
private final ObjectStorageFileService objectStorageFileService;
|
||||||
/**
|
|
||||||
* Variable `minioService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
|
||||||
*/
|
|
||||||
private final MinioService minioService;
|
private final MinioService minioService;
|
||||||
/**
|
|
||||||
* Variable `objectStorageUrlSupport`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
|
||||||
*/
|
|
||||||
private final ObjectStorageUrlSupport objectStorageUrlSupport;
|
private final ObjectStorageUrlSupport objectStorageUrlSupport;
|
||||||
/**
|
|
||||||
* Purpose: productMapper supports FrontendFileController.java by holding or executing the product mapper business role.
|
|
||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private final ProductMapper productMapper;
|
private final ProductMapper productMapper;
|
||||||
/**
|
|
||||||
* Purpose: shopMapper supports FrontendFileController.java by holding or executing the shop mapper business role.
|
|
||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private final ShopMapper shopMapper;
|
private final ShopMapper shopMapper;
|
||||||
/**
|
|
||||||
* Purpose: effectDiagramMapper supports FrontendFileController.java by holding or executing the effect diagram mapper business role.
|
|
||||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
|
||||||
*/
|
|
||||||
private final EffectDiagramMapper effectDiagramMapper;
|
private final EffectDiagramMapper effectDiagramMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取带签名的图片链接。
|
* Purpose: getSignedUrl returns a short-lived URL for public image references, or the original external URL when it is already public.
|
||||||
*
|
* Usage: pass a public file id and optional expiry minutes; private or unreferenced files are rejected.
|
||||||
* @param fileId 文件 ID
|
|
||||||
* @param expiryTimeInMinutes 有效期,默认 60 分钟
|
|
||||||
* @return 临时可访问的签名地址
|
|
||||||
*/
|
*/
|
||||||
@GetMapping("/get-signed-url/{fileId}")
|
@GetMapping("/get-signed-url/{fileId}")
|
||||||
public Result<String> getSignedUrl(@PathVariable Long fileId,
|
public Result<String> getSignedUrl(@PathVariable Long fileId,
|
||||||
@@ -71,7 +48,7 @@ public class FrontendFileController {
|
|||||||
|
|
||||||
String objectName = objectStorageUrlSupport.extractObjectName(fileVO.getFileUrl());
|
String objectName = objectStorageUrlSupport.extractObjectName(fileVO.getFileUrl());
|
||||||
if (objectName == null || objectName.isEmpty()) {
|
if (objectName == null || objectName.isEmpty()) {
|
||||||
return Result.error("文件 URL 格式错误");
|
return Result.success(fileVO.getFileUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
String signedUrl = minioService.getPresignedUrl(objectName, expiryTimeInMinutes);
|
String signedUrl = minioService.getPresignedUrl(objectName, expiryTimeInMinutes);
|
||||||
@@ -83,8 +60,8 @@ public class FrontendFileController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: isPublicFileReference supports FrontendFileController.java by holding or executing the is public file reference business role.
|
* Purpose: isPublicFileReference prevents arbitrary uploaded files from being exposed through the public signing endpoint.
|
||||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
* Usage: call with a file id and keep mapper checks in sync with public content tables.
|
||||||
*/
|
*/
|
||||||
private boolean isPublicFileReference(Long fileId) {
|
private boolean isPublicFileReference(Long fileId) {
|
||||||
if (fileId == null) {
|
if (fileId == null) {
|
||||||
@@ -96,8 +73,8 @@ public class FrontendFileController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: positive supports FrontendFileController.java by holding or executing the positive business role.
|
* Purpose: positive normalizes nullable mapper counts.
|
||||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
* Usage: use for COUNT(*) results where null should behave like zero.
|
||||||
*/
|
*/
|
||||||
private boolean positive(Long count) {
|
private boolean positive(Long count) {
|
||||||
return count != null && count > 0;
|
return count != null && count > 0;
|
||||||
|
|||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package com.xiaowang.yuminailcore.controller;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.common.Result;
|
||||||
|
import com.xiaowang.yuminailcore.service.GrowthService;
|
||||||
|
import com.xiaowang.yuminailcore.vo.GrowthSummaryVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/growth")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GrowthController {
|
||||||
|
|
||||||
|
private final GrowthService growthService;
|
||||||
|
|
||||||
|
@GetMapping("/summary")
|
||||||
|
public Result<GrowthSummaryVO> summary(HttpServletRequest request) {
|
||||||
|
Long userId = (Long) request.getAttribute("userId");
|
||||||
|
return Result.success(growthService.getSummary(userId));
|
||||||
|
}
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package com.xiaowang.yuminailcore.controller;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.common.Result;
|
||||||
|
import com.xiaowang.yuminailcore.service.PaymentService;
|
||||||
|
import com.xiaowang.yuminailcore.vo.PaymentOrderVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/payment")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PaymentController {
|
||||||
|
|
||||||
|
private final PaymentService paymentService;
|
||||||
|
|
||||||
|
@PostMapping("/order/{orderId}/prepare")
|
||||||
|
public Result<PaymentOrderVO> prepareOrderPayment(HttpServletRequest request, @PathVariable Long orderId) {
|
||||||
|
Long userId = (Long) request.getAttribute("userId");
|
||||||
|
return Result.success(paymentService.prepareOrderPayment(userId, orderId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/order/{orderId}/mock-success")
|
||||||
|
public Result<PaymentOrderVO> mockSuccess(HttpServletRequest request, @PathVariable Long orderId) {
|
||||||
|
Long userId = (Long) request.getAttribute("userId");
|
||||||
|
return Result.success(paymentService.manualConfirmOrderPaid(userId, orderId, "mock-success"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -176,6 +176,16 @@ public class ShopController {
|
|||||||
return Result.success(simpleVOs);
|
return Result.success(simpleVOs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
/**
|
||||||
|
* Purpose: listPublicShopsCompat keeps the legacy /shop/list public catalog URL usable for anonymous clients.
|
||||||
|
* Usage: call from old Web or mini-program builds that still request /api/shop/list; new code may prefer /shop/list/public.
|
||||||
|
* @return Result<List<ShopVO>> result consumed by the caller or returned to the frontend
|
||||||
|
*/
|
||||||
|
public Result<List<ShopVO>> listPublicShopsCompat() {
|
||||||
|
return Result.success(shopService.listAllShops());
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/list/public")
|
@GetMapping("/list/public")
|
||||||
/**
|
/**
|
||||||
* List records for the current query or current user scope.
|
* List records for the current query or current user scope.
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.xiaowang.yuminailcore.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AfterSaleApplyDTO {
|
||||||
|
private Long orderId;
|
||||||
|
private Long orderItemId;
|
||||||
|
private String type;
|
||||||
|
private String reason;
|
||||||
|
private BigDecimal refundAmount;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.xiaowang.yuminailcore.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AfterSaleAuditDTO {
|
||||||
|
private String auditReason;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.xiaowang.yuminailcore.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ArtistScheduleDTO {
|
||||||
|
private Long shopId;
|
||||||
|
private Long artistId;
|
||||||
|
private LocalDate workDate;
|
||||||
|
private LocalTime startTime;
|
||||||
|
private LocalTime endTime;
|
||||||
|
private Integer slotMinutes;
|
||||||
|
private Integer capacity;
|
||||||
|
private Integer status;
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.xiaowang.yuminailcore.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CampaignDTO {
|
||||||
|
private Long shopId;
|
||||||
|
private String title;
|
||||||
|
private String description;
|
||||||
|
private String scene;
|
||||||
|
private String productIds;
|
||||||
|
private String couponIds;
|
||||||
|
private Integer status;
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
private Integer sortOrder;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.xiaowang.yuminailcore.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class InventoryAdjustDTO {
|
||||||
|
private String changeType;
|
||||||
|
private BigDecimal changeQuantity;
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.xiaowang.yuminailcore.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class InventoryItemDTO {
|
||||||
|
private Long shopId;
|
||||||
|
private String category;
|
||||||
|
private String itemName;
|
||||||
|
private String unit;
|
||||||
|
private BigDecimal stockQuantity;
|
||||||
|
private BigDecimal warningThreshold;
|
||||||
|
private Integer status;
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.xiaowang.yuminailcore.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("t_after_sale")
|
||||||
|
public class AfterSaleDO extends BaseEntity {
|
||||||
|
@TableField("after_sale_no")
|
||||||
|
private String afterSaleNo;
|
||||||
|
@TableField("order_id")
|
||||||
|
private Long orderId;
|
||||||
|
@TableField("order_item_id")
|
||||||
|
private Long orderItemId;
|
||||||
|
@TableField("user_id")
|
||||||
|
private Long userId;
|
||||||
|
@TableField("shop_id")
|
||||||
|
private Long shopId;
|
||||||
|
@TableField("type")
|
||||||
|
private String type;
|
||||||
|
@TableField("reason")
|
||||||
|
private String reason;
|
||||||
|
@TableField("refund_amount")
|
||||||
|
private BigDecimal refundAmount;
|
||||||
|
@TableField("status")
|
||||||
|
private String status;
|
||||||
|
@TableField("audit_user_id")
|
||||||
|
private Long auditUserId;
|
||||||
|
@TableField("audit_reason")
|
||||||
|
private String auditReason;
|
||||||
|
@TableField("audit_time")
|
||||||
|
private LocalDateTime auditTime;
|
||||||
|
@TableField("refund_order_id")
|
||||||
|
private Long refundOrderId;
|
||||||
|
@TableField("is_delete")
|
||||||
|
@TableLogic
|
||||||
|
private Integer isDelete;
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.xiaowang.yuminailcore.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("t_after_sale_log")
|
||||||
|
public class AfterSaleLogDO extends BaseEntity {
|
||||||
|
@TableField("after_sale_id")
|
||||||
|
private Long afterSaleId;
|
||||||
|
@TableField("action")
|
||||||
|
private String action;
|
||||||
|
@TableField("from_status")
|
||||||
|
private String fromStatus;
|
||||||
|
@TableField("to_status")
|
||||||
|
private String toStatus;
|
||||||
|
@TableField("operator_id")
|
||||||
|
private Long operatorId;
|
||||||
|
@TableField("operator_type")
|
||||||
|
private String operatorType;
|
||||||
|
@TableField("remark")
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
package com.xiaowang.yuminailcore.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("t_appointment_reservation")
|
||||||
|
public class AppointmentReservationDO extends BaseEntity {
|
||||||
|
@TableField("order_id")
|
||||||
|
private Long orderId;
|
||||||
|
@TableField("order_item_id")
|
||||||
|
private Long orderItemId;
|
||||||
|
@TableField("shop_id")
|
||||||
|
private Long shopId;
|
||||||
|
@TableField("artist_id")
|
||||||
|
private Long artistId;
|
||||||
|
@TableField("product_title")
|
||||||
|
private String productTitle;
|
||||||
|
@TableField("appointment_start_time")
|
||||||
|
private LocalDateTime appointmentStartTime;
|
||||||
|
@TableField("appointment_end_time")
|
||||||
|
private LocalDateTime appointmentEndTime;
|
||||||
|
@TableField("status")
|
||||||
|
private String status;
|
||||||
|
@TableField("is_delete")
|
||||||
|
@TableLogic
|
||||||
|
private Integer isDelete;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.xiaowang.yuminailcore.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("t_artist_schedule")
|
||||||
|
public class ArtistScheduleDO extends BaseEntity {
|
||||||
|
@TableField("shop_id")
|
||||||
|
private Long shopId;
|
||||||
|
@TableField("artist_id")
|
||||||
|
private Long artistId;
|
||||||
|
@TableField("work_date")
|
||||||
|
private LocalDate workDate;
|
||||||
|
@TableField("start_time")
|
||||||
|
private LocalTime startTime;
|
||||||
|
@TableField("end_time")
|
||||||
|
private LocalTime endTime;
|
||||||
|
@TableField("slot_minutes")
|
||||||
|
private Integer slotMinutes;
|
||||||
|
@TableField("capacity")
|
||||||
|
private Integer capacity;
|
||||||
|
@TableField("status")
|
||||||
|
private Integer status;
|
||||||
|
@TableField("remark")
|
||||||
|
private String remark;
|
||||||
|
@TableField("is_delete")
|
||||||
|
@TableLogic
|
||||||
|
private Integer isDelete;
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.xiaowang.yuminailcore.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("t_campaign")
|
||||||
|
public class CampaignDO extends BaseEntity {
|
||||||
|
@TableField("shop_id")
|
||||||
|
private Long shopId;
|
||||||
|
@TableField("title")
|
||||||
|
private String title;
|
||||||
|
@TableField("description")
|
||||||
|
private String description;
|
||||||
|
@TableField("scene")
|
||||||
|
private String scene;
|
||||||
|
@TableField("product_ids")
|
||||||
|
private String productIds;
|
||||||
|
@TableField("coupon_ids")
|
||||||
|
private String couponIds;
|
||||||
|
@TableField("status")
|
||||||
|
private Integer status;
|
||||||
|
@TableField("start_time")
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
@TableField("end_time")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
@TableField("sort_order")
|
||||||
|
private Integer sortOrder;
|
||||||
|
@TableField("is_delete")
|
||||||
|
@TableLogic
|
||||||
|
private Integer isDelete;
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.xiaowang.yuminailcore.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("t_inventory_item")
|
||||||
|
public class InventoryItemDO extends BaseEntity {
|
||||||
|
@TableField("shop_id")
|
||||||
|
private Long shopId;
|
||||||
|
@TableField("category")
|
||||||
|
private String category;
|
||||||
|
@TableField("item_name")
|
||||||
|
private String itemName;
|
||||||
|
@TableField("unit")
|
||||||
|
private String unit;
|
||||||
|
@TableField("stock_quantity")
|
||||||
|
private BigDecimal stockQuantity;
|
||||||
|
@TableField("warning_threshold")
|
||||||
|
private BigDecimal warningThreshold;
|
||||||
|
@TableField("status")
|
||||||
|
private Integer status;
|
||||||
|
@TableField("is_delete")
|
||||||
|
@TableLogic
|
||||||
|
private Integer isDelete;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.xiaowang.yuminailcore.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("t_inventory_record")
|
||||||
|
public class InventoryRecordDO extends BaseEntity {
|
||||||
|
@TableField("inventory_item_id")
|
||||||
|
private Long inventoryItemId;
|
||||||
|
@TableField("shop_id")
|
||||||
|
private Long shopId;
|
||||||
|
@TableField("change_type")
|
||||||
|
private String changeType;
|
||||||
|
@TableField("change_quantity")
|
||||||
|
private BigDecimal changeQuantity;
|
||||||
|
@TableField("before_quantity")
|
||||||
|
private BigDecimal beforeQuantity;
|
||||||
|
@TableField("after_quantity")
|
||||||
|
private BigDecimal afterQuantity;
|
||||||
|
@TableField("operator_id")
|
||||||
|
private Long operatorId;
|
||||||
|
@TableField("remark")
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
@@ -45,6 +45,13 @@ public class OrderDO extends BaseEntity {
|
|||||||
* Field `couponSourceType` (String): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
* Field `couponSourceType` (String): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||||
*/
|
*/
|
||||||
private String couponSourceType;
|
private String couponSourceType;
|
||||||
|
private String paymentStatus;
|
||||||
|
private BigDecimal payAmount;
|
||||||
|
private BigDecimal paidAmount;
|
||||||
|
private LocalDateTime payTime;
|
||||||
|
private String paymentMethod;
|
||||||
|
private String paymentOrderNo;
|
||||||
|
private String refundStatus;
|
||||||
/**
|
/**
|
||||||
* Field `status` (Integer): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
* Field `status` (Integer): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.xiaowang.yuminailcore.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("t_payment_order")
|
||||||
|
public class PaymentOrderDO extends BaseEntity {
|
||||||
|
@TableField("pay_no")
|
||||||
|
private String payNo;
|
||||||
|
@TableField("order_id")
|
||||||
|
private Long orderId;
|
||||||
|
@TableField("order_no")
|
||||||
|
private String orderNo;
|
||||||
|
@TableField("user_id")
|
||||||
|
private Long userId;
|
||||||
|
@TableField("shop_id")
|
||||||
|
private Long shopId;
|
||||||
|
@TableField("channel")
|
||||||
|
private String channel;
|
||||||
|
@TableField("status")
|
||||||
|
private String status;
|
||||||
|
@TableField("pay_amount")
|
||||||
|
private BigDecimal payAmount;
|
||||||
|
@TableField("paid_amount")
|
||||||
|
private BigDecimal paidAmount;
|
||||||
|
@TableField("pay_time")
|
||||||
|
private LocalDateTime payTime;
|
||||||
|
@TableField("expire_time")
|
||||||
|
private LocalDateTime expireTime;
|
||||||
|
@TableField("operator_id")
|
||||||
|
private Long operatorId;
|
||||||
|
@TableField("remark")
|
||||||
|
private String remark;
|
||||||
|
@TableField("idempotency_key")
|
||||||
|
private String idempotencyKey;
|
||||||
|
@TableField("raw_payload")
|
||||||
|
private String rawPayload;
|
||||||
|
@TableField("is_delete")
|
||||||
|
@TableLogic
|
||||||
|
private Integer isDelete;
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.xiaowang.yuminailcore.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("t_refund_order")
|
||||||
|
public class RefundOrderDO extends BaseEntity {
|
||||||
|
@TableField("refund_no")
|
||||||
|
private String refundNo;
|
||||||
|
@TableField("after_sale_id")
|
||||||
|
private Long afterSaleId;
|
||||||
|
@TableField("payment_order_id")
|
||||||
|
private Long paymentOrderId;
|
||||||
|
@TableField("order_id")
|
||||||
|
private Long orderId;
|
||||||
|
@TableField("status")
|
||||||
|
private String status;
|
||||||
|
@TableField("refund_amount")
|
||||||
|
private BigDecimal refundAmount;
|
||||||
|
@TableField("refund_time")
|
||||||
|
private LocalDateTime refundTime;
|
||||||
|
@TableField("channel")
|
||||||
|
private String channel;
|
||||||
|
@TableField("external_refund_no")
|
||||||
|
private String externalRefundNo;
|
||||||
|
@TableField("fail_reason")
|
||||||
|
private String failReason;
|
||||||
|
@TableField("idempotency_key")
|
||||||
|
private String idempotencyKey;
|
||||||
|
@TableField("is_delete")
|
||||||
|
@TableLogic
|
||||||
|
private Integer isDelete;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.xiaowang.yuminailcore.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("t_user_growth_record")
|
||||||
|
public class UserGrowthRecordDO extends BaseEntity {
|
||||||
|
@TableField("user_id")
|
||||||
|
private Long userId;
|
||||||
|
@TableField("source_type")
|
||||||
|
private String sourceType;
|
||||||
|
@TableField("source_id")
|
||||||
|
private Long sourceId;
|
||||||
|
@TableField("growth_value")
|
||||||
|
private Integer growthValue;
|
||||||
|
@TableField("remark")
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.xiaowang.yuminailcore.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.xiaowang.yuminailcore.entity.AfterSaleLogDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface AfterSaleLogMapper extends BaseMapper<AfterSaleLogDO> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.xiaowang.yuminailcore.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.xiaowang.yuminailcore.entity.AfterSaleDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface AfterSaleMapper extends BaseMapper<AfterSaleDO> {
|
||||||
|
}
|
||||||
+57
@@ -0,0 +1,57 @@
|
|||||||
|
package com.xiaowang.yuminailcore.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.xiaowang.yuminailcore.entity.AppointmentReservationDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface AppointmentReservationMapper extends BaseMapper<AppointmentReservationDO> {
|
||||||
|
@Select("SELECT COUNT(*) FROM t_appointment_reservation WHERE artist_id = #{artistId} " +
|
||||||
|
"AND status IN ('LOCKED','CONFIRMED') AND is_delete = 0 " +
|
||||||
|
"AND appointment_start_time < #{endTime} AND appointment_end_time > #{startTime} FOR UPDATE")
|
||||||
|
int countOverlappingActiveForUpdate(@Param("artistId") Long artistId,
|
||||||
|
@Param("startTime") LocalDateTime startTime,
|
||||||
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
|
@Select("SELECT COUNT(*) FROM t_appointment_reservation WHERE artist_id = #{artistId} " +
|
||||||
|
"AND order_item_id <> #{orderItemId} AND status IN ('LOCKED','CONFIRMED') AND is_delete = 0 " +
|
||||||
|
"AND appointment_start_time < #{endTime} AND appointment_end_time > #{startTime} FOR UPDATE")
|
||||||
|
int countOverlappingActiveForUpdateExcludingOrderItem(@Param("artistId") Long artistId,
|
||||||
|
@Param("orderItemId") Long orderItemId,
|
||||||
|
@Param("startTime") LocalDateTime startTime,
|
||||||
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
|
@Select("SELECT COUNT(*) FROM t_appointment_reservation WHERE artist_id = #{artistId} " +
|
||||||
|
"AND status IN ('LOCKED','CONFIRMED') AND is_delete = 0 " +
|
||||||
|
"AND appointment_start_time < #{endTime} AND appointment_end_time > #{startTime}")
|
||||||
|
int countOverlappingActive(@Param("artistId") Long artistId,
|
||||||
|
@Param("startTime") LocalDateTime startTime,
|
||||||
|
@Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
|
@Update("UPDATE t_appointment_reservation SET status = #{status}, is_delete = 1, update_time = NOW() " +
|
||||||
|
"WHERE order_id = #{orderId} AND is_delete = 0")
|
||||||
|
int releaseByOrderId(@Param("orderId") Long orderId, @Param("status") String status);
|
||||||
|
|
||||||
|
@Update("UPDATE t_appointment_reservation SET status = #{status}, is_delete = 1, update_time = NOW() " +
|
||||||
|
"WHERE order_item_id = #{orderItemId} AND is_delete = 0")
|
||||||
|
int releaseByOrderItem(@Param("orderItemId") Long orderItemId, @Param("status") String status);
|
||||||
|
|
||||||
|
@Update("UPDATE t_appointment_reservation SET order_id = #{orderId}, shop_id = #{shopId}, " +
|
||||||
|
"artist_id = #{artistId}, product_title = #{productTitle}, " +
|
||||||
|
"appointment_start_time = #{startTime}, appointment_end_time = #{endTime}, " +
|
||||||
|
"status = #{status}, is_delete = 0, update_time = NOW() " +
|
||||||
|
"WHERE order_item_id = #{orderItemId} AND is_delete = 0")
|
||||||
|
int updateActiveReservationForOrderItem(@Param("orderItemId") Long orderItemId,
|
||||||
|
@Param("orderId") Long orderId,
|
||||||
|
@Param("shopId") Long shopId,
|
||||||
|
@Param("artistId") Long artistId,
|
||||||
|
@Param("productTitle") String productTitle,
|
||||||
|
@Param("startTime") LocalDateTime startTime,
|
||||||
|
@Param("endTime") LocalDateTime endTime,
|
||||||
|
@Param("status") String status);
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package com.xiaowang.yuminailcore.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.xiaowang.yuminailcore.entity.ArtistScheduleDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ArtistScheduleMapper extends BaseMapper<ArtistScheduleDO> {
|
||||||
|
@Select("SELECT * FROM t_artist_schedule WHERE shop_id = #{shopId} AND artist_id = #{artistId} " +
|
||||||
|
"AND work_date = #{workDate} AND start_time <= #{startTime} AND end_time >= #{endTime} " +
|
||||||
|
"AND is_delete = 0 ORDER BY CASE WHEN status = 1 THEN 0 ELSE 1 END, start_time ASC LIMIT 1 FOR UPDATE")
|
||||||
|
ArtistScheduleDO selectCoveringSchedule(@Param("shopId") Long shopId,
|
||||||
|
@Param("artistId") Long artistId,
|
||||||
|
@Param("workDate") LocalDate workDate,
|
||||||
|
@Param("startTime") LocalTime startTime,
|
||||||
|
@Param("endTime") LocalTime endTime);
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.xiaowang.yuminailcore.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.xiaowang.yuminailcore.entity.CampaignDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CampaignMapper extends BaseMapper<CampaignDO> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.xiaowang.yuminailcore.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.xiaowang.yuminailcore.entity.InventoryItemDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface InventoryItemMapper extends BaseMapper<InventoryItemDO> {
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package com.xiaowang.yuminailcore.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.xiaowang.yuminailcore.entity.InventoryRecordDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface InventoryRecordMapper extends BaseMapper<InventoryRecordDO> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.xiaowang.yuminailcore.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.xiaowang.yuminailcore.entity.PaymentOrderDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface PaymentOrderMapper extends BaseMapper<PaymentOrderDO> {
|
||||||
|
@Select("SELECT * FROM t_payment_order WHERE order_id = #{orderId} AND is_delete = 0 ORDER BY create_time DESC, id DESC LIMIT 1")
|
||||||
|
PaymentOrderDO selectLatestByOrderId(@Param("orderId") Long orderId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.xiaowang.yuminailcore.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.xiaowang.yuminailcore.entity.RefundOrderDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface RefundOrderMapper extends BaseMapper<RefundOrderDO> {
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package com.xiaowang.yuminailcore.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.xiaowang.yuminailcore.entity.UserGrowthRecordDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface UserGrowthRecordMapper extends BaseMapper<UserGrowthRecordDO> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.xiaowang.yuminailcore.service;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.dto.AfterSaleApplyDTO;
|
||||||
|
import com.xiaowang.yuminailcore.dto.AfterSaleAuditDTO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.AfterSaleVO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||||
|
|
||||||
|
public interface AfterSaleService {
|
||||||
|
AfterSaleVO apply(Long userId, AfterSaleApplyDTO dto);
|
||||||
|
|
||||||
|
PageResultVO<AfterSaleVO> listMy(Long userId, Integer page, Integer size);
|
||||||
|
|
||||||
|
PageResultVO<AfterSaleVO> listAdmin(Long shopId, String status, Integer page, Integer size);
|
||||||
|
|
||||||
|
AfterSaleVO approve(Long operatorId, Long afterSaleId, AfterSaleAuditDTO dto);
|
||||||
|
|
||||||
|
AfterSaleVO reject(Long operatorId, Long afterSaleId, AfterSaleAuditDTO dto);
|
||||||
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
package com.xiaowang.yuminailcore.service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
public interface AppointmentCapacityService {
|
||||||
|
void reserveOrThrow(Long orderId, Long orderItemId, Long shopId, Long artistId, String productTitle,
|
||||||
|
LocalDateTime startTime, LocalDateTime endTime);
|
||||||
|
|
||||||
|
void releaseByOrder(Long orderId);
|
||||||
|
|
||||||
|
void moveReservationForArtistChange(Long orderId, Long orderItemId, Long shopId, Long fromArtistId,
|
||||||
|
Long toArtistId, String productTitle,
|
||||||
|
LocalDateTime startTime, LocalDateTime endTime);
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
package com.xiaowang.yuminailcore.service;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.dto.ArtistScheduleDTO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.ArtistScheduleVO;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ArtistScheduleService {
|
||||||
|
ArtistScheduleVO saveSchedule(ArtistScheduleDTO dto);
|
||||||
|
|
||||||
|
List<ArtistScheduleVO> listSchedules(Long shopId, Long artistId, LocalDate startDate, LocalDate endDate);
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.xiaowang.yuminailcore.service;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.dto.CampaignDTO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.CampaignVO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||||
|
|
||||||
|
public interface CampaignService {
|
||||||
|
CampaignVO saveCampaign(CampaignDTO dto);
|
||||||
|
|
||||||
|
PageResultVO<CampaignVO> listCampaigns(Long shopId, Integer status, Integer page, Integer size);
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.xiaowang.yuminailcore.service;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.vo.GrowthSummaryVO;
|
||||||
|
|
||||||
|
public interface GrowthService {
|
||||||
|
GrowthSummaryVO getSummary(Long userId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.xiaowang.yuminailcore.service;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.dto.InventoryAdjustDTO;
|
||||||
|
import com.xiaowang.yuminailcore.dto.InventoryItemDTO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.InventoryItemVO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||||
|
|
||||||
|
public interface InventoryService {
|
||||||
|
InventoryItemVO saveItem(InventoryItemDTO dto);
|
||||||
|
|
||||||
|
InventoryItemVO adjustStock(Long operatorId, Long itemId, InventoryAdjustDTO dto);
|
||||||
|
|
||||||
|
PageResultVO<InventoryItemVO> listItems(Long shopId, Integer page, Integer size);
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
package com.xiaowang.yuminailcore.service;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.vo.OperationsAnalyticsVO;
|
||||||
|
|
||||||
|
public interface OperationsAnalyticsService {
|
||||||
|
OperationsAnalyticsVO getDashboardAnalytics(Long shopId, Long artistId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.xiaowang.yuminailcore.service;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.vo.PaymentOrderVO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.RefundOrderVO;
|
||||||
|
|
||||||
|
public interface PaymentService {
|
||||||
|
PaymentOrderVO prepareOrderPayment(Long userId, Long orderId);
|
||||||
|
|
||||||
|
PaymentOrderVO manualConfirmOrderPaid(Long operatorId, Long orderId, String remark);
|
||||||
|
|
||||||
|
RefundOrderVO manualRefundOrder(Long operatorId, Long orderId, Long afterSaleId, String remark);
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.xiaowang.yuminailcore.service;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.vo.StoreWorkbenchVO;
|
||||||
|
|
||||||
|
public interface WorkbenchService {
|
||||||
|
StoreWorkbenchVO getWorkbench(Long shopId, Long artistId);
|
||||||
|
}
|
||||||
+168
@@ -0,0 +1,168 @@
|
|||||||
|
package com.xiaowang.yuminailcore.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.xiaowang.yuminailcore.dto.AfterSaleApplyDTO;
|
||||||
|
import com.xiaowang.yuminailcore.dto.AfterSaleAuditDTO;
|
||||||
|
import com.xiaowang.yuminailcore.entity.AfterSaleDO;
|
||||||
|
import com.xiaowang.yuminailcore.entity.AfterSaleLogDO;
|
||||||
|
import com.xiaowang.yuminailcore.entity.OrderDO;
|
||||||
|
import com.xiaowang.yuminailcore.entity.SystemMessageDO;
|
||||||
|
import com.xiaowang.yuminailcore.mapper.AfterSaleLogMapper;
|
||||||
|
import com.xiaowang.yuminailcore.mapper.AfterSaleMapper;
|
||||||
|
import com.xiaowang.yuminailcore.mapper.OrderMapper;
|
||||||
|
import com.xiaowang.yuminailcore.mapper.SystemMessageMapper;
|
||||||
|
import com.xiaowang.yuminailcore.service.AfterSaleService;
|
||||||
|
import com.xiaowang.yuminailcore.vo.AfterSaleVO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AfterSaleServiceImpl implements AfterSaleService {
|
||||||
|
|
||||||
|
private static final String STATUS_PENDING = "PENDING";
|
||||||
|
private static final String STATUS_APPROVED = "APPROVED";
|
||||||
|
private static final String STATUS_REJECTED = "REJECTED";
|
||||||
|
|
||||||
|
private final AfterSaleMapper afterSaleMapper;
|
||||||
|
private final AfterSaleLogMapper afterSaleLogMapper;
|
||||||
|
private final OrderMapper orderMapper;
|
||||||
|
private final SystemMessageMapper systemMessageMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public AfterSaleVO apply(Long userId, AfterSaleApplyDTO dto) {
|
||||||
|
if (dto == null || dto.getOrderId() == null) {
|
||||||
|
throw new RuntimeException("售后订单信息不完整");
|
||||||
|
}
|
||||||
|
OrderDO order = orderMapper.selectById(dto.getOrderId());
|
||||||
|
if (order == null || Integer.valueOf(1).equals(order.getIsDelete())) {
|
||||||
|
throw new RuntimeException("订单不存在");
|
||||||
|
}
|
||||||
|
if (!order.getUserId().equals(userId)) {
|
||||||
|
throw new RuntimeException("无权申请该订单售后");
|
||||||
|
}
|
||||||
|
AfterSaleDO afterSale = new AfterSaleDO();
|
||||||
|
afterSale.setAfterSaleNo("AS" + System.currentTimeMillis() + dto.getOrderId());
|
||||||
|
afterSale.setOrderId(order.getId());
|
||||||
|
afterSale.setOrderItemId(dto.getOrderItemId());
|
||||||
|
afterSale.setUserId(userId);
|
||||||
|
afterSale.setShopId(order.getShopId());
|
||||||
|
afterSale.setType(dto.getType());
|
||||||
|
afterSale.setReason(dto.getReason());
|
||||||
|
afterSale.setRefundAmount(dto.getRefundAmount());
|
||||||
|
afterSale.setStatus(STATUS_PENDING);
|
||||||
|
afterSale.setIsDelete(0);
|
||||||
|
afterSaleMapper.insert(afterSale);
|
||||||
|
writeLog(afterSale.getId(), "CREATE", null, STATUS_PENDING, userId, "USER", dto.getReason());
|
||||||
|
return toVO(afterSale);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResultVO<AfterSaleVO> listMy(Long userId, Integer page, Integer size) {
|
||||||
|
return pageByWrapper(new LambdaQueryWrapper<AfterSaleDO>()
|
||||||
|
.eq(AfterSaleDO::getUserId, userId)
|
||||||
|
.eq(AfterSaleDO::getIsDelete, 0)
|
||||||
|
.orderByDesc(AfterSaleDO::getCreateTime), page, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResultVO<AfterSaleVO> listAdmin(Long shopId, String status, Integer page, Integer size) {
|
||||||
|
LambdaQueryWrapper<AfterSaleDO> wrapper = new LambdaQueryWrapper<AfterSaleDO>()
|
||||||
|
.eq(AfterSaleDO::getIsDelete, 0)
|
||||||
|
.orderByDesc(AfterSaleDO::getCreateTime);
|
||||||
|
if (shopId != null) {
|
||||||
|
wrapper.eq(AfterSaleDO::getShopId, shopId);
|
||||||
|
}
|
||||||
|
if (status != null && !status.isBlank()) {
|
||||||
|
wrapper.eq(AfterSaleDO::getStatus, status);
|
||||||
|
}
|
||||||
|
return pageByWrapper(wrapper, page, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public AfterSaleVO approve(Long operatorId, Long afterSaleId, AfterSaleAuditDTO dto) {
|
||||||
|
return audit(operatorId, afterSaleId, dto, STATUS_APPROVED, "APPROVE");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public AfterSaleVO reject(Long operatorId, Long afterSaleId, AfterSaleAuditDTO dto) {
|
||||||
|
return audit(operatorId, afterSaleId, dto, STATUS_REJECTED, "REJECT");
|
||||||
|
}
|
||||||
|
|
||||||
|
private AfterSaleVO audit(Long operatorId, Long afterSaleId, AfterSaleAuditDTO dto, String targetStatus, String action) {
|
||||||
|
AfterSaleDO afterSale = afterSaleMapper.selectById(afterSaleId);
|
||||||
|
if (afterSale == null || Integer.valueOf(1).equals(afterSale.getIsDelete())) {
|
||||||
|
throw new RuntimeException("售后单不存在");
|
||||||
|
}
|
||||||
|
if (!STATUS_PENDING.equals(afterSale.getStatus())) {
|
||||||
|
throw new RuntimeException("售后单已处理");
|
||||||
|
}
|
||||||
|
String fromStatus = afterSale.getStatus();
|
||||||
|
afterSale.setStatus(targetStatus);
|
||||||
|
afterSale.setAuditUserId(operatorId);
|
||||||
|
afterSale.setAuditReason(dto == null ? null : dto.getAuditReason());
|
||||||
|
afterSale.setAuditTime(LocalDateTime.now());
|
||||||
|
afterSaleMapper.updateById(afterSale);
|
||||||
|
writeLog(afterSale.getId(), action, fromStatus, targetStatus, operatorId, "ADMIN", afterSale.getAuditReason());
|
||||||
|
notifyCustomer(afterSale, targetStatus);
|
||||||
|
return toVO(afterSale);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeLog(Long afterSaleId, String action, String fromStatus, String toStatus,
|
||||||
|
Long operatorId, String operatorType, String remark) {
|
||||||
|
AfterSaleLogDO log = new AfterSaleLogDO();
|
||||||
|
log.setAfterSaleId(afterSaleId);
|
||||||
|
log.setAction(action);
|
||||||
|
log.setFromStatus(fromStatus);
|
||||||
|
log.setToStatus(toStatus);
|
||||||
|
log.setOperatorId(operatorId);
|
||||||
|
log.setOperatorType(operatorType);
|
||||||
|
log.setRemark(remark);
|
||||||
|
afterSaleLogMapper.insert(log);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyCustomer(AfterSaleDO afterSale, String status) {
|
||||||
|
SystemMessageDO message = new SystemMessageDO();
|
||||||
|
message.setTitle("售后处理进度更新");
|
||||||
|
message.setContent("您的售后申请已更新为:" + status);
|
||||||
|
message.setTargetType("SELECTED_USERS");
|
||||||
|
message.setTargetIds(String.valueOf(afterSale.getUserId()));
|
||||||
|
message.setBusinessType("AFTER_SALE_" + status);
|
||||||
|
message.setBusinessId(afterSale.getId());
|
||||||
|
message.setActionPath("/after-sales?afterSaleId=" + afterSale.getId());
|
||||||
|
message.setPopupEnabled(1);
|
||||||
|
message.setStatus(1);
|
||||||
|
message.setPublishTime(LocalDateTime.now());
|
||||||
|
message.setIsDelete(0);
|
||||||
|
systemMessageMapper.insert(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PageResultVO<AfterSaleVO> pageByWrapper(LambdaQueryWrapper<AfterSaleDO> wrapper, Integer page, Integer size) {
|
||||||
|
int current = page == null || page < 1 ? 1 : page;
|
||||||
|
int pageSize = size == null || size < 1 ? 10 : size;
|
||||||
|
Page<AfterSaleDO> result = afterSaleMapper.selectPage(new Page<>(current, pageSize), wrapper);
|
||||||
|
PageResultVO<AfterSaleVO> vo = new PageResultVO<>();
|
||||||
|
List<AfterSaleVO> list = result.getRecords().stream().map(this::toVO).toList();
|
||||||
|
vo.setList(list);
|
||||||
|
vo.setTotal(result.getTotal());
|
||||||
|
vo.setPage(current);
|
||||||
|
vo.setSize(pageSize);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private AfterSaleVO toVO(AfterSaleDO afterSale) {
|
||||||
|
AfterSaleVO vo = new AfterSaleVO();
|
||||||
|
BeanUtils.copyProperties(afterSale, vo);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
}
|
||||||
+106
@@ -0,0 +1,106 @@
|
|||||||
|
package com.xiaowang.yuminailcore.service.impl;
|
||||||
|
|
||||||
|
import com.xiaowang.yuminailcore.entity.AppointmentReservationDO;
|
||||||
|
import com.xiaowang.yuminailcore.entity.ArtistScheduleDO;
|
||||||
|
import com.xiaowang.yuminailcore.mapper.AppointmentReservationMapper;
|
||||||
|
import com.xiaowang.yuminailcore.mapper.ArtistScheduleMapper;
|
||||||
|
import com.xiaowang.yuminailcore.service.AppointmentCapacityService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AppointmentCapacityServiceImpl implements AppointmentCapacityService {
|
||||||
|
|
||||||
|
private static final int MIN_CAPACITY = 1;
|
||||||
|
private static final String STATUS_CONFIRMED = "CONFIRMED";
|
||||||
|
private static final String STATUS_RELEASED = "RELEASED";
|
||||||
|
private static final String UNAVAILABLE_MESSAGE = "涓嶅彲棰勭害";
|
||||||
|
private static final String FULL_MESSAGE = "褰撳墠缇庣敳甯堣鏃堕棿娈靛凡绾︽弧锛岃閲嶆柊閫夋嫨棰勭害鏃堕棿";
|
||||||
|
|
||||||
|
private final AppointmentReservationMapper reservationMapper;
|
||||||
|
private final ArtistScheduleMapper scheduleMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void reserveOrThrow(Long orderId, Long orderItemId, Long shopId, Long artistId, String productTitle,
|
||||||
|
LocalDateTime startTime, LocalDateTime endTime) {
|
||||||
|
if (orderId == null || orderItemId == null || shopId == null || artistId == null || startTime == null || endTime == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
assertCapacityAvailable(shopId, artistId, null, startTime, endTime);
|
||||||
|
AppointmentReservationDO reservation = new AppointmentReservationDO();
|
||||||
|
reservation.setOrderId(orderId);
|
||||||
|
reservation.setOrderItemId(orderItemId);
|
||||||
|
reservation.setShopId(shopId);
|
||||||
|
reservation.setArtistId(artistId);
|
||||||
|
reservation.setProductTitle(productTitle);
|
||||||
|
reservation.setAppointmentStartTime(startTime);
|
||||||
|
reservation.setAppointmentEndTime(endTime);
|
||||||
|
reservation.setStatus(STATUS_CONFIRMED);
|
||||||
|
reservation.setIsDelete(0);
|
||||||
|
reservationMapper.insert(reservation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void releaseByOrder(Long orderId) {
|
||||||
|
if (orderId != null) {
|
||||||
|
reservationMapper.releaseByOrderId(orderId, STATUS_RELEASED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void moveReservationForArtistChange(Long orderId, Long orderItemId, Long shopId, Long fromArtistId,
|
||||||
|
Long toArtistId, String productTitle,
|
||||||
|
LocalDateTime startTime, LocalDateTime endTime) {
|
||||||
|
if (orderItemId == null || orderId == null || shopId == null || toArtistId == null || startTime == null || endTime == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
assertCapacityAvailable(shopId, toArtistId, orderItemId, startTime, endTime);
|
||||||
|
int updated = reservationMapper.updateActiveReservationForOrderItem(
|
||||||
|
orderItemId,
|
||||||
|
orderId,
|
||||||
|
shopId,
|
||||||
|
toArtistId,
|
||||||
|
productTitle,
|
||||||
|
startTime,
|
||||||
|
endTime,
|
||||||
|
STATUS_CONFIRMED
|
||||||
|
);
|
||||||
|
if (updated == 0) {
|
||||||
|
reserveOrThrow(orderId, orderItemId, shopId, toArtistId, productTitle, startTime, endTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertCapacityAvailable(Long shopId, Long artistId, Long excludedOrderItemId,
|
||||||
|
LocalDateTime startTime, LocalDateTime endTime) {
|
||||||
|
int capacity = resolveCapacity(shopId, artistId, startTime, endTime);
|
||||||
|
int used = excludedOrderItemId == null
|
||||||
|
? reservationMapper.countOverlappingActiveForUpdate(artistId, startTime, endTime)
|
||||||
|
: reservationMapper.countOverlappingActiveForUpdateExcludingOrderItem(artistId, excludedOrderItemId, startTime, endTime);
|
||||||
|
if (used >= capacity) {
|
||||||
|
throw new RuntimeException(FULL_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int resolveCapacity(Long shopId, Long artistId, LocalDateTime startTime, LocalDateTime endTime) {
|
||||||
|
ArtistScheduleDO schedule = scheduleMapper.selectCoveringSchedule(
|
||||||
|
shopId,
|
||||||
|
artistId,
|
||||||
|
startTime.toLocalDate(),
|
||||||
|
startTime.toLocalTime(),
|
||||||
|
endTime.toLocalTime()
|
||||||
|
);
|
||||||
|
if (schedule == null || Integer.valueOf(1).equals(schedule.getIsDelete())
|
||||||
|
|| !Integer.valueOf(1).equals(schedule.getStatus())
|
||||||
|
|| schedule.getCapacity() == null || schedule.getCapacity() < MIN_CAPACITY) {
|
||||||
|
throw new RuntimeException(UNAVAILABLE_MESSAGE);
|
||||||
|
}
|
||||||
|
return schedule.getCapacity();
|
||||||
|
}
|
||||||
|
}
|
||||||
+66
@@ -0,0 +1,66 @@
|
|||||||
|
package com.xiaowang.yuminailcore.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.xiaowang.yuminailcore.dto.ArtistScheduleDTO;
|
||||||
|
import com.xiaowang.yuminailcore.entity.ArtistScheduleDO;
|
||||||
|
import com.xiaowang.yuminailcore.mapper.ArtistScheduleMapper;
|
||||||
|
import com.xiaowang.yuminailcore.service.ArtistScheduleService;
|
||||||
|
import com.xiaowang.yuminailcore.vo.ArtistScheduleVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ArtistScheduleServiceImpl implements ArtistScheduleService {
|
||||||
|
|
||||||
|
private final ArtistScheduleMapper artistScheduleMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public ArtistScheduleVO saveSchedule(ArtistScheduleDTO dto) {
|
||||||
|
if (dto == null || dto.getShopId() == null || dto.getArtistId() == null || dto.getWorkDate() == null
|
||||||
|
|| dto.getStartTime() == null || dto.getEndTime() == null) {
|
||||||
|
throw new RuntimeException("排班信息不完整");
|
||||||
|
}
|
||||||
|
ArtistScheduleDO schedule = new ArtistScheduleDO();
|
||||||
|
BeanUtils.copyProperties(dto, schedule);
|
||||||
|
schedule.setSlotMinutes(dto.getSlotMinutes() == null ? 60 : dto.getSlotMinutes());
|
||||||
|
schedule.setCapacity(dto.getCapacity() == null || dto.getCapacity() < 1 ? 1 : dto.getCapacity());
|
||||||
|
schedule.setStatus(dto.getStatus() == null ? 1 : dto.getStatus());
|
||||||
|
schedule.setIsDelete(0);
|
||||||
|
artistScheduleMapper.insert(schedule);
|
||||||
|
return toVO(schedule);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ArtistScheduleVO> listSchedules(Long shopId, Long artistId, LocalDate startDate, LocalDate endDate) {
|
||||||
|
LambdaQueryWrapper<ArtistScheduleDO> wrapper = new LambdaQueryWrapper<ArtistScheduleDO>()
|
||||||
|
.eq(ArtistScheduleDO::getIsDelete, 0)
|
||||||
|
.orderByAsc(ArtistScheduleDO::getWorkDate)
|
||||||
|
.orderByAsc(ArtistScheduleDO::getStartTime);
|
||||||
|
if (shopId != null) {
|
||||||
|
wrapper.eq(ArtistScheduleDO::getShopId, shopId);
|
||||||
|
}
|
||||||
|
if (artistId != null) {
|
||||||
|
wrapper.eq(ArtistScheduleDO::getArtistId, artistId);
|
||||||
|
}
|
||||||
|
if (startDate != null) {
|
||||||
|
wrapper.ge(ArtistScheduleDO::getWorkDate, startDate);
|
||||||
|
}
|
||||||
|
if (endDate != null) {
|
||||||
|
wrapper.le(ArtistScheduleDO::getWorkDate, endDate);
|
||||||
|
}
|
||||||
|
return artistScheduleMapper.selectList(wrapper).stream().map(this::toVO).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArtistScheduleVO toVO(ArtistScheduleDO schedule) {
|
||||||
|
ArtistScheduleVO vo = new ArtistScheduleVO();
|
||||||
|
BeanUtils.copyProperties(schedule, vo);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -47,7 +47,7 @@ public class BusinessEventOutboxProcessor {
|
|||||||
*/
|
*/
|
||||||
private final OrderServiceImpl orderService;
|
private final OrderServiceImpl orderService;
|
||||||
|
|
||||||
@Scheduled(fixedDelay = 10000L)
|
@Scheduled(fixedDelay = 2000L)
|
||||||
@Transactional
|
@Transactional
|
||||||
/**
|
/**
|
||||||
* Purpose: processDueEvents supports BusinessEventOutboxProcessor.java by holding or executing the process due events business role.
|
* Purpose: processDueEvents supports BusinessEventOutboxProcessor.java by holding or executing the process due events business role.
|
||||||
|
|||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
package com.xiaowang.yuminailcore.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.xiaowang.yuminailcore.dto.CampaignDTO;
|
||||||
|
import com.xiaowang.yuminailcore.entity.CampaignDO;
|
||||||
|
import com.xiaowang.yuminailcore.mapper.CampaignMapper;
|
||||||
|
import com.xiaowang.yuminailcore.service.CampaignService;
|
||||||
|
import com.xiaowang.yuminailcore.vo.CampaignVO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class CampaignServiceImpl implements CampaignService {
|
||||||
|
|
||||||
|
private final CampaignMapper campaignMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public CampaignVO saveCampaign(CampaignDTO dto) {
|
||||||
|
if (dto == null || dto.getTitle() == null || dto.getTitle().isBlank()) {
|
||||||
|
throw new RuntimeException("活动标题不能为空");
|
||||||
|
}
|
||||||
|
CampaignDO campaign = new CampaignDO();
|
||||||
|
BeanUtils.copyProperties(dto, campaign);
|
||||||
|
campaign.setStatus(dto.getStatus() == null ? 1 : dto.getStatus());
|
||||||
|
campaign.setSortOrder(dto.getSortOrder() == null ? 0 : dto.getSortOrder());
|
||||||
|
campaign.setIsDelete(0);
|
||||||
|
campaignMapper.insert(campaign);
|
||||||
|
return toVO(campaign);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResultVO<CampaignVO> listCampaigns(Long shopId, Integer status, Integer page, Integer size) {
|
||||||
|
int current = page == null || page < 1 ? 1 : page;
|
||||||
|
int pageSize = size == null || size < 1 ? 10 : size;
|
||||||
|
LambdaQueryWrapper<CampaignDO> wrapper = new LambdaQueryWrapper<CampaignDO>()
|
||||||
|
.eq(CampaignDO::getIsDelete, 0)
|
||||||
|
.orderByAsc(CampaignDO::getSortOrder)
|
||||||
|
.orderByDesc(CampaignDO::getCreateTime);
|
||||||
|
if (shopId != null) {
|
||||||
|
wrapper.eq(CampaignDO::getShopId, shopId);
|
||||||
|
}
|
||||||
|
if (status != null) {
|
||||||
|
wrapper.eq(CampaignDO::getStatus, status);
|
||||||
|
}
|
||||||
|
Page<CampaignDO> result = campaignMapper.selectPage(new Page<>(current, pageSize), wrapper);
|
||||||
|
PageResultVO<CampaignVO> vo = new PageResultVO<>();
|
||||||
|
vo.setList(result.getRecords().stream().map(this::toVO).toList());
|
||||||
|
vo.setTotal(result.getTotal());
|
||||||
|
vo.setPage(current);
|
||||||
|
vo.setSize(pageSize);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private CampaignVO toVO(CampaignDO campaign) {
|
||||||
|
CampaignVO vo = new CampaignVO();
|
||||||
|
BeanUtils.copyProperties(campaign, vo);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
}
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
package com.xiaowang.yuminailcore.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.xiaowang.yuminailcore.entity.UserGrowthRecordDO;
|
||||||
|
import com.xiaowang.yuminailcore.mapper.UserGrowthRecordMapper;
|
||||||
|
import com.xiaowang.yuminailcore.service.GrowthService;
|
||||||
|
import com.xiaowang.yuminailcore.vo.GrowthSummaryVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GrowthServiceImpl implements GrowthService {
|
||||||
|
|
||||||
|
private final UserGrowthRecordMapper userGrowthRecordMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GrowthSummaryVO getSummary(Long userId) {
|
||||||
|
Integer growthValue = userGrowthRecordMapper.selectList(new LambdaQueryWrapper<UserGrowthRecordDO>()
|
||||||
|
.eq(UserGrowthRecordDO::getUserId, userId))
|
||||||
|
.stream()
|
||||||
|
.map(UserGrowthRecordDO::getGrowthValue)
|
||||||
|
.filter(value -> value != null)
|
||||||
|
.reduce(0, Integer::sum);
|
||||||
|
GrowthSummaryVO vo = new GrowthSummaryVO();
|
||||||
|
vo.setUserId(userId);
|
||||||
|
vo.setGrowthValue(growthValue);
|
||||||
|
vo.setLevelName(growthValue >= 1000 ? "黄金会员" : growthValue >= 300 ? "白银会员" : "成长新客");
|
||||||
|
vo.setAppointmentCount(0);
|
||||||
|
vo.setReviewCount(0);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
}
|
||||||
+99
@@ -0,0 +1,99 @@
|
|||||||
|
package com.xiaowang.yuminailcore.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.xiaowang.yuminailcore.dto.InventoryAdjustDTO;
|
||||||
|
import com.xiaowang.yuminailcore.dto.InventoryItemDTO;
|
||||||
|
import com.xiaowang.yuminailcore.entity.InventoryItemDO;
|
||||||
|
import com.xiaowang.yuminailcore.entity.InventoryRecordDO;
|
||||||
|
import com.xiaowang.yuminailcore.mapper.InventoryItemMapper;
|
||||||
|
import com.xiaowang.yuminailcore.mapper.InventoryRecordMapper;
|
||||||
|
import com.xiaowang.yuminailcore.service.InventoryService;
|
||||||
|
import com.xiaowang.yuminailcore.vo.InventoryItemVO;
|
||||||
|
import com.xiaowang.yuminailcore.vo.PageResultVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class InventoryServiceImpl implements InventoryService {
|
||||||
|
|
||||||
|
private final InventoryItemMapper inventoryItemMapper;
|
||||||
|
private final InventoryRecordMapper inventoryRecordMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public InventoryItemVO saveItem(InventoryItemDTO dto) {
|
||||||
|
if (dto == null || dto.getShopId() == null || dto.getItemName() == null || dto.getItemName().isBlank()) {
|
||||||
|
throw new RuntimeException("库存物料信息不完整");
|
||||||
|
}
|
||||||
|
InventoryItemDO item = new InventoryItemDO();
|
||||||
|
BeanUtils.copyProperties(dto, item);
|
||||||
|
item.setStockQuantity(dto.getStockQuantity() == null ? BigDecimal.ZERO : dto.getStockQuantity());
|
||||||
|
item.setWarningThreshold(dto.getWarningThreshold() == null ? BigDecimal.ZERO : dto.getWarningThreshold());
|
||||||
|
item.setStatus(dto.getStatus() == null ? 1 : dto.getStatus());
|
||||||
|
item.setIsDelete(0);
|
||||||
|
inventoryItemMapper.insert(item);
|
||||||
|
return toVO(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public InventoryItemVO adjustStock(Long operatorId, Long itemId, InventoryAdjustDTO dto) {
|
||||||
|
InventoryItemDO item = inventoryItemMapper.selectById(itemId);
|
||||||
|
if (item == null || Integer.valueOf(1).equals(item.getIsDelete())) {
|
||||||
|
throw new RuntimeException("库存物料不存在");
|
||||||
|
}
|
||||||
|
BigDecimal before = item.getStockQuantity() == null ? BigDecimal.ZERO : item.getStockQuantity();
|
||||||
|
BigDecimal delta = dto == null || dto.getChangeQuantity() == null ? BigDecimal.ZERO : dto.getChangeQuantity();
|
||||||
|
BigDecimal after = before.add(delta);
|
||||||
|
if (after.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
|
throw new RuntimeException("库存不能小于 0");
|
||||||
|
}
|
||||||
|
item.setStockQuantity(after);
|
||||||
|
inventoryItemMapper.updateById(item);
|
||||||
|
InventoryRecordDO record = new InventoryRecordDO();
|
||||||
|
record.setInventoryItemId(item.getId());
|
||||||
|
record.setShopId(item.getShopId());
|
||||||
|
record.setChangeType(dto == null ? null : dto.getChangeType());
|
||||||
|
record.setChangeQuantity(delta);
|
||||||
|
record.setBeforeQuantity(before);
|
||||||
|
record.setAfterQuantity(after);
|
||||||
|
record.setOperatorId(operatorId);
|
||||||
|
record.setRemark(dto == null ? null : dto.getRemark());
|
||||||
|
inventoryRecordMapper.insert(record);
|
||||||
|
return toVO(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResultVO<InventoryItemVO> listItems(Long shopId, Integer page, Integer size) {
|
||||||
|
int current = page == null || page < 1 ? 1 : page;
|
||||||
|
int pageSize = size == null || size < 1 ? 10 : size;
|
||||||
|
LambdaQueryWrapper<InventoryItemDO> wrapper = new LambdaQueryWrapper<InventoryItemDO>()
|
||||||
|
.eq(InventoryItemDO::getIsDelete, 0)
|
||||||
|
.orderByDesc(InventoryItemDO::getCreateTime);
|
||||||
|
if (shopId != null) {
|
||||||
|
wrapper.eq(InventoryItemDO::getShopId, shopId);
|
||||||
|
}
|
||||||
|
Page<InventoryItemDO> result = inventoryItemMapper.selectPage(new Page<>(current, pageSize), wrapper);
|
||||||
|
PageResultVO<InventoryItemVO> vo = new PageResultVO<>();
|
||||||
|
vo.setList(result.getRecords().stream().map(this::toVO).toList());
|
||||||
|
vo.setTotal(result.getTotal());
|
||||||
|
vo.setPage(current);
|
||||||
|
vo.setSize(pageSize);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private InventoryItemVO toVO(InventoryItemDO item) {
|
||||||
|
InventoryItemVO vo = new InventoryItemVO();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
BigDecimal stock = item.getStockQuantity() == null ? BigDecimal.ZERO : item.getStockQuantity();
|
||||||
|
BigDecimal warning = item.getWarningThreshold() == null ? BigDecimal.ZERO : item.getWarningThreshold();
|
||||||
|
vo.setWarning(stock.compareTo(warning) <= 0);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
}
|
||||||
+56
@@ -3,6 +3,7 @@ package com.xiaowang.yuminailcore.service.impl;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.xiaowang.yuminailcore.dto.NailArtistInfoDTO;
|
import com.xiaowang.yuminailcore.dto.NailArtistInfoDTO;
|
||||||
|
import com.xiaowang.yuminailcore.entity.ArtistScheduleDO;
|
||||||
import com.xiaowang.yuminailcore.entity.NailArtistInfoDO;
|
import com.xiaowang.yuminailcore.entity.NailArtistInfoDO;
|
||||||
import com.xiaowang.yuminailcore.entity.OrderArtistReviewDO;
|
import com.xiaowang.yuminailcore.entity.OrderArtistReviewDO;
|
||||||
import com.xiaowang.yuminailcore.entity.OrderDO;
|
import com.xiaowang.yuminailcore.entity.OrderDO;
|
||||||
@@ -11,6 +12,8 @@ import com.xiaowang.yuminailcore.entity.ProductDO;
|
|||||||
import com.xiaowang.yuminailcore.entity.ShopDO;
|
import com.xiaowang.yuminailcore.entity.ShopDO;
|
||||||
import com.xiaowang.yuminailcore.entity.UserDO;
|
import com.xiaowang.yuminailcore.entity.UserDO;
|
||||||
import com.xiaowang.yuminailcore.mapper.NailArtistInfoMapper;
|
import com.xiaowang.yuminailcore.mapper.NailArtistInfoMapper;
|
||||||
|
import com.xiaowang.yuminailcore.mapper.AppointmentReservationMapper;
|
||||||
|
import com.xiaowang.yuminailcore.mapper.ArtistScheduleMapper;
|
||||||
import com.xiaowang.yuminailcore.mapper.OrderArtistReviewMapper;
|
import com.xiaowang.yuminailcore.mapper.OrderArtistReviewMapper;
|
||||||
import com.xiaowang.yuminailcore.mapper.OrderItemMapper;
|
import com.xiaowang.yuminailcore.mapper.OrderItemMapper;
|
||||||
import com.xiaowang.yuminailcore.mapper.OrderMapper;
|
import com.xiaowang.yuminailcore.mapper.OrderMapper;
|
||||||
@@ -98,6 +101,12 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ObjectStorageFileService objectStorageFileService;
|
private ObjectStorageFileService objectStorageFileService;
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
private ArtistScheduleMapper artistScheduleMapper;
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
private AppointmentReservationMapper appointmentReservationMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
/**
|
/**
|
||||||
* Load data by the supplied parameter.
|
* Load data by the supplied parameter.
|
||||||
@@ -262,6 +271,11 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
|||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<NailArtistAvailabilityVO> scheduleSlots = buildScheduleAvailabilitySlots(artistId, artistInfo);
|
||||||
|
if (!scheduleSlots.isEmpty()) {
|
||||||
|
return scheduleSlots;
|
||||||
|
}
|
||||||
|
|
||||||
LocalTime workStart = artistInfo.getWorkStartTime() == null ? LocalTime.of(10, 0) : artistInfo.getWorkStartTime();
|
LocalTime workStart = artistInfo.getWorkStartTime() == null ? LocalTime.of(10, 0) : artistInfo.getWorkStartTime();
|
||||||
LocalTime workEnd = artistInfo.getWorkEndTime() == null ? LocalTime.of(20, 0) : artistInfo.getWorkEndTime();
|
LocalTime workEnd = artistInfo.getWorkEndTime() == null ? LocalTime.of(20, 0) : artistInfo.getWorkEndTime();
|
||||||
if (!workEnd.isAfter(workStart)) {
|
if (!workEnd.isAfter(workStart)) {
|
||||||
@@ -291,6 +305,48 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
|||||||
return slots;
|
return slots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<NailArtistAvailabilityVO> buildScheduleAvailabilitySlots(Long artistId, NailArtistInfoDTO artistInfo) {
|
||||||
|
if (artistScheduleMapper == null || artistInfo.getShopId() == null) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
List<ArtistScheduleDO> schedules = artistScheduleMapper.selectList(new LambdaQueryWrapper<ArtistScheduleDO>()
|
||||||
|
.eq(ArtistScheduleDO::getShopId, artistInfo.getShopId())
|
||||||
|
.eq(ArtistScheduleDO::getArtistId, artistId)
|
||||||
|
.eq(ArtistScheduleDO::getStatus, 1)
|
||||||
|
.eq(ArtistScheduleDO::getIsDelete, 0)
|
||||||
|
.ge(ArtistScheduleDO::getWorkDate, today)
|
||||||
|
.lt(ArtistScheduleDO::getWorkDate, today.plusDays(AVAILABILITY_DAYS))
|
||||||
|
.orderByAsc(ArtistScheduleDO::getWorkDate)
|
||||||
|
.orderByAsc(ArtistScheduleDO::getStartTime));
|
||||||
|
if (schedules == null || schedules.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
LocalDateTime minStart = LocalDateTime.now().plusMinutes(30);
|
||||||
|
List<NailArtistAvailabilityVO> slots = new ArrayList<>();
|
||||||
|
for (ArtistScheduleDO schedule : schedules) {
|
||||||
|
int slotMinutes = schedule.getSlotMinutes() == null || schedule.getSlotMinutes() < 15 ? SLOT_MINUTES : schedule.getSlotMinutes();
|
||||||
|
int capacity = schedule.getCapacity() == null || schedule.getCapacity() < 1 ? 1 : schedule.getCapacity();
|
||||||
|
LocalTime cursor = schedule.getStartTime();
|
||||||
|
while (cursor != null && schedule.getEndTime() != null
|
||||||
|
&& !cursor.plusMinutes(slotMinutes).isAfter(schedule.getEndTime())
|
||||||
|
&& slots.size() < MAX_AVAILABILITY_SLOTS) {
|
||||||
|
LocalDateTime slotStart = schedule.getWorkDate().atTime(cursor);
|
||||||
|
LocalDateTime slotEnd = slotStart.plusMinutes(slotMinutes);
|
||||||
|
int used = appointmentReservationMapper == null ? 0
|
||||||
|
: appointmentReservationMapper.countOverlappingActive(artistId, slotStart, slotEnd);
|
||||||
|
if (slotStart.isAfter(minStart) && used < capacity) {
|
||||||
|
slots.add(buildAvailabilitySlot(slotStart, slotEnd));
|
||||||
|
}
|
||||||
|
cursor = cursor.plusMinutes(slotMinutes);
|
||||||
|
}
|
||||||
|
if (slots.size() >= MAX_AVAILABILITY_SLOTS) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return slots;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NailArtistReviewVO> listPublicReviews(Long artistId) {
|
public List<NailArtistReviewVO> listPublicReviews(Long artistId) {
|
||||||
if (artistId == null) {
|
if (artistId == null) {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user