ソースを参照

最近访问的店铺

shish 5 年 前
コミット
e3eaaf06e0

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

@@ -20,7 +20,7 @@ class AdminController extends BaseController
 	public function actionRecentShop()
 	{
 		$respond = AdminClass::getRecentShop($this->admin);
-		util::success($data);
+		util::success($respond);
 	}
 	
 	//获取登陆员工的权限 shish 2019.11.24

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

@@ -12,16 +12,16 @@ use biz\user\classes\UserClass;
 
 class AdminController extends BaseController
 {
-	
+
 	public $guestAccessAction = [];
-	
+
 	//最近店铺 shish 2021.2.27
 	public function actionRecentShop()
 	{
 		$respond = AdminClass::getRecentShop($this->admin);
-		util::success($data);
+		util::success($respond);
 	}
-	
+
 	//获取登陆员工的权限 shish 2019.11.24
 	public function actionLoginAuth()
 	{

+ 1 - 1
biz-ghs/admin/classes/AdminClass.php

@@ -28,7 +28,7 @@ class AdminClass extends BaseClass
 		$arr = [];
 		if (!empty($recent)) {
 			$ids = json_decode($recent, true);
-			$list = self::getAdminByIds($ids);
+			$list = ShopClass::getShopByIds($ids);
 			if (!empty($list)) {
 				foreach ($list as $key => $val) {
 					$arr[] = [

+ 138 - 114
biz-ty/shop/classes/ShopClass.php

@@ -3,6 +3,7 @@
 namespace bizTy\shop\classes;
 
 use biz\admin\classes\ShopAdminClass;
+use bizTy\sj\classes\MerchantClass;
 use common\components\dirUtil;
 use common\components\httpUtil;
 use common\components\qrCodeUtil;
@@ -13,118 +14,141 @@ use bizTy\base\classes\BaseClass;
 
 class ShopClass extends BaseClass
 {
-
-    public static $baseFile = '\bizTy\shop\models\Shop';
-
-    public static function getShopInfo($id)
-    {
-        return self::getById($id);
-    }
-
-    public static function getShopList($where)
-    {
-        $list = self::getList('*', $where, 'addTime DESC');
-        return $list;
-    }
-
-    //获取商家默认的门店ID shish 2020.1.19
-    public static function getDefaultShopId($merchant)
-    {
-        return isset($merchant['defaultShopId']) ? $merchant['defaultShopId'] : 0;
-    }
-
-    //创建门店 shish 2020.2.8
-    public static function addShop($data)
-    {
-        $data['createTime'] = date("Y-m-d H:i:s");
-        $shopName = isset($data['shopName']) ? $data['shopName'] : '';
-        if (empty($shopName)) {
-            util::fail('请填写门店名称');
-        }
-        $exists = self::getByCondition(['merchantId' => $data['merchantId'], 'shopName' => $shopName]);
-        if (!empty($exists)) {
-            util::fail('门店名称已经存在');
-        }
-        $shop = self::add($data);
-        return $shop;
-    }
-
-    //更新门店 shish 2020.2.29
-    public static function updateShop($id, $data)
-    {
-        $shopName = isset($data['shopName']) ? $data['shopName'] : '';
-        $merchantId = $data['merchantId'];
-        $findShop = self::getByCondition(['merchantId' => $merchantId, 'shopName' => $shopName]);
-        if (!empty($findShop) && $findShop['id'] != $id) {
-            util::fail('门店名称已经存在');
-        }
-        return self::updateById($id, $data);
-    }
-
-    //取商家所有门店 shish 2020.2.29
-    public static function getAllShop($merchantId)
-    {
-        return self::getAllByCondition(['merchantId' => $merchantId]);
-    }
-
-    //验证所属权限 shish 2020.2.29
-    public static function valid($shop, $merchantId)
-    {
-        if (empty($shop)) {
-            util::fail('门店无效');
-        }
-        if (isset($shop['merchantId']) == false || $shop['merchantId'] != $merchantId) {
-            util::fail('您没有权限访问');
-        }
-    }
-
-    //删除门店 shish 2020.3.1
-    public static function deleteShop($shop)
-    {
-        if (isset($shop['default']) && $shop['default'] == 1) {
-            util::fail('默认门店不允许删除');
-        }
-        $id = $shop['id'];
-        self::updateById($id, ['delStatus' => 1]);
-    }
-
-    //生成收款码 shish 2020.3.9
-    public static function generateGatheringCode($merchantId, $shopId)
-    {
-        $url = Yii::$app->params['mallDomain'] . "/#/pages/pay/index?account={$merchantId}&shopId=" . $shopId;
-        //强制转成https
-        $url = httpUtil::becomeHttps($url);
-        $gatheringCode = qrCodeUtil::generateGatheringQrCode($url, $merchantId, $shopId, '', 10);
-        return $gatheringCode;
-    }
-
-    //增加余额 shish 2021.2.21
-    //$fix = false 余额使用时不需要指定在谁那边用
-    public static function addBalance($shop, $amount, $fix = false)
-    {
-        $shop->balance += $amount;
-        $shop->totalRecharge += $amount;
-        if ($fix) {
-            $shop->fixBalance += $amount;
-        }
-        $shop->save();
-    }
-
-    //获取商家所有的门店 shish 2021.2.26
-    public static function getSjShopList($sjId)
-    {
-        return self::getAllByCondition(['merchantId' => $sjId, 'delStatus' => 0], null, ['id']);
-    }
-
-    //取门店长信息 shish 2021.1.17
-    public static function getSuper($id)
-    {
-        $shop = self::getById($id);
-        if (empty($shop)) {
-            return [];
-        }
-        $adminId = $shop['adminId'] ?? 0;
-        return \biz\admin\classes\AdminClass::getDetail($adminId);
-    }
-
+	
+	public static $baseFile = '\bizTy\shop\models\Shop';
+	
+	public static function getShopInfo($id)
+	{
+		return self::getById($id);
+	}
+	
+	public static function getShopList($where)
+	{
+		$list = self::getList('*', $where, 'addTime DESC');
+		return $list;
+	}
+	
+	//查看店铺 shish 2021.3.1
+	public static function getShopByIds($ids)
+	{
+		$list = self::getByIds($ids);
+		return self::groupShopInfo($list);
+	}
+	
+	//门店 shish 2021.3.1
+	public static function groupShopInfo($list)
+	{
+		if (empty($list)) {
+			return $list;
+		}
+		$sjIds = array_column($list, 'merchantId');
+		$sjList = MerchantClass::getMerchantByIds($sjIds);
+		foreach ($list as $key => $val) {
+			$sjId = $val['merchantId'];
+			$logoUrl = isset($sjList[$sjId]['logoUrl']) ? $sjList[$sjId]['logoUrl'] :  Yii::$app->params['imgHost'] . '/retail/default-img.png';
+			$list[$key]['avatar'] = $logoUrl;
+		}
+		return $list;
+	}
+	
+	//获取商家默认的门店ID shish 2020.1.19
+	public static function getDefaultShopId($merchant)
+	{
+		return isset($merchant['defaultShopId']) ? $merchant['defaultShopId'] : 0;
+	}
+	
+	//创建门店 shish 2020.2.8
+	public static function addShop($data)
+	{
+		$data['createTime'] = date("Y-m-d H:i:s");
+		$shopName = isset($data['shopName']) ? $data['shopName'] : '';
+		if (empty($shopName)) {
+			util::fail('请填写门店名称');
+		}
+		$exists = self::getByCondition(['merchantId' => $data['merchantId'], 'shopName' => $shopName]);
+		if (!empty($exists)) {
+			util::fail('门店名称已经存在');
+		}
+		$shop = self::add($data);
+		return $shop;
+	}
+	
+	//更新门店 shish 2020.2.29
+	public static function updateShop($id, $data)
+	{
+		$shopName = isset($data['shopName']) ? $data['shopName'] : '';
+		$merchantId = $data['merchantId'];
+		$findShop = self::getByCondition(['merchantId' => $merchantId, 'shopName' => $shopName]);
+		if (!empty($findShop) && $findShop['id'] != $id) {
+			util::fail('门店名称已经存在');
+		}
+		return self::updateById($id, $data);
+	}
+	
+	//取商家所有门店 shish 2020.2.29
+	public static function getAllShop($merchantId)
+	{
+		return self::getAllByCondition(['merchantId' => $merchantId]);
+	}
+	
+	//验证所属权限 shish 2020.2.29
+	public static function valid($shop, $merchantId)
+	{
+		if (empty($shop)) {
+			util::fail('门店无效');
+		}
+		if (isset($shop['merchantId']) == false || $shop['merchantId'] != $merchantId) {
+			util::fail('您没有权限访问');
+		}
+	}
+	
+	//删除门店 shish 2020.3.1
+	public static function deleteShop($shop)
+	{
+		if (isset($shop['default']) && $shop['default'] == 1) {
+			util::fail('默认门店不允许删除');
+		}
+		$id = $shop['id'];
+		self::updateById($id, ['delStatus' => 1]);
+	}
+	
+	//生成收款码 shish 2020.3.9
+	public static function generateGatheringCode($merchantId, $shopId)
+	{
+		$url = Yii::$app->params['mallDomain'] . "/#/pages/pay/index?account={$merchantId}&shopId=" . $shopId;
+		//强制转成https
+		$url = httpUtil::becomeHttps($url);
+		$gatheringCode = qrCodeUtil::generateGatheringQrCode($url, $merchantId, $shopId, '', 10);
+		return $gatheringCode;
+	}
+	
+	//增加余额 shish 2021.2.21
+	//$fix = false 余额使用时不需要指定在谁那边用
+	public static function addBalance($shop, $amount, $fix = false)
+	{
+		$shop->balance += $amount;
+		$shop->totalRecharge += $amount;
+		if ($fix) {
+			$shop->fixBalance += $amount;
+		}
+		$shop->save();
+	}
+	
+	//获取商家所有的门店 shish 2021.2.26
+	public static function getSjShopList($sjId)
+	{
+		return self::getAllByCondition(['merchantId' => $sjId, 'delStatus' => 0], null, ['id']);
+	}
+	
+	//取门店长信息 shish 2021.1.17
+	public static function getSuper($id)
+	{
+		$shop = self::getById($id);
+		if (empty($shop)) {
+			return [];
+		}
+		$adminId = $shop['adminId'] ?? 0;
+		return \biz\admin\classes\AdminClass::getDetail($adminId);
+	}
+	
 }

+ 102 - 97
biz-ty/sj/classes/MerchantClass.php

@@ -14,101 +14,106 @@ use biz\base\classes\BaseClass;
 
 class MerchantClass extends BaseClass
 {
-
-    public static $baseFile = '\bizTy\sj\models\Merchant';
-
-    //常用链接
-    public static $commonUrl = [
-        1 => ['id' => 1, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '商城'],
-        2 => ['id' => 2, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '申请会员'],
-        3 => ['id' => 3, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '点我付款'],
-    ];
-
-    //零售店
-    const STYLE_RETAIL = 1;
-    //供货商
-    const STYLE_SUPPLIER = 2;
-
-    //状态
-    const STATUS_UN_CHECK = 0;
-    const STATUS_HAS_CHECK = 1;
-    const STATUS_CHECK_NOT_PASS = 2;
-    const STATUS_FREEZE = 3;
-    const STATUS_EXPIRE = 4;
-
-    //开店初始化更多信息,有提供营业执照才初始化的信息 shish 2021.2.27
-    public static function initMore($applyData, $sjId, $shopId)
-    {
-        if ($applyData['style'] == MerchantClass::STYLE_RETAIL) {
-            self::initRetailMore($applyData, $sjId, $shopId);
-        }
-        if ($applyData['style'] == MerchantClass::STYLE_SUPPLIER) {
-            self::initGhsMore($applyData, $sjId, $shopId);
-        }
-    }
-
-    public static function initRetailMore($applyData, $sjId, $shopId)
-    {
-        //初始化员工和角色
-        AdminClass::initAdmin($applyData, $sjId, $shopId);
-        //商品和分类初始化
-        CategoryClass::initCategoryGoods($sjId);
-        //商城和门店广告初始化
-        AdClass::initAdd($sjId);
-        //优惠券资产与配置信息初始化
-        CouponAssetClass::add(['merchantId' => $sjId, 'switch' => 1]);
-    }
-
-    public static function initGhsMore($applyData, $sjId, $shopId)
-    {
-        //初始化员工和角色
-        \bizGhs\admin\classes\AdminClass::initAdmin($applyData, $sjId, $shopId);
-    }
-
-    //商家信息组合 shish 2019.12.20
-    public static function groupMerchantBaseInfo($list)
-    {
-        return $list;
-    }
-
-    public static function getMerchantByIds($ids)
-    {
-        return self::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id');
-    }
-
-    public static function getMerchantById($id)
-    {
-        $sj = self::getById($id);
-        if (empty($sj)) {
-            return $sj;
-        }
-        $list = self::groupBaseInfo([$sj]);
-        return current($list);
-    }
-
-    public static function groupBaseInfo($list)
-    {
-        foreach ($list as $key => $val) {
-            $list[$key] = business::formatMerchantLogo($list[$key]);
-            $list[$key]['address'] = '厦门市思明区后埭溪路128号-5';
-        }
-        return $list;
-    }
-
-    //h5商城链接二维码 shish 2020.4.30
-    public static function getH5MallQrCode($id)
-    {
-        $url = Yii::$app->params['mallDomain'] . "/#/?account=" . $id;
-        //强制转成https
-        $url = httpUtil::becomeHttps($url);
-        $respond = qrCodeUtil::generateH5MallQrCode($url);
-        return isset($respond['url']) ? $respond['url'] : '';
-    }
-
-    public static function getDefaultShopId($sj)
-    {
-        $defaultShopId = isset($sj['defaultShopId']) ? $sj['defaultShopId'] : 0;
-        return $defaultShopId;
-    }
-
+	
+	public static $baseFile = '\bizTy\sj\models\Merchant';
+	
+	//常用链接
+	public static $commonUrl = [
+		1 => ['id' => 1, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '商城'],
+		2 => ['id' => 2, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '申请会员'],
+		3 => ['id' => 3, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '点我付款'],
+	];
+
+	//零售店
+	const STYLE_RETAIL = 1;
+	//供货商
+	const STYLE_SUPPLIER = 2;
+
+	//状态
+	const STATUS_UN_CHECK = 0;
+	const STATUS_HAS_CHECK = 1;
+	const STATUS_CHECK_NOT_PASS = 2;
+	const STATUS_FREEZE = 3;
+	const STATUS_EXPIRE = 4;
+
+	//开店初始化更多信息,有提供营业执照才初始化的信息 shish 2021.2.27
+	public static function initMore($applyData, $sjId, $shopId)
+	{
+		if ($applyData['style'] == MerchantClass::STYLE_RETAIL) {
+			self::initRetailMore($applyData, $sjId, $shopId);
+		}
+		if ($applyData['style'] == MerchantClass::STYLE_SUPPLIER) {
+			self::initGhsMore($applyData, $sjId, $shopId);
+		}
+	}
+	
+	public static function initRetailMore($applyData, $sjId, $shopId)
+	{
+		//初始化员工和角色
+		AdminClass::initAdmin($applyData, $sjId, $shopId);
+		//商品和分类初始化
+		CategoryClass::initCategoryGoods($sjId);
+		//商城和门店广告初始化
+		AdClass::initAdd($sjId);
+		//优惠券资产与配置信息初始化
+		CouponAssetClass::add(['merchantId' => $sjId, 'switch' => 1]);
+	}
+	
+	public static function initGhsMore($applyData, $sjId, $shopId)
+	{
+		//初始化员工和角色
+		\bizGhs\admin\classes\AdminClass::initAdmin($applyData, $sjId, $shopId);
+	}
+	
+	//商家信息组合 shish 2019.12.20
+	public static function groupMerchantBaseInfo($list)
+	{
+		return $list;
+	}
+
+	public static function getMerchantByIds($ids)
+	{
+		$list = self::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id');
+		return self::groupBaseInfo($list);
+	}
+
+	public static function getMerchantById($id)
+	{
+		$sj = self::getById($id);
+		if (empty($sj)) {
+			return $sj;
+		}
+		$list = self::groupBaseInfo([$sj]);
+		return current($list);
+	}
+
+	//组合商家信息 shish 2021.3.1
+	public static function groupBaseInfo($list)
+	{
+		if (empty($list)) {
+			return $list;
+		}
+		foreach ($list as $key => $val) {
+			$list[$key] = business::formatMerchantLogo($list[$key]);
+			$list[$key]['address'] = '厦门市思明区后埭溪路128号-5';
+		}
+		return $list;
+	}
+	
+	//h5商城链接二维码 shish 2020.4.30
+	public static function getH5MallQrCode($id)
+	{
+		$url = Yii::$app->params['mallDomain'] . "/#/?account=" . $id;
+		//强制转成https
+		$url = httpUtil::becomeHttps($url);
+		$respond = qrCodeUtil::generateH5MallQrCode($url);
+		return isset($respond['url']) ? $respond['url'] : '';
+	}
+	
+	public static function getDefaultShopId($sj)
+	{
+		$defaultShopId = isset($sj['defaultShopId']) ? $sj['defaultShopId'] : 0;
+		return $defaultShopId;
+	}
+	
 }

+ 0 - 20
biz/admin/classes/AdminClass.php

@@ -22,26 +22,6 @@ class AdminClass extends BaseClass
 		//花美灵
 		'wx84d95afcb7b594eb' => ['oTFbYvsjwgVwXggwtlM2ESAKwuN8', 'oTFbYvqP6qwdCCkdFB9GYnlzDIUg'],
 	];
-	
-	public static function getRecentShop($admin)
-	{
-		$recent = $admin['recentShop'];
-		$arr = [];
-		if (!empty($recent)) {
-			$ids = json_decode($recent, true);
-			$list = self::getAdminByIds($ids);
-			if (!empty($list)) {
-				foreach ($list as $key => $val) {
-					$arr[] = [
-						'shopId' => $val['id'],
-						'shopName' => $val['shopName'],
-						'shopImg' => $val['avatar'],
-					];
-				}
-			}
-		}
-		return $arr;
-	}
 
 	//增加最近访问的门店 shish 2021.3.1
 	public static function addRecentShop($lookShopId, $admin)

+ 7 - 7
common/components/business.php

@@ -62,7 +62,7 @@ class business
 			$smallImg = self::getSmallImg($imgUrl);
 			$small = $prefixImgUrl . $smallImg;
 			$normal = $prefixImgUrl . $imgUrl;
-
+			
 			/*
 			$preImg = $imageRoot . str_replace('/uploads', '', $imgUrl);
 			if (file_exists($preImg)) {
@@ -81,7 +81,7 @@ class business
 				}
 			}
 			*/
-
+			
 			$imgList[] = $normal;
 			$smallImgList[] = $small;
 		}
@@ -195,14 +195,14 @@ class business
 	public static function formatMerchantLogo($info)
 	{
 		$imgUrl = isset($info['logo']) ? $info['logo'] : '';
+		$prefixImgUrl = Yii::$app->params['imgHost'];
 		if (empty($imgUrl)) {
-			$info['logoUrl'] = '';
-			$info['smallLogoUrl'] = '';
-			$info['smallWxQrCodeUrl'] = '';
-			$info['wxQrCodeUrl'] = '';
+			$info['logoUrl'] = $prefixImgUrl . '/retail/default-img.png';
+			$info['smallLogoUrl'] = $prefixImgUrl . '/retail/default-img.png';
+			$info['smallWxQrCodeUrl'] = $prefixImgUrl . '/retail/default-img.png';
+			$info['wxQrCodeUrl'] = $prefixImgUrl . '/retail/default-img.png';
 			return $info;
 		}
-		$prefixImgUrl = Yii::$app->params['imgHost'];
 		//logo
 		$smallImg = self::getSmallImg($imgUrl);
 		$small = $prefixImgUrl . $smallImg;