|
@@ -92,49 +92,35 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
];
|
|
|
return Result::success($data);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @param array $data
|
|
|
*/
|
|
|
public function createWebsite(array $data): array
|
|
|
{
|
|
|
var_dump("网站数据:", $data);
|
|
|
- $wzbs = PinyinHelper::getFirstLetter($data['website_name']);
|
|
|
+ // $wzbs = $this->getWebsitetAdkey($data);
|
|
|
+ // return Result::success($wzbs);
|
|
|
+ $web = Website::where('ad_key', $data['ad_key'])->first();
|
|
|
+ if (!empty($web)) {
|
|
|
+ return Result::error("网站名称简写重复,请填写", 0);
|
|
|
+ }
|
|
|
$insertData = [
|
|
|
'website_name' => $data['website_name'],
|
|
|
'logo' => $data['logo'] ?? '',
|
|
|
'website_url' => $data['website_url'] ?? '',
|
|
|
- // 'city_id'=>$data['city_id']??0,
|
|
|
+ //'city_id'=>$data['city_id']??0,
|
|
|
'website_column_id' => $data['website_column_id'],
|
|
|
'title' => $data['title'] ?? '',
|
|
|
'keywords' => $data['keywords'] ?? '',
|
|
|
'description' => $data['description'] ?? '',
|
|
|
'status' => $data['status'] ?? 1,
|
|
|
'website_column_arr_id' => $data['website_column_arr_id'],
|
|
|
- // 'city_arr_id'=>$data['city_arr_id']??[0],
|
|
|
+ //'city_arr_id'=>$data['city_arr_id']??[0],
|
|
|
'template_id' => $data['template_id'] ?? 0,
|
|
|
'suffix' => $data['suffix'] ?? "",
|
|
|
- // 'ad_key' => $wzbs,
|
|
|
- ];
|
|
|
-
|
|
|
- // return Result::success($result);
|
|
|
- // 检查网站名称是否重复或者 ad_key 是否重复
|
|
|
- $web = Website::where('ad_key', $wzbs)->first();
|
|
|
- // return Result::success(!empty($web->toArray()));
|
|
|
- if (!empty($web)) {
|
|
|
- if(!empty($data['ad_key']) && $data['ad_key']!='' && $data['ad_key']!=$wzbs){
|
|
|
- $web_adkey = Website::where('ad_key', $data['ad_key'])->first();
|
|
|
- if (!empty($web_adkey)) {
|
|
|
- return Result::error("网站名称简写重复,请重新填写", 0);
|
|
|
- }else{
|
|
|
- $insertData['ad_key'] = $data['ad_key'];
|
|
|
- }
|
|
|
- }else{
|
|
|
- return Result::error("网站名称简写重复,请填写", 0);
|
|
|
- }
|
|
|
- }else{
|
|
|
- $insertData['ad_key'] = $wzbs;
|
|
|
- }
|
|
|
+ 'ad_key' => $data['ad_key']?? "",
|
|
|
+ ];
|
|
|
$result = Website::insertGetId($insertData);
|
|
|
if (empty($result)) {
|
|
|
return Result::error("创建网站失败", 0);
|
|
@@ -150,8 +136,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
*/
|
|
|
public function updateWebsite(int $id, array $data): array
|
|
|
{
|
|
|
-
|
|
|
- $wzbs = PinyinHelper::getFirstLetter($data['website_name']);
|
|
|
$insertData = [
|
|
|
'website_name' => $data['website_name'],
|
|
|
'logo' => $data['logo'] ?? '',
|
|
@@ -166,29 +150,21 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
// 'city_arr_id'=>$data['city_arr_id']??[0],
|
|
|
'template_id' => $data['template_id'] ?? 0,
|
|
|
'suffix' => $data['suffix'] ?? "",
|
|
|
+ 'ad_key' => $data['ad_key']?? "",
|
|
|
];
|
|
|
$web_templsate = WebsiteTemplateInfo::where('website_id', $data['id'])->first();
|
|
|
// `status` tinyint(1) DEFAULT '0' COMMENT '0:未构建 1:未应用 2:已应用',
|
|
|
if (!empty($web_templsate) && $web_templsate['status'] == 2) {
|
|
|
return Result::error("此网站已应用,不可修改基本信息", 0);
|
|
|
}
|
|
|
- $web = Website::where('ad_key', $wzbs)->first();
|
|
|
+ $web = Website::where(function ($query) use ($data) {
|
|
|
+ $query->where('id','!=', $data['id'])
|
|
|
+ ->where('ad_key', $data['ad_key']);
|
|
|
+ })->first();
|
|
|
if (!empty($web)) {
|
|
|
- if (!empty($data['ad_key']) && $data['ad_key'] != '' && $data['ad_key'] != $wzbs) {
|
|
|
- $web_adkey = Website::where('ad_key', $data['ad_key'])->first();
|
|
|
- // return Result::success($web_adkey);
|
|
|
- if (!empty($web_adkey)) {
|
|
|
- return Result::error("网站名称简写重复,请重新填写", 0);
|
|
|
- }else{
|
|
|
- $insertData['ad_key'] = $data['ad_key'];
|
|
|
- }
|
|
|
- }else{
|
|
|
- return Result::error("网站名称简写重复,请填写", 0);
|
|
|
- }
|
|
|
- }else{
|
|
|
- $insertData['ad_key'] = $wzbs;
|
|
|
+ return Result::error("网站名称简写重复,请填写", 0);
|
|
|
}
|
|
|
- $result = Website::where('id', $id)->update($insertData);
|
|
|
+ $result = Website::where('id', $data['id'])->update($insertData);
|
|
|
// var_dump("更新站点", $result);
|
|
|
if (empty($result)) {
|
|
|
return Result::error("更新网站失败", 0);
|
|
@@ -196,7 +172,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
return Result::success("更新成功");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* @param int $id
|
|
|
* @return array
|
|
@@ -669,7 +644,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$pidQuery = WebsiteCategory::where($website_id)
|
|
|
->where('pid', '!=', 0)
|
|
|
->orderBy('sort')
|
|
|
- ->select('pid', 'category_id', 'alias');
|
|
|
+ ->select('pid', 'category_id', 'alias','aLIas_pinyin');
|
|
|
$pid = $pidQuery->pluck('pid');
|
|
|
$pid = array_values(array_unique($pid->toArray()));
|
|
|
|
|
@@ -712,6 +687,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$pidResult = $pidMap->get($record->category_id);
|
|
|
$record->chilid_id = $pidResult->category_id;
|
|
|
$record->chilid_alias = $pidResult->alias;
|
|
|
+ // $record->aLIas_pinyin = $pidResult->aLIas_pinyin;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -2699,5 +2675,19 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 获取网站名称缩写
|
|
|
+ * @param array $data
|
|
|
+ */
|
|
|
+ public function getWebsiteAdkey(array $data): array
|
|
|
+ {
|
|
|
+
|
|
|
+ $result = PinyinHelper::getFirstLetter($data['website_name']);
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("没有数据", 0);
|
|
|
+ } else {
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ }
|
|
|
// --自助建站-----------20250522fr----------------------end
|
|
|
}
|