diff --git a/src/MiniProgram/Application.php b/src/MiniProgram/Application.php index d012c2b7e..d751dd7c6 100644 --- a/src/MiniProgram/Application.php +++ b/src/MiniProgram/Application.php @@ -105,6 +105,8 @@ class Application extends ServiceContainer Shop\Delivery\ServiceProvider::class, Shop\Aftersale\ServiceProvider::class, Business\ServiceProvider::class, + + Shipping\ServiceProvider::class, ]; /** diff --git a/src/MiniProgram/Base/Client.php b/src/MiniProgram/Base/Client.php index 3d1e89662..5fec7f3db 100644 --- a/src/MiniProgram/Base/Client.php +++ b/src/MiniProgram/Base/Client.php @@ -35,7 +35,7 @@ public function getPaidUnionid($openid, $options = []) { return $this->httpGet('wxa/getpaidunionid', compact('openid') + $options); } - + /** * Get version info * diff --git a/src/MiniProgram/Shipping/Client.php b/src/MiniProgram/Shipping/Client.php new file mode 100644 index 000000000..983b4e277 --- /dev/null +++ b/src/MiniProgram/Shipping/Client.php @@ -0,0 +1,140 @@ +httpPostJson('wxa/sec/order/upload_shipping_info', $params); + } + + /** + * 发货信息合单录入接口 + * + * @param array $params + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function uploadCombineShippingInfo(array $params) + { + return $this->httpPostJson('wxa/sec/order/upload_combined_shipping_info', $params); + } + + + /** + * 查询订单发货状态 + * + * @param array $params + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getOrder(array $params) + { + return $this->httpPostJson('wxa/sec/order/get_order', $params); + } + + /** + * 查询订单列表 + * + * @param array $params + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getOrderList(array $params = []) + { + return $this->httpPostJson('wxa/sec/order/get_order_list', $params); + } + + /** + * 确认收货提醒接口 + * + * @param array $params + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function notifyConfirmReceive(array $params) + { + return $this->httpPostJson('wxa/sec/order/notify_confirm_receive', $params); + } + + /** + * 消息跳转路径设置接口 + * + * @param string $path + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function setMsgJumpPath(string $path) + { + $params = [ + 'path' => $path + ]; + + return $this->httpPostJson('wxa/sec/order/set_msg_jump_path', $params); + } + + /** + * 查询小程查询小程序是否已开通发货信息管理服务 + * + * @param string $appID + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function isTradeManaged(string $appID = '') + { + $params = [ + 'appid' => empty($appID) ? $this->app['config']['app_id'] : $appID + ]; + + return $this->httpPostJson('wxa/sec/order/is_trade_managed', $params); + } + + /** + * 查询小程序是否已完成交易结算管理确认 + * + * @param string $appID + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function isTradeCompleted(string $appID = '') + { + $params = [ + 'appid' => empty($appID) ? $this->app['config']['app_id'] : $appID + ]; + + return $this->httpPostJson('wxa/sec/order/is_trade_management_confirmation_completed', $params); + } +} diff --git a/src/MiniProgram/Shipping/ServiceProvider.php b/src/MiniProgram/Shipping/ServiceProvider.php new file mode 100644 index 000000000..2f7e26b20 --- /dev/null +++ b/src/MiniProgram/Shipping/ServiceProvider.php @@ -0,0 +1,16 @@ + */ class Client extends BaseClient { - /** * 获取盘专业版信息 - * + * * @param string $userid * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/95856#%E8%8E%B7%E5%8F%96%E7%9B%98%E4%B8%93%E4%B8%9A%E7%89%88%E4%BF%A1%E6%81%AF */ public function proInfo($userid) @@ -44,7 +43,7 @@ public function proInfo($userid) * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/95856#%E8%8E%B7%E5%8F%96%E7%9B%98%E5%AE%B9%E9%87%8F%E4%BF%A1%E6%81%AF */ public function capacity() diff --git a/src/Work/Wedrive/FileClient.php b/src/Work/Wedrive/FileClient.php index 965fb5875..54ed21a4d 100644 --- a/src/Work/Wedrive/FileClient.php +++ b/src/Work/Wedrive/FileClient.php @@ -17,7 +17,7 @@ /** * Class FileClient - * + * * @author lio990527 */ class FileClient extends BaseClient @@ -30,12 +30,12 @@ class FileClient extends BaseClient * @param string $fatherid 父目录fileid, 在根目录时为空间spaceid * @param int $fileType 文件类型, 1:文件夹 3:文档(文档) 4:文档(表格) 6:文档(幻灯片) * @param string $fileName 文件名字 - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93657#%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6%E6%96%87%E6%A1%A3 */ public function create($userid, $spaceid, $fatherid, $fileType, $fileName) @@ -57,12 +57,12 @@ public function create($userid, $spaceid, $fatherid, $fileType, $fileName) * @param string $userid 操作人userid * @param string $fileid 文件id * @param string $name 新文件名 - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93657#%E9%87%8D%E5%91%BD%E5%90%8D%E6%96%87%E4%BB%B6 */ public function rename($userid, $fileid, $name) @@ -79,16 +79,16 @@ public function rename($userid, $fileid, $name) /** * 移动文件 * - * @param string $userid + * @param string $userid * @param string|array $fileid 文件fileid * @param string $fatherid 目标目录的fileid * @param boolean $replace 重名时,是否覆盖 false:重名文件进行冲突重命名处理(移动后文件名格式如xxx(1).txt xxx(1).doc等) - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93657#%E7%A7%BB%E5%8A%A8%E6%96%87%E4%BB%B6 */ public function move($userid, $fileid, $fatherid, $replace = false) @@ -103,12 +103,12 @@ public function move($userid, $fileid, $fatherid, $replace = false) * * @param string $userid * @param string|array $fileid - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93657#%E5%88%A0%E9%99%A4%E6%96%87%E4%BB%B6 */ public function delete($userid, $fileid) @@ -127,12 +127,12 @@ public function delete($userid, $fileid) * @param integer $start 查询游标 首次填0, 后续填上一次请求返回的next_start * @param integer $limit 拉取条数 最大1000 * @param integer $sort 列表排序方式 1:名字升序;2:名字降序;3:大小升序;4:大小降序;5:修改时间升序;6:修改时间降序 - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93657#%E8%8E%B7%E5%8F%96%E6%96%87%E4%BB%B6%E5%88%97%E8%A1%A8 */ public function list($userid, $spaceid, $fatherid = null, $start = 0, $limit = 1000, $sort = 1) @@ -154,12 +154,12 @@ public function list($userid, $spaceid, $fatherid = null, $start = 0, $limit = 1 * * @param string $userid * @param string $fileid - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93657#%E6%96%87%E4%BB%B6%E4%BF%A1%E6%81%AF */ public function info($userid, $fileid) @@ -175,12 +175,12 @@ public function info($userid, $fileid) * @param string $fatherid 目录id * @param string $fileName 文件名 * @param string $fileContent 文件内容 - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93657#%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6 */ public function upload($userid, $spaceid, $fatherid, $fileName, $fileContent) @@ -202,12 +202,12 @@ public function upload($userid, $spaceid, $fatherid, $fileName, $fileContent) * @param string $userid * @param string $fileid * @param boolean $download 是否直接下载 - * + * * @return \EasyWeChat\Kernel\Http\StreamResponse|\Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93657#%E4%B8%8B%E8%BD%BD%E6%96%87%E4%BB%B6 */ public function download($userid, $fileid, $download = false) @@ -230,12 +230,12 @@ public function download($userid, $fileid, $download = false) * * @param string $userid * @param string $fileid - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93658#%E8%8E%B7%E5%8F%96%E5%88%86%E4%BA%AB%E9%93%BE%E6%8E%A5 */ public function share($userid, $fileid) @@ -252,12 +252,12 @@ public function share($userid, $fileid) * @param int $auth 权限信息 权限信息 * 普通文档: 1:仅浏览(可下载) 4:仅预览(仅专业版企业可设置);如果不填充此字段为保持原有状态 * 微文档: 1:仅浏览(可下载) 2:可编辑;如果不填充此字段为保持原有状态 - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93658#%E5%88%86%E4%BA%AB%E8%AE%BE%E7%BD%AE */ public function setting($userid, $fileid, $authScope, $auth = null) @@ -278,12 +278,12 @@ public function setting($userid, $fileid, $authScope, $auth = null) * @param string $userid * @param string $fileid * @param array $authInfo 添加成员的信息 - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93658#%E6%96%B0%E5%A2%9E%E6%88%90%E5%91%98 */ public function aclAdd($userid, $fileid, $authInfo) @@ -299,16 +299,16 @@ public function aclAdd($userid, $fileid, $authInfo) /** * 删除成员 - * + * * @param string $userid * @param string $fileid * @param array $authInfo 删除成员的信息 - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93658#%E5%88%A0%E9%99%A4%E6%88%90%E5%91%98 */ public function aclDel($userid, $fileid, $authInfo) diff --git a/src/Work/Wedrive/ServiceProvider.php b/src/Work/Wedrive/ServiceProvider.php index 822d42dda..04723f7cf 100644 --- a/src/Work/Wedrive/ServiceProvider.php +++ b/src/Work/Wedrive/ServiceProvider.php @@ -16,7 +16,7 @@ /** * Class ServiceProvider - * + * * @author lio990527 */ class ServiceProvider implements ServiceProviderInterface diff --git a/src/Work/Wedrive/SpaceClient.php b/src/Work/Wedrive/SpaceClient.php index 6824bd732..da0d500b2 100644 --- a/src/Work/Wedrive/SpaceClient.php +++ b/src/Work/Wedrive/SpaceClient.php @@ -16,12 +16,11 @@ /** * Class SpaceClient - * + * * @author lio990527 */ class SpaceClient extends BaseClient { - /** * 新建空间 * @@ -29,12 +28,12 @@ class SpaceClient extends BaseClient * @param string $spaceName 空间名称 * @param array $authInfo 空间成员权限信息 * @param integer $spaceSubType 空间类型, 0:普通 1:相册 - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93656#%E6%96%B0%E5%BB%BA%E7%A9%BA%E9%97%B4 */ public function create($userid, $spaceName, $authInfo = [], $spaceSubType = 0) @@ -55,12 +54,12 @@ public function create($userid, $spaceName, $authInfo = [], $spaceSubType = 0) * @param string $userid * @param string $spaceid * @param string $spaceName 重命名后的空间名 - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93656#%E9%87%8D%E5%91%BD%E5%90%8D%E7%A9%BA%E9%97%B4 */ public function rename($userid, $spaceid, $spaceName) @@ -79,12 +78,12 @@ public function rename($userid, $spaceid, $spaceName) * * @param string $userid * @param string $spaceid - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93656#%E8%A7%A3%E6%95%A3%E7%A9%BA%E9%97%B4 */ public function dismiss($userid, $spaceid) @@ -97,12 +96,12 @@ public function dismiss($userid, $spaceid) * * @param string $userid * @param string $spaceid - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93656#%E8%8E%B7%E5%8F%96%E7%A9%BA%E9%97%B4%E7%9B%B8%E5%86%8C%E4%BF%A1%E6%81%AF */ public function info($userid, $spaceid) @@ -115,12 +114,12 @@ public function info($userid, $spaceid) * * @param string $userid * @param string $spaceid - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93656#%E8%8E%B7%E5%8F%96%E9%82%80%E8%AF%B7%E9%93%BE%E6%8E%A5 */ public function share($userid, $spaceid) @@ -134,12 +133,12 @@ public function share($userid, $spaceid) * @param string $userid * @param string $spaceid * @param array $settings 设置 - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93656#%E5%AE%89%E5%85%A8%E8%AE%BE%E7%BD%AE */ public function setting($userid, $spaceid, $settings) @@ -155,12 +154,12 @@ public function setting($userid, $spaceid, $settings) * @param string $userid * @param string $spaceid * @param array $authInfo 被添加的空间成员信息 - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93656#%E6%B7%BB%E5%8A%A0%E6%88%90%E5%91%98%E9%83%A8%E9%97%A8 */ public function aclAdd($userid, $spaceid, $authInfo) @@ -180,12 +179,12 @@ public function aclAdd($userid, $spaceid, $authInfo) * @param string $userid * @param string $spaceid * @param array $authInfo 被移除的空间成员信息 - * + * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string - * + * * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException - * + * * @see https://developer.work.weixin.qq.com/document/path/93656#%E6%B7%BB%E5%8A%A0%E6%88%90%E5%91%98%E9%83%A8%E9%97%A8 */ public function aclDel($userid, $spaceid, $authInfo) diff --git a/src/Work/Wedrive/Wedrive.php b/src/Work/Wedrive/Wedrive.php index bb01931f3..eed85dcb6 100644 --- a/src/Work/Wedrive/Wedrive.php +++ b/src/Work/Wedrive/Wedrive.php @@ -15,16 +15,15 @@ /** * Class Wedrive - * + * * @property \EasyWeChat\Work\Wedrive\Client $base * @property \EasyWeChat\Work\Wedrive\SpaceClient $space * @property \EasyWeChat\Work\Wedrive\FileClient $file - * + * * @author lio990527 */ class Wedrive extends Container { - public function __get($key) { return $this->offsetGet($key); diff --git a/tests/MiniProgram/Shipping/ClientTest.php b/tests/MiniProgram/Shipping/ClientTest.php new file mode 100644 index 000000000..6decfa348 --- /dev/null +++ b/tests/MiniProgram/Shipping/ClientTest.php @@ -0,0 +1,162 @@ +mockApiClient(Client::class); + + $data = [ + 'order_key' => [ + 'order_number_type' => 1, + 'transaction_id' => '', + 'mchid' => '', + 'out_trade_no' => '' + ], + 'logistics_type' => 1, + 'delivery_mode' => 1, + 'is_all_delivered' => true, + 'shipping_list' => [ + 'tracking_no' => '323244567777', + 'express_company' => 'DHL', + 'item_desc' => '微信红包抱枕*1个', + 'contact' => [ + 'consignor_contact' => '189****1234, 021-****1234', + 'receiver_contact' => '189****1234' + ], + ], + 'upload_time' => '2022-12-15T13:29:35.120+08:00', + 'payer' => [ + 'openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o' + ] + ]; + + $client->expects()->httpPostJson('wxa/sec/order/upload_shipping_info', $data)->andReturn('mock-result'); + + $this->assertSame('mock-result', $client->uploadShippingInfo($data)); + + } + + public function testUploadCombineShippingInfo() + { + $client = $this->mockApiClient(Client::class); + + $data = [ + 'order_key' => [ + 'order_number_type' => 1, + 'transaction_id' => '', + 'mchid' => '', + 'out_trade_no' => '' + ], + 'sub_orders' => [ + 'order_key' => [ + 'order_number_type' => 1, + 'transaction_id' => '', + 'mchid' => '', + 'out_trade_no' => '' + ], + 'logistics_type' => 1, + 'delivery_mode' => 1, + 'is_all_delivered' => true, + 'shipping_list' => [ + 'tracking_no' => '323244567777', + 'express_company' => 'DHL', + 'item_desc' => '微信红包抱枕*1个', + 'contact' => [ + 'consignor_contact' => '189****1234, 021-****1234', + 'receiver_contact' => '189****1234' + ], + ], + ], + 'upload_time' => '2022-12-15T13:29:35.120+08:00', + 'payer' => [ + 'openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o' + ] + ]; + + $client->expects()->httpPostJson('wxa/sec/order/upload_combined_shipping_info', $data)->andReturn('mock-result'); + + $this->assertSame('mock-result', $client->uploadCombineShippingInfo($data)); + } + + public function testGetOrder() + { + $client = $this->mockApiClient(Client::class); + + $params = [ + 'transaction_id' => '42000020212023112332159214' + ]; + + $client->expects()->httpPostJson('wxa/sec/order/get_order', $params)->andReturn('mock-result'); + $this->assertSame('mock-result', $client->getOrder($params)); + } + + public function testGetOrderList() + { + $client = $this->mockApiClient(Client::class); + + $data = []; + + $client->expects()->httpPostJson('wxa/sec/order/get_order_list', $data)->andReturn('mock-result'); + + $this->assertSame('mock-result', $client->getOrderList($data)); + } + + public function testNotifyConfirmReceive() + { + $client = $this->mockApiClient(Client::class); + + $data = [ + 'transaction_id' => '42000020212023112332159214xx', + 'received_time' => '' + ]; + + $client->expects()->httpPostJson('wxa/sec/order/notify_confirm_receive', $data)->andReturn('mock-result'); + + $this->assertSame('mock-result', $client->notifyConfirmReceive($data)); + } + + public function testSetMsgJumpPath() + { + $client = $this->mockApiClient(Client::class); + + $data = [ + 'path' => 'pages/not-found', + ]; + + $client->expects()->httpPostJson('wxa/sec/order/set_msg_jump_path', $data)->andReturn('mock-result'); + + $this->assertSame('mock-result', $client->setMsgJumpPath('pages/not-found')); + } + + public function testIsTradeManaged() + { + $client = $this->mockApiClient(Client::class); + + $data = [ + 'appid' => '123', + ]; + + $client->expects()->httpPostJson('wxa/sec/order/is_trade_managed', $data)->andReturn('mock-result'); + + $this->assertSame('mock-result', $client->isTradeManaged('123')); + } + + public function testIsTradeCompleted() + { + $client = $this->mockApiClient(Client::class); + + $data = [ + 'appid' => '123', + ]; + + $client->expects()->httpPostJson('wxa/sec/order/is_trade_management_confirmation_completed', $data)->andReturn('mock-result'); + + $this->assertSame('mock-result', $client->isTradeCompleted('123')); + } +} diff --git a/tests/OpenPlatform/Base/ClientTest.php b/tests/OpenPlatform/Base/ClientTest.php index 4a8aced11..491325d98 100644 --- a/tests/OpenPlatform/Base/ClientTest.php +++ b/tests/OpenPlatform/Base/ClientTest.php @@ -109,7 +109,7 @@ public function testCreatePreAuthorizationCode() $client->expects() ->httpPostJson('cgi-bin/component/api_create_preauthcode', ['component_appid' => '123456']) ->andReturn('mock-result') - ; + ; $result = $client->createPreAuthorizationCode(); @@ -126,7 +126,7 @@ public function testClearQuota() $client->expects() ->httpPostJson('cgi-bin/component/clear_quota', ['component_appid' => '123456']) ->andReturn('mock-result') - ; + ; $result = $client->clearQuota();