283 lines
11 KiB
PHP
283 lines
11 KiB
PHP
<?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\Order;
|
|
|
|
use TuzhiEasyWeChat\Kernel\BaseClient;
|
|
use TuzhiEasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
|
|
|
/**
|
|
* Class Client.
|
|
*
|
|
* @author mingyoung <mingyoungcheung@gmail.com>
|
|
*/
|
|
class OrderClient extends BaseClient
|
|
{
|
|
/**
|
|
* 获取订单列表
|
|
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
|
* @param $create_time_range object TimeRange 时间范围至少填一个 订单创建时间范围,具体结构请参考TimeRange结构体
|
|
* @param $update_time_range object TimeRange 时间范围至少填一个 订单更新时间范围,具体结构请参考TimeRange结构体
|
|
* @param $status number 否 订单状态,具体枚举值请参考RequestOrderStatus枚举
|
|
* @param $openid string 否 买家身份标识
|
|
* @param $next_key string 否 分页参数,上一页请求返回
|
|
* @param $page_size number 是 每页数量(不超过100)
|
|
*
|
|
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
*/
|
|
public function getList($create_time_range=[],$update_time_range = [],$status='',$openid='',$page_size='',$next_key='')
|
|
{
|
|
$params = [
|
|
'create_time_range' => $create_time_range,
|
|
'update_time_range' => $update_time_range,
|
|
'status' => $status,
|
|
'openid' => $openid,
|
|
'page_size' => $page_size,
|
|
'next_key' => $next_key
|
|
];
|
|
|
|
return $this->httpPostJson('channels/ec/order/list/get', $params);
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取订单详情
|
|
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
|
* @param $order_id string 是 订单ID,可从获取订单列表中获得
|
|
* @param $encode_sensitive_info bool 否 用于商家提前测试订单脱敏效果,如果传true,即对订单进行脱敏,后期会默认对所有订单脱敏
|
|
*
|
|
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
*/
|
|
public function getOrder($order_id,$encode_sensitive_info='')
|
|
{
|
|
$params = [
|
|
'order_id'=>$order_id
|
|
];
|
|
|
|
if($encode_sensitive_info !== ''){
|
|
$params['encode_sensitive_info'] = $encode_sensitive_info;
|
|
}
|
|
|
|
return $this->httpPostJson('channels/ec/order/get', $params);
|
|
}
|
|
|
|
/**
|
|
* 修改订单价格
|
|
* 可通过该接口修改订单价格
|
|
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
|
* @param $order_id string 是 订单id,可通过获取订单列表接口获取
|
|
* @param $change_express bool 是 是否修改运费
|
|
* @param $express_fee number 否 修改后的运费价格(change_express=true时必填),以分为单位
|
|
* @param $change_order_infos array ChangeOrderInfo 是 改价列表,具体可见结构体ChangeOrderInfo
|
|
*
|
|
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
*/
|
|
public function update($order_id,$change_express,$change_order_infos,$express_fee='')
|
|
{
|
|
$params = [
|
|
'order_id'=>$order_id,
|
|
'change_express'=>$change_express,
|
|
'change_order_infos'=>$change_order_infos
|
|
];
|
|
|
|
if($express_fee !== ''){
|
|
$params['express_fee'] = $express_fee;
|
|
}
|
|
return $this->httpPostJson('channels/ec/order/price/update', $params);
|
|
}
|
|
|
|
/**
|
|
* 修改订单备注
|
|
* 可通过该接口修改订单备注。
|
|
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
|
* @param $order_id string 是 订单id,可通过获取订单列表接口获取
|
|
* @param $merchant_notes string 是 备注内容
|
|
*
|
|
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
*/
|
|
public function updateMerchantnotes($order_id,$merchant_notes)
|
|
{
|
|
$params = [
|
|
'order_id' => $order_id,
|
|
'merchant_notes'=>$merchant_notes
|
|
];
|
|
|
|
return $this->httpPostJson('channels/ec/order/merchantnotes/update', $params);
|
|
}
|
|
|
|
/**
|
|
* 修改订单地址
|
|
* 可通过该接口对订单地址进行修改。
|
|
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
|
* @param $order_id string 是 订单id,可通过获取订单列表接口获取
|
|
* @param $user_address object AddressInfo 是 新地址,具体可见结构体AddressInfo
|
|
*
|
|
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
*/
|
|
public function updateAddress($order_id,$user_address)
|
|
{
|
|
$params = [
|
|
'order_id' => $order_id,
|
|
'user_address'=>$user_address
|
|
];
|
|
|
|
return $this->httpPostJson('channels/ec/order/address/update', $params);
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 修改物流信息
|
|
* 可通过该接口修改物流信息。
|
|
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
|
* @param $order_id string 是 订单id,可通过获取订单列表接口获取
|
|
* @param $delivery_list array DeliveryInfo 是 物流信息,具体可见结构体DeliveryInfo
|
|
*
|
|
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
*/
|
|
public function updateDeliveryinfo($order_id,$delivery_list)
|
|
{
|
|
$params = [
|
|
'order_id' => $order_id,
|
|
'delivery_list'=>$delivery_list
|
|
];
|
|
|
|
return $this->httpPostJson('channels/ec/order/deliveryinfo/update', $params);
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 解码订单包含的敏感数据
|
|
* 为保护敏感数据(如收货人昵称、电话号码、详细收货地址),平台对这些信息进行了部分隐藏。通过本接口操作订单后,可以获取到这些信息的完整数据。
|
|
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
|
* @param $order_id string 是 订单id,可通过获取订单列表接口获取
|
|
*
|
|
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
*/
|
|
public function decodeSensitiveinfo($order_id)
|
|
{
|
|
$params = [
|
|
'order_id' => $order_id
|
|
];
|
|
|
|
return $this->httpPostJson('ec/order/sensitiveinfo/decode', $params);
|
|
}
|
|
|
|
|
|
/**
|
|
* 同意用户修改收货地址申请
|
|
* 可通过该接口同意用户修改收货地址申请。
|
|
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
|
* @param $order_id string 是 订单id,可通过获取订单列表接口获取
|
|
*
|
|
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
*/
|
|
public function acceptAddressmodify($order_id)
|
|
{
|
|
$params = [
|
|
'order_id' => $order_id
|
|
];
|
|
|
|
return $this->httpPostJson('channels/ec/order/addressmodify/accept', $params);
|
|
}
|
|
|
|
|
|
/**
|
|
* 拒绝用户修改收货地址申请
|
|
* 可通过该接口拒绝买家的订单修改收货地址申请。
|
|
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
|
* @param $order_id string 是 订单id,可通过获取订单列表接口获取
|
|
*
|
|
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
*/
|
|
public function rejectAddressmodify($order_id)
|
|
{
|
|
$params = [
|
|
'order_id' => $order_id
|
|
];
|
|
|
|
return $this->httpPostJson('channels/ec/order/addressmodify/reject', $params);
|
|
}
|
|
|
|
|
|
/**
|
|
* 兑换虚拟号
|
|
* 可通过该接口兑换虚拟号
|
|
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
|
* @param $order_id string 是 订单id,可通过获取订单列表接口获取
|
|
*
|
|
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
*/
|
|
public function getVirtualtelnumber($order_id)
|
|
{
|
|
$params = [
|
|
'order_id' => $order_id
|
|
];
|
|
|
|
return $this->httpPostJson('channels/ec/order/virtualtelnumber/get', $params);
|
|
}
|
|
|
|
|
|
/**
|
|
* 订单搜索
|
|
* 该接口用于根据传递的条件搜索订单
|
|
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
|
* @param $search_condition object SearchCondition 是 搜索条件,具体结构请参考SearchCondition结构体
|
|
* @param $on_aftersale_order_exist number 否 不传该参数:搜索全部订单;
|
|
0:搜索没有正在售后的订单;
|
|
1:搜索正在售后且售后单数量>=1的订单
|
|
|
|
除了以下几种售后单状态(AfterSaleStatus)外其它的都是正在售后的状态:
|
|
USER_CANCELD
|
|
MERCHANT_REFUND_RETRY_FAIL
|
|
MERCHANT_FAIL
|
|
MERCHANT_REFUND_SUCCESS
|
|
MERCHANT_RETURN_SUCCESS
|
|
* @param $status number 否 订单状态,枚举值见RequestOrderStatus
|
|
* @param $next_key string 是 分页参数,上一页请求返回
|
|
* @param $page_size number 是 每页数量(不超过100)
|
|
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
*/
|
|
public function search($search_condition,$page_size,$next_key,$status = '',$on_aftersale_order_exist = '')
|
|
{
|
|
$params = [
|
|
'search_condition' => $search_condition,
|
|
'page_size' => $page_size,
|
|
'next_key' => $next_key
|
|
];
|
|
|
|
if($status !== ''){
|
|
$params['status'] = $status;
|
|
}
|
|
|
|
if($on_aftersale_order_exist !== ''){
|
|
$params['on_aftersale_order_exist'] = $on_aftersale_order_exist;
|
|
}
|
|
|
|
return $this->httpPostJson('channels/ec/order/search', $params);
|
|
}
|
|
|
|
|
|
|
|
}
|