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