Jelajahi Sumber

商品图片名称变更

shish 6 tahun lalu
induk
melakukan
ac5f604c97

+ 13 - 1
app/business/controllers/ChatController.php

@@ -2,7 +2,10 @@
 
 namespace business\controllers;
 
+use biz\goods\services\GoodsService;
+use biz\merchant\services\MerchantService;
 use biz\user\services\UserService;
+use common\components\business;
 use Yii;
 use common\components\util;
 use GatewayClient\Gateway;
@@ -47,13 +50,22 @@ class ChatController extends BaseController
 				break;
 			case 'img':
 				$shortUrl = $post['shortUrl'];
-
+				$return = business::formatUploadImg($shortUrl);
+				$arr['url'] = $return['url'];
+				$arr['smallUrl'] = $return['smallUrl'];
 				break;
 			case 'link':
 				$id = $post['id'];
+				$respond = MerchantService::getCommonUrl($id);
+				$arr['name'] = $respond['name'];
+				$arr['img'] = $respond['img'];
+				$arr['url'] = $respond['url'];
 				break;
 			case 'goods':
 				$id = $post['id'];
+				$info = GoodsService::getGoodsInfo($id);dd($info);
+				GoodsService::valid($info, $this->merchantId);
+				$arr['goodsName'] = $info['goodsName'];
 				break;
 		}
 		

+ 7 - 4
app/business/controllers/GoodsController.php

