lqmac 8 months ago
parent 35413bed23
commit c0d67879e1
  1. 1
      app/api/controller/Goods.php
  2. 48
      app/api/model/Goods.php
  3. 3
      app/store/model/goods/Import.php

@ -57,6 +57,7 @@ class Goods extends Controller
// wmc商品详情
$model = new GoodsModel;
$goodsInfo = $model->getDetails($goodsId, $verifyStatus);
if (!empty($goodsInfo['content'])) {
$goodsInfo['content'] = str_ireplace('onload="if(this.width>750){this.height=this.height*(750.0/this.width); this.width = 750;}', '', $goodsInfo['content']);
}

@ -332,9 +332,17 @@ class Goods extends GoodsModel
public function getDetails(int $goodsId, bool $verifyStatus = true)
{
// 关联查询(商品图片、sku列表)
$with = ['images.file', 'skuList.image', 'video', 'videoCover'];
//$with = ['images.file', 'skuList.image', 'video', 'videoCover'];
$info = $this->field('spec_type,goods_id')->find($goodsId);
// 关联查询
if ($info->spec_type == GoodsSpecTypeEnum::SINGLE) {
$with = ['images.file', 'skuList1.image', 'video', 'videoCover'];
} else {
$with = ['images.file', 'skuList.image', 'video', 'videoCover'];
}
// 获取商品记录
$goodsInfo = $this->getGoodsMain($goodsId, $with, $verifyStatus);
// 商品规格列表
$goodsInfo['specList'] = GoodsSpecRelModel::getSpecList($goodsInfo['goods_id']);
$GoodsCategoryRelModel = new GoodsCategoryRelModel();
@ -348,41 +356,13 @@ class Goods extends GoodsModel
$goodsInfo->category = $category ? $category->toArray() : [];
//多规格
$goodsInfo->specifications = [];
// $skuList = [];
// $specList = [];
// if ($goodsInfo->spu_id > 0) {
// //查同规格的商品
// $spe = GoodsModel::where([
// 'spu_id' => $goodsInfo->spu_id,
// 'store_id' => request()->header()['storeid'],
// 'is_delete' => 0
// ])->column('goods_id');
// foreach ($spe as $k => $v) {
// //$sku1 = $this->getSpecData($v)['skuList']->toArray()[0];
// // $skuList[] = $sku1;
// $spe1 = $this->getSpecData($v)['specList'][0];
// $spe1['valueList'][0]['goods_id'] = $v;
// $aa = 0;
// foreach ($specList as &$v2) {
// if ($v2['spec_name'] == $spe1['spec_name']) {
// $aa = 1;
// $v2['valueList'][] = $spe1['valueList'];
// break;
// }
// }
// if ($aa == 0) {
// $specList[] = $spe1;
// }
// }
// }
$goodsInfo = $goodsInfo->toArray();
//替换原规格数组
// $goodsInfo['skuList2'] = $skuList;
$goodsInfo['specList2'] = $specList ?? [];
if (isset($goodsInfo['skuList1'])) {
$goodsInfo['skuList'] = $goodsInfo['skuList1'];
unset($goodsInfo['skuList1']);
}
//加入足迹
$userId = UserService::getCurrentLoginUserId(false) ?? '';
if ($userId) {
@ -426,6 +406,8 @@ class Goods extends GoodsModel
{
// 关联查询(商品图片)
$with = ['images.file'];
// 获取商品记录
return $this->getGoodsMain($goodsId, $with, $verifyStatus);
}

@ -72,7 +72,8 @@ class Import extends ImportModel
{
// 读取excel文件内容
$execlData = $this->readExecl();
// var_dump($execlData);
// echo "<pre>";
// print_r($execlData);
// exit();
// 验证导入的商品数量是否合法
$this->checkLimit($execlData);

Loading…
Cancel
Save