<?php

namespace App\Services\goods;


use App\Models\goods\mysql\PindanGoodsSnapshot;

class GoodsSnapshotsService
{
    /**
     * 拼单商品快照批量获取
     * @param $params
     * @return array
     */
    public static function pindanGoodsSnapshots($params)
    {
        $str = empty($params["snapshots_str"]) ? "" : $params["snapshots_str"];
        $pindanGoodsSnapshot = [];
        if (!empty($str)) {
            $paramsArr = json_decode($str, true);
            if (!empty($paramsArr)) {
                foreach ($paramsArr as $param) {
                    if (isset($param["goods_sku_id"]) || isset($param["goods_version"])) {
                        $key = $param["goods_sku_id"]."_".$param["goods_version"];
                        $pindanGoodsSnapshot[$key] = PindanGoodsSnapshot::select("*", [
                            "goods_sku_id" => $param["goods_sku_id"],
                            "goods_version" => $param["goods_version"]
                        ]);
                    }
                }
            }
        }
        return $pindanGoodsSnapshot;
    }
}