| | |
| | | } from '@life-payment/core-vue'; |
| | | import { MaybeRef } from 'vue'; |
| | | import { Message } from '@/utils'; |
| | | import Taro from '@tarojs/taro'; |
| | | |
| | | export function useOnlineService() { |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | |
| | | 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(); |
| | | |
| | |
| | | onSuccess: (data) => { |
| | | onSuccess?.(data); |
| | | }, |
| | | staleTime: staleTime, |
| | | }); |
| | | |
| | | return { |
| | |
| | | }; |
| | | } |
| | | |
| | | 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, |
| | | }); |
| | | } |
| | |
| | | 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); |
| | | |
| | |
| | | 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 |
| | | ); |
| | | }); |
| | | |
| | |
| | | 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 |
| | | ); |
| | | }); |
| | | |
| | |
| | | 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, |
| | | }; |
| | | } |
| | | |
New file |
| | |
| | | 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, |
| | | }; |
| | | } |
| | |
| | | /**已停止 */ |
| | | Stop = 30, |
| | | } |
| | | |
| | | export enum LifePayRateChannelStatus { |
| | | /**启用 */ |
| | | Disabled = -10, |
| | | /**禁用 */ |
| | | Enabled = 10, |
| | | } |
| | | } |
| | |
| | | } |
| | | ); |
| | | } |
| | | |
| | | /** 获取折扣通道配置列表 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 { |
| | |
| | | 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; |
| | | } |
| | |
| | | |
| | | interface QueryRateChannelInput { |
| | | status?: LifePayRateChannelStatus; |
| | | lifePayOrderType?: LifePayOrderTypeEnum; |
| | | } |
| | | |
| | | interface QueryUserAccountAllListInput { |