PageSourceSearch

https://qwenwork.ai/app/assets/subscribe_.billing-ByrBO6jv.js

js qwenwork.ai collected 2026-10-05 12:27:28 UTC 36,765 bytes, 3 lines download raw bytes

1import{e3 as Ee,e4 as Oe,s as be,r as u,j as t,a6 as X,B as _,t as H,aR as xe,v as fe,a8 as Ae,a9 as Ce,e5 as ve,ap as Le,D as De,f as Me,h as Ue,i as Fe,I as we,l as Be,U as z,V as Z,W as J,X as ee,Y as te,Z as P,e6 as oe,a7 as qe,ai as We,a1 as ce,cy as de,aq as Ye,e7 as Ke,e8 as ze,aI as Qe,aN as Ge}from"./index--f5LZpbn.js";import{I as $e}from"./IconCircleAlert-DNeDMdoY.js";import{E as ue}from"./index-BiqwsEzf.js";import{t as Ne,W as He,X as Ve,Y as Xe,Z as Ze,_ as Je,$ as et,l as D,n as tt,u as nt,a0 as rt,T as at,g as it,f as st,m as re,a1 as lt,O as ot,S as ct,P as dt,a2 as ut,V as mt,a3 as me,q as pt,a4 as ne,C as pe,H as yt}from"./use-acck-subscription-payment-7reohn1p.js";import{q as gt}from"./queryOptions-C9woPjwX.js";import{a as ht,b as bt}from"./billing-navigation-DCRBYDHo.js";import"./index-vQHcgB7z.js";import"./formatters-BBXzMOPn.js";import"./account-context-CeX5_PnN.js";import"./index-B2nW7MNO.js";const $={all:["billing"],orders:()=>[...$.all,"orders"],orderList:e=>[...$.orders(),e]},xt={orderList:(e,n)=>gt({queryKey:$.orderList(n),queryFn:()=>e.listOrders(n)})},ft={listOrders:Ee,voidOrder:async({orderId:e,idempotencyKey:n})=>{if(!(await Oe(e,{headers:{"X-Idempotency-Key":n}})).accepted)throw new Error("ORDER_CANCELLATION_NOT_ACCEPTED")}},je=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),At=(e,n)=>e!==void 0&&e===n,Ct=e=>{const n=e?.source,i=e?.auto_renewal_actions??{enable:!1,cancel:!0};return n?.state!=="ACTIVE"||!n.instance_id?.trim()?null:n.billing_mode==="recurring_month"&&i.cancel?"cancel":n.billing_mode==="one_time_month"&&i.enable?"enable":null},vt=async(e=n=>be(n))=>{const n=await e({url:"/user/v2/personal-subscription/auto-renewal/cancel",method:"POST"});if(!je(n)||n.auto_renew!==!1||typeof n.already_disabled!="boolean"||n.request_id!==void 0&&typeof n.request_id!="string")throw new Error("personal auto-renewal cancellation returned an invalid response");return{auto_renew:!1,already_disabled:n.already_disabled,...n.request_id===void 0?{}:{request_id:n.request_id}}},wt=async(e=n=>be(n))=>{const n=await e({url:"/user/v2/personal-subscription/auto-renewal/enable",method:"POST"});if(!je(n)||n.auto_renew!==!0||typeof n.already_enabled!="boolean"||n.request_id!==void 0&&typeof n.request_id!="string")throw new Error("personal auto-renewal activation returned an invalid response");return{auto_renew:!0,already_enabled:n.already_enabled,...n.request_id===void 0?{}:{request_id:n.request_id}}};var Nt={channel:"OFFICIAL",locale:"zh-CN"},jt=u.createContext(Nt);function It({value:e,children:n}){const i=u.useMemo(()=>({channel:"OFFICIAL",locale:"zh-CN",...e}),[e]);return t.jsx(jt.Provider,{value:i,children:n})}const Pt=e=>{if(e.site!=="intl"||e.method.paymentMethodKind!=="card")return null;const i=(e.openWindow??((c,d)=>window.open(c,d)))("about:blank","_blank");return i&&(i.opener=null),i},St=e=>{const{site:n,method:i,result:c}=e;if(n!=="intl"||i.paymentMethodKind!=="card"||c.status!=="external"||c.requiresAuthentication!==!0)return e.authenticationWindow?.close(),!1;const d=e.openWindow??((r,s,l)=>window.open(r,s,l));return et(c.paymentUrl,e.authenticationWindow,r=>{d(r,"_blank","noopener,noreferrer")}),!0},Tt=async e=>{const n=Pt({site:e.site,method:e.method,openWindow:e.reserveOpenWindow});try{const i=await e.mergePayment();return e.isCurrent&&!e.isCurrent()?(n?.close(),i):(St({site:e.site,method:e.method,result:i,authenticationWindow:n,openWindow:e.fallbackOpenWindow}),i)}catch(i){throw n?.close(),i}},_t=e=>e.status==="failed"?e.failureMessage||e.failureCode:void 0,Rt=e=>{const{client:n,site:i,createClient:c,order:d,detail:r,returnUrl:s,withholdSignContext:l,onSuccess:b,onError:a,mergePayment:o=Ze,pollPayment:p=Ve,confirmPayment:v=He}=e,[N,A]=u.useState(),[y,x]=u.useState(!1),[W,U]=u.useState(!1),[F,R]=u.useState(!1),k=u.useRef(void 0),S=u.useRef(void 0),O=u.useRef(!1),B=u.useRef(d.orderId),T=u.useRef(0),E=u.useRef(!0),g=u.useRef(!1),f=u.useRef(!1);u.useEffect(()=>(E.current=!0,()=>{E.current=!1,T.current+=1}),[]);const C=u.useCallback((m,h)=>E.current&&T.current===m&&(!h||S.current===h),[]),j=u.useCallback(m=>{S.current=m,E.current&&A(m)},[]);u.useEffect(()=>{B.current!==d.orderId&&(B.current=d.orderId,T.current+=1,k.current=void 0,S.current=void 0,O.current=!1,g.current=!1,f.current=!1,A(void 0),x(!1),U(!1),R(!1))},[d.orderId]);const se=u.useCallback((m,h)=>{C(h,m)&&(O.current||(O.current=!0,j({...m,status:"succeeded"}),x(!1),b()))},[C,b,j]),Y=u.useCallback((m,h)=>{const w=Ne(m.orderType);return m.site==="intl"?h?v(n,m.orderId,m.site,w,m.nbid,h):v(n,m.orderId,m.site,w,m.nbid):h?v(n,m.orderId,m.site,w,void 0,h):v(n,m.orderId,m.site,w)},[n,v]),q=u.useCallback((m,h,w)=>{if(C(w,m)){if(h.status==="success"){se(m,w);return}if(h.status==="failed"){j({...m,status:"failed",failureMessage:_t(h)});return}j({...m,status:h.status==="pending"?"timed_out":"unknown"})}},[C,se,j]);u.useEffect(()=>{if(!y||N?.status!=="pending")return;const m=T.current,h=N,w=new AbortController;return p(n,h.intent.orderId,{signal:w.signal,site:h.intent.site}).then(async I=>{if(!(w.signal.aborted||!C(m,h))){if(I.status==="success"){const L=await Y(h.intent,I);w.signal.aborted||q(h,L,m);return}if(I.status==="failed"){q(h,I,m);return}j({...h,status:I.status==="timeout"?"timed_out":"unknown"})}}).catch(()=>{!w.signal.aborted&&C(m,h)&&j({...h,status:"unknown"})}),()=>w.abort()},[q,n,Y,C,y,p,N,j]);const _e=u.useCallback(async m=>{if(!r||g.current)return;const h=T.current+1;T.current=h,g.current=!0,U(!0),x(!1);let w;try{const I=k.current??Xe(d,r,void 0,i);k.current=I,w={intent:I,method:m,status:"pending"};const L=await Tt({site:i,method:m,isCurrent:()=>C(h),mergePayment:()=>o({intent:I,paymentType:m.paymentType,extendInfo:m.extendInfo,returnUrl:s(),...I.withholdOrderParams?{withholdSignContext:l}:{},createClient:c})});if(!C(h))return;const K={...w,...L.status==="external"?{paymentUrl:L.paymentUrl}:{}};if(j(K),L.status!=="completed"){x(!0);return}try{const le=await Y(K.intent);if(!C(h,K))return;if(le.status==="pending"){x(!0);return}x(!0),q(K,le,h)}catch{C(h,K)&&(j({...K,status:"unknown"}),x(!0))}}
1catch(I){if(!C(h))return;const L=k.current;if(!L){a?.(I);return}if(Je(I)){j(w??{intent:L,method:m,status:"pending"}),x(!0);return}j({intent:L,method:m,status:"failed",failureMessage:I instanceof Error?I.message:void 0}),x(!0)}finally{T.current===h&&(g.current=!1,E.current&&U(!1))}},[q,Y,c,r,C,o,a,d,s,i,j,l]),Re=u.useCallback(async()=>{const m=S.current;if(!m||f.current)return;const h=T.current;f.current=!0,R(!0);try{const w=await Y(m.intent);q(m,w,h)}catch{C(h,m)&&j({...m,status:"unknown"})}finally{T.current===h&&(f.current=!1,E.current&&R(!1))}},[q,Y,C,j]),ke=u.useCallback(()=>{T.current+=1,g.current=!1,f.current=!1,U(!1),R(!1),x(!1)},[]);return{session:N,isOpen:y,isSubmitting:W,isChecking:F,start:_e,checkPaymentResult:Re,dismiss:ke}},ae=(e,n)=>{const i=e.orderLines??[],c=({planCode:d,planName:r})=>d?.trim()||r?.trim();if(e.orderType==="REFUND"){const d=e.relatedOrderId?.trim();return[d?`${n} · ${d}`:n]}if(e.orderType==="UPGRADE"||e.orderType==="CHANGE_RESIGN"){const d=i.find(({changeRole:b})=>b==="SOURCE"),r=i.find(({changeRole:b})=>b==="TARGET"),s=d?c(d):void 0,l=r?c(r):void 0;if(s&&l)return[`${s} → ${l}`]}return i.map(d=>c(d)||d.commodityName?.trim()).filter(d=>!!d)},ye=(e,n)=>{switch(e){case"BUY":return n("billing.orderType.buy","新购");case"RENEW":case"RENEWAL":return n("billing.orderType.renew","续费");case"UPGRADE":return n("billing.orderType.upgrade","升级");case"REFUND":return n("billing.orderType.refund","退款");case"CHANGE_RESIGN":return n("billing.orderType.changeResign","套餐变更");default:return e||"—"}},ge=(e,n,i)=>{if(e==="PAID"&&i==="REFUND")return n("billing.status.refunded","退款成功");switch(e){case"PAID":return n("billing.status.paid","已支付");case"UNPAID":return n("billing.status.unpaid","未支付");case"PAYING":return n("billing.status.paying","支付中");case"CONFIRM":return n("billing.status.confirming","确认中");case"CANCELED":return n("billing.status.canceled","已取消");default:return e}},V=(e,n)=>{if(!e)return"—";const i=typeof e=="string"?e.trim():e,c=new Date(typeof i=="string"&&/^\d{13}$/.test(i)?Number(i):i);return Number.isFinite(c.getTime())?new Intl.DateTimeFormat(n,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(c).replaceAll("/","-"):"—"},Ie=(e,n,i)=>{if(!e)return"—";const c=Number(e);if(!Number.isFinite(c))return e;try{return new Intl.NumberFormat(i,{style:"currency",currency:n||"CNY",minimumFractionDigits:2}).format(c)}catch{return`${n||""} ${e}`.trim()}},ie="IpayAlipayCnWithhold",kt=e=>e.paymentType===ie,Et=e=>{const{paymentType:n,providerPaymentType:i,selectedCard:c,selectedAlipayMethod:d,nbid:r}=e;if(!r||n===D.IPAY_ALIPAYCN&&d?.paymentType!==ie)return;const s=n===D.IPAY_ALIPAYCN?d:n===D.IPAY_CREDIT?c:null;if(s)return tt(n,n===D.IPAY_ALIPAYCN?ie:i,s,r)},Ot=e=>e==="IpayAlipayCnNative",Lt=e=>{const{client:n,productCodes:i,enabled:c,children:d}=e,[r,s]=u.useState(),l=X({queryKey:["billing","continue-payment","cn-methods",i],queryFn:()=>rt(n,i),enabled:c,staleTime:6e4}),b=l.data?.paymentMethods.platformMethods.filter(({channelCode:o})=>o==="ALIPAY")??[],a=b.find(({id:o})=>o===r)??b[0];return u.useEffect(()=>{a&&a.id!==r&&s(a.id)},[r,a]),d({method:a?{paymentType:a.paymentType,name:a.name,iconUrl:a.iconUrl}:void 0,loading:l.isLoading,error:l.isError||!l.isLoading&&b.length===0,reload:()=>{l.refetch()},options:t.jsx("div",{className:"mt-3 space-y-2",children:b.map(o=>{const p=o.id===a?.id;return t.jsxs(_,{type:"button",variant:"ghost",rounded:"xl",className:`flex h-12 w-full items-center gap-3 rounded-xl border px-4 text-left transition-colors ${p?"border-primary bg-primary/5":"border-border-light bg-bg-container hover:bg-overlay-on-container-hover"}`,onClick:()=>s(o.id),children:[o.iconUrl?t.jsx("img",{src:o.iconUrl,alt:"",className:"size-6 object-contain"}):null,t.jsx("span",{className:"flex-1 text-14 text-text",children:o.name}),t.jsx("span",{"aria-hidden":"true",className:`size-4 rounded-full border-4 ${p?"border-primary":"border-border-tertiary"}`})]},o.id)})})})},Dt=e=>{const{picker:n,alipayMethods:i,selectedAlipayMethod:c,defaultAlipayMethod:d}=e,{t:r}=H();return t.jsxs("div",{className:"mt-3 space-y-2",children:[d?t.jsxs(_,{type:"button",variant:"ghost",rounded:"xl",className:`flex h-12 w-full items-center gap-3 rounded-xl border px-4 text-left ${c?"border-primary bg-primary/5":"border-border-light bg-bg-container hover:bg-overlay-on-container-hover"}`,onClick:()=>{n.setSelectedCard(null),n.setSelectedAlipayMethod(d),n.setPaymentType(D.IPAY_ALIPAYCN)},children:[t.jsx("span",{className:"flex-1 text-14 text-text",children:"Alipay"}),t.jsx("span",{"aria-hidden":"true",className:`size-4 rounded-full border-4 ${c?"border-primary":"border-border-tertiary"}`})]}):null,d?t.jsx("div",{className:"space-y-2 pl-8",children:i.map(s=>{const l=s.paymentMethodId===c?.paymentMethodId;return t.jsxs(_,{type:"button",variant:"ghost",rounded:"xl",className:`flex h-10 w-full items-center gap-3 rounded-xl border px-4 text-left ${l?"border-primary bg-primary/5":"border-border-light bg-bg-container hover:bg-overlay-on-container-hover"}`,onClick:()=>{n.setSelectedCard(null),n.setSelectedAlipayMethod(s),n.setPaymentType(D.IPAY_ALIPAYCN)},children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-14 text-text",children:s.displayName||"Alipay"}),t.jsx("span",{"aria-hidden":"true",className:`size-4 rounded-full border-4 ${l?"border-primary":"border-border-tertiary"}`})]},s.paymentMethodId)})}):null,n.boundCards.map(s=>{const l=n.selectedCard?.paymentMethodId===s.paymentMethodId;return t.jsxs(_,{type:"button",variant:"ghost",rounded:"xl",disabled:s.Available===!1,className:`flex h-12 w-full items-center gap-3 rounded-xl border px-4 text-left ${l?"border-primary bg-primary/5":"border-border-light bg-bg-container hover:bg-overlay-on-container-hover"}`,onClick:()=>{n.setSelectedAlipayMethod(null),n.setSelectedCard(s),n.setPaymentType(D.IPAY_CREDIT)},children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-14 text-text",children:s.displayName||r("billing.payment.bankCard","银行卡")}),t.jsx("span",{className:"block truncate text-xs text-text-tertiary",children:s.maskedCardNo})]}),t.jsx("span",{"aria-hidden":"true",className:`size-4 rounded-full border-4 ${l?"border-primary":"border-border-tertiary"}`})]},s.paymentMethodId)})]})},Mt=e=>{const{client:n,createWriteClient:i,currency:c,children:d}=e,r=nt({client:n,createWriteClient:i,currency:c??"",returnUrl:typeof window>"u"?"":window.location.href}),s=r.alipayMethods.filter(kt),l=s.find(({paymentMethodId:p})=>p===r.selectedAlipayMethod?.paymentMethodId),b=l??s.find(({isDefault:p})=>p)??s[0];u.useEffect(()=>{if(r.selectedCard||l)return;const p=r.boundCards.find(({Available:v})=>v!==!1);if(p){r.setSelectedCard(p),r.setPaymentType(D.IPAY_CREDIT);return}b&&(r.setSelectedAlipayMethod(b),r.setPaymentType(D.IPAY_ALIPAYCN))},[b,r.boundCards,r.selectedCard,r.setPaymentType,r.setSelectedAlipayMethod,r.setSelectedCard,l]);const a=Et({paymentType:r.paymentType,providerPaymentType:r.providerPaymentType,selectedCard:r.selectedCard,selectedAlipayMethod:r.selectedAlipayMethod,nbid:r.nbid}),o=s.length>0||r.boundCards.some(({Available:p})=>p!==!1);return d({method:a?{paymentType:a.paymentType,paymentMethodKind:a.paymentMethodKind,extendInfo:a.extendInfo,name:r.selectedCard?.displayName||r.selectedAlipayMethod?.dis
1playName||"Alipay"}:void 0,loading:r.loading,error:!!r.error||!r.loading&&!o,reload:()=>{r.refreshPaymentMethods().catch(()=>{})},options:t.jsx(Dt,{picker:r,alipayMethods:s,selectedAlipayMethod:l,defaultAlipayMethod:b})})},Ut={},M=at(Ut),Ft=mt(M,typeof window>"u"?void 0:window.location.origin),Q=st(M),Pe=e=>it(M,e),Se=e=>Array.from(new Set(e.orderLines?.map(({commodityCode:n})=>n.trim()).filter(Boolean)??[])),Bt=e=>{const n=Se(e),i=e.payAmount??e.tradeAmount,c=typeof i=="string"?ut(i):void 0,d=(e.realSettleCurrency||e.settleCurrency||"").trim(),r=Ne(e.orderType);if(e.orderStatus!=="UNPAID"||c===void 0||c<=0||!d||n.length!==1)throw new Error("Billing order does not contain an exact payable identity");return{orderId:e.orderId,orderType:r,status:"UNPAID",canPay:!0,canCancel:!1,tradeAmount:c/100,currency:d,commodityCode:n[0]}},Te=e=>{const{order:n,methodState:i,orderDetailQuery:c,onClose:d,onSuccess:r}=e,{t:s}=H(),l=fe(),[b]=u.useState(Ae),[a]=u.useState(()=>Ce({site:M.site,channel:b})),o=u.useMemo(()=>{if(n)try{return Bt(n)}catch{return{orderId:n.orderId,status:"UNPAID",canPay:!1,canCancel:!1}}},[n]),p=u.useMemo(()=>({attemptId:o?.orderId??"",productType:ve(o?.commodityCode?[o.commodityCode]:[]),scope:"personal"}),[o?.commodityCode,o?.orderId]),v=u.useRef(!1),N=u.useCallback(()=>{const g=o?.orderId??"",f=o?.tradeAmount??0,C=o?.currency??"";Le({type:"purchase",transactionId:g,productId:o?.commodityCode,value:f,currency:C,scope:"personal"}),o&&a.recordResult(p,{operation:"payment",outcome:"success",orderReference:re(o.orderId)}),r()},[p,a,r,o]),A=Rt({client:Q,site:M.site,createClient:Pe,order:o??{orderId:"",status:"UNPAID",canPay:!1,canCancel:!1},detail:c.data,returnUrl:()=>window.location.href,withholdSignContext:Ft,onSuccess:N,onError:()=>{o&&a.recordResult(p,{operation:"payment_start",outcome:"failure"}),z.error(s("billing.payment.failed","支付未完成,请稍后重试"))}}),y=A.session;if(u.useEffect(()=>{!n||!o||(v.current=!1,a.recordStep(p,{step:"pending_order_review"}))},[p,a,n,o]),u.useEffect(()=>{y&&(a.recordStep(p,{step:"payment_dialog",paymentMethod:y.method.paymentMethodKind==="card"?"card":y.method.paymentType.trim().toUpperCase().endsWith("WITHHOLD")?"direct_debit":"alipay"}),y.status!=="failed"&&(v.current=!0,a.recordResult(p,{operation:"payment_start",outcome:"success"})),y.status==="failed"?a.recordResult(p,{operation:v.current?"payment":"payment_start",outcome:"failure"}):(y.status==="timed_out"||y.status==="unknown")&&a.recordResult(p,{operation:"payment",outcome:y.status}))},[p,a,y]),!n||!o)return null;const x=c.isLoading||i.loading,W=!x&&(c.isError||i.error||!i.method||!o.canPay),U=c.data?.currency||n.realSettleCurrency||n.settleCurrency,F=c.data?.payAmount,R=typeof F=="number"?Ie(String(F),U,l):"—",k=ae(n,s("billing.orderType.refund","退款")).join("、")||n.productName||"—",S=y?lt(y.method.paymentType)||Ot(y.method.paymentType):!1,B=M.site==="intl"&&y!==void 0&&ot(y.method)&&y?.status==="pending",T=y?.status==="failed"?y.failureMessage||s("billing.payment.failed","支付未完成,请稍后重试"):void 0,E=y?.status==="pending"?s("billing.payment.waitingForResult","等待支付结果确认"):y?.status==="timed_out"||y?.status==="unknown"?s("billing.payment.resultPending","暂未确认支付结果,请稍后查询"):void 0;return t.jsxs(t.Fragment,{children:[A.isOpen?null:t.jsx(De,{open:!0,onOpenChange:g=>{g||A.isSubmitting||(a.recordAction(p,{step:"pending_order_review",action:"cancel"}),d())},children:t.jsxs(Me,{className:"max-w-[440px] rounded-2xl p-6",children:[t.jsx(Ue,{children:t.jsx(Fe,{children:s("billing.payment.title","继续付款")})}),t.jsxs("dl",{className:"mt-5 space-y-2 text-14",children:[t.jsxs("div",{className:"grid min-h-7 grid-cols-[96px_minmax(0,1fr)] items-center gap-4",children:[t.jsx("dt",{className:"text-text-secondary",children:s("billing.table.goodsName","商品名称")}),t.jsx("dd",{className:"truncate text-right font-medium text-text",title:k,children:k})]}),t.jsxs("div",{className:"grid min-h-7 grid-cols-[96px_minmax(0,1fr)] items-center gap-4",children:[t.jsx("dt",{className:"text-text-secondary",children:s("billing.table.orderId","订单号")}),t.jsx("dd",{className:"truncate text-right font-mono text-text",title:n.orderId,children:n.orderId})]}),t.jsxs("div",{className:"grid min-h-7 grid-cols-[96px_minmax(0,1fr)] items-center gap-4",children:[t.jsx("dt",{className:"text-text-secondary",children:s("billing.payment.amountDue","待支付金额")}),t.jsx("dd",{className:"text-right font-semibold text-text tabular-nums",children:x?"—":R})]})]}),t.jsxs("section",{className:"mt-5",children:[t.jsx("h3",{className:"text-14 font-medium text-text",children:s("billing.payment.method","支付方式")}),x?t.jsx("div",{className:"mt-3 flex h-16 items-center justify-center rounded-xl bg-fill-secondary text-text-quaternary",children:t.jsx(we,{"aria-label":s("billing.payment.loading","正在加载支付信息"),className:"size-5 animate-spin"})}):W?t.jsxs("div",{className:"mt-3 flex h-16 items-center justify-between gap-4 roun
1ded-xl bg-fill-secondary px-4 text-14 text-text-secondary",children:[t.jsx("span",{children:s("billing.payment.loadFailed","订单支付信息加载失败")}),t.jsx(_,{variant:"tertiary",size:"md",onClick:()=>{c.refetch(),i.reload?.()},children:s("billing.action.reload","重新加载")})]}):i.options]}),t.jsxs(Be,{className:"mt-6 gap-2 sm:justify-end",children:[t.jsx(_,{variant:"outline",disabled:A.isSubmitting,onClick:()=>{a.recordAction(p,{step:"pending_order_review",action:"cancel"}),d()},children:s("billing.payment.cancel","取消")}),t.jsx(_,{variant:"secondary",disabled:x||W||A.isSubmitting||!i.method,onClick:()=>{const g=i.method;g&&(a.recordAction(p,{step:"pending_order_review",action:"continue_payment"}),A.start(g))},children:A.isSubmitting?s("billing.payment.starting","正在发起支付"):typeof F=="number"?s("billing.payment.payAmount","支付 {{amount}}",{amount:R}):s("billing.action.pay","支付")})]})]})}),A.isOpen&&y&&B?t.jsx(ct,{open:!0,onClose:A.dismiss}):null,A.isOpen&&y&&!B?t.jsx(dt,{site:M.site,productLabel:k,billingLabel:s("billing.payment.orderPayment","订单续付"),amount:y.intent.amountCents/100,currency:y.intent.currency,paymentMethodLabel:y.method.name,paymentMethodIconUrl:y.method.iconUrl,qrCodeUrl:S?y.paymentUrl:void 0,externalPaymentUrl:S?void 0:y.paymentUrl,paymentFailureMessage:T,paymentProgressMessage:E,manualPaymentCheckLoading:A.isChecking,onManualPaymentCheck:y.status==="timed_out"||y.status==="unknown"?()=>{a.recordAction(p,{step:"payment_dialog",action:"manual_check"}),A.checkPaymentResult()}:void 0,dismissOnOverlayClick:!1,compact:!0,confirmBeforeClose:!0,onClose:()=>{A.dismiss()},onAbandon:()=>{a.recordAction(p,{step:"payment_dialog",action:"abandon"}),a.recordResult(p,{operation:"payment",outcome:"abandoned"}),A.dismiss()}}):null]})},qt=e=>{const{order:n}=e;return n?t.jsx(Lt,{client:Q,productCodes:Se(n),enabled:!!e.orderDetailQuery.data,children:i=>t.jsx(Te,{...e,methodState:i})}):null},Wt=e=>{const{order:n}=e;return n?t.jsx(Mt,{client:Q,createWriteClient:Pe,currency:n.realSettleCurrency||n.settleCurrency||void 0,children:i=>t.jsx(Te,{...e,methodState:i})}):null},Yt=e=>{const n=xe(),i=X({queryKey:["billing","continue-payment","order-detail",e.order?.orderId],queryFn:async()=>{const d=e.order?.orderId??"";if(!n)return me(Q,d);const r=await pt(Q);return me(Q,d,"intl",{nbid:r,orderType:e.order?.orderType??""})},enabled:!!e.order?.orderId,retry:!1});if(!e.order)return null;const c=n?{channel:"SIN",locale:"en-US",apiBaseUrl:M.baseUrl,gateway:"oneconsole"}:{channel:"OFFICIAL",locale:"zh-CN",apiBaseUrl:M.baseUrl};return t.jsx(It,{value:c,children:n?t.jsx(Wt,{...e,orderDetailQuery:i}):t.jsx(qt,{...e,orderDetailQuery:i})})},Kt=e=>{const{orderType:n,status:i,sortBy:c,onOrderTypeChange:d,onStatusChange:r,onSortChange:s}=e,{t:l}=H();return t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs(Z,{value:n,onValueChange:b=>d(b),children:[t.jsx(J,{className:"h-9 w-40","aria-label":l("billing.filter.orderType","订单类型"),children:t.jsx(ee,{})}),t.jsxs(te,{children:[t.jsx(P,{value:"ALL",children:l("billing.filter.allOrderTypes","订单类型:全部")}),t.jsx(P,{value:"BUY",children:l("billing.orderType.buy","新购")}),t.jsx(P,{value:"RENEW",children:l("billing.orderType.renew","ç»­è´¹")}),t.jsx(P,{value:"UPGRADE",children:l("billing.orderType.upgrade","升级")}),t.jsx(P,{value:"REFUND",children:l("billing.orderType.refund","退款")}),t.jsx(P,{value:"CHANGE_RESIGN",children:l("billing.orderType.changeResign","套餐变更")})]})]}),t.jsxs(Z,{value:i,onValueChange:b=>r(b),children:[t.jsx(J,{className:"h-9 w-48 whitespace-nowrap","aria-label":l("billing.filter.status","订单状态"),children:t.jsx(ee,{})}),t.jsxs(te,{children:[t.jsx(P,{value:"ALL",children:l("billing.filter.allStatuses","订单状态:全部")}),t.jsx(P,{value:"PAID",children:l("billing.status.paid","已支付")}),t.jsx(P,{value:"UNPAID",children:l("billing.status.unpaid","未支付")}),t.jsx(P,{value:"PAYING",children:l("billing.status.paying","支付中")}),t.jsx(P,{value:"CONFIRM",children:l("billing.status.confirming","确认中")}),t.jsx(P,{value:"CANCELED",children:l("billing.status.canceled","已取消")})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"shrink-0 text-sm text-text-secondary",children:l("billing.filter.sortBy","排序方式")}),t.jsxs(Z,{value:c,onValueChange:b=>s(b),children:[t.jsx(J,{className:"h-9 w-36","aria-label":l("billing.filter.sortBy","排序方式"),children:t.jsx(ee,{})}),t.jsxs(te,{children:[t.jsx(P,{value:"DEFAULT",children:l("billing.filter.defaultSort","默认排序")}),t.jsx(P,{value:"createdAt",children:l("billing.filter.createdAtSort","按创建时间")}),t.jsx(P,{value:"updatedAt",children:l("billing.filter.updatedAtSort","按更新时间")})]})]})]})]})},he=e=>e==="PAID"?"success":e==="UNPAID"||e==="PAYING"||e==="CONFIRM"?"warning":"default",zt=e=>{const{orders:n,pendingOrderId:i,onPay:c,onVoid:d}=e,{t:r}=H(),s=fe(),l=(a,o)=>Ie(o,a.realSettleCurrency||a.settleCurrency,s),b=a=>{if(a.orderStatus!=="UNPAID")return null;const o=i===a.orderId;return t.jsxs("div",{className:"flex w-fit items-center gap-2 whitespace-nowrap",children:[t.jsx(_,{type:"button",variant:"secondary",size:"md",rounded:"xl",disabled:o,onClick:()=>c(a),children:r("billing.action.pay","支付")}),t.jsx(_,{type:"button",variant:"outline",size:"md",rounded:"xl",disabled:o,onClick:()=>d(a),children:r("billing.action.void","作废")})]})};return t.jsxs("div",{className:"@container/billing-orders",children:[t.jsx("div",{className:"hidden overflow-x-auto rounded-xl border border-border-light @min-[1280px]/billing-orders:block",children:t.jsxs("table",{className:"w-full min-w-[1280px] text-left text-13",children:[t.jsx("thead",{className:"border-b border-border-light bg-bg-sidebar-normal text-text-secondary [&_th]:whitespace-nowrap",children:t.jsxs("tr",{className:"h-10",children:[t.jsx("th",{className:"w-44 min-w-44 max-w-44 px-3 font-normal",children:r("billing.table.orderId","订单号")}),t.jsx("th",{className:"min-w-44 px-3 font-normal",children:r("billing.table.goodsName","商品名称")}),t.jsx("th",{className:"min-w-24 px-3 font-normal",children:r("billing.table.orderType","è
1®¢å•类型")}),t.jsx("th",{className:"min-w-24 px-3 font-normal",children:r("billing.table.status","订单状态")}),t.jsx("th",{className:"min-w-40 px-3 font-normal",children:r("billing.table.createdAt","创建时间")}),t.jsx("th",{className:"min-w-40 px-3 font-normal",children:r("billing.table.paidAt","支付/开通时间")}),t.jsx("th",{className:"min-w-28 px-3 font-normal",children:r("billing.table.originalAmount","原价")}),t.jsx("th",{className:"min-w-28 px-3 font-normal",children:r("billing.table.paidAmount","实付金额")}),t.jsx("th",{className:"min-w-20 px-2 font-normal",children:r("billing.table.discountAmount","优惠金额")}),t.jsx("th",{className:"w-px min-w-36 whitespace-nowrap px-3 font-normal",children:r("billing.table.action","操作")})]})}),t.jsx("tbody",{children:n.map(a=>{const o=ae(a,r("billing.orderType.refund","退款"));return t.jsxs("tr",{className:"h-14 border-b border-border-light text-text transition-colors last:border-0 hover:bg-overlay-on-container-hover",children:[t.jsx("td",{className:"w-44 max-w-44 truncate whitespace-nowrap px-3 font-mono tabular-nums",title:a.orderId,children:a.orderId}),t.jsx("td",{className:"max-w-52 px-3 py-2",title:o.join(`
2`),children:t.jsx("div",{className:"line-clamp-2 break-words",children:o.join("、")||"—"})}),t.jsx("td",{className:"whitespace-nowrap px-3",children:ye(a.orderType,r)}),t.jsx("td",{className:"whitespace-nowrap px-3",children:t.jsx(oe,{color:he(a.orderStatus),className:"h-6 rounded-full px-2.5 text-xs",children:ge(a.orderStatus,r,a.orderType)})}),t.jsx("td",{className:"whitespace-nowrap px-3 tabular-nums",children:V(a.gmtCreate,s)}),t.jsx("td",{className:"whitespace-nowrap px-3 tabular-nums",children:V(a.gmtPay,s)}),t.jsx("td",{className:"whitespace-nowrap px-3 tabular-nums",children:l(a,a.originalAmount)}),t.jsx("td",{className:"whitespace-nowrap px-3 tabular-nums",children:a.orderStatus==="UNPAID"?"—":l(a,a.payAmount)}),t.jsx("td",{className:"whitespace-nowrap px-2 tabular-nums",children:l(a,a.promotionAmount)}),t.jsx("td",{className:"w-px min-w-36 whitespace-nowrap px-3",children:b(a)??"—"})]},a.orderId)})})]})}),t.jsx("div",{className:"grid gap-3 @min-[720px]/billing-orders:grid-cols-2 @min-[1280px]/billing-orders:hidden",children:n.map(a=>{const o=ae(a,r("billing.orderType.refund","退款"));return t.jsxs("article",{className:"rounded-xl border border-border-light bg-bg-card-z1 p-4",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"line-clamp-2 break-words text-sm font-medium text-text",title:o.join(`
3`),children:o.join("、")||"—"}),t.jsx("p",{className:"mt-1 truncate whitespace-nowrap font-mono text-xs text-text-tertiary",children:a.orderId})]}),t.jsx(oe,{color:he(a.orderStatus),className:"h-6 shrink-0 rounded-full px-2.5 text-xs",children:ge(a.orderStatus,r,a.orderType)})]}),t.jsx("dl",{className:"mt-4 grid grid-cols-2 gap-x-4 gap-y-3 text-xs",children:[{label:r("billing.table.orderType","订单类型"),value:ye(a.orderType,r)},{label:r("billing.table.createdAt","创建时间"),value:V(a.gmtCreate,s)},{label:r("billing.table.paidAt","支付/开通时间"),value:V(a.gmtPay,s)},{label:r("billing.table.originalAmount","原价"),value:l(a,a.originalAmount)},{label:r("billing.table.paidAmount","实付金额"),value:a.orderStatus==="UNPAID"?"—":l(a,a.payAmount)},{label:r("billing.table.discountAmount","优惠金额"),value:l(a,a.promotionAmount)}].map(({label:p,value:v})=>t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"text-text-tertiary",children:p}),t.jsx("dd",{className:"mt-1 truncate whitespace-nowrap text-text",title:v,children:v})]},p))}),a.orderStatus==="UNPAID"?t.jsx("div",{className:"mt-4 border-t border-border-light pt-3",children:b(a)}):null]},a.orderId)})})]})},Qt=10,Gt={currentPage:1,pageSize:Qt},G=e=>({attemptId:e.orderId,productType:ve(e.orderLines?.map(({commodityCode:n})=>n.trim()).filter(Boolean)??[]),scope:"personal"}),$t=()=>{const{t:e}=H(),n=qe(),i=ft,c=xe(),[d]=u.useState(Ae),[r]=u.useState(()=>Ce({site:c?"intl":"cn",channel:d})),[s,l]=u.useState(Gt),[b,a]=u.useState(),[o,p]=u.useState(),v=u.useRef(new Map),[N,A]=u.useState(),y=We({query:{staleTime:3e4,refetchOnWindowFocus:!1}}),x=X(xt.orderList(i,s)),W=X({queryKey:ne,queryFn:()=>yt(c?"intl":"cn"),staleTime:0,retry:1,refetchInterval:3e4,refetchOnWindowFocus:!0}),U=ce(x.error)&&x.error.response?.status===404,F=y.data?.nickname||y.data?.username||e("billing.page.userFallback","千问办公用户"),R=Ct(W.data),k=At(N,R);u.useEffect(()=>{N&&!k&&A(void 0)},[N,k]),u.useEffect(()=>{o&&r.recordStep(G(o.order),{step:"cancel_order_confirmation"})},[r,o]);const S=de({mutationFn:i.voidOrder,onSuccess:async(g,f)=>{const C=v.current.get(f.orderId);C&&(r.recordResult(G(C),{operation:"cancel_order",outcome:"success",orderReference:re(f.orderId)}),v.current.delete(f.orderId)),p(void 0),await n.invalidateQueries({queryKey:$.orders()}),z.success(e("billing.void.success","订单已作废"))},onError:(g,f)=>{const C=v.current.get(f.orderId);C&&r.recordResult(G(C),{operation:"cancel_order",outcome:"failure",orderReference:re(f.orderId)}),z.error(e("billing.void.failed","订单作废失败,请稍后重试"))}}),O=de({mutationFn:async g=>g==="cancel"?await vt():await wt(),onSuccess:async(g,f)=>{await n.invalidateQueries({queryKey:ne}),A(void 0),z.success(f==="cancel"?e("billing.autoRenewal.cancelSuccess","自动续费已关闭"):e("billing.autoRenewal.enableSuccess","自动续费已开启"))},onError:(g,f)=>{ce(g)&&g.response?.status===403&&(A(void 0),n.invalidateQueries({queryKey:ne})),z.error(f==="cancel"?e("billing.autoRenewal.cancelFailed","自动续费关闭失败,请稍后重试"):e("billing.autoRenewal.enableFailed","自动续费开启失败,请稍后重试"))}}),B=g=>{l(f=>({...f,currentPage:1,orderType:g==="ALL"?void 0:g}))},T=g=>{l(f=>({...f,currentPage:1,orderStatus:g==="ALL"?void 0:g}))},E=g=>{l(f=>({...f,currentPage:1,sortBy:g==="DEFAULT"?void 0:g}))};return t.jsxs("div",{className:"flex min-h-dvh flex-col bg-bg-base text-text",children:[t.jsx(Ye,{accountName:F,avatarUrl:y.data?.avatar||void 0,accountLoading:y.isLoading,accountPopover:{badge:e("billing.page.personal","个人")},actions:t.jsx(_,{variant:"ghost",rounded:"pill",className:"!h-8 bg-primary-bg px-3 text-text-accent-normal hover:bg-primary-bg-hover hover:text-text-accent-hover",onClick:()=>window.location.assign("/subscribe"),children:e("subscription.page.rechargeCredits","充值积分")})}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:t.jsxs("main",{className:"mx-auto w-full max-w-[1600px] px-4 pb-16 pt-8 sm:px-8 lg:px-12",children:[t.jsxs("header",{children:[t.jsx("h1",{className:"text-[28px] font-semibold leading-9 text-text",children:e("billing.page.title","订单管理")}),t.jsx("p",{className:"mt-1 text-sm text-text-tertiary",children:e("billing.page.subtitle","个人版 · 千问办公订单")})]}),t.jsxs("section",{className:"mt-5 flex flex-col items-stretch justify-between gap-4 roun
3ded-xl border border-border-light bg-bg-card-z1 px-5 py-4 sm:flex-row sm:items-center",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-13 text-text-secondary",children:e("billing.page.currentAccount","当前账户")}),t.jsx("div",{className:"mt-1 text-xl font-semibold leading-7 text-text",children:e("billing.page.personalAccount","个人账户")})]}),c||R?t.jsxs("div",{className:"grid gap-2 sm:flex sm:shrink-0 sm:items-center",children:[c?t.jsx(_,{type:"button",variant:"outline",rounded:"xl",className:"h-9 px-4",onClick:ht,children:e("billing.action.managePaymentMethods","管理支付方式")}):null,R?t.jsx(_,{type:"button",variant:"outline",rounded:"xl",className:"h-9 px-4",onClick:()=>A(R),children:R==="cancel"?e("billing.autoRenewal.cancelAction","关闭自动续费"):e("billing.autoRenewal.enableAction","开启自动续费")}):null]}):null]}),t.jsxs("section",{className:"mt-5 flex flex-wrap items-start justify-between gap-3",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(Kt,{orderType:s.orderType||"ALL",status:s.orderStatus||"ALL",sortBy:s.sortBy||"DEFAULT",onOrderTypeChange:B,onStatusChange:T,onSortChange:E})}),t.jsx(_,{type:"button",variant:"secondary",rounded:"xl",className:"h-9 shrink-0 px-5",onClick:bt,children:e("billing.action.issueInvoice","开具发票")})]}),x.isLoading?t.jsx("div",{className:"flex min-h-72 items-center justify-center text-text-quaternary",children:t.jsx(we,{"aria-label":e("billing.page.loading","正在加载订单"),className:"size-5 animate-spin"})}):x.isError&&!U?t.jsx(ue,{className:"mt-6",icon:t.jsx($e,{className:"size-5"}),title:e("billing.page.loadFailed","订单加载失败"),description:e("billing.page.retryLater","请稍后重试"),action:t.jsx(_,{variant:"secondary",onClick:()=>x.refetch(),children:e("billing.action.reload","重新加载")})}):x.data?.orders.length?t.jsxs("div",{className:"mt-5",children:[t.jsx(zt,{orders:x.data.orders,pendingOrderId:S.isPending?S.variables?.orderId:void 0,onPay:a,onVoid:g=>{v.current.set(g.orderId,g),r.recordAction(G(g),{step:"cancel_order_confirmation",action:"request_cancel"}),p({order:g,orderId:g.orderId,idempotencyKey:crypto.randomUUID()})}}),t.jsx(Ke,{className:"mt-4",current:x.data.currentPage,total:x.data.totalCount,pageSize:x.data.pageSize,disabled:x.isFetching,totalFormatter:g=>e("billing.page.total","共 {{count}} 条",{count:g}),onChange:g=>l(f=>({...f,currentPage:g}))})]}):t.jsx(ue,{className:"mt-6",icon:t.jsx(ze,{className:"size-5"}),title:e("billing.page.empty","暂无订单"),description:e("billing.page.emptyDescription","调整查询条件后再试试")}),t.jsx("div",{className:"mt-4 text-right text-xs leading-5 text-text-quaternary",children:e("billing.page.historyStartNotice","仅展示 2026 年 9 月 1 日后的订单信息")})]})}),t.jsx(pe,{open:k,title:N==="enable"?e("billing.autoRenewal.enableTitle","开启自动续费?"):e("billing.autoRenewal.cancelTitle","关闭自动续费?"),description:N==="enable"?e("billing.autoRenewal.enableDesc","开启后,将在当前周期结束时自动续费。"):e("billing.autoRenewal.cancelDesc","关闭后,本期权益仍可使用至当前周期结束,之后不再自动续费。"),secondaryActionLabel:e("common.cancel","取消"),primaryActionLabel:O.isPending?N==="enable"?e("billing.autoRenewal.enabling","正在开启"):e("billing.autoRenewal.canceling","正在关闭"):N==="enable"?e("billing.autoRenewal.enableConfirm","确认开启"):e("billing.autoRenewal.cancelConfirm","确认关闭"),actionsDisabled:O.isPending,fullWidthActions:!0,onDismiss:()=>{O.isPending||A(void 0)},onSecondaryAction:()=>A(void 0),onPrimaryAction:()=>{k&&N&&O.mutate(N)}}),t.jsx(pe,{open:!!o,title:e("billing.void.title","作废订单"),description:e("billing.void.description","作废后该订单将无法继续付款,确定作废“{{product}}”吗?",{product:o?.order.productName||e("billing.void.orderFallback","该订单")}),secondaryActionLabel:e("billing.void.keep","保留订单"),primaryActionLabel:S.isPending?e("billing.void.processing","正在作废"):e("billing.void.confirm","确认作废"),actionsDisabled:S.isPending,fullWidthActions:!0,onDismiss:()=>{S.isPending||(o&&v.current.delete(o.orderId),p(void 0))},onSecondaryAction:()=>{o&&v.current.delete(o.orderId),p(void 0)},onPrimaryAction:()=>{o&&(r.recordAction(G(o.order),{step:"cancel_order_confirmation",action:"confirm_cancel"}),S.mutate(o))}}),t.jsx(Yt,{order:b,onClose:()=>a(void 0),onSuccess:()=>{a(void 0),n.invalidateQueries({queryKey:$.orders()}),z.success(e("billing.payment.successAndUpdated","支付完成,订单状态已更新"))}})]})};function sn(){const{isAuthenticated:e}=Qe();return e?t.jsx($t,{}):t.jsx(Ge,{to:"/signin",search:{return_to:"/subscribe/billing"},replace:!0})}export{sn as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.