shish 6 سال پیش
والد
کامیت
1fbd2e5c51
3فایلهای تغییر یافته به همراه61 افزوده شده و 9 حذف شده
  1. 29 1
      app/business/controllers/ShopController.php
  2. 19 2
      biz/merchant/classes/ShopClass.php
  3. 13 6
      biz/merchant/services/ShopService.php

+ 29 - 1
app/business/controllers/ShopController.php

@@ -5,10 +5,11 @@ namespace business\controllers;
 use biz\merchant\services\ShopService;
 use common\components\dirUtil;
 use common\components\util;
+use Yii;
 
 class ShopController extends BaseController
 {
-
+	
 	//门店列表 shish 20202.2.29
 	public function actionList()
 	{
@@ -17,6 +18,27 @@ class ShopController extends BaseController
 		util::success($list);
 	}
 	
+	//更新门店 shish 2020.2.29
+	public function actionUpdate()
+	{
+		$data = Yii::$app->request->post();
+		$data['merchantId'] = $this->merchantId;
+		$id = isset($data['id']) ? $data['id'] : 0;
+		unset($data['id']);
+		$shop = ShopService::getById($id);
+		ShopService::valid($shop, $this->merchantId);
+		ShopService::updateShop($id, $data);
+		util::ok();
+	}
+	
+	public function actionAdd()
+	{
+		$data = Yii::$app->request->post();
+		$data['merchantId'] = $this->merchantId;
+		ShopService::addShop($data);
+		util::ok();
+	}
+	
 	//下载收款码 shish 2020.2.29
 	public function actionDownloadGatheringCode()
 	{
@@ -24,6 +46,9 @@ class ShopController extends BaseController
 		$shop = ShopService::getById($id);
 		ShopService::valid($shop, $this->merchantId);
 		$gatheringCode = isset($shop['gatheringCode']) ? $shop['gatheringCode'] : '';
+		if (empty($gatheringCode)) {
+			util::fail('没有收款码');
+		}
 		$file = dirUtil::getImgDir() . $gatheringCode;
 		if (file_exists($file) == false) {
 			util::fail('没有找到收款码');
@@ -44,6 +69,9 @@ class ShopController extends BaseController
 		$shop = ShopService::getById($id);
 		ShopService::valid($shop, $this->merchantId);
 		$applyMemberCode = isset($shop['applyMemberCode']) ? $shop['applyMemberCode'] : '';
+		if (empty($applyMemberCode)) {
+			util::fail('没有注册会员码');
+		}
 		$file = dirUtil::getImgDir() . $applyMemberCode;
 		if (file_exists($file) == false) {
 			util::fail('没有找到注册会员码');

+ 19 - 2
biz/merchant/classes/ShopClass.php

@@ -15,17 +15,34 @@ class ShopClass extends BaseClass
 		$list = self::getList('*', $where, 'addTime DESC');
 		return $list;
 	}
-
+	
 	//获取商家默认的门店ID shish 2020.1.19
 	public static function getDefaultShopId($merchant)
 	{
 		return isset($merchant['defaultShopId']) && !empty($merchant['defaultShopId']) ? $merchant['defaultShopId'] : 0;
 	}
-
+	
 	//创建门店 shish 2020.2.8
 	public static function addShop($data)
 	{
 		return self::add($data);
 	}
+
+	//更新门店 shish 2020.2.29
+	public static function updateShop($id, $data)
+	{
+		return self::updateById($id, $data);
+	}
+	
+	//验证所属权限 shish 2020.2.29
+	public static function valid($shopInfo, $merchantId)
+	{
+		if (empty($shopInfo)) {
+			util::fail('门店无效');
+		}
+		if (isset($shopInfo['merchantId']) == false || $shopInfo['merchantId'] != $merchantId) {
+			util::fail('您没有权限访问');
+		}
+	}
 	
 }

+ 13 - 6
biz/merchant/services/ShopService.php

@@ -45,12 +45,7 @@ class ShopService extends BaseService
 	//验证门店
 	public static function valid($shopInfo, $merchantId)
 	{
-		if (isset($shopInfo['merchantId']) == false) {
-			util::fail('门店无效');
-		}
-		if ($shopInfo['merchantId'] != $merchantId) {
-			util::fail('您没有权限访问');
-		}
+		ShopClass::valid($shopInfo,$merchantId);
 	}
 	
 	public static function getShopList($where)
@@ -64,5 +59,17 @@ class ShopService extends BaseService
 	{
 		return ShopClass::getDefaultShopId($merchant);
 	}
+	
+	//添加门店 shish 2020.2.29
+	public static function addShop($data)
+	{
+		return ShopClass::addShop($data);
+	}
+
+	//更新门店 shish 2020.2.29
+	public static function updateShop($data)
+	{
+		return ShopClass::updateShop($data);
+	}
 
 }