shish 5 năm trước cách đây
mục cha
commit
9467a81afa

+ 67 - 64
app/ghs/controllers/BaseController.php

@@ -20,72 +20,75 @@ use common\components\util;
 
 class BaseController extends PublicController
 {
-	public $admin, $adminId, $adminAvatar, $account;
-	public $sjId = 0, $sj = [], $sjExtend = [], $signPackage, $shopId = 0, $lookShopId = 0, $shopAdminId = 0, $shopAdmin = [];
-	public $appId;
-	public $isWx = false;
-	public $isLogin = false;
-	public $guestAccessAction = [];//不需要登陆的方法名
+    public $admin, $adminId, $adminAvatar, $account;
+    public $sjId = 0, $sj = [], $sjExtend = [], $signPackage, $shop = [], $shopId = 0, $lookShopId = 0, $shopAdminId = 0, $shopAdmin = [];
+    public $appId;
+    public $isWx = false;
+    public $isLogin = false;
+    public $guestAccessAction = [];//不需要登陆的方法名
 
-	//shish 2020.3.8
-	public function beforeAction($action)
-	{
-		//定义平台类型 1花店 2供货商
-		Yii::$app->params['ptStyle'] = 2;
+    //shish 2020.3.8
+    public function beforeAction($action)
+    {
+        //定义平台类型 1花店 2供货商
+        Yii::$app->params['ptStyle'] = 2;
 
-		//token验证
-		$adminId = jwt::getLoginId();
-		//$adminId = 18;
-		if (empty($adminId)) {
-			util::notLogin();
-		}
-		$this->adminId = $adminId;
-		$admin = AdminService::getById($adminId);
-		if (empty($admin)) {
-			util::fail('帐号无效');
-		}
-		$this->admin = $admin;
-		$header = httpUtil::getHeader();
-		$lookShopId = $header['shop-id'] ?? 0;
-		if (!empty($lookShopId)) {
-			//商城和下单页
-			if (in_array($action->id, $this->guestAccessAction) == false) {
-				util::fail('您没有权限访问哦~');
-			}
-			$shop = ShopClass::getById($lookShopId);
-			if (empty($shop)) {
-				util::fail('没有找到店铺');
-			}
-			$this->lookShopId = $lookShopId;
-			$sjId = $shop['merchantId'] ?? 0;
-			$sj = MerchantService::getMerchantById($sjId);
-			$sjExtend = MerchantExtendClass::getByMerchantId($sjId);
-		} else {
-			//后台
-			$currentShopId = $admin['currentShopId'] ?? 0;
-			if (empty($currentShopId) && in_array($action->id, $this->guestAccessAction) == false) {
-				util::fail('您没有权限访问哦!');
-			}
-			$this->shopId = $currentShopId;
-			$shop = ShopService::getById($currentShopId);
-			if (empty($shop)) {
-				util::fail('没有找到您管理的门店');
-			}
-			$shopAdmin = ShopAdminClass::getByCondition(['shopId' => $currentShopId, 'adminId' => $adminId, 'delStatus' => 0]);
-			if (empty($shopAdmin)) {
-				util::fail('没有找到员工信息');
-			}
-			$this->shopAdmin = $shopAdmin;
-			$this->shopAdminId = $shopAdmin['id'] ?? 0;
-			$sjId = $shop['merchantId'];
-			$this->sjId = $sjId;
-			$sj = MerchantService::getMerchantById($sjId);
-			$this->sj = $sj;
-			$sjExtend = MerchantExtendService::getByMerchantId($sjId);
-			$this->sjExtend = $sjExtend;
-		}
-		return parent::beforeAction($action);
-	}
+        //token验证
+        $adminId = jwt::getLoginId();
+        //$adminId = 18;
+        if (empty($adminId)) {
+            util::notLogin();
+        }
+        $this->adminId = $adminId;
+        $admin = AdminService::getById($adminId);
+        if (empty($admin)) {
+            util::fail('帐号无效');
+        }
+        $this->admin = $admin;
+        $header = httpUtil::getHeader();
+        $lookShopId = $header['shop-id'] ?? 0;
+        if (!empty($lookShopId)) {
+            //商城和下单页
+            if (in_array($action->id, $this->guestAccessAction) == false) {
+                util::fail('您没有权限访问哦~');
+            }
+            $shop = ShopClass::getById($lookShopId);
+            if (empty($shop)) {
+                util::fail('没有找到店铺');
+            }
+            $this->lookShopId = $lookShopId;
+            $sjId = $shop['merchantId'] ?? 0;
+            $sj = MerchantService::getMerchantById($sjId);
+            $sjExtend = MerchantExtendClass::getByMerchantId($sjId);
+            $this->sj = $sj;
+            $this->sjExtend = $sjExtend;
+        } else {
+            //后台
+            $currentShopId = $admin['currentShopId'] ?? 0;
+            if (empty($currentShopId) && in_array($action->id, $this->guestAccessAction) == false) {
+                util::fail('您没有权限访问哦!');
+            }
+            $this->shopId = $currentShopId;
+            $shop = ShopClass::getShopInfo($currentShopId);
+            $this->shop = $shop;
+            if (empty($shop)) {
+                util::fail('没有找到您管理的门店');
+            }
+            $shopAdmin = ShopAdminClass::getByCondition(['shopId' => $currentShopId, 'adminId' => $adminId, 'delStatus' => 0]);
+            if (empty($shopAdmin)) {
+                util::fail('没有找到员工信息');
+            }
+            $this->shopAdmin = $shopAdmin;
+            $this->shopAdminId = $shopAdmin['id'] ?? 0;
+            $sjId = $shop['merchantId'];
+            $this->sjId = $sjId;
+            $sj = MerchantService::getMerchantById($sjId);
+            $this->sj = $sj;
+            $sjExtend = MerchantExtendService::getByMerchantId($sjId);
+            $this->sjExtend = $sjExtend;
+        }
+        return parent::beforeAction($action);
+    }
 
 }
 

