<?php

namespace App\Services\Business\MiaoXuan;

use App\Models\BusinessGoodsSku;

class Goods
{
    public static function bindGoods(array $goods, $shopId)
    {
        foreach ($goods as $item) {
            BusinessGoodsSku::updateOrCreate(
                ['shop_id' => $shopId, 'goods_id' => $item['goods_id'], 'sku_id' => $item['sku_id']],
                $item
            );
        }
    }

    public static function incrQuantity($shopId, $quantity, BusinessGoodsSku $businessGoods)
    {
        return [
            'data' => [
                'stock' => $quantity,
                'business_sku_id' => $businessGoods->sku_id,
                'business_goods_id' => $businessGoods->goods_id,
                'erp_shop_id' => $shopId,
                'erp_sku_id' => $businessGoods->external_sku_id,
            ],
            'type' => '更新库存',
        ];
    }
}

