Properties

$access_token

$access_token : string

访问AccessToken

Type

string

$currentMethod

$currentMethod : array

当前请求方法参数

Type

array

$isTry

$isTry : boolean

当前模式

Type

boolean

$GetAccessTokenCallback

$GetAccessTokenCallback : string

注册代替函数

Type

string

Methods

__construct()

__construct(array  $options) 

BasicWeChat constructor.

Parameters

array $options

getAccessToken()

getAccessToken() : string

获取访问accessToken

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

string

delAccessToken()

delAccessToken() : boolean

清理删除accessToken

Returns

boolean

callPostApi()

callPostApi(string  $url, array  $data, boolean  $isBuildJson = true) : array

接口通用POST请求方法

Parameters

string $url

接口URL

array $data

POST提交接口参数

boolean $isBuildJson

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

callGetApi()

callGetApi(string  $url) : array

接口通用GET请求方法

Parameters

string $url

接口URL

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

create()

create(array  $data) : array

创建卡券

Parameters

array $data

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

setPaycell()

setPaycell(string  $card_id, boolean  $is_open = true) : array

设置买单接口

Parameters

string $card_id
boolean $is_open

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

setConsumeCell()

setConsumeCell(string  $card_id, boolean  $is_open = true) : array

设置自助核销接口

Parameters

string $card_id
boolean $is_open

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

createQrc()

createQrc(array  $data) : array

创建二维码接口

Parameters

array $data

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

createLandingPage()

createLandingPage(array  $data) : array

创建货架接口

Parameters

array $data

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

deposit()

deposit(string  $card_id, array  $code) : array

导入自定义code

Parameters

string $card_id
array $code

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

getDepositCount()

getDepositCount(string  $card_id) : array

查询导入code数目

Parameters

string $card_id

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

checkCode()

checkCode(string  $card_id, array  $code) : array

核查code接口

Parameters

string $card_id

进行导入code的卡券ID

array $code

已经微信卡券后台的自定义code,上限为100个

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

getNewsHtml()

getNewsHtml(string  $card_id) : array

图文消息群发卡券

Parameters

string $card_id

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

setTestWhiteList()

setTestWhiteList(array  $openids = array(), array  $usernames = array()) : array

设置测试白名单

Parameters

array $openids
array $usernames

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

getCode()

getCode(string  $code, string  $card_id = null, boolean  $check_consume = null) : array

线下核销查询Code

Parameters

string $code

单张卡券的唯一标准

string $card_id

卡券ID代表一类卡券。自定义code卡券必填

boolean $check_consume

是否校验code核销状态,填入true和false时的code异常状态返回数据不同

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

consume()

consume(string  $code, null  $card_id = null) : array

线下核销核销Code

Parameters

string $code

需核销的Code码

null $card_id

券ID。创建卡券时use_custom_code填写true时必填。非自定义Code不必填写

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

decrypt()

decrypt(string  $encrypt_code) : array

Code解码接口

Parameters

string $encrypt_code

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

getCardList()

getCardList(string  $openid, null|string  $card_id = null) : array

获取用户已领取卡券接口

Parameters

string $openid
null|string $card_id

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

getCard()

getCard(string  $card_id) : array

查看卡券详情

Parameters

string $card_id

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

batchGet()

batchGet(integer  $offset, integer  $count = 50, array  $status_list = array()) : array

批量查询卡券列表

Parameters

integer $offset

查询卡列表的起始偏移量,从0开始,即offset: 5是指从从列表里的第六个开始读取

integer $count

需要查询的卡片的数量(数量最大50)

array $status_list

支持开发者拉出指定状态的卡券列表

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

updateCard()

updateCard(string  $card_id, array  $member_card) : array

更改卡券信息接口

Parameters

string $card_id
array $member_card

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

modifyStock()

modifyStock(string  $card_id, null|integer  $increase_stock_value = null, null|integer  $reduce_stock_value = null) : array

修改库存接口

Parameters

string $card_id

卡券ID

null|integer $increase_stock_value

增加多少库存,支持不填或填0

null|integer $reduce_stock_value

减少多少库存,可以不填或填0

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

updateCode()

updateCode(string  $code, string  $new_code, null|string  $card_id = null) : array

更改Code接口

Parameters

string $code

需变更的Code码

string $new_code

变更后的有效Code码

null|string $card_id

卡券ID

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

deleteCard()

deleteCard(string  $card_id) : array

删除卡券接口

Parameters

string $card_id

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

unAvailable()

unAvailable(string  $code, string  $card_id, null|string  $reason = null) : array

设置卡券失效接口

Parameters

string $code
string $card_id
null|string $reason

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

getCardBizuininfo()

getCardBizuininfo(string  $begin_date, string  $end_date, string  $cond_source) : array

