<?php


namespace App\Servers\Upload;


use App\Servers\Aliyun\Oss;

class UploadDiyTemplateService
{
    //上传系统模版
    public function uploadManagerDiyTemplate($filePath, $templateId, $type)
    {
        $bucket = config('aliyun.oss.bucket','kailin-saas');

        $object = 'uploads/manager/diy_template/' . $templateId . '_' . $type . '.json';

        $oss = new Oss();

        $url = $oss->uploadDiyFile($filePath, $bucket , $object);

        if (empty($url)) {
            return false ;
        }

        return $url;

    }

    public function uploadManagerDiyBottomTemplate($filePath, $templateId, $type)
    {
        $bucket = config('aliyun.oss.bucket','kailin-saas');

        $object = 'uploads/manager/diy_bottom_template/' . $templateId . '_' . $type . '.json';

        $oss = new Oss();

        $url = $oss->uploadDiyFile($filePath, $bucket , $object);

        if (empty($url)) {
            return false ;
        }

        return $url;

    }

    //上传商户店铺模版
    public function uploadCompanyAndShopDiy($filePath, $id, $type, $companyId, $shopId)
    {
        $bucket = config('aliyun.oss.bucket','kailin-saas');

        //'uploads/company/' . $companyId . '/shop' . $shopId . '/diy/';
        //$object = 'uploads/manager/diy_template/' . $templateId . '_' . $type . '.json';
        $object = 'uploads/company/' . $companyId . '/shop/' . $shopId . '/diy/' . $id . '_' . $type . '.json';

        $oss = new Oss();

        $url = $oss->uploadDiyFile($filePath, $bucket , $object);

        if (empty($url)) {
            return false ;
        }

        return $url;

    }

    //上传商户店铺底部栏
    public function uploadCompanyAndShopDiyBottom($filePath, $id, $type, $companyId, $shopId)
    {
        $bucket = config('aliyun.oss.bucket','kailin-saas');

        //$object = 'uploads/manager/diy_bottom_template/' . $id . '_' . $type . '.json';
        $object = 'uploads/company/' . $companyId . '/shop/' . $shopId . '/diy_bottom/' . $id . '_' . $type . '.json';

        $oss = new Oss();

        $url = $oss->uploadDiyFile($filePath, $bucket , $object);

        if (empty($url)) {
            return false ;
        }

        return $url;

    }

}