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