From 21b418f4ffb8e76d72819e8d489b3179154cb0c1 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期一, 24 三月 2025 15:46:54 +0800
Subject: [PATCH] fix: 三期需求

---
 packages/components/src/hooks/index.ts |   83 ++++++++++++++++++++++++++++++++++++-----
 1 files changed, 72 insertions(+), 11 deletions(-)

diff --git a/packages/components/src/hooks/index.ts b/packages/components/src/hooks/index.ts
index ec903cc..9946e0e 100644
--- a/packages/components/src/hooks/index.ts
+++ b/packages/components/src/hooks/index.ts
@@ -11,7 +11,7 @@
   UserAccountListOutput,
   AddUpdateUserAccountInput,
   GasParValueResponse,
-  GasParValueOutput,
+  ChannelRateOutput,
 } from '@life-payment/core-vue';
 import { useQuery, useQueryClient } from '@tanstack/vue-query';
 import { computed, MaybeRef, reactive, unref } from 'vue';
@@ -30,26 +30,54 @@
     placeholderData: () => [] as LifePayRateListOutput[],
   });
 
-  const lifePayPhoneRate = computed(
-    () =>
+  const hasChannel = computed(() => !!blLifeRecharge.accountModel.channlesNum);
+
+  const { data: channelRate } = useQuery({
+    queryKey: ['blLifeRecharge/getChannelRate', blLifeRecharge.accountModel.channlesNum],
+    queryFn: async () => {
+      return await blLifeRecharge.services.getChannelRate(
+        {
+          checkChannelId: blLifeRecharge.accountModel.channlesNum,
+        },
+        { showLoading: false }
+      );
+    },
+    placeholderData: () => ({} as ChannelRateOutput),
+    enabled: hasChannel,
+  });
+
+  const lifePayPhoneRate = computed(() => {
+    if (hasChannel.value && channelRate.value.channlesRate) {
+      return channelRate.value.channlesRate;
+    }
+    return (
       lifePayRateList.value.find(
         (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿璇濊垂鎶樻墸
       )?.rate ?? 100
-  );
+    );
+  });
 
-  const lifePayElectricRate = computed(
-    () =>
+  const lifePayElectricRate = computed(() => {
+    if (hasChannel.value && channelRate.value.channlesRate) {
+      return channelRate.value.channlesRate;
+    }
+    return (
       lifePayRateList.value.find(
         (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿鐢佃垂鎶樻墸
       )?.rate ?? 100
-  );
+    );
+  });
 
-  const lifePayGasRate = computed(
-    () =>
+  const lifePayGasRate = computed(() => {
+    if (hasChannel.value && channelRate.value.channlesRate) {
+      return channelRate.value.channlesRate;
+    }
+    return (
       lifePayRateList.value.find(
         (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿鐕冩皵鎶樻墸
       )?.rate ?? 100
-  );
+    );
+  });
 
   return {
     lifePayRateList,
@@ -127,7 +155,11 @@
       });
       res.data = res.data.map((x) => ({
         ...x,
-        frontStatus: convertOrderFrontStatus(x.payStatus, x.lifePayOrderStatus),
+        frontStatus: convertOrderFrontStatus(
+          x.payStatus,
+          x.lifePayOrderStatus,
+          x.lifePayRefundStatus
+        ),
       }));
       return res;
     },
@@ -276,3 +308,32 @@
     gasParValueList,
   };
 }
+
+type UseIntroInfoOptions = {
+  lifePayOrderType: MaybeRef<LifeRechargeConstants.LifePayOrderTypeEnum>;
+  onSuccess?: (data: API.LifePayIntroInfoOutput[]) => any;
+};
+
+export function useIntroInfo({ lifePayOrderType, onSuccess }: UseIntroInfoOptions) {
+  const { blLifeRecharge } = useLifeRechargeContext();
+
+  const { data: introInfo } = useQuery({
+    queryKey: ['blLifeRecharge/getIntroInfo', lifePayOrderType],
+    queryFn: async () => {
+      return await blLifeRecharge.services.getIntroInfo(
+        {
+          type: unref(lifePayOrderType),
+        },
+        {
+          showLoading: false,
+        }
+      );
+    },
+    placeholderData: () => [] as API.LifePayIntroInfoOutput[],
+    onSuccess: (data) => {
+      onSuccess?.(data);
+    },
+  });
+
+  return { introInfo };
+}

--
Gitblit v1.9.1