You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.5 KiB
PHP

<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class PlanController extends Controller
{
//创建号源
public function CreatePlan()
{
$Info =request('CPlan');
$params = [
'model_id' => isset($Info['model_id']) ? $Info['model_id'] : null,
'week' => isset($Info['week']) ? $Info['week'] : null,
'workday_create' => isset($Info['workday_create']) ? $Info['workday_create'] : null,
'holiday_create' => isset($Info['holiday_create']) ? $Info['holiday_create'] : null,
];
$requiredFields = ['model_id'=>'模板id','week'=>'星期','workday_create'=>'工作日是否生成','holiday_create'=>'节假日是否生成'];
// 判断是否为空
foreach ($requiredFields as $key=> $field) {
if (!isset($params[$key]) || $params[$key] === null) {
return \Yz::echoError1('参数 ' . $field . ' 不能为空');
}
}
if(!isset($Info['TimeRange']) or count($Info['TimeRange'])<>2){
return \Yz::echoError1('起止时间格式错误');
}
$model=DB::table('plan_model as a')->where(['a.id'=>$params['model_id'],'a.is_del'=>0,'a.status'=>1])->first();
if(!$model) return \Yz::echoError1('模板不可用');
$planType=DB::table('plan_type')->where(['id'=>$model->plan_type,'a.is_del'=>0,'a.status'=>1])->first();
if(!$planType) return \Yz::echoError1('号源类型不可用');
}
}