zhengyiming
20 小时以前 6ac59f6fa91e51272b8cd4797458995e168ec0f9
feat: 公告
1个文件已添加
5个文件已修改
145 ■■■■ 已修改文件
apps/taro/src/hooks/lifepay.ts 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/hooks/index.ts 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/hooks/rate.ts 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/core/src/lifeRechargeConstants.ts 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/core/src/lifeRechargeServices.ts 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/services/api/typings.d.ts 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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) {
      if (!dialogShowingLifePayAnnouncementCache[router.path]) {
        dialogShowingLifePayAnnouncementCache[router.path] = true;
      Message.confirm({
        title: '公告',
        message: data.announcementContent ?? '',
        showCancelBtn: false,
      });
      }
    },
    staleTime: Infinity,
  });
}
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,
  };
}
packages/components/src/hooks/rate.ts
New file
@@ -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,
  };
}
packages/core/src/lifeRechargeConstants.ts
@@ -247,4 +247,11 @@
    /**已停止 */
    Stop = 30,
  }
  export enum LifePayRateChannelStatus {
    /**启用 */
    Disabled = -10,
    /**禁用 */
    Enabled = 10,
  }
}
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;
}
packages/services/api/typings.d.ts
@@ -2305,6 +2305,7 @@
  interface QueryRateChannelInput {
    status?: LifePayRateChannelStatus;
    lifePayOrderType?: LifePayOrderTypeEnum;
  }
  interface QueryUserAccountAllListInput {