50 lines
1.7 KiB
PHP
50 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Models\Consultation;
|
|
use App\Models\Course\Course;
|
|
use App\Models\MerchantShop;
|
|
use App\Models\Server\CommunityActivity;
|
|
use App\Models\Server\MerchantEvaluate;
|
|
use App\Models\Server\SurveyService as SurveyServiceModel;
|
|
class SurveyService
|
|
{
|
|
public function bindSurveyService($param)
|
|
{
|
|
switch ($param['type']) {
|
|
case 'activity':
|
|
case 'service':
|
|
$service = CommunityActivity::find($param['type_id']);
|
|
$pic = $service->pic;
|
|
$title = $service->title;
|
|
break;
|
|
case "course":
|
|
$course = Course::find($param['type_id']);
|
|
$pic = $course->thumb;
|
|
$title = $course->title;
|
|
break;
|
|
case "consult":
|
|
$consult = Consultation::find($param['type_id']);
|
|
$pic = $consult->pic;
|
|
$title = $consult->title;
|
|
break;
|
|
case "shop":
|
|
$shop = MerchantShop::find($param['type_id']);
|
|
$pic = $shop->icon;
|
|
$title = $shop->title;
|
|
break;
|
|
case "evaluate":
|
|
$evaluate = MerchantEvaluate::find($param['type_id']);
|
|
$pic = $evaluate->image;
|
|
$title = $evaluate->title;
|
|
break;
|
|
default:
|
|
throw new \Exception("参数类型错误");
|
|
}
|
|
$service = SurveyServiceModel::firstOrCreate(['m_id'=>$param['m_id'], 'survey_id'=>$param['survey_id'], 'type'=>$param['type'], 'type_id'=>$param['type_id'], 'num'=>0, 'title'=>$title, 'pic'=>$pic]);
|
|
return $service;
|
|
}
|
|
|
|
}
|