shish 6 lat temu
rodzic
commit
48f1edcfb6

+ 16 - 0
app/saas/web/index.php

@@ -1,5 +1,21 @@
 <?php
 
+//跨域临时解决方案 shish 2019.12.1
+header('Access-Control-Allow-Origin:*');
+// 响应类型
+header('Access-Control-Allow-Methods:*');
+// 响应头设置
+header('Access-Control-Allow-Headers:content-type,token,id,source,account');
+header("Access-Control-Request-Headers: Origin, X-Requested-With, content-Type, Accept, Authorization");
+
+//调用使用的输出方法
+function dd($out)
+{
+	echo '<pre>';
+	print_r($out);
+	Yii::$app->end();
+}
+
 require(__DIR__ . '/../../../vendor/autoload.php');
 
 require(__DIR__ . '/../../../env.php');// Environment

+ 4 - 3
biz/merchant/services/AdminService.php

@@ -34,7 +34,7 @@ class AdminService extends BaseService
 		xhTMessageService::sendUrlToMobile($url, $openId, $merchant);
 		return true;
 	}
-
+	
 	//根据id批量取管理员 shish 2019.12.20
 	public static function getAdminByIds($ids, $order = null, $indexBy = null)
 	{
@@ -44,9 +44,10 @@ class AdminService extends BaseService
 		}
 		$imgPrefix = Yii::$app->params['imgUrl'];
 		foreach ($admin as $key => $val) {
-			//$admin[$key]['avatarUrl'] = $imgPrefix . $val['avatar'];
-			$val = business::formatAvatar($val);
+			$val = business::formatUserAvatar($val);
+			$admin[$key] = $val;
 		}
+		return $admin;
 	}
 	
 }

+ 7 - 1
biz/merchant/services/MerchantAssetService.php

@@ -34,5 +34,11 @@ class MerchantAssetService extends BaseService
 	{
 		MerchantAssetClass::addMemberNum($merchantId);
 	}
-
+	
+	//根据商家id批量取商家资产 shish 2019.12.20
+	public static function getAssetByMerchantIds($ids)
+	{
+		return MerchantAssetClass::getAllByCondition(['merchantId' => ['in', $ids]], null, '*', 'merchantId');
+	}
+	
 }

+ 21 - 6
biz/merchant/services/MerchantService.php

@@ -6,6 +6,8 @@ use biz\auth\services\AuthService;
 use biz\base\services\BaseService;
 use biz\merchant\classes\MerchantClass;
 use biz\saas\services\SetAuthService;
+use biz\saas\services\SetMealService;
+use common\components\business;
 use Yii;
 
 class MerchantService extends BaseService
@@ -71,7 +73,7 @@ class MerchantService extends BaseService
 		return $list;
 	}
 	
-	//取平台下的商家
+	//取平台下的商家 shish 2019.12.20
 	public static function getSaasMerchant($where)
 	{
 		$data = MerchantClass::getList('*', $where, 'addTime DESC');
@@ -79,15 +81,28 @@ class MerchantService extends BaseService
 		if (empty($list)) {
 			return $data;
 		}
+		
+		//管理员
 		$adminIdList = array_column($list, 'adminId');
-		$admin = AdminService::getByIds($adminIdList, null, 'id');
-		$merchantIdList = array_column($list, 'merchantId');
-		$asset = MerchantAssetService::getByIds($merchantIdList, null, 'merchantId');
+		$admin = AdminService::getAdminByIds($adminIdList, null, 'id');
+		//商家资产
+		$merchantIdList = array_column($list, 'id');
+		$asset = MerchantAssetService::getAssetByMerchantIds($merchantIdList);
+		//套餐
+		$setIdList = array_column($list, 'setId');
+		$set = SetMealService::getSetByIds($setIdList);
+		
 		foreach ($list as $key => $val) {
-			die;
+			$adminId = $val['adminId'];
+			$merchantId = $val['id'];
+			$setId = $val['setId'];
+			$val['adminName'] = isset($admin[$adminId]['adminName']) ? $admin[$adminId]['adminName'] : '';
+			$val['merchantAsset'] = isset($asset[$merchantId]) ? $asset[$merchantId] : [];
+			$val['setMealName'] = isset($set[$setId]) ? $set[$setId]['name'] : '';
+			$list[$key] = business::formatMerchantLogo($val);
 		}
 		$data['list'] = $list;
 		return $data;
 	}
