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]); } }