修复上传
This commit is contained in:
parent
5bbc214663
commit
38590de7f5
@ -239,7 +239,14 @@ class ProductRepository extends BaseRepository
|
|||||||
$result = $this->dao->create($product);
|
$result = $this->dao->create($product);
|
||||||
|
|
||||||
$settleParams = $this->setAttrValue($data, $result->product_id, $productType, 0, $data['mer_id']);
|
$settleParams = $this->setAttrValue($data, $result->product_id, $productType, 0, $data['mer_id']);
|
||||||
if (isset($data['mer_cate_id']) && count($data['mer_cate_id']) != 0) {
|
if (isset($data['mer_cate_id']) && $data['mer_cate_id'] != '') {
|
||||||
|
if (is_array($data['mer_cate_id'])) {
|
||||||
|
if (count($data['mer_cate_id']) == 0) {
|
||||||
|
$data['mer_cate_id'] = [];
|
||||||
|
} elseif ($data['mer_cate_id'][0] == 0) {
|
||||||
|
$data['mer_cate_id'] = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
$settleParams['cate'] = $this->setMerCate($data['mer_cate_id'], $result->product_id, $data['mer_id']);
|
$settleParams['cate'] = $this->setMerCate($data['mer_cate_id'], $result->product_id, $data['mer_id']);
|
||||||
}
|
}
|
||||||
$settleParams['attr'] = $this->setAttr($data['attr'], $result->product_id);
|
$settleParams['attr'] = $this->setAttr($data['attr'], $result->product_id);
|
||||||
@ -277,10 +284,15 @@ class ProductRepository extends BaseRepository
|
|||||||
event('product.update.before', compact('id', 'data', 'merId', 'productType', 'conType'));
|
event('product.update.before', compact('id', 'data', 'merId', 'productType', 'conType'));
|
||||||
$spuData = $product = $this->setProduct($data);
|
$spuData = $product = $this->setProduct($data);
|
||||||
$settleParams = $this->setAttrValue($data, $id, $productType, 1, $merId);
|
$settleParams = $this->setAttrValue($data, $id, $productType, 1, $merId);
|
||||||
if (isset($data['mer_cate_id']) && count($data['mer_cate_id']) != 0 ) {
|
if (isset($data['mer_cate_id'])) {
|
||||||
if($data['mer_cate_id'][0]!=0){
|
if (is_array($data['mer_cate_id'])) {
|
||||||
$settleParams['cate'] = $this->setMerCate($data['mer_cate_id'], $id, $merId);
|
if (count($data['mer_cate_id']) == 0) {
|
||||||
|
$data['mer_cate_id'] = [];
|
||||||
|
} elseif ($data['mer_cate_id'][0] == 0) {
|
||||||
|
$data['mer_cate_id'] = [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$settleParams['cate'] = $this->setMerCate($data['mer_cate_id'], $id, $merId);
|
||||||
}
|
}
|
||||||
$settleParams['attr'] = $this->setAttr($data['attr'], $id);
|
$settleParams['attr'] = $this->setAttr($data['attr'], $id);
|
||||||
$content = [
|
$content = [
|
||||||
|
@ -7,6 +7,7 @@ use think\facade\Db;
|
|||||||
use think\facade\Log;
|
use think\facade\Log;
|
||||||
use crmeb\services\UploadService;
|
use crmeb\services\UploadService;
|
||||||
use think\api\Client;
|
use think\api\Client;
|
||||||
|
use GuzzleHttp\Client as http_client;
|
||||||
|
|
||||||
class ProductLibrary extends BaseController
|
class ProductLibrary extends BaseController
|
||||||
{
|
{
|
||||||
@ -129,9 +130,8 @@ class ProductLibrary extends BaseController
|
|||||||
$data['create_time'] = date('Y-m-d H:i:s');
|
$data['create_time'] = date('Y-m-d H:i:s');
|
||||||
$data['images'] = '';
|
$data['images'] = '';
|
||||||
$arr=[];
|
$arr=[];
|
||||||
|
|
||||||
if ($param['img'] != '') {
|
if ($param['img'] != '') {
|
||||||
$oss = $upload->to($dir)->stream(file_get_contents($param['img']));
|
$oss = $upload->to($dir)->stream($this->getPic($param['img']));
|
||||||
$data['image'] = $oss->filePath;
|
$data['image'] = $oss->filePath;
|
||||||
$arr[]=$oss->filePath;
|
$arr[]=$oss->filePath;
|
||||||
} else {
|
} else {
|
||||||
@ -139,7 +139,7 @@ class ProductLibrary extends BaseController
|
|||||||
$data['slider_image'] = 'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230130/00ebcfdf75684f5494c0193075055d1.png';
|
$data['slider_image'] = 'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230130/00ebcfdf75684f5494c0193075055d1.png';
|
||||||
}
|
}
|
||||||
foreach($param['imgList'] as $k=>$v){
|
foreach($param['imgList'] as $k=>$v){
|
||||||
$oss=$upload->to($dir)->stream(file_get_contents($v));
|
$oss=$upload->to($dir)->stream($this->getPic($v));
|
||||||
$arr[] = $oss->filePath;
|
$arr[] = $oss->filePath;
|
||||||
}
|
}
|
||||||
if(count($arr)>0){
|
if(count($arr)>0){
|
||||||
@ -173,4 +173,10 @@ class ProductLibrary extends BaseController
|
|||||||
throw new \think\exception\ValidateException('一维码商品采集错误:'.$e->getMessage());
|
throw new \think\exception\ValidateException('一维码商品采集错误:'.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPic($url){
|
||||||
|
$client = new http_client();
|
||||||
|
$a=$client->get($url);
|
||||||
|
return $a->getBody()->getContents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user