import{d as O,r as v,a as Y,o as N,g as c,J as Z,c as $,k as U,e as t,w as a,K as q,b as u,t as p,l as k,O as J,s as K,z as A,m as G,x as r,S as H,aa as Q,E as V,_ as W}from"./index-CUnFTKV2.js";import{r as X}from"./user-EiTTpYhZ.js";const ee={class:"page-container"},te={class:"card-header"},ae={class:"user-info"},le={class:"user-detail"},oe={class:"nickname"},ne={class:"uid"},se={class:"mobile"},ie={class:"money-text"},de={class:"money-text"},re={class:"money-text"},ue={class:"money-text"},ce={class:"money-text"},_e={class:"money-text"},pe={class:"pagination-container"},fe=O({__name:"profit-loss",setup(ge){const C=v(!1),D=v([]),I=v(0),z=v(!1),f=v(null),l=Y({userIdStr:void 0,uid:void 0,startTime:void 0,endTime:void 0,page:1,pageSize:20}),T=i=>i>0?"profit-positive":i<0?"profit-negative":"",h=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 i=await X(l);D.value=i.data.list,I.value=i.data.total}catch(i){console.error("获取盈亏列表失败:",i)}finally{C.value=!1}},L=()=>{l.page=1,h()},B=()=>{l.userIdStr=void 0,l.uid=void 0,f.value=null,l.startTime=void 0,l.endTime=void 0,l.page=1,h()},R=i=>{l.page=i,h()},j=i=>{l.pageSize=i,l.page=1,h()},E=async()=>{z.value=!0;try{const i=D.value.map(n=>{var m,x,d,w,M,S,F;return{用户ID:n.userId,UID:n.uid||"",昵称:n.nickname||"",手机号:n.mobile||"",账户余额:((m=n.money)==null?void 0:m.toFixed(2))||"0.00",积分:n.integral||0,钻石:n.money2||0,订单数:n.orderCount||0,订单总额:((x=n.orderZheTotal)==null?void 0:x.toFixed(2))||"0.00",RMB支付:((d=n.money1)==null?void 0:d.toFixed(2))||"0.00",钻石支付:n.money2Pay||0,用户支付:((w=n.useMoney)==null?void 0:w.toFixed(2))||"0.00",发货金额:((M=n.fhMoney)==null?void 0:M.toFixed(2))||"0.00",背包金额:((S=n.bbMoney)==null?void 0:S.toFixed(2))||"0.00",剩余达达券:n.syMoney||0,盈亏金额:((F=n.yueMoney)==null?void 0:F.toFixed(2))||"0.00",盈亏状态:n.profitStatus||""}}),o=Object.keys(i[0]||{}),g=[o.join(","),...i.map(n=>o.map(m=>`"${n[m]}"`).join(","))].join(`
`),y="\uFEFF",b=new Blob([y+g],{type:"text/csv;charset=utf-8;"}),_=document.createElement("a");_.href=URL.createObjectURL(b),_.download=`用户盈亏统计_${new Date().toISOString().slice(0,10)}.csv`,_.click(),URL.revokeObjectURL(_.href),V.success("导出成功")}catch(i){console.error("导出失败:",i),V.error("导出失败")}finally{z.value=!1}};return N(()=>{h()}),(i,o)=>{const g=c("el-icon"),y=c("el-button"),b=c("el-input"),_=c("el-form-item"),n=c("el-date-picker"),m=c("el-form"),x=c("el-avatar"),d=c("el-table-column"),w=c("el-tag"),M=c("el-table"),S=c("el-pagination"),F=c("el-card"),P=Z("loading");return U(),$("div",ee,[t(F,null,{header:a(()=>[u("div",te,[o[6]||(o[6]=u("span",null,"用户盈亏统计",-1)),t(y,{type:"primary",onClick:E,loading:z.value},{default:a(()=>[t(g,null,{default:a(()=>[t(k(Q))]),_:1}),o[5]||(o[5]=p("导出Excel ",-1))]),_:1},8,["loading"])])]),default:a(()=>[t(m,{model:l,inline:"",class:"search-form"},{default:a(()=>[t(_,{label:"用户ID"},{default:a(()=>[t(b,{modelValue:l.userIdStr,"onUpdate:modelValue":o[0]||(o[0]=e=>l.userIdStr=e),placeholder:"请输入用户ID",clearable:"",style:{width:"150px"}},null,8,["modelValue"])]),_:1}),t(_,{label:"UID"},{default:a(()=>[t(b,{modelValue:l.uid,"onUpdate:modelValue":o[1]||(o[1]=e=>l.uid=e),placeholder:"请输入UID",clearable:"",style:{width:"150px"}},null,8,["modelValue"])]),_:1}),t(_,{label:"时间范围"},{default:a(()=>[t(n,{modelValue:f.value,"onUpdate:modelValue":o[2]||(o[2]=e=>f.value=e),type:"daterange","range-separator":"至","start-placeholder":"开始日期","end-placeholder":"结束日期","value-format":"YYYY-MM-DD",style:{width:"240px"}},null,8,["modelValue"])]),_:1}),t(_,null,{default:a(()=>[t(y,{type:"primary",onClick:L},{default:a(()=>[t(g,null,{default:a(()=>[t(k(J))]),_:1}),o[7]||(o[7]=p("搜索 ",-1))]),_:1}),t(y,{onClick:B},{default:a(()=>[t(g,null,{default:a(()=>[t(k(K))]),_:1}),o[8]||(o[8]=p("重置 ",-1))]),_:1})]),_:1})]),_:1},8,["model"]),q((U(),A(M,{data:D.value,border:"",stripe:""},{default:a(()=>[t(d,{label:"用户信息","min-width":"180"},{default:a(({row:e})=>[u("div",ae,[t(x,{src:e.headimg,size:40},{default:a(()=>[t(g,null,{default:a(()=>[t(k(G))]),_:1})]),_:1},8,["src"]),u("div",le,[u("div",oe,r(e.nickname||"-"),1),u("div",ne,"UID: "+r(e.uid||"-"),1),u("div",se,r(e.mobile||"-"),1)])])]),_:1}),t(d,{label:"账户余额",align:"right",width:"100"},{default:a(({row:e})=>{var s;return[u("span",ie,"¥"+r(((s=e.money)==null?void 0:s.toFixed(2))||"0.00"),1)]}),_:1}),t(d,{label:"积分",align:"right",width:"80"},{default:a(({row:e})=>[p(r(e.integral||0),1)]),_:1}),t(d,{label:"钻石",align:"right",width:"80"},{default:a(({row:e})=>[p(r(e.money2||0),1)]),_:1}),t(d,{label:"订单数",align:"center",width:"80"},{default:a(({row:e})=>[p(r(e.orderCount||0),1)]),_:1}),t(d,{label:"订单总额",align:"right",width:"100"},{default:a(({row:e})=>{var s;return[u("span",de,"¥"+r(((s=e.orderZheTotal)==null?void 0:s.toFixed(2))||"0.00"),1)]}),_:1}),t(d,{label:"RMB支付",align:"right",width:"100"},{default:a(({row:e})=>{var s;return[u("span",re,"¥"+r(((s=e.money1)==null?void 0:s.toFixed(2))||"0.00"),1)]}),_:1}),t(d,{label:"钻石支付",align:"right",width:"100"},{default:a(({row:e})=>[p(r(e.money2Pay||0),1)]),_:1}),t(d,{label:"用户支付",align:"right",width:"100"},{default:a(({row:e})=>{var s;return[u("span",ue,"¥"+r(((s=e.useMoney)==null?void 0:s.toFixed(2))||"0.00"),1)]}),_:1}),t(d,{label:"发货金额",align:"right",width:"100"},{default:a(({row:e})=>{var s;return[u("span",ce,"¥"+r(((s=e.fhMoney)==null?void 0:s.toFixed(2))||"0.00"),1)]}),_:1}),t(d,{label:"背包金额",align:"right",width:"100"},{default:a(({row:e})=>{var s;return[u("span",_e,"¥"+r(((s=e.bbMoney)==null?void 0:s.toFixed(2))||"0.00"),1)]}),_:1}),t(d,{label:"剩余达达券",align:"right",width:"100"},{default:a(({row:e})=>[p(r(e.syMoney||0),1)]),_:1}),t(d,{label:"盈亏金额",align:"right",width:"120"},{default:a(({row:e})=>{var s;return[u("span",{class:H(T(e.yueMoney))},r(e.yueMoney>=0?"+":"")+"¥"+r(((s=e.yueMoney)==null?void 0:s.toFixed(2))||"0.00"),3)]}),_:1}),t(d,{label:"盈亏状态",align:"center",width:"100"},{default:a(({row:e})=>[t(w,{type:e.profitStatus==="盈利"?"success":"danger"},{default:a(()=>[p(r(e.profitStatus||"-"),1)]),_:2},1032,["type"])]),_:1})]),_:1},8,["data"])),[[P,C.value]]),u("div",pe,[t(S,{"current-page":l.page,"onUpdate:currentPage":o[3]||(o[3]=e=>l.page=e),"page-size":l.pageSize,"onUpdate:pageSize":o[4]||(o[4]=e=>l.pageSize=e),"page-sizes":[20,50,100],total:I.value,layout:"total, sizes, prev, pager, next, jumper",onSizeChange:j,onCurrentChange:R},null,8,["current-page","page-size","total"])])]),_:1})])}}}),ye=W(fe,[["__scopeId","data-v-02371af8"]]);export{ye as default};
