import{d as G,r as h,a as H,o as Q,g as s,J as W,c as S,k,e,w as t,K as X,b as u,t as m,l as x,O as Z,s as ee,z as te,m as E,x as c,S as ae,aa as le,E as O,_ as ne}from"./index-CUnFTKV2.js";import{p as oe}from"./user-EiTTpYhZ.js";const se={class:"page-container"},ie={class:"card-header"},de={key:0,class:"expand-content"},re={class:"user-info-small"},ue={class:"money-text"},ce={key:1,class:"expand-empty"},pe={class:"user-info"},_e={class:"user-detail"},me={class:"nickname"},fe={class:"uid"},ve={class:"money-text"},ge={class:"pagination-container"},he=G({__name:"invite-stats",setup(be){const C=h(!1),I=h([]),D=h(0),z=h(!1),v=h([]),f=h(null),l=H({userIdStr:void 0,uid:void 0,minInviteCount:void 0,startTime:void 0,endTime:void 0,page:1,pageSize:20}),j=o=>o===1?"rank-gold":o===2?"rank-silver":o===3?"rank-bronze":"",L=o=>o?new Date(o).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-",b=async()=>{C.value=!0;try{f.value&&f.value.length===2?(l.startTime=f.value[0],l.endTime=f.value[1]):(l.startTime=void 0,l.endTime=void 0);const o=await oe(l);I.value=o.data.list,D.value=o.data.total}catch(o){console.error("获取邀请统计失败:",o)}finally{C.value=!1}},M=()=>{l.page=1,v.value=[],b()},B=()=>{l.userIdStr=void 0,l.uid=void 0,l.minInviteCount=void 0,f.value=null,l.startTime=void 0,l.endTime=void 0,l.page=1,v.value=[],b()},F=o=>{l.page=o,v.value=[],b()},N=o=>{l.pageSize=o,l.page=1,v.value=[],b()},P=(o,n)=>{v.value=n.map(_=>_.userId)},R=async()=>{z.value=!0;try{const o=I.value.map(i=>{var g;return{排名:i.index,用户ID:i.userId,UID:i.uid||"",昵称:i.nickname||"",邀请人数:i.inviteNumber||0,绑定手机数:i.countMobile||0,消费人数:i.sumOrder||0,消费总金额:((g=i.sumPrice)==null?void 0:g.toFixed(2))||"0.00"}}),n=Object.keys(o[0]||{}),_=[n.join(","),...o.map(i=>n.map(g=>`"${i[g]}"`).join(","))].join(`
`),y="\uFEFF",w=new Blob([y+_],{type:"text/csv;charset=utf-8;"}),p=document.createElement("a");p.href=URL.createObjectURL(w),p.download=`用户邀请统计_${new Date().toISOString().slice(0,10)}.csv`,p.click(),URL.revokeObjectURL(p.href),O.success("导出成功")}catch(o){console.error("导出失败:",o),O.error("导出失败")}finally{z.value=!1}};return Q(()=>{b()}),(o,n)=>{const _=s("el-icon"),y=s("el-button"),w=s("el-input"),p=s("el-form-item"),i=s("el-input-number"),g=s("el-date-picker"),Y=s("el-form"),V=s("el-avatar"),d=s("el-table-column"),U=s("el-table"),$=s("el-empty"),q=s("el-tag"),A=s("el-pagination"),J=s("el-card"),K=W("loading");return k(),S("div",se,[e(J,null,{header:t(()=>[u("div",ie,[n[7]||(n[7]=u("span",null,"用户邀请统计",-1)),e(y,{type:"primary",onClick:R,loading:z.value},{default:t(()=>[e(_,null,{default:t(()=>[e(x(le))]),_:1}),n[6]||(n[6]=m("导出Excel ",-1))]),_:1},8,["loading"])])]),default:t(()=>[e(Y,{model:l,inline:"",class:"search-form"},{default:t(()=>[e(p,{label:"用户ID"},{default:t(()=>[e(w,{modelValue:l.userIdStr,"onUpdate:modelValue":n[0]||(n[0]=a=>l.userIdStr=a),placeholder:"请输入用户ID",clearable:"",style:{width:"150px"}},null,8,["modelValue"])]),_:1}),e(p,{label:"UID"},{default:t(()=>[e(w,{modelValue:l.uid,"onUpdate:modelValue":n[1]||(n[1]=a=>l.uid=a),placeholder:"请输入UID",clearable:"",style:{width:"150px"}},null,8,["modelValue"])]),_:1}),e(p,{label:"最少邀请数"},{default:t(()=>[e(i,{modelValue:l.minInviteCount,"onUpdate:modelValue":n[2]||(n[2]=a=>l.minInviteCount=a),min:0,max:9999,style:{width:"150px"}},null,8,["modelValue"])]),_:1}),e(p,{label:"时间范围"},{default:t(()=>[e(g,{modelValue:f.value,"onUpdate:modelValue":n[3]||(n[3]=a=>f.value=a),type:"daterange","range-separator":"至","start-placeholder":"开始日期","end-placeholder":"结束日期","value-format":"YYYY-MM-DD",style:{width:"240px"}},null,8,["modelValue"])]),_:1}),e(p,null,{default:t(()=>[e(y,{type:"primary",onClick:M},{default:t(()=>[e(_,null,{default:t(()=>[e(x(Z))]),_:1}),n[8]||(n[8]=m("搜索 ",-1))]),_:1}),e(y,{onClick:B},{default:t(()=>[e(_,null,{default:t(()=>[e(x(ee))]),_:1}),n[9]||(n[9]=m("重置 ",-1))]),_:1})]),_:1})]),_:1},8,["model"]),X((k(),te(U,{data:I.value,border:"",stripe:"","row-key":"userId","expand-row-keys":v.value,onExpandChange:P},{default:t(()=>[e(d,{type:"expand"},{default:t(({row:a})=>[a.info&&a.info.length>0?(k(),S("div",de,[e(U,{data:a.info,border:"",size:"small"},{default:t(()=>[e(d,{label:"被邀请用户","min-width":"150"},{default:t(({row:r})=>[u("div",re,[e(V,{src:r.headimg,size:28},{default:t(()=>[e(_,null,{default:t(()=>[e(x(E))]),_:1})]),_:1},8,["src"]),u("span",null,c(r.nickname||r.uid||"-"),1)])]),_:1}),e(d,{label:"手机号",prop:"mobile",width:"130"},{default:t(({row:r})=>[m(c(r.mobile||"-"),1)]),_:1}),e(d,{label:"订单数",prop:"orderCount",align:"center",width:"80"}),e(d,{label:"消费金额",align:"right",width:"120"},{default:t(({row:r})=>{var T;return[u("span",ue,"¥"+c(((T=r.totalPrice)==null?void 0:T.toFixed(2))||"0.00"),1)]}),_:1}),e(d,{label:"注册时间",width:"180"},{default:t(({row:r})=>[m(c(L(r.createdAt)),1)]),_:1})]),_:1},8,["data"])])):(k(),S("div",ce,[e($,{description:"暂无被邀请用户数据","image-size":60})]))]),_:1}),e(d,{label:"排名",align:"center",width:"70"},{default:t(({row:a})=>[u("span",{class:ae(j(a.index))},c(a.index),3)]),_:1}),e(d,{label:"邀请人信息","min-width":"180"},{default:t(({row:a})=>[u("div",pe,[e(V,{src:a.headimg,size:40},{default:t(()=>[e(_,null,{default:t(()=>[e(x(E))]),_:1})]),_:1},8,["src"]),u("div",_e,[u("div",me,c(a.nickname||"-"),1),u("div",fe,"UID: "+c(a.uid||"-"),1)])])]),_:1}),e(d,{label:"邀请人数",align:"center",width:"100"},{default:t(({row:a})=>[e(q,{type:"primary"},{default:t(()=>[m(c(a.inviteNumber||0),1)]),_:2},1024)]),_:1}),e(d,{label:"绑定手机数",align:"center",width:"100"},{default:t(({row:a})=>[m(c(a.countMobile||0),1)]),_:1}),e(d,{label:"消费人数",align:"center",width:"100"},{default:t(({row:a})=>[m(c(a.sumOrder||0),1)]),_:1}),e(d,{label:"消费总金额",align:"right",width:"120"},{default:t(({row:a})=>{var r;return[u("span",ve,"¥"+c(((r=a.sumPrice)==null?void 0:r.toFixed(2))||"0.00"),1)]}),_:1})]),_:1},8,["data","expand-row-keys"])),[[K,C.value]]),u("div",ge,[e(A,{"current-page":l.page,"onUpdate:currentPage":n[4]||(n[4]=a=>l.page=a),"page-size":l.pageSize,"onUpdate:pageSize":n[5]||(n[5]=a=>l.pageSize=a),"page-sizes":[20,50,100],total:D.value,layout:"total, sizes, prev, pager, next, jumper",onSizeChange:N,onCurrentChange:F},null,8,["current-page","page-size","total"])])]),_:1})])}}}),we=ne(he,[["__scopeId","data-v-ad7b5197"]]);export{we as default};
