stanley-king il y a 2 ans
Parent
commit
8024871ca4

+ 17 - 4
data/model/refill_order.model.php

@@ -105,10 +105,23 @@ class refill_orderModel extends Model
         return $this->table('refill_detail')->where(['mchid' => $mchid,'mch_order' => $mch_order])->update($datas);
     }
 
-    public function exist($mchid,$mch_order)
-    {
-        $item = $this->table('refill_detail')->where(['mchid' => $mchid,'mch_order' => $mch_order])->select();
-        return !empty($item);
+    public function exist($mchid, $mch_order, $scope = false)
+    {
+        $miner = function ($time) {
+            return strtotime(date('Y-m-d',$time)) - 86400 * 15;
+        };
+        $maxer = function ($time) {
+            return $time + 3600;
+        };
+
+        $cond = ['mchid' => $mchid,'mch_order' => $mch_order];
+        if($scope) {
+            $now = time();
+            $cond['order_time'] = [['egt', $miner($now)], ['elt', $maxer($now)], 'and'];
+        }
+
+        $items = $this->table('refill_detail')->field('detail_id')->where($cond)->select();
+        return !empty($items);
     }
 
     public function getAllOrders($condition)

+ 1 - 1
mobile/control/refill.php

@@ -429,7 +429,7 @@ class refillControl extends merchantControl
             return false;
         } else {
             $refill_order = Model('refill_order');
-            $ret = $refill_order->exist($mchid, $mch_order);
+            $ret = $refill_order->exist($mchid, $mch_order, true);
             return ($ret == false);
         }
     }

+ 0 - 8
test/TestPHPLan.php

@@ -16,13 +16,5 @@ class TestPHPLan extends TestCase
             $high = array_slice($specs,$length);
         }
     }
-    public function testLastMonth()
-    {
-        $getter = function ($time) {
-            return strtotime(date('Y-m-d',$time)) - 86400 * 30;
-        };
 
-        $x = $getter(time());
-        $y = 10;
-    }
 }

+ 32 - 0
test/refill/TestPartOptimization.php

@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 2017/5/25
+ * Time: 上午10:21
+ */
+
+define('APP_ID', 'test');
+define('BASE_ROOT_PATH', str_replace('/test/refill', '', dirname(__FILE__)));
+require_once(BASE_ROOT_PATH . '/global.php');
+require_once(BASE_CORE_PATH . '/lrlz.php');
+require_once(BASE_ROOT_PATH . '/fooder.php');
+
+
+use PHPUnit\Framework\TestCase;
+class TestPartOptimization extends TestCase
+{
+    public static function setUpBeforeClass() : void
+    {
+        Base::run_util();
+    }
+
+    public function testDetailExist()
+    {
+        $refill_order = Model('refill_order');
+        $ret = $refill_order->exist(10198, '10298620105', true);
+    }
+
+
+}