From 7e221e745aec4f6e20478ed288832890adb29271 Mon Sep 17 00:00:00 2001 From: Timi Date: Thu, 12 Nov 2026 16:41:31 +0800 Subject: [PATCH] feat: recycle system --- .idea/gao-customer-h5.iml | 4 +- package.json | 2 +- pnpm-lock.yaml | 10 +- src/api/RecycleAPI.ts | 157 +++- src/assets/styles/global.less | 11 - .../productSelector/ProductSelectPopup.vue | 14 +- .../productSelector/ProductSkuSelector.vue | 2 +- src/layout/MainLayout.vue | 2 +- src/pages/customer/CustomerDataCharts.vue | 13 +- src/pages/customer/CustomerDetail.vue | 324 ++++--- src/pages/customer/CustomerInviteeList.vue | 15 +- src/pages/customer/CustomerList.vue | 17 +- src/pages/dataExport/dataExport.ts | 2 +- .../fulfillment/OrderFulfillmentCreate.vue | 277 +++--- .../fulfillment/OrderFulfillmentDetail.vue | 15 +- .../fulfillment/OrderFulfillmentList.vue | 74 +- .../components/OrderFulfillmentListCell.vue | 29 +- src/pages/package/PackageConfigDetail.vue | 8 +- src/pages/package/PackageConfigEdit.vue | 8 +- src/pages/package/PackageConfigList.vue | 8 +- src/pages/point/PointRedeemSkuEdit.vue | 2 +- src/pages/point/PointRedeemSkuList.vue | 4 +- src/pages/point/PointRedemptionCreate.vue | 2 +- src/pages/point/PointRedemptionDetail.vue | 2 +- src/pages/point/PointRedemptionList.vue | 4 +- src/pages/product/ProductDetail.vue | 214 ++--- src/pages/product/ProductEdit.vue | 6 +- src/pages/product/ProductList.vue | 53 +- src/pages/product/ProductSkuDetail.vue | 380 ++++++++ src/pages/product/ProductStockDetail.vue | 2 +- .../product/ProductStockRecordDetail.vue | 4 +- src/pages/product/ProductStockRecordList.vue | 4 +- src/pages/product/ProductStockSkuList.vue | 4 +- .../product/component/ProductSkuEditor.vue | 4 - .../product/component/ProductSkuUnitList.vue | 11 +- src/pages/recycle/RecycleAccount.vue | 180 ++++ src/pages/recycle/RecycleExchangeCreate.vue | 879 ++++++++++++------ src/pages/recycle/RecycleExchangeDetail.vue | 498 ---------- src/pages/recycle/RecycleExchangeList.vue | 517 ---------- src/pages/recycle/RecycleItemDetail.vue | 104 +++ src/pages/recycle/RecycleItemEdit.vue | 284 +----- src/pages/recycle/RecycleItemList.vue | 242 ++--- src/pages/recycle/RecyclePaymentCreate.vue | 250 +++++ src/pages/recycle/RecyclePaymentDetail.vue | 287 ++++++ src/pages/recycle/RecyclePaymentList.vue | 448 +++++++++ src/pages/recycle/RecyclePaymentRevoke.vue | 224 +++++ src/pages/recycle/RecycleRuleDetail.vue | 180 ++++ src/pages/recycle/RecycleRuleEdit.vue | 505 +++++----- src/pages/recycle/RecycleRuleList.vue | 236 +++-- src/pages/recycle/RecycleStat.vue | 4 +- .../components/RecycleAccountAdjustPopup.vue | 200 ++++ .../components/RecycleExchangeActionPopup.vue | 242 ----- .../components/RecycleExchangeListCell.vue | 239 ----- .../components/RecycleExchangePanel.vue | 295 ++++++ .../components/RecycleItemEditPopup.vue | 28 + .../recycle/components/RecycleItemForm.vue | 159 ++++ .../components/RecycleItemPickerPopup.vue | 163 ++++ .../salesOrder/ConsumptionRecordList.vue | 2 +- src/pages/salesOrder/FundRecordDetail.vue | 10 +- src/pages/salesOrder/FundRecordList.vue | 4 +- src/pages/salesOrder/FundRecordRevoke.vue | 8 +- src/pages/salesOrder/SalesOrderCancel.vue | 25 +- src/pages/salesOrder/SalesOrderCreate.vue | 8 +- src/pages/salesOrder/SalesOrderDetail.vue | 546 ++++++----- src/pages/salesOrder/SalesOrderList.vue | 157 +++- src/pages/salesOrder/SalesOrderNoRefund.vue | 4 +- src/pages/salesOrder/SalesOrderPayment.vue | 6 +- src/pages/salesOrder/SalesOrderRefund.vue | 4 +- .../component/SalesOrderFilterPopup.vue | 18 +- .../component/SalesOrderFilterSummary.vue | 25 +- .../component/SalesOrderListCell.vue | 39 +- .../tabs/component/CustomerEntryPanel.vue | 18 +- .../tabs/component/ProductEntryPanel.vue | 52 +- src/router/routes/chartRoutes.ts | 4 +- src/router/routes/fulfillmentRoutes.ts | 8 +- src/router/routes/packageRoutes.ts | 14 +- src/router/routes/pointRoutes.ts | 12 +- src/router/routes/productRoutes.ts | 32 +- src/router/routes/recycleRoutes.ts | 105 ++- src/router/routes/salesOrderRoutes.ts | 22 +- src/store/pendingNoticeStore.ts | 12 +- src/types/Fulfillment.ts | 8 +- src/types/Recycle.ts | 350 +++++-- src/types/SalesOrder.ts | 15 +- src/types/SalesOrderFilter.ts | 2 +- src/utils/listDataEvents.ts | 2 + src/utils/permission.ts | 24 +- src/utils/product.ts | 4 +- src/utils/recycle.ts | 116 ++- src/utils/salesOrder.ts | 15 +- 90 files changed, 5981 insertions(+), 3542 deletions(-) create mode 100644 src/pages/product/ProductSkuDetail.vue create mode 100644 src/pages/recycle/RecycleAccount.vue delete mode 100644 src/pages/recycle/RecycleExchangeDetail.vue delete mode 100644 src/pages/recycle/RecycleExchangeList.vue create mode 100644 src/pages/recycle/RecycleItemDetail.vue create mode 100644 src/pages/recycle/RecyclePaymentCreate.vue create mode 100644 src/pages/recycle/RecyclePaymentDetail.vue create mode 100644 src/pages/recycle/RecyclePaymentList.vue create mode 100644 src/pages/recycle/RecyclePaymentRevoke.vue create mode 100644 src/pages/recycle/RecycleRuleDetail.vue create mode 100644 src/pages/recycle/components/RecycleAccountAdjustPopup.vue delete mode 100644 src/pages/recycle/components/RecycleExchangeActionPopup.vue delete mode 100644 src/pages/recycle/components/RecycleExchangeListCell.vue create mode 100644 src/pages/recycle/components/RecycleExchangePanel.vue create mode 100644 src/pages/recycle/components/RecycleItemEditPopup.vue create mode 100644 src/pages/recycle/components/RecycleItemForm.vue create mode 100644 src/pages/recycle/components/RecycleItemPickerPopup.vue diff --git a/.idea/gao-customer-h5.iml b/.idea/gao-customer-h5.iml index c956989..6c401ba 100644 --- a/.idea/gao-customer-h5.iml +++ b/.idea/gao-customer-h5.iml @@ -1,7 +1,9 @@ - + + + diff --git a/package.json b/package.json index c27fb94..0eaf99e 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "less": "^4.3.0", "pinia": "^3.0.2", "tdesign-mobile-vue": "^1.17.1", - "timi-tdesign-mobile": "^1.0.2", + "timi-tdesign-mobile": "^1.1.1", "timi-ts": "^1.0.0", "timi-web": "^1.0.2", "timi-web-api": "^1.0.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2731625..ff9c0a6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -47,8 +47,8 @@ importers: specifier: ^1.17.1 version: 1.17.1(patch_hash=c98db305008fbfd00046666ca890e1c6cb88257c0619418694689cddf8cd78c3)(vue@3.5.40(typescript@5.8.3)) timi-tdesign-mobile: - specifier: ^1.0.2 - version: 1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue-router@4.5.1(vue@3.5.40(typescript@5.8.3)))(vue@3.5.40(typescript@5.8.3)) + specifier: ^1.1.1 + version: 1.1.1(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue-router@4.5.1(vue@3.5.40(typescript@5.8.3)))(vue@3.5.40(typescript@5.8.3)) timi-ts: specifier: ^1.0.0 version: 1.0.0 @@ -2748,8 +2748,8 @@ packages: through2@4.0.2: resolution: {integrity: sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==} - timi-tdesign-mobile@1.0.2: - resolution: {integrity: sha512-7qjwUUqIjMB9TJbOWguK61JfQ15PLf3gnfUDU1gY2eS4cjbgo/PD2U/eHNV6CZ0VB/hBjPNp84xKZ0qr03tsmw==} + timi-tdesign-mobile@1.1.1: + resolution: {integrity: sha512-aR6SKu8zVbaqHRJHRtria3amvp9UKS6jTT99FNei38ZrP1sJDBsvCoQmWi0xzUD3F/wkGnSECWWrJQToqso6PQ==} engines: {node: '>=20.0.0'} peerDependencies: vue: ^3.5.0 @@ -5849,7 +5849,7 @@ snapshots: dependencies: readable-stream: 3.6.2 - timi-tdesign-mobile@1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue-router@4.5.1(vue@3.5.40(typescript@5.8.3)))(vue@3.5.40(typescript@5.8.3)): + timi-tdesign-mobile@1.1.1(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue-router@4.5.1(vue@3.5.40(typescript@5.8.3)))(vue@3.5.40(typescript@5.8.3)): dependencies: tdesign-mobile-vue: 1.17.1(patch_hash=c98db305008fbfd00046666ca890e1c6cb88257c0619418694689cddf8cd78c3)(vue@3.5.40(typescript@5.8.3)) timi-web: 1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3)) diff --git a/src/api/RecycleAPI.ts b/src/api/RecycleAPI.ts index 18a1a57..57def7d 100644 --- a/src/api/RecycleAPI.ts +++ b/src/api/RecycleAPI.ts @@ -1,16 +1,22 @@ import { axios } from "timi-web-api"; import type { + OrderTransaction, + RecycleAccount, + RecycleAccountAdjustRequest, RecycleExchange, - RecycleExchangeActionRequest, RecycleExchangeCreateRequest, RecycleExchangeDetail, - RecycleExchangePage, RecycleExchangeRule, RecycleExchangeRulePage, RecycleExchangeStatRow, RecycleItem, RecycleItemPage, + RecycleLedger, RecyclePageResult, + RecyclePayment, + RecyclePaymentRequest, + RecycleProductYield, + RecycleRuleRequest, RecycleStatRow } from "@/types/Recycle"; import { pendingNoticeEvents } from "@/utils/pendingNoticeEvents"; @@ -18,6 +24,8 @@ import { getCurrentStoreId, withCurrentStoreId } from "@/utils/store"; const CONFIG_URI = "/gao/recycle/config"; const EXCHANGE_URI = "/gao/recycle/exchange"; +const ACCOUNT_URI = "/gao/recycle/account"; +const PAYMENT_URI = "/gao/recycle/payment"; const STAT_URI = "/gao/recycle/stat"; /** 配置接口的 storeId 走查询参数,可省略时由后端按登录用户门店范围解析。 */ @@ -46,7 +54,7 @@ async function itemList(page: RecycleItemPage): Promise { return await axios.post(`${CONFIG_URI}/item/detail`, undefined, { params: { storeId: getCurrentStoreId() || undefined, id } @@ -75,11 +83,18 @@ async function ruleDetail(id: string): Promise { }); } -/** 保存规则配置:新增不传 id,修改必须提交完整配置。 */ -async function ruleSave(rule: RecycleExchangeRule): Promise { +/** 保存模板:新增不传 id,修改必须提交完整明细。 */ +async function ruleSave(rule: RecycleRuleRequest): Promise { return await axios.post(`${CONFIG_URI}/rule/save`, withCurrentStoreId(rule)); } +/** 删除模板。已创建的兑换单保存了快照,不依赖模板继续履约。 */ +async function ruleDelete(id: string): Promise { + await axios.post(`${CONFIG_URI}/rule/delete`, undefined, { + params: { storeId: getCurrentStoreId() || undefined, id } + }); +} + // ---------- 兑换单 ---------- /** 创建兑换单。requestNo 为幂等号,重试必须原样复用。 */ @@ -88,34 +103,109 @@ async function create(request: RecycleExchangeCreateRequest): Promise> { - return await axios.post(`${EXCHANGE_URI}/page`, withCurrentStoreId(request)); -} - +/** 兑换单详情。兑换单列表已并入交易订单查询,这里只保留详情与动作。 */ async function detail(id: string): Promise { return await axios.post(`${EXCHANGE_URI}/detail`, undefined, { params: { id } }); } +// ---------- 客户额度 ---------- + +/** 客户额度账户列表,按回收物类型逐项返回余额与预占。 */ +async function accountList(customerId: string): Promise { + return await axios.post(`${ACCOUNT_URI}/list`, undefined, { + params: { storeId: getCurrentStoreId() || undefined, customerId } + }); +} + +/** 额度流水,服务端当前最多返回 100 条。 */ +async function accountLedger(customerId: string): Promise { + return await axios.post(`${ACCOUNT_URI}/ledger`, undefined, { + params: { storeId: getCurrentStoreId() || undefined, customerId } + }); +} + /** - * 核销待核销单。成功返回的兑换单状态可能已被并发操作改变,页面应重新查询详情。 - * 门店由服务端按兑换单自身归属解析,请求不需要带 storeId。 + * 人工调整额度。 + * + * 减少不能超过可用额度;调整只动账面,不代表门店收到实物。 */ -async function verify(request: RecycleExchangeActionRequest): Promise { - const result = await axios.post(`${EXCHANGE_URI}/verify`, request); - return notifyPendingNoticeChanged(result); +async function accountAdjust(request: RecycleAccountAdjustRequest): Promise { + await axios.post(`${ACCOUNT_URI}/adjust`, withCurrentStoreId(request)); } -/** 撤销待核销单,recycleReturned 决定回收物是否全部退还客户。门店同理由服务端取。 */ -async function cancel(request: RecycleExchangeActionRequest): Promise { - const result = await axios.post(`${EXCHANGE_URI}/cancel`, request); - return notifyPendingNoticeChanged(result); +/** 某 SKU 的回收物产出配置。 */ +async function yieldList(skuId: string): Promise { + return await axios.post(`${ACCOUNT_URI}/yield/list`, undefined, { + params: { storeId: getCurrentStoreId() || undefined, skuId } + }); } -/** 冲正已核销单。库存商品必须 stockReturned 且至少一张 PHOTO。门店同理由服务端取。 */ -async function revoke(request: RecycleExchangeActionRequest): Promise { - const result = await axios.post(`${EXCHANGE_URI}/revoke`, request); - return notifyPendingNoticeChanged(result); +/** 某产品下所有 SKU 的回收物产出配置,产品详情里配置产出用。 */ +async function yieldProductList(productId: string): Promise { + return await axios.post(`${ACCOUNT_URI}/yield/product/list`, undefined, { + params: { storeId: getCurrentStoreId() || undefined, productId } + }); +} + +/** 保存产出比例,同一 SKU 与回收物组合会覆盖。 */ +async function yieldSave(skuId: string, recycleItemId: string, quantityPerBase: string): Promise { + await axios.post(`${ACCOUNT_URI}/yield/save`, undefined, { + params: { storeId: getCurrentStoreId() || undefined, skuId, recycleItemId, quantityPerBase } + }); +} + +/** 删除产出配置。历史额度流水仍会保留来源。 */ +async function yieldDelete(skuId: string, recycleItemId: string): Promise { + await axios.post(`${ACCOUNT_URI}/yield/delete`, undefined, { + params: { storeId: getCurrentStoreId() || undefined, skuId, recycleItemId } + }); +} + +// ---------- 回收物支付 ---------- + +/** 登记一笔待核销支付,创建即预占客户额度。 */ +async function paymentCreate(request: RecyclePaymentRequest): Promise { + return await axios.post(`${PAYMENT_URI}/create`, withCurrentStoreId(request)); +} + +/** 创建并立即核销,预占转扣减并记录实物收到。 */ +async function paymentCreateAndVerify(request: RecyclePaymentRequest): Promise { + return await axios.post(`${PAYMENT_URI}/create-and-verify`, withCurrentStoreId(request)); +} + +/** 某订单的回收物支付记录。 */ +async function paymentList(orderId: string): Promise { + return await axios.post(`${PAYMENT_URI}/list`, undefined, { params: { orderId } }); +} + +/** 按客户、时间和状态分页查询回收流水。 */ +async function paymentSearch(params: { customerId?: string; orderId?: string; status?: string; beginAt?: number; endAt?: number; offset: number; limit: number }): Promise { + return await axios.post(`${PAYMENT_URI}/search`, undefined, { params: { ...params, storeId: getCurrentStoreId() || undefined } }); +} + +/** 某订单的统一交易视图,资金流水与回收物支付按权限混合返回。 */ +async function paymentTransactions(orderId: string): Promise { + return await axios.post(`${PAYMENT_URI}/transactions`, undefined, { params: { orderId } }); +} + +/** 核销待核销支付。 */ +async function paymentVerify(paymentId: string): Promise { + return await axios.post(`${PAYMENT_URI}/verify`, { paymentId }); +} + +/** 拒绝待核销支付并释放预占。 */ +async function paymentReject(request: RecyclePaymentRequest): Promise { + return await axios.post(`${PAYMENT_URI}/reject`, request); +} + +/** 撤销待核销支付并释放预占,普通撤销仅限提交人。 */ +async function paymentCancel(request: RecyclePaymentRequest): Promise { + return await axios.post(`${PAYMENT_URI}/cancel`, request); +} + +/** 整笔冲正已核销支付并返还额度。 */ +async function paymentRevoke(request: RecyclePaymentRequest): Promise { + return await axios.post(`${PAYMENT_URI}/revoke`, withCurrentStoreId(request)); } // ---------- 统计 ---------- @@ -150,12 +240,25 @@ export default { activeRuleList, ruleDetail, ruleSave, + ruleDelete, create, - page, detail, - verify, - cancel, - revoke, + accountList, + accountLedger, + accountAdjust, + yieldList, + yieldProductList, + yieldSave, + yieldDelete, + paymentCreate, + paymentCreateAndVerify, + paymentList, + paymentSearch, + paymentTransactions, + paymentVerify, + paymentReject, + paymentCancel, + paymentRevoke, statRecycle, statExchange }; diff --git a/src/assets/styles/global.less b/src/assets/styles/global.less index 228ad47..23224fe 100644 --- a/src/assets/styles/global.less +++ b/src/assets/styles/global.less @@ -189,12 +189,6 @@ html.theme-dark body { margin: 0 1rem; } -.form-tips { - color: var(--td-text-color-secondary); - font-size: .8125rem; - line-height: 1.5; -} - .empty-cell-title-margin { --td-spacer-2: .25rem; } @@ -231,11 +225,6 @@ html.theme-dark body { } } -.t-pull-down-refresh { - height: auto; - overflow: visible; -} - .t-dropdown-menu { &:after { diff --git a/src/components/productSelector/ProductSelectPopup.vue b/src/components/productSelector/ProductSelectPopup.vue index ff13b56..183c3fa 100644 --- a/src/components/productSelector/ProductSelectPopup.vue +++ b/src/components/productSelector/ProductSelectPopup.vue @@ -27,7 +27,7 @@ @toggle="toggleSku" @check="toggleProduct" /> - + @@ -46,14 +46,12 @@ interface Props { modelValue?: ProductSkuSelectionValue; visible?: boolean; selectionMode?: ProductSkuSelectionMode; - /** sellable 只列可售产品;all 连停售产品一起列,用于来源产品这类仅作识别的场景 */ - productScope?: "sellable" | "all"; selectableProductIdList?: string[]; selectableSkuIdList?: string[]; selectedSkuIdList?: string[]; } -const props = withDefaults(defineProps(), { selectionMode: "single", productScope: "sellable" }); +const props = withDefaults(defineProps(), { selectionMode: "single" }); const emit = defineEmits<{ "update:modelValue": [value: Props["modelValue"]]; "update:visible": [value: boolean]; @@ -97,7 +95,7 @@ const visibleProductList = computed(() => { }); const emptyProductText = computed(() => props.selectableProductIdList?.length === 0 ? "客户暂无已购可履约产品" - : (props.productScope === "all" ? "暂无产品" : "暂无可售产品")); + : "暂无可售产品"); const selectorItemList = computed(() => visibleProductList.value.map((summary, index) => { const key = getProductKey(summary, index); const product = productDetailMap.value[key] || (summary.skuList?.length ? summary : undefined); @@ -136,11 +134,9 @@ watch(popupVisible, async visible => { } loading.value = true; try { - productList.value = props.productScope === "all" - ? (await ProductAPI.list({ index: 0, size: 1000 })).list || [] - : await ProductAPI.sellableList({ index: 0, size: 1000 }); + productList.value = await ProductAPI.sellableList({ index: 0, size: 1000 }); } catch (error) { - Message.error(getErrorMessage(error, props.productScope === "all" ? "产品加载失败" : "可售产品加载失败")); + Message.error(getErrorMessage(error, "可售产品加载失败")); } finally { loading.value = false; } diff --git a/src/components/productSelector/ProductSkuSelector.vue b/src/components/productSelector/ProductSkuSelector.vue index fde2446..feefb6f 100644 --- a/src/components/productSelector/ProductSkuSelector.vue +++ b/src/components/productSelector/ProductSkuSelector.vue @@ -1,7 +1,7 @@