初始化项目:添加后端代码、ThinkPHP框架、前端资源

This commit is contained in:
amb
2026-09-03 12:42:39 +08:00
commit 482bece22e
3726 changed files with 416708 additions and 0 deletions
@@ -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);
}
}
@@ -0,0 +1,37 @@
<?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 Pimple\Container;
use Pimple\ServiceProviderInterface;
/**
* Class ServiceProvider.
*
* @author mingyoung <mingyoungcheung@gmail.com>
*/
class ServiceProvider implements ServiceProviderInterface
{
/**
* {@inheritdoc}.
*/
public function register(Container $app)
{
$app['product'] = function ($app) {
return new Client($app);
};
$app['stock'] = function ($app) {
return new StockClient($app);
};
}
}
@@ -0,0 +1,130 @@
<?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 StockClient extends BaseClient
{
/**
* 获取库存流水
* 通过该接口可以获取视频号小店的商品库存流水
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
*
* @param $product_id string(uint64) 是 内部商品ID
* @param $sku_id string(uint64) 是 内部sku_id
* @param $stock_type number 是 库存类型,参考StockType枚举值 0 自营库存;1 达人库存
* @param $finder_id string 否 达人的视频号finder_id,若StockType=1则必填
* @param $begin_time number 是 时间范围开始时间戳,秒级
* @param $end_time number 是 时间范围结束时间戳,秒级
* @param $op_type_list array[number] 否 库存事件类型,参考StockFlowOpType枚举值,填空获取全部
* @param $page_size number 是 每页数量
* @param $next_key string 否 由上次请求返回,记录翻页的上下文。传入时会从上次返回的结果往后翻一页,不传默认获取第一页数据。
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function getflow($product_id,$sku_id,$stock_type,$finder_id,$begin_time,$end_time,$op_type_list,$page_size,$next_key)
{
$params = [
'product_id' => $product_id,
'sku_id' => $sku_id,
'stock_type' => $stock_type,
'finder_id' => $finder_id,
'begin_time' => $begin_time,
'end_time' => $end_time,
'op_type_list' => $op_type_list,
'page_size' => $page_size,
'next_key' => $next_key
];
if($next_key){
$params['next_key'] = $next_key;
}
if($finder_id){
$params['finder_id'] = $finder_id;
}
return $this->httpPostJson('channels/ec/product/stock/getflow', $params);
}
/**
* 批量获取库存信息
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
*
* @param $product_id[] string(uint64) array 是 商品ID列表,上限为50
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function batchget($product_id)
{
$params = [
'product_id' => $product_id
];
return $this->httpPostJson('channels/ec/product/stock/batchget', $params);
}
/**
* 快速更新库存
* 可通过该接口快速更新视频号小店商品的库存
* 仅对商品草稿状态为非审核中(edit_status != 2 )的商品适用,本地生活商品不受此规则约束
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
* @param $product_id string(uint64) 是 内部商品ID
* @param $sku_id string(uint64) 是 内部sku_id
* @param $diff_type number 是 修改类型。1: 增加;2:减少;3:设置。建议使用1或2,不建议使用3,因为使用3在高并发场景可能会出现预期外表现
* @param $num number 是 增加、减少或者设置的库存值。
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function updateStock($product_id,$sku_id,$diff_type,$num)
{
$params = [
'product_id' => $product_id,
'sku_id' => $sku_id,
'diff_type' => intval($diff_type),
'num' => intval($num)
];
return $this->httpPostJson('channels/ec/product/stock/update', $params);
}
/**
* 获取库存
* 通过该接口可以获取视频号小店的商品库存信息
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
* @param $product_id string(uint64) 是 内部商品ID
* @param $sku_id string(uint64) 是 内部sku_id
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function getStock($product_id,$sku_id)
{
$params = [
'product_id' => $product_id,
'sku_id' => $sku_id
];
return $this->httpPostJson('channels/ec/product/stock/get', $params);
}
}