EnterpriseProductLogic.php 2.1 KB
<?php
/**
 * @remark :
 * @name   :EnterpriseProductLogic.php
 * @author :lyh
 * @method :post
 * @time   :2025/3/26 10:10
 */

namespace App\Http\Logic\Aside\Project;

use App\Http\Logic\Aside\BaseLogic;
use App\Models\Geo\GeoLink;
use App\Models\Project\EnterpriseProduct;
use App\Models\SeoSetting\LinkData;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;

/**
 * @remark :企业产品库
 * @name   :EnterpriseProductLogic
 * @author :lyh
 * @method :post
 * @time   :2025/3/26 10:13
 */
class EnterpriseProductLogic extends BaseLogic
{
    public function __construct()
    {
        parent::__construct();
        $this->model = new EnterpriseProduct();
        $this->param = $this->requestAll;
    }

    /**
     * @remark :保存产品企业库
     * @name   :saveEnterpriseProduct
     * @author :lyh
     * @method :post
     * @time   :2025/3/26 10:17
     */
    public function saveEnterpriseProduct(){
        try {
            $this->model->saveEnterpriseProduct($this->param['project_id'],$this->param['data']);
        }catch (\Exception $e){
            $this->fail('保存失败,请联系管理员');
        }
        return $this->success();
    }


    /**
     * @remark :批量保存外链数据
     * @name   :saveLinkData
     * @author :lyh
     * @method :post
     * @time   :2025/4/2 9:08
     */
    public function saveLinkData(){
        $linkModel = new GeoLink();
        $data = [];
        $count = count($this->param['data']);
        $error_num = 0;
        foreach ($this->param['data'] as $v){
            if(empty($v['send_time'])){
                $error_num++;
                continue;
            }
            $data[] = [
                'url'=>$v['url'],
                'type'=>$linkModel::TYPE_LINK,
                'da_values'=>$v['da_values'],
                'project_id'=>$this->param['project_id'],
                'send_time'=>$v['send_time'] ?? date('Y-m-d H:i:s')
            ];
        }
        if(!empty($data)){
            $linkModel->insertAll($data);
        }
        return $this->success(['success'=>$count,'error'=>$error_num]);
    }
}