Просмотр исходного кода

1. 返回用户数据不包含 password
2. 门店数据接口添加 reachVip(xhShopExt表的字段)
3. 客户列表接口添加不同查询类型查询的总客户数

shizhongqi 3 месяцев назад
Родитель
Сommit
6f84b8af31

+ 4 - 0
app-hd/controllers/AuthController.php

@@ -10,6 +10,7 @@ use bizHd\admin\services\ShopAdminService;
 use bizHd\admin\services\AdminService;
 use bizHd\member\classes\MemberLevelClass;
 use bizHd\recharge\classes\RechargeSqClass;
+use bizHd\shop\classes\ShopExtClass;
 use bizHd\wx\services\WxOpenService;
 use common\components\dict;
 use common\components\httpUtil;
@@ -226,6 +227,7 @@ class AuthController extends PublicController
         $mainId = $currentShop->mainId ?? 0;
         $pfShopId = $currentShop->pfShopId ?? 0;
         $onlyCg = $currentShop->onlyCg ?? 1;
+        $shopExt = ShopExtClass::getByCondition(['shopId' => $currentShop->id], false, false, 'reachVip');
 
         $shareLogo = imgUtil::groupImg('buy_logo.jpg');
         if (isset($currentShop->shareLogo) && !empty($currentShop->shareLogo)) {
@@ -282,6 +284,7 @@ class AuthController extends PublicController
             }
         }
 
+        unset($admin['password']); //返回的用户数据删除密码字段,防止密码加密方法被反查
         //涉及几个登录的地方,需要同步修改,请搜索关键词uni_login_info
         util::success([
             'token' => $token,
@@ -297,6 +300,7 @@ class AuthController extends PublicController
             //有小程序新版本提示更新
             'update' => $remind,
             'staff' => $shopAdmin,
+            'reachVip' => $shopExt['reachVip'] //用于判断是否开启vip
         ]);
     }
 

+ 1 - 1
app-hd/controllers/BaseController.php

@@ -50,7 +50,7 @@ class BaseController extends PublicController
         if (empty($adminId) && !in_array($action->id, $this->guestAccess)) {
             util::notLogin();
         }
-        $admin = AdminClass::getById($adminId, true);
+        $admin = AdminClass::getById($adminId, true, 'password', true);
         if (empty($admin) && !in_array($action->id, $this->guestAccess)) {
             util::notLogin();
         }

+ 3 - 0
app-hd/controllers/ConsoleController.php

@@ -6,6 +6,7 @@ use bizGhs\stat\classes\StatSaleClass;
 use bizHd\custom\classes\CustomClass;
 use bizHd\goods\classes\GoodsClass;
 use bizHd\order\classes\OrderClass;
+use bizHd\shop\classes\ShopExtClass;
 use bizHd\stat\classes\StatVisitClass;
 use bizGhs\item\classes\ItemClass;
 use common\components\dict;
@@ -132,7 +133,9 @@ class ConsoleController extends BaseController
     public function actionInit()
     {
         $dict = dict::get($this->mainId);
+        $shopExt = ShopExtClass::getByCondition(['shopId' => $this->shop->id], false, false, 'reachVip');
         $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
+        $shop['reachVip'] = $shopExt['reachVip'];
         util::success(['dict' => $dict, 'shop' => $shop]);
     }
 

+ 17 - 0
app-hd/controllers/CustomController.php

@@ -239,6 +239,8 @@ class CustomController extends BaseController
         $type = $get['type'] ?? 0;
         $searchStyle = $get['searchStyle'] ?? 0;
         $where = ['shopId' => $this->shopId];
+        $all = CustomClass::getCount($where);
+
         if ($type == 1) {
             //消费排行
             $sort = 'buyAmount DESC';
@@ -249,6 +251,14 @@ class CustomController extends BaseController
             //生日
             $sort = 'birthdayTime ASC';
             $where['birthdayTime>'] = 0;
+        } else if ($type == 4) {
+            //已经删除的客户
+            $sort = 'id ASC';
+            $where['delStatus'] = 1;
+        }  else if ($type == 5) {
+            //只显示VIP用户
+            $sort = 'id ASC';
+            $where['vip'] = 1;
         } else {
             $sort = 'visitTime DESC';
         }
@@ -272,6 +282,13 @@ class CustomController extends BaseController
             }
         }
         $list = CustomService::getCustomList($where, $sort);
