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