stanley-king 3 年之前
父節點
當前提交
a82e6bf811
共有 2 個文件被更改,包括 66 次插入8 次删除
  1. 36 8
      admin/control/refill_order.php
  2. 30 0
      test/TestTime.php

+ 36 - 8
admin/control/refill_order.php

@@ -132,13 +132,7 @@ class refill_orderControl extends SystemControl
             $order_list[$order_id]['org_quality_text'] = $this->quality_format($order_info['org_quality'],$order_info['card_type']);
         }
 
-        $provider_list = Model('')->table('refill_provider,store')
-            ->field('refill_provider.*,store.store_name')
-            ->join('inner')
-            ->on('store.store_id=refill_provider.store_id')
-            ->order('opened asc, name asc')
-            ->limit(1000)
-            ->select();
+        $provider_list = $this->providers();
 
         if ($fShowStat) {
             $stat = $this->all_order_state_stat($condition);
@@ -177,7 +171,41 @@ class refill_orderControl extends SystemControl
                 return strcmp($lp,$rp);
             }
         };
-        
+
+        usort($items,$asc);
+        return $items;
+    }
+
+    private function providers()
+    {
+        $items = Model('')->table('refill_provider,store')
+            ->field('refill_provider.*,store.store_name')
+            ->join('inner')
+            ->on('store.store_id=refill_provider.store_id')
+            ->order('opened asc, name asc')
+            ->limit(1000)
+            ->select();
+
+        foreach ($items as &$item) {
+            $item['pinyin'] = Pinyin::getPinyin($item['store_name']);
+        }
+
+        $asc = function ($l,$r)
+        {
+            $lp = $l['pinyin'];
+            $rp = $r['pinyin'];
+
+            $lo = $l['opened'];
+            $ro = $r['opened'];
+
+            if($lo != $ro) {
+                return $lo < $ro ? -1 : 1;
+            }
+            else {
+                return strcmp($lp,$rp);
+            }
+        };
+
         usort($items,$asc);
         return $items;
     }

File diff suppressed because it is too large
+ 30 - 0
test/TestTime.php