+        $list['all'] = $all; //全部的总人数
+        $list['balance'] = $all; //余额排行的总人数
+        $list['buyAmount'] = $all; //消费排行的总人数
+        $list['birth'] = CustomClass::getCount(array_merge(['shopId' => $this->shopId], ['birthdayTime>' => 0])); //有设置生日的总人数
+        $list['deleted']   = CustomClass::getCount(array_merge(['shopId' => $this->shopId], ['delStatus' => 1])); //被删除的总人数
+        $list['vip']   = CustomClass::getCount(array_merge(['shopId' => $this->shopId], ['vip' => 1])); //是vip的总人数
+
         util::success($list);
     }
 

+ 1 - 0
app-hd/controllers/OrderController.php

@@ -1312,6 +1312,7 @@ class OrderController extends BaseController
         }
         $list = OrderService::getOrderList($where);
         $list['shop'] = $this->shop->attributes ?? [];
+        
         util::success($list);
     }
 

+ 6 - 3
app-hd/controllers/ShopController.php

@@ -130,7 +130,10 @@ class ShopController extends BaseController
     //获取当前门店信息 ssh 2021.3.27
     public function actionCurrentShop()
     {
-        util::success($this->shop);
+        $shopExt = ShopExtClass::getByCondition(['shopId' => $this->shop->id], false, false, 'reachVip');
+        $shop = $this->shop->attributes;
+        $shop['reachVip'] = $shopExt['reachVip'];
+        util::success($shop);
     }
 
     //门店列表 ssh 20202.2.29
@@ -558,10 +561,10 @@ class ShopController extends BaseController
         $data = Yii::$app->request->post();
         $rechargeWeal = intval($data['rechargeRule']);
         $isVipMember = intval($data['isVipMember']);
-        if ($isVipMember == 1 && $data['vipAmount'] > 0) {
+        if ($isVipMember == 1 && $data['vipAmount'] >= 0) {
             $reachVip = floatval($data['vipAmount']);
         } else {
-            $reachVip = 0.00;
+            $reachVip = -1;
         }
         $hbPayable = intval($data['hbPayable']);
         if ($rechargeWeal == 2 && $hbPayable == 0) {

+ 3 - 2
common/base/classes/BaseClass.php

@@ -205,12 +205,13 @@ class BaseClass
      * @param bool $returnObject 是否返回对象
      * @param string|array $field 查询字段
      * @return array|ActiveRecord|null
+     * @param bool $reverseExclude 是否反向排除字段(传入的字段不查询,其他字段都查询出来),传 true 则反向排除,false 则正向排除,默认 false
      * @throws \Exception
      */
-    public static function getById($id, $returnObject = false, $field = '*')
+    public static function getById($id, $returnObject = false, $field = '*', $reverseExclude = false)
     {
         $model = self::getModel();
-        return $model->getById($id, $returnObject, $field);
+        return $model->getById($id, $returnObject, $field, $reverseExclude);
     }
 
     /**

+ 16 - 2
common/base/models/Base.php

@@ -3,6 +3,7 @@
 namespace common\base\models;
 
 use common\components\util;
+use Yii;
 use yii\db\ActiveRecord;
 
 class Base extends ActiveRecord
@@ -184,12 +185,25 @@ class Base extends ActiveRecord
      * @param int|string $id 主键ID
      * @param bool $returnObject 是否返回对象
      * @param string|array $field 查询字段
+     * @param bool $reverseExclude 是否反向排除字段(传入的字段不查询,其他字段都查询出来),传 true 则反向排除,false 则正向排除,默认 false
      * @return array|ActiveRecord|null
      * @throws \Exception
      */
-    public function getById($id, $returnObject = false, $field = '*')
+    public function getById($id, $returnObject = false, $field = '*', $reverseExclude = false)
     {
-        $query = $this->conditionQuery(['id' => $id])->select($field);
+        $selectField = '*';
+        if (!empty($field) && $field !== '*' && $reverseExclude == true) {
+            $excludeFields = is_array($field) ? $field : array_map('trim', explode(',', $field));
+            $allFields = $this->getFields();
+            $selectField = array_values(array_diff($allFields, $excludeFields));
+            if (empty($selectField)) {
+                Yii::error('getById: selectField is empty');
+                return null;
+            }
+        } else if (!empty($field) && $field !== '*' && $reverseExclude == false) {
+            $selectField = $field;
+        }
+        $query = $this->conditionQuery(['id' => $id])->select($selectField);
         if ($returnObject == false) {
             return $query->asArray()->one();
         } else {