|
@@ -147,10 +147,10 @@ class WebsiteService implements WebsiteServiceInterface
|
|
*/
|
|
*/
|
|
public function updateWebsite(int $id, array $data): array
|
|
public function updateWebsite(int $id, array $data): array
|
|
{
|
|
{
|
|
- $website = Website::where('id', $id)->first();
|
|
|
|
- if (empty($website)) {
|
|
|
|
- return Result::error("网站不存在", 0);
|
|
|
|
- }
|
|
|
|
|
|
+ $website = Website::where('id', $id)->first();
|
|
|
|
+ if (empty($website)) {
|
|
|
|
+ return Result::error("网站不存在", 0);
|
|
|
|
+ }
|
|
$insertData = [
|
|
$insertData = [
|
|
'website_name' => $data['website_name'],
|
|
'website_name' => $data['website_name'],
|
|
'logo' => $data['logo'] ?? '',
|
|
'logo' => $data['logo'] ?? '',
|
|
@@ -172,31 +172,31 @@ class WebsiteService implements WebsiteServiceInterface
|
|
if (!empty($web_templsate) && $web_templsate['status'] == 2) {
|
|
if (!empty($web_templsate) && $web_templsate['status'] == 2) {
|
|
return Result::error("此网站已应用,不可修改基本信息", 0);
|
|
return Result::error("此网站已应用,不可修改基本信息", 0);
|
|
}
|
|
}
|
|
-
|
|
|
|
- Db::beginTransaction();
|
|
|
|
- try{
|
|
|
|
- if($data['ad_key'] != $website['ad_key']){
|
|
|
|
|
|
+
|
|
|
|
+ Db::beginTransaction();
|
|
|
|
+ try {
|
|
|
|
+ if ($data['ad_key'] != $website['ad_key']) {
|
|
$web = Website::where(function ($query) use ($data) {
|
|
$web = Website::where(function ($query) use ($data) {
|
|
- $query->where('id','!=', $data['id'])
|
|
|
|
- ->where('ad_key', $data['ad_key']);
|
|
|
|
|
|
+ $query->where('id', '!=', $data['id'])
|
|
|
|
+ ->where('ad_key', $data['ad_key']);
|
|
})->first();
|
|
})->first();
|
|
if (!empty($web)) {
|
|
if (!empty($web)) {
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
return Result::error("网站名称简写重复,请填写", 0);
|
|
return Result::error("网站名称简写重复,请填写", 0);
|
|
}
|
|
}
|
|
- $ad_place = AdPlace::where('website_id', $data['id'])->select('ad_tag','id')->get()->toArray();
|
|
|
|
|
|
+ $ad_place = AdPlace::where('website_id', $data['id'])->select('ad_tag', 'id')->get()->toArray();
|
|
if (!empty($ad_place)) {
|
|
if (!empty($ad_place)) {
|
|
- foreach($ad_place as $key => $val){
|
|
|
|
|
|
+ foreach ($ad_place as $key => $val) {
|
|
$ad_keys = explode('_', $val['ad_tag']);
|
|
$ad_keys = explode('_', $val['ad_tag']);
|
|
$ad_keys[0] = $data['ad_key'];
|
|
$ad_keys[0] = $data['ad_key'];
|
|
$ad_place[$key]['ad_tag'] = implode('_', $ad_keys);
|
|
$ad_place[$key]['ad_tag'] = implode('_', $ad_keys);
|
|
|
|
|
|
// $up_adtags = AdPlace::where('id', $val['id'])->update(['ad_tag' => $ad_tags[$key]]);
|
|
// $up_adtags = AdPlace::where('id', $val['id'])->update(['ad_tag' => $ad_tags[$key]]);
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
$up_adtags = AdPlace::upsert($ad_place, ['id'], ['ad_tag']);
|
|
$up_adtags = AdPlace::upsert($ad_place, ['id'], ['ad_tag']);
|
|
|
|
|
|
- if(empty($up_adtags)){
|
|
|
|
|
|
+ if (empty($up_adtags)) {
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
return Result::error('广告位标识同步失败', 0);
|
|
return Result::error('广告位标识同步失败', 0);
|
|
}
|
|
}
|
|
@@ -207,26 +207,22 @@ class WebsiteService implements WebsiteServiceInterface
|
|
$uptemplate = WebsiteTemplate::where('website_id', $data['id'])->update([
|
|
$uptemplate = WebsiteTemplate::where('website_id', $data['id'])->update([
|
|
'template_data' => DB::raw("REPLACE(template_data, '{$website['ad_key']}', '{$data['ad_key']}')")
|
|
'template_data' => DB::raw("REPLACE(template_data, '{$website['ad_key']}', '{$data['ad_key']}')")
|
|
]);
|
|
]);
|
|
- if(empty($uptemplate)){
|
|
|
|
|
|
+ if (empty($uptemplate)) {
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
return Result::error("更新模板失败!", 0);
|
|
return Result::error("更新模板失败!", 0);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
// return Result::success($UP_template);
|
|
// return Result::success($UP_template);
|
|
|
|
|
|
$result = Website::where('id', $data['id'])->update($insertData);
|
|
$result = Website::where('id', $data['id'])->update($insertData);
|
|
- if(empty($result)){
|
|
|
|
|
|
+ if (empty($result)) {
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
return Result::error("更新网站失败!", 0);
|
|
return Result::error("更新网站失败!", 0);
|
|
}
|
|
}
|
|
Db::commit();
|
|
Db::commit();
|
|
return Result::success("更新成功");
|
|
return Result::success("更新成功");
|
|
-
|
|
|
|
- }catch(\Exception $e){
|
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
return Result::error($e->getMessage(), 0);
|
|
return Result::error($e->getMessage(), 0);
|
|
}
|
|
}
|
|
@@ -1717,6 +1713,8 @@ class WebsiteService implements WebsiteServiceInterface
|
|
// $randss = substr(str_shuffle($letters), 0, 4);
|
|
// $randss = substr(str_shuffle($letters), 0, 4);
|
|
|
|
|
|
$data['aLIas_pinyin'] = $aLIas_pinyin;
|
|
$data['aLIas_pinyin'] = $aLIas_pinyin;
|
|
|
|
+ //数据库先更新一下,再改path
|
|
|
|
+ WebsiteCategory::where($where)->update(['aLIas_pinyin' => $data['aLIas_pinyin']]);
|
|
//处理path
|
|
//处理path
|
|
$category_arr_id = json_decode($result['category_arr_id'], true);
|
|
$category_arr_id = json_decode($result['category_arr_id'], true);
|
|
//取出来设置path
|
|
//取出来设置path
|
|
@@ -2208,9 +2206,9 @@ class WebsiteService implements WebsiteServiceInterface
|
|
// if (!in_array(1, $foot_type) ) {
|
|
// if (!in_array(1, $foot_type) ) {
|
|
// $missingTypes[] = "列表型底部导航";
|
|
// $missingTypes[] = "列表型底部导航";
|
|
// }
|
|
// }
|
|
- if (!in_array(0, $foot_type) ) {
|
|
|
|
|
|
+ if (!in_array(0, $foot_type)) {
|
|
$missingTypes[] = "单页(详情)";
|
|
$missingTypes[] = "单页(详情)";
|
|
- }
|
|
|
|
|
|
+ }
|
|
if (!empty($missingTypes)) {
|
|
if (!empty($missingTypes)) {
|
|
$errorMessage = "请先添加" . $missingTypes . "!";
|
|
$errorMessage = "请先添加" . $missingTypes . "!";
|
|
return Result::error($errorMessage, 0);
|
|
return Result::error($errorMessage, 0);
|
|
@@ -2252,7 +2250,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
return Result::error("此网站的广告位正在使用中,暂不可编辑!", 0);
|
|
return Result::error("此网站的广告位正在使用中,暂不可编辑!", 0);
|
|
}
|
|
}
|
|
$check = $this->checkWebsiteBuild($data);
|
|
$check = $this->checkWebsiteBuild($data);
|
|
- if($check['code'] != 200){
|
|
|
|
|
|
+ if ($check['code'] != 200) {
|
|
return Result::error($check['message'], 0);
|
|
return Result::error($check['message'], 0);
|
|
}
|
|
}
|
|
// return Result::success($check);
|
|
// return Result::success($check);
|
|
@@ -3593,7 +3591,8 @@ class WebsiteService implements WebsiteServiceInterface
|
|
* @param array $data
|
|
* @param array $data
|
|
* @return array
|
|
* @return array
|
|
*/
|
|
*/
|
|
- public function delWebsiteUrl(array $data): array{
|
|
|
|
|
|
+ public function delWebsiteUrl(array $data): array
|
|
|
|
+ {
|
|
try {
|
|
try {
|
|
$wensiteInfo = Website::where(["id" => $data['website_id']])->first();
|
|
$wensiteInfo = Website::where(["id" => $data['website_id']])->first();
|
|
if (empty($wensiteInfo)) {
|
|
if (empty($wensiteInfo)) {
|