import{_ as Q,a as h}from"./index-BlP3rxMf.js";import{g as I,u as N,a as L}from"./index-BqycflTi.js";import{y as l,A as t,K as u,Q as g,O as r,D as f,aD as F,I as p,al as _,P as v,a6 as y,M as m,V as j,z as i}from"./vendor-C3mpOp0n.js";import"./elementPlus-DFx51bSH.js";const q={name:"Matching",data(){return{stats:{userStats:null},creating:!1,processing:!1,pendingAllocations:[],matchingOrders:[],showOrderDetail:!1,selectedOrder:null,matchingType:"small",customAmount:"",transferDialog:{visible:!1,allocationId:null,toUser:{id:null,name:"",wechatQr:"",alipayQr:"",unionpayQr:"",bankCard:""},amount:0,actualAmount:0,voucher:"",description:""}}},async mounted(){await this.loadData()},methods:{async loadData(){try{await Promise.all([this.loadStats(),this.loadPendingAllocations(),this.loadMatchingOrders()])}catch(e){console.error("加载数据失败:",e),this.$message.error("加载数据失败")}},async loadStats(){try{const e=await h.get("/matching/stats");this.stats=e.data.data||{}}catch(e){console.error("加载统计数据失败:",e)}},async loadPendingAllocations(){try{const e=await h.get("/matching/pending-allocations");this.pendingAllocations=e.data.data||[]}catch(e){console.error("加载待处理分配失败:",e)}},async loadMatchingOrders(){try{const e=await h.get("/matching/my-orders");this.matchingOrders=e.data.data||[]}catch(e){console.error("加载匹配订单失败:",e)}},async createOrder(){var e,s;this.creating=!0;try{const d={matchingType:this.matchingType};if(this.matchingType==="large"){if(!this.isValidCustomAmount){this.$message.error("请输入有效的匹配金额(5000-50000元)");return}d.customAmount=parseFloat(this.customAmount)}await h.post("/matching/create",d);const c=this.matchingType==="small"?"小额匹配成功!已为您生成3笔转账分配":`大额匹配成功!已为您生成${this.getLargeMatchingCount()}笔转账分配`;this.$message.success(c),await this.loadData()}catch(d){console.error("创建匹配订单失败:",d);const c=((s=(e=d.response)==null?void 0:e.data)==null?void 0:s.message)||"匹配失败,请稍后重试";c.includes("审核")||c.includes("上传")||c.includes("完善")?this.$confirm(c+",是否前往个人中心完善资料?","提示",{confirmButtonText:"前往完善",cancelButtonText:"取消",type:"warning"}).then(()=>{this.$router.push("/profile")}).catch(()=>{}):this.$message.error(c)}finally{this.creating=!1}},async confirmAllocation(e,s){try{const c=(await h.get(`/matching/allocation/${e}`)).data.data,o=(await h.get(`/users/payment-info/${c.to_user_id}`)).data.data;this.transferDialog={visible:!0,allocationId:e,toUser:{id:c.to_user_id,name:c.to_user_name,wechatQr:o.wechat_qr,alipayQr:o.alipay_qr,unionpayQr:o.unionpay_qr,bankCard:o.bank_card},amount:s,actualAmount:s}}catch(d){console.error("获取转账信息失败:",d),this.$message.error("获取转账信息失败")}},async rejectAllocation(e){const s=prompt("请输入拒绝原因(可选):");if(s!==null){this.processing=!0;try{await h.post(`/matching/reject-allocation/${e}`,{reason:s}),this.$message.success("已拒绝分配"),await this.loadData()}catch(d){console.error("拒绝分配失败:",d),this.$message.error("拒绝分配失败")}finally{this.processing=!1}}},async viewOrderDetail(e){try{const s=await h.get(`/matching/order/${e}`);this.selectedOrder=s.data.data,this.showOrderDetail=!0}catch(s){console.error("获取订单详情失败:",s),this.$message.error("获取订单详情失败")}},closeOrderDetail(){this.showOrderDetail=!1,this.selectedOrder=null},getStatusText(e){return{pending:"待处理",matching:"匹配中",completed:"已完成",cancelled:"已取消",confirmed:"已确认",rejected:"已拒绝",failed:"匹配失败"}[e]||e},getActionText(e){return{join:"加入",confirm:"确认",reject:"拒绝",complete:"完成"}[e]||e},formatDate(e){return new Date(e).toLocaleString("zh-CN")},formatDeadline(e){if(!e)return"";const s=new Date(e),d=new Date,c=new Date(d.getFullYear(),d.getMonth(),d.getDate()),n=new Date(s.getFullYear(),s.getMonth(),s.getDate()),o=s.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return n.getTime()===c.getTime()?`今天${o}`:n.getTime()===c.getTime()+24*60*60*1e3?`明天${o}`:s.toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})},formatAmount(e){const s=parseFloat(e);return isNaN(s)?"0.00":s.toFixed(2)},getLargeMatchingRule(){const e=parseFloat(this.customAmount)||0;return e<=0?"请输入金额":e<5e3?"金额不能少于5000元":e>5e4?"金额不能超过50000元":e<=15e3?"分成3笔随机金额":"随机分拆,每笔1000-8000元"},getLargeMatchingCount(){const e=parseFloat(this.customAmount)||0;if(e<=0||e<5e3||e>5e4)return"0";if(e<=15e3)return"3";{const s=Math.ceil(e/8e3),d=Math.floor(e/1e3);return`${s}-${Math.min(d,10)}`}},closeTransferDialog(){this.transferDialog.visible=!1,this.transferDialog.allocationId=null,this.transferDialog.toUser={id:null,name:"",wechatQr:"",alipayQr:"",unionpayQr:"",bankCard:""},this.transferDialog.amount=0,this.transferDialog.actualAmount=0,this.transferDialog.voucher="",this.transferDialog.description=""},getImageUrl(e){return L(e)},beforeUpload(e){const s=e.type.startsWith("image/"),d=e.size/1024/1024<5;return s||this.$message.error("只能上传图片文件!"),d||this.$message.error("图片大小不能超过 5MB!"),s&&d},handleUploadSuccess(e){e.success?(this.transferDialog.voucher=e.url,this.$message.success("凭证上传成功")):this.$message.error(e.message||"上传失败")},handleUploadError(e){console.error("上传失败:",e),this.$message.error("上传失败")},async submitTransfer(){var s,d;if(!this.transferDialog.voucher){this.$message.error("请先上传转账凭证");return}const e=parseFloat(this.transferDialog.actualAmount);this.processing=!0;try{await h.post(`/matching/confirm-allocation/${this.transferDialog.allocationId}`,{transferAmount:e,description:this.transferDialog.description,voucher:this.transferDialog.voucher}),this.$message.success("转账凭证已提交,转账记录已创建"),this.closeTransferDialog(),this.$router.push("/transfers")}catch(c){console.error("确认分配失败:",c),this.$message.error(((d=(s=c.response)==null?void 0:s.data)==null?void 0:d.message)||"确认分配失败")}finally{this.processing=!1}}},computed:{isValidCustomAmount(){const e=parseFloat(this.customAmount);return!isNaN(e)&&e>=5e3&&e<=5e4},uploadUrl(){return N},uploadHeaders(){return I().headers}}},z={class:"matching-container"},R={class:"stats-cards"},B={class:"stat-card"},P={class:"stat-number"},E={class:"stat-card"},H={class:"stat-number"},W={class:"stat-card"},Y={class:"stat-number"},K={class:"stat-card"},G={class:"stat-number"},J={class:"action-section"},X={class:"create-order-card"},Z={class:"matching-type-selector"},$={class:"type-tabs"},ss={key:0,class:"matching-info"},ts={key:1,class:"matching-info"},es={class:"info-item"},as={class:"custom-amount-input"},ns={class:"info-item"},rs={class:"value"},os={class:"info-item"},ls={class:"value"},is=["disabled"],ds={key:2,class:"tips"},cs={key:3,class:"tips"},us={key:0,class:"pending-section"},ms={class:"allocation-list"},gs={class:"allocation-info"},ps={class:"allocation-header"},hs={class:"order-id"},_s={class:"cycle"},fs={class:"allocation-details"},vs={class:"amount"},ys={class:"deadline-info"},bs={class:"deadline-time"},Ds={key:0,class:"timeout-warning"},ks={class:"warning-text"},ws={class:"allocation-actions"},Cs=["onClick","disabled","title"],As=["onClick","disabled"],Ts={class:"orders-section"},Os={class:"orders-list"},Us=["onClick"],Ms={class:"order-header"},xs={class:"order-id"},Vs={key:0,class:"system-reverse-tag"},Ss={class:"order-info"},Qs={key:0},Is={key:1,class:"system-note"},Ns={key:0,class:"empty-state"},Ls={class:"modal-header"},Fs={key:0,class:"modal-body"},js={class:"order-summary"},qs={class:"allocations-section"},zs={class:"allocation-timeline"},Rs={class:"timeline-content"},Bs={class:"timeline-header"},Ps={class:"cycle"},Es={class:"amount"},Hs={class:"records-section"},Ws={class:"records-list"},Ys={class:"record-info"},Ks={class:"action"},Gs={class:"user"},Js={class:"time"},Xs={key:0,class:"record-amount"},Zs={key:1,class:"record-note"},$s={class:"transfer-dialog-content"},st={class:"transfer-info"},tt={class:"payment-codes"},et={class:"payment-grid"},at={key:0,class:"payment-item"},nt=["src"],rt={key:1,class:"payment-item"},ot=["src"],lt={key:2,class:"payment-item"},it=["src"],dt={key:3,class:"payment-item"},ct={class:"bank-card"},ut={class:"transfer-form"},mt={key:0,class:"upload-preview"},gt=["src"],pt={key:1,class:"upload-tip"},ht={class:"dialog-footer"};function _t(e,s,d,c,n,o){var w,C,A,T,O,U;const b=_("el-input"),D=_("el-form-item"),k=_("el-button"),x=_("el-upload"),V=_("el-form"),S=_("el-dialog");return i(),l("div",z,[s[49]||(s[49]=t("div",{class:"header"},[t("h1",null,"资金循环匹配"),t("p",{class:"subtitle"},"智能匹配,循环增值")],-1)),t("div",R,[t("div",B,[t("div",P,r(((w=n.stats.userStats)==null?void 0:w.initiated_orders)||0),1),s[10]||(s[10]=t("div",{class:"stat-label"},"发起订单",-1))]),t("div",E,[t("div",H,r(((C=n.stats.userStats)==null?void 0:C.participated_allocations)||0),1),s[11]||(s[11]=t("div",{class:"stat-label"},"参与分配",-1))]),t("div",W,[t("div",Y,"¥"+r(o.formatAmount((A=n.stats.userStats)==null?void 0:A.total_initiated_amount)),1),s[12]||(s[12]=t("div",{class:"stat-label"},"发起总额",-1))]),t("div",K,[t("div",G,"¥"+r(o.formatAmount((T=n.stats.userStats)==null?void 0:T.total_participated_amount)),1),s[13]||(s[13]=t("div",{class:"stat-label"},"参与总额",-1))])]),t("div",J,[t("div",X,[s[21]||(s[21]=t("h3",null,"资金匹配",-1)),t("div",Z,[t("div",$,[t("button",{class:f(["type-tab",{active:n.matchingType==="small"}]),onClick:s[0]||(s[0]=a=>n.matchingType="small")}," 小额匹配 ",2),t("button",{class:f(["type-tab",{active:n.matchingType==="large"}]),onClick:s[1]||(s[1]=a=>n.matchingType="large")}," 大额匹配 ",2)])]),n.matchingType==="small"?(i(),l("div",ss,s[14]||(s[14]=[F('