shish 4 лет назад
Родитель
Сommit
d79b84fee9
2 измененных файлов с 23 добавлено и 3 удалено
  1. 21 1
      app-hd/controllers/CustomController.php
  2. 2 2
      biz-hd/custom/services/CustomService.php

+ 21 - 1
app-hd/controllers/CustomController.php

@@ -32,8 +32,28 @@ class CustomController extends BaseController
     //客户列表 ssh 2019.11.30
     public function actionList()
     {
+        $get = Yii::$app->request->get();
+        $type = isset($get['type']) ? $get['type'] : 0;
+        $name = isset($get['name']) ? $get['name'] : '';
         $where = ['shopId' => $this->shopId];
-        $list = CustomService::getCustomList($where);
+        if ($type == 1) {
+            //消费排行
+            $sort = 'buyAmount DESC';
+        } else if ($type == 2) {
+            //欠款客户
+            $where['isDebt'] = 1;
+            $sort = 'debtAmount DESC';
+        } else {
+            $sort = 'visitTime DESC';
+        }
+        if (!empty($name)) {
+            if (stringUtil::isLetter($name)) {
+                $where['py'] = ['like', $name];
+            } else {
+                $where['name'] = ['like', $name];
+            }
+        }
+        $list = CustomService::getCustomList($where, $sort);
         util::success($list);
     }
 

+ 2 - 2
biz-hd/custom/services/CustomService.php

@@ -11,9 +11,9 @@ class CustomService extends BaseService
 
     public static $baseFile = '\bizHd\custom\classes\CustomClass';
 
-    public static function getCustomList($where)
+    public static function getCustomList($where, $order='visitTime DESC')
     {
-        $data = CustomClass::getList('*', $where, 'addTime DESC');
+        $data = CustomClass::getList('*', $where, $order);
         $data['list'] = CustomClass::groupBaseInfo($data['list']);
         return $data;
     }