From 6ac59f6fa91e51272b8cd4797458995e168ec0f9 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期四, 11 九月 2025 09:13:08 +0800
Subject: [PATCH] feat: 公告
---
packages/services/api/typings.d.ts | 1
packages/core/src/lifeRechargeConstants.ts | 7 ++
apps/taro/src/hooks/lifepay.ts | 22 +++++--
packages/core/src/lifeRechargeServices.ts | 37 ++++++++++++
packages/components/src/hooks/rate.ts | 36 ++++++++++++
packages/components/src/hooks/index.ts | 52 +++++++++++-----
6 files changed, 132 insertions(+), 23 deletions(-)
diff --git a/apps/taro/src/hooks/lifepay.ts b/apps/taro/src/hooks/lifepay.ts
index 9384fb3..eb019fa 100644
--- a/apps/taro/src/hooks/lifepay.ts
+++ b/apps/taro/src/hooks/lifepay.ts
@@ -6,6 +6,7 @@
} from '@life-payment/core-vue';
import { MaybeRef } from 'vue';
import { Message } from '@/utils';
+import Taro from '@tarojs/taro';
export function useOnlineService() {
const { blLifeRecharge } = useLifeRechargeContext();
@@ -69,10 +70,11 @@
type UseShowingLifePayAnnouncementOptions = {
params?: MaybeRef<API.GetShowingLifePayAnnouncementInput>;
onSuccess?: (data: API.CreateEditLifePayAnnouncementOutput) => any;
+ staleTime?: MaybeRef<number>;
};
export function useShowingLifePayAnnouncement(options: UseShowingLifePayAnnouncementOptions = {}) {
- const { onSuccess, params = {} } = options;
+ const { onSuccess, params = {}, staleTime } = options;
const { blLifeRecharge } = useLifeRechargeContext();
@@ -91,6 +93,7 @@
onSuccess: (data) => {
onSuccess?.(data);
},
+ staleTime: staleTime,
});
return {
@@ -100,19 +103,26 @@
};
}
+const dialogShowingLifePayAnnouncementCache = {};
+
export function useDialogShowingLifePayAnnouncement() {
const { blLifeRecharge } = useLifeRechargeContext();
+ const router = Taro.useRouter();
useShowingLifePayAnnouncement({
params: {
announcementType: blLifeRecharge.constants.AnnouncementTypeEnum.Dialog,
},
onSuccess(data) {
- Message.confirm({
- title: '鍏憡',
- message: data.announcementContent ?? '',
- showCancelBtn: false,
- });
+ if (!dialogShowingLifePayAnnouncementCache[router.path]) {
+ dialogShowingLifePayAnnouncementCache[router.path] = true;
+ Message.confirm({
+ title: '鍏憡',
+ message: data.announcementContent ?? '',
+ showCancelBtn: false,
+ });
+ }
},
+ staleTime: Infinity,
});
}
diff --git a/packages/components/src/hooks/index.ts b/packages/components/src/hooks/index.ts
index 6eca483..624ec3d 100644
--- a/packages/components/src/hooks/index.ts
+++ b/packages/components/src/hooks/index.ts
@@ -18,17 +18,19 @@
import { useInfiniteLoading } from './infiniteLoading';
import { OrderInputType } from '../constants';
import { convertOrderFrontStatus } from '../utils';
+import { useLifePayRateChannelAllList } from './rate';
export function useGetRate() {
const { blLifeRecharge } = useLifeRechargeContext();
- const { data: lifePayRateList, isLoading } = useQuery({
- queryKey: ['blLifeRecharge/getRate'],
- queryFn: async () => {
- return await blLifeRecharge.services.getRate({ showLoading: false });
- },
- placeholderData: () => [] as LifePayRateListOutput[],
- });
+ // const { data: lifePayRateList, isLoading } = useQuery({
+ // queryKey: ['blLifeRecharge/getRate'],
+ // queryFn: async () => {
+ // return await blLifeRecharge.services.getRate({ showLoading: false });
+ // },
+ // placeholderData: () => [] as LifePayRateListOutput[],
+ // });
+ const { allRateChannelList } = useLifePayRateChannelAllList();
const hasChannel = computed(() => !!blLifeRecharge.accountModel.channlesNum);
@@ -50,10 +52,15 @@
if (hasChannel.value && channelRate.value.channlesRate) {
return channelRate.value.channlesRate;
}
+ // return (
+ // lifePayRateList.value.find(
+ // (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿璇濊垂鎶樻墸
+ // )?.rate ?? 0
+ // );
return (
- lifePayRateList.value.find(
- (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿璇濊垂鎶樻墸
- )?.rate ?? 0
+ allRateChannelList.value
+ .filter((x) => x.lifePayOrderType == blLifeRecharge.constants.LifePayOrderTypeEnum.璇濊垂璁㈠崟)
+ .toSorted((a, b) => a.platformRate - b.platformRate)?.[0]?.platformRate ?? 0
);
});
@@ -61,10 +68,15 @@
if (hasChannel.value && channelRate.value.channlesRate) {
return channelRate.value.channlesRate;
}
+ // return (
+ // lifePayRateList.value.find(
+ // (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿鐢佃垂鎶樻墸
+ // )?.rate ?? 0
+ // );
return (
- lifePayRateList.value.find(
- (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿鐢佃垂鎶樻墸
- )?.rate ?? 0
+ allRateChannelList.value
+ .filter((x) => x.lifePayOrderType == blLifeRecharge.constants.LifePayOrderTypeEnum.鐢佃垂璁㈠崟)
+ .toSorted((a, b) => a.platformRate - b.platformRate)?.[0]?.platformRate ?? 0
);
});
@@ -72,18 +84,24 @@
if (hasChannel.value && channelRate.value.channlesRate) {
return channelRate.value.channlesRate;
}
+ // return (
+ // lifePayRateList.value.find(
+ // (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿鐕冩皵鎶樻墸
+ // )?.rate ?? 0
+ // );
return (
- lifePayRateList.value.find(
- (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿鐕冩皵鎶樻墸
- )?.rate ?? 0
+ allRateChannelList.value
+ .filter((x) => x.lifePayOrderType == blLifeRecharge.constants.LifePayOrderTypeEnum.鐕冩皵璁㈠崟)
+ .toSorted((a, b) => a.platformRate - b.platformRate)?.[0]?.platformRate ?? 0
);
});
return {
- lifePayRateList,
+ // lifePayRateList,
lifePayPhoneRate,
lifePayElectricRate,
lifePayGasRate,
+ allRateChannelList,
};
}
diff --git a/packages/components/src/hooks/rate.ts b/packages/components/src/hooks/rate.ts
new file mode 100644
index 0000000..5db3d7c
--- /dev/null
+++ b/packages/components/src/hooks/rate.ts
@@ -0,0 +1,36 @@
+import {
+ useLifeRechargeContext,
+ QueryRateChannelInput,
+ CreateEditRateChannelOutput,
+} from '@life-payment/core-vue';
+import { useQuery } from '@tanstack/vue-query';
+import { MaybeRef, unref, computed } from 'vue';
+
+type UseLifePayRateChannelAllListOptions = {
+ params?: MaybeRef<QueryRateChannelInput>;
+};
+
+export function useLifePayRateChannelAllList(options: UseLifePayRateChannelAllListOptions = {}) {
+ const { params = {} } = options;
+
+ const { blLifeRecharge } = useLifeRechargeContext();
+
+ const _params = computed(() => ({
+ status: blLifeRecharge.constants.LifePayRateChannelStatus.Enabled,
+ ...unref(params),
+ }));
+
+ const { data: allRateChannelList } = useQuery({
+ queryKey: ['blLifeRecharge/getLifePayRateChannelAllList', _params],
+ queryFn: async () => {
+ return await blLifeRecharge.services.getLifePayRateChannelAllList(_params.value, {
+ showLoading: false,
+ });
+ },
+ placeholderData: () => [] as CreateEditRateChannelOutput[],
+ });
+
+ return {
+ allRateChannelList,
+ };
+}
diff --git a/packages/core/src/lifeRechargeConstants.ts b/packages/core/src/lifeRechargeConstants.ts
index f88fb61..0a502dd 100644
--- a/packages/core/src/lifeRechargeConstants.ts
+++ b/packages/core/src/lifeRechargeConstants.ts
@@ -247,4 +247,11 @@
/**宸插仠姝� */
Stop = 30,
}
+
+ export enum LifePayRateChannelStatus {
+ /**鍚敤 */
+ Disabled = -10,
+ /**绂佺敤 */
+ Enabled = 10,
+ }
}
diff --git a/packages/core/src/lifeRechargeServices.ts b/packages/core/src/lifeRechargeServices.ts
index 8935e5a..9bfcac7 100644
--- a/packages/core/src/lifeRechargeServices.ts
+++ b/packages/core/src/lifeRechargeServices.ts
@@ -482,6 +482,21 @@
}
);
}
+
+ /** 鑾峰彇鎶樻墸閫氶亾閰嶇疆鍒楄〃 POST /api/LifePayRate/GetLifePayRateChannelAllList */
+ async getLifePayRateChannelAllList(body: QueryRateChannelInput, options?: RequestConfig) {
+ return this.request<CreateEditRateChannelOutput[]>(
+ '/api/LifePayRate/GetLifePayRateChannelAllList',
+ {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ data: body,
+ ...(options || {}),
+ }
+ );
+ }
}
export interface PhoneMesssageCodeLoginInput {
@@ -1104,3 +1119,25 @@
creationTime?: string;
status?: LifeRechargeConstants.AnnouncementStatusEnum;
}
+
+export interface QueryRateChannelInput {
+ status?: LifeRechargeConstants.LifePayRateChannelStatus;
+ lifePayOrderType?: LifeRechargeConstants.LifePayOrderTypeEnum;
+}
+
+export interface CreateEditRateChannelOutput {
+ id?: string;
+ lifePayOrderType: LifeRechargeConstants.LifePayOrderTypeEnum;
+ /** 閫氶亾 */
+ rateChannelName: string;
+ /** ID */
+ code: string;
+ /** 渚涘簲鍟嗘姌鎵� */
+ supplierRate: number;
+ /** 骞冲彴鎶樻墸 */
+ platformRate: number;
+ status: LifeRechargeConstants.LifePayRateChannelStatus;
+ /** 閫氱煡鍐呭 */
+ remark: string;
+ creationTime?: string;
+}
diff --git a/packages/services/api/typings.d.ts b/packages/services/api/typings.d.ts
index 88e5ca5..81c5ffa 100644
--- a/packages/services/api/typings.d.ts
+++ b/packages/services/api/typings.d.ts
@@ -2305,6 +2305,7 @@
interface QueryRateChannelInput {
status?: LifePayRateChannelStatus;
+ lifePayOrderType?: LifePayOrderTypeEnum;
}
interface QueryUserAccountAllListInput {
--
Gitblit v1.10.0