国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

616 lines
24KB

  1. <?php
  2. namespace WeChat;
  3. if (!defined('DEDEINC')) exit ('dedebiz');
  4. use WeChat\Contracts\BasicWeChat;
  5. /**
  6. * 卡券管理
  7. * Class Card
  8. * @package WeChat
  9. */
  10. class Card extends BasicWeChat
  11. {
  12. /**
  13. * 创建卡券
  14. * @param array $data
  15. * @return array
  16. * @throws Exceptions\InvalidResponseException
  17. * @throws Exceptions\LocalCacheException
  18. */
  19. public function create(array $data)
  20. {
  21. $url = "https://api.weixin.qq.com/card/create?access_token=ACCESS_TOKEN";
  22. $this->registerApi($url, __FUNCTION__, func_get_args());
  23. return $this->httpPostForJson($url, $data);
  24. }
  25. /**
  26. * 设置买单接口
  27. * @param string $card_id
  28. * @param bool $is_open
  29. * @return array
  30. * @throws Exceptions\InvalidResponseException
  31. * @throws Exceptions\LocalCacheException
  32. */
  33. public function setPaycell($card_id, $is_open = true)
  34. {
  35. $url = "https://api.weixin.qq.com/card/paycell/set?access_token=ACCESS_TOKEN";
  36. $this->registerApi($url, __FUNCTION__, func_get_args());
  37. return $this->httpPostForJson($url, ['card_id' => $card_id, 'is_open' => $is_open]);
  38. }
  39. /**
  40. * 设置自助核销接口
  41. * @param string $card_id
  42. * @param bool $is_open
  43. * @return array
  44. * @throws Exceptions\InvalidResponseException
  45. * @throws Exceptions\LocalCacheException
  46. */
  47. public function setConsumeCell($card_id, $is_open = true)
  48. {
  49. $url = "https://api.weixin.qq.com/card/selfconsumecell/set?access_token=ACCESS_TOKEN";
  50. $this->registerApi($url, __FUNCTION__, func_get_args());
  51. return $this->httpPostForJson($url, ['card_id' => $card_id, 'is_open' => $is_open]);
  52. }
  53. /**
  54. * 创建二维码接口
  55. * @param array $data
  56. * @return array
  57. * @throws Exceptions\InvalidResponseException
  58. * @throws Exceptions\LocalCacheException
  59. */
  60. public function createQrc(array $data)
  61. {
  62. $url = "https://api.weixin.qq.com/card/qrcode/create?access_token=ACCESS_TOKEN";
  63. $this->registerApi($url, __FUNCTION__, func_get_args());
  64. return $this->httpPostForJson($url, $data);
  65. }
  66. /**
  67. * 创建货架接口
  68. * @param array $data
  69. * @return array
  70. * @throws Exceptions\InvalidResponseException
  71. * @throws Exceptions\LocalCacheException
  72. */
  73. public function createLandingPage(array $data)
  74. {
  75. $url = "https://api.weixin.qq.com/card/landingpage/create?access_token=ACCESS_TOKEN";
  76. $this->registerApi($url, __FUNCTION__, func_get_args());
  77. return $this->httpPostForJson($url, $data);
  78. }
  79. /**
  80. * 导入自定义code
  81. * @param string $card_id
  82. * @param array $code
  83. * @return array
  84. * @throws Exceptions\InvalidResponseException
  85. * @throws Exceptions\LocalCacheException
  86. */
  87. public function deposit($card_id, array $code)
  88. {
  89. $url = "https://api.weixin.qq.com/card/code/deposit?access_token=ACCESS_TOKEN";
  90. $this->registerApi($url, __FUNCTION__, func_get_args());
  91. return $this->httpPostForJson($url, ['card_id' => $card_id, 'code' => $code]);
  92. }
  93. /**
  94. * 查询导入code数目
  95. * @param string $card_id
  96. * @return array
  97. * @throws Exceptions\InvalidResponseException
  98. * @throws Exceptions\LocalCacheException
  99. */
  100. public function getDepositCount($card_id)
  101. {
  102. $url = "https://api.weixin.qq.com/card/code/getdepositcount?access_token=ACCESS_TOKEN";
  103. $this->registerApi($url, __FUNCTION__, func_get_args());
  104. return $this->httpPostForJson($url, ['card_id' => $card_id]);
  105. }
  106. /**
  107. * 核查code接口
  108. * @param string $card_id 进行导入code的卡券ID
  109. * @param array $code 已经微信卡券后台的自定义code,上限为100个
  110. * @return array
  111. * @throws Exceptions\InvalidResponseException
  112. * @throws Exceptions\LocalCacheException
  113. */
  114. public function checkCode($card_id, array $code)
  115. {
  116. $url = "https://api.weixin.qq.com/card/code/checkcode?access_token=ACCESS_TOKEN";
  117. $this->registerApi($url, __FUNCTION__, func_get_args());
  118. return $this->httpPostForJson($url, ['card_id' => $card_id, 'code' => $code]);
  119. }
  120. /**
  121. * 图文消息群发卡券
  122. * @param string $card_id
  123. * @return array
  124. * @throws Exceptions\InvalidResponseException
  125. * @throws Exceptions\LocalCacheException
  126. */
  127. public function getNewsHtml($card_id)
  128. {
  129. $url = "https://api.weixin.qq.com/card/mpnews/gethtml?access_token=ACCESS_TOKEN";
  130. $this->registerApi($url, __FUNCTION__, func_get_args());
  131. return $this->httpPostForJson($url, ['card_id' => $card_id]);
  132. }
  133. /**
  134. * 设置测试白名单
  135. * @param array $openids
  136. * @param array $usernames
  137. * @return array
  138. * @throws Exceptions\InvalidResponseException
  139. * @throws Exceptions\LocalCacheException
  140. */
  141. public function setTestWhiteList($openids = [], $usernames = [])
  142. {
  143. $url = "https://api.weixin.qq.com/card/testwhitelist/set?access_token=ACCESS_TOKEN";
  144. $this->registerApi($url, __FUNCTION__, func_get_args());
  145. return $this->httpPostForJson($url, ['openid' => $openids, 'username' => $usernames]);
  146. }
  147. /**
  148. * 线下核销查询Code
  149. * @param string $code 单张卡券的唯一标准
  150. * @param string $card_id 卡券ID代表一类卡券。自定义code卡券必填
  151. * @param bool $check_consume 是否校验code核销状态,填入true和false时的code异常状态返回数据不同
  152. * @return array
  153. * @throws Exceptions\InvalidResponseException
  154. * @throws Exceptions\LocalCacheException
  155. */
  156. public function getCode($code, $card_id = null, $check_consume = null)
  157. {
  158. $data = ['code' => $code];
  159. is_null($card_id) || $data['card_id'] = $card_id;
  160. is_null($check_consume) || $data['check_consume'] = $check_consume;
  161. $url = "https://api.weixin.qq.com/card/code/get?access_token=ACCESS_TOKEN";
  162. $this->registerApi($url, __FUNCTION__, func_get_args());
  163. return $this->httpPostForJson($url, $data);
  164. }
  165. /**
  166. * 线下核销核销Code
  167. * @param string $code 需核销的Code码
  168. * @param null $card_id 券ID。创建卡券时use_custom_code填写true时必填。非自定义Code不必填写
  169. * @return array
  170. * @throws Exceptions\InvalidResponseException
  171. * @throws Exceptions\LocalCacheException
  172. */
  173. public function consume($code, $card_id = null)
  174. {
  175. $data = ['code' => $code];
  176. is_null($card_id) || $data['card_id'] = $card_id;
  177. $url = "https://api.weixin.qq.com/card/code/consume?access_token=ACCESS_TOKEN";
  178. $this->registerApi($url, __FUNCTION__, func_get_args());
  179. return $this->httpPostForJson($url, $data);
  180. }
  181. /**
  182. * Code解码接口
  183. * @param string $encrypt_code
  184. * @return array
  185. * @throws Exceptions\InvalidResponseException
  186. * @throws Exceptions\LocalCacheException
  187. */
  188. public function decrypt($encrypt_code)
  189. {
  190. $url = "https://api.weixin.qq.com/card/code/decrypt?access_token=ACCESS_TOKEN";
  191. $this->registerApi($url, __FUNCTION__, func_get_args());
  192. return $this->httpPostForJson($url, ['encrypt_code' => $encrypt_code]);
  193. }
  194. /**
  195. * 获取会员已领取卡券接口
  196. * @param string $openid
  197. * @param null|string $card_id
  198. * @return array
  199. * @throws Exceptions\InvalidResponseException
  200. * @throws Exceptions\LocalCacheException
  201. */
  202. public function getCardList($openid, $card_id = null)
  203. {
  204. $data = ['openid' => $openid];
  205. is_null($card_id) || $data['card_id'] = $card_id;
  206. $url = "https://api.weixin.qq.com/card/user/getcardlist?access_token=ACCESS_TOKEN";
  207. $this->registerApi($url, __FUNCTION__, func_get_args());
  208. return $this->httpPostForJson($url, $data);
  209. }
  210. /**
  211. * 查看卡券详情
  212. * @param string $card_id
  213. * @return array
  214. * @throws Exceptions\InvalidResponseException
  215. * @throws Exceptions\LocalCacheException
  216. */
  217. public function getCard($card_id)
  218. {
  219. $url = "https://api.weixin.qq.com/card/get?access_token=ACCESS_TOKEN";
  220. $this->registerApi($url, __FUNCTION__, func_get_args());
  221. return $this->httpPostForJson($url, ['card_id' => $card_id]);
  222. }
  223. /**
  224. * 批量查询卡券列表
  225. * @param int $offset 查询卡列表的起始偏移量,从0开始,即offset: 5是指从从列表里的第六个开始读取
  226. * @param int $count 需要查询的卡片的数量(数量最大50)
  227. * @param array $status_list 支持开发者拉出指定状态的卡券列表
  228. * @return array
  229. * @throws Exceptions\InvalidResponseException
  230. * @throws Exceptions\LocalCacheException
  231. */
  232. public function batchGet($offset, $count = 50, array $status_list = [])
  233. {
  234. $data = ['offset' => $offset, 'count' => $count];
  235. empty($status_list) || $data['status_list'] = $status_list;
  236. $url = "https://api.weixin.qq.com/card/batchget?access_token=ACCESS_TOKEN";
  237. $this->registerApi($url, __FUNCTION__, func_get_args());
  238. return $this->httpPostForJson($url, $data);
  239. }
  240. /**
  241. * 更改卡券信息接口
  242. * @param string $card_id
  243. * @param array $member_card
  244. * @return array
  245. * @throws Exceptions\InvalidResponseException
  246. * @throws Exceptions\LocalCacheException
  247. */
  248. public function updateCard($card_id, array $member_card)
  249. {
  250. $url = "https://api.weixin.qq.com/card/update?access_token=ACCESS_TOKEN";
  251. $this->registerApi($url, __FUNCTION__, func_get_args());
  252. return $this->httpPostForJson($url, ['card_id' => $card_id, 'member_card' => $member_card]);
  253. }
  254. /**
  255. * 修改库存接口
  256. * @param string $card_id 卡券ID
  257. * @param null|integer $increase_stock_value 增加多少库存,支持不填或填0
  258. * @param null|integer $reduce_stock_value 减少多少库存,可以不填或填0
  259. * @return array
  260. * @throws Exceptions\InvalidResponseException
  261. * @throws Exceptions\LocalCacheException
  262. */
  263. public function modifyStock($card_id, $increase_stock_value = null, $reduce_stock_value = null)
  264. {
  265. $data = ['card_id' => $card_id];
  266. is_null($increase_stock_value) || $data['increase_stock_value'] = $increase_stock_value;
  267. is_null($reduce_stock_value) || $data['reduce_stock_value'] = $reduce_stock_value;
  268. $url = "https://api.weixin.qq.com/card/modifystock?access_token=ACCESS_TOKEN";
  269. $this->registerApi($url, __FUNCTION__, func_get_args());
  270. return $this->httpPostForJson($url, $data);
  271. }
  272. /**
  273. * 更改Code接口
  274. * @param string $code 需变更的Code码
  275. * @param string $new_code 变更后的有效Code码
  276. * @param null|string $card_id 卡券ID
  277. * @return array
  278. * @throws Exceptions\InvalidResponseException
  279. * @throws Exceptions\LocalCacheException
  280. */
  281. public function updateCode($code, $new_code, $card_id = null)
  282. {
  283. $data = ['code' => $code, 'new_code' => $new_code];
  284. is_null($card_id) || $data['card_id'] = $card_id;
  285. $url = "https://api.weixin.qq.com/card/code/update?access_token=ACCESS_TOKEN";
  286. $this->registerApi($url, __FUNCTION__, func_get_args());
  287. return $this->httpPostForJson($url, $data);
  288. }
  289. /**
  290. * 删除卡券接口
  291. * @param string $card_id
  292. * @return array
  293. * @throws Exceptions\InvalidResponseException
  294. * @throws Exceptions\LocalCacheException
  295. */
  296. public function deleteCard($card_id)
  297. {
  298. $url = "https://api.weixin.qq.com/card/delete?access_token=ACCESS_TOKEN";
  299. $this->registerApi($url, __FUNCTION__, func_get_args());
  300. return $this->httpPostForJson($url, ['card_id' => $card_id]);
  301. }
  302. /**
  303. * 设置卡券失效接口
  304. * @param string $code
  305. * @param string $card_id
  306. * @param null|string $reason
  307. * @return array
  308. * @throws Exceptions\InvalidResponseException
  309. * @throws Exceptions\LocalCacheException
  310. */
  311. public function unAvailable($code, $card_id, $reason = null)
  312. {
  313. $data = ['code' => $code, 'card_id' => $card_id];
  314. is_null($reason) || $data['reason'] = $reason;
  315. $url = "https://api.weixin.qq.com/card/code/unavailable?access_token=ACCESS_TOKEN";
  316. $this->registerApi($url, __FUNCTION__, func_get_args());
  317. return $this->httpPostForJson($url, $data);
  318. }
  319. /**
  320. * 拉取卡券概况数据接口
  321. * @param string $begin_date 查询数据的起始时间
  322. * @param string $end_date 查询数据的截至时间
  323. * @param string $cond_source 卡券来源(0为公众平台创建的卡券数据 1是API创建的卡券数据)
  324. * @return array
  325. * @throws Exceptions\InvalidResponseException
  326. * @throws Exceptions\LocalCacheException
  327. */
  328. public function getCardBizuininfo($begin_date, $end_date, $cond_source)
  329. {
  330. $data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'cond_source' => $cond_source];
  331. $url = "https://api.weixin.qq.com/datacube/getcardbizuininfo?access_token=ACCESS_TOKEN";
  332. $this->registerApi($url, __FUNCTION__, func_get_args());
  333. return $this->httpPostForJson($url, $data);
  334. }
  335. /**
  336. * 获取免费券数据接口
  337. * @param string $begin_date 查询数据的起始时间
  338. * @param string $end_date 查询数据的截至时间
  339. * @param integer $cond_source 卡券来源,0为公众平台创建的卡券数据、1是API创建的卡券数据
  340. * @param null $card_id 卡券ID
  341. * @return array
  342. * @throws Exceptions\InvalidResponseException
  343. * @throws Exceptions\LocalCacheException
  344. */
  345. public function getCardCardinfo($begin_date, $end_date, $cond_source, $card_id = null)
  346. {
  347. $data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'cond_source' => $cond_source];
  348. is_null($card_id) || $data['card_id'] = $card_id;
  349. $url = "https://api.weixin.qq.com/datacube/getcardcardinfo?access_token=ACCESS_TOKEN";
  350. $this->registerApi($url, __FUNCTION__, func_get_args());
  351. return $this->httpPostForJson($url, $data);
  352. }
  353. /**
  354. * 激活会员卡
  355. * @param array $data
  356. * @return array
  357. * @throws Exceptions\InvalidResponseException
  358. * @throws Exceptions\LocalCacheException
  359. */
  360. public function activateMemberCard(array $data)
  361. {
  362. $url = 'https://api.weixin.qq.com/card/membercard/activate?access_token=ACCESS_TOKEN';
  363. $this->registerApi($url, __FUNCTION__, func_get_args());
  364. return $this->httpPostForJson($url, $data);
  365. }
  366. /**
  367. * 设置开卡字段接口
  368. * 会员激活时需要填写的选项
  369. * @param array $data
  370. * @return array
  371. * @throws Exceptions\InvalidResponseException
  372. * @throws Exceptions\LocalCacheException
  373. */
  374. public function setActivateMemberCardUser(array $data)
  375. {
  376. $url = 'https://api.weixin.qq.com/card/membercard/activateuserform/set?access_token=ACCESS_TOKEN';
  377. $this->registerApi($url, __FUNCTION__, func_get_args());
  378. return $this->httpPostForJson($url, $data);
  379. }
  380. /**
  381. * 获取会员提交资料
  382. * 根据activate_ticket获取到会员填写的信息
  383. * @param string $activate_ticket
  384. * @return array
  385. * @throws Exceptions\InvalidResponseException
  386. * @throws Exceptions\LocalCacheException
  387. */
  388. public function getActivateMemberCardTempinfo($activate_ticket)
  389. {
  390. $url = 'https://api.weixin.qq.com/card/membercard/activatetempinfo/get?access_token=ACCESS_TOKEN';
  391. $this->registerApi($url, __FUNCTION__, func_get_args());
  392. return $this->httpPostForJson($url, ['activate_ticket' => $activate_ticket]);
  393. }
  394. /**
  395. * 更新会员信息
  396. * @param array $data
  397. * @return array
  398. * @throws Exceptions\InvalidResponseException
  399. * @throws Exceptions\LocalCacheException
  400. */
  401. public function updateMemberCardUser(array $data)
  402. {
  403. $url = 'https://api.weixin.qq.com/card/membercard/updateuser?access_token=ACCESS_TOKEN';
  404. $this->registerApi($url, __FUNCTION__, func_get_args());
  405. return $this->httpPostForJson($url, $data);
  406. }
  407. /**
  408. * 拉取会员卡概况数据接口
  409. * @param string $begin_date 查询数据的起始时间
  410. * @param string $end_date 查询数据的截至时间
  411. * @param string $cond_source 卡券来源(0为公众平台创建的卡券数据 1是API创建的卡券数据)
  412. * @return array
  413. * @throws Exceptions\InvalidResponseException
  414. * @throws Exceptions\LocalCacheException
  415. */
  416. public function getCardMemberCardinfo($begin_date, $end_date, $cond_source)
  417. {
  418. $data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'cond_source' => $cond_source];
  419. $url = "https://api.weixin.qq.com/datacube/getcardmembercardinfo?access_token=ACCESS_TOKEN";
  420. $this->registerApi($url, __FUNCTION__, func_get_args());
  421. return $this->httpPostForJson($url, $data);
  422. }
  423. /**
  424. * 拉取单张会员卡数据接口
  425. * @param string $begin_date 查询数据的起始时间
  426. * @param string $end_date 查询数据的截至时间
  427. * @param string $card_id 卡券id
  428. * @return array
  429. * @throws Exceptions\InvalidResponseException
  430. * @throws Exceptions\LocalCacheException
  431. */
  432. public function getCardMemberCardDetail($begin_date, $end_date, $card_id)
  433. {
  434. $data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'card_id' => $card_id];
  435. $url = "https://api.weixin.qq.com/datacube/getcardmembercarddetail?access_token=ACCESS_TOKEN";
  436. $this->registerApi($url, __FUNCTION__, func_get_args());
  437. return $this->httpPostForJson($url, $data);
  438. }
  439. /**
  440. * 拉取会员信息(积分查询)接口
  441. * @param string $card_id 查询会员卡的cardid
  442. * @param string $code 所查询会员领取到的code值
  443. * @return array
  444. * @throws Exceptions\InvalidResponseException
  445. * @throws Exceptions\LocalCacheException
  446. */
  447. public function getCardMemberCard($card_id, $code)
  448. {
  449. $data = ['card_id' => $card_id, 'code' => $code];
  450. $url = "https://api.weixin.qq.com/card/membercard/userinfo/get?access_token=ACCESS_TOKEN";
  451. $this->registerApi($url, __FUNCTION__, func_get_args());
  452. return $this->httpPostForJson($url, $data);
  453. }
  454. /**
  455. * 设置支付后投放卡券接口
  456. * @param array $data
  457. * @return array
  458. * @throws Exceptions\InvalidResponseException
  459. * @throws Exceptions\LocalCacheException
  460. */
  461. public function payGiftCard(array $data)
  462. {
  463. $url = "https://api.weixin.qq.com/card/paygiftcard/add?access_token=ACCESS_TOKEN";
  464. $this->registerApi($url, __FUNCTION__, func_get_args());
  465. return $this->httpPostForJson($url, $data);
  466. }
  467. /**
  468. * 删除支付后投放卡券规则
  469. * @param integer $rule_id 支付即会员的规则名称
  470. * @return array
  471. * @throws Exceptions\InvalidResponseException
  472. * @throws Exceptions\LocalCacheException
  473. */
  474. public function delPayGiftCard($rule_id)
  475. {
  476. $url = "https://api.weixin.qq.com/card/paygiftcard/add?access_token=ACCESS_TOKEN";
  477. $this->registerApi($url, __FUNCTION__, func_get_args());
  478. return $this->httpPostForJson($url, ['rule_id' => $rule_id]);
  479. }
  480. /**
  481. * 查询支付后投放卡券规则详情
  482. * @param integer $rule_id 要查询规则id
  483. * @return array
  484. * @throws Exceptions\InvalidResponseException
  485. * @throws Exceptions\LocalCacheException
  486. */
  487. public function getPayGiftCard($rule_id)
  488. {
  489. $url = "https://api.weixin.qq.com/card/paygiftcard/getbyid?access_token=ACCESS_TOKEN";
  490. $this->registerApi($url, __FUNCTION__, func_get_args());
  491. return $this->httpPostForJson($url, ['rule_id' => $rule_id]);
  492. }
  493. /**
  494. * 批量查询支付后投放卡券规则
  495. * @param integer $offset 起始偏移量
  496. * @param integer $count 查询的数量
  497. * @param bool $effective 是否仅查询生效的规则
  498. * @return array
  499. * @throws Exceptions\InvalidResponseException
  500. * @throws Exceptions\LocalCacheException
  501. */
  502. public function batchGetPayGiftCard($offset = 0, $count = 10, $effective = true)
  503. {
  504. $data = ['type' => 'RULE_TYPE_PAY_MEMBER_CARD', 'offset' => $offset, 'count' => $count, 'effective' => $effective];
  505. $url = "https://api.weixin.qq.com/card/paygiftcard/batchget?access_token=ACCESS_TOKEN";
  506. $this->registerApi($url, __FUNCTION__, func_get_args());
  507. return $this->httpPostForJson($url, $data);
  508. }
  509. /**
  510. * 创建支付后领取立减金活动
  511. * @param array $data
  512. * @return array
  513. * @throws Exceptions\InvalidResponseException
  514. * @throws Exceptions\LocalCacheException
  515. */
  516. public function addActivity(array $data)
  517. {
  518. $url = "https://api.weixin.qq.com/card/mkt/activity/create?access_token=ACCESS_TOKEN";
  519. $this->registerApi($url, __FUNCTION__, func_get_args());
  520. return $this->httpPostForJson($url, $data);
  521. }
  522. /**
  523. * 开通券点账户接口
  524. * @return array
  525. * @throws Exceptions\InvalidResponseException
  526. * @throws Exceptions\LocalCacheException
  527. */
  528. public function payActivate()
  529. {
  530. $url = "https://api.weixin.qq.com/card/pay/activate?access_token=ACCESS_TOKEN";
  531. $this->registerApi($url, __FUNCTION__, func_get_args());
  532. return $this->httpGetForJson($url);
  533. }
  534. /**
  535. * 对优惠券批价
  536. * @param string $card_id 需要来配置库存的card_id
  537. * @param integer $quantity 本次需要兑换的库存数目
  538. * @return array
  539. * @throws Exceptions\InvalidResponseException
  540. * @throws Exceptions\LocalCacheException
  541. */
  542. public function getPayprice($card_id, $quantity)
  543. {
  544. $url = "POST https://api.weixin.qq.com/card/pay/getpayprice?access_token=ACCESS_TOKEN";
  545. $this->registerApi($url, __FUNCTION__, func_get_args());
  546. return $this->httpPostForJson($url, ['card_id' => $card_id, 'quantity' => $quantity]);
  547. }
  548. /**
  549. * 查询券点余额接口
  550. * @return array
  551. * @throws Exceptions\InvalidResponseException
  552. * @throws Exceptions\LocalCacheException
  553. */
  554. public function getCoinsInfo()
  555. {
  556. $url = "https://api.weixin.qq.com/card/pay/getcoinsinfo?access_token=ACCESS_TOKEN";
  557. $this->registerApi($url, __FUNCTION__, func_get_args());
  558. return $this->httpGetForJson($url);
  559. }
  560. /**
  561. * 确认兑换库存接口
  562. * @param string $card_id 需要来兑换库存的card_id
  563. * @param integer $quantity 本次需要兑换的库存数目
  564. * @param string $order_id 仅可以使用上面得到的订单号,保证批价有效性
  565. * @return array
  566. * @throws Exceptions\InvalidResponseException
  567. * @throws Exceptions\LocalCacheException
  568. */
  569. public function payConfirm($card_id, $quantity, $order_id)
  570. {
  571. $data = ['card_id' => $card_id, 'quantity' => $quantity, 'order_id' => $order_id];
  572. $url = "https://api.weixin.qq.com/card/pay/confirm?access_token=ACCESS_TOKEN";
  573. $this->registerApi($url, __FUNCTION__, func_get_args());
  574. return $this->httpPostForJson($url, $data);
  575. }
  576. /**
  577. * 充值券点接口
  578. * @param integer $coin_count
  579. * @return array
  580. * @throws Exceptions\InvalidResponseException
  581. * @throws Exceptions\LocalCacheException
  582. */
  583. public function payRecharge($coin_count)
  584. {
  585. $url = "https://api.weixin.qq.com/card/pay/recharge?access_token=ACCESS_TOKEN";
  586. $this->registerApi($url, __FUNCTION__, func_get_args());
  587. return $this->httpPostForJson($url, ['coin_count' => $coin_count]);
  588. }
  589. /**
  590. * 查询订单详情接口
  591. * @param string $order_id
  592. * @return array
  593. * @throws Exceptions\InvalidResponseException
  594. * @throws Exceptions\LocalCacheException
  595. */
  596. public function payGetOrder($order_id)
  597. {
  598. $url = "https://api.weixin.qq.com/card/pay/getorder?access_token=ACCESS_TOKEN";
  599. $this->registerApi($url, __FUNCTION__, func_get_args());
  600. return $this->httpPostForJson($url, ['order_id' => $order_id]);
  601. }
  602. /**
  603. * 查询券点流水详情接口
  604. * @param array $data
  605. * @return array
  606. * @throws Exceptions\InvalidResponseException
  607. * @throws Exceptions\LocalCacheException
  608. */
  609. public function payGetList(array $data)
  610. {
  611. $url = "https://api.weixin.qq.com/card/pay/getorderlist?access_token=ACCESS_TOKEN";
  612. $this->registerApi($url, __FUNCTION__, func_get_args());
  613. return $this->httpPostForJson($url, $data);
  614. }
  615. }
  616. ?>