更新代码
This commit is contained in:
parent
9d8b9c097d
commit
6d77498105
@ -16,7 +16,7 @@ namespace app\common\service\wechat;
|
|||||||
|
|
||||||
use EasyWeChat\Kernel\Exceptions\Exception;
|
use EasyWeChat\Kernel\Exceptions\Exception;
|
||||||
use EasyWeChat\MiniApp\Application;
|
use EasyWeChat\MiniApp\Application;
|
||||||
|
use support\Cache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信功能类
|
* 微信功能类
|
||||||
@ -102,19 +102,41 @@ class WeChatMnpService
|
|||||||
*/
|
*/
|
||||||
public function delivery()
|
public function delivery()
|
||||||
{
|
{
|
||||||
$accessToken = $this->app->getAccessToken();
|
$token=Cache::get('mmp_access_token');
|
||||||
$token = $accessToken->getToken();
|
if(!$token){
|
||||||
return $this->app->getClient()->postJson('product/delivery/send?access_token=' . $token, [
|
$token=$this->getStableAccessToken();
|
||||||
'order_id' => 'PF171564998868869065',
|
}
|
||||||
|
return $this->app->getClient()->post("wxa/sec/order/upload_shipping_info?access_token=$token", [
|
||||||
|
'order_key' =>[
|
||||||
|
'order_number_type'=>1,
|
||||||
|
'out_trade_no'=>'PF171564998868869065'
|
||||||
|
],
|
||||||
|
'logistics_type'=>4,
|
||||||
|
'delivery_mode'=>'UNIFIED_DELIVERY',
|
||||||
|
'shipping_list'=>[
|
||||||
|
['item_desc'=>'商品']
|
||||||
|
],
|
||||||
|
'upload_time'=>date('Y-m-d H:i:s'),
|
||||||
|
'payer'=>[
|
||||||
|
'openid'=>'onoIP7VVWhCZSWX8zazdNS4KazPE'
|
||||||
|
]
|
||||||
])->toArray();
|
])->toArray();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @notes 获取access_token
|
* @notes 获取access_token
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function AccessToken()
|
public function getStableAccessToken()
|
||||||
{
|
{
|
||||||
$accessToken = $this->app->getAccessToken();
|
$token =$this->app->getClient()->postJson("cgi-bin/stable_token", [
|
||||||
return $accessToken->getToken(); // string
|
'grant_type'=>'client_credential',
|
||||||
|
'appid'=>$this->config['app_id'],
|
||||||
|
'secret'=>$this->config['secret'],
|
||||||
|
'force_refresh'=>true
|
||||||
|
])->toArray();
|
||||||
|
if($token['access_token']){
|
||||||
|
Cache::set('mmp_access_token',$token['access_token'],$token['expires_in']);
|
||||||
|
return $token['access_token'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user