|
@@ -654,16 +654,16 @@ class NewsService implements NewsServiceInterface
|
|
*/
|
|
*/
|
|
public function getWebsiteSurvey(array $data): array
|
|
public function getWebsiteSurvey(array $data): array
|
|
{
|
|
{
|
|
- if (isset($data['survey_id']) && !empty($data['survey_id'])) {
|
|
|
|
- $website = Website::where('id', $data['website_id'])->first();
|
|
|
|
- if (empty($website)) {
|
|
|
|
- return Result::error("暂无此网站", 0);
|
|
|
|
|
|
+ if(isset($data['website_id']) && !empty($data['website_id'])){
|
|
|
|
+ $website = Website::where('id',$data['website_id'])->first();
|
|
|
|
+ if(empty($website)){
|
|
|
|
+ return Result::error("暂无此网站",0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (isset($data['art_id']) && !empty($data['art_id'])) {
|
|
|
|
- $article = Article::where('id', $data['art_id'])->first();
|
|
|
|
- if (empty($article)) {
|
|
|
|
- return Result::error("暂无此文章", 0);
|
|
|
|
|
|
+ if(isset($data['art_id']) && !empty($data['art_id'])){
|
|
|
|
+ $article = Article::where('id',$data['art_id'])->where('status',1)->first();
|
|
|
|
+ if(empty($article)){
|
|
|
|
+ return Result::error("暂无此文章",0);
|
|
}
|
|
}
|
|
// return Result::error($data,0);
|
|
// return Result::error($data,0);
|
|
$where['art_id'] = $data['art_id'];
|
|
$where['art_id'] = $data['art_id'];
|
|
@@ -677,14 +677,14 @@ class NewsService implements NewsServiceInterface
|
|
$where['sur_id'] = $survey['sur_id'];
|
|
$where['sur_id'] = $survey['sur_id'];
|
|
// $query = ArticleSurvey::where('sur_id',$survey['sur_id']);
|
|
// $query = ArticleSurvey::where('sur_id',$survey['sur_id']);
|
|
}
|
|
}
|
|
- $result['survey'] = ArticleSurvey::where($where)->where('is_other', 0)
|
|
|
|
- ->leftJoin('article', 'article_survey.art_id', 'article.id')
|
|
|
|
- ->select('article_survey.*', 'article.survey_type')
|
|
|
|
- ->get()->all();
|
|
|
|
- $result['others'] = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', 0)->first();
|
|
|
|
- $result['other'] = ArticleSurvey::where($where)->where('is_other', 1)->where('other_id', '!=', 0)->orderByDesc('created_at')->first();
|
|
|
|
- if (empty($result)) {
|
|
|
|
- return Result::error("此文章暂无调查问卷", 0);
|
|
|
|
|
|
+ $result['survey'] = ArticleSurvey::where($where)->where('is_other',0)
|
|
|
|
+ ->leftJoin('article','article_survey.art_id','article.id')
|
|
|
|
+ ->select('article_survey.*','article.survey_type')
|
|
|
|
+ ->get()->all();
|
|
|
|
+ $result['other'] = ArticleSurvey::where($where)->where('is_other',1)->where('other_id',0)->first();
|
|
|
|
+ $result['others'] = ArticleSurvey::where($where)->where('is_other',1)->where('other_id','!=',0)->orderByDesc('created_at')->first();
|
|
|
|
+ if(empty($result)){
|
|
|
|
+ return Result::error("此文章暂无调查问卷",0);
|
|
}
|
|
}
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
}
|
|
}
|
|
@@ -735,11 +735,11 @@ class NewsService implements NewsServiceInterface
|
|
*/
|
|
*/
|
|
public function addWebsiteSurveyVote(array $data): array
|
|
public function addWebsiteSurveyVote(array $data): array
|
|
{
|
|
{
|
|
-
|
|
|
|
- if (isset($data['website_id']) && !empty($data['website_id'])) {
|
|
|
|
- $website = Website::where('id', $data['website_id'])->first();
|
|
|
|
- if (empty($website)) {
|
|
|
|
- return Result::error("暂无此网站", 0);
|
|
|
|
|
|
+
|
|
|
|
+ if(isset($data['website_id']) && !empty($data['website_id'])){
|
|
|
|
+ $website = Website::where('id',$data['website_id'])->first();
|
|
|
|
+ if(empty($website)){
|
|
|
|
+ return Result::error("暂无此网站",0);
|
|
}
|
|
}
|
|
if (isset($data['sur_id']) && !empty($data['sur_id'])) {
|
|
if (isset($data['sur_id']) && !empty($data['sur_id'])) {
|
|
$survey = ArticleSurvey::where('sur_id', $data['sur_id'])->where('website_id', $data['website_id'])->pluck('sur_id');
|
|
$survey = ArticleSurvey::where('sur_id', $data['sur_id'])->where('website_id', $data['website_id'])->pluck('sur_id');
|
|
@@ -900,4 +900,53 @@ class NewsService implements NewsServiceInterface
|
|
}
|
|
}
|
|
|
|
|
|
//20250226 产品列表
|
|
//20250226 产品列表
|
|
-}
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 后端-获取网站调查问卷列表
|
|
|
|
+ * @param array $data
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function getSurveyList(array $data): array
|
|
|
|
+ {
|
|
|
|
+ $result = Article::where('is_survey',1)
|
|
|
|
+ // ->select('id','survey_id','survey_type')
|
|
|
|
+ ->orderByDesc('updated_at')
|
|
|
|
+ ->limit($data['pageSize'])
|
|
|
|
+ ->offset(($data['page']-1)*$data['pageSize'])
|
|
|
|
+ ->get();
|
|
|
|
+ if(empty($result)){
|
|
|
|
+ return Result::error("暂无调查问卷",0);
|
|
|
|
+ }
|
|
|
|
+ return Result::success($result);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 后端-获取网站调查问卷详情
|
|
|
|
+ * @param array $data
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function getSurveyInfo(array $data): array
|
|
|
|
+ {
|
|
|
|
+ if(isset($data['sur_id']) &&!empty($data['sur_id'])){
|
|
|
|
+ $where = [ 'sur_id'=>$data['sur_id']];
|
|
|
|
+ $result['survey'] = ArticleSurvey::where($where)->where('is_other',0)
|
|
|
|
+ ->leftJoin('article','article_survey.art_id','article.id')
|
|
|
|
+ ->select('article_survey.*','article.survey_type')
|
|
|
|
+ ->get()->all();
|
|
|
|
+ if(empty($result)){
|
|
|
|
+ return Result::error("此调查问卷不存在",0);
|
|
|
|
+ }
|
|
|
|
+ $resultsArray = array_column($result['survey'], 'results');
|
|
|
|
+ $total = array_sum($resultsArray);
|
|
|
|
+ // $total = $result['survey']->sum('results');
|
|
|
|
+ $result['other'] = ArticleSurvey::where($where)->where('is_other',1)->where('other_id',0)->first();
|
|
|
|
+ $result['others'] = ArticleSurvey::where($where)->where('is_other',1)->where('other_id','!=',0)->orderByDesc('created_at')->first();
|
|
|
|
+
|
|
|
|
+ // $total = 0;
|
|
|
|
+ if(!empty($result['other'])){
|
|
|
|
+ $total = $total + $result['other']['results'];
|
|
|
|
+ }
|
|
|
|
+ $result['total'] = $total;
|
|
|
|
+ }
|
|
|
|
+ return Result::success($result);
|
|
|
|
+ }
|
|
|
|
+}
|