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/components.d.ts b/components.d.ts index 95b65d8..66ac3c9 100644 --- a/components.d.ts +++ b/components.d.ts @@ -45,6 +45,7 @@ declare module 'vue' { SegmentedSlider: typeof import('./src/components/SegmentedSlider.vue')['default'] StoreRemoveDialog: typeof import('./src/components/StoreRemoveDialog.vue')['default'] TagSelector: typeof import('./src/components/TagSelector.vue')['default'] + TAvatar: typeof import('tdesign-mobile-vue')['Avatar'] TBadge: typeof import('tdesign-mobile-vue')['Badge'] TButton: typeof import('tdesign-mobile-vue')['Button'] TCalendar: typeof import('tdesign-mobile-vue')['Calendar'] diff --git a/package.json b/package.json index c27fb94..cdc22a2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gao-customer-h5", "private": true, - "version": "1.2.0", + "version": "1.3.0", "type": "module", "scripts": { "dev": "vite --host", @@ -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 @@