浏览代码

Merge branch 'rmaster' into rtest

ayHaru 4 年之前
父节点
当前提交
3b1d0c807f

+ 2 - 12
admin/control/merchant.php

@@ -1665,12 +1665,7 @@ class merchantControl extends SystemControl
     }
 
     private function successful_where() {
-        if(defined('COMPANY_NAME') && COMPANY_NAME === 'LZKJ_COMPANY') {
-            $url = 'https://www.lzkj168.cn/plot/days';
-        }
-        else {
-            $url = 'https://www.xyzshops.cn/plot/days';
-        }
+        $url = BASE_SITE_URL . '/plot/days';
         Log::record("successful get timestamp url : {$url}", Log::DEBUG);
         $data = http_request($url);
         if(empty($data)) return [];
@@ -1685,12 +1680,7 @@ class merchantControl extends SystemControl
     }
 
     public function successful_time_get_whereOp(){
-        if(defined('COMPANY_NAME') && COMPANY_NAME === 'LZKJ_COMPANY') {
-            $url = 'https://www.lzkj168.cn/plot/paths?time_stamp='.$_GET['timestamp'];
-        }
-        else {
-            $url = 'https://www.xyzshops.cn/plot/paths?time_stamp='.$_GET['timestamp'];
-        }
+        $url = BASE_SITE_URL . '/plot/paths?time_stamp='.$_GET['timestamp'];
         Log::record("successful get where url : {$url}", Log::DEBUG);
         $data = http_request($url);
         preg_match_all('/\d{10}\/[a-z]+\/\d{1,2}\/\d\/\d{2,4}/', $data, $matches);

+ 3 - 12
admin/templates/default/provider.successful.php

@@ -158,15 +158,8 @@
                 layer.msg('请选择时间');
                 return
             }
-            let base_src = ''
-            <?php
-            if (defined('COMPANY_NAME') && COMPANY_NAME === 'LZKJ_COMPANY'){?>
-                base_src = 'https://www.lzkj168.cn';
-            <?php }else{?>
-                base_src = 'https://www.xyzshops.cn';
-            <?php }?>
-            // console.log('val', time_stamp, interval,chname,quality,card_type,amount);
-            let src = base_src+"/plot/index?time_stamp="+time+"&interval="+interval+"&chname="+chname+"&quality="+quality+"&card_type="+card_type+"&amount="+amount
+
+            let src = window.location.origin + "/plot/index?time_stamp=" + time + "&interval=" + interval + "&chname=" + chname + "&quality=" + quality + "&card_type=" + card_type + "&amount=" + amount
             if (!interval) {
                 src = src.replace("&interval=", "")
             }
@@ -182,14 +175,12 @@
             if (!amount) {
                 src = src.replace("&amount=", "")
             }
-            // $('iframe').attr('src',src)
-            // console.log('src',src);
+
             $.get(src, function (data){
                 if (!data) {
                     return
                 }
                 $('iframe').attr('src',src)
-                // console.log('data', data);
             });
         });
     })

+ 2 - 2
admin/templates/default/refill.order.index.php

@@ -225,7 +225,7 @@
                         <li class="lineLi">总计充值失败供方扣款金额:<?php echo $output['stat']['cancel']['channel_amounts'] ?? 0?></li>
                         <li class="lineLi">总计充值失败利润:<?php echo ncPriceFormat($output['stat']['cancel']['mch_amounts'] - $output['stat']['cancel']['channel_amounts'])?></li>
                     </div>
-                    <di>
+                    <div>
                         <li class="lineLi">成功率:
                             <?php
                                 $count = $output['stat']['success']['order_count'] + $output['stat']['cancel']['order_count'];
@@ -237,7 +237,7 @@
                                     echo "{$ratio}%";
                                 }
                             ?></li>
-                    </di>
+                    </div>
                 </ul>
             </td>
           </tr>

+ 32 - 7
plot/DataCenter.py

@@ -141,7 +141,7 @@ class DataCenter(object):
             print(ex)
             return []
 
-    def paths(self,time_stamp):
+    def paths(self, time_stamp):
         try:
             day_stamp = self.day_stamp(time_stamp)
             hfive = h5py.File(self._file_name, 'r')
