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