RefillPhone.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace refill\duiba_fetch;
  3. require_once(BASE_HELPER_RAPI_PATH . '/duiba_fetch/config.php');
  4. use refill;
  5. use Log;
  6. class RefillPhone extends refill\IRefillThird
  7. {
  8. public function __construct($cfgs)
  9. {
  10. parent::__construct($cfgs);
  11. }
  12. private function req_params(int $phone, int $amount, int $card_type, string $order_sn)
  13. {
  14. $params['tel'] = $phone;
  15. $params['mch_order_id'] = $order_sn;
  16. $params['mchid'] = config::MCHID;
  17. $params['price'] = $amount;
  18. $params['notify'] = config::NOTIFY_URL;
  19. $params['teltype'] = config::operator[$card_type];
  20. $params['timeout'] = 50;
  21. $params['time'] = time();
  22. $params['rand'] = rand(100000,999999);
  23. return $params;
  24. }
  25. public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
  26. {
  27. //大面值 直接返回成功
  28. // refill\util::send_normal($params['order_sn']);
  29. return [true , '',false];
  30. }
  31. public function query($refill_info)
  32. {
  33. $params['mch_order_id'] = $refill_info['order_sn'];
  34. $params['mchid'] = config::MCHID;
  35. $content = $params['mchid'] . $params['mch_order_id'] . config::KEY;
  36. $params['sign'] = md5($content);
  37. $resp = http_request(config::QUERY_URL, $params , 'POST' , false);
  38. if ($resp === false) {
  39. return [false, '系统错误'];
  40. } else {
  41. $rand = mt_rand(0,1);
  42. return [$rand , ''];
  43. }
  44. }
  45. private function sign($params)
  46. {
  47. $key = config::KEY;
  48. $content = $params['mchid'] . $params['tel'] . $params['mch_order_id'] . $params['price'] . $params['teltype'] . $params['timeout'] . $params['notify'];
  49. $content .= $params['time'] . $params['rand'] . $key;
  50. return md5($content);
  51. }
  52. }