@@ -184,10 +184,10 @@ class DataCenter(object):
             for path, data in self.read_data(hfive, paths):
                 data = np.array(data)
                 predata = predata + data
-                self._draw_plot(ax, x, day_stamp, start_pos,end_pos, data, interval, path)
+                self._draw_plot(ax, x, day_stamp, start_pos, end_pos, data, interval, path)
                 logger.info("path=%s", path)
 
-            self._draw_plot(ax, x, day_stamp, start_pos,end_pos, predata, interval, filer_text)
+            self._draw_plot(ax, x, day_stamp, start_pos, end_pos, predata, interval, filer_text)
 
             ax.legend()
             ax.grid()
@@ -208,8 +208,6 @@ class DataCenter(object):
         for path in paths:
             yield path, hfive[path]
 
-
-
     def datasets(self, hfive, start_time, **kwargs):
         logger = logging.getLogger('app')
 
@@ -269,7 +267,7 @@ class DataCenter(object):
 
         return filer_text, paths
 
-    def _draw_plot(self, ax, x, day_stamp, start_pos,end_pos, data, interval=300, path=''):
+    def _draw_plot(self, ax, x, day_stamp, start_pos, end_pos, data, interval=300, path=''):
         import matplotlib.dates as mdate
         # 'commit-succ': 0, 'commit-fail': 1, 'notify-succ': 2, 'notify-fail': 3, 'user_succ': 4
 
@@ -294,8 +292,35 @@ class DataCenter(object):
             x = x[pos]
             ySucc = ySucc[pos]
 
+        opened = np.where(ySucc > 0)
+        if len(opened) == 0:
+            return False
+
         xs = np.array([stime.strftime('%H:%M', stime.localtime(d + day_stamp)) for d in x])
         ax.yaxis.set_major_formatter(ticker.PercentFormatter(xmax=1, decimals=0))
-        ax.plot(xs, ySucc, ls='--', marker='o', label=path)
+        ax.plot(xs, ySucc, ls='--', marker='o', label=self._label(path))
+
+        return True
+
+    def _label(self,path):
+        items = re.split(r'/', path)
+        if len(items) == 6:
+            (_, _sday, _chname, _quality, _card_type, _amount) = items
+            card_type = ''
+            if _card_type == '1':
+                card_type = 'sy'
+            elif _card_type == '2':
+                card_type = 'sh'
+            elif _card_type == '4':
+                card_type = 'yd'
+            elif _card_type == '5':
+                card_type = 'lt'
+            elif _card_type == '6':
+                card_type = 'dianxin'
+            return f"{_chname}-{_quality}-{card_type}-{_amount}"
+        else:
+            return path
+
+
 
 dataCenter = DataCenter()

+ 3 - 5
plot/app.py

@@ -46,9 +46,6 @@ def index():
     else:
         interval = int(interval)
 
-    # buf = dataCenter.draw_plot(1618243200, chname=chname)
-    # , quality=quality, card_type=card_type, interval=interval,
-    #                        amount=amount)1618502478
     buf = dataCenter.draw_plot(time_stamp, interval=interval, chname=chname, quality=quality, card_type=card_type,
                                amount=amount)
     data = base64.b64encode(buf.getbuffer()).decode("ascii")
@@ -57,8 +54,9 @@ def index():
 
 @app.route('/plot/days')
 def days():
-    datas = dataCenter.days()
-    return jsonify(datas)
+    dates = dataCenter.days()
+    dates.reverse()
+    return jsonify(dates)
 
 @app.route('/plot/paths')
 def paths():

+ 1 - 1
plot/thdf5.py

@@ -60,7 +60,7 @@ class DataTest(unittest.TestCase):
         print(days)
 
     def test_data(self):
-        buf = dataCenter.draw_plot(1619020800, chname='lingzh')
+        buf = dataCenter.draw_plot(1619020800)
         img = Image.open(buf)
         img.show()
 

+ 1 - 1
test/TestTime.php

@@ -143,7 +143,7 @@ class TestTime extends TestCase
     public function testZero()
     {
         $x = time();
-        $date = date('Y-m-d H:i:s',1618243200);
+        $date = date('Y-m-d H:i:s',1619020800);
         $day_start = strtotime("{$date}");
 
     }