RatingController.php 2.5 KB
<?php
/**
 * @remark :
 * @name   :RatingController.php
 * @author :lyh
 * @method :post
 * @time   :2024/1/20 14:02
 */

namespace App\Http\Controllers\Bside\Scoring;

use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Scoring\RatingLogic;
use App\Models\Scoring\RatingQuestion;
use App\Models\Scoring\ScoringSystem;
use App\Models\Sms\SmsLog;
use App\Models\User\User;
use Illuminate\Support\Facades\Cache;
use Mrgoon\AliSms\AliSms;

/**
 * @remark :评分系统问题管理
 * @name   :RatingController
 * @author :lyh
 * @method :post
 * @time   :2024/1/20 14:02
 */
class RatingController extends BaseController
{

    /**
     * @remark :问卷调查详情
     * @name   :getProjectRead
     * @author :lyh
     * @method :post
     * @time   :2024/1/20 14:11
     */
    public function getProjectRead(RatingLogic $ratingLogic){
        $this->request->validate([
            'type' => 'required',
        ],[
            'type.required' => '问题类型不能为空',
        ]);
        $info = $ratingLogic->getRatingRead();
        $this->response('success',Code::SUCCESS,$info);
    }

    /**
     * @remark :提交评分
     * @name   :save
     * @author :lyh
     * @method :post
     * @time   :2024/1/20 14:43
     */
    public function save(RatingLogic $ratingLogic){
        $this->request->validate([
            'data' => 'required',
            'mobile' => 'required',
            'type'=> 'required'
        ],[
            'data.required' => '请填写完整',
            'mobile.required' => '手机号码不能为空',
            'type.required' => '阶段不能为空',
        ]);
        $ratingLogic->ratingSave();
        $this->response('success');
    }

    /**
     * @remark :问卷调查验证验证码
     * @name   :VerificationCode
     * @author :lyh
     * @method :post
     * @time   :2024/1/22 11:23
     */
    public function verificationCode(){
        $smsModel = new SmsLog();
        $smsInfo = $smsModel->formatQuery(['mobile'=>$this->param['mobile'],'type'=>$smsModel::TYPE_CORING])->orderBy('id','desc')->first();
        if(!empty($smsInfo)){
            if(($this->param['code'] != $smsInfo['code']) || ($smsInfo['created_at']  < date('Y-m-d H:i:s',time() - 300))){
                $this->response('验证码已过期或验证码错误',Code::SYSTEM_ERROR);
            }
        }else{
            $this->response('验证码错误',Code::SYSTEM_ERROR);
        }
        $this->response('success');
    }
}