12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace refill\yifutong;
- require_once(BASE_HELPER_RAPI_PATH . '/yifutong/config.php');
- use refill;
- use Log;
- class RefillPhone extends refill\IRefillPhone
- {
- public function __construct($cfgs)
- {
- parent::__construct($cfgs);
- }
- public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
- {
- $mod_refill = Model('refill_order');
- $order_sn = $params['order_sn'];
- $refill_info = $mod_refill->getOrderInfo(['order_sn' => $order_sn]);
- $mch_order = $refill_info['mch_order'];
- $cbparams = refill\util::read_yifutong_order($mch_order);
- $this->send_normal($order_sn, $cbparams);
- return [true, '', false];
- }
- public static function send_normal($order_sn,$cbparams)
- {
- go(function () use ($order_sn,$cbparams)
- {
- sleep(1);
- while (true)
- {
- $net_errno = 0;
- $resp = http_request($cbparams['notify_url'],['status' => $cbparams['status'],'order_sn' => $order_sn],'GET', false, [], $net_errno);
- if($resp == 'SUCCESS') {
- break;
- }
- }
- Log::record("resp = $resp",Log::DEBUG);
- });
- }
- public function query($refill_info): array
- {
- $mod_order = Model('vr_order');
- $order_sn = $refill_info['order_sn'];
- $order_info = $mod_order->getOrderInfo(['order_sn' => $order_sn]);
- if (empty($order_info)) {
- $order_state = ORDER_STATE_NOEXIST;
- } else {
- $order_state = intval($order_info['order_state']);
- }
- return [true, $order_state, ''];
- }
- }
|