Commit 12bb3643 authored by luhongguang's avatar luhongguang

update:上架生成商品快照

parent e9d45509
......@@ -12,6 +12,7 @@ use App\Exception\custom\GoodsException;
use App\Models\goods\mysql\Category;
use App\Models\goods\mysql\GoodsOperationRecord;
use App\Models\goods\mysql\GoodsSku;
use App\Models\goods\mysql\GoodsSnapshot;
use App\Models\goods\mysql\GoodsSpu;
use App\Models\goods\mysql\Shop;
use App\Services\shop\ShopService;
......@@ -312,7 +313,7 @@ class GoodsService
$operatorName = $params["user_name"];
$goodsSpu = GoodsSpu::get("*", ["goods_spu_id" => $goodsSpuId]);
//todo::权限判断 商品所属 life_account_id 或者 后台管理员
//todo::权限判断 后台管理员
//权限判断
if (!empty($params["life_account_id"]) && $goodsSpu["life_account_id"] != $params["life_account_id"]) {
throw new GoodsException(["cus" => 13]);
......@@ -333,7 +334,6 @@ class GoodsService
$goodsSkuId = $sku["goods_sku_id"];
GoodsSku::save(["online_status" => $onlineStatus], ["goods_sku_id" => $goodsSkuId]);
//todo:: info to es
//商品操作记录
$res = self::getSnowIdgenId("goods");
if (empty($res)) {
......@@ -352,6 +352,11 @@ class GoodsService
"note" => empty($params["rejected_reason"]) ? "" : $params["rejected_reason"],
];
GoodsOperationRecord::insertRecord($record);
//上架的话,生成快照
if (GoodsSku::ONLINE_STATUS_ONLINE == $onlineStatus) {
self::addGoodsSnapshot($sku);
}
}
}
if (!GoodsSku::commit()) {
......@@ -361,6 +366,17 @@ class GoodsService
return true;
}
/**
* 生成快照数据
* @param $skuInfo
*/
private static function addGoodsSnapshot($skuInfo)
{
$subShopList = ShopService::getSubShopList($skuInfo["shop_id"]);
$skuInfo["sub_shop"] = json_encode($subShopList);
GoodsSnapshot::insertRecord($skuInfo);
}
/**
* 商品名是否可用
* @param $goodsName
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment