RefillOil.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace refill\fetch_lingzh;
  3. require_once(BASE_HELPER_RAPI_PATH . '/fetch_lingzh/config.php');
  4. use refill;
  5. class RefillOil extends refill\IRefillOil
  6. {
  7. public function __construct($cfgs)
  8. {
  9. parent::__construct($cfgs);
  10. }
  11. public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
  12. {
  13. $mod_fetch = Model('fetch_order');
  14. $count = $mod_fetch->store_order_count($this->store_id());
  15. return [config::PROCESS_ABILITY >= $count, '',false];
  16. }
  17. public function query($refill_info)
  18. {
  19. $order_sn = $refill_info['order_sn'];
  20. $store_id = $this->store_id();
  21. $mod_fetch = Model('fetch_order');
  22. $order = $mod_fetch->order_info(['order_sn' => $order_sn,'store_id' => $store_id],'*',true);
  23. if(empty($order)) {
  24. return [true, ORDER_STATE_NOEXIST];
  25. }
  26. $fetch_status = intval($order['fetch_status']);
  27. $fetch_result = $order['fetch_result'];
  28. $official_sn = $order['official_sn'];
  29. if ($fetch_status == 0) {
  30. $order_state = ORDER_STATE_CANCEL;
  31. } elseif ($fetch_status == 1 || $fetch_status == 2) {
  32. $order_state = ORDER_STATE_SEND;
  33. } elseif ($fetch_result == "SUCCESS") {
  34. $order_state = ORDER_STATE_SUCCESS;
  35. Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $official_sn]);
  36. } else {
  37. $order_state = ORDER_STATE_CANCEL;
  38. }
  39. return [true, $order_state];
  40. }
  41. }