stanley-king 3 years ago
parent
commit
f90295597a
2 changed files with 12 additions and 2 deletions
  1. 1 1
      helper/refill/RefillBase.php
  2. 11 1
      rdispatcher/proxy.php

+ 1 - 1
helper/refill/RefillBase.php

@@ -417,7 +417,7 @@ class RefillBase
 
                 $thrid_refill = Model('thrid_refill');
                 if($order->is_third()) {
-                    $product = $thrid_refill->getProduct(['system_code' => $order->pcode()]);
+                    $product = $thrid_refill->getProduct(['system_code' => $order->pcode(),'opened' => 1]);
                     $refill_amount = $product['refill_amount'];
                 } else {
                     $refill_amount = $order->spec();

+ 11 - 1
rdispatcher/proxy.php

@@ -189,7 +189,18 @@ class proxy
 
     public function addthird($params)
     {
+        $is_closed = function ($pcode) {
+            $thrid_refill = Model('thrid_refill');
+            $product = $thrid_refill->getProduct(['system_code' => $pcode,'opened' => 1]);
+
+            return empty($product);
+        };
+
         $order = refill\order::from_parameters($params);
+        if($is_closed($order->pcode())) {
+            return $this->onEerror($order, "{$order->pcode()} has closed.");
+        }
+
         $mchid = $order->mchid();
         $mch_order = $order->mch_order();
         $card_type = $order->card_type();
@@ -197,7 +208,6 @@ class proxy
         $org_quality = $order->org_quality();
 
         $refill_order = Model('refill_order');
-
         refill\util::push_queue_order($mchid,$mch_order,ORDER_STATE_SEND);
         $refill_order->edit_detail($mchid,$mch_order,['order_state' => ORDER_STATE_SEND]);
         refill\util::incr_user_commit($mchid,$card_type,$spec,$org_quality);