PageSourceSearch

https://hansai.art/_next/static/chunks/pages/admin/super/payment-0da810b83ca6ba66.js

js hansai.art collected 2026-10-07 20:20:11 UTC 30,176 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[56574],{19941:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/super/payment",function(){return r(56166)}])},46817:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var l=r(2445),a=r(27006),n=r(96540),i=r(44995);let o=(0,a.forwardRef)((e,t)=>{let{href:r,trackerName:o,onClick:d,label:c,...s}=e,u=(0,n.useCallback)(e=>{d&&d(e),o&&"function"==typeof window.gtag&&window.gtag("event","click_button",{button_name:o})},[d,o]),h=(0,n.useMemo)(()=>r&&!s.isDisabled?(0,l.Y)(a.IconButton,{ref:t,href:r,as:i.A,onClick:u,...s}):(0,l.Y)(a.IconButton,{onClick:u,...s,ref:t}),[u,r,s,t]);return c?(0,l.Y)(a.Tooltip,{label:c,children:h}):h})},3748:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var l=r(2445),a=r(18854),n=r(96540);let i=function(e){var t;let{labels:r,column:i,withCount:o=!1,valueGetter:d}=e,{filterValue:c,setFilter:s,preFilteredRows:u,id:h}=i,[p,m]=(0,n.useMemo)(()=>{let e={},t=new Set;return u.forEach(r=>{let l=d?d(r.original,r):r.values[h],a=null==l?"":String(l);o&&(e[a]=(e[a]||0)+1),t.add(a)}),[Array.from(t).sort((t,r)=>o?(e[r]||0)-(e[t]||0):t.localeCompare(r)),e]},[h,u,d,o]),g=null!=c?c:"";return(0,l.FD)(a.l,{size:"sm",value:g,name:h,onChange:e=>{s(e.target.value||void 0)},children:[(0,l.Y)("option",{value:"",children:"All"}),g&&!p.includes(g)&&(0,l.Y)("option",{value:g,children:null!==(t=null==r?void 0:r[g])&&void 0!==t?t:g}),p.map(e=>{var t;return(0,l.FD)("option",{value:e,children:[r&&null!==(t=r[e])&&void 0!==t?t:e,o?" (".concat(m[e]||0,")"):""]},e)})]})}},59986:(e,t,r)=>{"use strict";r.d(t,{A:()=>m});var l=r(2445),a=r(27006),n=r(8423),i=r(42371),o=r(93540),d=r(91672),c=r(33087),s=r(37323),u=r(43252),h=r(59397),p=r(99370);let m=e=>{let{data:t,dataKey:r,dataPointName:m,children:g,isSmooth:y=!1,showDots:Y=!1}=e,b=(0,a.useConst)(()=>(0,n.A)(6)),[x]=(0,a.useToken)("colors",["GUI.green.500"]);return(0,l.Y)(i.u,{children:(0,l.FD)(o.Q,{data:t,children:[(0,l.Y)("defs",{children:(0,l.FD)("linearGradient",{id:b,x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,l.Y)("stop",{offset:"0%",stopColor:x}),(0,l.Y)("stop",{offset:"100%",stopColor:x,stopOpacity:"0"})]})}),(0,l.Y)(d.W,{dataKey:"date",tickFormatter:e=>String(e).substring(5).replace("-","/"),ticks:(0,h.A)(t)}),(0,l.Y)(c.h,{allowDecimals:!1,tickFormatter:p.A}),(0,l.Y)(s.d,{stroke:"#eee",vertical:!1}),(0,l.Y)(u.G,{type:y?"monotoneX":"linear",strokeWidth:1.5,dataKey:r,stroke:x,fill:"url(#".concat(b,")"),name:m,dot:!!Y&&{strokeWidth:1.5,r:5,fill:"white",fillOpacity:1,stroke:x}}),g]})})}},59397:(e,t,r)=>{"use strict";r.d(t,{A:()=>l});let l=function(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"date",l=(null===(t=[[10,1],[30,5],[90,10]].reverse().find(t=>{let[r]=t;return e.length>=r}))||void 0===t?void 0:t[1])||1;return l>1?[...e].reverse().filter((e,t)=>t%l==0).map(e=>e[r]).reverse():void 0}},99370:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let l=(0,r(2199).GP)(".2s"),a=e=>0===e?"":e>=1&&e<10?e:l(e)},95738:(e,t,r)=>{"use strict";r.d(t,{A:()=>i,m:()=>n});var l=r(2445),a=r(22061);let n=[{name:"analytics",label:"Metrics"},{name:"revenue",label:"營收分析"},{name:"subscriptions",label:"會員分析"},{name:"payment",label:"Payment"},{name:"product-metrics",label:"產品指標"},{name:"affiliates",label:"Rewards"},{name:"digital-products",label:"商品贊助"},{name:"referrals-metrics",label:"推薦成效分析"}],i=e=>{let{tabs:t}=e;return(0,l.Y)(a.A,{tabs:t,allTabs:n})}},73064:(e,t,r)=>{"use strict";r.d(t,{A:()=>c});var l=r(2445),a=r(27006);r(96540);var n=r(89571),i=r(46817),o=r(44995),d=r(84316);let c=e=>{let{value:t,children:r}=e,c=t||r,s=(0,d.A)(c);return!!c&&(0,l.FD)(a.HStack,{children:[(0,l.Y)(o.A,{href:s,isExternal:!0,children:"/".concat(c)}),(0,l.Y)(i.A,{href:s,isExternal:!0,icon:(0,l.Y)(n.Dus,{size:"1.5em"}),variant:"ghost",size:"sm"})]})}},49177:(e,t,r)=>{"use strict";r.d(t,{$i:()=>o,RU:()=>g,S8:()=>x,YW:()=>h,_W:()=>b,a7:()=>u,ae:()=>m,b6:()=>s,mG:()=>v,pp:()=>y,tK:()=>p});var l=r(77381),a=r(39182),n=r(85911),i=r(74447);let o="Asia/Taipei",d=/^\d{4}-\d{2}-\d{2}$/,c=e=>{if(e instanceof Date)return e;if("number"==typeof e)return new Date(e);if(d.test(e))return new Date("".concat(e,"T00:00:00.000Z"));let t=new Date(e);if(Number.isNaN(t.getTime())||/[Zz]|[+-]\d{2}:?\d{2}$/.test(e))return t;throw TypeError('adminTimezone: 無時區資訊的日期字串 "'.concat(e,'" 會依瀏覽器時區解析,請傳 yyyy-MM-dd、帶時區的 ISO 字串或 Date'))},s=(e,t)=>{if(null==e||""===e)return"";let r=c(e);
1return Number.isNaN(r.getTime())?"":(0,i.formatInTimeZone)(r,o,t)},u=e=>s(e,"yyyy-MM-dd"),h=e=>s(e,"yyyy-MM"),p=e=>(0,i.zonedTimeToUtc)("".concat(u(e),"T00:00:00.000"),o),m=e=>(0,i.zonedTimeToUtc)("".concat(u(e),"T23:59:59.999"),o),g=e=>{let[t,r,l]=u(e).split("-").map(Number);return new Date(t,r-1,l)},y=()=>g(new Date),Y=e=>(0,i.zonedTimeToUtc)("".concat((0,l.A)(e,"yyyy-MM-dd"),"T00:00:00.000"),o),b=(e,t)=>Y((0,a.A)(g(e),t)),x=(e,t)=>(0,n.A)(g(t),g(e))+1,v=(e,t)=>{let r=g(e);return Array.from({length:Math.max(x(e,t),0)},(e,t)=>(0,l.A)((0,a.A)(r,t),"yyyy-MM-dd"))}},56166:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>eB});var l=r(2445),a=r(13368),n=r.n(a),i=r(95738),o=r(46960),d=r(27006),c=r(96540),s=r(77037),u=r(89571),h=r(46817),p=r(41421),m=r(58323),g=r(3748);let y=["one-time","monthly","yearly"],Y={"one-time":"單次付款",monthly:"月訂閱",yearly:"年訂閱"},b={"one-time":"gray",monthly:"teal",yearly:"orange"},x={live:"已建正式 key",test:"僅測試 key",none:"未串接"},v={verified:"已認證",submitted:"待審核",rejected:"待修正",none:"未送審"},f={verified:"green",submitted:"orange",rejected:"red",none:"gray"},w=e=>/^https?:\/\//i.test(e)?e:"https://".concat(e);var S=r(73064),F=r(39911),k=r(59986),T=r(26923);r(44846);let D=(e,t)=>t>0?"".concat((e/t*100).toFixed(1),"%"):"—",A=e=>{let{title:t,headers:r,rows:a}=e;return(0,l.FD)(d.Stack,{spacing:3,children:[t&&(0,l.Y)(d.Heading,{size:"sm",children:t}),(0,l.Y)(d.TableContainer,{children:(0,l.FD)(d.Table,{variant:"simple",sx:{"th, td":{borderLeftWidth:"1px",borderRightWidth:"1px"},th:{bg:"gray.50",borderTopWidth:"1px",whiteSpace:"nowrap"}},children:[(0,l.Y)(d.Thead,{children:(0,l.Y)(d.Tr,{children:r.map((e,t)=>(0,l.Y)(d.Th,{px:"3",fontSize:"sm",isNumeric:t>0,children:e},e))})}),(0,l.Y)(d.Tbody,{children:a.map(e=>(0,l.FD)(d.Tr,{bg:e.emphasis?"teal.50":void 0,children:[(0,l.FD)(d.Td,{px:"3",py:"4",pl:e.indent?8:"3",fontWeight:e.emphasis?"bold":void 0,color:e.indent?"gray.600":void 0,children:[e.label,e.tooltip&&(0,l.Y)(p.A,{size:3.5,color:"gray.400",as:T.kAG,ml:1,children:e.tooltip})]}),e.values.map((t,r)=>(0,l.Y)(d.Td,{px:"3",py:"4",isNumeric:!0,fontWeight:e.emphasis?"bold":void 0,sx:{fontVariantNumeric:"tabular-nums"},children:"number"==typeof t?t.toLocaleString():t},"".concat(e.key,"-").concat(r)))]},e.key))})]})})]})},W=e=>{let{isLoading:t,error:r,children:a}=e;return r?(0,l.FD)(d.Stack,{spacing:2,children:[(0,l.Y)(d.Text,{color:"red.500",children:"數據載入失敗,請稍後再試。"}),(0,l.Y)(d.Text,{fontSize:"xs",color:"gray.500",whiteSpace:"pre-wrap",children:r instanceof Error?r.message:String(r)})]}):t?(0,l.Y)(d.Spinner,{}):(0,l.Y)(l.FK,{children:a})};var z=r(93540),B=r(42371),C=r(91672),H=r(33087),M=r(37323),I=r(1191),L=r(43252),R=r(59397),N=r(99370);let P=z.Q,K=["#51CBCE","#EF8157","#FBC658","#6ED19A","#68A2E0","#C58CE0","#F19DB5","#8DA2B5"],E=e=>"NT$ ".concat(Math.round(e).toLocaleString("en-US")),G=e=>{let{series:t}=e,r=(0,c.useMemo)(()=>t.length&&t[0].daily.length?t[0].daily.map((e,r)=>{let l={date:e.date};return t.forEach(e=>{var t,a;l[e.id]=null!==(a=null===(t=e.daily[r])||void 0===t?void 0:t.revenue)&&void 0!==a?a:0}),l}):[],[t]);return(0,l.Y)(d.Box,{h:"240px",children:(0,l.Y)(B.u,{children:(0,l.FD)(P,{data:r,children:[(0,l.Y)(C.W,{dataKey:"date",tickFormatter:e=>String(e).substring(5).replace("-","/"),ticks:(0,R.A)(r)}),(0,l.Y)(H.h,{allowDecimals:!1,tickFormatter:N.A}),(0,l.Y)(M.d,{stroke:"#eee",vertical:!1}),(0,l.Y)(F.m,{formatter:(e,t)=>[E(e),t]}),(0,l.Y)(I.s,{}),t.map((e,t)=>(0,l.Y)(L.G,{type:"monotoneX",dataKey:e.id,name:e.name,stackId:"revenue",stroke:K[t%K.length],fill:K[t%K.length],fillOpacity:.75,strokeWidth:1.5},e.id))]})})})};var O=r(59324),_=r(11335);let U={revalidateOnFocus:!1,dedupingInterval:3e4},$=e=>{let t=(0,_.A)();return(0,O.Ay)(e?"/api/super/payment-metrics/summary?start=".concat(e.start,"&end=").concat(e.end):null,t,U)},X=e=>{let t=(0,_.A)();return(0,O.Ay)(e?"/api/super/payment-metrics/list?start=".concat(e.start,"&end=").concat(e.end):null,t,U)},j=(e,t,r)=>{let l=(0,_.A)();return(0,O.Ay)(e&&t&&r?"/api/super/payment-metrics/trend?type=".concat(e,"&id=").concat(encodeURIComponent(t),"&start=").concat(r.start,"&end=").concat(r.end):null,l,U)},Q=m.A,V=S.A,Z=k.A,q=e=>
1"NT$ ".concat(Math.round(e).toLocaleString("en-US")),J=e=>{let{label:t,value:r}=e;return(0,l.FD)(d.Box,{borderWidth:"1px",rounded:"md",px:"4",py:"3",children:[(0,l.Y)(d.Text,{fontSize:"sm",color:"gray.500",children:t}),(0,l.Y)(d.Text,{fontSize:"2xl",fontWeight:"bold",mt:"1",children:r})]})},ee=e=>{let{account:t,windowRevenue:r,windowOrders:a,daily:n,products:i,onBack:o,onSelectProduct:s}=e,u=(0,c.useMemo)(()=>[...i].sort((e,t)=>t.windowRevenue-e.windowRevenue).map(e=>({id:e.merchantId,name:e.name,daily:e.daily})),[i]),h=(0,c.useMemo)(()=>[{Header:"產品",accessor:"name",disableFilters:!0},{Header:"審核狀態",accessor:"reviewStatus",disableFilters:!0,Cell:e=>{let{value:t}=e;return(0,l.Y)(d.Tag,{size:"sm",colorScheme:f[t],children:v[t]})}},{Header:"銷售方式",accessor:"saleModes",disableFilters:!0,disableSortBy:!0,Cell:e=>{let{value:t}=e;return(0,l.Y)(d.HStack,{spacing:"1",flexWrap:"wrap",children:y.filter(e=>t.includes(e)).map(e=>(0,l.Y)(d.Tag,{size:"sm",colorScheme:b[e],children:Y[e]},e))})}},{Header:"建立日期",accessor:"createdAt",disableFilters:!0,Cell:e=>{let{value:t}=e;return(0,l.Y)(d.Text,{as:"span",whiteSpace:"nowrap",children:null!=t?t:"—"})}},{Header:"交易收入",accessor:"windowRevenue",disableFilters:!0,Cell:e=>{let{value:t}=e;return(0,l.Y)(d.Text,{as:"span",whiteSpace:"nowrap",children:q(t)})}},{Header:"交易筆數",accessor:"windowOrders",disableFilters:!0,Cell:e=>{let{value:t}=e;return(0,l.Y)(d.Text,{as:"span",whiteSpace:"nowrap",children:t.toLocaleString()})}},{Header:"操作",id:"plans",accessor:"merchantId",disableFilters:!0,disableSortBy:!0,Cell:e=>{let{row:{original:t}}=e;return(0,l.Y)(d.Button,{size:"sm",variant:"outline",colorScheme:"teal",onClick:()=>s(t.merchantId),children:"查看"})}}],[s]);return(0,l.FD)(d.Stack,{spacing:5,children:[(0,l.FD)(d.HStack,{flexWrap:"wrap",children:[(0,l.Y)(d.Button,{size:"sm",variant:"outline",onClick:o,children:"← 回列表"}),(0,l.Y)(d.Heading,{size:"md",children:t.name||t.slug}),(0,l.Y)(d.Box,{maxW:"20em",sx:{"& a":{display:"inline-block",maxW:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"middle"}},title:"/".concat(t.slug),children:(0,l.Y)(V,{value:t.slug})}),t.companyName&&(0,l.Y)(d.Tooltip,{label:"金流審核為公司戶",placement:"top",children:(0,l.Y)(d.Tag,{size:"sm",children:t.companyName})}),(0,l.Y)(d.Badge,{variant:"subtle",colorScheme:"premium"===t.vipStatus?"teal":"gray",children:t.vipStatus})]}),(0,l.FD)(d.SimpleGrid,{columns:{base:1,md:3},spacing:"4",children:[(0,l.Y)(J,{label:"交易收入",value:q(r)}),(0,l.Y)(J,{label:"交易量",value:a.toLocaleString()}),(0,l.Y)(J,{label:"串接產品數",value:String(t.productCount)})]}),(0,l.FD)(d.SimpleGrid,{columns:{base:1,lg:2},spacing:"4",children:[(0,l.FD)(d.Box,{borderWidth:"1px",rounded:"md",p:"4",children:[(0,l.Y)(d.Text,{fontWeight:"bold",mb:"2",children:"帳號總收入"}),(0,l.Y)(d.Box,{h:"190px",children:(0,l.Y)(Z,{data:n,dataKey:"revenue",dataPointName:"收入",isSmooth:!0,children:(0,l.Y)(F.m,{formatter:e=>[q(e),"收入"]})})})]}),(0,l.FD)(d.Box,{borderWidth:"1px",rounded:"md",p:"4",children:[(0,l.Y)(d.Text,{fontWeight:"bold",mb:"2",children:"交易量"}),(0,l.Y)(d.Box,{h:"190px",children:(0,l.Y)(Z,{data:n,dataKey:"orders",dataPointName:"筆數",isSmooth:!0,children:(0,l.Y)(F.m,{formatter:e=>[e.toLocaleString(),"筆數"]})})})]})]}),i.length>1&&(0,l.FD)(d.Box,{borderWidth:"1px",rounded:"md",p:"4",children:[(0,l.Y)(d.Text,{fontWeight:"bold",mb:"2",children:"各產品營收(堆疊)"}),(0,l.Y)(G,{series:u})]}),(0,l.FD)(d.Box,{borderWidth:"1px",rounded:"md",p:"4",children:[(0,l.Y)(d.Text,{fontWeight:"bold",mb:"3",children:"各產品營收明細"}),(0,l.Y)(Q,{columns:h,data:i,storageKey:"super-payment-account-products:".concat(t.profileId),defaultSortBy:[{id:"windowRevenue",desc:!0}],disablePagination:!0,disableGlobalFilter:!0})]})]})},et=e=>{let{profileId:t,date:r,onBack:a,onSelectProduct:n}=e,{data:i,error:o,isLoading:c}=j("account",t,r);if(!i||"account"!==i.type)return(0,l.FD)(d.Stack,{spacing:4,children:[(0,l.Y)(d.HStack,{children:(0,l.Y)(d.Button,{size:"sm",variant:"outline",onClick:a,children:"← 回列表"})}),(0,l.Y)(W,{isLoading:c||!o,error:o,children:null})]});let{account:s,windowRevenue:u,windowOrders:h,daily:p,products:m}=i;return(0,l.Y)(ee,{account:s,windowRevenue:u,windowOrders:h,daily:p,products:m,onBack:a,onSelectProduct:n})};var er=r(57201),el=r(80431);let ea=er.b,[en,ei]=K,eo=e=>{let{daily:t}=e;return(0,l.Y)(d.Box,{h:"240px",children:(0,l.Y)(B.u,{children:(0,l.FD)(ea,{data:t,children:[(0,l.Y)(C.W,{dataKey:"date",tickFormatter:e=>String(e).substring(5).replace("-","/"),ticks:(0,R.A)(t)}),(0,l.Y)(H.h,{allowDecimals:!1,width:32}),(0,l.Y)(M.d,{stroke:"#eee",vertical:!1}),(0,l.Y)(F.m,{}),(0,l.Y)(I.s,{}),(0,l.Y)(el.N,{type:"monotoneX",dataKey:"liveApiKeys",name:"正式 key 串接",stroke:en,strokeWidth:2,dot:!1}),(0,l.Y)(el.N,{type:"monotoneX",dataKey:"reviewSubmissions",name:"送審",stroke:ei,strokeWidth:2,dot:!1})]})})})},ed=m.A,ec=S.A,es=k.A,eu=e=>
1"NT$ ".concat(Math.round(e).toLocaleString("en-US")),eh=e=>{let{label:t,value:r}=e;return(0,l.FD)(d.Box,{borderWidth:"1px",rounded:"md",px:"4",py:"3",children:[(0,l.Y)(d.Text,{fontSize:"sm",color:"gray.500",children:t}),(0,l.Y)(d.Text,{fontSize:"2xl",fontWeight:"bold",mt:"1",children:r})]})},ep=e=>{let{product:t,windowRevenue:r,windowOrders:a,daily:n,plans:i,onBack:o}=e,s=(0,c.useMemo)(()=>i.filter(e=>e.windowRevenue>0).sort((e,t)=>t.windowRevenue-e.windowRevenue).map(e=>({id:e.planId,name:e.name,daily:e.daily})),[i]),u=(0,c.useMemo)(()=>[{Header:"方案",accessor:"name",disableFilters:!0},{Header:"銷售方式",accessor:"saleMode",disableFilters:!0,Cell:e=>{let{value:t}=e;return t?(0,l.Y)(d.Tag,{size:"sm",colorScheme:b[t],children:Y[t]}):(0,l.Y)(d.Text,{as:"span",color:"gray.400",children:"—"})}},{Header:"單價",accessor:"price",disableFilters:!0,Cell:e=>{let{value:t}=e;return(0,l.Y)(d.Text,{as:"span",whiteSpace:"nowrap",children:eu(t)})}},{Header:"交易收入",accessor:"windowRevenue",disableFilters:!0,Cell:e=>{let{value:t}=e;return(0,l.Y)(d.Text,{as:"span",whiteSpace:"nowrap",children:eu(t)})}},{Header:"交易筆數",accessor:"windowOrders",disableFilters:!0,Cell:e=>{let{value:t}=e;return(0,l.Y)(d.Text,{as:"span",whiteSpace:"nowrap",children:t.toLocaleString()})}}],[]);return(0,l.FD)(d.Stack,{spacing:5,children:[(0,l.FD)(d.HStack,{flexWrap:"wrap",children:[(0,l.Y)(d.Button,{size:"sm",variant:"outline",onClick:o,children:"← 回列表"}),(0,l.Y)(d.Heading,{size:"md",children:t.name}),(0,l.Y)(d.Link,{href:w(t.url),isExternal:!0,fontSize:"sm",color:"teal.500",maxW:"24em",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",title:t.url,children:t.url.replace(/^https?:\/\//,"")}),(0,l.Y)(d.Tag,{size:"sm",colorScheme:t.isPrimary?"gray":"teal",children:t.isPrimary?"主產品":"次要產品"}),(0,l.Y)(d.Tag,{size:"sm",colorScheme:f[t.reviewStatus],children:v[t.reviewStatus]}),(0,l.Y)(d.Box,{maxW:"16em",sx:{"& a":{display:"inline-block",maxW:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"middle"}},title:"/".concat(t.slug),children:(0,l.Y)(ec,{value:t.slug})})]}),(0,l.FD)(d.SimpleGrid,{columns:{base:1,md:3},spacing:"4",children:[(0,l.Y)(eh,{label:"交易收入",value:eu(r)}),(0,l.Y)(eh,{label:"交易量",value:a.toLocaleString()}),(0,l.Y)(eh,{label:"方案數",value:String(i.length)})]}),(0,l.FD)(d.SimpleGrid,{columns:{base:1,lg:2},spacing:"4",children:[(0,l.FD)(d.Box,{borderWidth:"1px",rounded:"md",p:"4",children:[(0,l.Y)(d.Text,{fontWeight:"bold",mb:"2",children:"產品交易收入"}),(0,l.Y)(d.Box,{h:"190px",children:(0,l.Y)(es,{data:n,dataKey:"revenue",dataPointName:"收入",isSmooth:!0,children:(0,l.Y)(F.m,{formatter:e=>[eu(e),"收入"]})})})]}),(0,l.FD)(d.Box,{borderWidth:"1px",rounded:"md",p:"4",children:[(0,l.Y)(d.Text,{fontWeight:"bold",mb:"2",children:"交易量"}),(0,l.Y)(d.Box,{h:"190px",children:(0,l.Y)(es,{data:n,dataKey:"orders",dataPointName:"筆數",isSmooth:!0,children:(0,l.Y)(F.m,{formatter:e=>[e.toLocaleString(),"筆數"]})})})]})]}),s.length>1&&(0,l.FD)(d.Box,{borderWidth:"1px",rounded:"md",p:"4",children:[(0,l.Y)(d.Text,{fontWeight:"bold",mb:"2",children:"各方案營收(堆疊)"}),(0,l.Y)(G,{series:s})]}),(0,l.FD)(d.Box,{borderWidth:"1px",rounded:"md",p:"4",children:[(0,l.Y)(d.Text,{fontWeight:"bold",mb:"3",children:"各方案成效"}),(0,l.Y)(ed,{columns:u,data:i,storageKey:"super-payment-product-plans:".concat(t.merchantId),defaultSortBy:[{id:"windowRevenue",desc:!0}],disablePagination:!0,disableGlobalFilter:!0})]})]})},em=e=>{let{merchantId:t,date:r,onBack:a}=e,{data:n,error:i,isLoading:o}=j("product",t,r);if(!n||"product"!==n.type)return(0,l.FD)(d.Stack,{spacing:4,children:[(0,l.Y)(d.HStack,{children:(0,l.Y)(d.Button,{size:"sm",variant:"outline",onClick:a,children:"← 回列表"})}),(0,l.Y)(W,{isLoading:o||!i,error:i,children:null})]});let{product:c,windowRevenue:s,windowOrders:u,daily:h,plans:p}=n;return(0,l.Y)(ep,{product:c,windowRevenue:s,windowOrders:u,daily:h,plans:p,onBack:a})},eg=m.A,ey=S.A,eY=e=>"NT$ ".concat(Math.round(e).toLocaleString("en-US")),eb=e=>e?"有":"無",ex={filter:(e,t,r)=>r?e.filter(e=>"有"===e.values[t[0]]):e,disableFilters:!0,withFilter:!0},ev=e=>{let{value:t}=e;return"有"===t?(0,l.Y)(d.Icon,{as:s.CMH,color:"green.500"}):null},ef={Header:"交易收入",accessor:"windowRevenue",w:"132px",disableFilters:!0,Cell:e=>{let{value:t}=e;return(0,l.Y)(d.Text,{as:"span",whiteSpace:"nowrap",children:eY(t)})}},ew=[{Header:"單筆",id:"oneTime",w:"104px",accessor:e=>eb(e.saleModes.includes("one-time")),...ex,Cell:ev}
1,{Header:"訂閱",id:"subscription",w:"104px",accessor:e=>eb(e.saleModes.includes("monthly")||e.saleModes.includes("yearly")),...ex,Cell:ev}],eS=e=>{let{value:t}=e;return(0,l.Y)(d.Stack,{spacing:"0",minW:"180px",children:t.map(e=>(0,l.FD)(d.HStack,{spacing:"1",children:[(0,l.Y)(d.Text,{fontSize:"sm",noOfLines:1,title:e.name,children:e.name}),(0,l.Y)(h.A,{"aria-label":"開啟 ".concat(e.name),href:e.url,isExternal:!0,icon:(0,l.Y)(u.Dus,{size:"1.25em"}),variant:"ghost",size:"xs"})]},e.merchantId))})},eF=e=>{let{name:t,url:r}=e;return r?(0,l.FD)(d.HStack,{spacing:"0",children:[(0,l.Y)(d.Link,{href:w(r),isExternal:!0,title:r,maxW:"240px",isTruncated:!0,children:t}),(0,l.Y)(h.A,{"aria-label":"開啟 ".concat(t),href:w(r),isExternal:!0,icon:(0,l.Y)(u.Dus,{size:"1.25em"}),variant:"ghost",size:"xs"})]}):(0,l.Y)(d.Text,{as:"span",children:t})},ek=e=>{let{label:t,value:r,tooltip:a}=e;return(0,l.FD)(d.Box,{borderWidth:"1px",rounded:"md",px:"4",py:"3",children:[(0,l.FD)(d.Text,{fontSize:"sm",color:"gray.500",children:[t,a&&(0,l.Y)(p.A.Question,{size:3.5,color:"gray.400",ml:1,children:a})]}),(0,l.Y)(d.Text,{fontSize:"2xl",fontWeight:"bold",mt:"1",children:r})]})},eT=e=>{let{date:t}=e,[r,a]=(0,c.useState)("account"),[n,i]=(0,c.useState)(null),[o,s]=(0,c.useState)(null),{data:u,error:h,isLoading:m}=X(t),y=(0,c.useMemo)(()=>{var e;let t=null!==(e=null==u?void 0:u.daily)&&void 0!==e?e:[],r=(e,r,l)=>({id:e,name:r,daily:t.map(e=>({date:e.date,revenue:e[l],orders:0}))});return[r("one-time","單次付款","oneTimeRevenue"),r("subscription","訂閱","subscriptionRevenue")]},[null==u?void 0:u.daily]),Y=(0,c.useMemo)(()=>[{Header:"正式 key 串接時間",accessor:"firstLiveApiKeyAt",w:"132px",disableFilters:!0,Cell:e=>{let{value:t}=e;return(0,l.Y)(d.Text,{as:"span",whiteSpace:"nowrap",children:null!=t?t:"—"})}},{Header:"帳號",accessor:"slug",id:"slug",w:"200px",disableFilters:!0,Cell:e=>{let{value:t}=e;return(0,l.Y)(ey,{value:t})}},{Header:"名稱",accessor:"name",w:"180px",disableFilters:!0},{Header:"產品列表",id:"products",accessor:"products",w:"240px",disableFilters:!0,disableSortBy:!0,exportAccessor:e=>e.products.map(e=>e.name).join("、"),Cell:e=>{let{value:t}=e;return(0,l.Y)(eS,{value:t})}},...ew,{Header:"金流審核",id:"paymentVerified",w:"132px",accessor:e=>eb(e.paymentVerified),...ex,Cell:ev},ef,{Header:"等級",id:"vipStatus",w:"120px",accessor:e=>e.vipStatus||"free",filter:"equals",Filter:e=>(0,l.Y)(g.A,{...e,withCount:!0}),Cell:e=>{let{value:t,row:{original:r}}=e;return(0,l.Y)(d.Text,{as:"span",whiteSpace:"nowrap",children:t+(r.hasSubscription?"\uD83D\uDCB2":"")})}},{Header:"操作",id:"trend",accessor:"profileId",w:"96px",disableFilters:!0,disableSortBy:!0,Cell:e=>{let{row:{original:t}}=e;return(0,l.Y)(d.Button,{size:"sm",colorScheme:"teal",onClick:()=>i(t.profileId),children:"查看"})}}],[]),b=(0,c.useMemo)(()=>[{Header:"產品",accessor:"name",w:"280px",disableFilters:!0,Cell:e=>{let{value:t,row:{original:r}}=e;return(0,l.Y)(eF,{name:t,url:r.url})}},{Header:"所屬帳號",accessor:"slug",id:"slug",w:"200px",disableFilters:!0,Cell:e=>{let{value:t}=e;return(0,l.Y)(ey,{value:t})}},...ew,{Header:"產品建立日期",accessor:"createdAt",w:"132px",disableFilters:!0,Cell:e=>{let{value:t}=e;return(0,l.Y)(d.Text,{as:"span",whiteSpace:"nowrap",children:null!=t?t:"—"})}},{Header:"審核狀態",accessor:"reviewStatus",w:"120px",disableFilters:!0,Cell:e=>{let{value:t}=e;return(0,l.Y)(d.Tag,{size:"sm",colorScheme:f[t],children:v[t]})}},ef,{Header:"操作",id:"trend",accessor:"merchantId",w:"96px",disableFilters:!0,disableSortBy:!0,Cell:e=>{let{row:{original:t}}=e;return(0,l.Y)(d.Button,{size:"sm",colorScheme:"teal",onClick:()=>s(t.merchantId),children:"查看"})}}],[]);if(!t)return(0,l.Y)(W,{isLoading:!0,error:null,children:null});if(!u)return(0,l.Y)(W,{isLoading:m||!h,error:h,children:null});let{totals:x,daily:w,accountRows:S,productRows:F}=u;return(0,l.FD)(d.Stack,{spacing:5,children:[(0,l.FD)(d.SimpleGrid,{columns:{base:1,md:2,lg:4},spacing:"4",children:[(0,l.Y)(ek,{label:"總金額",value:eY(x.windowRevenue)}),(0,l.Y)(ek,{label:"單筆金額",value:eY(x.oneTimeRevenue)}),(0,l.Y)(ek,{label:"訂閱金額",value:eY(x.subscriptionRevenue)}),(0,l.Y)(ek,{label:"金流審核通過",value:"".concat(x.verifiedAccounts.toLocaleStr
1ing("en-US")," 人"),tooltip:"全平台送過金流審核的帳號中已通過的人數;目前狀態,不隨查詢期間變動,也不受下方列表門檻影響"})]}),(0,l.FD)(d.SimpleGrid,{columns:{base:1,lg:2},spacing:"4",children:[(0,l.FD)(d.Box,{borderWidth:"1px",rounded:"md",p:"4",children:[(0,l.FD)(d.Text,{fontWeight:"bold",mb:"2",children:["正式 key 串接 / 送審",(0,l.Y)(p.A.Question,{size:3.5,color:"gray.400",ml:1,children:"送審包含:首次金流送審、多產品送審,不含退件後重送;2026-09 才開始記錄首次送審時間"})]}),(0,l.Y)(eo,{daily:w})]}),(0,l.FD)(d.Box,{borderWidth:"1px",rounded:"md",p:"4",children:[(0,l.Y)(d.Text,{fontWeight:"bold",mb:"2",children:"交易金額(單次/訂閱)"}),(0,l.Y)(G,{series:y})]})]}),(0,l.Y)(d.RadioGroup,{value:r,onChange:e=>a(e),children:(0,l.FD)(d.HStack,{spacing:"6",children:[(0,l.Y)(d.Radio,{value:"account",children:"依帳號"}),(0,l.Y)(d.Radio,{value:"product",children:"依產品"})]})}),"account"===r?(0,l.Y)(eg,{columns:Y,data:S,storageKey:"super-payment-analytics-account",defaultSortBy:[{id:"windowRevenue",desc:!0}],enableFilters:!0,canExport:!0}):(0,l.Y)(eg,{columns:b,data:F,storageKey:"super-payment-analytics-product",defaultSortBy:[{id:"windowRevenue",desc:!0}],enableFilters:!0,canExport:!0}),(0,l.Y)(d.Text,{fontSize:"xs",color:"gray.500",children:"表頭可點擊排序;帶下拉選單的欄位可篩選,帶漏斗圖示的欄位可一鍵篩出「有」的資料。"}),(0,l.FD)(d.Modal,{isOpen:!!(n||o),onClose:()=>{s(null),i(null)},size:"6xl",scrollBehavior:"inside",children:[(0,l.Y)(d.ModalOverlay,{}),(0,l.FD)(d.ModalContent,{overflow:"hidden",children:[(0,l.Y)(d.ModalHeader,{children:"交易趨勢"}),(0,l.Y)(d.ModalCloseButton,{}),(0,l.Y)(d.ModalBody,{pb:"6",children:o?(0,l.Y)(em,{merchantId:o,date:t,onBack:()=>s(null)}):n&&(0,l.Y)(et,{profileId:n,date:t,onBack:()=>i(null),onSelectProduct:e=>s(e)})})]})]})]})},eD=e=>{var t,r,a,n;let{steps:i}=e,o=null!==(a=null===(t=i[0])||void 0===t?void 0:t.count)&&void 0!==a?a:0,c=null!==(n=null===(r=i[i.length-1])||void 0===r?void 0:r.count)&&void 0!==n?n:0;return(0,l.FD)(d.Stack,{spacing:"3",children:[(0,l.FD)(d.HStack,{spacing:"3",children:[(0,l.Y)(d.Text,{fontSize:"sm",color:"gray.500",children:"總轉換率"}),(0,l.FD)(d.Text,{fontSize:"xl",fontWeight:"bold",children:[o>0?(c/o*100).toFixed(1):"0","%"]}),(0,l.FD)(d.Text,{fontSize:"sm",color:"gray.500",children:["(",o.toLocaleString()," → ",c.toLocaleString(),")"]})]}),(0,l.Y)(d.HStack,{align:"flex-start",spacing:"3",children:i.map((e,t)=>{let r=o>0?e.count/o:0,a=t===i.length-1;return(0,l.FD)(d.Box,{flex:"1",minW:"0",children:[(0,l.FD)(d.Text,{fontSize:"sm",color:"gray.500",children:["步驟 ",t+1]}),(0,l.Y)(d.Text,{fontSize:"2xl",fontWeight:"bold",lineHeight:"1.2",children:e.count.toLocaleString()}),(0,l.Y)(d.Box,{h:"140px",mt:"2",bg:"gray.50",rounded:"md",display:"flex",alignItems:"flex-end",overflow:"hidden",children:(0,l.Y)(d.Box,{w:"full",h:o>0?"".concat(Math.max(100*r,1.5),"%"):"0%",bg:a?"teal.500":"teal.300",transition:"height 200ms ease"})}),(0,l.FD)(d.HStack,{spacing:"1",mt:"2",flexWrap:"wrap",children:[(0,l.Y)(d.Text,{fontSize:"md",fontWeight:"medium",children:e.label}),e.tooltip&&(0,l.Y)(p.A,{size:3.5,color:"gray.400",as:T.kAG,children:e.tooltip})]}),(0,l.FD)(d.Text,{fontSize:"sm",color:"gray.500",children:["累積轉換 ",(100*r).toFixed(1),"%"]}),e.note&&(0,l.Y)(d.Text,{fontSize:"sm",color:"gray.500",mt:"1",children:e.note})]},e.key)})})]})},eA=e=>{let{date:t}=e,{data:r,error:a,isLoading:n}=$(t);if(!r)return(0,l.Y)(W,{isLoading:n||!a,error:a,children:null});let{userStates:i,productKeyModes:o,trialFunnel:c,recovery:s}=r;return(0,l.FD)(d.Stack,{spacing:8,divider:(0,l.Y)(d.Divider,{}),children:[r.truncated&&(0,l.FD)(d.Alert,{status:"warning",borderRadius:"md",fontSize:"sm",children:[(0,l.Y)(d.AlertIcon,{}),"進站名單已達單次查詢上限(20,000 筆),本頁數字只涵蓋最近進站的那部分,較早的用戶未計入。"]}),(0,l.Y)(A,{title:"使用 Payment 的用戶狀態",headers:["狀態","人數","佔比"],rows:[{key:"paid",label:"付費頂級",values:[i.paidPremium,D(i.paidPremium,
1i.total)]},{key:"trial",label:"試用頂級",tooltip:"試用期尚未到期、也還沒開始付費的人。",values:[i.trialPremium,D(i.trialPremium,i.total)]},{key:"basic",label:"基礎",values:[i.basic,D(i.basic,i.total)]},...i.legacyPro>0?[{key:"legacyPro",label:"pro(舊等級)",values:[i.legacyPro,D(i.legacyPro,i.total)]}]:[],{key:"total",label:"合計",emphasis:!0,values:[i.total,"100%"]}]}),(0,l.Y)(A,{title:"產品 API key 串接狀態",headers:["狀態","產品數","佔比"],rows:[{key:"live",label:x.live,values:[o.live,D(o.live,o.total)]},{key:"test",label:x.test,tooltip:"只建立過測試 key,還沒換上正式 key,等於還沒真的開始收款。",values:[o.test,D(o.test,o.total)]},{key:"none",label:x.none,values:[o.none,D(o.none,o.total)]},{key:"total",label:"合計",emphasis:!0,values:[o.total,"100%"]}]}),(0,l.FD)(d.Stack,{spacing:"3",children:[(0,l.FD)(d.HStack,{align:"baseline",spacing:"3",flexWrap:"wrap",children:[(0,l.Y)(d.Heading,{size:"sm",children:"試用轉換漏斗"}),(0,l.Y)(d.Text,{fontSize:"sm",color:"gray.500",children:"本區間內開始試用頂級的帳號"})]}),(0,l.Y)(eD,{steps:[{key:"startedTrial",label:"開始試用頂級",tooltip:"進站當下是基礎會員才會發試用;paymentTrialStartedAt 落在本區間。",count:c.startedTrial},{key:"connectedLiveKey",label:"完成正式 API key 串接",tooltip:"有 live key 且 lastUsedAt 有值,代表真的呼叫成功過。",count:c.connectedLiveKey},{key:"upgradedInTrial",label:"試用到期前優惠升級",tooltip:"試用期內就轉付費頂級(未走到到期)。",count:c.upgradedInTrial,note:c.upgradedInTrial>0?"其中 ".concat(D(c.upgradedWithTrialRevenue,c.upgradedInTrial)," 在試用期間也完成 API key 串接"):void 0}]})]}),(0,l.FD)(d.Stack,{spacing:3,children:[(0,l.FD)(d.HStack,{align:"baseline",spacing:"3",flexWrap:"wrap",children:[(0,l.Y)(d.Heading,{size:"sm",children:"降級後回收"}),(0,l.Y)(d.Text,{fontSize:"sm",color:"gray.500",children:"本區間開始試用、後來走到到期的帳號"})]}),(0,l.Y)(d.Box,{borderWidth:"1px",rounded:"md",overflow:"hidden",children:[{key:"downgraded",label:"試用到期後降級帳號數",value:s.downgraded.toLocaleString()},{key:"upgraded",label:"其中目前為付費頂級的帳號數",value:s.upgradedAfterDowngrade.toLocaleString()},{key:"rate",label:"比例",value:D(s.upgradedAfterDowngrade,s.downgraded)}].map((e,t)=>(0,l.FD)(d.HStack,{justify:"space-between",px:"4",py:"3",borderTopWidth:0===t?0:"1px",children:[(0,l.Y)(d.Text,{children:e.label}),(0,l.Y)(d.Text,{sx:{fontVariantNumeric:"tabular-nums"},children:e.value})]},e.key))})]})]})},eW=()=>(0,l.Y)(o.A,{defaultDays:30,children:(0,l.Y)(eT,{})}),ez=()=>(0,l.Y)(o.A,{defaultDays:30,children:(0,l.Y)(eA,{})}),eB=function(){return(0,l.FD)(l.FK,{children:[(0,l.Y)(n(),{children:(0,l.FD)("title",{children:["SuperAdmin | ","Portaly"]})}),(0,l.Y)(i.A,{tabs:[{label:"交易成效",comp:(0,l.Y)(eW,{})},{label:"功能用量",comp:(0,l.Y)(ez,{}),query:"usage"}]})]})}}},e=>{var t=t=>e(e.s=t);e.O(0,[19883,28505,58247,67690,17057,43465,87551,69735,81544,75687,38563,53958,75377,92535,28035,75945,78758,63596,65354,42419,92893,80971,64065,99624,13404,49785,96323,77381,90585,34005,47533,5244,85701,57716,2524,35439,55054,95005,79247,64190,30027,90636,46593,38792],()=>t(19941)),_N_E=e.O()}]);

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.