核心代码完整代码/** * 通用的支付状态查询函数 * 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.allowClosetrue] 是否允许支付成功后关闭窗口 * param {string} [options.themeColor#1890ff] 主题色用于提示框等 * param {number} [options.interval1000] 查询间隔避免高频递归 * param {number} [options.maxRetries30] 最大重试次数防止无限递归 * param {number} [options.retryCount0] 已重试次数内部参数无需手动传 */ 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? Dont just be the one reaping all the benefits; step up and be a contributor too. Whether youre 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. Were gonna team up and explore the whole silicon - based life thing, and in the process, well be fueling the growth of technology