Compare commits

...

9 Commits

Author SHA1 Message Date
邹景立
8a11271805 fix: 增加微信V3券卡管理 2024-08-19 12:42:08 +08:00
邹景立
d422e5dc17 fix: 完善小程序 Live 接口 2024-08-18 22:32:01 +08:00
邹景立
e750ac9cd2 fix: 修正微信V3提现接口参数处理 2024-08-05 21:32:30 +08:00
邹景立
8c84c053d3 fix: 修改兼容文件加载配置 2024-08-05 20:20:35 +08:00
邹景立
28de3a64cd fix: 增加 array_column 兼容函数 2024-08-04 23:09:55 +08:00
邹景立
65c3dca0fd fix: 降低 PHP 版本限制为 5.4 2024-08-04 23:09:34 +08:00
邹景立
868d6dcb7f fix: 限定最低 php 版本为 5.5 2024-08-04 23:02:08 +08:00
邹景立
c102bfa331 fix: 微信 V3 提现增加自动统计金额 2024-08-04 23:01:24 +08:00
邹景立
d05f53e548 fix: 增加 GithubActions 配置脚本 2024-08-04 23:01:00 +08:00
7 changed files with 558 additions and 3 deletions

65
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,65 @@
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Create Release
permissions: write-all
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies
run: npm install -g gen-git-log
- name: Find Last Tag
id: last_tag
run: |
# 获取所有标签,按版本排序(降序)
Tags=$(git tag --list --sort=-version:refname)
# 获取最新的标签(即列表中的第一个)
LATEST_TAG=$(echo "$Tags" | awk 'NR==1 {print $1; exit}')
# 获取倒数第二个标签(如果存在)
if [[ -n "$Tags" ]]; then
# 使用 tail 获取除了最后一个标签之外的所有标签,然后用 head 获取第一个
SECOND_LATEST_TAG=$(echo "$Tags" | tail -n +2 | head -n 1)
else
SECOND_LATEST_TAG=""
fi
# 设置输出变量
echo "::set-output name=tag_last::${LATEST_TAG:-v1.0.0}"
echo "::set-output name=tag_second::${SECOND_LATEST_TAG:-v1.0.0}"
- name: Generate Release Notes
run: |
rm -rf log
newTag=${{ steps.last_tag.outputs.tag_last }}
git-log -m tag -f -S ${{ steps.last_tag.outputs.tag_second }} -v ${newTag#v}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.last_tag.outputs.tag_last }}
release_name: Release ${{ steps.last_tag.outputs.tag_last }}
body_path: log/${{steps.last_tag.outputs.tag_last}}.md
draft: false
prerelease: false

View File

@ -168,4 +168,303 @@ class Live extends BasicWeChat
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/getapproved?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 删除直播间
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function delLive($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/deleteroom?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 编辑直播间
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function editLive($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/editroom?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 获取直播间推流地址
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function getPushUrl($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/getpushurl?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 获取直播间分享二维码
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function getShareCode($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/getsharedcode?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 添加管理直播间小助手
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function addAssistant($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/addassistant?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 修改管理直播间小助手
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function modifyAssistant($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/modifyassistant?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 删除管理直播间小助手
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function removeAssistant($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/removeassistant?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 查询管理直播间小助手
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function getAssistantList($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/getassistantlist?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 添加主播副号
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function addSubAnchor($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/addsubanchor?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 修改主播副号
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function modifySubAnchor($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/modifysubanchor?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 修删除主播副号
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function delSubAnchor($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/deletesubanchor?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 查询除主播副号
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function getSubAnchor($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/getsubanchor?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 开启/关闭直播间官方收录
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function updateFeedPublic($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/updatefeedpublic?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 开启/关闭回放功能
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function updateReplay($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/updatereplay?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 开启/关闭客服功能
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function updateKf($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/updatekf?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 开启/关闭直播间全局禁言
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function updateComment($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/updatecomment?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 上下架商品
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function goodsOnsale($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/onsale?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 删除直播间商品
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function goodsDeleteInRoom($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/deleteInRoom?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 推送商品
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function goodsPush($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/push?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 商品排序
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function goodsSort($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/sort?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 下载商品讲解视频
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function getVideo($data)
{
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/getVideo?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 获取长期订阅用户
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function getFollowers($data)
{
$url = "https://api.weixin.qq.com/wxa/business/get_wxa_followers?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
/**
* 长期订阅群发接口
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function pushMessage($data)
{
$url = "https://api.weixin.qq.com/wxa/business/push_message?access_token=ACCESS_TOKEN";
return $this->callPostApi($url, $data, true);
}
}

158
WePayV3/Coupon.php Normal file
View File

@ -0,0 +1,158 @@
<?php
// +----------------------------------------------------------------------
// | WeChatDeveloper
// +----------------------------------------------------------------------
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
// +----------------------------------------------------------------------
// | 官方网站: https://thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// | 免责声明 ( https://thinkadmin.top/disclaimer )
// +----------------------------------------------------------------------
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
// +----------------------------------------------------------------------
namespace WePayV3;
use WeChat\Exceptions\InvalidResponseException;
use WePayV3\Contracts\BasicWePay;
/**
* 微信支付代金券
* @class Coupon
* @package WePayV3
*/
class Coupon extends BasicWePay
{
/**
* 创建代金券批次
* @param array $data
* @return array|string
* @throws InvalidResponseException
*/
public function stocksCreate(array $data)
{
$path = "/v3/marketing/favor/coupon-stocks";
return $this->doRequest('POST', $path, json_encode($data), true);
}
/**
* 激活代金券批次
* @param string $stock_id 批次号
* @param string $stock_creator_mchid 创建批次的商户号
* @return array|string
* @throws InvalidResponseException
*/
public function stocksStart(string $stock_id , string $stock_creator_mchid)
{
$path = "/v3/marketing/favor/stocks/{$stock_id}/start";
return $this->doRequest('POST', $path, json_encode(['stock_creator_mchid' => $stock_creator_mchid]), true);
}
/**
* 暂停代金券批次
* @param string $stock_id 批次号
* @param string $stock_creator_mchid 创建批次的商户号
* @return array|string
* @throws InvalidResponseException
*/
public function stocksPause(string $stock_id , string $stock_creator_mchid)
{
$path = "/v3/marketing/favor/stocks/{$stock_id}/pause";
return $this->doRequest('POST', $path, json_encode(['stock_creator_mchid' => $stock_creator_mchid]), true);
}
/**
* 重启代金券批次
* @param string $stock_id 批次号
* @param string $stock_creator_mchid 创建批次的商户号
* @return array|string
* @throws InvalidResponseException
*/
public function stocksRestart(string $stock_id , string $stock_creator_mchid)
{
$path = "/v3/marketing/favor/stocks/{$stock_id}/restart";
return $this->doRequest('POST', $path, json_encode(['stock_creator_mchid' => $stock_creator_mchid]), true);
}
/**
* 查询批次详情
* @param string $stock_id 批次号
* @param string $stock_creator_mchid 创建批次的商户号
* @return array|string
* @throws InvalidResponseException
*/
public function stocksDetail(string $stock_id , string $stock_creator_mchid)
{
$path = "/v3/marketing/favor/stocks/{$stock_id}?stock_creator_mchid={$stock_creator_mchid}";
return $this->doRequest('GET', $path, '', true);
}
/**
* 代金券批次可用商品
* @param array $param
* @return array|string
* @throws InvalidResponseException
*/
public function stocksItems(array $param)
{
$path = "/v3/marketing/favor/stocks/{$param['stock_id']}/items ";
return $this->doRequest('POST', $path, json_encode($param), true);
}
/**
* 设置消息通知地址
* @param array $param
* @return array|string
* @throws InvalidResponseException
*/
public function setCallbacks(array $param)
{
$path = "/v3/marketing/favor/callbacks";
return $this->doRequest('POST', $path, json_encode($param), true);
}
/**
* 发放代金券批次
* @param array $param 请求参数
* @return array|string
* @throws InvalidResponseException
*/
public function couponsSend( array $param)
{
$path = "/v3/marketing/favor/users/{$param['openid']}/coupons";
return $this->doRequest('POST', $path, json_encode($param), true);
}
/**
* 根据商户号查用户的券
* @param array $param 请求参数
* @return array|string
* @throws InvalidResponseException
*/
public function couponsList(array $param)
{
$path = "/v3/marketing/favor/users/{$param['openid']}/coupons";
return $this->doRequest('POST', $path, json_encode($param), true);
}
/**
* 查询代金券详情
* @param string $openid 用户openid
* @param string $coupon_id 代金券id
* @param string $appid 公众账号ID
* @return array|string
* @throws InvalidResponseException
*/
public function couponsDetail( string $openid , string $coupon_id , string $appid)
{
$path = "/v3/marketing/favor/users/{$openid}/coupons/{$coupon_id}?appid={$appid}";
return $this->doRequest('GET', $path,'', true);
}
}

View File

@ -42,9 +42,12 @@ class Transfers extends BasicWePay
foreach ($body['transfer_detail_list'] as &$item) if (isset($item['user_name'])) {
$item['user_name'] = $this->rsaEncode($item['user_name']);
}
}
if (empty($body['total_num'])) {
$body['total_num'] = count($body['transfer_detail_list']);
if (empty($body['total_num'])) {
$body['total_num'] = count($body['transfer_detail_list']);
}
if (empty($body['total_amount'])) {
$body['total_amount'] = array_sum(array_column($body['transfer_detail_list'], 'transfer_amount'));
}
}
return $this->doRequest('POST', '/v3/transfer/batches', json_encode($body, JSON_UNESCAPED_UNICODE), true);
}

View File

@ -30,6 +30,9 @@
"ext-simplexml": "*"
},
"autoload": {
"files": [
"helper.php"
],
"classmap": [
"We.php"
],

25
helper.php Normal file
View File

@ -0,0 +1,25 @@
<?php
if (!function_exists('array_column')) {
/**
* PHP 版本兼容函数
* @param $input
* @param $columnKey
* @param $indexKey
* @return array
*/
function array_column($input, $columnKey, $indexKey = null)
{
$result = array();
foreach ($input as $row) {
if (isset($row[$columnKey])) {
if ($indexKey !== null && isset($row[$indexKey])) {
$result[$row[$indexKey]] = $row[$columnKey];
} else {
$result[] = $row[$columnKey];
}
}
}
return $result;
}
}

View File

@ -14,6 +14,8 @@
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
// +----------------------------------------------------------------------
include_once __DIR__ . '/helper.php';
spl_autoload_register(function ($classname) {
$pathname = __DIR__ . DIRECTORY_SEPARATOR;
$filename = str_replace('\\', DIRECTORY_SEPARATOR, $classname) . '.php';