-
+	
 }

+ 8 - 0
biz/saas/services/SetMealService.php

@@ -1,7 +1,9 @@
 <?php
 
 namespace biz\saas\services;
+
 use biz\base\services\BaseService;
+use biz\saas\classes\SetMealClass;
 use Yii;
 
 class SetMealService extends BaseService
@@ -9,4 +11,10 @@ class SetMealService extends BaseService
 
 	public static $baseFile = '\biz\saas\classes\SetMealClass';
 
+	//根据id批量取套餐信息 shish 2019.12.20
+	public static function getSetByIds($ids)
+	{
+		return SetMealClass::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id');
+	}
+
 }

+ 20 - 3
common/components/business.php

@@ -111,8 +111,8 @@ class business
 		return $info;
 	}
 	
-	//头像处理 shish 2019.12.20
-	public static function formatAvatar($info)
+	//客户头像处理 shish 2019.12.20
+	public static function formatUserAvatar($info)
 	{
 		$imgUrl = isset($info['avatar']) ? $info['avatar'] : '';
 		if (empty($imgUrl)) {
@@ -128,6 +128,23 @@ class business
 		return $info;
 	}
 
+	//商家公众号logo处理 shish 2019.12.20
+	public static function formatMerchantLogo($info)
+	{
+		$imgUrl = isset($info['logo']) ? $info['logo'] : '';
+		if (empty($imgUrl)) {
+			$info['logoUrl'] = '';
+			$info['logoSmallUrl'] = '';
+			return $info;
+		}
+		$prefixImgUrl = Yii::$app->params['imgUrl'];
+		$smallImg = self::getSmallImg($imgUrl);
+		$small = $prefixImgUrl . $smallImg;
+		$info['logoSmallUrl'] = $small;
+		$info['logoUrl'] = $prefixImgUrl . $imgUrl;
+		return $info;
+	}
+
 	//取小图,尺寸 200px shish 2019.12.4
 	public static function getSmallImg($imgUrl)
 	{
@@ -138,5 +155,5 @@ class business
 		$smallImg = $pre . '_small.' . $ext;
 		return $smallImg;
 	}
-
+	
 }

+ 1 - 0
common/config/params.php

@@ -40,4 +40,5 @@ return [
 	'neverExpireTime' => 4102416000,
 	//永不过期日期
 	'neverExpireDate' => '2100-01-01 00:00:00',
+	'pageSize'=>20,
 ];

+ 1 - 0
sql.txt

@@ -3,6 +3,7 @@ ALTER TABLE `xhMerchantAsset` MODIFY `totalOrder` INT NOT NULL DEFAULT 0 COMMENT
 ALTER TABLE `xhMerchantAsset` ADD `payOrder` INT NOT NULL DEFAULT 0 COMMENT '付款订单数' AFTER `totalOrder`;
 ALTER TABLE `xhMerchant` ADD `addTime` INT NOT NULL DEFAULT 0 COMMENT '添加时间' AFTER `status`;
 ALTER TABLE `xhAdmin` ADD `avatar` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '头像' AFTER `adminName`;
+ALTER TABLE `xhMerchant` MODIFY `status` TINYINT NOT NULL DEFAULT 0 COMMENT '商家状态 0待审 1审核通过,取消冻结,正常 2审核未通过 3冻结 4过期';
 
 2019.12.19 商家资产更新 shish
 ALTER TABLE `xhMerchantAsset` MODIFY `totalOrder` INT NOT NULL DEFAULT 0 COMMENT '订单数;已付款订单数';