|
@@ -6,6 +6,7 @@ use App\Base\BaseService;
|
|
use App\Models\Goods\Goods;
|
|
use App\Models\Goods\Goods;
|
|
use App\Models\Goods\GoodsCategoryMap;
|
|
use App\Models\Goods\GoodsCategoryMap;
|
|
use App\Models\Goods\GoodsCustom;
|
|
use App\Models\Goods\GoodsCustom;
|
|
|
|
+use App\Models\Goods\GoodsSearch;
|
|
use App\Models\Goods\GoodsSku;
|
|
use App\Models\Goods\GoodsSku;
|
|
use App\Models\Goods\GoodsSpecMap;
|
|
use App\Models\Goods\GoodsSpecMap;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
@@ -53,7 +54,7 @@ class GoodsService extends BaseService
|
|
|
|
|
|
$specIdArr = array_values(Arr::sort(Arr::get($params, "spec", [])));
|
|
$specIdArr = array_values(Arr::sort(Arr::get($params, "spec", [])));
|
|
|
|
|
|
- DB::transaction(function () use ($params, $goods, $specIdArr) {
|
|
|
|
|
|
+ $goods = DB::transaction(function () use ($params, $goods, $specIdArr) {
|
|
$goods->image_list = Arr::get($params, "image_list", []);
|
|
$goods->image_list = Arr::get($params, "image_list", []);
|
|
$goods->sn = $params['sn'] ?? "";
|
|
$goods->sn = $params['sn'] ?? "";
|
|
$goods->url_3d = $params['url_3d'] ?? "";
|
|
$goods->url_3d = $params['url_3d'] ?? "";
|
|
@@ -110,8 +111,25 @@ class GoodsService extends BaseService
|
|
}
|
|
}
|
|
|
|
|
|
GoodsSpecMap::where("goods_id", $goods->id)->whereNotIn("id", $doNotDelIdArr)->delete();
|
|
GoodsSpecMap::where("goods_id", $goods->id)->whereNotIn("id", $doNotDelIdArr)->delete();
|
|
|
|
+ $this->createIndex($goods);
|
|
|
|
+ return $goods;
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function createIndex(Goods $goods)
|
|
|
|
+ {
|
|
|
|
+ GoodsSearch::updateOrCreate([
|
|
|
|
+ "goods_id" => $goods->id,
|
|
|
|
+ ], [
|
|
|
|
+ "goods_id" => $goods->id,
|
|
|
|
+ "content" => $goods->name . $goods->en_name . implode("", array_map(function ($item) {
|
|
|
|
+ return implode("", Arr::pluck($item, "attr.value"));
|
|
|
|
+ }, $goods->custom)) . strip_tags($goods->desc_html) . $goods->specMap->map(function (GoodsSpecMap $m) {
|
|
|
|
+ return $m->value;
|
|
|
|
+ })->implode(""),
|
|
|
|
+ ]);
|
|
}
|
|
}
|
|
|
|
|
|
public function info($params)
|
|
public function info($params)
|