Browse Source

提现限制

Kirin 2 years ago
parent
commit
291de70603

+ 10 - 2
app/api/controller/PublicController.php

@@ -4,6 +4,7 @@ namespace app\api\controller;
 
 use app\admin\model\store\StoreProductAttrValue;
 use app\admin\model\system\SystemAttachment;
+use app\models\system\SystemStoreCategory;
 use app\admin\model\user\UserExtract as UserExtractModel;
 use app\models\store\StoreCategory;
 use app\models\store\StoreCouponIssue;
@@ -277,19 +278,26 @@ class PublicController
         }
     }
 
+    public function store_category(Request $request)
+    {
+        $cateogry = SystemStoreCategory::with('children')->where('is_show', 1)->order('sort desc,id desc')->where('pid', 0)->select();
+        return app('json')->success($cateogry->hidden(['add_time', 'is_show', 'sort', 'children.sort', 'children.add_time', 'children.pid', 'children.is_show'])->toArray());
+    }
+
     /**
      * 门店列表
      * @return mixed
      */
     public function store_list(Request $request)
     {
-        list($latitude, $longitude, $page, $limit) = UtilService::getMore([
+        list($latitude, $longitude, $page, $limit, $cid) = UtilService::getMore([
             ['latitude', ''],
             ['longitude', ''],
             ['page', 1],
             ['limit', 10],
+            ['cid', '']
         ], $request, true);
-        $list = SystemStore::lst($latitude, $longitude, $page, $limit);
+        $list = SystemStore::lst($latitude, $longitude, $page, $limit, $cid);
         if (!$list) $list = [];
         $data['list'] = $list;
         $data['tengxun_map_key'] = sys_config('tengxun_map_key');

+ 11 - 1
app/models/system/SystemStore.php

@@ -4,6 +4,7 @@
 namespace app\models\system;
 
 use app\admin\model\system\SystemAdmin;
+use app\admin\model\system\SystemStoreCategory;
 use crmeb\traits\ModelTrait;
 use crmeb\basic\BaseModel;
 
@@ -84,11 +85,20 @@ class SystemStore extends BaseModel
      * 门店列表
      * @return mixed
      */
-    public static function lst($latitude, $longitude, $page, $limit)
+    public static function lst($latitude, $longitude, $page, $limit, $cid = '')
     {
         $model = new self();
         $model = $model->where('is_del', 0);
         $model = $model->where('is_show', 1);
+        if ($cid != '') {
+            $model = $model->where(function ($query) use ($cid) {
+                $query->where('find_in_set("' . $cid . '",cid)');
+                $cids = SystemStoreCategory::where('pid', $cid)->column('id');
+                foreach ($cids as $v) {
+                    $query->whereOr('find_in_set("' . $v . '",cid)');
+                }
+            });
+        }
 //        $model = $model->where('is_triple', 0);
         if ($latitude && $longitude) {
             $model = $model->field(['*', self::distanceSql($latitude, $longitude)])->order('distance asc');

+ 92 - 0
app/models/system/SystemStoreCategory.php

@@ -0,0 +1,92 @@
+<?php
+/**
+ *
+ * @author: xaboy<365615158@qq.com>
+ * @day: 2017/12/12
+ */
+
+namespace app\models\system;
+
+use crmeb\basic\BaseModel;
+use think\facade\Cache;
+
+/**
+ * TODO 产品分类Model
+ * Class StoreCategory
+ * @package app\models\store
+ */
+class SystemStoreCategory extends BaseModel
+{
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'system_store_category';
+
+    public static function pidByCategory($pid, $field = '*', $limit = 0)
+    {
+        $model = self::where('pid', $pid)->where('is_show', 1)->order('sort desc,id desc')->field($field);
+        if ($limit) $model->limit($limit);
+        return $model->select();
+    }
+
+    public static function pidBySidList($pid)
+    {
+        return self::where('pid', $pid)->field('id,cate_name,pid')->select();
+    }
+
+    public static function cateIdByPid($cateId)
+    {
+        return self::where('id', $cateId)->value('pid');
+    }
+
+    /*
+     * 获取一级和二级分类
+     * @return array
+     * */
+    public static function getProductCategory($expire = 800)
+    {
+        if (Cache::has('parent_category')) {
+            return Cache::get('parent_category');
+        } else {
+            $parentCategory = self::pidByCategory(0, 'id,cate_name')->toArray();
+            foreach ($parentCategory as $k => $category) {
+                $category['child'] = self::pidByCategory($category['id'], 'id,cate_name,pic')->toArray();
+                $parentCategory[$k] = $category;
+            }
+            Cache::set('parent_category', $parentCategory, $expire);
+            return $parentCategory;
+        }
+    }
+
+    /**
+     * TODO  获取首页展示的二级分类  排序默认降序
+     * @param string $field
+     * @param int $limit
+     * @return false|\PDOStatement|string|\think\Collection
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public static function byIndexList($limit = 4, bool $bool = true, $field = 'id,cate_name,pid,pic')
+    {
+        if (!$limit && !$bool) return [];
+        return self::where('pid', '>', 0)->where('is_show', 1)->field($field)->order('sort DESC')->limit($limit)->select();
+    }
+
+    /**
+     * 获取子集分类查询条件
+     * @return \think\model\relation\HasMany
+     */
+    public function children()
+    {
+        return $this->hasMany(self::class, 'pid', 'id')->where('is_show', 1)->order('sort DESC,id DESC');
+    }
+
+}