/** 
     * 设置商品信息 
     */
    public function setGoods()
    {
        try {
            $data = $this->request->post();
            $this->validate($data, ['product_id' => 'require']);
            
            $ids = is_array($data['product_id']) ? $data['product_id'] : [$data['product_id']];
            $ids = array_filter(array_map('trim', $ids), function($value) { return $value !== ''; });
            
            $batch = count($ids) > 1;
            if ($batch) {
                $existingIds = Goods::whereIn('product_id', $ids)->column('product_id');
                $existingIds = array_map('strtolower', $existingIds);
                $ids = array_map('strtolower', $ids);
                $newIds = array_diff($ids, $existingIds);
                if (empty($newIds)) {
                    return json(['code' => 200, 'msg' => '所有商品已存在，无需插入', 'count' => count($ids)]);
                }
                $rows = [];
                foreach ($newIds as $productId) {
                    $rows[] = ['product_id' => $productId];
                }
                $count = Goods::insertAll($rows, false);
                $this->clearLocksForIds($newIds);
                $this->clearIncompleteGoodsCache();
                return json(['code' => 200, 'msg' => '批量操作成功', 'count' => $count]);
            }

            $data['product_id'] = $ids[0];
            $goods = Goods::where('product_id', $data['product_id'])->findOrEmpty();
            if ($goods->isEmpty()) {
                $goods = new Goods();
                $goods->product_id = $data['product_id'];
                // $goods->short_url = $data['short_url'];
            }
            foreach (['detail', 'skus', 'properties', 'title', 'shop_id', 'sec_shop_id', 'shop_name','sub_content','short_url',
            'pic_url','category_ids','category_leaf_id'] as $field) {
                if (!empty($data[$field])) {
                    $goods->$field = is_array($data[$field]) ? json_encode($data[$field], JSON_UNESCAPED_UNICODE) : $data[$field];
                }
            }
            $goods->save();
            
            $lockKey = self::REDIS_LOCK_PREFIX . $data['product_id'];
            Cache::store('redis')->del($lockKey);
            
            $cacheKey = 'goods:' . $data['product_id'];
            $cacheData = [];
            if (!empty($goods->detail)) $cacheData['detail'] = $goods->detail;
            if (!empty($goods->properties)) $cacheData['properties'] = $goods->properties;
            if (!empty($goods->skus)) $cacheData['skus'] = $goods->skus;
            if (!empty($goods->sub_content)) $cacheData['sub_content'] = $goods->sub_content;
            if (!empty($goods->title)) $cacheData['title'] = $goods->title;
            if (!empty($goods->shop_id)) $cacheData['shop_id'] = $goods->shop_id;
            if (!empty($goods->sec_shop_id)) $cacheData['sec_shop_id'] = $goods->sec_shop_id;
            if (!empty($goods->shop_name)) $cacheData['shop_name'] = $goods->shop_name;
            if (!empty($goods->short_url)) $cacheData['short_url'] = $goods->short_url;
            if (!empty($goods->pic_url)) $cacheData['pic_url'] = $goods->pic_url;
            if (!empty($goods->category_ids)) $cacheData['category_ids'] = $goods->category_ids;
            if (!empty($goods->category_leaf_id)) $cacheData['category_leaf_id'] = $goods->category_leaf_id;
            
            Cache::set($cacheKey, $cacheData, 60 * 60 * 24 * 7);
            
            Cache::store('redis')->lpush(self::REDIS_CACHE_LIST_KEY, $data['product_id']);
            Cache::store('redis')->ltrim(self::REDIS_CACHE_LIST_KEY, 0, self::REDIS_CACHE_MAX - 1);
            $redis = Cache::store('redis');
            if ($redis->llen(self::REDIS_CACHE_LIST_KEY) > self::REDIS_CACHE_MAX) {
                $oldId = $redis->rpop(self::REDIS_CACHE_LIST_KEY);
                if ($oldId) {
                    Cache::delete('goods:' . $oldId);
                }
            }
            
            $this->clearIncompleteGoodsCache();
            
            return json(['code' => 200, 'msg' => '操作成功']);
        } catch (ValidateException $e) {
            return json(['code' => 400, 'msg' => $e->getMessage()]);
        } catch (\Exception $e) {
            return json(['code' => 500, 'msg' => $e->getMessage()]);
        }
    }

这个代码中的foreach (['detail', 'skus', 'properties', 'title', 'shop_id', 'sec_shop_id', 'shop_name','sub_content','short_url',
            'pic_url','category_ids','category_leaf_id'] as $field) {
                if (!empty($data[$field])) {
                    $goods->$field = is_array($data[$field]) ? json_encode($data[$field], JSON_UNESCAPED_UNICODE) : $data[$field];
                }
            }是什么意思