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
相关文章:
PHP 支付宝支付、订阅支付(周期扣款)整理汇总
最近项目中需要使用支付宝的周期扣款,整理一下各种封装方法 APP支付(服务端) /******************************************************* 调用方法******************************************************/function test_pay(){$isSubscri…...
python-pytorch基础之神经网络回归
这里写目录标题 定义数据集定义函数生成数据集 使用Dataloader加载dataset定义神经网络定义实例化查看是否是输出的一个 训练编写trian方法训练并保存模型 测试模型结果构造数据测试结论 定义数据集 import torch import random定义函数 # 生成数据 def get_rancledata():wid…...
linux中通过.desktop文件执行bash命令打开chrome浏览器并传参
.desktop 文件介绍 Ecex 参数介绍 Code 描述 %f %f指向临时文件。用于不了解URL语法的程序。 %F 文件列表。用于可以一次打开多个本地文件的应用程序。每个文件作为单独的参数传递给可执行程序。 %u 单一的URL或者本地文件 %U %u的复数 %i 如果Icon 为空,不应该填写此参数。…...

ChatGPT的应用与发展趋势:解析人工智能的新风口
目录 优势 应用领域 发展趋势 总结 在人工智能技术迅猛发展的时代,自然语言处理系统的提升一直是研究者们追求的目标。作为人工智能领域的重要突破之一,ChatGPT以其出色的语言模型和交互能力,在智能对话领域取得了重要的进展。 ChatGPT是…...
使用maven打jar包时,如何只把依赖的其它jar中的类打进jar包,没有依赖的其它jar包的类文件不打进来?
简介 使用Maven打包时,默认情况下,所有依赖的jar包都会被打包到生成的jar文件中。 如果只想将依赖的其他jar中的类文件打进来,而不包含其它jar包,可以使用Maven的 maven-shade-plugin插件进行配置。 步骤 以下是一个示例配置&…...

arm neon/fpu/mfloat
neon官网介绍: Arm Neon technology is an advanced Single Instruction Multiple Data (SIMD) architecture extension for the A-profile and R-profile processors. Neon technology is a packed SIMD architecture. Neon registers are considered as vectors of elements …...

Maven基础之项目创建、packaging
文章目录 创建 maven 项目流程骨架是浮云,packaging 是关键 创建 maven 项目流程 通过骨架(archetype)创建 maven 工程 第一步:选择 new → maven → Maven Project 第二步:New Maven Project 窗口不作任何设置&…...
c++ std::map 使用注意事项
1. std::map 如果在添加元素前,直接去取 key-value,会怎样 ? 先说答案,map 在添加元素前,直接使用会给 key 添加默认的 value! 2. 问题背景 某项目代码报出个严重的bug,具体现象是某个 map…...
Camera HAL/ISP 专业术语大全
不断更新,建议收藏,快速检索 SOC,System On Chip,片上系统 HAL,Hardware Abstraction Layer,硬件抽象层 ISP,Image Signal Processor,图像信号处理器 KMD,Kernel Mod…...
POI的简单入门
POI的简单入门 导入jar包将数据写入Excel文件读取Excel文件中的数据 导入jar包 Apache POI的maven坐标 <dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>3.17</version> </dependency>…...

如何将笔记本作为另一台电脑的副屏显示
背景说明 台式电脑一个显示器不够我使用,而手头又没有多的显示器。我的笔记本有屏幕,但是不能直接连HDMI线给台式拓展屏幕。研究一段时间后发现,利用spacedesk软件可以基本完美解决这个问题。 效果演示 软件下载与安装 官网下载最新版(需要…...
深入理解正则表达式:为什么它在Java中如此重要?
文章目录 一、正则表达式1.1 为什么引入正则表达式1.2 什么是正则表达式 二、正则表达式规则2.1 正则表达式的基本语法规则2.2 非贪婪匹配 三、正则表达式在java中的应用3.1 String3.2 java.util.regex 参考资料 一、正则表达式 1.1 为什么引入正则表达式 在实际编写程序的过…...

jmeter实现webservice接口测试
其实可以用jmeter两种sampler进行webservice的测试: 1、SOAP/XML-RPC Request(但是在jmeter3.2以后版本中已经取消了这个取样器) 2、HTTP请求 下面分别介绍两种方式 一、首先需要使用soupUI工具抓取webservice接口的部分需要的信息。 1、新建项目 2、新建成功的…...
js 四舍五入保留一位小数 求百分比
概览:一个数据占一组数据的比率,并且四舍五入保留一位小数。通过Math.round()四舍五入。 参考链接: mdn中文文档Math.round() 实现思路: Math.round(x) 函数返回一个数字四舍五入后最接近的整数。参数x是一个数值 实现代码&a…...

文件上传漏洞总结2
文件上传的大体都已经学习过了 这个假期在给他强化一下 什么是webshell webshell是web入侵的脚本攻击工具。webshell就是一个asp或php木马后门,黑客在入侵了一个网站后,常常在将这些asp或php木马后门文件放置在网站服务器的web目录中,与正常…...

【组内工作】木马回联
文章目录 C2服务器安装和运行方法CrossC2运行方法sliver运行方法empire安装方法DeimosC2安装教程TrevorC2安装教程: C2服务器的流量特征CrossC21. 心跳包2. 命令3. ja3/ja3s Sliver1. http2. https empirehttphttps DeimosC2https TrevorC2 C2服务器安装和运行方法 …...

未来将会有更多基于 Cortana 的设备
在前些日子的 Build 大会首日 Keynote 中,微软正式确认 HP 跟 Intel 也正在开发基于 Cortana 平台的联网家居产品,这是继推出 Invoke 喇叭的 Harman Kardon 后,又有知名大牌加入到 Cortana 的阵营当中,有这样的品牌资源背景&#…...

嵌入式硬件系统的基本组成
嵌入式硬件系统的基本组成 嵌入式系统的硬件是以包含嵌入式微处理器的SOC为核心,主要由SOC、总线、存储器、输入/输出接口和设备组成。 嵌入式微处理器 每个嵌入式系统至少包含一个嵌入式微处理器 嵌入式微处理器体系结构可采用冯.诺依曼(Von Neumann&…...
def __init__(self, **kwargs):中的**kwargs是什么意思
**kwargs是什么意思 在Python中,**kwargs是一种特殊的参数形式,用于接收可变数量的关键字参数(Keyword Arguments)。kwargs是一个字典(dictionary),其中关键字是参数名,对应的值是传…...
web攻击面试|网络渗透面试(三)
Web攻击大纲 常见Web攻击类型: SQL注入攻击:介绍SQL注入攻击的概念、原理和常见的攻击方式,如基于错误消息的注入、基于布尔盲注的注入等。解释攻击者如何利用SQL注入漏洞获取敏感信息或者对数据库进行恶意操作,并提供防御措施&a…...

stm32G473的flash模式是单bank还是双bank?
今天突然有人stm32G473的flash模式是单bank还是双bank?由于时间太久,我真忘记了。搜搜发现,还真有人和我一样。见下面的链接:https://shequ.stmicroelectronics.cn/forum.php?modviewthread&tid644563 根据STM32G4系列参考手…...

Redis相关知识总结(缓存雪崩,缓存穿透,缓存击穿,Redis实现分布式锁,如何保持数据库和缓存一致)
文章目录 1.什么是Redis?2.为什么要使用redis作为mysql的缓存?3.什么是缓存雪崩、缓存穿透、缓存击穿?3.1缓存雪崩3.1.1 大量缓存同时过期3.1.2 Redis宕机 3.2 缓存击穿3.3 缓存穿透3.4 总结 4. 数据库和缓存如何保持一致性5. Redis实现分布式…...

CentOS下的分布式内存计算Spark环境部署
一、Spark 核心架构与应用场景 1.1 分布式计算引擎的核心优势 Spark 是基于内存的分布式计算框架,相比 MapReduce 具有以下核心优势: 内存计算:数据可常驻内存,迭代计算性能提升 10-100 倍(文档段落:3-79…...
Java 加密常用的各种算法及其选择
在数字化时代,数据安全至关重要,Java 作为广泛应用的编程语言,提供了丰富的加密算法来保障数据的保密性、完整性和真实性。了解这些常用加密算法及其适用场景,有助于开发者在不同的业务需求中做出正确的选择。 一、对称加密算法…...
CRMEB 框架中 PHP 上传扩展开发:涵盖本地上传及阿里云 OSS、腾讯云 COS、七牛云
目前已有本地上传、阿里云OSS上传、腾讯云COS上传、七牛云上传扩展 扩展入口文件 文件目录 crmeb\services\upload\Upload.php namespace crmeb\services\upload;use crmeb\basic\BaseManager; use think\facade\Config;/*** Class Upload* package crmeb\services\upload* …...

嵌入式学习笔记DAY33(网络编程——TCP)
一、网络架构 C/S (client/server 客户端/服务器):由客户端和服务器端两个部分组成。客户端通常是用户使用的应用程序,负责提供用户界面和交互逻辑 ,接收用户输入,向服务器发送请求,并展示服务…...

Python Ovito统计金刚石结构数量
大家好,我是小马老师。 本文介绍python ovito方法统计金刚石结构的方法。 Ovito Identify diamond structure命令可以识别和统计金刚石结构,但是无法直接输出结构的变化情况。 本文使用python调用ovito包的方法,可以持续统计各步的金刚石结构,具体代码如下: from ovito…...
JS手写代码篇----使用Promise封装AJAX请求
15、使用Promise封装AJAX请求 promise就有reject和resolve了,就不必写成功和失败的回调函数了 const BASEURL ./手写ajax/test.jsonfunction promiseAjax() {return new Promise((resolve, reject) > {const xhr new XMLHttpRequest();xhr.open("get&quo…...
4. TypeScript 类型推断与类型组合
一、类型推断 (一) 什么是类型推断 TypeScript 的类型推断会根据变量、函数返回值、对象和数组的赋值和使用方式,自动确定它们的类型。 这一特性减少了显式类型注解的需要,在保持类型安全的同时简化了代码。通过分析上下文和初始值,TypeSc…...
OD 算法题 B卷【正整数到Excel编号之间的转换】
文章目录 正整数到Excel编号之间的转换 正整数到Excel编号之间的转换 excel的列编号是这样的:a b c … z aa ab ac… az ba bb bc…yz za zb zc …zz aaa aab aac…; 分别代表以下的编号1 2 3 … 26 27 28 29… 52 53 54 55… 676 677 678 679 … 702 703 704 705;…...