初始化项目:添加后端代码、ThinkPHP框架、前端资源
This commit is contained in:
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace TuzhiEasyWeChat\Channels\Product;
|
||||
|
||||
use TuzhiEasyWeChat\Kernel\BaseClient;
|
||||
use TuzhiEasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 获取商品列表
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
*
|
||||
* @param $status 商品状态,不填默认拉全部商品(不包含回收站),具体枚举值请参考
|
||||
* @param $pageSize 每页数量(默认10,不超过30)
|
||||
* @param $nextKey 由上次请求返回,记录翻页的上下文。传入时会从上次返回的结果往后翻一页,不传默认获取第一页数据。
|
||||
*
|
||||
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getList($pageSize=10,$nextKey = '',$status = '')
|
||||
{
|
||||
$params = [
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
|
||||
if($nextKey){
|
||||
$params['next_key'] = $nextKey;
|
||||
}
|
||||
|
||||
if($nextKey){
|
||||
$params['status'] = $status;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('channels/ec/product/list/get', $params);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 添加商品
|
||||
* 通过该接口可对商品添加进视频号小店
|
||||
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
* @param $product_id 商品ID
|
||||
*
|
||||
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function add($params)
|
||||
{
|
||||
return $this->httpPostJson('channels/ec/product/add', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品
|
||||
* 该接口用于对视频号小店内商品信息的更新
|
||||
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
* @param $product_id 商品ID
|
||||
*
|
||||
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update($params)
|
||||
{
|
||||
return $this->httpPostJson('channels/ec/product/update', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
* 可通过该接口删除视频号小店商品(审核中的商品无法删除)
|
||||
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
* @param $product_id 商品ID
|
||||
*
|
||||
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function del($product_id)
|
||||
{
|
||||
$params = [
|
||||
'product_id' => $product_id
|
||||
];
|
||||
|
||||
return $this->httpPostJson('channels/ec/product/delete', $params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取商品
|
||||
* 可通过指定商品ID获取商品具体信息
|
||||
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
* @param $product_id 商品ID
|
||||
* @data_type 默认取1
|
||||
1:获取线上数据
|
||||
2:获取草稿数据
|
||||
3:同时获取线上和草稿数据(注意:上架过的商品才有线上数据)
|
||||
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function detail($product_id,$data_type=1)
|
||||
{
|
||||
$params = [
|
||||
'product_id' => $product_id,
|
||||
'data_type'=>$data_type
|
||||
];
|
||||
|
||||
return $this->httpPostJson('channels/ec/product/get', $params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上架商品
|
||||
* 通过该接口可将商品上架到视频号小店
|
||||
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
* @param $product_id 商品ID
|
||||
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function listing($product_id)
|
||||
{
|
||||
$params = [
|
||||
'product_id' => $product_id
|
||||
];
|
||||
|
||||
return $this->httpPostJson('channels/ec/product/listing', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下架商品
|
||||
* 可通过该接口将商品从视频号小店下架
|
||||
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
* @param $product_id 商品ID
|
||||
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delisting($product_id)
|
||||
{
|
||||
$params = [
|
||||
'product_id' => $product_id
|
||||
];
|
||||
|
||||
return $this->httpPostJson('channels/ec/product/delisting', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下架商撤回商品审核
|
||||
* 该接口用于撤销视频号小店商品审核申请,将商品状态从审核中改为未审核
|
||||
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
* @param $product_id 商品ID
|
||||
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function cancel($product_id)
|
||||
{
|
||||
$params = [
|
||||
'product_id' => $product_id
|
||||
];
|
||||
|
||||
return $this->httpPostJson('channels/ec/product/audit/cancel', $params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取商品二维码
|
||||
* 通过该接口可以获取视频号小店的商品二维码
|
||||
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
* @param $product_id 商品ID
|
||||
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getqrcode($product_id)
|
||||
{
|
||||
$params = [
|
||||
'product_id' => $product_id
|
||||
];
|
||||
|
||||
return $this->httpPostJson('channels/ec/product/qrcode/get', $params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取商品口令
|
||||
* 通过该接口可以获取视频号小店的商品微信口令
|
||||
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
* @param $product_id 商品ID
|
||||
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getTaglink($product_id)
|
||||
{
|
||||
$params = [
|
||||
'product_id' => $product_id
|
||||
];
|
||||
|
||||
return $this->httpPostJson('channels/ec/product/taglink/get', $params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取商品H5短链
|
||||
* 通过该接口可以获取视频号小店的商品H5短链
|
||||
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
* @param $product_id 商品ID
|
||||
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getH5url($product_id)
|
||||
{
|
||||
$params = [
|
||||
'product_id' => $product_id
|
||||
];
|
||||
|
||||
return $this->httpPostJson('channels/ec/product/h5url/get', $params);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user