PHP 支付宝支付、订阅支付(周期扣款)整理汇总

最近项目中需要使用支付宝的周期扣款,整理一下各种封装方法

APP支付(服务端)

    /******************************************************* 调用方法******************************************************/function test_pay(){$isSubscribe = 1;$price = 0.01;$detail = $body = "会员充值";$orderSn = date("mdHis") . mt_rand(2000, 8000);$hostApi = config('host_api');if (!$isSubscribe) { // 一次性支付$bizSontent = ["timeout_express" => "30m","product_code" => "QUICK_MSECURITY_PAY","total_amount" => $price,"subject" => $detail,"body" => $body,"out_trade_no" => $orderSn,];} else { // 订阅// 参见下文sign_scene参数说明 https://opendocs.alipay.com/open/08bg92?pathHash=b655de17$bizSontent = ["out_trade_no" => $orderSn,"total_amount" => $price, //订单总金额,首次支付的金额,不算在周期扣总金额里。"subject" => $detail,"body" => $body,"product_code" => "CYCLE_PAY_AUTH",  // CYCLE_PAY_AUTH"timeout_express" => "90m",//商家扣款协议信息"agreement_sign_params" => ["product_code" => "GENERAL_WITHHOLDING",//收单产品码固定为GENERAL_WITHHOLDING"personal_product_code" => "CYCLE_PAY_AUTH_P", //个人签约产品码固定为CYCLE_PAY_AUTH_P"sign_scene" => "INDUSTRY|DEFAULT_SCENE",//协议签约场景,参见下文sign_scene参数说明 数字传媒行业"external_agreement_no" => $orderSn,//商户签约号,代扣协议中用户的唯一签约号
//                    "sign_notify_url" => $hostApi . "/v1/notify/alipay_sub",//签约成功异步通知地址"access_params" => [ //签约接入的方式"channel" => "ALIPAYAPP"],// 签约规则"period_rule_params" => ["period_type" => "DAY",//周期类型枚举值为 DAY 和 MONTH"period" => 9999,//周期数,与 period_type 组合使用确定扣款周期 // 扣款周期类型period_type参数为DAY时,扣款周期period参数不得小于7。"execute_time" => date('Y-m-d'),//用户签约后,下一次使用代扣支付扣款的时间"single_amount" => $price,//单次扣款最大金额
//                        "total_amount" => "0.02",//周期内扣允许扣款的总金额,单位为元
//                        "total_payments" => "2"//总扣款次数。]],];}$notiyUrl = $hostApi . '/notify/alipay';list($result, $responseNode) = PayUtil::pay($bizSontent, $notiyUrl);dump($result);}

异步回调

 // 支付宝异步通知function alipay(){$verify = PayUtil::notifyVerify($_POST);$orderSn = addslashes($_POST['out_trade_no'] ?? '');    //商户订单号$trade_no = addslashes($_POST['trade_no'] ?? '');       //支付宝交易号$trade_status = trim(addslashes($_POST['trade_status'] ?? ''));if (!empty($trade_status)) { // 支付回调LogHelperUtil::outLog('alipay_notify_' . $trade_status, json_encode(['post' => $_POST, 'verify' => $verify]), 'alipay_notify');if (empty($orderSn)) {return "fail";}Db::name('order_log_alipay')->insert(['order_sn' => $orderSn, 'trans_id' => $trade_no, 'create_time' => date('Y-m-d H:i:s'),'content' => json_encode($_POST)]);$orderInfo = OrderModel::get_info(['order_sn' => $orderSn, 'status' => 0, 'pay_type' => 1]);if (!empty($orderInfo) && $trade_status == 'TRADE_SUCCESS') {$this->paySuccess($orderInfo, $trade_no);return "success";}if ($trade_status == 'TRADE_CLOSED') { // 退款return "success";}return "fail";}/**************************************************************** 订阅回调* 重要参数说明* status:协议状态,枚举支持。 NORMAL:正常  UNSIGN:解约。* external_agreement_no:标示用户的唯一签约协议号,商家自定义。仅签约接口传入时返回* agreement_no:支付宝系统中用以唯一标识用户签约记录的编号。* notify_type:异步通知类型,枚举支持。 dut_user_sign:当 status = NORMAL 表示签约成功。  dut_user_unsign:当 status = UNSIGN 表示解约成功。* sign_scene:签约协议场景。* personal_product_code:协议产品码。* alipay_user_id:用户的支付宝账号对应的支付宝唯一用户号。**********************************************************************/$status = $_POST['status'] ?? '';  // 协议状态,枚举支持。 NORMAL:正常  UNSIGN:解约。$notifyType = $_POST['notify_type'] ?? '';  // 异步通知类型,枚举支持。 dut_user_sign:当 status = NORMAL 表示签约成功。  dut_user_unsign:当 status = UNSIGN 表示解约成功。$orderSn = $_POST['external_agreement_no'] ?? ''; // 自定义$agreementNo = $_POST['agreement_no'] ?? '';Db::name('order_log_alipay_sub')->insert(['order_sn' => $orderSn, 'trans_id' => $agreementNo, 'create_time' => date('Y-m-d H:i:s'),'content' => json_encode($_POST)]);LogHelperUtil::outLog('alipay_notify_sub_' . $status, json_encode(['post' => $_POST, 'verify' => $verify]), 'alipay_notify_sub');if (empty($agreementNo)) {return "fail";}$orderInfo = OrderSubscribeModel::get_info(['order_sn' => $orderSn, 'pay_type' => 1]);$oid = intval($orderInfo['id'] ?? 0);    //  订单IDif ($status == 'UNSIGN' && $notifyType == 'dut_user_unsign') { // 解约$response = OrderSubscribeModel::update_data(['id' => $oid], ['status' => 2, // 0-签约中 1-已订阅 2-已退订'contract_del_date' => date('Y-m-d H:i:s'), // 解约时间]);return "success";}// 0-签约中 1-已订阅 2-已退订if (!empty($orderInfo) && $status == 'NORMAL' && $notifyType == 'dut_user_sign') { // 签约成功// 记录签约成功的订单$response = OrderSubscribeModel::update_data(['id' => $oid], ['status' => 1, // 0-签约中 1-已订阅 2-已退订'agreement_no' => $agreementNo,  // 签约号'contract_date' => date('Y-m-d H:i:s'), // 签约时间]);if ($response) {$toDay = date('Y-m-d');$kontDay = date('Y-m-d', strtotime("+1 day"));$nextPay = $orderInfo['next_pay'] ?? '';if ($nextPay == $kontDay || $toDay == $nextPay) {$notiyUrl = config('host_api') . '/notify/alipay_sub_knot?order_sn=' . $orderSn;send_socket_time_task($notiyUrl, 300);LogHelperUtil::outLog('alipay_notify_sub_' . $status, "已加入队列" . $notiyUrl, 'alipay_notify_sub');}}return "success";}return "fail";}

周期扣款操作(定时任务)

// 支付宝订阅自动扣款function alipay_sub_knot(){$orderSnSub = trim(addslashes($_GET['order_sn'] ?? ''));if (empty($orderSnSub)) {return 'fail-sn';}// 0-签约中 1-已订阅 2-已退订$orderInfo = OrderSubscribeModel::get_info(['order_sn' => $orderSnSub, 'status' => 1]);if (empty($orderInfo)) {return 'fail-order';}$type = $orderInfo['type'] ?? 0;   $uid = $orderInfo['uid'] ?? 0;$priceRenew = $orderInfo['price_renew'] ?? 0;  // 续订价格$agreementNo = $orderInfo['agreement_no'] ?? '';  // 签约号if (empty($agreementNo)) {return 'fail-order';}LogHelperUtil::outLog('alipay_sub_knot', json_encode(['orderSnSub' => $orderSnSub, 'order' => $orderInfo]), 'alipay_sub_knot');$detail = '周期扣款';$orderSn = "DYK{$type}U" . $uid . date("mdHis") . mt_rand(2000, 8000);list($result) = PayUtil::pay_sub_knot($orderSn, $detail, $priceRenew, $agreementNo);$resultCode = $result['code'] ?? 0;if ($resultCode != 10000) {LogHelperUtil::outLog('alipay_sub_knot_fail', json_encode(['orderSnSub' => $orderSnSub, 'order' => $orderInfo, 'result' => $result]), 'alipay_sub_knot');return "fail-result";}// 扣款成功,写入订单逻辑return "success";}

其他一下方法

    function alipay_test(){$agreementNo = '20235529965404462663';list($res,$code) = PayUtil::agreementQuery($agreementNo); // 签约查询dump($res);// 周期性扣款协议执行计划修改list($res,$code) = PayUtil::agreementModify($agreementNo,'2023-11-01','购买了半年包月');dump($res);// 解约list($res,$code) = PayUtil::agreementUnsign($agreementNo);dump($res);return '';}

PayUtil 封装方法文件

<?phpnamespace pay\alipay;class PayUtil
{/*** 发起支付* 支付后签约场景:https://opendocs.alipay.com/pre-open/08bpuc?pathHash=a572b7a7* @param $bizSontent* @param $notiyUrl* @return array|string[]* @author wzb* @date 2023/7/22 9:50*/static function pay($bizSontent = [], $notiyUrl = ''){$alipayConfig = config('alipay_config'); // 配置if (empty($bizSontent) || empty($alipayConfig)) {return ['', ''];}$aop = new AopClient();$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';$aop->appId = $alipayConfig['appid'] ?? '';$aop->rsaPrivateKey = $alipayConfig['rsaPrivateKey'] ?? '';$aop->alipayrsaPublicKey = $alipayConfig['alipayrsaPublicKey'] ?? '';$aop->apiVersion = '1.0';$aop->signType = 'RSA2';$aop->postCharset = 'utf-8';$aop->format = 'json';$request = new \AlipayTradeAppPayRequest();$request->setNotifyUrl($notiyUrl);$request->setBizContent(json_encode($bizSontent));$result = $aop->sdkExecute($request);$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";return [$result, $responseNode];}/*** 查询交易信息** @param $outTradeNo* @return string[]|void* @author wzb* @date 2023/7/22 10:03*/static function queryOrder($outTradeNo = ''){$bizSontent = ["out_trade_no" => $outTradeNo,
//            "trade_no"=>"DJ4U2407211930124801",
//            "query_options"=>[
//                "trade_settle_info", // 交易结算信息
//            ]];$alipayConfig = config('alipay_config'); // 配置if (empty($alipayConfig)) {return ['', ''];}$aop = new AopClient();$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';$aop->appId = $alipayConfig['appid'] ?? '';$aop->rsaPrivateKey = $alipayConfig['rsaPrivateKey'] ?? '';$aop->alipayrsaPublicKey = $alipayConfig['alipayrsaPublicKey'] ?? '';$aop->apiVersion = '1.0';$aop->signType = 'RSA2';$aop->postCharset = 'utf-8';$aop->format = 'json';$request = new \AlipayTradeQueryRequest();$request->setBizContent(json_encode($bizSontent));$result = $aop->execute($request);$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";$response = $result->$responseNode;$response = json_decode(json_encode($response), true);return [$response, $responseNode];}/*** @param string $orderSn 订单号* @param string $detail 说明* @param int $totalAmount 扣款金额* @param string $agreement_no 签约号* @return array|string[]* @author wzb* @date 2023/7/29 10:50*/static function pay_sub_knot($orderSn, $detail, $totalAmount, $agreement_no){$bizSontent = ["out_trade_no" => $orderSn,  //订单号"total_amount" => $totalAmount,"subject" => $detail,"product_code" => "GENERAL_WITHHOLDING",// 代扣信息。'agreement_params' => ["agreement_no" => $agreement_no,],];$alipayConfig = config('alipay_config'); // 配置if (empty($bizSontent) || empty($alipayConfig)) {return ['', ''];}$aop = new AopClient();$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';$aop->appId = $alipayConfig['appid'] ?? '';$aop->rsaPrivateKey = $alipayConfig['rsaPrivateKey'] ?? '';$aop->alipayrsaPublicKey = $alipayConfig['alipayrsaPublicKey'] ?? '';$aop->apiVersion = '1.0';$aop->signType = 'RSA2';$aop->postCharset = 'utf-8';$aop->format = 'json';$request = new \AlipayTradePayRequest();$request->setBizContent(json_encode($bizSontent));$result = $aop->execute($request);$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";$response = $result->$responseNode;$response = json_decode(json_encode($response), true);return [$response, $responseNode];}/*** 退款* @param $outTradeNo* @param $tradeNo* @param $refundAmount* @return array* @author wzb* @date 2023/7/25 17:14*/static function refundOrder($outTradeNo = '', $tradeNo = '', $refundAmount = 0){$bizSontent = ["out_trade_no" => $outTradeNo,"trade_no" => $tradeNo,"refund_amount" => $refundAmount,];$alipayConfig = config('alipay_config'); // 配置if (empty($alipayConfig)) {return ['', ''];}$aop = new AopClient();$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';$aop->appId = $alipayConfig['appid'] ?? '';$aop->rsaPrivateKey = $alipayConfig['rsaPrivateKey'] ?? '';$aop->alipayrsaPublicKey = $alipayConfig['alipayrsaPublicKey'] ?? '';$aop->apiVersion = '1.0';$aop->signType = 'RSA2';$aop->postCharset = 'utf-8';$aop->format = 'json';$request = new \AlipayTradeRefundRequest();$request->setBizContent(json_encode($bizSontent));$result = $aop->execute($request);$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";$response = $result->$responseNode;$response = json_decode(json_encode($response), true);return [$response, $responseNode];}/*** 查询签约接口* https://opendocs.alipay.com/open/3dab71bc_alipay.user.agreement.query?scene=8837b4183390497f84bb53783b488ecc&pathHash=9a0c5949* @return array|string[]* @author wzb* @date 2023/7/29 13:35*/static function agreementQuery($agreementNo){$bizSontent = ["agreement_no" => $agreementNo,];$alipayConfig = config('alipay_config'); // 配置if (empty($alipayConfig)) {return ['', ''];}$aop = new AopClient();$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';$aop->appId = $alipayConfig['appid'] ?? '';$aop->rsaPrivateKey = $alipayConfig['rsaPrivateKey'] ?? '';$aop->alipayrsaPublicKey = $alipayConfig['alipayrsaPublicKey'] ?? '';$aop->apiVersion = '1.0';$aop->signType = 'RSA2';$aop->postCharset = 'utf-8';$aop->format = 'json';$request = new \AlipayUserAgreementQueryRequest();$request->setBizContent(json_encode($bizSontent));$result = $aop->execute($request);$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";$response = $result->$responseNode;$response = json_decode(json_encode($response), true);return [$response, $responseNode];}/*** 解约* https://opendocs.alipay.com/open/b841da1f_alipay.user.agreement.unsign?scene=90766afb41f74df6ae1676e89625ebac&pathHash=a3599432* @param string $agreementNo 签约号(协议号)* @param string $orderSn 订单号 代扣协议中标示用户的唯一签约号(确保在商户系统中唯一)。* @return array|string[]* @author wzb* @date 2023/7/29 13:49*/static function agreementUnsign($agreementNo, $orderSn){$bizSontent = ["agreement_no" => $agreementNo,"external_agreement_no" => $orderSn,];$alipayConfig = config('alipay_config'); // 配置if (empty($alipayConfig)) {return ['', ''];}$aop = new AopClient();$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';$aop->appId = $alipayConfig['appid'] ?? '';$aop->rsaPrivateKey = $alipayConfig['rsaPrivateKey'] ?? '';$aop->alipayrsaPublicKey = $alipayConfig['alipayrsaPublicKey'] ?? '';$aop->apiVersion = '1.0';$aop->signType = 'RSA2';$aop->postCharset = 'utf-8';$aop->format = 'json';$request = new \AlipayUserAgreementUnsignRequest();$request->setBizContent(json_encode($bizSontent));$result = $aop->execute($request);$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";$response = $result->$responseNode;$response = json_decode(json_encode($response), true);return [$response, $responseNode];}/*** 周期性扣款协议执行计划修改* https://opendocs.alipay.com/open/ed428330_alipay.user.agreement.executionplan.modify?pathHash=e019f106* @param string $agreementNo 签约号(协议号)* @param string $nextPay 商户下一次扣款时间 2023-01-01* @param string $memo 具体修改原因    64个字符* @return array|string[]* @author wzb* @date 2023/7/29 13:45*/static function agreementModify($agreementNo, $nextPay, $memo){$bizSontent = ["agreement_no" => $agreementNo,"deduct_time" => $nextPay,"memo" => $memo,];$alipayConfig = config('alipay_config'); // 配置if (empty($alipayConfig)) {return ['', ''];}$aop = new AopClient();$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';$aop->appId = $alipayConfig['appid'] ?? '';$aop->rsaPrivateKey = $alipayConfig['rsaPrivateKey'] ?? '';$aop->alipayrsaPublicKey = $alipayConfig['alipayrsaPublicKey'] ?? '';$aop->apiVersion = '1.0';$aop->signType = 'RSA2';$aop->postCharset = 'utf-8';$aop->format = 'json';$request = new \AlipayUserAgreementExecutionplanModifyRequest();$request->setBizContent(json_encode($bizSontent));$result = $aop->execute($request);$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";$response = $result->$responseNode;$response = json_decode(json_encode($response), true);return [$response, $responseNode];}/*** 验证* @param $arr* @return bool|string[]|null* @author wzb* @date 2023/7/22 10:33*/static function notifyVerify($arr){$alipayConfig = config('alipay_config'); // 配置if (empty($alipayConfig)) {return false;}$aop = new AopClient();$aop->alipayrsaPublicKey = $alipayConfig['alipayrsaPublicKey'] ?? '';$urlString = urldecode(http_build_query($arr));$data = explode('&', $urlString);$params = [];foreach ($data as $param) {$item = explode('=', $param, "2");$params[$item[0]] = $item[1];}$result = $aop->rsaCheckV1($params, null, 'RSA2');return $result;}
}

PHP服务端SDK

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/12814.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

mybatis日志工厂

前言&#xff1a; 如果一个数据库操作&#xff0c;出现异常&#xff0c;我们需要排错&#xff0c;日志就是最好的助手 官方给我们提供了logImpl&#xff1a;指定 MyBatis 所用日志的具体实现&#xff0c;未指定时将自动查找。 默认工厂&#xff1a; 在配置文件里添加&#xf…

深度剖析APP开发中的UI/UX设计

作为一个 UI/UX设计师&#xff0c;除了要关注 UI/UX设计之外&#xff0c;还要掌握移动开发知识&#xff0c;同时在日常工作中也需要对用户体验有一定的认知&#xff0c;在本次分享中&#xff0c;笔者就针对自己在工作中积累的一些经验来进行一个总结&#xff0c;希望能够帮助到…

cartographer发布畸变矫正后的scan数据

实现方式&#xff1a; 模仿源代码&#xff0c;在cartographer_ros写一个函数&#xff0c;以函数指针的方式传入cartographer后端&#xff0c;然后接收矫正后的scan数据&#xff0c;然后按照话题laserScan发布出来。 需要同时发布点云强度信息的&#xff0c;还要自己添加含有强度…

如何连接远程服务器?快解析内内网穿透可以吗?

如今我们迎来了数字化转型的时代&#xff0c;众多企业来为了更好地推动业务的发展&#xff0c;常常需要在公司内部搭建一个远程服务器。然而&#xff0c;对于企业员工来说&#xff0c;在工作过程中经常需要与这个服务器进行互动&#xff0c;而服务器位于公司的局域网中&#xf…

Go重写Redis中间件 - Go实现Redis协议解析器

Go实现Redis协议解析器 Redis网络协议详解 在解决完通信后,下一步就是搞清楚 Redis 的协议-RESP协议,其实就是一套类似JSON、Protocol Buffers的序列化协议,也就是我们的客户端和服务端通信的协议 RESP定义了5种格式 简单字符串(Simple String) : 服务器用来返回简单的结…

简述IO(BIO NIO IO多路复用)

在unix网络变成中的五种IO模型: Blocking IO(阻塞IO) NoneBlocking IO (非阻塞IO) IO mulitplexing(IO多路复用) signal driven IO (信号驱动IO) asynchronous IO (异步IO) BIO BIO&#xff08;Blocking IO&#xff09;是一种阻塞IO模型&#xff0c;也是传统的IO操作模型之一…

Windows上安装和使用git到gitoschina和github上_亲测

Windows上安装和使用git到gitoschina和github上_亲测 git介绍与在windows上安装创建SSHkey在gitoschina使用 【git介绍与在windows上安装】 Git是一款免费、开源的分布式版本控制系统&#xff0c;用于敏捷高效地处理任何或小或大的项目。 相关介绍可以参考 <百度百科>…

【Vue3 + Element Plus】纯前端实现本地数据分页

先附上效果图 Vue3 Element Plus 实现本地分页 首页弹窗代码 <el-table :data"tableData" style"width: 100%" border stripe><el-table-column v-for"{ id, prop, label } in tableColumn" :prop"prop" :key"id"…

RocketMQ概论

目录 前言&#xff1a; 1.概述 2.下载安装、集群搭建 3.消息模型 4.如何保证吞吐量 4.1.消息存储 4.1.1顺序读写 4.1.2.异步刷盘 4.1.3.零拷贝 4.2.网络传输 前言&#xff1a; RocketMQ的代码示例在安装目录下有全套详细demo&#xff0c;所以本文不侧重于讲API这种死…

【Rust 基础篇】Rust默认泛型参数:简化泛型使用

导言 Rust是一种以安全性和高效性著称的系统级编程语言&#xff0c;其设计哲学是在不损失性能的前提下&#xff0c;保障代码的内存安全和线程安全。在Rust中&#xff0c;泛型是一种非常重要的特性&#xff0c;它允许我们编写一种可以在多种数据类型上进行抽象的代码。然而&…

tcp keepalive

tcp keepalive用于检查两者之间的链路是否正常&#xff0c;或防止链路断开。 一旦建立了TCP连接&#xff0c;该连接被定义为有效&#xff0c;直到一方关闭它。一旦连接进入连接状态&#xff0c;它将无限期地保持连接状态。但实际上&#xff0c;这种联系不会无限期地持续下去。如…

数据结构:快速的Redis有哪些慢操作?

redis 为什么要这莫快&#xff1f;一个就是他是基于内存的&#xff0c;另外一个就是他是他的数据结构 说到这儿&#xff0c;你肯定会说&#xff1a;“这个我知道&#xff0c;不就是 String&#xff08;字符串&#xff09;、List&#xff08;列表&#xff09;、 Hash&#xff08…

1.Ansible

文章目录 Ansible概念作用特性总结 部署AnsibleAnsible模块commandshellcronusergroupcopyfilehostnamepingyumserice/systemdscriptmountarchiveunarchivereplacesetup inventory主机清单主机变量组变量组嵌套 Ansible 概念 Ansible是一个基于Python开发的配置管理和应用部署…

【Redis】面试题

1. 为什么要用缓存 1. 提高系统的读写性能。 2. 减轻数据库的压力&#xff0c;防止大量的请求到达数据库&#xff0c;让数据库压力剧增&#xff0c;拖垮数据库。redis数据存储在内存中&#xff0c;高效的数据结构&#xff0c;读写数据比数据库快。 将热点数据存储在redis当中&…

#P1004. [NOIP1998普及组] 三连击

题目描述 将 1, 2, \ldots , 91,2,…,9 共 99 个数分成 33 组&#xff0c;分别组成 33 个三位数&#xff0c;且使这 33 个三位数构成 1 : 2 : 31:2:3 的比例&#xff0c;试求出所有满足条件的 33 个三位数。 输入格式 无 输出格式 若干行&#xff0c;每行 33 个数字。按照…

数据结构:分块查找

分块查找&#xff0c;也叫索引顺序查找&#xff0c;算法实现除了需要查找表本身之外&#xff0c;还需要根据查找表建立一个索引表。例如图 1&#xff0c;给定一个查找表&#xff0c;其对应的索引表如图所示&#xff1a; 图 1 查找表及其对应的索引表 图 1 中&#xff0c;查找表…

小程序 账号的体验版正式版的账号信息及相关配置

siteinfo.js // 正式环境 const releaseConfig {appID: "",apiUrl: "",imgUrl: "" }; // 测试环境&#xff08;包含开发环境和体验环境&#xff09; const developConfig {appID: "",apiUrl: "",imgUrl: "" }…

相机可用性变化监听AvailabilityCallback流程分析

相机可用性变化监听及流程分析 一、接口说明 ​ 相机可用性变化监听可以通过CameraManager中的接口registerAvailabilityCallback()来设置回调&#xff0c;接口如下&#xff1a; /** *注册一个回调以获得有关相机设备可用性的通知。 * *<p>再次注册相同的回调将用提供…

Nginx性能优化配置

一、全局优化 # 工作进程数 worker_processes auto; # 建议 CPU核心数|CPU线程数# 最大支持的连接(open-file)数量&#xff1b;最大值受限于 Linux open files (ulimit -n) # 建议公式&#xff1a;worker_rlimit_nofile > worker_processes * worker_connections…

vue指令-v-for

vue指令-v-for 1、目标2、语法语法 1、目标 列表渲染&#xff0c;所在标签结构&#xff0c;按照数据数量&#xff0c;循环生成 2、语法 v-for "(值变量&#xff0c;索引变量) in 目标结构"示例&#xff1a; <template><div id"app"><di…