f34af9bbc5ec1a40fa5d9f658ea2face2fb13b19..5cd618c9523ad30dccf858a00ff6d99a28de4187
17 小时以前 zhengyiming
feat: 公告
5cd618 对比 | 目录
18 小时以前 zhengyiming
feat: 公告
6ac59f 对比 | 目录
1个文件已添加
10个文件已修改
341 ■■■■ 已修改文件
apps/taro/src/components/NavigationBar/TransparentNavigationBar.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/hooks/lifepay.ts 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/hooks/index.ts 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/hooks/rate.ts 101 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeBaseForm.vue 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeStep2.vue 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/components/src/views/electricBillRecharge/ElectricBillRechargeStep2.vue 32 ●●●●● 补丁 | 查看 | 原始文档 | 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/components/NavigationBar/TransparentNavigationBar.vue
@@ -36,7 +36,6 @@
const props = defineProps(commonNavigationBarProps);
const router = Taro.useRouter();
console.log('router: ', router);
const isLastPage = computed(() => {
  const pages = Taro.getCurrentPages();
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,
  });
}
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,
  };
}
@@ -265,23 +283,25 @@
  onSetUserAccount: (currentUserAccount: UserAccountListOutput) => any;
  getDefaultUserAccount?: (
    userAccountList: UserAccountListOutput[]
  ) => UserAccountListOutput | undefined;
  ) => Promise<UserAccountListOutput | undefined>;
};
export function useSetUserAccountBySelect({
  lifePayOrderType,
  onSetUserAccount,
  getDefaultUserAccount = (data) => data[0],
  getDefaultUserAccount = (data) => Promise.resolve(data[0]),
}: UseSetUserAccountBySelectOptions) {
  const { userAccountAllList } = useUserAccountAllList({
    lifePayOrderType: lifePayOrderType,
    onSuccess(data) {
      if (data.length > 0) {
        const currentUserAccount = getDefaultUserAccount(data);
        if (currentUserAccount) {
          onSetUserAccount?.(currentUserAccount);
    async onSuccess(data) {
      try {
        if (data.length > 0) {
          const currentUserAccount = await getDefaultUserAccount(data);
          if (currentUserAccount) {
            onSetUserAccount?.(currentUserAccount);
          }
        }
      }
      } catch (error) {}
    },
  });
packages/components/src/hooks/rate.ts
New file
@@ -0,0 +1,101 @@
import {
  useLifeRechargeContext,
  QueryRateChannelInput,
  CreateEditRateChannelOutput,
} from '@life-payment/core-vue';
import { useQuery, useQueryClient } from '@tanstack/vue-query';
import { MaybeRef, unref, computed, Ref } from 'vue';
type UseLifePayRateChannelAllListOptions = {
  params?: MaybeRef<QueryRateChannelInput>;
};
export function useLifePayRateChannelAllList(options: UseLifePayRateChannelAllListOptions = {}) {
  const { params = {} } = options;
  const { blLifeRecharge } = useLifeRechargeContext();
  const queryClient = useQueryClient();
  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[],
  });
  function ensureLifePayRateChannelAllList() {
    return queryClient.ensureQueryData({
      queryKey: ['blLifeRecharge/getLifePayRateChannelAllList', _params],
    });
  }
  function getRateChannelByCode(code: string) {
    return allRateChannelList.value.find((item) => item.code === code);
  }
  return {
    allRateChannelList,
    ensureLifePayRateChannelAllList,
    getRateChannelByCode,
  };
}
type UseCheckCanRechargeOptions = {
  msg: Ref<string>;
  show: Ref<boolean>;
};
export function useCheckCanRecharge(options: UseCheckCanRechargeOptions) {
  const { msg, show } = options;
  const { blLifeRecharge } = useLifeRechargeContext();
  const { getRateChannelByCode, ensureLifePayRateChannelAllList } = useLifePayRateChannelAllList({
    params: {
      status: null,
    },
  });
  /**
   *
   * @param rateChannelCode
   * @description rateChannelCode值话费为IspCode、电费为electricType、燃气费为gasOrgType
   * @returns
   */
  function isCanRecharge(rateChannelCode: string) {
    const rateChannel = getRateChannelByCode(rateChannelCode);
    return rateChannel?.status === blLifeRecharge.constants.LifePayRateChannelStatus.Enabled;
  }
  /**
   *
   * @param rateChannelCode
   * @description rateChannelCode值话费为IspCode、电费为electricType、燃气费为gasOrgType
   * @returns
   */
  function checkCanRecharge(rateChannelCode: string) {
    const rateChannel = getRateChannelByCode(rateChannelCode);
    if (!isCanRecharge(rateChannelCode)) {
      //通道正在升级,给您带来不便尽情谅解
      msg.value = rateChannel?.remark ?? '';
      show.value = true;
      return false;
    }
    return true;
  }
  return {
    isCanRecharge,
    checkCanRecharge,
    ensureLifePayRateChannelAllList,
  };
}
packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue
@@ -13,7 +13,7 @@
          direction="horizontal"
          class="par-account-list"
          v-if="userAccountAllList.length > 0"
          @change="handleUserAccountChange"
          @change="_handleUserAccountChange"
        >
          <NutRadio
            :label="item.id"
@@ -145,6 +145,7 @@
import { RechargeProps } from '../PhoneBillRecharge/types';
import Chunk from '../../components/Layout/Chunk.vue';
import IconSelect from '../../assets/recharge/icon-select.png';
import { useCheckCanRecharge } from '../../hooks/rate';
defineOptions({
  name: 'GasBillRechargeStep3',
@@ -199,7 +200,28 @@
      form.parValue = 0;
    }
  },
  async getDefaultUserAccount(userAccountList) {
    await ensureLifePayRateChannelAllList();
    const defaultUserAccount = userAccountList.find((x) => {
      const currentUserAccountExtraProperties = JSON.parse(
        x.extraProperties
      ) as GasUserAccountExtraProperties;
      return isCanRecharge(currentUserAccountExtraProperties.gasOrgType);
    });
    return defaultUserAccount;
  },
});
function _handleUserAccountChange(userAccountId: string) {
  const currentUserAccount = userAccountAllList.value.find((x) => x.id === userAccountId);
  const currentUserAccountExtraProperties = JSON.parse(
    currentUserAccount.extraProperties
  ) as GasUserAccountExtraProperties;
  if (!checkCanRecharge(currentUserAccountExtraProperties.gasOrgType)) {
    // return;
  }
  handleUserAccountChange(userAccountId);
}
function handleAddUserAccount() {
  goTo('step1');
@@ -257,8 +279,16 @@
const currentOrderNo = ref('');
const { isCanRecharge, checkCanRecharge, ensureLifePayRateChannelAllList } = useCheckCanRecharge({
  msg: toRef(state, 'msg'),
  show: toRef(state, 'show'),
});
async function goPay() {
  try {
    if (!checkCanRecharge(form.gasOrgType)) {
      return;
    }
    let params: LifeGasDataCreateLifePayOrderInput = {
      userId: blLifeRecharge.accountModel.userId,
      channelId: blLifeRecharge.accountModel.channlesNum,
packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeBaseForm.vue
@@ -8,12 +8,9 @@
  >
    <NutFormItem label="选择运营商:" class="bole-form-item" prop="ispCode" required>
      <NutRadioGroup v-model="form.ispCode" direction="horizontal" @change="handleIspCodeChange">
        <BlRadio
          :label="key"
          v-for="(val, key) in BlLifeRecharge.constants.IspCodeTextForSelect"
          :key="key"
          >{{ val }}</BlRadio
        >
        <BlRadio :label="item.code" v-for="item in allRateChannelList" :key="item.id">{{
          item.rateChannelName
        }}</BlRadio>
      </NutRadioGroup>
    </NutFormItem>
    <NutFormItem label="充值手机号" class="bole-form-item" prop="phone" required>
@@ -56,6 +53,7 @@
import BlRadio from '../../components/Radio/Radio.vue';
import { FormValidator } from '../../utils';
import { BlLifeRecharge, LifeRechargeConstants } from '@life-payment/core-vue';
import { useLifePayRateChannelAllList } from '../../hooks/rate';
defineOptions({
  name: 'PhoneBillRechargeBaseForm',
@@ -78,6 +76,12 @@
const dialogVisible = ref(false);
const { allRateChannelList } = useLifePayRateChannelAllList({
  params: {
    lifePayOrderType: LifeRechargeConstants.LifePayOrderTypeEnum.话费订单,
  },
});
function handleIspCodeChange(ispCode: LifeRechargeConstants.IspCode) {
  console.log('ispCode: ', ispCode);
  if (ispCode === LifeRechargeConstants.IspCode.dianxin) {
packages/components/src/views/PhoneBillRecharge/PhoneBillRechargeStep2.vue
@@ -132,6 +132,7 @@
import { RechargeProps } from './types';
import Chunk from '../../components/Layout/Chunk.vue';
import IconSelect from '../../assets/recharge/icon-select.png';
import { useCheckCanRecharge } from '../../hooks/rate';
defineOptions({
  name: 'PhoneBillRechargeStep2',
@@ -166,7 +167,8 @@
    form.remark = currentUserAccount.remark;
    changeIspCode(form.ispCode as any);
  },
  getDefaultUserAccount(userAccountList) {
  async getDefaultUserAccount(userAccountList) {
    await ensureLifePayRateChannelAllList();
    const defaultUserAccount = userAccountList.find((x) => {
      const currentUserAccountExtraProperties = JSON.parse(
        x.extraProperties
@@ -262,20 +264,10 @@
const currentOrderNo = ref('');
function isCanRecharge(ispCode: string) {
  return ispCode !== blLifeRecharge.constants.IspCode.yidong;
}
function checkCanRecharge(ispCode: string) {
  if (!isCanRecharge(ispCode)) {
    //通道正在升级,给您带来不便尽情谅解
    state.msg =
      '尊敬的用户,为提供更安全、稳定的充值服务,移动充值通道正在进行升级维护,维护期间暂无法发起充值';
    state.show = true;
    return false;
  }
  return true;
}
const { isCanRecharge, checkCanRecharge, ensureLifePayRateChannelAllList } = useCheckCanRecharge({
  msg: toRef(state, 'msg'),
  show: toRef(state, 'show'),
});
async function goPay() {
  try {
packages/components/src/views/electricBillRecharge/ElectricBillRechargeStep2.vue
@@ -13,7 +13,7 @@
          direction="horizontal"
          class="par-account-list"
          v-if="userAccountAllList.length > 0"
          @change="handleUserAccountChange"
          @change="_handleUserAccountChange"
        >
          <NutRadio
            :label="item.id"
@@ -143,6 +143,7 @@
import { RechargeProps } from '../PhoneBillRecharge/types';
import Chunk from '../../components/Layout/Chunk.vue';
import IconSelect from '../../assets/recharge/icon-select.png';
import { useCheckCanRecharge } from '../../hooks/rate';
defineOptions({
  name: 'ElectricBillRechargeStep2',
@@ -201,7 +202,28 @@
      form.parValue = 0;
    }
  },
  async getDefaultUserAccount(userAccountList) {
    await ensureLifePayRateChannelAllList();
    const defaultUserAccount = userAccountList.find((x) => {
      const currentUserAccountExtraProperties = JSON.parse(
        x.extraProperties
      ) as ElectricUserAccountExtraProperties;
      return isCanRecharge(currentUserAccountExtraProperties.electricType);
    });
    return defaultUserAccount;
  },
});
function _handleUserAccountChange(userAccountId: string) {
  const currentUserAccount = userAccountAllList.value.find((x) => x.id === userAccountId);
  const currentUserAccountExtraProperties = JSON.parse(
    currentUserAccount.extraProperties
  ) as ElectricUserAccountExtraProperties;
  if (!checkCanRecharge(currentUserAccountExtraProperties.electricType)) {
    // return;
  }
  handleUserAccountChange(userAccountId);
}
function handleAddUserAccount() {
  goTo('step1');
@@ -261,8 +283,16 @@
const currentOrderNo = ref('');
const { isCanRecharge, checkCanRecharge, ensureLifePayRateChannelAllList } = useCheckCanRecharge({
  msg: toRef(state, 'msg'),
  show: toRef(state, 'show'),
});
async function goPay() {
  try {
    if (!checkCanRecharge(form.electricType)) {
      return;
    }
    let params: LifeElectricDataCreateLifePayOrderInput = {
      userId: blLifeRecharge.accountModel.userId,
      channelId: blLifeRecharge.accountModel.channlesNum,
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 {