Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: 调整代金券文件结构 #928

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- change(internal): `AbstractProvider` 默认使用 `HttpClientFactoryInterface` 创建 http client(#921)
- change(internal): 调整 银联 插件文件夹结构(#923)
- change(internal): 替换为 `artful` API 请求框架(#926)
- change(internal): 调整微信代金券插件文件结构(#928)

## v3.5.3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @see https://pay.weixin.qq.com/docs/merchant/apis/cash-coupons/coupon/query-coupon.html
* @see https://pay.weixin.qq.com/docs/partner/apis/cash-coupons/coupon/query-coupon.html
*/
class QueryCouponDetailPlugin implements PluginInterface
class QueryDetailPlugin implements PluginInterface
{
/**
* @throws InvalidParamsException
Expand All @@ -29,7 +29,7 @@ class QueryCouponDetailPlugin implements PluginInterface
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::debug('[Wechat][V3][Marketing][Coupon][QueryCouponDetailPlugin] 插件开始装载', ['rocket' => $rocket]);
Logger::debug('[Wechat][V3][Marketing][Coupon][QueryDetailPlugin] 插件开始装载', ['rocket' => $rocket]);

$params = $rocket->getParams();
$config = get_wechat_config($params);
Expand All @@ -48,7 +48,7 @@ public function assembly(Rocket $rocket, Closure $next): Rocket
'_service_url' => 'v3/marketing/favor/users/'.$openId.'/coupons/'.$couponId.'?appid='.$appId,
]);

Logger::info('[Wechat][V3][Marketing][Coupon][QueryCouponDetailPlugin] 插件装载完毕', ['rocket' => $rocket]);
Logger::info('[Wechat][V3][Marketing][Coupon][QueryDetailPlugin] 插件装载完毕', ['rocket' => $rocket]);

return $next($rocket);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon;
namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon\Stock;

use Closure;
use Yansongda\Artful\Contract\PluginInterface;
Expand All @@ -25,7 +25,7 @@ class CreatePlugin implements PluginInterface
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::debug('[Wechat][V3][Marketing][Coupon][CreatePlugin] 插件开始装载', ['rocket' => $rocket]);
Logger::debug('[Wechat][V3][Marketing][Coupon][Stock][CreatePlugin] 插件开始装载', ['rocket' => $rocket]);

$params = $rocket->getParams();
$config = get_wechat_config($params);
Expand All @@ -38,7 +38,7 @@ public function assembly(Rocket $rocket, Closure $next): Rocket
'belong_merchant' => $belongMerchant,
]);

Logger::info('[Wechat][V3][Marketing][Coupon][CreatePlugin] 插件装载完毕', ['rocket' => $rocket]);
Logger::info('[Wechat][V3][Marketing][Coupon][Stock][CreatePlugin] 插件装载完毕', ['rocket' => $rocket]);

return $next($rocket);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon;
namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon\Stock;

use Closure;
use Yansongda\Artful\Contract\PluginInterface;
Expand All @@ -28,7 +28,7 @@ class PausePlugin implements PluginInterface
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::debug('[Wechat][V3][Marketing][Coupon][PausePlugin] 插件开始装载', ['rocket' => $rocket]);
Logger::debug('[Wechat][V3][Marketing][Coupon][Stock][PausePlugin] 插件开始装载', ['rocket' => $rocket]);

$params = $rocket->getParams();
$config = get_wechat_config($params);
Expand All @@ -47,7 +47,7 @@ public function assembly(Rocket $rocket, Closure $next): Rocket
'stock_creator_mchid' => $stockCreatorMchId,
]);

Logger::info('[Wechat][V3][Marketing][Coupon][PausePlugin] 插件装载完毕', ['rocket' => $rocket]);
Logger::info('[Wechat][V3][Marketing][Coupon][Stock][PausePlugin] 插件装载完毕', ['rocket' => $rocket]);

return $next($rocket);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon;
namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon\Stock;

use Closure;
use Yansongda\Artful\Contract\PluginInterface;
Expand All @@ -19,7 +19,7 @@
* @see https://pay.weixin.qq.com/docs/merchant/apis/cash-coupons/stock/query-stock.html
* @see https://pay.weixin.qq.com/docs/partner/apis/cash-coupons/stock/query-stock.html
*/
class QueryStockDetailPlugin implements PluginInterface
class QueryDetailPlugin implements PluginInterface
{
/**
* @throws ContainerException
Expand All @@ -28,7 +28,7 @@ class QueryStockDetailPlugin implements PluginInterface
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::debug('[Wechat][V3][Marketing][Coupon][QueryStockDetailPlugin] 插件开始装载', ['rocket' => $rocket]);
Logger::debug('[Wechat][V3][Marketing][Coupon][Stock][QueryDetailPlugin] 插件开始装载', ['rocket' => $rocket]);

$params = $rocket->getParams();
$config = get_wechat_config($params);
Expand All @@ -46,7 +46,7 @@ public function assembly(Rocket $rocket, Closure $next): Rocket
'_service_url' => 'v3/marketing/favor/stocks/'.$stockId.'?stock_creator_mchid='.$mchId,
]);

Logger::info('[Wechat][V3][Marketing][Coupon][QueryStockDetailPlugin] 插件装载完毕', ['rocket' => $rocket]);
Logger::info('[Wechat][V3][Marketing][Coupon][Stock][QueryDetailPlugin] 插件装载完毕', ['rocket' => $rocket]);

return $next($rocket);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon;
namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon\Stock;

use Closure;
use Yansongda\Artful\Contract\PluginInterface;
Expand All @@ -20,7 +20,7 @@
* @see https://pay.weixin.qq.com/docs/merchant/apis/cash-coupons/stock/list-available-singleitems.html
* @see https://pay.weixin.qq.com/docs/partner/apis/cash-coupons/stock/list-available-singleitems.html
*/
class QueryStockItemsPlugin implements PluginInterface
class QueryItemsPlugin implements PluginInterface
{
/**
* @throws ContainerException
Expand All @@ -29,7 +29,7 @@ class QueryStockItemsPlugin implements PluginInterface
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::debug('[Wechat][V3][Marketing][Coupon][QueryStockItemsPlugin] 插件开始装载', ['rocket' => $rocket]);
Logger::debug('[Wechat][V3][Marketing][Coupon][Stock][QueryItemsPlugin] 插件开始装载', ['rocket' => $rocket]);

$params = $rocket->getParams();
$config = get_wechat_config($params);
Expand All @@ -46,7 +46,7 @@ public function assembly(Rocket $rocket, Closure $next): Rocket
'_service_url' => 'v3/marketing/favor/stocks/'.$stockId.'/items?'.$this->normal($payload, $config),
]);

Logger::info('[Wechat][V3][Marketing][Coupon][QueryStockItemsPlugin] 插件装载完毕', ['rocket' => $rocket]);
Logger::info('[Wechat][V3][Marketing][Coupon][Stock][QueryItemsPlugin] 插件装载完毕', ['rocket' => $rocket]);

return $next($rocket);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon;
namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon\Stock;

use Closure;
use Yansongda\Artful\Contract\PluginInterface;
Expand All @@ -20,7 +20,7 @@
* @see https://pay.weixin.qq.com/docs/merchant/apis/cash-coupons/stock/list-available-merchants.html
* @see https://pay.weixin.qq.com/docs/partner/apis/cash-coupons/stock/list-available-merchants.html
*/
class QueryStockMerchantsPlugin implements PluginInterface
class QueryMerchantsPlugin implements PluginInterface
{
/**
* @throws ContainerException
Expand All @@ -29,7 +29,7 @@ class QueryStockMerchantsPlugin implements PluginInterface
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::debug('[Wechat][V3][Marketing][Coupon][QueryStockMerchantsPlugin] 插件开始装载', ['rocket' => $rocket]);
Logger::debug('[Wechat][V3][Marketing][Coupon][Stock][QueryMerchantsPlugin] 插件开始装载', ['rocket' => $rocket]);

$params = $rocket->getParams();
$config = get_wechat_config($params);
Expand All @@ -46,7 +46,7 @@ public function assembly(Rocket $rocket, Closure $next): Rocket
'_service_url' => 'v3/marketing/favor/stocks/'.$stockId.'/merchants?'.$this->normal($payload, $config),
]);

Logger::info('[Wechat][V3][Marketing][Coupon][QueryStockMerchantsPlugin] 插件装载完毕', ['rocket' => $rocket]);
Logger::info('[Wechat][V3][Marketing][Coupon][Stock][QueryMerchantsPlugin] 插件装载完毕', ['rocket' => $rocket]);

return $next($rocket);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon;
namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon\Stock;

use Closure;
use Yansongda\Artful\Contract\PluginInterface;
Expand All @@ -20,7 +20,7 @@
* @see https://pay.weixin.qq.com/docs/merchant/apis/cash-coupons/stock/list-stocks.html
* @see https://pay.weixin.qq.com/docs/partner/apis/cash-coupons/stock/list-stocks.html
*/
class QueryStocksPlugin implements PluginInterface
class QueryPlugin implements PluginInterface
{
/**
* @throws ContainerException
Expand All @@ -29,7 +29,7 @@ class QueryStocksPlugin implements PluginInterface
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::debug('[Wechat][V3][Marketing][Coupon][QueryStocksPlugin] 插件开始装载', ['rocket' => $rocket]);
Logger::debug('[Wechat][V3][Marketing][Coupon][Stock][QueryPlugin] 插件开始装载', ['rocket' => $rocket]);

$params = $rocket->getParams();
$config = get_wechat_config($params);
Expand All @@ -45,7 +45,7 @@ public function assembly(Rocket $rocket, Closure $next): Rocket
'_service_url' => 'v3/marketing/favor/stocks?'.$this->normal($payload, $config),
]);

Logger::info('[Wechat][V3][Marketing][Coupon][QueryStocksPlugin] 插件装载完毕', ['rocket' => $rocket]);
Logger::info('[Wechat][V3][Marketing][Coupon][Stock][QueryPlugin] 插件装载完毕', ['rocket' => $rocket]);

return $next($rocket);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon;
namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon\Stock;

use Closure;
use Yansongda\Artful\Contract\PluginInterface;
Expand All @@ -15,14 +15,14 @@
* @see https://pay.weixin.qq.com/docs/merchant/apis/cash-coupons/stock/refund-flow.html
* @see https://pay.weixin.qq.com/docs/partner/apis/cash-coupons/stock/refund-flow.html
*/
class QueryStockRefundFlowPlugin implements PluginInterface
class QueryRefundFlowPlugin implements PluginInterface
{
/**
* @throws InvalidParamsException
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::debug('[Wechat][V3][Marketing][Coupon][QueryStockRefundFlowPlugin] 插件开始装载', ['rocket' => $rocket]);
Logger::debug('[Wechat][V3][Marketing][Coupon][Stock][QueryRefundFlowPlugin] 插件开始装载', ['rocket' => $rocket]);

$stockId = $rocket->getPayload()?->get('stock_id') ?? null;

Expand All @@ -36,7 +36,7 @@ public function assembly(Rocket $rocket, Closure $next): Rocket
'_service_url' => 'v3/marketing/favor/stocks/'.$stockId.'/refund-flow',
]);

Logger::info('[Wechat][V3][Marketing][Coupon][QueryStockRefundFlowPlugin] 插件装载完毕', ['rocket' => $rocket]);
Logger::info('[Wechat][V3][Marketing][Coupon][Stock][QueryRefundFlowPlugin] 插件装载完毕', ['rocket' => $rocket]);

return $next($rocket);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon;
namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon\Stock;

use Closure;
use Yansongda\Artful\Contract\PluginInterface;
Expand All @@ -15,14 +15,14 @@
* @see https://pay.weixin.qq.com/docs/merchant/apis/cash-coupons/stock/use-flow.html
* @see https://pay.weixin.qq.com/docs/partner/apis/cash-coupons/stock/use-flow.html
*/
class QueryStockUseFlowPlugin implements PluginInterface
class QueryUseFlowPlugin implements PluginInterface
{
/**
* @throws InvalidParamsException
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::debug('[Wechat][V3][Marketing][Coupon][QueryStockUseFlowPlugin] 插件开始装载', ['rocket' => $rocket]);
Logger::debug('[Wechat][V3][Marketing][Coupon][Stock][QueryUseFlowPlugin] 插件开始装载', ['rocket' => $rocket]);

$stockId = $rocket->getPayload()?->get('stock_id') ?? null;

Expand All @@ -36,7 +36,7 @@ public function assembly(Rocket $rocket, Closure $next): Rocket
'_service_url' => 'v3/marketing/favor/stocks/'.$stockId.'/use-flow',
]);

Logger::info('[Wechat][V3][Marketing][Coupon][QueryStockUseFlowPlugin] 插件装载完毕', ['rocket' => $rocket]);
Logger::info('[Wechat][V3][Marketing][Coupon][Stock][QueryUseFlowPlugin] 插件装载完毕', ['rocket' => $rocket]);

return $next($rocket);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon;
namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon\Stock;

use Closure;
use Yansongda\Artful\Contract\PluginInterface;
Expand All @@ -28,7 +28,7 @@ class RestartPlugin implements PluginInterface
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::debug('[Wechat][V3][Marketing][Coupon][RestartPlugin] 插件开始装载', ['rocket' => $rocket]);
Logger::debug('[Wechat][V3][Marketing][Coupon][Stock][RestartPlugin] 插件开始装载', ['rocket' => $rocket]);

$params = $rocket->getParams();
$config = get_wechat_config($params);
Expand All @@ -47,7 +47,7 @@ public function assembly(Rocket $rocket, Closure $next): Rocket
'stock_creator_mchid' => $stockCreatorMchId,
]);

Logger::info('[Wechat][V3][Marketing][Coupon][RestartPlugin] 插件装载完毕', ['rocket' => $rocket]);
Logger::info('[Wechat][V3][Marketing][Coupon][Stock][RestartPlugin] 插件装载完毕', ['rocket' => $rocket]);

return $next($rocket);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon;
namespace Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon\Stock;

use Closure;
use Yansongda\Artful\Contract\PluginInterface;
Expand All @@ -28,7 +28,7 @@ class StartPlugin implements PluginInterface
*/
public function assembly(Rocket $rocket, Closure $next): Rocket
{
Logger::debug('[Wechat][V3][Marketing][Coupon][StartPlugin] 插件开始装载', ['rocket' => $rocket]);
Logger::debug('[Wechat][V3][Marketing][Coupon][Stock][StartPlugin] 插件开始装载', ['rocket' => $rocket]);

$params = $rocket->getParams();
$config = get_wechat_config($params);
Expand All @@ -46,7 +46,7 @@ public function assembly(Rocket $rocket, Closure $next): Rocket
'stock_creator_mchid' => $payload->get('stock_creator_mchid') ?? $config['mch_id'] ?? '',
]);

Logger::info('[Wechat][V3][Marketing][Coupon][StartPlugin] 插件装载完毕', ['rocket' => $rocket]);
Logger::info('[Wechat][V3][Marketing][Coupon][Stock][StartPlugin] 插件装载完毕', ['rocket' => $rocket]);

return $next($rocket);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

use Yansongda\Pay\Exception\Exception;
use Yansongda\Artful\Exception\InvalidParamsException;
use Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon\QueryCouponDetailPlugin;
use Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon\QueryDetailPlugin;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Tests\TestCase;
use Yansongda\Supports\Collection;

class QueryCouponDetailPluginTest extends TestCase
class QueryDetailPluginTest extends TestCase
{
protected QueryCouponDetailPlugin $plugin;
protected QueryDetailPlugin $plugin;

protected function setUp(): void
{
parent::setUp();

$this->plugin = new QueryCouponDetailPlugin();
$this->plugin = new QueryDetailPlugin();
}

public function testEmptyPayload()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Yansongda\Pay\Tests\Plugin\Wechat\V3\Marketing\Coupon;
namespace Yansongda\Pay\Tests\Plugin\Wechat\V3\Marketing\Coupon\Stock;

use Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon\CreatePlugin;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Plugin\Wechat\V3\Marketing\Coupon\Stock\CreatePlugin;
use Yansongda\Pay\Tests\TestCase;
use Yansongda\Supports\Collection;

Expand Down
Loading