@@ -16,7 +16,7 @@ use biz\goods\services\GoodsService;
 
 class GoodsController extends BaseController
 {
-
+	
 	//商品列表 shish 2019.12.7
 	public function actionList()
 	{
@@ -62,7 +62,8 @@ class GoodsController extends BaseController
 		$data = Yii::$app->request->post();
 		$id = isset($data['id']) ? $data['id'] : 0;
 		unset($data['id']);
-		GoodsService::valid($id, $this->merchantId);
+		$info = GoodsService::getById($id);
+		GoodsService::valid($info, $this->merchantId);
 		$data['merchantId'] = $this->merchantId;
 		GoodsService::updateGoods($id, $data);
 		util::ok();
@@ -73,7 +74,8 @@ class GoodsController extends BaseController
 	{
 		$id = Yii::$app->request->get('id', 0);
 		$inTurn = Yii::$app->request->get('inTurn', 0);
-		GoodsService::valid($id, $this->merchantId);
+		$info = GoodsService::getById($id);
+		GoodsService::valid($info, $this->merchantId);
 		GoodsService::updateById($id, ['inTurn' => $inTurn]);
 		util::ok('操作成功');
 	}
@@ -92,7 +94,8 @@ class GoodsController extends BaseController
 		$get = Yii::$app->request->get();
 		$id = isset($get['id']) ? $get['id'] : 0;
 		$status = isset($get['status']) ? $get['status'] : 1;
-		GoodsService::valid($id, $this->merchantId);
+		$info = GoodsService::getById($id);
+		GoodsService::valid($info, $this->merchantId);
 		GoodsService::changeStatus($id, $status);
 		util::ok();
 	}

+ 1 - 1
app/business/controllers/MerchantController.php

@@ -62,7 +62,7 @@ class MerchantController extends BaseController
 	//常用链接
 	public function actionCommonUrl()
 	{
-		$list = MerchantService::getCommonUrl();
+		$list = MerchantService::getCommonUrlList();
 		util::success($list);
 	}
 	

+ 1 - 1
app/business/views/chat/index.php

@@ -16,7 +16,7 @@
     };
 
     function send() {
-        var type = 'text';
+        var type = 'goods';
         var data = {type: type, userId:<?= $userId ?>}
         switch (type) {
             case 'text':

+ 1 - 1
app/client/controllers/OrderController.php

@@ -113,7 +113,7 @@ class OrderController extends BaseController
 			'userId' => $this->userId,
 			'merchantId' => $this->merchantId,
 			'title' => $goodsInfo['goodsName'],
-			'cover' => isset($goodsInfo['originImgList']) && !empty($goodsInfo['originImgList']) ? current($goodsInfo['originImgList']) : '',
+			'cover' => isset($goodsInfo['shortImgList']) && !empty($goodsInfo['shortImgList']) ? current($goodsInfo['shortImgList']) : '',
 			'unitPrice' => $unitPrice,
 			'num' => $goodsNum,
 			'goodsStyleName' => isset($goodsInfo['goodsStyleList'][$goodsStyleId]['title']) ? $goodsInfo['goodsStyleList'][$goodsStyleId]['title'] : '',

+ 4 - 5
biz/goods/services/GoodsService.php

@@ -58,12 +58,11 @@ class GoodsService extends BaseService
 	{
 		return GoodsClass::updateGoods($id, $data);
 	}
-	
+
 	//验证对此商品的操作权限 shish 2019.12.7
-	public static function valid($id, $merchantId)
+	public static function valid($info, $merchantId)
 	{
-		$goods = GoodsClass::getById($id);
-		if ($goods['merchantId'] != $merchantId) {
+		if ($info['merchantId'] != $merchantId) {
 			util::fail('您没有权限操作');
 		}
 	}
@@ -73,5 +72,5 @@ class GoodsService extends BaseService
 	{
 		GoodsClass::changeStatus($id, $status);
 	}
-
+	
 }

+ 4 - 4
biz/merchant/classes/MerchantClass.php

@@ -12,11 +12,11 @@ class MerchantClass extends BaseClass
 	
 	//常用链接
 	public static $commonUrl = [
-		['id' => 1, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '商城'],
-		['id' => 2, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '申请会员'],
-		['id' => 3, 'url' => '/mall/index?account=12358', 'img' => 'http://a.huahb.com/images/avatar.jpg', 'sign' => 'mall', 'name' => '点我付款'],
+		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' => '点我付款'],
 	];
-	
+
 	//商家信息组合 shish 2019.12.20
 	public static function groupMerchantBaseInfo($list)
 	{

+ 9 - 2
biz/merchant/services/MerchantService.php

@@ -67,10 +67,17 @@ class MerchantService extends BaseService
 	}
 	
 	//常用链接 shish 2019.12.19
-	public static function getCommonUrl()
+	public static function getCommonUrlList()
 	{
 		$list = MerchantClass::$commonUrl;
-		return $list;
+		return array_values($list);
+	}
+	
+	//取指定常用链接 shish 2019.12.28
+	public static function getCommonUrl($id)
+	{
+		$list = MerchantClass::$commonUrl;
+		return isset($list[$id]) ? $list[$id] : [];
 	}
 	
 	//取平台下的商家 shish 2019.12.20

+ 8 - 8
common/components/business.php

@@ -40,32 +40,32 @@ class business
 		unset($info['shopImg']);
 		//没有保存图片返回空
 		if (empty($shopImg)) {
-			$info['originImgList'] = [];
+			$info['shortImgList'] = [];
 			$info['imgList'] = [];
-			$info['imgSmallList'] = [];
+			$info['smallImgList'] = [];
 			return $info;
 		}
 		$arr = json_decode($shopImg, true);
 		//图片内容转化失败返回空
 		if (is_array($arr) == false) {
-			$info['originImgList'] = [];
+			$info['shortImgList'] = [];
 			$info['imgList'] = [];
-			$info['imgSmallList'] = [];
+			$info['smallImgList'] = [];
 			return $info;
 		}
 		$imgList = [];
-		$imgSmallList = [];
+		$smallImgList = [];
 		$prefixImgUrl = Yii::$app->params['imgUrl'];
 		foreach ($arr as $imgUrl) {
 			$smallImg = self::getSmallImg($imgUrl);
 			$normal = $prefixImgUrl . $imgUrl;
 			$small = $prefixImgUrl . $smallImg;
 			$imgList[] = $normal;
-			$imgSmallList[] = $small;
+			$smallImgList[] = $small;
 		}
-		$info['originImgList'] = $arr;
+		$info['shortImgList'] = $arr;
 		$info['imgList'] = $imgList;
-		$info['imgSmallList'] = $imgSmallList;
+		$info['smallImgList'] = $smallImgList;
 		return $info;
 	}