shish пре 4 година
родитељ
комит
f668a5cc6b
2 измењених фајлова са 15 додато и 8 уклоњено
  1. 14 7
      app-ghs/controllers/CustomController.php
  2. 1 1
      biz-ghs/custom/services/CustomService.php

+ 14 - 7
app-ghs/controllers/CustomController.php

@@ -118,10 +118,19 @@ class CustomController extends BaseController
         $type = isset($get['type']) ? $get['type'] : 0;
         $name = isset($get['name']) ? $get['name'] : '';
         $where = ['ownShopId' => $this->shopId];
-        //欠款客户
-        if (!empty($type) && $type == 1) {
+
+        if ($type == 1) {
+            //欠款客户
             $where['isDebt'] = 1;
+            $sort = 'debtAmount DESC';
+        } else if ($type == 2) {
+            //消费排行
+            $sort = 'buyAmount DESC';
+        } else {
+            //其它
+            $sort = 'addTime DESC';
         }
+
         if (!empty($name)) {
             if (stringUtil::isLetter($name)) {
                 $where['py'] = ['like', $name];
@@ -129,11 +138,9 @@ class CustomController extends BaseController
                 $where['name'] = ['like', $name];
             }
         }
-        if ($type == 2) {
-            $list = CustomService::getCustomOrderList($where, 'buyAmount DESC');
-        } else {
-            $list = CustomService::getCustomList($where);
-        }
+
+        $list = CustomService::getCustomSortList($where, $sort);
+
         $shop = $this->shop;
         $list['totalUser'] = $shop->totalUser ?? 0;
         $list['mayGatheringNum'] = $shop->mayGatheringNum ?? 0;

+ 1 - 1
biz-ghs/custom/services/CustomService.php

@@ -43,7 +43,7 @@ class CustomService extends BaseService
     }
 
     //有带排序的列表 shish 20210913
-    public static function getCustomOrderList($where,$order)
+    public static function getCustomSortList($where,$order)
     {
         $data = CustomClass::getList('*', $where, $order);
         $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];