RenewProjectController.php 2.6 KB
<?php
/**
 * @remark :
 * @name   :RenewProjectController.php
 * @author :lyh
 * @method :post
 * @time   :2023/8/11 10:22
 */

namespace App\Http\Controllers\Aside\Project;

use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Http\Logic\Aside\Project\RenewLogic;
use App\Models\HomeCount\Count;
use App\Models\Project\DeployOptimize;
use Carbon\Carbon;

class RenewProjectController extends BaseController
{
    /**
     * @remark :获取所有服务天数小于15天的项目
     * @name   :lists
     * @author :lyh
     * @method :post
     * @time   :2023/8/11 10:22
     */
    public function lists(ProjectLogic $logic){
        $count = new Count();
        $yesterday = Carbon::yesterday()->toDateString();
        $count_list = $count->list(['date'=>$yesterday,'service_day'=>['<=',15]],'id',['project_id']);
        $arr = [];
        foreach ($count_list as $v){
            $arr[] = $v['project_id'];
        }
        $sort = ['id' => 'desc'];
        //按类型搜索
        $map[] = ['id', 'in', $arr];
        if(!empty($this->param['search']) && !empty($this->param['search_type'])){
            if($this->param['search_type'] == 'domain'){
                //搜索域名
                $map[] = ['id', 'in', DeployOptimize::where('domain', 'like', "%{$this->param['search']}%")->where('id','in',$arr)->pluck('project_id')->toArray()];
            }else{
                $map[] = [$this->param['search_type'], 'like', "%{$this->param['search']}%"];
            }
        }
        $data = $logic->getList($map, $sort,['*'],$this->row);
        $this->response('success',Code::SUCCESS,$data);
    }

    /**
     * @remark :续费记录单
     * @name   :renewLists
     * @author :lyh
     * @method :post
     * @time   :2023/8/11 17:28
     */
    public function renewLists(RenewLogic $logic){
        if(isset($this->map['company']) && !empty($this->map['company'])){
            $this->map['company'] = ['like','%'.$this->map['company'].'%'];
        }
        $lists = $logic->renewListsLog($this->map,$this->page,$this->row,$this->order);
        $this->response('success',Code::SUCCESS,$lists);
    }

    /**
     * @remark :获取续费单详情
     * @name   :info
     * @author :lyh
     * @method :post
     * @time   :2023/8/14 9:08
     */
    public function info(RenewLogic $logic){
        $this->request->validate([
            'id'=>'required',
        ],[
            'id.required' => 'ID不能为空'
        ]);
        $info = $logic->renewRead();
        $this->response('success',Code::SUCCESS,$info);
    }
}