Ver Fonte

文件名随机数

shish há 6 anos atrás
pai
commit
b52bb2b0cc

+ 3 - 6
biz/goods/classes/GoodsClass.php

@@ -63,8 +63,7 @@ class GoodsClass extends BaseClass
 			util::fail('没有选择分类');
 		}
 		$goodsStyleList = isset($data['goodsStyleList']) && !empty($data['goodsStyleList']) ? $data['goodsStyleList'] : [];
-		unset($data['goodsStyleList']);
-		
+
 		//用商户id生成商品的编号
 		$merchantId = $data['merchantId'];
 		$data['itemNumber'] = stringUtil::buildRandNo($merchantId);
@@ -88,11 +87,9 @@ class GoodsClass extends BaseClass
 		GoodsCategoryClass::batchAdd($addCategory);
 		//处理款式
 		if (!empty($goodsStyleList) && $data['goodsStyle'] == 1) {
-			$goodsStyleList = ['add' => [['styleName' => '红色', 'price' => 0.1, 'picture' => ''], ['styleName' => '蓝色', 'price' => 0.1, 'picture' => '']]];
-			$addGoodsStyle = $goodsStyleList['add'];
 			$addStyle = [];
-			foreach ($addGoodsStyle as $style) {
-				$addStyle[] = ['styleName' => $style['styleName'], 'goodsId' => $id, 'picture' => $style['picture'], 'price' => $style['price']];
+			foreach ($goodsStyleList as $goodsStyle) {
+				$addStyle[] = ['styleName' => $goodsStyle['styleName'], 'goodsId' => $id, 'picture' => $goodsStyle['picture'], 'price' => $goodsStyle['price']];
 			}
 			GoodsStyleClass::batchAdd($addStyle);
 		}

+ 1 - 1
common/components/fileUtil.php

@@ -23,7 +23,7 @@ class fileUtil
 				//检查是否有该文件夹,如果没有就创建,并给予最高权限
 				mkdir($path, 0700, true);
 			}
-			$preFileName = stringUtil::uniqueFileName();
+			$preFileName = uniqid();
 			$newFile = $preFileName . ".{$type}";
 			$fullPathFile = $path . $newFile;
 			if (file_put_contents($fullPathFile, base64_decode(str_replace($result[1], '', $base64_image_content))) == false) {

+ 2 - 2
common/components/stringUtil.php

@@ -448,10 +448,10 @@ class stringUtil
 	}
 
 	//生成唯一的文件名称 shish 2020.1.7
-	//参考 https://www.cnblogs.com/yjf512/p/9057229.html
-	//https://www.cnblogs.com/roluce/p/6026081.html
 	public static function uniqueFileName()
 	{
+		//参考 https://www.cnblogs.com/yjf512/p/9057229.html
+		//https://www.cnblogs.com/roluce/p/6026081.html
 		return md5(uniqid(mt_rand(), true));
 	}
 

+ 4 - 0
console/controllers/UpgradeController.php

@@ -951,6 +951,10 @@ ALTER TABLE `xhUser` CHANGE `source` `sourceType` TINYINT NOT NULL DEFAULT 0 COM
 ALTER TABLE `xhUser` ADD `store` TINYINT NOT NULL DEFAULT 0 COMMENT '门店订单 0不是 1是' AFTER `sourceType`;";
 		Yii::$app->db->createCommand($sql)->execute();
 
+		//商品图片变长
+		$sql = "ALTER TABLE `xhGoodsStyle` MODIFY `picture` VARCHAR(800) NOT NULL DEFAULT '' COMMENT '图片相对路径';";
+		Yii::$app->db->createCommand($sql)->execute();
+
 		//继续执行
 		$this->actionInit2();