shish 5 years ago
parent
commit
d329619a41

+ 1 - 1
app/shop/controllers/AdminController.php

@@ -13,7 +13,7 @@ use biz\user\classes\UserClass;
 class AdminController extends BaseController
 {
 
-    public $withoutLoginAction = [];
+    public $guestAccessAction = [];
 
     //获取登陆员工的权限 shish 2019.11.24
     public function actionLoginAuth()

+ 20 - 23
app/shop/controllers/BaseController.php

@@ -20,16 +20,13 @@ use common\components\util;
 class BaseController extends PublicController
 {
 
-    public $admin, $adminId, $adminAvatar, $account, $customId, $custom;
+    public $admin, $adminId, $adminAvatar, $account, $customId = 0, $custom;
     public $sjId = 0, $sj = [], $sjExtend = [], $signPackage, $shopId = 0;
     public $appId;
     public $isWx = false;
     public $isLogin = false;
-    //不需要登陆的方法名
-    public $withoutLoginAction = [];
-    //需求带account请求头才能访问的方法
-    public $needShopIdAction = [];
-    public $validate = true;
+    //游客可以访问的方法
+    public $guestAccessAction = [];
 
     //shish 2020.3.8
     public function beforeAction($action)
@@ -37,11 +34,16 @@ class BaseController extends PublicController
         //token验证
         //$adminId = jwt::getLoginId();
         $adminId = 18569;
+        if (empty($adminId)) {
+            util::notLogin();
+        }
         $admin = AdminClass::getAdminById($adminId, true);
         if (empty($admin)) {
-            util::fail('帐号无效');
+            util::notLogin();
         }
         $adminId = $admin['id'];
+        $this->admin = $admin;
+        $this->adminId = $adminId;
         $header = httpUtil::getHeader();
         $shopId = $header['shop-id'] ?? 0;
         if (!empty($shopId)) {
@@ -61,30 +63,25 @@ class BaseController extends PublicController
             $sj = MerchantService::getMerchantById($sjId);
             $this->sj = $sj;
             $this->sjExtend = MerchantExtendClass::getByMerchantId($sjId);
-        } else {
-            if (in_array($action->id, $this->needShopIdAction)) {
-                util::fail('您正在访问店铺,但没有找到店铺id');
+            if (in_array($action->id, $this->guestAccessAction) == false) {
+                util::fail('此商家的页面,您没有权限访问');
             }
-            $shopId = $admin['currentShopId'] ?? 0;
-            if (!empty($shopId)) {
-                $shop = ShopService::getById($shopId);
+        } else {
+            $currentShopId = $admin['currentShopId'] ?? 0;
+            if (!empty($currentShopId)) {
+                $shop = ShopService::getById($currentShopId);
                 $sjId = $shop['merchantId'];
                 $sj = MerchantService::getMerchantById($sjId);
                 $this->sj = $sj;
-                $this->shopId = $shopId;
+                $this->shopId = $currentShopId;
                 $this->sjId = $sjId;
                 $this->sjExtend = MerchantExtendClass::getByMerchantId($sjId);
+            } else {
+                if (in_array($action->id, $this->guestAccessAction) == false) {
+                    util::fail('此管理后台页面,您没有权限访问');
+                }
             }
         }
-        $this->admin = $admin;
-        $this->adminId = $adminId;
-        //游客可以访问的方法
-        if (in_array($action->id, $this->withoutLoginAction)) {
-            $this->validate = true;
-        }
-        if ($this->validate == false) {
-            util::notLogin();
-        }
         return parent::beforeAction($action);
     }
 

+ 96 - 98
app/shop/controllers/CategoryController.php

@@ -1,10 +1,4 @@
 <?php
-/**
- * Created by PhpStorm.
- * User: admin
- * Date: 2019/12/1
- * Time: 13:55
- */
 
 namespace shop\controllers;
 
@@ -12,101 +6,105 @@ use biz\goods\services\CategoryService;
 use biz\goods\services\GoodsCategoryService;
 use Yii;
 use common\components\util;
-use yii\web\Controller;
 
 class CategoryController extends BaseController
 {
-	
-	//分类列表
-	public function actionList()
-	{
-		$list = CategoryService::getCategoryList($this->sjId);
-		util::success($list);
-	}
-	
-	//查看详情 shish 2019.12.8
-	public function actionDetail()
-	{
-		$id = Yii::$app->request->get('categoryId', 0);
-		$category = CategoryService::getById($id);
-		CategoryService::valid($category, $this->sjId);
-		$info = CategoryService::getInfo($id);
-		util::success($info);
-	}
-	
-	//添加分类 shish 2019.12.8
-	public function actionAdd()
-	{
-		$post = Yii::$app->request->post();
-		$post['merchantId'] = $this->sjId;
-		$cat = CategoryService::addCategory($post);
-		util::success(['id' => $cat['id']]);
-	}
-	
-	//更新分类 shish 2019.12.8
-	public function actionUpdate()
-	{
-		$post = Yii::$app->request->post();
-		$categoryId = isset($post['categoryId']) ? $post['categoryId'] : 0;
-		$category = CategoryService::getById($categoryId);
-		CategoryService::valid($category, $this->sjId);
-		CategoryService::updateCategory($category, $post);
-		util::complete('修改成功');
-	}
-	
-	//分类启用停用 shish 2019.12.8
-	public function actionChangeStatus()
-	{
-		$get = Yii::$app->request->get();
-		$categoryId = isset($get['categoryId']) ? $get['categoryId'] : 0;
-		$status = isset($get['status']) ? $get['status'] : 0;
-		$category = CategoryService::getById($categoryId);
-		CategoryService::valid($category, $this->sjId);
-		CategoryService::changeStatus($categoryId, $status);
-		util::complete();
-	}
-	
-	//删除分类 shish 2019.12.28
-	public function actionDelete()
-	{
-		$get = Yii::$app->request->get();
-		$categoryId = isset($get['categoryId']) ? $get['categoryId'] : 0;
-		$category = CategoryService::getById($categoryId);
-		CategoryService::valid($category, $this->sjId);
-		CategoryService::deleteCategory($categoryId);
-		util::complete('删除成功');
-	}
-	
-	//取分类下商品 shish 2019.12.2
-	public function actionGoodsList()
-	{
-		$categoryId = Yii::$app->request->get('categoryId');
-		//没有分类默认取商家第一个分类
-		$categoryId = !empty($categoryId) ? $categoryId : CategoryService::getTopCategoryId($this->sjId);
-		$where = [];
-		$where['merchantId'] = $this->sjId;
-		$where['cId'] = $categoryId;
-		$where['delStatus'] = 0;
-		$data = GoodsCategoryService::getGoodsList($where);
-		util::success($data);
-	}
 
-	//分类排序 shish 2020.3.11
-	public function actionSort()
-	{
-		$id = Yii::$app->request->get('id', 0);
-		$inTurn = Yii::$app->request->get('inTurn', 0);
-		$category = CategoryService::getById($id);
-		CategoryService::valid($category, $this->sjId);
-		CategoryService::updateById($id, ['inTurn' => $inTurn]);
-		util::complete();
-	}
-	
-	//获取分类 shish 2019.12.2
-	public function actionMallList()
-	{
-		$return = CategoryService::getEnableList($this->sjId);
-		util::success($return);
-	}
+    //分类列表
+    public function actionList()
+    {
+        $list = CategoryService::getCategoryList($this->sjId);
+        util::success($list);
+    }
+
+    //查看详情 shish 2019.12.8
+    public function actionDetail()
+    {
+        $id = Yii::$app->request->get('categoryId', 0);
+        $category = CategoryService::getById($id);
+        CategoryService::valid($category, $this->sjId);
+        $info = CategoryService::getInfo($id);
+        util::success($info);
+    }
+
+    //添加分类 shish 2019.12.8
+    public function actionAdd()
+    {
+        $post = Yii::$app->request->post();
+        $post['merchantId'] = $this->sjId;
+        $cat = CategoryService::addCategory($post);
+        util::success(['id' => $cat['id']]);
+    }
+
+    //更新分类 shish 2019.12.8
+    public function actionUpdate()
+    {
+        $post = Yii::$app->request->post();
+        $categoryId = isset($post['categoryId']) ? $post['categoryId'] : 0;
+        $category = CategoryService::getById($categoryId);
+        CategoryService::valid($category, $this->sjId);
+        CategoryService::updateCategory($category, $post);
+        util::complete('修改成功');
+    }
+
+    //分类启用停用 shish 2019.12.8
+    public function actionChangeStatus()
+    {
+        $get = Yii::$app->request->get();
+        $categoryId = isset($get['categoryId']) ? $get['categoryId'] : 0;
+        $status = isset($get['status']) ? $get['status'] : 0;
+        $category = CategoryService::getById($categoryId);
+        CategoryService::valid($category, $this->sjId);
+        CategoryService::changeStatus($categoryId, $status);
+        util::complete();
+    }
+
+    //删除分类 shish 2019.12.28
+    public function actionDelete()
+    {
+        $get = Yii::$app->request->get();
+        $categoryId = isset($get['categoryId']) ? $get['categoryId'] : 0;
+        $category = CategoryService::getById($categoryId);
+        CategoryService::valid($category, $this->sjId);
+        CategoryService::deleteCategory($categoryId);
+        util::complete('删除成功');
+    }
+
+    //取分类下商品 shish 2019.12.2
+    public function actionGoodsList()
+    {
+        $categoryId = Yii::$app->request->get('categoryId', 0);
+        //没有分类默认取商家第一个分类
+        if (empty($categoryId)) {
+            $categoryId = CategoryService::getTopCategoryId($this->sjId);
+        }
+        if (empty($categoryId)) {
+            util::fail('没有找商品分类');
+        }
+        $where = [];
+        $where['merchantId'] = $this->sjId;
+        $where['cId'] = $categoryId;
+        $where['delStatus'] = 0;
+        $data = GoodsCategoryService::getGoodsList($where);
+        util::success($data);
+    }
+
+    //分类排序 shish 2020.3.11
+    public function actionSort()
+    {
+        $id = Yii::$app->request->get('id', 0);
+        $inTurn = Yii::$app->request->get('inTurn', 0);
+        $category = CategoryService::getById($id);
+        CategoryService::valid($category, $this->sjId);
+        CategoryService::updateById($id, ['inTurn' => $inTurn]);
+        util::complete();
+    }
+
+    //获取分类 shish 2019.12.2
+    public function actionMallList()
+    {
+        $return = CategoryService::getEnableList($this->sjId);
+        util::success($return);
+    }
 
 }

+ 3 - 24
app/shop/controllers/CustomController.php

@@ -4,6 +4,7 @@ namespace shop\controllers;
 
 use biz\admin\services\AdminService;
 use biz\custom\classes\CustomClass;
+use biz\custom\services\CustomService;
 use biz\merchant\services\MerchantAssetService;
 use biz\merchant\services\MerchantRemarkService;
 use biz\user\services\UserAssetService;
@@ -29,30 +30,8 @@ class CustomController extends BaseController
     //客户列表 shish 2019.11.30
     public function actionList()
     {
-        $get = Yii::$app->request->get();
-        $type = isset($get['type']) ? $get['type'] : -1;
-        $search = isset($get['search']) ? $get['search'] : '';
-        $where = ['merchantId' => $this->sjId];
-        switch ($type) {
-            case 1:
-                //粉丝
-                $where['subscribe'] = 1;
-                break;
-            case 2:
-                //会员
-                $where['member>'] = 0;
-                break;
-            default:
-        }
-        if (!empty($search)) {
-            if (stringUtil::isMobile($search)) {
-                $where['mobile'] = $search;
-            } else {
-                $where['userName'] = ['like', $search];
-            }
-        }
-        $list = UserService::getUserList($where);
-        $list['asset'] = MerchantAssetService::getByMerchantId($this->sjId);
+        $where = ['sjId' => $this->sjId];
+        $list = CustomService::getCustomList($where);
         util::success($list);
     }
 

+ 175 - 170
app/shop/controllers/GoodsController.php

@@ -1,6 +1,8 @@
 <?php
+
 namespace shop\controllers;
 
+use biz\goods\classes\GoodsClass;
 use biz\goods\services\CategoryService;
 use biz\goods\services\GoodsCategoryService;
 use biz\goods\services\GoodsSettingService;
@@ -13,174 +15,177 @@ use yii\web\Controller;
 
 class GoodsController extends BaseController
 {
-	
-	//商品列表 shish 2019.12.7
-	public function actionList()
-	{
-		$get = Yii::$app->request->get();
-		$status = isset($get['status']) ? $get['status'] : -1;
-		$goodsName = isset($get['goodsName']) && !empty($get['goodsName']) ? $get['goodsName'] : '';
-		$where = [];
-		if ($status != -1) {
-			$where['status'] = $status;
-		}
-		if (!empty($goodsName)) {
-			$where['goodsName'] = ['like', $goodsName];
-		}
-		if (isset($get['cId']) && $get['cId'] != -1) {
-			$where['cId'] = $get['cId'];
-		}
-		$where['merchantId'] = $this->sjId;
-		$where['delStatus'] = 0;
-		$data = GoodsService::getGoodsList($where);
-		$asset = MerchantAssetService::getByMerchantId($this->sjId);
-		$data['MerchantAsset'] = $asset;
-		util::success($data);
-	}
-	
-	//添加商品 shish 2019.12.7
-	public function actionAdd()
-	{
-		$data = Yii::$app->request->post();
-		$data['merchantId'] = $this->sjId;
-		$return = GoodsService::addGoods($data);
-		$id = $return['id'];
-		$info = GoodsService::getById($id);
-		util::success($info);
-	}
-	
-	//获取商品详情 shish 2019.12.7
-	public function actionDetail()
-	{
-		$id = Yii::$app->request->get('id');
-		$goods = GoodsService::getGoodsInfo($id);
-		util::success($goods);
-	}
-	
-	//更新商品 shish 2019.12.7
-	public function actionUpdate()
-	{
-		$data = Yii::$app->request->post();
-		$id = isset($data['id']) ? $data['id'] : 0;
-		$info = GoodsService::getById($id);
-		GoodsService::valid($info, $this->sjId);
-		$data['merchantId'] = $this->sjId;
-		GoodsService::updateGoods($id, $data);
-		util::complete();
-	}
-	
-	//商品排序 shish 2020.3.11
-	public function actionSort()
-	{
-		$id = Yii::$app->request->get('id', 0);
-		$cId = Yii::$app->request->get('cId', 0);
-		$inTurn = Yii::$app->request->get('inTurn', 0);
-		//验证商品
-		$info = GoodsService::getById($id);
-		GoodsService::valid($info, $this->sjId);
-		if ($cId != 0) {
-			//验证分类
-			$category = CategoryService::getById($cId);
-			CategoryService::valid($category, $this->sjId);
-			GoodsCategoryService::updateByCondition(['cId' => $cId, 'gId' => $id], ['inTurn' => $inTurn]);
-		} else {
-			GoodsService::updateById($id, ['inTurn' => $inTurn]);
-			GoodsCategoryService::updateByCondition(['gId' => $id], ['inTurn' => $inTurn]);
-		}
-		util::complete('操作成功');
-	}
-	
-	//删除商品 shish 2019.12.7
-	public function actionDelete()
-	{
-		$id = Yii::$app->request->get('id', 0);
-		$goods = GoodsService::getById($id);
-		GoodsService::valid($goods, $this->sjId);
-		GoodsService::deleteGoods($goods);
-		util::complete();
-	}
-	
-	//上下架 shish 2019.12.8
-	public function actionChangeStatus()
-	{
-		$post = Yii::$app->request->post();
-		$id = isset($post['id']) ? $post['id'] : 0;
-		$status = isset($post['status']) ? $post['status'] : 1;
-		$info = GoodsService::getById($id);
-		GoodsService::valid($info, $this->sjId);
-		GoodsService::changeStatus($id, $status);
-		util::complete();
-	}
-	
-	//发送短链接到手机上 shish 2019.12.8
-	public function actionSendShortUrl()
-	{
-		$id = Yii::$app->request->get('id');
-		util::complete();
-	}
-	
-	//查看商品短链接 shish 2019.12.8
-	public function actionShortUrl()
-	{
-		$id = Yii::$app->request->get('id');
-		util::success(['shortUrl' => 'https://w.url.cn/s/A8iQl2r']);
-	}
-	
-	//商品说明 shish 2019.12.8
-	public function actionIntroduce()
-	{
-		$set = GoodsSettingService::getByCondition(['merchantId' => $this->sjId]);
-		$introduce = $set['goodsIntroduce'];
-		util::success(['introduce' => $introduce]);
-	}
-	
-	//修改商品说明 shish 2019.12.8
-	public function actionUpdateIntroduce()
-	{
-		$introduce = Yii::$app->request->post('introduce', '');
-		GoodsSettingService::updateByCondition(['merchantId' => $this->sjId], ['goodsIntroduce' => $introduce]);
-		util::complete('提交成功');
-	}
-	
-	//设置 shish 2019.12.8
-	public function actionSetting()
-	{
-		$return = GoodsSettingService::getSetting($this->sjId);
-		util::success($return);
-	}
-	
-	//更新涨价 shish 2019.12.9
-	public function actionUpdateRise()
-	{
-		$post = Yii::$app->request->post();
-		$festIdList = isset($post['festIdList']) && !empty($post['festIdList']) ? $post['festIdList'] : [];
-		unset($post['festIdList']);
-		$riseSwitch = isset($post['riseSwitch']) && is_numeric($post['riseSwitch']) ? $post['riseSwitch'] : 1;
-		if ($riseSwitch == 1) {
-			if (empty($festIdList)) {
-				util::fail('请选择节日');
-			}
-			FestRiseService::deleteByCondition(['merchantId' => $this->sjId]);
-			$add = [];
-			foreach ($festIdList as $festId) {
-				$add[] = ['merchantId' => $this->sjId, 'festId' => $festId];
-			}
-			FestRiseService::batchAdd($add);
-		}
-		GoodsSettingService::updateByCondition(['merchantId' => $this->sjId], $post);
-		util::complete('提交成功');
-	}
-
-	//获取商品详情 shish 2019.12.3
-	public function actionMallDetail()
-	{
-		$id = Yii::$app->request->get('id', 0);
-		$info = GoodsService::getGoodsInfo($id);
-		GoodsService::valid($info, $this->sjId);
-		$setting = GoodsSettingService::getByCondition(['merchantId' => $this->sjId]);
-		$commonIntro = isset($setting['goodsIntroduce']) ? $setting['goodsIntroduce'] : '';
-		$info['commonIntro'] = $commonIntro;
-		util::success($info);
-	}
-	
+
+    public $guestAccessAction = ['detail'];
+
+    //商品列表 shish 2019.12.7
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $status = isset($get['status']) ? $get['status'] : -1;
+        $goodsName = isset($get['goodsName']) && !empty($get['goodsName']) ? $get['goodsName'] : '';
+        $where = [];
+        if ($status != -1) {
+            $where['status'] = $status;
+        }
+        if (!empty($goodsName)) {
+            $where['goodsName'] = ['like', $goodsName];
+        }
+        if (isset($get['cId']) && $get['cId'] != -1) {
+            $where['cId'] = $get['cId'];
+        }
+        $where['merchantId'] = $this->sjId;
+        $where['delStatus'] = 0;
+        $data = GoodsService::getGoodsList($where);
+        $asset = MerchantAssetService::getByMerchantId($this->sjId);
+        $data['MerchantAsset'] = $asset;
+        util::success($data);
+    }
+
+    //添加商品 shish 2019.12.7
+    public function actionAdd()
+    {
+        $data = Yii::$app->request->post();
+        $data['merchantId'] = $this->sjId;
+        $return = GoodsService::addGoods($data);
+        $id = $return['id'];
+        $info = GoodsService::getById($id);
+        util::success($info);
+    }
+
+    //获取商品详情 shish 2019.12.7
+    public function actionDetail()
+    {
+        $id = Yii::$app->request->get('id');
+        $goods = GoodsService::getGoodsInfo($id);
+        GoodsClass::valid($goods, $this->sjId);
+        util::success($goods);
+    }
+
+    //更新商品 shish 2019.12.7
+    public function actionUpdate()
+    {
+        $data = Yii::$app->request->post();
+        $id = isset($data['id']) ? $data['id'] : 0;
+        $info = GoodsService::getById($id);
+        GoodsService::valid($info, $this->sjId);
+        $data['merchantId'] = $this->sjId;
+        GoodsService::updateGoods($id, $data);
+        util::complete();
+    }
+
+    //商品排序 shish 2020.3.11
+    public function actionSort()
+    {
+        $id = Yii::$app->request->get('id', 0);
+        $cId = Yii::$app->request->get('cId', 0);
+        $inTurn = Yii::$app->request->get('inTurn', 0);
+        //验证商品
+        $info = GoodsService::getById($id);
+        GoodsService::valid($info, $this->sjId);
+        if ($cId != 0) {
+            //验证分类
+            $category = CategoryService::getById($cId);
+            CategoryService::valid($category, $this->sjId);
+            GoodsCategoryService::updateByCondition(['cId' => $cId, 'gId' => $id], ['inTurn' => $inTurn]);
+        } else {
+            GoodsService::updateById($id, ['inTurn' => $inTurn]);
+            GoodsCategoryService::updateByCondition(['gId' => $id], ['inTurn' => $inTurn]);
+        }
+        util::complete('操作成功');
+    }
+
+    //删除商品 shish 2019.12.7
+    public function actionDelete()
+    {
+        $id = Yii::$app->request->get('id', 0);
+        $goods = GoodsService::getById($id);
+        GoodsService::valid($goods, $this->sjId);
+        GoodsService::deleteGoods($goods);
+        util::complete();
+    }
+
+    //上下架 shish 2019.12.8
+    public function actionChangeStatus()
+    {
+        $post = Yii::$app->request->post();
+        $id = isset($post['id']) ? $post['id'] : 0;
+        $status = isset($post['status']) ? $post['status'] : 1;
+        $info = GoodsService::getById($id);
+        GoodsService::valid($info, $this->sjId);
+        GoodsService::changeStatus($id, $status);
+        util::complete();
+    }
+
+    //发送短链接到手机上 shish 2019.12.8
+    public function actionSendShortUrl()
+    {
+        $id = Yii::$app->request->get('id');
+        util::complete();
+    }
+
+    //查看商品短链接 shish 2019.12.8
+    public function actionShortUrl()
+    {
+        $id = Yii::$app->request->get('id');
+        util::success(['shortUrl' => 'https://w.url.cn/s/A8iQl2r']);
+    }
+
+    //商品说明 shish 2019.12.8
+    public function actionIntroduce()
+    {
+        $set = GoodsSettingService::getByCondition(['merchantId' => $this->sjId]);
+        $introduce = $set['goodsIntroduce'];
+        util::success(['introduce' => $introduce]);
+    }
+
+    //修改商品说明 shish 2019.12.8
+    public function actionUpdateIntroduce()
+    {
+        $introduce = Yii::$app->request->post('introduce', '');
+        GoodsSettingService::updateByCondition(['merchantId' => $this->sjId], ['goodsIntroduce' => $introduce]);
+        util::complete('提交成功');
+    }
+
+    //设置 shish 2019.12.8
+    public function actionSetting()
+    {
+        $return = GoodsSettingService::getSetting($this->sjId);
+        util::success($return);
+    }
+
+    //更新涨价 shish 2019.12.9
+    public function actionUpdateRise()
+    {
+        $post = Yii::$app->request->post();
+        $festIdList = isset($post['festIdList']) && !empty($post['festIdList']) ? $post['festIdList'] : [];
+        unset($post['festIdList']);
+        $riseSwitch = isset($post['riseSwitch']) && is_numeric($post['riseSwitch']) ? $post['riseSwitch'] : 1;
+        if ($riseSwitch == 1) {
+            if (empty($festIdList)) {
+                util::fail('请选择节日');
+            }
+            FestRiseService::deleteByCondition(['merchantId' => $this->sjId]);
+            $add = [];
+            foreach ($festIdList as $festId) {
+                $add[] = ['merchantId' => $this->sjId, 'festId' => $festId];
+            }
+            FestRiseService::batchAdd($add);
+        }
+        GoodsSettingService::updateByCondition(['merchantId' => $this->sjId], $post);
+        util::complete('提交成功');
+    }
+
+    //获取商品详情 shish 2019.12.3
+    public function actionMallDetail()
+    {
+        $id = Yii::$app->request->get('id', 0);
+        $info = GoodsService::getGoodsInfo($id);
+        GoodsService::valid($info, $this->sjId);
+        $setting = GoodsSettingService::getByCondition(['merchantId' => $this->sjId]);
+        $commonIntro = isset($setting['goodsIntroduce']) ? $setting['goodsIntroduce'] : '';
+        $info['commonIntro'] = $commonIntro;
+        util::success($info);
+    }
+
 }

+ 0 - 2
app/shop/controllers/MainController.php

@@ -11,8 +11,6 @@ use common\components\util;
 class MainController extends BaseController
 {
 
-    public $needShopIdAction = ['index'];
-
     public function actionDemo()
     {
         return $this->renderPartial('demo');

+ 1 - 1
app/shop/controllers/MapController.php

@@ -9,7 +9,7 @@ use Yii;
 class MapController extends BaseController
 {
 	
-	public $withoutLoginAction = ['suggestion'];
+	public $guestAccessAction = ['suggestion'];
 	
 	//腾讯地图关键词输入提醒 shish 2020.1.21
 	public function actionSuggestion()

+ 11 - 11
app/shop/controllers/OrderController.php

@@ -29,9 +29,7 @@ use yii\web\Controller;
 class OrderController extends BaseController
 {
 
-    public $withoutLoginAction = ['order-relate', 'fast-pay'];
-
-    public $needShopIdAction = ['order-relate'];
+    public $guestAccessAction = ['order-relate', 'fast-pay', 'create-order', 'list'];
 
     //商城下单操作 shish 2019.12.3
     public function actionCreateOrder()
@@ -53,14 +51,16 @@ class OrderController extends BaseController
         }
         //运费计算方式
         $freightType = isset($goodsInfo['freightType']) ? $goodsInfo['freightType'] : 0;
-
-        $post['userId'] = $this->adminId;
-        $user = $this->user;
-        $post['bookName'] = isset($user['userName']) ? $user['userName'] : '';
+        $customId = $post['customId'] ?? 0;
+        if (!empty($customId)) {
+            $customId = $this->customId;
+        }
+        $post['customId'] = $customId;
+        $user = $this->custom;
+        $post['bookName'] = isset($user['name']) ? $user['name'] : '';
         $bookMobile = isset($post['bookMobile']) && !empty($post['bookMobile']) && stringUtil::isMobile($post['bookMobile']) ? $post['bookMobile'] : '';
         $bookMobile = empty($bookMobile) && isset($user['mobile']) && !empty($user['mobile']) ? $user['mobile'] : $bookMobile;
         $post['bookMobile'] = $bookMobile;
-
         $post['payWay'] = $this->isWx == true ? 0 : 1;
         $defaultShopId = MerchantService::getDefaultShopId($this->sj);
         if (empty($defaultShopId)) {
@@ -280,10 +280,10 @@ class OrderController extends BaseController
         $fromType = $sourceType == 3 ? 2 : 0;
         $fromType = isset($post['fromType']) && !empty($post['fromType']) ? $post['fromType'] : $fromType;
         $post['userId'] = $this->adminId;
-        $user = $this->user;
-        $post['bookName'] = isset($user['userName']) ? $user['userName'] : '';
+        $custom = $this->custom;
+        $post['bookName'] = $custom['userName'] ?? '';
         $bookMobile = isset($post['bookMobile']) && !empty($post['bookMobile']) && stringUtil::isMobile($post['bookMobile']) ? $post['bookMobile'] : '';
-        $bookMobile = empty($bookMobile) && isset($user['mobile']) && !empty($user['mobile']) ? $user['mobile'] : $bookMobile;
+        $bookMobile = empty($bookMobile) && isset($custom['mobile']) && !empty($custom['mobile']) ? $custom['mobile'] : $bookMobile;
         $post['bookMobile'] = $bookMobile;
         $prePrice = round($post['prePrice'], 2);
         $couponId = isset($post['couponId']) ? $post['couponId'] : 0;

+ 141 - 128
app/shop/controllers/ShopController.php

@@ -18,132 +18,145 @@ use yii\web\Controller;
 
 class ShopController extends BaseController
 {
-	
-	//门店列表 shish 20202.2.29
-	public function actionList()
-	{
-		$where = [];
-		$where['merchantId'] = $this->sjId;
-		$where['delStatus'] = 0;
-		$list = ShopService::getShopList($where);
-		util::success($list);
-	}
-	
-	//更新门店 shish 2020.2.29
-	public function actionUpdate()
-	{
-		$data = Yii::$app->request->post();
-		$data['merchantId'] = $this->sjId;
-		$id = isset($data['id']) ? $data['id'] : 0;
-		unset($data['id']);
-		$shop = ShopService::getById($id);
-		ShopService::valid($shop, $this->sjId);
-		ShopService::updateShop($id, $data);
-		util::complete();
-	}
-	
-	public function actionAdd()
-	{
-		$data = Yii::$app->request->post();
-		$data['merchantId'] = $this->sjId;
-		ShopService::addShop($data);
-		util::complete();
-	}
-	
-	//下载微信和支付宝收款码 shish 2020.2.29
-	public function actionGatheringCode()
-	{
-		$id = Yii::$app->request->get('id', 0);
-		$shop = ShopService::getById($id);
-		ShopService::valid($shop, $this->sjId);
-		$gatheringCode = ShopService::generateGatheringCode($this->sjId, $id);
-		$file = dirUtil::getImgDir() . $gatheringCode;
-		if (file_exists($file) == false) {
-			util::fail('没有找到收款码');
-		}
-		$fileName = "门店({$id})收款码.jpg";
-		$contentType = 'image/jpeg';
-		header("Cache-control: private");
-		header("Content-type: $contentType"); //设置要下载的文件类型
-		header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
-		header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
-		readfile($file);
-	}
-	
-	//获取小程序的收款码 shish
-	public function actionGatheringMiniCode()
-	{
-		$id = Yii::$app->request->get('id', 0);
-		$extend = MerchantExtendService::getByMerchantId($this->sjId);
-		if ($extend['miniAuth'] == 0) {
-			util::fail('您的小程序还没有授权');
-		}
-		$shop = ShopService::getById($id);
-		ShopService::valid($shop, $this->sjId);
-		$applyMemberCode = wxUtil::generateGatheringMiniCode($this->sj, $id);
-		$file = dirUtil::getImgDir() . $applyMemberCode;
-		if (file_exists($file) == false) {
-			util::fail('没有找到注册会员码');
-		}
-		$fileName = "门店({$id})小程序收款码.jpg";
-		$contentType = 'image/jpeg';
-		header("Cache-control: private");
-		header("Content-type: $contentType"); //设置要下载的文件类型
-		header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
-		header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
-		readfile($file);
-	}
-	
-	//下载会员注册码 shish 2020.2.29
-	public function actionApplyMemberCode()
-	{
-		$id = Yii::$app->request->get('id', 0);
-		$extend = MerchantExtendService::getByMerchantId($this->sjId);
-		if ($extend['miniAuth'] == 0) {
-			util::fail('您的小程序还没有授权');
-		}
-		$shop = ShopService::getById($id);
-		ShopService::valid($shop, $this->sjId);
-		$applyMemberCode = wxUtil::generateMemberCode($this->sj, $id);
-		$file = dirUtil::getImgDir() . $applyMemberCode;
-		if (file_exists($file) == false) {
-			util::fail('没有找到注册会员码');
-		}
-		$fileName = "注册会员码{$id}.jpg";
-		$contentType = 'image/jpeg';
-		header("Cache-control: private");
-		header("Content-type: $contentType"); //设置要下载的文件类型
-		header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
-		header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
-		readfile($file);
-	}
-	
-	//删除门店 shish 2020.3.1
-	public function actionDelete()
-	{
-		$id = Yii::$app->request->get('id', 0);
-		util::fail('功能开发中');
-		$shop = ShopService::getById($id);
-		ShopService::valid($shop, $this->sjId);
-		ShopService::deleteShop($shop);
-		util::complete();
-	}
-	
-	//获取商家的默认门店 shish 2019.12.6
-	public function actionDetail()
-	{
-		$introUserId = Yii::$app->request->get('introUserId');
-		$merchant = $this->sj;
-		$shop = ShopService::getDefaultShop($merchant);
-		$ad = AdService::getValidAdList($this->sjId);
-		
-		//新人专享礼物
-		$newUserGift = [];
-		if (!empty($introUserId)) {
-			$userInfo = UserService::getUserInfo($this->adminId);
-			$newUserGift = InviteService::hasNewGift($userInfo);
-		}
-		util::success(['ad' => $ad, 'shop' => $shop, 'newUserGift' => $newUserGift]);
-	}
-	
+
+    //门店列表 shish 20202.2.29
+    public function actionList()
+    {
+        $where = [];
+        $where['merchantId'] = $this->sjId;
+        $where['delStatus'] = 0;
+        $list = ShopService::getShopList($where);
+        util::success($list);
+    }
+
+    //更新门店 shish 2020.2.29
+    public function actionUpdate()
+    {
+        $data = Yii::$app->request->post();
+        $data['merchantId'] = $this->sjId;
+        $id = isset($data['id']) ? $data['id'] : 0;
+        unset($data['id']);
+        $shop = ShopService::getById($id);
+        ShopService::valid($shop, $this->sjId);
+        ShopService::updateShop($id, $data);
+        util::complete();
+    }
+
+    public function actionAdd()
+    {
+        $data = Yii::$app->request->post();
+        $data['merchantId'] = $this->sjId;
+        ShopService::addShop($data);
+        util::complete();
+    }
+
+    //下载微信和支付宝收款码 shish 2020.2.29
+    public function actionGatheringCode()
+    {
+        $id = Yii::$app->request->get('id', 0);
+        $shop = ShopService::getById($id);
+        ShopService::valid($shop, $this->sjId);
+        $gatheringCode = ShopService::generateGatheringCode($this->sjId, $id);
+        $file = dirUtil::getImgDir() . $gatheringCode;
+        if (file_exists($file) == false) {
+            util::fail('没有找到收款码');
+        }
+        $fileName = "门店({$id})收款码.jpg";
+        $contentType = 'image/jpeg';
+        header("Cache-control: private");
+        header("Content-type: $contentType"); //设置要下载的文件类型
+        header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
+        header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
+        readfile($file);
+    }
+
+    //获取小程序的收款码 shish
+    public function actionGatheringMiniCode()
+    {
+        $id = Yii::$app->request->get('id', 0);
+        $extend = MerchantExtendService::getByMerchantId($this->sjId);
+        if ($extend['miniAuth'] == 0) {
+            util::fail('您的小程序还没有授权');
+        }
+        $shop = ShopService::getById($id);
+        ShopService::valid($shop, $this->sjId);
+        $applyMemberCode = wxUtil::generateGatheringMiniCode($this->sj, $id);
+        $file = dirUtil::getImgDir() . $applyMemberCode;
+        if (file_exists($file) == false) {
+            util::fail('没有找到注册会员码');
+        }
+        $fileName = "门店({$id})小程序收款码.jpg";
+        $contentType = 'image/jpeg';
+        header("Cache-control: private");
+        header("Content-type: $contentType"); //设置要下载的文件类型
+        header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
+        header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
+        readfile($file);
+    }
+
+    //下载会员注册码 shish 2020.2.29
+    public function actionApplyMemberCode()
+    {
+        $id = Yii::$app->request->get('id', 0);
+        $extend = MerchantExtendService::getByMerchantId($this->sjId);
+        if ($extend['miniAuth'] == 0) {
+            util::fail('您的小程序还没有授权');
+        }
+        $shop = ShopService::getById($id);
+        ShopService::valid($shop, $this->sjId);
+        $applyMemberCode = wxUtil::generateMemberCode($this->sj, $id);
+        $file = dirUtil::getImgDir() . $applyMemberCode;
+        if (file_exists($file) == false) {
+            util::fail('没有找到注册会员码');
+        }
+        $fileName = "注册会员码{$id}.jpg";
+        $contentType = 'image/jpeg';
+        header("Cache-control: private");
+        header("Content-type: $contentType"); //设置要下载的文件类型
+        header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
+        header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
+        readfile($file);
+    }
+
+    //删除门店 shish 2020.3.1
+    public function actionDelete()
+    {
+        $id = Yii::$app->request->get('id', 0);
+        util::fail('功能开发中');
+        $shop = ShopService::getById($id);
+        ShopService::valid($shop, $this->sjId);
+        ShopService::deleteShop($shop);
+        util::complete();
+    }
+
+    //获取商家的默认门店 shish 2019.12.6
+    public function actionDetail()
+    {
+        $introUserId = Yii::$app->request->get('introUserId');
+        //$merchant = $this->sj;
+        //$shop = ShopService::getDefaultShop($merchant);
+        //$ad = AdService::getValidAdList($this->sjId);
+        //新人专享礼物
+        $newUserGift = [
+            [
+                'adImgUrl' => "https://img.huahb.com/uploads/12358/202006/03/20210120220152.jpg",
+                'adName' => '图片',
+            ],
+        ];
+        if (!empty($introUserId)) {
+            //$userInfo = UserService::getUserInfo($this->adminId);
+            //$newUserGift = InviteService::hasNewGift($userInfo);
+        }
+        $ad = [];
+        $shop = [
+            'address' => '福建省厦门市思明区后埭溪路128-5号',
+            'telephone' => '15280215347',
+            'openTime' => '09:00--18:00',
+            'shopName' => '国兰花尚',
+            'merchantName' => '国兰花尚2',
+            'introduction' => '门店介绍',
+        ];
+        util::success(['ad' => $ad, 'shop' => $shop, 'newUserGift' => $newUserGift]);
+    }
+
 }

+ 1 - 1
app/shop/controllers/TestController.php

@@ -13,7 +13,7 @@ use common\components\util;
 class TestController extends BaseController
 {
 
-	public $withoutLoginAction = ['inform', 'notice','order-query','add-order'];
+	public $guestAccessAction = ['inform', 'notice','order-query','add-order'];
 
 	//新增订单
 	public function actionAddOrder()

+ 1 - 1
app/shop/controllers/UploadController.php

@@ -15,7 +15,7 @@ use yii\imagine\Image;
 class UploadController extends BaseController
 {
 	
-	public $withoutLoginAction = [];
+	public $guestAccessAction = [];
 	
 	//上传图片接口
 	public function actionSaveImg()

+ 38 - 17
app/shop/controllers/UserController.php

@@ -3,7 +3,9 @@
 namespace shop\controllers;
 
 use biz\admin\services\AdminService;
+use biz\custom\classes\CustomClass;
 use biz\custom\services\CustomService;
+use biz\merchant\classes\MerchantExtendClass;
 use biz\merchant\services\MerchantAssetService;
 use biz\merchant\services\MerchantRemarkService;
 use biz\user\services\UserAssetService;
@@ -18,7 +20,6 @@ use common\services\xhUserIntegralService;
 use Yii;
 use common\components\stringUtil;
 use common\components\util;
-use biz\merchant\services\MerchantExtendService;
 use biz\message\services\SmsService;
 use biz\user\classes\UserClass;
 use yii\helpers\Json;
@@ -26,6 +27,8 @@ use yii\helpers\Json;
 class UserController extends BaseController
 {
 
+    public $guestAccessAction = ['my-profile', 'discount'];
+
     //客户列表 shish 2019.11.30
     public function actionList()
     {
@@ -268,10 +271,25 @@ class UserController extends BaseController
         util::success($asset);
     }
 
-    //获取登陆客户的优惠情况  shish 2019.12.3
+    //客户获取自己的优惠情况  shish 2021.2.1
     public function actionDiscount()
     {
-        $discount = UserAssetService::getDiscount($this->adminId);
+        $get = Yii::$app->request->get();
+        $customId = $get['customId'] ?? 0;
+        if (empty($customId)) {
+            $customId = $this->customId;
+        }
+        if (empty($customId)) {
+            util::fail('没有找到客户信息');
+        }
+        $info = CustomClass::getCustomInfo($customId);
+        CustomClass::valid($info, $this->sjId);
+        $level = $info['member'] ?? 0;
+        $discount = $info['discount'] ?? 1;
+        $discount = [
+            'member' => ['level' => $level, 'discount' => $discount],
+            'coupon' => [],
+        ];
         util::success($discount);
     }
 
@@ -411,20 +429,23 @@ class UserController extends BaseController
     //用户基本信息和资产 shish 2019.12.19
     public function actionMyProfile()
     {
-        $user = UserService::getUserInfo($this->adminId);
-        $growth = $user['userAsset']['growth'];
-        $extend = $this->sjExtend;
-        $grade = MerchantExtendService::getGradeList($extend, 'asc');
-        //下个等级的积分
-        $nextLevelGrowth = 0;
-        foreach ($grade as $val) {
-            $currentGrowth = $val['growth'];
-            if ($currentGrowth > $growth) {
-                $nextLevelGrowth = $currentGrowth;
-                break;
-            }
-        }
-        $user['userAsset']['nextLevelGrowth'] = $nextLevelGrowth;
+        $custom = $this->custom;
+        $growth = 100;
+        $id = $custom['id'] ?? 0;
+        $name = $custom['name'] ?? '';
+        $user = [
+            'id' => $id,
+            'userName' => $name,
+            'member' => 2,
+        ];
+        $nextLevelGrowth = MerchantExtendClass::getNextLevelGrowth($growth, $this->sjExtend);
+        $user['userAsset'] = [
+            'nextLevelGrowth' => $nextLevelGrowth,
+            'growth' => 0,
+            'balance' => 0,
+            'member' => 2,
+            'discount' => 0.88
+        ];
         util::success($user);
     }
 

+ 39 - 0
biz/custom/classes/CustomClass.php

@@ -2,6 +2,8 @@
 
 namespace biz\custom\classes;
 
+use biz\admin\classes\AdminClass;
+use common\components\util;
 use Yii;
 use biz\base\classes\BaseClass;
 
@@ -20,4 +22,41 @@ class CustomClass extends BaseClass
         return $custom;
     }
 
+    //获取客户信息 shish 2021.2.1
+    public static function getCustomInfo($id)
+    {
+        $custom = self::getById($id);
+        if (empty($custom)) {
+            return $custom;
+        }
+        $list = self::groupBaseInfo([$custom]);
+        return current($list);
+    }
+
+    public static function valid($info, $sjId)
+    {
+        if (isset($info['sjId']) && $info['sjId'] == $sjId) {
+            return true;
+        }
+        util::fail('客户信息无效');
+    }
+
+    //整合基本信息 shish 2021.1.31
+    public static function groupBaseInfo($list)
+    {
+        if (empty($list)) {
+            return $list;
+        }
+
+        $adminIds = array_column($list, 'adminId');
+        $adminInfo = AdminClass::getByIds($adminIds, null, 'id');
+
+        foreach ($list as $key => $val) {
+            $adminId = $val['adminId'];
+            $subscribe = $adminInfo[$adminId]['subscribe'] ?? 0;
+            $list[$key]['subscribe'] = $subscribe;
+        }
+        return $list;
+    }
+
 }

+ 8 - 0
biz/custom/services/CustomService.php

@@ -11,6 +11,14 @@ class CustomService extends BaseService
 
     public static $baseFile = '\biz\custom\classes\CustomClass';
 
+    public static function getCustomList($where)
+    {
+        $data = CustomClass::getList('*', $where, 'addTime DESC');
+        $data['list'] = CustomClass::groupBaseInfo($data['list']);
+        return $data;
+    }
+
+
     //获取客户列表,兼容老项目使用,请勿再调用 shish 2021.1.30
     public static function getOldCustomList($where)
     {

+ 14 - 2
biz/goods/classes/GoodsClass.php

@@ -36,8 +36,8 @@ class GoodsClass extends BaseClass
 
         //注意这里涉及商家节日涨价的问题,不要去取不同商家的商品,确有必要另外起方法!!!!!!
 
-		$currentData = current($list);
-		$merchantId = $currentData['merchantId'];
+        $currentData = current($list);
+        $merchantId = $currentData['merchantId'];
         $rise = GoodsSettingClass::getRise($merchantId);
 
         foreach ($list as $key => $val) {
@@ -178,4 +178,16 @@ class GoodsClass extends BaseClass
         GoodsCategoryClass::updateByCondition(['gId' => $id], ['status' => $status]);
     }
 
+    //验证商品的有效性 shish 20201.2.1
+    public static function valid($goods, $sjId)
+    {
+        if (empty($goods)) {
+            util::fail('没有找到商品');
+        }
+        if (isset($goods['merchantId']) && $goods['merchantId'] == $sjId) {
+            return true;
+        }
+        util::fail('此商品您没有权限查看哦');
+    }
+
 }

+ 56 - 21
biz/merchant/classes/MerchantExtendClass.php

@@ -2,6 +2,7 @@
 
 namespace biz\merchant\classes;
 
+use common\components\arrayUtil;
 use common\components\dirUtil;
 use common\components\wxUtil;
 use Yii;
@@ -9,26 +10,60 @@ use biz\base\classes\BaseClass;
 
 class MerchantExtendClass extends BaseClass
 {
-	
-	public static $baseFile = '\biz\merchant\models\MerchantExtend';
-	
-	public static function getByMerchantId($id, $returnType = false)
-	{
-		return self::getByCondition(['merchantId' => $id], $returnType);
-	}
-	
-	//获取申请会员的小程序码 shish 2020.2.19
-	public static function getApplyMemberCode($id)
-	{
-		$extend = self::getByMerchantId($id);
-		$imgUrl = isset($extend['applyMemberCode']) && !empty($extend['applyMemberCode']) ? $extend['applyMemberCode'] : '';
-		$file = dirUtil::getImgDir() . $imgUrl;
-		if (empty($imgUrl) || file_exists($file) == false) {
-			$merchant = MerchantClass::getMerchantById($id);
-			$imgUrl = wxUtil::generateMemberCode($merchant);
-			self::updateByCondition(['merchantId' => $id], ['applyMemberCode' => $imgUrl]);
-		}
-		return Yii::$app->params['imgHost'] . $imgUrl;
-	}
+
+    public static $baseFile = '\biz\merchant\models\MerchantExtend';
+
+    public static function getByMerchantId($id, $returnType = false)
+    {
+        return self::getByCondition(['merchantId' => $id], $returnType);
+    }
+
+    //获取申请会员的小程序码 shish 2020.2.19
+    public static function getApplyMemberCode($id)
+    {
+        $extend = self::getByMerchantId($id);
+        $imgUrl = isset($extend['applyMemberCode']) && !empty($extend['applyMemberCode']) ? $extend['applyMemberCode'] : '';
+        $file = dirUtil::getImgDir() . $imgUrl;
+        if (empty($imgUrl) || file_exists($file) == false) {
+            $merchant = MerchantClass::getMerchantById($id);
+            $imgUrl = wxUtil::generateMemberCode($merchant);
+            self::updateByCondition(['merchantId' => $id], ['applyMemberCode' => $imgUrl]);
+        }
+        return Yii::$app->params['imgHost'] . $imgUrl;
+    }
+
+    //获取下个等级的成长值 shish 2021.1.31
+    public static function getNextLevelGrowth($growth, $extend)
+    {
+        $grade = self::getGradeList($extend, 'asc');
+        //下个等级的积分
+        $nextLevelGrowth = 0;
+        foreach ($grade as $val) {
+            $currentGrowth = $val['growth'];
+            if ($currentGrowth > $growth) {
+                $nextLevelGrowth = $currentGrowth;
+                break;
+            }
+        }
+        return $nextLevelGrowth;
+    }
+
+    //积分等级列表,带索引 shish 2019.12.1
+    public static function getGradeList($extend, $order = 'asc', $indexBy = true)
+    {
+        $gradeStr = $extend['gradeList'];
+        $data = [];
+        if (!empty($gradeStr)) {
+            $arr = explode("I", $gradeStr);
+            $arr = array_filter($arr);
+            foreach ($arr as $key => $val) {
+                $son = explode("_", $val);
+                $discount = $son[2];
+                $data[$son[0]] = ['level' => $son[0], 'growth' => $son[1], 'discount' => $discount];
+            }
+        }
+        $data = arrayUtil::sort($data, 'level', $order);
+        return $indexBy == false ? array_values($data) : $data;
+    }
 
 }