拉取卡券概况数据接口

Parameters

string $begin_date

查询数据的起始时间

string $end_date

查询数据的截至时间

string $cond_source

卡券来源(0为公众平台创建的卡券数据 1是API创建的卡券数据)

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

getCardCardinfo()

getCardCardinfo(string  $begin_date, string  $end_date, integer  $cond_source, null  $card_id = null) : array

获取免费券数据接口

Parameters

string $begin_date

查询数据的起始时间

string $end_date

查询数据的截至时间

integer $cond_source

卡券来源,0为公众平台创建的卡券数据、1是API创建的卡券数据

null $card_id

卡券ID

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

activateMemberCard()

activateMemberCard(array  $data) : array

激活会员卡

Parameters

array $data

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

setActivateMemberCardUser()

setActivateMemberCardUser(array  $data) : array

设置开卡字段接口 用户激活时需要填写的选项

Parameters

array $data

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

getActivateMemberCardTempinfo()

getActivateMemberCardTempinfo(string  $activate_ticket) : array

获取用户提交资料 根据activate_ticket获取到用户填写的信息

Parameters

string $activate_ticket

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

updateMemberCardUser()

updateMemberCardUser(array  $data) : array

更新会员信息

Parameters

array $data

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

getCardMemberCardinfo()

getCardMemberCardinfo(string  $begin_date, string  $end_date, string  $cond_source) : array

拉取会员卡概况数据接口

Parameters

string $begin_date

查询数据的起始时间

string $end_date

查询数据的截至时间

string $cond_source

卡券来源(0为公众平台创建的卡券数据 1是API创建的卡券数据)

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

getCardMemberCardDetail()

getCardMemberCardDetail(string  $begin_date, string  $end_date, string  $card_id) : array

拉取单张会员卡数据接口

Parameters

string $begin_date

查询数据的起始时间

string $end_date

查询数据的截至时间

string $card_id

卡券id

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

getCardMemberCard()

getCardMemberCard(string  $card_id, string  $code) : array

拉取会员信息(积分查询)接口

Parameters

string $card_id

查询会员卡的cardid

string $code

所查询用户领取到的code值

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

payGiftCard()

payGiftCard(array  $data) : array

设置支付后投放卡券接口

Parameters

array $data

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

delPayGiftCard()

delPayGiftCard(integer  $rule_id) : array

删除支付后投放卡券规则

Parameters

integer $rule_id

支付即会员的规则名称

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

getPayGiftCard()

getPayGiftCard(integer  $rule_id) : array

查询支付后投放卡券规则详情

Parameters

integer $rule_id

要查询规则id

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

batchGetPayGiftCard()

batchGetPayGiftCard(integer  $offset, integer  $count = 10, boolean  $effective = true) : array

批量查询支付后投放卡券规则

Parameters

integer $offset

起始偏移量

integer $count

查询的数量

boolean $effective

是否仅查询生效的规则

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

addActivity()

addActivity(array  $data) : array

创建支付后领取立减金活动

Parameters

array $data

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

payActivate()

payActivate() : array

开通券点账户接口

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

getPayprice()

getPayprice(string  $card_id, integer  $quantity) : array

对优惠券批价

Parameters

string $card_id

需要来配置库存的card_id

integer $quantity

本次需要兑换的库存数目

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

getCoinsInfo()

getCoinsInfo() : array

查询券点余额接口

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

payConfirm()

payConfirm(string  $card_id, integer  $quantity, string  $order_id) : array

确认兑换库存接口

Parameters

string $card_id

需要来兑换库存的card_id

integer $quantity

本次需要兑换的库存数目

string $order_id

仅可以使用上面得到的订单号,保证批价有效性

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

payRecharge()

payRecharge(integer  $coin_count) : array

充值券点接口

Parameters

integer $coin_count

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

payGetOrder()

payGetOrder(string  $order_id) : array

查询订单详情接口

Parameters

string $order_id

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

payGetList()

payGetList(array  $data) : array

查询券点流水详情接口

Parameters

array $data

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

httpGetForJson()

httpGetForJson(string  $url) : array

以GET获取接口数据并转为数组

Parameters

string $url

接口地址

Throws

\WeChat\Exceptions\InvalidResponseException

Returns

array

httpPostForJson()

httpPostForJson(string  $url, array  $data, boolean  $buildToJson = true) : array

以POST获取接口数据并转为数组

Parameters

string $url

接口地址

array $data

请求数据

boolean $buildToJson

Throws

\WeChat\Exceptions\InvalidResponseException

Returns

array

registerApi()

registerApi(string  $url, string  $method, array  $arguments = array()) : mixed

注册当前请求接口

Parameters

string $url

接口地址

string $method

当前接口方法

array $arguments

请求参数

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

mixed