注:微信小程序对接发货功能
文档地址:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html
php代码
common.php
use think\Config;
use think\Db;
use fast\Http;
use think\Cache;
if(!function_exists('getAccessToken')){
//获取token
function getAccessToken()
{
$site = Config::get("site");
$appId = '';
if(array_key_exists('WX_AppID',$site)){
$appId = $site['WX_AppID'];
}
$appSecret = '';
if(array_key_exists('WX_AppSecret',$site)){
$appSecret = $site['WX_AppSecret'];
}
$cacheKey = $appId . '@access_token';
if (!Cache::get($cacheKey)) {
// 请求API获取 access_token
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={
$appId}&secret={
$appSecret}";
$result = Http::get($url);
$data = json_decode($result, true);
// return $data['access_token'];
// 写入缓存
Cache::set($cacheKey, $data['access_token'], 5000); // 7000
}
return Cache::get($cacheKey);
}
}
if(!function_exists('getWxSendOrderStatus')</