+ 18 - 8
app/ghs/controllers/MainController.php

@@ -113,15 +113,25 @@ class MainController extends BaseController
     //我的 shish 2021.1.30
     public function actionMy()
     {
-        $shopImg = imgUtil::getPrefix() . '/hhb_small.png';
+        $shop = $this->shop;
+        $balance = $shop['balance'] ?? 0.00;
+        $txBalance = $shop['txBalance'] ?? 0.00;
+        $sj = $this->sj;
+        $shopImg = $shop['avatar'] ?? '';
+        $deadline = $sj['deadline'] ?? '';
+        $admin = $this->admin;
+        $adminName = $admin['adminName'];
+        $mobile = $admin['mobile'] ?? '';
+        $sjName = $sj['merchantName'] ?? '';
+        $shopName = $shop['shopName'] ?? '';
         $data = [
-            'balance' => 20,
-            'totalIncome' => 100,
-            'deadline' => '2021-12-01',
-            'adminName' => '石少华',
-            'adminMobile' => 15280215347,
-            'sjName' => '纯彩花艺',
-            'shopName' => '集美店',
+            'balance' => $balance,
+            'txBalance' => $txBalance,
+            'deadline' => $deadline,
+            'adminName' => $adminName,
+            'adminMobile' => $mobile,
+            'sjName' => $sjName,
+            'shopName' => $shopName,
             'shopImg' => $shopImg,
         ];
         util::success($data);

+ 144 - 137
biz/shop/classes/ShopClass.php

@@ -15,141 +15,148 @@ use biz\base\classes\BaseClass;
 
 class ShopClass extends BaseClass
 {
-	
-	public static $baseFile = '\biz\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'] :  imgUtil::getPrefix() . '/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 \bizHd\admin\classes\AdminClass::getDetail($adminId);
-	}
-	
+
+    public static $baseFile = '\biz\shop\models\Shop';
+
+    //获取图片信息 shish 2021.3.14
+    public static function getShopInfo($id)
+    {
+        $info = self::getById($id);
+        if (empty($info)) {
+            return $info;
+        }
+        $list = self::groupShopInfo([$info]);
+        return current($list);
+    }
+
+    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);
+        $prefix = imgUtil::getPrefix();
+        foreach ($list as $key => $val) {
+            $sjId = $val['merchantId'];
+            $avatar = isset($sjList[$sjId]['logoUrl']) ? $sjList[$sjId]['logoUrl'] : $prefix . '/retail/default-img.png';
+            $list[$key]['avatar'] = $avatar;
+        }
+        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 \bizHd\admin\classes\AdminClass::getDetail($adminId);
+    }
+
 }

+ 2 - 1
sql.sql

@@ -1420,4 +1420,5 @@ RENAME TABLE `xhStaff` TO `xhPtAdmin`;
 RENAME TABLE `xhWxBase` TO `xhWxGzh`;
 RENAME TABLE `xhWxMiniBase` TO `xhWxMini`;
 ALTER TABLE xhWxOpen DROP COLUMN `appIdCreated`;
-ALTER TABLE xhAdmin MODIFY `identity` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '用户身份 1客户 2员工';
+ALTER TABLE xhAdmin MODIFY `identity` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '用户身份 1客户 2员工';
+ALTER TABLE `xhShop` ADD `txBalance` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '可提现余额' AFTER `balance`;