<?php

namespace App\Http\Controllers\Manage\Channel;

use App\Http\Controllers\Manage\BaseController;
use App\Http\Controllers\Manage\Channel\Transformers\ChannelQuestionNaireTransformer;
use App\Modules\Channel\Models\ChannelActivities;
use App\Modules\Channel\Models\ChannelQuestionNaire;
use App\Modules\Channel\Services\ChannelActivitiesService;
use App\Modules\Channel\Services\ChannelQuestionNaireService;
use App\Modules\Channel\Services\CompanyService;
use Illuminate\Http\Request;


class ChannelActivityController extends BaseController
{
    public function addActivity(Request $request) {
        $channel_id = $request->input('channel_id','');
        $begin_time = $request->input('start_time','');
        $end_time = $request->input('end_time','');
        $amount = $request->input('amount',500);
        if(empty($channel_id)||empty($begin_time)||empty($end_time)) {
            return response()->error('PARAM_EMPTY');
        }
        if(!in_array($amount,[500,1000])) {
            return response()->error('PARAM_ERROR');
        }
        $res = ChannelActivitiesService::addChannelActivity($channel_id,['begin_time'=>$begin_time,'end_time'=>$end_time,'amount'=>$amount]);
        return response()->success($res);
    }

    public function getActivities(Request $request) {
        $res = ChannelActivitiesService::getAll();
        return response()->success($res);
    }
}