当前位置: 首页 > news >正文

未来之窗昭和仙君(七十六)扫码支付查询函数—东方仙盟练气

核心代码

完整代码

/** * 通用的支付状态查询函数 * @param {Object} options 配置参数 * @param {string} options.orderId 订单ID(必传) * @param {Function} options.onSuccess 支付成功回调 (result) => {} * @param {Function} options.onFail 支付失败回调 (result) => {} (状态码9417等终止性失败) * @param {Function} options.onError 其他错误回调 (result) => {} (非终止性错误/循环等待) * @param {boolean} [options.allowClose=true] 是否允许支付成功后关闭窗口 * @param {string} [options.themeColor='#1890ff'] 主题色(用于提示框等) * @param {number} [options.interval=1000] 查询间隔(避免高频递归) * @param {number} [options.maxRetries=30] 最大重试次数(防止无限递归) * @param {number} [options.retryCount=0] 已重试次数(内部参数,无需手动传) */ function cyberStoreQueryOrder(options) { // 默认配置 const defaultOptions = { allowClose: true, themeColor: '#1890ff', interval: 1000, maxRetries: 30, retryCount: 0, onSuccess: (result) => console.log('支付成功:', result), onFail: (result) => console.log('支付失败:', result), onError: (result) => console.log('查询异常:', result) }; // 合并配置参数 const opts = { ...defaultOptions, ...options }; const { orderId, retryCount, maxRetries, interval, allowClose, themeColor } = opts; // 边界校验:订单ID必传 if (!orderId) { console.error('订单ID不能为空'); opts.onError({ status: -1, info: '订单ID不能为空' }); return; } // 超过最大重试次数,终止查询并触发错误回调 if (retryCount >= maxRetries) { console.log('查询次数超限,终止查询'); opts.onError({ status: -2, info: '查询超时,请手动检查支付状态' }); return; } console.log(`查询中....(第${retryCount + 1}次)`); const deposit_query_url = ""; // 发送查询请求 $.post(deposit_query_url, { order_id: 0, orderid: orderId }, function (result_ch) { console.log("查询结果:", result_ch); // 支付成功逻辑 if (result_ch.status === 1) { console.log("支付成功"); // 调用成功回调 opts.onSuccess(result_ch); // 主题色可用于自定义提示框样式 layer.msg('支付成功', { icon: 1, skin: `layui-layer-${themeColor.replace('#', '')}` // 自定义主题色 }); // 处理窗口关闭逻辑(可配置) if (allowClose) { alert("支付成功,关闭小窗口"); parent?.cyberwin_closeAndDeldlg?.('wlzcapp_ai_all346_commondlg'); art.dialog?.close(); } // 执行原逻辑中的订单状态更新 const handId = $("#order_base_id").val(); if (handId) { parent?.update_hand_status_use?.(handId, result_ch.current_order_id); } // 团队订单批量更新 if (result_ch.order_base_id_extids && Array.isArray(result_ch.order_base_id_extids)) { result_ch.order_base_id_extids.forEach(extId => { parent?.update_hand_status_use?.(extId, result_ch.current_order_id); }); } return; } // 支付失败/异常逻辑 switch (result_ch.status) { // 等待输入密码/支付宝检测中(非终止性错误,继续查询) case 9005: console.log("等待用户输入密码..."); layer.msg("等待用户输入密码...", { color: themeColor }); cwpd_Play_DDYHCZ?.(); // 播放音频(保留原逻辑) opts.onError(result_ch); // 触发错误回调 // 延迟递归查询(避免高频请求) setTimeout(() => { cyberStoreQueryOrder({ ...opts, retryCount: retryCount + 1 }); }, interval); break; case 8005: // 支付宝循环检测 console.log("支付宝检测中..."); layer.msg("支付宝检测中...", { color: themeColor }); cwpd_Play_DDYHCZ?.(); opts.onError(result_ch); setTimeout(() => { cyberStoreQueryOrder({ ...opts, retryCount: retryCount + 1 }); }, interval); break; case 9417: // 交易失败(终止性失败) console.log("交易失败,终止查询"); cwpd_Play_errorFail?.(); opts.onFail(result_ch); // 触发失败回调 layer.msg("交易失败", { icon: 2, skin: `layui-layer-${themeColor.replace('#', '')}` }); break; // 其他错误状态 default: const errorMsg = `${result_ch.info || '查询异常'}${result_ch.status} V2020-`; layer.msg(errorMsg, { icon: 2, color: themeColor }); opts.onError(result_ch); break; } }, 'json').fail(function (xhr, status, error) { // AJAX请求本身失败的情况(如网络错误) console.error('查询请求失败:', error); opts.onError({ status: -3, info: '网络异常,查询失败', error: error }); // 可选:是否重试AJAX失败的情况 if (retryCount < maxRetries) { setTimeout(() => { cyberStoreQueryOrder({ ...opts, retryCount: retryCount + 1 }); }, interval); } }); }

东方仙盟:拥抱知识开源,共筑数字新生态


在全球化与数字化浪潮中,东方仙盟始终秉持开放协作、知识共享的理念,积极拥抱开源技术与开放标准。我们相信,唯有打破技术壁垒、汇聚全球智慧,才能真正推动行业的可持续发展。

开源赋能中小商户:通过将前端异常检测、跨系统数据互联等核心能力开源化,东方仙盟为全球中小商户提供了低成本、高可靠的技术解决方案,让更多商家能够平等享受数字转型的红利。
共建行业标准:我们积极参与国际技术社区,与全球开发者、合作伙伴共同制定开放协议与技术规范,推动跨境零售、文旅、餐饮等多业态的系统互联互通,构建更加公平、高效的数字生态。
知识普惠,共促发展:通过开源社区、技术文档与培训体系,东方仙盟致力于将前沿技术转化为可落地的行业实践,赋能全球合作伙伴,共同培育创新人才,推动数字经济的普惠式增长


阿雪技术观

在科技发展浪潮中,我们不妨积极投身技术共享。不满足于做受益者,更要主动担当贡献者。无论是分享代码、撰写技术博客,还是参与开源项目维护改进,每一个微小举动都可能蕴含推动技术进步的巨大能量。东方仙盟是汇聚力量的天地,我们携手在此探索硅基生命,为科技进步添砖加瓦。

Hey folks, in this wild tech - driven world, why not dive headfirst into the whole tech - sharing scene? Don't just be the one reaping all the benefits; step up and be a contributor too. Whether you're tossing out your code snippets, hammering out some tech blogs, or getting your hands dirty with maintaining and sprucing up open - source projects, every little thing you do might just end up being a massive force that pushes tech forward. And guess what? The Eastern FairyAlliance is this awesome place where we all come together. We're gonna team up and explore the whole silicon - based life thing, and in the process, we'll be fueling the growth of technology

http://www.jsqmd.com/news/422078/

相关文章:

  • 为量子互联网“掐表”:基于ZYNQ的皮秒级TDC与自适应温漂补偿系统实战
  • 使用 Rich 库打造专业 CLI 工具:终端美化、Table、Progress、Syntax 高亮、Theme 自定义与 Live 动态 UI 实
  • ionic 列表:全面解析与实战指南
  • QA之二 - 单元测试-- JaCoCo
  • 基于YOLO+deepseek 智慧农业作物长势监测系统 | 基于YOLO+deepseek 人脸识别与管理系统
  • 程序员兼职怎么选到更靠谱的软件外包平台
  • 谷歌NanoBanana 2又刷屏了,一文看懂如何使用
  • 闲置分某乐微信立减金回收方式推荐,高效转化闲置资源 - 京顺回收
  • 2026省选集训比赛总结
  • 校招/社招通用!计算机信息类专业简历写法,面试官一眼看中
  • 别再让AI毁网站了!告别蓝紫渐变,这7招彻底去除AI味,新手也能会 踩坑无数总结的去AI味技巧|从请求者变指挥官,AI做站也能有质感
  • JVM内存模型详解与垃圾回收日志分析
  • 中年不发福的关键!8个好习惯,不用节食,腰腹慢慢变紧致
  • 春节回来,康复学习Day4(13:30-18:00)
  • 使用Sentinel作为Spring Boot应用限流组件
  • 谷歌最新Nano Banana 2模型发布!国内免费使用教程
  • 算法:两个链表的第一个公共节点。
  • python生成静音音频
  • TCP 粘包与 UDP 丢包
  • PyTorch中的memory format - NCHW和channels last
  • YOLO26改进46:全网首发--使用FSConv改进下采样
  • abc447
  • 北京五粮液上门回收|经典五粮液、老五粮液、原件五粮液,上门高价收 - 品牌排行榜单
  • OpenClaw 源码深度解析(一):Gateway——为什么需要一个“中枢“
  • 北京茅台上门回收|年份茅台、生肖茅台、飞天茅台,当场结算不压价 - 品牌排行榜单
  • 北京老酒上门回收|家里的老白酒别乱放,亚南上门高价收 - 品牌排行榜单
  • [豪の算法奇妙冒险] 代码随想录算法训练营第四十九天 | 42-接雨水、84-柱状图中最大的矩形
  • 600018的753分析
  • 大数据情感分析:如何利用情感数据优化供应链管理?
  • 京城亚南酒业:北京上门收酒老字号,藏家公认放心选择 - 品牌排行榜单