<?php
namespace app\common\library\wechat\wow;
use app\common\library\wechat\WxBase;
class Shoping extends WxBase
{
public function addList($openId, $productList)
{
$accessToken = $this->getAccessToken();
$url = "https://api.weixin.qq.com/mall/addshoppinglist?access_token={$accessToken}";
$params = $this->jsonEncode([
'user_open_id' => $openId,
'sku_product_list' => $productList
]);
$result = $this->post($url, $params);
$this->doLogs(['describe' => '新增好物圈商品收藏', 'url' => $url, 'params' => $params, 'result' => $result]);
$response = $this->jsonDecode($result);
if (!isset($response['errcode'])) {
$this->error = 'not found errcode';
return false;
}
if ($response['errcode'] != 0) {
$this->error = $response['errmsg'];
return false;
}
return true;
}
public function delete($openId, $productList)
{
$accessToken = $this->getAccessToken();
$url = "https://api.weixin.qq.com/mall/deleteshoppinglist?access_token={$accessToken}";
$params = [
'user_open_id' => $openId,
'sku_product_list' => $productList
];
$result = $this->post($url, $this->jsonEncode($params));
$this->doLogs(['describe' => '删除好物圈商品收藏', 'url' => $url, 'params' => $params, 'result' => $result]);
$response = $this->jsonDecode($result);
if (!isset($response['errcode'])) {
$this->error = 'not found errcode';
return false;
}
if ($response['errcode'] != 0) {
$this->error = $response['errmsg'];
return false;
}
return true;
}
}