Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
近在做應(yīng)用商城涉及到小程序微信支付和app支付寶支付,所以也大概地將這方面的東西看了一個遍,整個流程梳理總結(jié)一下。
環(huán)境是:tp5 + 小程序 + App
app_id 商戶appid
private_path 商戶私鑰
1.生成密鑰并上傳
https://opendocs.alipay.com/open/291/105971
2.PHP的demo下載地址
https://opendocs.alipay.com/open/54/103419
3.php支付消息
<?php
/*
* out_trade_no string 支付單號
* total_fee string 支付金額(單位分)
* notify_url 支付后回調(diào)地址
* Date:2021-03-12
*/
//微信支付
function parampay($out_trade_no,$total_fee,$notify_url){
$body='商品支付';//支付標(biāo)題
header("Content-type:text/html;charset=utf-8");
require_once './alipay/aop/AopClient.php';
$private_path="./alipay/key/app_private_key.pem";//私鑰路徑
//構(gòu)造業(yè)務(wù)請求參數(shù)的集合(訂單信息)
$content=array();
$content['timeout_express']="30m";
$content['product_code']="QUICK_MSECURITY_PAY";//銷售產(chǎn)品碼,固定值
$content['total_amount']=$total_fee;
$content['subject']=$body;
$content['out_trade_no']=$out_trade_no;
$con=json_encode($content);//$content是biz_content的值,將之轉(zhuǎn)化成json字符串
//公共參數(shù)
$Client=new \AopClient();//實例化支付寶sdk里面的AopClient類,下單時需要的操作,都在這個類里面
$param['app_id']='';//商戶信息
$param['method']='alipay.trade.app.pay';//接口名稱,固定值
$param['format']='json';//請求使用的編碼格式
$param['charset']='utf-8';//請求使用的編碼格式
$param['sign_type']='RSA2';//商戶生成簽名字符串所使用的簽名算法類型
$param['timestamp']=date("Y-m-d H:i:s");//發(fā)送請求的時間
$param['version']='1.0';//調(diào)用的接口版本,固定為:1.0
$param['notify_url']=SITE_URL.'/api/Onilnestudy/alipaynotify';
$param['biz_content']=$con;//業(yè)務(wù)請求參數(shù)的集合,長度不限,json格式,即前面一步得到的
// dump($param);
$paramStr=$Client->getSignContent($param);//組裝請求簽名參數(shù)
// $paramStr='a=123';
$sign=$Client->alonersaSign($paramStr, $private_path, 'RSA2', true);//生成簽名
// dump($sign);
$param['sign']=$sign;
return $info=$Client->getSignContentUrlencode($param);//最終請求參數(shù)
}
?>
異步回調(diào)消息處理
indows 11 KB5011563 終于開始向公司測試渠道以外的用戶推出。此版本帶有一些新功能和一些小的改進。您可以通過 Windows 更新嘗試新的可選補丁或下載 KB5011563 的離線安裝程序。
Windows 11 KB5011563 是一個可選更新,除非您明確單擊“獲取更新”按鈕,否則它不會自動安裝。正如我們所知,可以跳過可選更新并且我們不必安裝它,除非我們真的需要那些小的改進和錯誤修復(fù)。2022 年 4 月的星期二補丁將推出相同的一組更改。
與上個月的更新不同,2022 年 3 月的可選更新并沒有帶來大量新功能,但幾乎沒有質(zhì)量改進。例如,Windows 11 通知中心現(xiàn)在可以同時顯示多達三個高優(yōu)先級 Toast 通知。
如前所述,您可以直接從 Windows 更新設(shè)置頁面下載和安裝可選更新。同時,可以從 Microsoft 更新目錄下載離線安裝程序(.msu 包)并執(zhí)行更新,而無需依賴內(nèi)置機制。
如果您無法使用 Windows 更新安裝更新,更新目錄特別有用。在這種情況下,您可以從微軟的網(wǎng)站上獲取離線包。要開始,請打開上面的鏈接,選擇“下載”按鈕,復(fù)制 .msu 鏈接并在新選項卡中打開它以開始下載。
正如開頭所說,微軟正在對通知中心的默認(rèn)行為進行更改。更新后,Windows 11 將同時顯示三個高優(yōu)先級 Toast 通知。這適用于性質(zhì)相同(優(yōu)先級)的呼叫、提醒或警報等通知。
因此,您可能會注意到最多四個 toast 通知,您會發(fā)現(xiàn)三個高優(yōu)先級通知和一個普通優(yōu)先級通知。
除了這個新功能,微軟還修復(fù)了操作系統(tǒng)中的幾個錯誤。例如,修復(fù)了一個錯誤,即 Windows 會錯誤地禁用對使用通用 Windows 平臺 (UWP) 構(gòu)建的應(yīng)用程序的啟動應(yīng)用程序支持。
另一個嚴(yán)重錯誤已修復(fù),其中 SystemSettings.exe 可能會停止工作,并且 searchindexer.exe 會阻止 Outlook 的脫機搜索返回最近的電子郵件。
微軟表示,它還修復(fù)了一個潛在的性能問題,即啟動時間會因網(wǎng)絡(luò) API 中的 UI 線程而增加,當(dāng) 5G WWAN 設(shè)備喚醒緩慢時,網(wǎng)絡(luò)會停止響應(yīng)。
在 Windows 11 Build 22000.593 中,微軟正式在未能滿足操作系統(tǒng)官方系統(tǒng)要求的桌面上啟用桌面水印。
您可能還記得,Windows 11 官方僅通過 TPM 2.0 和 SecureBoot 支持較新的處理器。為了提醒用戶他們的硬件不受支持,微軟現(xiàn)在在系統(tǒng)托盤上方放置一個水印(桌面右下角,在激活錯誤下方)。
此水印之前在預(yù)覽版本中被發(fā)現(xiàn),現(xiàn)在已通過今天的可選更新進入生產(chǎn)渠道。
任何在不受官方支持的機器上安裝了 Windows 11 操作系統(tǒng)的人都會在桌面上看到水印,上面寫著“未滿足系統(tǒng)要求”,然后有一個鏈接可以了解更多信息。
秒殺活動中,熱賣商品的詳情頁訪問頻率非常高,詳情頁的數(shù)據(jù)加載,我們可以采用直接從數(shù)據(jù)庫查詢加載,但這種方式會給數(shù)據(jù)庫帶來極大的壓力,甚至崩潰,這種方式我們并不推薦。
? 商品詳情頁主要有商品介紹、商品標(biāo)題、商品圖片、商品價格、商品數(shù)量等,大部分?jǐn)?shù)據(jù)幾乎不變,可能只有數(shù)量會變,因此我們可以考慮把商品詳情頁做成靜態(tài)頁,每次訪問只需要加載庫存數(shù)量,這樣就可以大大降低數(shù)據(jù)庫的壓力。
? 我們這里將采用freemarker來實現(xiàn)商品詳情頁的靜態(tài)化,關(guān)于freemarker的語法我們就不在這里講解了,大家可以自行去網(wǎng)上查閱相關(guān)API。
我們創(chuàng)建一個靜態(tài)頁生成工程,用于生成商品詳情頁。
pom.xml
<dependencies>
<!--依賴web-->
<dependency>
<groupId>com.seckill</groupId>
<artifactId>seckill-web</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<!--api-->
<dependency>
<groupId>com.seckill</groupId>
<artifactId>seckill-goods-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<!--freemarker-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
</dependencies>
bootstrap.yml
server:
port: 18087
spring:
application:
name: seckill-page
cloud:
nacos:
config:
file-extension: yaml
server-addr: nacos-server:8848
discovery:
#Nacos的注冊地址
server-addr: nacos-server:8848
profiles:
active: dev #dev 開發(fā)環(huán)境 #test測試環(huán)境 #pro生產(chǎn)環(huán)境
main:
allow-bean-definition-overriding: true
#freemarker配置
freemarker:
cache: false #關(guān)閉模板緩存,方便測試
settings:
template_update_delay: 0 #檢查模板更新延遲時間,設(shè)置為0表示立即檢查,如果時間大于0會有緩存不方便進行模板測試
template-loader-path: classpath:/templates
charset: UTF-8
check-template-location: true
suffix: .ftl
content-type: text/html
expose-request-attributes: true
expose-session-attributes: true
request-context-attribute: request
#超時配置
ribbon:
ReadTimeout: 300000
ConnectTimeout: 30000
#靜態(tài)頁位置
htmlPath: D:/page/html
創(chuàng)建文件生成對象:
public class BaseProcess {
@Autowired
private Configuration configuration;
/***
* 生成靜態(tài)頁
* @param dataMap
* dataMap.templateName: 模板名字
* dataMap.path: 生成文件存儲路徑
* dataMap.name: 生成的文件名字
* @throws Exception
*/
public void writerPage(Map<String,Object> dataMap) throws Exception {
//獲取模板名字
String templateName=dataMap.get("templateName").toString();
//文件生存的路徑
String path=dataMap.get("path").toString();
//文件路徑如果不存在,則創(chuàng)建
File file=new File(path);
if(!file.exists()){
file.mkdirs();
}
//獲取文件名字
String fileName=dataMap.get("name").toString();
//獲取模板對象
Template template=configuration.getTemplate(templateName);
//模板處理,獲取生成的文件字符串
String content=FreeMarkerTemplateUtils.processTemplateIntoString(template, dataMap);
//生成文件
FileUtils.writeStringToFile(new File(path,fileName),content);
}
}
BaseProcess介紹:
該類用于生成靜態(tài)文件,調(diào)用writerPage方法即可實現(xiàn),其中有3個變量,變量注釋如下:
templateName:模板名字,例如item.ftl,模板放到templates目錄下
path:生成文件的路徑,例如D:/page/html
name:生成靜態(tài)頁文件的名字,例如:1.html
生成商品詳情頁,我們需要提供商品信息(sku),并且將商品數(shù)據(jù)存儲到數(shù)據(jù)模型Map中,然后在頁面渲染。
1)靜態(tài)頁生成
在seckill-page中創(chuàng)建com.seckill.page.service.SkuPageService,添加生成靜態(tài)頁方法,代碼如下:
/***
* 生成靜態(tài)頁
*/
void itemPage(Map<String,Object> dataMap) throws Exception;
在seckill-page中創(chuàng)建com.seckill.page.service.impl.SkuPageServiceImpl,添加生成靜態(tài)頁方法,代碼如下:
@Service
public class SkuPageServiceImpl extends BaseProcess implements SkuPageService {
/***
* 生成靜態(tài)頁
*/
@Override
public void itemPage(Map<String,Object> dataMap) throws Exception {
dataMap.put("username","王五");
//生成靜態(tài)頁
super.writerPage(dataMap);
}
}
在seckill-page中創(chuàng)建com.seckill.page.controller.SkuPageController,添加生成靜態(tài)頁方法,代碼如下:
@RestController
@RequestMapping(value="/page")
public class SkuPageController {
@Autowired
private SkuPageService skuPageService;
@Value("${htmlPath}")
private String htmlPath;
/****
* 生成商品詳情靜態(tài)頁
*/
@PostMapping(value="/html")
public Result html(@RequestBody Sku sku) throws Exception {
//數(shù)據(jù)模型
Map<String,Object> dataMap=new HashMap<String,Object>();
dataMap.put("name",sku.getId()+".html"); //生成靜態(tài)頁的文件名字
dataMap.put("path",htmlPath); //文件路徑
dataMap.put("templateName","item.ftl"); //模板名字
dataMap.put("sku",sku); //商品數(shù)據(jù)
//生成靜態(tài)頁
skuPageService.itemPage(dataMap);
return new Result(true, StatusCode.OK,"生成成功!");
}
}
注意:其中bootstrap.yml中添加htmlPath: D:/page/html配置。
2)Feign調(diào)用
在seckill-page-api中創(chuàng)建com.seckill.page.feign.SkuPageFeign實現(xiàn)調(diào)用,代碼如下:
*請認(rèn)真填寫需求信息,我們會在24小時內(nèi)與您取得聯(lián)系。