diff --git a/Wechat/Contracts/Prpcrypt.php b/Wechat/Contracts/Prpcrypt.php
index 59c14c8..2b93c50 100644
--- a/Wechat/Contracts/Prpcrypt.php
+++ b/Wechat/Contracts/Prpcrypt.php
@@ -19,7 +19,7 @@
class PKCS7Encoder
{
- public static $block_size = 32;
+ public static $blockSize = 32;
/**
* 对需要加密的明文进行填充补位
@@ -28,9 +28,9 @@ class PKCS7Encoder
*/
function encode($text)
{
- $amount_to_pad = PKCS7Encoder::$block_size - (strlen($text) % PKCS7Encoder::$block_size);
+ $amount_to_pad = PKCS7Encoder::$blockSize - (strlen($text) % PKCS7Encoder::$blockSize);
if ($amount_to_pad == 0) {
- $amount_to_pad = PKCS7Encoder::$block_size;
+ $amount_to_pad = PKCS7Encoder::$blockSize;
}
list($pad_chr, $tmp) = [chr($amount_to_pad), ''];
for ($index = 0; $index < $amount_to_pad; $index++) {
@@ -47,10 +47,10 @@ class PKCS7Encoder
function decode($text)
{
$pad = ord(substr($text, -1));
- if ($pad < 1 || $pad > PKCS7Encoder::$block_size) {
+ if ($pad < 1 || $pad > PKCS7Encoder::$blockSize) {
$pad = 0;
}
- return substr($text, 0, (strlen($text) - $pad));
+ return substr($text, 0, strlen($text) - $pad);
}
}
@@ -119,7 +119,6 @@ class Prpcrypt
} catch (Exception $e) {
return [ErrorCode::$IllegalBuffer, null];
}
-
}
/**
@@ -176,13 +175,13 @@ class ErrorCode
/**
* 获取错误消息内容
- * @param string $err
+ * @param string $code 错误代码
* @return bool
*/
- public static function getErrText($err)
+ public static function getErrText($code)
{
- if (isset(self::$errCode[$err])) {
- return self::$errCode[$err];
+ if (isset(self::$errCode[$code])) {
+ return self::$errCode[$code];
}
return false;
}
diff --git a/Wechat/Contracts/Request.php b/Wechat/Contracts/Request.php
index 5a72271..94107d5 100644
--- a/Wechat/Contracts/Request.php
+++ b/Wechat/Contracts/Request.php
@@ -99,14 +99,14 @@ class Request
require __DIR__ . '/Prpcrypt.php';
}
$prpcrypt = new \Prpcrypt($this->config->get('encodingaeskey'));
- $result = Tools::fromXml($this->postxml);
+ $result = Tools::xml2arr($this->postxml);
$array = $prpcrypt->decrypt($result['Encrypt']);
if (intval($array[0]) > 0) {
throw new InvalidResponseException($array[1], $array[0]);
}
list($this->postxml, $this->appid) = [$array[1], $array[2]];
}
- $this->receive = new Config(Tools::fromXml($this->postxml));
+ $this->receive = new Config(Tools::xml2arr($this->postxml));
} elseif ($_SERVER['REQUEST_METHOD'] == "GET" && $this->checkSignature()) {
@ob_clean();
exit($this->params->get('echostr'));
@@ -152,7 +152,7 @@ class Request
*/
public function reply(array $data = [], $return = false)
{
- $xml = Tools::toXml(empty($data) ? $this->message : $data);
+ $xml = Tools::arr2xml(empty($data) ? $this->message : $data);
if ($this->encryptType == 'aes') {
if (!class_exists('Prpcrypt', false)) {
require __DIR__ . '/Prpcrypt.php';
diff --git a/Wechat/Contracts/Tools.php b/Wechat/Contracts/Tools.php
index 814f3d4..e40bb51 100644
--- a/Wechat/Contracts/Tools.php
+++ b/Wechat/Contracts/Tools.php
@@ -117,9 +117,9 @@ class Tools
* @param array $data
* @return string
*/
- public static function toXml($data)
+ public static function arr2xml($data)
{
- return "" . self::_data_to_xml($data) . "";
+ return "" . self::_arr2xml($data) . "";
}
/**
@@ -128,12 +128,12 @@ class Tools
* @param string $content
* @return string
*/
- private static function _data_to_xml($data, $content = '')
+ private static function _arr2xml($data, $content = '')
{
foreach ($data as $key => $val) {
$content .= "<{$key}>";
if (is_array($val) || is_object($val)) {
- $content .= self::_data_to_xml($val);
+ $content .= self::_arr2xml($val);
} elseif (is_string($val)) {
$content .= '';
} else {
@@ -149,9 +149,9 @@ class Tools
* @param string $xml
* @return array
*/
- public static function fromXml($xml)
+ public static function xml2arr($xml)
{
- return json_decode(self::toJson(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
+ return json_decode(self::arr2json(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
}
/**
@@ -159,7 +159,7 @@ class Tools
* @param array $data
* @return null|string|string
*/
- public static function toJson($data)
+ public static function arr2json($data)
{
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', function ($matches) {
return mb_convert_encoding(pack("H*", $matches[1]), "UTF-8", "UCS-2BE");
@@ -172,7 +172,7 @@ class Tools
* @return array
* @throws InvalidResponseException
*/
- public static function fromJson($json)
+ public static function json2arr($json)
{
$result = json_decode($json, true);
if (empty($result)) {
@@ -198,15 +198,15 @@ class Tools
if (!empty($options['query'])) {
$url .= (stripos($url, '?') !== false ? '&' : '?') . http_build_query($options['query']);
}
- // POST数据设置
- if (strtolower($method) === 'post') {
- curl_setopt($curl, CURLOPT_POST, true);
- curl_setopt($curl, CURLOPT_POSTFIELDS, self::build($options['data']));
- }
// CURL头信息设置
if (!empty($options['headers'])) {
curl_setopt($curl, CURLOPT_HTTPHEADER, $options['headers']);
}
+ // POST数据设置
+ if (strtolower($method) === 'post') {
+ curl_setopt($curl, CURLOPT_POST, true);
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $options['data']);
+ }
// 证书文件设置
if (!empty($options['ssl_cer'])) {
if (file_exists($options['ssl_cer'])) {
@@ -228,33 +228,13 @@ class Tools
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($curl, CURLOPT_HEADER, false);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
list($content, $status) = [curl_exec($curl), curl_getinfo($curl), curl_close($curl)];
return (intval($status["http_code"]) === 200) ? $content : false;
}
- /**
- * POST数据过滤处理
- * @param array $data
- * @return array
- */
- private static function build($data)
- {
- if (is_array($data)) {
- foreach ($data as $key => $value) {
- if (is_string($value) && class_exists('CURLFile', false) && stripos($value, '@') === 0) {
- $filename = realpath(trim($value, '@'));
- if ($filename && file_exists($filename)) {
- $data[$key] = new \CURLFile($filename);
- }
- }
- }
- }
- return $data;
- }
-
/**
* 缓存配置与存储
* @param string $name 缓存名称
diff --git a/Wechat/Contracts/Wechat.php b/Wechat/Contracts/Wechat.php
index cfc0c7b..06b9552 100644
--- a/Wechat/Contracts/Wechat.php
+++ b/Wechat/Contracts/Wechat.php
@@ -81,7 +81,7 @@ class Wechat
}
list($appid, $secret) = [$this->config->get('appid'), $this->config->get('appsecret')];
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}";
- $result = Tools::fromJson(Tools::get($url));
+ $result = Tools::json2arr(Tools::get($url));
if (!empty($result['access_token'])) {
Tools::setCache($cacheKey, $result['access_token'], 6000);
}
@@ -107,7 +107,7 @@ class Wechat
protected function httpGetForJson($url)
{
try {
- return Tools::fromJson(Tools::get($url));
+ return Tools::json2arr(Tools::get($url));
} catch (InvalidResponseException $e) {
if (!$this->isTry && in_array($e->getCode(), ['40014', '40001', '41001', '42001'])) {
$this->delAccessToken();
@@ -127,7 +127,7 @@ class Wechat
protected function httpPostForJson($url, array $data, $buildToJson = true)
{
try {
- return Tools::fromJson(Tools::post($url, $buildToJson ? Tools::toJson($data) : $data));
+ return Tools::json2arr(Tools::post($url, $buildToJson ? Tools::arr2json($data) : $data));
} catch (InvalidResponseException $e) {
if (!$this->isTry && in_array($e->getCode(), ['40014', '40001', '41001', '42001'])) {
$this->delAccessToken();
diff --git a/Wechat/Media.php b/Wechat/Media.php
index 023008b..d0a94d2 100644
--- a/Wechat/Media.php
+++ b/Wechat/Media.php
@@ -118,7 +118,7 @@ class Media extends Wechat
}
$url = "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type={$type}";
$this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['media' => Tools::createCurlFile($filename), 'description' => Tools::toJson($description)], false);
+ return $this->httpPostForJson($url, ['media' => Tools::createCurlFile($filename), 'description' => Tools::arr2json($description)], false);
}
/**
diff --git a/Wechat/Scan.php b/Wechat/Scan.php
new file mode 100644
index 0000000..9ec9a5e
--- /dev/null
+++ b/Wechat/Scan.php
@@ -0,0 +1,199 @@
+registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpGetForJson($url);
+ }
+
+ /**
+ * 创建商品
+ * @param array $data
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function addProduct(array $data)
+ {
+ $url = "https://api.weixin.qq.com/scan/product/create?access_token=ACCESS_TOKEN";
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, $data);
+ }
+
+ /**
+ * 商品发布
+ * @param string $keystandard 商品编码标准
+ * @param string $keystr 商品编码内容
+ * @param string $status 设置发布状态。on为提交审核,off为取消发布
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function modProduct($keystandard, $keystr, $status = 'on')
+ {
+ $data = ['keystandard' => $keystandard, 'keystr' => $keystr, 'status' => $status];
+ $url = "https://api.weixin.qq.com/scan/product/modstatus?access_token=ACCESS_TOKEN";
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, $data);
+ }
+
+ /**
+ * 设置测试人员白名单
+ * @param array $openids 测试人员的openid列表
+ * @param array $usernames 测试人员的微信号列表
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function setTestWhiteList($openids = [], $usernames = [])
+ {
+ $data = ['openid' => $openids, 'username' => $usernames];
+ $url = "https://api.weixin.qq.com/scan/product/modstatus?access_token=ACCESS_TOKEN";
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, $data);
+ }
+
+ /**
+ * 获取商品二维码
+ * @param string $keystandard
+ * @param string $keystr
+ * @param null|string $extinfo
+ * @param integer $qrcode_size
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function getQrc($keystandard, $keystr, $extinfo = null, $qrcode_size = 64)
+ {
+ $data = ['keystandard' => $keystandard, 'keystr' => $keystr, 'qrcode_size' => $qrcode_size];
+ is_null($extinfo) ?: $data['extinfo'] = $extinfo;
+ $url = "https://api.weixin.qq.com/scan/product/getqrcode?access_token=ACCESS_TOKEN";
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, $data);
+ }
+
+ /**
+ * 查询商品信息
+ * @param string $keystandard 商品编码标准
+ * @param string $keystr 商品编码内容
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function getProductInfo($keystandard, $keystr)
+ {
+ $url = "https://api.weixin.qq.com/scan/product/get?access_token=ACCESS_TOKEN";
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, ['keystandard' => $keystandard, 'keystr' => $keystr]);
+ }
+
+ /**
+ * 批量查询商品信息
+ * @param integer $offset 批量查询的起始位置,从0开始,包含该起始位置。
+ * @param integer $limit 批量查询的数量。
+ * @param string $status 支持按状态拉取。on为发布状态,off为未发布状态,check为审核中状态,reject为审核未通过状态,all为所有状态。
+ * @param string $keystr 支持按部分编码内容拉取。填写该参数后,可将编码内容中包含所传参数的商品信息拉出。类似关键词搜索。
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function getProductList($offset = 1, $limit = 10, $status = null, $keystr = null)
+ {
+ $data = ['offset' => $offset, 'limit' => $limit];
+ is_null($status) ?: $data['status'] = $status;
+ is_null($keystr) ?: $data['keystr'] = $keystr;
+ $url = "https://api.weixin.qq.com/scan/product/getlist?access_token=ACCESS_TOKEN";
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, $data);
+ }
+
+ /**
+ * 更新商品信息
+ * @param array $data
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function updateProduct(array $data)
+ {
+ $url = "https://api.weixin.qq.com/scan/product/update?access_token=ACCESS_TOKEN";
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, $data);
+ }
+
+ /**
+ * 清除商品信息
+ * @param string $keystandard 商品编码标准
+ * @param string $keystr 商品编码内容
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function clearProduct($keystandard, $keystr)
+ {
+ $url = "https://api.weixin.qq.com/scan/product/clear?access_token=ACCESS_TOKEN";
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, ['keystandard' => $keystandard, 'keystr' => $keystr]);
+ }
+
+ /**
+ * 检查wxticket参数
+ * @param string $ticket
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function checkTicket($ticket)
+ {
+ $url = "https://api.weixin.qq.com/scan/scanticket/check?access_token=ACCESS_TOKEN";
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, ['ticket' => $ticket]);
+ }
+
+ /**
+ * 清除扫码记录
+ * @param string $keystandard 商品编码标准
+ * @param string $keystr 商品编码内容
+ * @param string $extinfo 调用“获取商品二维码接口”时传入的extinfo,为标识参数
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function clearScanTicket($keystandard, $keystr, $extinfo)
+ {
+ $url = "https://api.weixin.qq.com/scan/scanticket/check?access_token=ACCESS_TOKEN";
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, ['keystandard' => $keystandard, 'keystr' => $keystr, 'extinfo' => $extinfo]);
+ }
+
+}
\ No newline at end of file
diff --git a/Wechat/Wifi.php b/Wechat/Wifi.php
new file mode 100644
index 0000000..a60afeb
--- /dev/null
+++ b/Wechat/Wifi.php
@@ -0,0 +1,284 @@
+registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, ['pageindex' => $pageindex, 'pagesize' => $pagesize]);
+ }
+
+ /**
+ * 查询门店Wi-Fi信息
+ * @param integer $shop_id 门店ID
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function getShopWifi($shop_id)
+ {
+ $url = 'https://api.weixin.qq.com/bizwifi/shop/list?access_token=ACCESS_TOKEN';
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, ['shop_id' => $shop_id]);
+ }
+
+ /**
+ * 修改门店网络信息
+ * @param integer $shop_id 门店ID
+ * @param string $old_ssid 旧的无线网络设备的ssid
+ * @param string $ssid 新的无线网络设备的ssid
+ * @param string $password 无线网络设备的密码(可选)
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function upShopWifi($shop_id, $old_ssid, $ssid, $password = null)
+ {
+ $data = ['shop_id' => $shop_id, 'old_ssid' => $old_ssid, 'ssid' => $ssid];
+ is_null($password) ?: $data['password'] = $password;
+ $url = 'https://api.weixin.qq.com/bizwifi/shop/update?access_token=ACCESS_TOKEN';
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, $data);
+ }
+
+ /**
+ * 清空门店网络及设备
+ * @param integer $shop_id
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function clearShopWifi($shop_id)
+ {
+ $url = 'https://api.weixin.qq.com/bizwifi/shop/clean?access_token=ACCESS_TOKEN';
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, ['shop_id' => $shop_id]);
+ }
+
+ /**
+ * 添加密码型设备
+ * @param integer $shop_id 门店ID
+ * @param string $ssid 无线网络设备的ssid
+ * @param null|string $password 无线网络设备的密码
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function addShopWifi($shop_id, $ssid, $password = null)
+ {
+ $data = ['shop_id' => $shop_id, 'ssid' => $ssid, 'password' => $password];
+ $url = 'https://api.weixin.qq.com/bizwifi/device/add?access_token=ACCESS_TOKEN';
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, $data);
+ }
+
+ /**
+ * 添加portal型设备
+ * @param integer $shop_id 门店ID
+ * @param string $ssid 无线网络设备的ssid
+ * @param bool $reset 重置secretkey,false-不重置,true-重置,默认为false
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function addShopPortal($shop_id, $ssid, $reset = false)
+ {
+ $data = ['shop_id' => $shop_id, 'ssid' => $ssid, 'reset' => $reset];
+ $url = 'https://api.weixin.qq.com/bizwifi/apportal/register?access_token=ACCESS_TOKEN';
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, $data);
+ }
+
+ /**
+ * 查询设备
+ * @param null|integer $shop_id 根据门店id查询
+ * @param null|integer $pageindex 分页下标,默认从1开始
+ * @param null|integer $pagesize 每页的个数,默认10个,最大20个
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function queryShopWifi($shop_id = null, $pageindex = null, $pagesize = null)
+ {
+ $data = [];
+ is_null($pagesize) ?: $data['pagesize'] = $pagesize;
+ is_null($pageindex) ?: $data['pageindex'] = $pageindex;
+ is_null($shop_id) ?: $data['shop_id'] = $shop_id;
+ $url = 'https://api.weixin.qq.com/bizwifi/device/list?access_token=ACCESS_TOKEN';
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, $data);
+ }
+
+ /**
+ * 删除设备
+ * @param string $bssid 需要删除的无线网络设备无线mac地址,格式冒号分隔,字符长度17个,并且字母小写,例如:00:1f:7a:ad:5c:a8
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function delShopWifi($bssid)
+ {
+ $url = 'https://api.weixin.qq.com/bizwifi/device/delete?access_token=ACCESS_TOKEN';
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, ['bssid' => $bssid]);
+ }
+
+ /**
+ * 获取物料二维码
+ * @param integer $shop_id 门店ID
+ * @param string $ssid 已添加到门店下的无线网络名称
+ * @param integer $img_id 物料样式编号:0-纯二维码,可用于自由设计宣传材料;1-二维码物料,155mm×215mm(宽×高),可直接张贴
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function getQrc($shop_id, $ssid, $img_id = 1)
+ {
+ $url = 'https://api.weixin.qq.com/bizwifi/qrcode/get?access_token=ACCESS_TOKEN';
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, ['shop_id' => $shop_id, 'ssid' => $ssid, 'img_id' => $img_id]);
+ }
+
+ /**
+ * 设置商家主页
+ * @param integer $shop_id 门店ID
+ * @param integer $template_id 模板ID,0-默认模板,1-自定义url
+ * @param null|string $url 自定义链接,当template_id为1时必填
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function setHomePage($shop_id, $template_id, $url = null)
+ {
+ $data = ['shop_id' => $shop_id, 'template_id' => $template_id];
+ is_null($url) ?: $data['struct'] = ['url' => $url];
+ $url = 'https://api.weixin.qq.com/bizwifi/homepage/set?access_token=ACCESS_TOKEN';
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, $data);
+ }
+
+ /**
+ * 查询商家主页
+ * @param integer $shop_id 查询的门店id
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function getHomePage($shop_id)
+ {
+ $url = 'https://api.weixin.qq.com/bizwifi/homepage/get?access_token=ACCESS_TOKEN';
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, ['shop_id' => $shop_id]);
+ }
+
+ /**
+ * 设置微信首页欢迎语
+ * @param integer $shop_id 门店ID
+ * @param integer $bar_type 微信首页欢迎语的文本内容:0--欢迎光临+公众号名称;1--欢迎光临+门店名称;2--已连接+公众号名称+WiFi;3--已连接+门店名称+Wi-Fi。
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function setBar($shop_id, $bar_type = 1)
+ {
+ $url = 'https://api.weixin.qq.com/bizwifi/bar/set?access_token=ACCESS_TOKEN';
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, ['shop_id' => $shop_id, 'bar_type' => $bar_type]);
+ }
+
+ /**
+ * 设置连网完成页
+ * @param integer $shop_id 门店ID
+ * @param string $finishpage_url 连网完成页URL
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function setFinishPage($shop_id, $finishpage_url)
+ {
+ $url = 'https://api.weixin.qq.com/bizwifi/finishpage/set?access_token=ACCESS_TOKEN';
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, ['shop_id' => $shop_id, 'finishpage_url' => $finishpage_url]);
+ }
+
+ /**
+ * Wi-Fi 数据统计
+ * @param string $begin_date 起始日期时间,格式yyyy-mm-dd,最长时间跨度为30天
+ * @param string $end_date 结束日期时间戳,格式yyyy-mm-dd,最长时间跨度为30天
+ * @param integer $shop_id 按门店ID搜索,-1为总统计
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function staticList($begin_date, $end_date, $shop_id = -1)
+ {
+ $url = 'https://api.weixin.qq.com/bizwifi/statistics/list?access_token=ACCESS_TOKEN';
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, ['shop_id' => $shop_id, 'begin_date' => $begin_date, 'end_date' => $end_date]);
+ }
+
+ /**
+ * 设置门店卡券投放信息
+ * @param integer $shop_id 门店ID,可设置为0,表示所有门店
+ * @param integer $card_id 卡券ID
+ * @param string $card_describe 卡券描述,不能超过18个字符
+ * @param string $start_time 卡券投放开始时间(单位是秒)
+ * @param string $end_time 卡券投放结束时间(单位是秒) 注:不能超过卡券的有效期时间
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function setCouponput($shop_id, $card_id, $card_describe, $start_time, $end_time)
+ {
+ $data = ['shop_id' => $shop_id, 'card_id' => $card_id, 'card_describe' => $card_describe, 'start_time' => $start_time, 'end_time' => $end_time];
+ $url = 'https://api.weixin.qq.com/bizwifi/couponput/set?access_token=ACCESS_TOKEN';
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, $data);
+ }
+
+ /**
+ * 查询门店卡券投放信息
+ * @param integer $shop_id 门店ID,可设置为0,表示所有门店
+ * @return array
+ * @throws Exceptions\InvalidResponseException
+ * @throws Exceptions\LocalCacheException
+ */
+ public function getCouponput($shop_id)
+ {
+ $url = 'https://api.weixin.qq.com/bizwifi/couponput/get?access_token=ACCESS_TOKEN';
+ $this->registerApi($url, __FUNCTION__, func_get_args());
+ return $this->httpPostForJson($url, ['shop_id' => $shop_id]);
+ }
+
+}
\ No newline at end of file