stanley-king 3 gadi atpakaļ
vecāks
revīzija
e35ac477bb

+ 3 - 0
helper/refill/api/xyz/xiaoniu/RefillOil.php

@@ -30,6 +30,8 @@ class RefillOil extends refill\IRefillOil
     public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
     {
         $params = $this->req_params($card_no, $amount, $params['order_sn']);
+        $card_info = refill\util::read_card($card_no,$card_type);
+        $params['mobile'] = $card_info['bind_phone'];
         $sign = $this->sign($params);
         $params['sign'] = $sign;
 
@@ -45,6 +47,7 @@ class RefillOil extends refill\IRefillOil
             if (empty($resp)) {
                 return [false, '系统错误', true];
             } elseif ($resp['code'] === '0') {
+                refill\util::inc_card($card_no,$card_info);
                 return [true, $resp['orderNo'], false];
             } else {
                 return [false, $resp['msg'], false];

+ 11 - 15
plot/MchDataCenter.py

@@ -401,8 +401,8 @@ class MchDataCenter(object):
         return predata
 
     def _calc_mratio(self,data,startes,end):
-        all = data[1] + data[2]
-        ySucc = data[1]
+        succ = data[1]
+        fail = data[2]
         x = np.arange(0, 86400, 1)
 
         result = {}
@@ -414,20 +414,17 @@ class MchDataCenter(object):
 
             pos = np.where(x >= start_pos)
             t = x[pos]
-            _all = all[pos]
-            _succ = ySucc[pos]
+            _fail = fail[pos]
+            _succ = succ[pos]
 
             pos = np.where(t < end)
-            _all = _all[pos]
+            _fail = _fail[pos]
             _succ = _succ[pos]
 
-            succ_count = np.sum(_succ)
-            all_count  = np.sum(_all) + 0.00001
-
-            ratio = round(succ_count / all_count, 4)
-            if ratio > 1.0:
-                ratio = 1.0
-            result[start] = ratio
+            succs = int(np.sum(_succ))
+            fails  = int(np.sum(_fail))
+            ratio = round((succs + 0.00001) / (succs + fails + 0.00001), 4)
+            result[start] = [succs, fails, ratio]
         return result
 
     def mratios(self, time_stamp,presecs):
@@ -566,8 +563,8 @@ class MchDataCenter(object):
             _succ = _succ[pos]
             _fail = _fail[pos]
 
-            succs = np.sum(_succ)
-            fails  = np.sum(_fail)
+            succs = int(np.sum(_succ))
+            fails = int(np.sum(_fail))
             ratio = round((succs + 0.00001) / (succs + fails + 0.00001), 4)
             result[start] = [succs, fails, ratio]
         return result
@@ -627,7 +624,6 @@ class MchDataCenter(object):
             day_stamp = self.day_stamp(time_stamp)
             result[key] = self._calc_mcount(mdata,presecs,time_stamp - day_stamp)
         hfive.close()
-
         return result
 
     def mch_counts(self):

+ 23 - 0
plot/mcounts.py

@@ -0,0 +1,23 @@
+from MchDataCenter import mchDataCenter
+import signal as sig
+import sys,getopt
+
+if __name__ == '__main__':
+    try:
+        opts, args = getopt.getopt(sys.argv[1:],"h:p:",["host=",'port='])
+    except Exception as ex:
+        print(ex)
+        sys.exit(2)
+
+    rhost = ''
+    rport=6379
+    for o, val in opts:
+        if o in ("-h", "--host"):
+            rhost = val
+        elif o in ('-p', "--port"):
+            rport = int(val)
+        else:
+            print("Err argv")
+    mchDataCenter.set_redis(rhost,rport)
+    sig.signal(sig.SIGINT, lambda: mchDataCenter.stop())
+    mchDataCenter.mch_counts()

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 1
test/TestBigData.php