From 4a57b4e344758b2aa40688da09a8e1b82d2be751 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 30 Nov 2023 10:45:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A7=84=E6=A0=BC=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/Demo.php | 15 ++++++++++----- crmeb/jobs/ImportPicJob.php | 10 ++++++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/controller/api/Demo.php b/app/controller/api/Demo.php index 8dd59220..dedd198a 100644 --- a/app/controller/api/Demo.php +++ b/app/controller/api/Demo.php @@ -30,7 +30,7 @@ class Demo extends BaseController { public function index() { - $mer_id = 36; + $mer_id = 104; $file = request()->file('file'); $zip_name = explode('.', $file->getOriginalName())[0]; // 上传到本地服务器 @@ -136,11 +136,17 @@ class Demo extends BaseController Db::name('store_product')->where('product_id', $find['product_id'])->update($update); /**更新规格图片 */ foreach ($sku_arr as $k => $v) { - $store_product_attr_value = Db::name('store_product_attr_value')->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $k])->find(); + $sku = explode(',', $k); + if(count($sku)==2){ + $sku_name=$sku[0]; + }else{ + continue; + } + $store_product_attr_value = Db::name('store_product_attr_value')->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $sku_name])->find(); if ($store_product_attr_value) { $oss = $upload->to($dir)->stream(file_get_contents($v)); Db::name('store_product_attr_value') - ->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $k]) + ->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $sku_name]) ->update(['image' => $oss->filePath]); } } @@ -158,9 +164,8 @@ class Demo extends BaseController } } else { $update_content['product_id'] = $find['product_id']; - $a=Db::name('store_product_content') + Db::name('store_product_content') ->insert(['product_id' => $find['product_id'], 'type' => 1, 'content' => json_encode($update_content)]); - halt($a,2222); } } catch (Exception $e) { halt($e->getMessage(), $e->getLine()); diff --git a/crmeb/jobs/ImportPicJob.php b/crmeb/jobs/ImportPicJob.php index 4b39b42b..d917b296 100644 --- a/crmeb/jobs/ImportPicJob.php +++ b/crmeb/jobs/ImportPicJob.php @@ -89,11 +89,17 @@ class ImportPicJob implements JobInterface Db::name('store_product')->where('product_id', $find['product_id'])->update($update); /**更新规格图片 */ foreach ($sku_arr as $k => $v) { - $store_product_attr_value = Db::name('store_product_attr_value')->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $k])->find(); + $sku = explode(',', $k); + if(count($sku)==2){ + $sku_name=$sku[0]; + }else{ + continue; + } + $store_product_attr_value = Db::name('store_product_attr_value')->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $sku_name])->find(); if ($store_product_attr_value) { $oss = $upload->to($dir)->stream(file_get_contents($v)); Db::name('store_product_attr_value') - ->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $k]) + ->where(['mer_id' => $mer_id, 'product_id' => $find['product_id'], 'sku' => $sku_name]) ->update(['image' => $oss->filePath]); } }