|
- <?php
- namespace WeChat;
- if (!defined('DEDEINC')) exit ('dedebiz');
- use WeChat\Contracts\BasicWeChat;
-
- class Card extends BasicWeChat
- {
-
-
- public function create(array $data)
- {
- $url = "https://api.weixin.qq.com/card/create?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function setPaycell($card_id, $is_open = true)
- {
- $url = "https://api.weixin.qq.com/card/paycell/set?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['card_id' => $card_id, 'is_open' => $is_open]);
- }
-
-
- public function setConsumeCell($card_id, $is_open = true)
- {
- $url = "https://api.weixin.qq.com/card/selfconsumecell/set?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['card_id' => $card_id, 'is_open' => $is_open]);
- }
-
-
- public function createQrc(array $data)
- {
- $url = "https://api.weixin.qq.com/card/qrcode/create?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function createLandingPage(array $data)
- {
- $url = "https://api.weixin.qq.com/card/landingpage/create?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function deposit($card_id, array $code)
- {
- $url = "https://api.weixin.qq.com/card/code/deposit?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['card_id' => $card_id, 'code' => $code]);
- }
-
-
- public function getDepositCount($card_id)
- {
- $url = "https://api.weixin.qq.com/card/code/getdepositcount?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['card_id' => $card_id]);
- }
-
-
- public function checkCode($card_id, array $code)
- {
- $url = "https://api.weixin.qq.com/card/code/checkcode?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['card_id' => $card_id, 'code' => $code]);
- }
-
-
- public function getNewsHtml($card_id)
- {
- $url = "https://api.weixin.qq.com/card/mpnews/gethtml?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['card_id' => $card_id]);
- }
-
-
- public function setTestWhiteList($openids = [], $usernames = [])
- {
- $url = "https://api.weixin.qq.com/card/testwhitelist/set?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['openid' => $openids, 'username' => $usernames]);
- }
-
-
- public function getCode($code, $card_id = null, $check_consume = null)
- {
- $data = ['code' => $code];
- is_null($card_id) || $data['card_id'] = $card_id;
- is_null($check_consume) || $data['check_consume'] = $check_consume;
- $url = "https://api.weixin.qq.com/card/code/get?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function consume($code, $card_id = null)
- {
- $data = ['code' => $code];
- is_null($card_id) || $data['card_id'] = $card_id;
- $url = "https://api.weixin.qq.com/card/code/consume?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function decrypt($encrypt_code)
- {
- $url = "https://api.weixin.qq.com/card/code/decrypt?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['encrypt_code' => $encrypt_code]);
- }
-
-
- public function getCardList($openid, $card_id = null)
- {
- $data = ['openid' => $openid];
- is_null($card_id) || $data['card_id'] = $card_id;
- $url = "https://api.weixin.qq.com/card/user/getcardlist?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function getCard($card_id)
- {
- $url = "https://api.weixin.qq.com/card/get?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['card_id' => $card_id]);
- }
-
-
- public function batchGet($offset, $count = 50, array $status_list = [])
- {
- $data = ['offset' => $offset, 'count' => $count];
- empty($status_list) || $data['status_list'] = $status_list;
- $url = "https://api.weixin.qq.com/card/batchget?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function updateCard($card_id, array $member_card)
- {
- $url = "https://api.weixin.qq.com/card/update?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['card_id' => $card_id, 'member_card' => $member_card]);
- }
-
-
- public function modifyStock($card_id, $increase_stock_value = null, $reduce_stock_value = null)
- {
- $data = ['card_id' => $card_id];
- is_null($increase_stock_value) || $data['increase_stock_value'] = $increase_stock_value;
- is_null($reduce_stock_value) || $data['reduce_stock_value'] = $reduce_stock_value;
- $url = "https://api.weixin.qq.com/card/modifystock?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function updateCode($code, $new_code, $card_id = null)
- {
- $data = ['code' => $code, 'new_code' => $new_code];
- is_null($card_id) || $data['card_id'] = $card_id;
- $url = "https://api.weixin.qq.com/card/code/update?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function deleteCard($card_id)
- {
- $url = "https://api.weixin.qq.com/card/delete?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['card_id' => $card_id]);
- }
-
-
- public function unAvailable($code, $card_id, $reason = null)
- {
- $data = ['code' => $code, 'card_id' => $card_id];
- is_null($reason) || $data['reason'] = $reason;
- $url = "https://api.weixin.qq.com/card/code/unavailable?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function getCardBizuininfo($begin_date, $end_date, $cond_source)
- {
- $data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'cond_source' => $cond_source];
- $url = "https://api.weixin.qq.com/datacube/getcardbizuininfo?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function getCardCardinfo($begin_date, $end_date, $cond_source, $card_id = null)
- {
- $data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'cond_source' => $cond_source];
- is_null($card_id) || $data['card_id'] = $card_id;
- $url = "https://api.weixin.qq.com/datacube/getcardcardinfo?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function activateMemberCard(array $data)
- {
- $url = 'https://api.weixin.qq.com/card/membercard/activate?access_token=ACCESS_TOKEN';
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function setActivateMemberCardUser(array $data)
- {
- $url = 'https://api.weixin.qq.com/card/membercard/activateuserform/set?access_token=ACCESS_TOKEN';
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function getActivateMemberCardTempinfo($activate_ticket)
- {
- $url = 'https://api.weixin.qq.com/card/membercard/activatetempinfo/get?access_token=ACCESS_TOKEN';
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['activate_ticket' => $activate_ticket]);
- }
-
-
- public function updateMemberCardUser(array $data)
- {
- $url = 'https://api.weixin.qq.com/card/membercard/updateuser?access_token=ACCESS_TOKEN';
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function getCardMemberCardinfo($begin_date, $end_date, $cond_source)
- {
- $data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'cond_source' => $cond_source];
- $url = "https://api.weixin.qq.com/datacube/getcardmembercardinfo?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function getCardMemberCardDetail($begin_date, $end_date, $card_id)
- {
- $data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'card_id' => $card_id];
- $url = "https://api.weixin.qq.com/datacube/getcardmembercarddetail?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function getCardMemberCard($card_id, $code)
- {
- $data = ['card_id' => $card_id, 'code' => $code];
- $url = "https://api.weixin.qq.com/card/membercard/userinfo/get?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function payGiftCard(array $data)
- {
- $url = "https://api.weixin.qq.com/card/paygiftcard/add?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function delPayGiftCard($rule_id)
- {
- $url = "https://api.weixin.qq.com/card/paygiftcard/add?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['rule_id' => $rule_id]);
- }
-
-
- public function getPayGiftCard($rule_id)
- {
- $url = "https://api.weixin.qq.com/card/paygiftcard/getbyid?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['rule_id' => $rule_id]);
- }
-
-
- public function batchGetPayGiftCard($offset = 0, $count = 10, $effective = true)
- {
- $data = ['type' => 'RULE_TYPE_PAY_MEMBER_CARD', 'offset' => $offset, 'count' => $count, 'effective' => $effective];
- $url = "https://api.weixin.qq.com/card/paygiftcard/batchget?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function addActivity(array $data)
- {
- $url = "https://api.weixin.qq.com/card/mkt/activity/create?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function payActivate()
- {
- $url = "https://api.weixin.qq.com/card/pay/activate?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpGetForJson($url);
- }
-
-
- public function getPayprice($card_id, $quantity)
- {
- $url = "POST https://api.weixin.qq.com/card/pay/getpayprice?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['card_id' => $card_id, 'quantity' => $quantity]);
- }
-
-
- public function getCoinsInfo()
- {
- $url = "https://api.weixin.qq.com/card/pay/getcoinsinfo?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpGetForJson($url);
- }
-
-
- public function payConfirm($card_id, $quantity, $order_id)
- {
- $data = ['card_id' => $card_id, 'quantity' => $quantity, 'order_id' => $order_id];
- $url = "https://api.weixin.qq.com/card/pay/confirm?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
-
-
- public function payRecharge($coin_count)
- {
- $url = "https://api.weixin.qq.com/card/pay/recharge?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['coin_count' => $coin_count]);
- }
-
-
- public function payGetOrder($order_id)
- {
- $url = "https://api.weixin.qq.com/card/pay/getorder?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, ['order_id' => $order_id]);
- }
-
-
- public function payGetList(array $data)
- {
- $url = "https://api.weixin.qq.com/card/pay/getorderlist?access_token=ACCESS_TOKEN";
- $this->registerApi($url, __FUNCTION__, func_get_args());
- return $this->httpPostForJson($url, $data);
- }
- }
- ?>
|