|
|
@@ -20,15 +20,15 @@ class miniUtil
|
|
|
{
|
|
|
public $access_token;
|
|
|
|
|
|
- public function __construct($merchant = '', $isOpen = 1)
|
|
|
+ public function __construct($merchant = '', $ptStyle = 1)
|
|
|
{
|
|
|
- $this->access_token = !empty($merchant) ? self::getMiniProgramAccessToken($merchant, $isOpen) : '';
|
|
|
+ $this->access_token = !empty($merchant) ? self::getMiniProgramAccessToken($merchant, $ptStyle) : '';
|
|
|
}
|
|
|
|
|
|
//获取用户基本信息
|
|
|
- public static function userInfo($openId, $merchant, $isOpen = 0)
|
|
|
+ public static function userInfo($openId, $merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getAuthorizerAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getAuthorizerAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=$accessToken&openid=$openId";
|
|
|
$curl = new curl\Curl();
|
|
|
$result = $curl->get($url);
|
|
|
@@ -41,9 +41,9 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//创建开放平台帐号
|
|
|
- public static function createOpenAccount($appId, $merchant, $isOpen = 0)
|
|
|
+ public static function createOpenAccount($appId, $merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getAuthorizerAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getAuthorizerAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/open/create?access_token=" . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$data = ['appid' => $appId];
|
|
|
@@ -53,12 +53,12 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//绑定到开放平台
|
|
|
- public static function bindOpenAccount($appId, $openAppId, $merchant, $isMiniProgram, $isOpen = 0)
|
|
|
+ public static function bindOpenAccount($appId, $openAppId, $merchant, $isMiniProgram, $ptStyle = 0)
|
|
|
{
|
|
|
if ($isMiniProgram) {
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
} else {
|
|
|
- $accessToken = self::getAuthorizerAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getAuthorizerAccessToken($merchant, $ptStyle);
|
|
|
}
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/open/bind?access_token=' . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
@@ -69,12 +69,12 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//获取公众号、小程序绑定的开放平台帐号
|
|
|
- public static function getOpenAccount($appId, $merchant, $isMiniProgram, $isOpen = 0)
|
|
|
+ public static function getOpenAccount($appId, $merchant, $isMiniProgram, $ptStyle = 0)
|
|
|
{
|
|
|
if ($isMiniProgram) {
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
} else {
|
|
|
- $accessToken = self::getAuthorizerAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getAuthorizerAccessToken($merchant, $ptStyle);
|
|
|
}
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/open/get?access_token=" . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
@@ -85,9 +85,9 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//解绑公众号绑定的平台 ssh 2019.9.15
|
|
|
- public static function unbindAccount($merchant, $isOpen = 0)
|
|
|
+ public static function unbindAccount($merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getAuthorizerAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getAuthorizerAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/open/unbind?access_token=" . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$openAppId = $merchant['openAppId'];
|
|
|
@@ -99,9 +99,9 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//解绑小程序绑定的平台 ssh 2019.9.15
|
|
|
- public static function unbindMiniProgram($merchant, $isOpen = 0)
|
|
|
+ public static function unbindMiniProgram($merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/open/unbind?access_token=" . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$openAppId = $merchant['openAppId'];
|
|
|
@@ -112,18 +112,18 @@ class miniUtil
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
- public static function getSubscribeUserList($merchant, $nextOpenId = '', $isOpen = 1)
|
|
|
+ public static function getSubscribeUserList($merchant, $nextOpenId = '', $ptStyle = 1)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=$accessToken&next_openid=$nextOpenId";
|
|
|
$curl = new curl\Curl();
|
|
|
$result = $curl->get($url);
|
|
|
return Json::decode($result);
|
|
|
}
|
|
|
|
|
|
- public static function batchGetUserInfo($merchant, $openIdList, $isOpen)
|
|
|
+ public static function batchGetUserInfo($merchant, $openIdList, $ptStyle)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token=" . $accessToken;
|
|
|
$format = [];
|
|
|
foreach ($openIdList as $val) {
|
|
|
@@ -167,7 +167,7 @@ class miniUtil
|
|
|
*/
|
|
|
public static function uploadImgMedia($merchant, $fullFile)
|
|
|
{
|
|
|
- $access_token = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $access_token = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token=" . $access_token . "&type=image";
|
|
|
$curl = curl_init();
|
|
|
if (class_exists('\CURLFile')) {//关键是判断curlfile,官网推荐php5.5或更高的版本使用curlfile来实例文件
|
|
|
@@ -200,7 +200,7 @@ class miniUtil
|
|
|
*/
|
|
|
public function uploadVideoMedia($merchant, $fullFile)
|
|
|
{
|
|
|
- $access_token = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $access_token = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token=" . $access_token . "&type=video";
|
|
|
$curl = curl_init();
|
|
|
if (class_exists('\CURLFile')) {//关键是判断curlfile,官网推荐php5.5或更高的版本使用curlfile来实例文件
|
|
|
@@ -242,9 +242,9 @@ class miniUtil
|
|
|
* 获取素材总数
|
|
|
* 图片和图文消息素材(包括单图文和多图文)的总数上限为5000,其他素材的总数上限为1000
|
|
|
*/
|
|
|
- public function getMaterialCount($merchant, $isOpen)
|
|
|
+ public function getMaterialCount($merchant, $ptStyle)
|
|
|
{
|
|
|
- $token = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $token = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/material/get_materialcount?access_token={$token}";
|
|
|
$curl = new curl\Curl();
|
|
|
$response = $curl->get($url);
|
|
|
@@ -256,9 +256,9 @@ class miniUtil
|
|
|
* $data = ['type' => 'image','offset' => 0,'count' => 100];
|
|
|
* type:news image video voice
|
|
|
*/
|
|
|
- public function batchgetMaterial($merchant, $data, $isOpen)
|
|
|
+ public function batchgetMaterial($merchant, $data, $ptStyle)
|
|
|
{
|
|
|
- $token = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $token = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token={$token}";
|
|
|
$curl = new curl\Curl();
|
|
|
$response = $curl->setOption(CURLOPT_POSTFIELDS, json_encode($data))->post($url);
|
|
|
@@ -268,9 +268,9 @@ class miniUtil
|
|
|
/**
|
|
|
* 解除绑定删除自定义菜单
|
|
|
*/
|
|
|
- public static function menuDelete($merchant, $isOpen)
|
|
|
+ public static function menuDelete($merchant, $ptStyle)
|
|
|
{
|
|
|
- $token = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $token = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=$token";
|
|
|
$curl = new curl\Curl();
|
|
|
$response = $curl->get($url);
|
|
|
@@ -326,9 +326,9 @@ class miniUtil
|
|
|
/**
|
|
|
* 创建临时二维码 ssh 2019.9.4
|
|
|
*/
|
|
|
- public static function qrcodeCreate($merchant, $sceneId, $expireSeconds = null, $isOpen = 1)
|
|
|
+ public static function qrcodeCreate($merchant, $sceneId, $expireSeconds = null, $ptStyle = 1)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=$accessToken";
|
|
|
//有效期默认一天
|
|
|
$expireSeconds = isset($expireSeconds) ? $expireSeconds : 86400;
|
|
|
@@ -342,9 +342,9 @@ class miniUtil
|
|
|
/**
|
|
|
* 创建永久二维码
|
|
|
*/
|
|
|
- public static function qrcodePermanentCreate($merchant, $sceneId, $isOpen = 1)
|
|
|
+ public static function qrcodePermanentCreate($merchant, $sceneId, $ptStyle = 1)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=$accessToken";
|
|
|
$post = array('action_name' => 'QR_LIMIT_STR_SCENE', "action_info" => array('scene' => array('scene_str' => $sceneId)));
|
|
|
$curl = new curl\Curl();
|
|
|
@@ -356,7 +356,7 @@ class miniUtil
|
|
|
/**
|
|
|
* 微信授权获取code
|
|
|
*/
|
|
|
- public static function getCode($urlEncode, $merchant, $scope, $isOpen)
|
|
|
+ public static function getCode($urlEncode, $merchant, $scope, $ptStyle)
|
|
|
{
|
|
|
$host = Yii::$app->request->getHostInfo();
|
|
|
$REDIRECT_URI = $host . '/auth/get-user-info?url=' . $urlEncode . '&authScope=' . $scope;
|
|
|
@@ -364,13 +364,13 @@ class miniUtil
|
|
|
$appId = $merchant['wxAppId'];
|
|
|
|
|
|
$open = [];
|
|
|
- if ($isOpen == 1) {
|
|
|
+ if ($ptStyle == 1) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'hd')]);
|
|
|
}
|
|
|
- if ($isOpen == 2) {
|
|
|
+ if ($ptStyle == 2) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'ghs')]);
|
|
|
}
|
|
|
- if ($isOpen == 3) {
|
|
|
+ if ($ptStyle == 3) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'mall')]);
|
|
|
}
|
|
|
if (empty($open)) {
|
|
|
@@ -387,18 +387,18 @@ class miniUtil
|
|
|
/**
|
|
|
* 获取openId
|
|
|
*/
|
|
|
- public static function getOpenId($code, $merchant, $isOpen)
|
|
|
+ public static function getOpenId($code, $merchant, $ptStyle)
|
|
|
{
|
|
|
$appId = $merchant['wxAppId'];
|
|
|
|
|
|
$open = [];
|
|
|
- if ($isOpen == 1) {
|
|
|
+ if ($ptStyle == 1) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'hd')]);
|
|
|
}
|
|
|
- if ($isOpen == 2) {
|
|
|
+ if ($ptStyle == 2) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'ghs')]);
|
|
|
}
|
|
|
- if ($isOpen == 3) {
|
|
|
+ if ($ptStyle == 3) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'mall')]);
|
|
|
}
|
|
|
if (empty($open)) {
|
|
|
@@ -433,9 +433,9 @@ class miniUtil
|
|
|
/**
|
|
|
* 自动获取自己的信息(公众号的粉丝才能获取)
|
|
|
*/
|
|
|
- public static function autoGetUserInfo($openid, $merchant, $isOpen)
|
|
|
+ public static function autoGetUserInfo($openid, $merchant, $ptStyle)
|
|
|
{
|
|
|
- $access_token = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $access_token = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=$access_token&openid=$openid&lang=zh_CN";
|
|
|
$curl = new curl\Curl();
|
|
|
$result = $curl->get($url);
|
|
|
@@ -477,9 +477,9 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//客服接口发消息
|
|
|
- public static function sendMsg($content, $merchant, $openId, $isOpen)
|
|
|
+ public static function sendMsg($content, $merchant, $openId, $ptStyle)
|
|
|
{
|
|
|
- $token = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $token = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$token}";
|
|
|
$data = ['touser' => $openId, 'msgtype' => 'text', 'text' => ['content' => $content]];
|
|
|
$curl = new curl\Curl();
|
|
|
@@ -488,9 +488,9 @@ class miniUtil
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
- public static function sendImgMsg($mediaId, $merchant, $openId, $isOpen)
|
|
|
+ public static function sendImgMsg($mediaId, $merchant, $openId, $ptStyle)
|
|
|
{
|
|
|
- $token = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $token = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$token}";
|
|
|
$data = ['touser' => $openId, 'msgtype' => 'image', 'image' => ['media_id' => $mediaId]];
|
|
|
$curl = new curl\Curl();
|
|
|
@@ -499,9 +499,9 @@ class miniUtil
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
- public static function sendVideoMsg($mediaId, $merchant, $openId, $isOpen)
|
|
|
+ public static function sendVideoMsg($mediaId, $merchant, $openId, $ptStyle)
|
|
|
{
|
|
|
- $token = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $token = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$token}";
|
|
|
$data = ['touser' => $openId, 'msgtype' => 'video', 'video' => ['media_id' => $mediaId,
|
|
|
'thumb_media_id' => $mediaId,
|
|
|
@@ -519,9 +519,9 @@ class miniUtil
|
|
|
* @param unknown $data
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public static function sendTaskInform($data, $merchant, $isOpen)
|
|
|
+ public static function sendTaskInform($data, $merchant, $ptStyle)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={$accessToken}";
|
|
|
$data = urldecode(json_encode($data, JSON_UNESCAPED_UNICODE));
|
|
|
$curl = new curl\Curl();
|
|
|
@@ -536,9 +536,9 @@ class miniUtil
|
|
|
* @param unknown $template_id_short
|
|
|
* @return unknown
|
|
|
*/
|
|
|
- public static function tMessageCreate($merchant, $shortTemplateId, $isOpen)
|
|
|
+ public static function tMessageCreate($merchant, $shortTemplateId, $ptStyle)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/template/api_add_template?access_token={$accessToken}";
|
|
|
$post = array('template_id_short' => $shortTemplateId);
|
|
|
$curl = new curl\Curl();
|
|
|
@@ -550,9 +550,9 @@ class miniUtil
|
|
|
/**
|
|
|
* 删除模板消息
|
|
|
*/
|
|
|
- public static function delTMessage($merchant, $templateId, $isOpen)
|
|
|
+ public static function delTMessage($merchant, $templateId, $ptStyle)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/template/del_private_template?access_token={$accessToken}";
|
|
|
$post = array('template_id' => $templateId);
|
|
|
$curl = new curl\Curl();
|
|
|
@@ -564,9 +564,9 @@ class miniUtil
|
|
|
/**
|
|
|
* 取所有模板消息
|
|
|
*/
|
|
|
- public function getAllTMessage($merchant, $isOpen)
|
|
|
+ public function getAllTMessage($merchant, $ptStyle)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/template/get_all_private_template?access_token={$accessToken}";
|
|
|
$curl = new curl\Curl();
|
|
|
$result = $curl->get($url);
|
|
|
@@ -577,9 +577,9 @@ class miniUtil
|
|
|
/**
|
|
|
* 设置模板消息的行业
|
|
|
*/
|
|
|
- public function setTMIndustry($merchant, $industry_id1, $industry_id2, $isOpen)
|
|
|
+ public function setTMIndustry($merchant, $industry_id1, $industry_id2, $ptStyle)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/template/api_set_industry?access_token={$accessToken}";
|
|
|
$post = array('industry_id1' => $industry_id1, 'industry_id2' => $industry_id2);
|
|
|
$curl = new curl\Curl();
|
|
|
@@ -591,18 +591,18 @@ class miniUtil
|
|
|
/**
|
|
|
* 获取公众号的accessToken 公众号调用凭据
|
|
|
*/
|
|
|
- public static function getAuthorizerAccessToken($merchant, $isOpen = 0)
|
|
|
+ public static function getAuthorizerAccessToken($merchant, $ptStyle = 0)
|
|
|
{
|
|
|
$sjId = $merchant['id'];
|
|
|
|
|
|
$open = [];
|
|
|
- if ($isOpen == 1) {
|
|
|
+ if ($ptStyle == 1) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'hd')]);
|
|
|
}
|
|
|
- if ($isOpen == 2) {
|
|
|
+ if ($ptStyle == 2) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'ghs')]);
|
|
|
}
|
|
|
- if ($isOpen == 3) {
|
|
|
+ if ($ptStyle == 3) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'mall')]);
|
|
|
}
|
|
|
if (empty($open)) {
|
|
|
@@ -629,19 +629,19 @@ class miniUtil
|
|
|
$uData['wxRefreshToken'] = $authorize_refresh_token;;
|
|
|
$uData['wxAccessToken'] = $authorize_access_token;
|
|
|
$uData['wxAccessTokenTime'] = date("Y-m-d H:i:s", (time() + $expires_in - 100));
|
|
|
- if ($isOpen == 1) {
|
|
|
+ if ($ptStyle == 1) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'hd')]);
|
|
|
$wxBaseId = isset($open['wxBaseId']) ? $open['wxBaseId'] : 0;
|
|
|
if (!empty($wxBaseId)) {
|
|
|
WxBaseService::updateById($wxBaseId, $uData);
|
|
|
}
|
|
|
- } elseif ($isOpen == 2) {
|
|
|
+ } elseif ($ptStyle == 2) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'ghs')]);
|
|
|
$wxBaseId = isset($open['wxBaseId']) ? $open['wxBaseId'] : 0;
|
|
|
if (!empty($wxBaseId)) {
|
|
|
WxBaseService::updateById($wxBaseId, $uData);
|
|
|
}
|
|
|
- } elseif ($isOpen == 3) {
|
|
|
+ } elseif ($ptStyle == 3) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'mall')]);
|
|
|
$wxBaseId = isset($open['wxBaseId']) ? $open['wxBaseId'] : 0;
|
|
|
if (!empty($wxBaseId)) {
|
|
|
@@ -661,18 +661,18 @@ class miniUtil
|
|
|
/**
|
|
|
* 获取小程序的accessToken
|
|
|
*/
|
|
|
- public static function getMiniProgramAccessToken($merchant, $isOpen = 0)
|
|
|
+ public static function getMiniProgramAccessToken($merchant, $ptStyle = 0)
|
|
|
{
|
|
|
$sjId = isset($merchant['id']) ? $merchant['id'] : 0;
|
|
|
//$id = dict::getDict('openId');
|
|
|
$open = [];
|
|
|
- if ($isOpen == 1) {
|
|
|
+ if ($ptStyle == 1) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'hd')]);
|
|
|
}
|
|
|
- if ($isOpen == 2) {
|
|
|
+ if ($ptStyle == 2) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'ghs')]);
|
|
|
}
|
|
|
- if ($isOpen == 3) {
|
|
|
+ if ($ptStyle == 3) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'mall')]);
|
|
|
}
|
|
|
if (empty($open)) {
|
|
|
@@ -682,15 +682,15 @@ class miniUtil
|
|
|
$component_app_id = $open['appId'];
|
|
|
$componentAccessToken = wxUtil::getComponentAccessToken($open);
|
|
|
$appId = $merchant['miniAppId'];
|
|
|
- if ($isOpen == 1) {
|
|
|
+ if ($ptStyle == 1) {
|
|
|
$miniAccessToken = $merchant['miniAccessToken'];
|
|
|
$miniAccessTokenTime = $merchant['miniAccessTokenTime'];
|
|
|
$miniRefreshToken = $merchant['miniRefreshToken'];
|
|
|
- } elseif ($isOpen == 2) {
|
|
|
+ } elseif ($ptStyle == 2) {
|
|
|
$miniAccessToken = $merchant['miniAccessToken'];
|
|
|
$miniAccessTokenTime = $merchant['miniAccessTokenTime'];
|
|
|
$miniRefreshToken = $merchant['miniRefreshToken'];
|
|
|
- } elseif ($isOpen == 3) {
|
|
|
+ } elseif ($ptStyle == 3) {
|
|
|
$miniAccessToken = $merchant['miniAccessToken'];
|
|
|
$miniAccessTokenTime = $merchant['miniAccessTokenTime'];
|
|
|
$miniRefreshToken = $merchant['miniRefreshToken'];
|
|
|
@@ -715,20 +715,20 @@ class miniUtil
|
|
|
$uData['miniAccessToken'] = $miniAccessToken;
|
|
|
$uData['miniAccessTokenTime'] = date("Y-m-d H:i:s", (time() + $expires_in - 100));
|
|
|
|
|
|
- if ($isOpen == 1) {
|
|
|
+ if ($ptStyle == 1) {
|
|
|
//零售
|
|
|
$wxMiniBaseId = isset($open['wxMiniBaseId']) ? $open['wxMiniBaseId'] : 0;
|
|
|
if (!empty($wxMiniBaseId)) {
|
|
|
WxMiniBaseService::updateById($wxMiniBaseId, $uData);
|
|
|
}
|
|
|
|
|
|
- } elseif ($isOpen == 2) {
|
|
|
+ } elseif ($ptStyle == 2) {
|
|
|
//供货商
|
|
|
$wxMiniBaseId = isset($open['wxMiniBaseId']) ? $open['wxMiniBaseId'] : 0;
|
|
|
if (!empty($wxMiniBaseId)) {
|
|
|
WxMiniBaseService::updateById($wxMiniBaseId, $uData);
|
|
|
}
|
|
|
- } elseif ($isOpen == 3) {
|
|
|
+ } elseif ($ptStyle == 3) {
|
|
|
//商城
|
|
|
$wxMiniBaseId = isset($open['wxMiniBaseId']) ? $open['wxMiniBaseId'] : 0;
|
|
|
if (!empty($wxMiniBaseId)) {
|
|
|
@@ -772,9 +772,9 @@ class miniUtil
|
|
|
/**
|
|
|
* 下载学员作品图片
|
|
|
*/
|
|
|
- public static function downloadStudentWorksImg($merchant, $mediaId, $savePathType = 'wxUserImg', $isOpen = 1)
|
|
|
+ public static function downloadStudentWorksImg($merchant, $mediaId, $savePathType = 'wxUserImg', $ptStyle = 1)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token={$accessToken}&media_id={$mediaId}";
|
|
|
$ch = curl_init($url);
|
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
|
@@ -811,9 +811,9 @@ class miniUtil
|
|
|
/**
|
|
|
* 获取media_id里的图片保存到服务器
|
|
|
*/
|
|
|
- public static function downloadmediaIdImg($merchant, $mediaId, $savePathType = 'wxUserImg', $isOpen)
|
|
|
+ public static function downloadmediaIdImg($merchant, $mediaId, $savePathType = 'wxUserImg', $ptStyle)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token={$accessToken}&media_id={$mediaId}";
|
|
|
$ch = curl_init($url);
|
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
|
@@ -849,9 +849,9 @@ class miniUtil
|
|
|
return ['large' => $fileName, 'medium' => $mediumImg, 'small' => $smallImg];
|
|
|
}
|
|
|
|
|
|
- public static function createTag($merchant, $name, $isOpen)
|
|
|
+ public static function createTag($merchant, $name, $ptStyle)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/tags/create?access_token={$accessToken}";
|
|
|
$post = ['tag' => ['name' => $name]];
|
|
|
$curl = new curl\Curl();
|
|
|
@@ -860,9 +860,9 @@ class miniUtil
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
- public static function delTag($merchant, $id, $isOpen)
|
|
|
+ public static function delTag($merchant, $id, $ptStyle)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/tags/delete?access_token={$accessToken}";
|
|
|
$post = ['tag' => ['id' => $id]];
|
|
|
$curl = new curl\Curl();
|
|
|
@@ -871,9 +871,9 @@ class miniUtil
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
- public static function modTag($merchant, $id, $name, $isOpen)
|
|
|
+ public static function modTag($merchant, $id, $name, $ptStyle)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/tags/update?access_token={$accessToken}";
|
|
|
$post = ['tag' => ['id' => $id, 'name' => $name]];
|
|
|
$curl = new curl\Curl();
|
|
|
@@ -885,9 +885,9 @@ class miniUtil
|
|
|
/**
|
|
|
* 获取商家所有标签
|
|
|
*/
|
|
|
- public static function getTag($merchant, $isOpen)
|
|
|
+ public static function getTag($merchant, $ptStyle)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/tags/get?access_token={$accessToken}";
|
|
|
$curl = new curl\Curl();
|
|
|
$result = $curl->get($url);
|
|
|
@@ -908,9 +908,9 @@ class miniUtil
|
|
|
/**
|
|
|
* 批量为用户打标签
|
|
|
*/
|
|
|
- public static function membersBatchTag($merchant, $openIdList, $tagId, $isOpen)
|
|
|
+ public static function membersBatchTag($merchant, $openIdList, $tagId, $ptStyle)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token={$accessToken}";
|
|
|
$post = ['openid_list' => $openIdList, 'tagid' => $tagId];
|
|
|
$curl = new curl\Curl();
|
|
|
@@ -922,9 +922,9 @@ class miniUtil
|
|
|
/**
|
|
|
* 批量取消用户标签
|
|
|
*/
|
|
|
- public static function membersCancelTag($merchant, $openIdList, $tagId, $isOpen)
|
|
|
+ public static function membersCancelTag($merchant, $openIdList, $tagId, $ptStyle)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?access_token={$accessToken}";
|
|
|
$post = ['openid_list' => $openIdList, 'tagid' => $tagId];
|
|
|
$curl = new curl\Curl();
|
|
|
@@ -936,9 +936,9 @@ class miniUtil
|
|
|
/**
|
|
|
* 新增临时素材
|
|
|
*/
|
|
|
- public static function uploadTempMedia($merchant, $fullPathImg, $isOpen, $type = 'image')
|
|
|
+ public static function uploadTempMedia($merchant, $fullPathImg, $ptStyle, $type = 'image')
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token={$accessToken}&type=" . $type;
|
|
|
$ch = curl_init();
|
|
|
if (class_exists('CURLFile')) {// 这里用特性检测判断php版本
|
|
|
@@ -962,9 +962,9 @@ class miniUtil
|
|
|
/**
|
|
|
* 获取临时素材
|
|
|
*/
|
|
|
- public static function getTempMaterial($merchant, $mediaId, $isOpen)
|
|
|
+ public static function getTempMaterial($merchant, $mediaId, $ptStyle)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token={$accessToken}&media_id=" . $mediaId;
|
|
|
$fileInfo = self::getTempMaterialInfo($url);
|
|
|
if (empty($fileInfo) || isset($fileInfo['errcode'])) {
|
|
|
@@ -1274,13 +1274,13 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//设置小程序服务器域名
|
|
|
- public static function setDomain($merchant, $isOpen = 0)
|
|
|
+ public static function setDomain($merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/wxa/modify_domain?access_token=" . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$mallHost = Yii::$app->params['mallHost'];
|
|
|
- if ($isOpen == 1) {
|
|
|
+ if ($ptStyle == 1) {
|
|
|
$mallHost = Yii::$app->params['hdHost'];
|
|
|
}
|
|
|
$has = strpos($mallHost, 'https');
|
|
|
@@ -1302,13 +1302,13 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//设置业务域名
|
|
|
- public static function setWebViewDomain($merchant, $isOpen = 0)
|
|
|
+ public static function setWebViewDomain($merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/wxa/setwebviewdomain?access_token=" . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$mallHost = Yii::$app->params['mallHost'];
|
|
|
- if ($isOpen == 1) {
|
|
|
+ if ($ptStyle == 1) {
|
|
|
$mallHost = Yii::$app->params['hdHost'];
|
|
|
}
|
|
|
$has = strpos($mallHost, 'https');
|
|
|
@@ -1326,13 +1326,13 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//为授权的小程序帐号上传小程序代码
|
|
|
- public static function miniCommit($merchant, $templateId, $isOpen = 0)
|
|
|
+ public static function miniCommit($merchant, $templateId, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = 'https://api.weixin.qq.com/wxa/commit?access_token=' . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$apiUrl = Yii::$app->params['mallHost'];
|
|
|
- if ($isOpen == 1) {
|
|
|
+ if ($ptStyle == 1) {
|
|
|
$apiUrl = Yii::$app->params['hdHost'];
|
|
|
}
|
|
|
$imgUrl = imgUtil::getPrefix();
|
|
|
@@ -1351,13 +1351,13 @@ class miniUtil
|
|
|
$account = isset($merchant['id']) ? $merchant['id'] : 0;
|
|
|
$name = isset($merchant['name']) ? $merchant['name'] : '';
|
|
|
$open = [];
|
|
|
- if ($isOpen == 1) {
|
|
|
+ if ($ptStyle == 1) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'hd')]);
|
|
|
}
|
|
|
- if ($isOpen == 2) {
|
|
|
+ if ($ptStyle == 2) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'ghs')]);
|
|
|
}
|
|
|
- if ($isOpen == 3) {
|
|
|
+ if ($ptStyle == 3) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'mall')]);
|
|
|
}
|
|
|
if (empty($open)) {
|
|
|
@@ -1391,9 +1391,9 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//获取体验小程序的体验二维码
|
|
|
- public static function getExperienceQrCode($merchant, $page, $isOpen = 0)
|
|
|
+ public static function getExperienceQrCode($merchant, $page, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$path = urlencode($page);
|
|
|
$url = "https://api.weixin.qq.com/wxa/get_qrcode?access_token={$accessToken}&path=" . $path;
|
|
|
$curl = new curl\Curl();
|
|
|
@@ -1404,9 +1404,9 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//获取授权小程序帐号已设置的类目
|
|
|
- public static function getMiniCategory($merchant, $isOpen = 0)
|
|
|
+ public static function getMiniCategory($merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/wxa/get_category?access_token=" . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$result = $curl->get($url);
|
|
|
@@ -1416,9 +1416,9 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//小程序支付成功后获取唯一ID ssh 2020.5.12
|
|
|
- public static function getPaidUnionId($merchant, $miniOpenId, $mcId, $orderId, $isOpen = 0)
|
|
|
+ public static function getPaidUnionId($merchant, $miniOpenId, $mcId, $orderId, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/wxa/getpaidunionid?access_token={$accessToken}&openid={$miniOpenId}&mch_id={$mcId}&out_trade_no=" . (string)$orderId;
|
|
|
$curl = new curl\Curl();
|
|
|
$result = $curl->get($url);
|
|
|
@@ -1428,9 +1428,9 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//小程序加急审核 ssh 2020.4.20
|
|
|
- public static function speedupAudit($merchant, $id, $isOpen = 0)
|
|
|
+ public static function speedupAudit($merchant, $id, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/wxa/speedupaudit?access_token=" . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$data = [
|
|
|
@@ -1442,9 +1442,9 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//获取小程序的第三方提交代码的页面配置
|
|
|
- public static function getMiniPage($merchant, $isOpen = 0)
|
|
|
+ public static function getMiniPage($merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/wxa/get_page?access_token=" . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$result = $curl->get($url);
|
|
|
@@ -1454,12 +1454,12 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//将第三方提交的代码包提交审核
|
|
|
- public static function miniSubmitAudit($merchant, $page, $isOpen = 0)
|
|
|
+ public static function miniSubmitAudit($merchant, $page, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/wxa/submit_audit?access_token=" . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
- if ($isOpen == 1) {
|
|
|
+ if ($ptStyle == 1) {
|
|
|
$data = [
|
|
|
"item_list" => [
|
|
|
[
|
|
|
@@ -1499,9 +1499,9 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//查询最新一次提交的审核状态
|
|
|
- public static function miniGetLatestAuditStatus($merchant, $isOpen = 0)
|
|
|
+ public static function miniGetLatestAuditStatus($merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/wxa/get_latest_auditstatus?access_token=" . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$result = $curl->get($url);
|
|
|
@@ -1512,9 +1512,9 @@ class miniUtil
|
|
|
|
|
|
|
|
|
//发布已通过审核的小程序
|
|
|
- public static function miniRelease($merchant, $isOpen = 0)
|
|
|
+ public static function miniRelease($merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/wxa/release?access_token=" . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$result = $curl->setOption(CURLOPT_POSTFIELDS, '{}')->post($url);
|
|
|
@@ -1523,9 +1523,9 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//撤回审核
|
|
|
- public static function rollbackCheck($merchant, $isOpen = 0)
|
|
|
+ public static function rollbackCheck($merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/wxa/undocodeaudit?access_token=" . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$result = $curl->get($url);
|
|
|
@@ -1535,7 +1535,7 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//申请会员的小程序码
|
|
|
- public static function generateMemberCode($merchant, $shopId, $isOpen = 0)
|
|
|
+ public static function generateMemberCode($merchant, $shopId, $ptStyle = 0)
|
|
|
{
|
|
|
$fileName = $merchant['id'] . '_' . $shopId . '_apply_member.jpg';
|
|
|
$behind = 'retail/mimiMemberCode/';
|
|
|
@@ -1548,7 +1548,7 @@ class miniUtil
|
|
|
return $behind . $fileName;
|
|
|
}
|
|
|
$path = 'pages/home/user?scan=1&shopId=' . $shopId;
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/wxa/getwxacode?access_token={$accessToken}";
|
|
|
$curl = new curl\Curl();
|
|
|
$data = [
|
|
|
@@ -1561,7 +1561,7 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//小程序码生成,永久有效,数量暂无限制 ssh 2020.4.17
|
|
|
- public static function generateUnlimitedMiniCode($merchant, $page, $scene = '', $isOpen = 0)
|
|
|
+ public static function generateUnlimitedMiniCode($merchant, $page, $scene = '', $ptStyle = 0)
|
|
|
{
|
|
|
$id = isset($merchant['id']) ? $merchant['id'] : 0;
|
|
|
$fileName = md5($page . '_' . $scene) . '.jpg';
|
|
|
@@ -1574,7 +1574,7 @@ class miniUtil
|
|
|
if (file_exists($file)) {
|
|
|
return $behind . $fileName;
|
|
|
}
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={$accessToken}";
|
|
|
$curl = new curl\Curl();
|
|
|
$data = [];
|
|
|
@@ -1668,17 +1668,17 @@ class miniUtil
|
|
|
* 微信开放平台使用授权码换取公众号的接口调用凭据和授权信息
|
|
|
* authorizer_access_token authorizer_refresh_token
|
|
|
*/
|
|
|
- public static function getAuthorizer($code, $isOpen)
|
|
|
+ public static function getAuthorizer($code, $ptStyle)
|
|
|
{
|
|
|
|
|
|
$open = [];
|
|
|
- if ($isOpen == 1) {
|
|
|
+ if ($ptStyle == 1) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'hd')]);
|
|
|
}
|
|
|
- if ($isOpen == 2) {
|
|
|
+ if ($ptStyle == 2) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'ghs')]);
|
|
|
}
|
|
|
- if ($isOpen == 3) {
|
|
|
+ if ($ptStyle == 3) {
|
|
|
$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => dict::getDict('ptStyle', 'mall')]);
|
|
|
}
|
|
|
if (empty($open)) {
|
|
|
@@ -1709,9 +1709,9 @@ class miniUtil
|
|
|
}
|
|
|
/**************************即时配送相关接口 START *****************************************/
|
|
|
//开通即时配送权限
|
|
|
- public static function openLocalExpress($merchant, $isOpen = 0)
|
|
|
+ public static function openLocalExpress($merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/express/local/business/open?access_token=" . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$result = $curl->get($url);
|
|
|
@@ -1734,9 +1734,9 @@ class miniUtil
|
|
|
|
|
|
}
|
|
|
*/
|
|
|
- public static function abnormalConfirm($data, $merchant, $isOpen = 0)
|
|
|
+ public static function abnormalConfirm($data, $merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/confirm_return?access_token=' . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$data = Json::encode($data);
|
|
|
@@ -1746,9 +1746,9 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//即时配送,拉取已绑定账号 ssh 2021.2.1
|
|
|
- public static function getBindAccount($merchant, $isOpen = 0)
|
|
|
+ public static function getBindAccount($merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/shop/get?access_token=' . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$result = $curl->setOption(CURLOPT_POSTFIELDS, '{}')->post($url);
|
|
|
@@ -1757,9 +1757,9 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//获取已支持的配送公司列表接口 linqh 2021.2.2
|
|
|
- public static function getAllImmeDelivery($merchant, $isOpen = 0)
|
|
|
+ public static function getAllImmeDelivery($merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/delivery/getall?access_token=' . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$result = $curl->setOption(CURLOPT_POSTFIELDS, '{}')->post($url);
|
|
|
@@ -1775,9 +1775,9 @@ class miniUtil
|
|
|
* 商家可调用本接口向配送公司请求下配送单,配送公司会返回这一单的配送单号、配送费、预计骑手接单时间等信息。
|
|
|
如遇下单错误,请先确认一下编码方式,python建议 json.dumps(b, ensure_ascii=False),php建议 json_encode($arr, JSON_UNESCAPED_UNICODE) 可预约时间:达达:72小时内,闪送2小时以后,48小时以内
|
|
|
*/
|
|
|
- public static function addOrder($data, $merchant, $isOpen = 0)
|
|
|
+ public static function addOrder($data, $merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/add?access_token=' . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$data = Json::encode($data);
|
|
|
@@ -1798,9 +1798,9 @@ class miniUtil
|
|
|
"shop_no": "shop_no_111"
|
|
|
}
|
|
|
*/
|
|
|
- public static function addTip($data, $merchant, $isOpen = 0)
|
|
|
+ public static function addTip($data, $merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/addtips?access_token=' . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$data = Json::encode($data);
|
|
|
@@ -1810,9 +1810,9 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//取消配送单接口 linqh 2021.2.3
|
|
|
- public static function cancelOrder($data, $merchant, $isOpen = 0)
|
|
|
+ public static function cancelOrder($data, $merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/cancel?access_token=' . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$data = Json::encode($data);
|
|
|
@@ -1822,9 +1822,9 @@ class miniUtil
|
|
|
}
|
|
|
|
|
|
//拉取配送单信息 linqh 2021.2.3
|
|
|
- public static function getOrder($data, $merchant, $isOpen = 0)
|
|
|
+ public static function getOrder($data, $merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/get?access_token=' . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$data = Json::encode($data);
|
|
|
@@ -1835,9 +1835,9 @@ class miniUtil
|
|
|
|
|
|
|
|
|
//模拟配送公司更新配送单状态, 该接口只用于沙盒环境,即订单并没有真实流转到运力方
|
|
|
- public static function mockUpdateOrder($data, $merchant, $isOpen = 0)
|
|
|
+ public static function mockUpdateOrder($data, $merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/test_update_order?access_token=' . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$data = Json::encode($data);
|
|
|
@@ -1849,9 +1849,9 @@ class miniUtil
|
|
|
//预下配送单接口
|
|
|
//在用户提交外卖订单时,商家可调用本接口查询配送公司是否可接单、预计多久接单、运费预估等。
|
|
|
//预估运费可作为展示给用户的运费参考值。
|
|
|
- public static function preAddOrder($data, $merchant, $isOpen = 0)
|
|
|
+ public static function preAddOrder($data, $merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/pre_add?access_token=' . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$data = Json::encode($data);
|
|
|
@@ -1862,9 +1862,9 @@ class miniUtil
|
|
|
|
|
|
//预取消配送单接口
|
|
|
//在正式取消配送单前,商家可调用本接口查询该订单是否可以取消,取消订单配送公司需要扣除的费用是多少
|
|
|
- public static function preCancelOrder($data, $merchant, $isOpen = 0)
|
|
|
+ public static function preCancelOrder($data, $merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/precancel?access_token=' . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$data = Json::encode($data);
|
|
|
@@ -1876,9 +1876,9 @@ class miniUtil
|
|
|
//重新下单
|
|
|
//在调用下配送单接口、订单被取消、过期或者投递异常的情况下,可调用此接口,重新下单,需要保持orderid一致。
|
|
|
//备注:美团不支持重新下单接口,如果订单被取消商家需要重新下单,请修改orderid之后,调用下配送单接口下单。
|
|
|
- public static function reOrder($data, $merchant, $isOpen = 0)
|
|
|
+ public static function reOrder($data, $merchant, $ptStyle = 0)
|
|
|
{
|
|
|
- $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
|
|
|
+ $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/readd?access_token=' . $accessToken;
|
|
|
$curl = new curl\Curl();
|
|
|
$data = Json::encode($data);
|