var e=(e,a,l)=>new Promise((s,t)=>{var u=e=>{try{r(l.next(e))}catch(a){t(a)}},n=e=>{try{r(l.throw(e))}catch(a){t(a)}},r=e=>e.done?s(e.value):Promise.resolve(e.value).then(u,n);r((l=l.apply(e,a)).next())});import{i as a,e as l,n as s,M as t,N as u,O as n}from"./vendor-element-DupX9wXy.js";import{q as r,bI as o,r as v,c as i,R as c,t as d,A as p,H as y,M as _,E as m,K as h,D as f,bC as g,bB as k,u as b,J as w,v as j,bE as q}from"./vendor-core-Di0OO4oJ.js";import{c as x}from"./wallet-D5bWawEZ.js";import"./index-BkDr3sJj.js";const P={class:"payment-callback"},C={class:"content"},D={key:0,class:"status-icon loading"},E={key:1,class:"status-icon success"},T={key:2,class:"status-icon pending"},A={key:3,class:"status-icon fail"},I={class:"title"},O={class:"desc"},W={key:4,class:"meta"},M={key:0},Q={key:1},R={class:"actions"},S=q(r({__name:"callback",setup(r){const{t:q}=o(),S=k(),B=g(),H=()=>{sessionStorage.removeItem("shop_pending_payment_order")},J=v(!0),K=v(!1),L=v(!1),N=v("正在处理支付结果..."),U=v("请稍候，我们正在确认您的支付状态"),z=v(null),F=i(()=>"order"===z.value?"查看订单":"docking"===z.value||"recharge"===z.value?"返回对接中心":"返回钱包"),G=()=>{const e={};return Object.entries(B.query).forEach(([a,l])=>{const s=(e=>Array.isArray(e)?e[0]:e)(l);void 0!==s&&(e[a]=s)}),e},V=i(()=>{const e=G();return e.out_trade_no||e.trade_no||""}),X=i(()=>{const e=G();return(e=>{const a=e.toLowerCase();return a.includes("alipay")?"支付宝":a.includes("wx")?"微信":a.includes("qq")?"QQ钱包":a.includes("epay")?"易支付":a.includes("usdt")?"USDT":e||""})(e.type||e.pay_type||"")}),Y=()=>e(null,null,function*(){var e;try{const a=G(),l=a.out_trade_no||a.trade_no;!z.value&&l&&(l.startsWith("OP")?z.value="operating":l.startsWith("DEP")?z.value="deposit":l.startsWith("DR")?z.value="docking":z.value="order");const s=yield x(a.sign?a:l),t=(null==s?void 0:s.status)||(null==(e=null==s?void 0:s.data)?void 0:e.status);if(s&&("paid"===t||"pending_shipment"===t)){const e="pending_shipment"===t;return J.value=!1,L.value=!1,K.value=!0,"operating"!==z.value&&(z.value=s.type||z.value),"order"===z.value?(H(),N.value=e?"支付成功，待发货":q("payment.success"),U.value=e?"订单已支付成功，但当前库存不足，已进入待发货，稍后可在订单页查看。":"您的订单已支付成功，即将自动跳转...",setTimeout(()=>{ee()},3e3)):"docking"===z.value||"recharge"===z.value?(N.value="充值成功",U.value="您的对接余额充值已到账"):"operating"===z.value?(N.value="充值成功",U.value="您的运营余额充值已到账"):(N.value="充值成功",U.value="您的保证金充值已到账"),!0}return!1}catch(a){return!1}}),Z=()=>e(null,null,function*(){if(J.value=!0,L.value=!1,K.value=!1,N.value="正在查询支付状态...",U.value="请稍候，我们正在与支付平台核对结果",!(yield Y())){for(let e=0;e<24;e++){const a=e<8?1e3:2e3;if(yield new Promise(e=>setTimeout(e,a)),yield Y())return}J.value=!1,L.value=!0,K.value=!1,N.value="支付处理中",U.value="已收到回调，正在异步发货与通知，通常几十秒内完成。可点击“重试查询”。"}});c(()=>{const e=G();e.out_trade_no||e.trade_no?Z():setTimeout(()=>{J.value=!1,K.value=!1,N.value="参数错误",U.value="未找到订单号，无法查询支付状态。"},1e3)});const $=()=>{const e=G();(e.out_trade_no||e.trade_no)&&Z()},ee=()=>{const e=G(),a=e.out_trade_no||e.trade_no;"order"===z.value?(H(),S.push({path:"/order/search",query:{keyword:a}})):"docking"===z.value||"recharge"===z.value?S.push("/"):S.push("/user/wallet/balance")};return(e,r)=>{const o=a,v=l;return j(),d("div",P,[p("div",C,[J.value?(j(),d("div",D,[_(o,{class:"is-loading"},{default:m(()=>[_(b(s))]),_:1})])):K.value?(j(),d("div",E,[_(o,null,{default:m(()=>[_(b(t))]),_:1})])):L.value?(j(),d("div",T,[_(o,null,{default:m(()=>[_(b(u))]),_:1})])):(j(),d("div",A,[_(o,null,{default:m(()=>[_(b(n))]),_:1})])),p("h2",I,h(N.value),1),p("p",O,h(U.value),1),V.value||X.value?(j(),d("div",W,[V.value?(j(),d("span",M,"订单号："+h(V.value),1)):y("",!0),X.value?(j(),d("span",Q,"渠道："+h(X.value),1)):y("",!0)])):y("",!0),p("div",R,[_(v,{type:"primary",onClick:ee},{default:m(()=>[w(h(F.value),1)]),_:1}),J.value||K.value?y("",!0):(j(),f(v,{key:0,onClick:$},{default:m(()=>[...r[0]||(r[0]=[w("重试查询",-1)])]),_:1}))])])])}}}),[["__scopeId","data-v-45fd8134"]]);export{S as default};
