作者 lyh

更新修改

@@ -9,6 +9,7 @@ use App\Http\Logic\Bside\BaseLogic; @@ -9,6 +9,7 @@ use App\Http\Logic\Bside\BaseLogic;
9 use App\Models\Com\NoticeLog; 9 use App\Models\Com\NoticeLog;
10 use App\Models\News\News; 10 use App\Models\News\News;
11 use App\Models\Product\Keyword; 11 use App\Models\Product\Keyword;
  12 +use App\Models\Product\KeywordRelated;
12 use App\Models\Product\Product; 13 use App\Models\Product\Product;
13 use App\Models\RouteMap\RouteMap; 14 use App\Models\RouteMap\RouteMap;
14 use Illuminate\Support\Facades\DB; 15 use Illuminate\Support\Facades\DB;
@@ -207,6 +208,7 @@ class KeywordLogic extends BaseLogic @@ -207,6 +208,7 @@ class KeywordLogic extends BaseLogic
207 $this->delRoute($id); 208 $this->delRoute($id);
208 $this->model->del(['id'=>$id]); 209 $this->model->del(['id'=>$id]);
209 } 210 }
  211 + (new KeywordRelated())->del(['keyword_id'=>['in',$ids]]);
210 //清除缓存 212 //清除缓存
211 Common::del_user_cache('product_keyword',$this->user['project_id']); 213 Common::del_user_cache('product_keyword',$this->user['project_id']);
212 return $this->success(); 214 return $this->success();
@@ -270,11 +272,23 @@ class KeywordLogic extends BaseLogic @@ -270,11 +272,23 @@ class KeywordLogic extends BaseLogic
270 */ 272 */
271 public function batchDel(){ 273 public function batchDel(){
272 try { 274 try {
  275 + $productModel = new Product();
273 foreach ($this->param['title'] as $v){ 276 foreach ($this->param['title'] as $v){
274 $info = $this->model->read(['title'=>$v]); 277 $info = $this->model->read(['title'=>$v]);
275 if($info){ 278 if($info){
276 $this->delRoute($info['id']); 279 $this->delRoute($info['id']);
277 $this->model->del(['id'=>$info['id']]); 280 $this->model->del(['id'=>$info['id']]);
  281 + $id = $info['id'];
  282 + $replace_id = ','.$id.',';
  283 + $productModel->where('keyword_id', 'like', '%,' . $id . ',%')
  284 + ->update([
  285 + 'keyword_id' => DB::raw("REPLACE(keyword_id, '$replace_id' , ',')")
  286 + ]);
  287 + $productModel->where('keyword_id', ',')
  288 + ->update([
  289 + 'keyword_id' => DB::raw("REPLACE(keyword_id, ',' , '')")
  290 + ]);
  291 + (new KeywordRelated())->del(['keyword_id'=>$id]);
278 } 292 }
279 } 293 }
280 //清除缓存 294 //清除缓存
@@ -66,6 +66,7 @@ class ProductLogic extends BaseLogic @@ -66,6 +66,7 @@ class ProductLogic extends BaseLogic
66 } 66 }
67 //产品分类关联 67 //产品分类关联
68 CategoryRelated::saveRelated($id, $category_ids); 68 CategoryRelated::saveRelated($id, $category_ids);
  69 + KeywordRelated::saveRelated($id,$category_ids);
69 //保存扩展字段 70 //保存扩展字段
70 $this->saveExtendInfo($id,$extend); 71 $this->saveExtendInfo($id,$extend);
71 }catch (\Exception $e){ 72 }catch (\Exception $e){
@@ -62,8 +62,8 @@ class RouteMap extends Base @@ -62,8 +62,8 @@ class RouteMap extends Base
62 $i=1; 62 $i=1;
63 $sign = generateRoute($title); 63 $sign = generateRoute($title);
64 $length = strlen($sign); 64 $length = strlen($sign);
65 - if($length > 100){  
66 - $sign = trim(mb_substr($sign, 0, 100, 'UTF-8'),'-'); 65 + if($length > 180){
  66 + $sign = trim(mb_substr($sign, 0, 180, 'UTF-8'),'-');
67 } 67 }
68 $info = self::where(['project_id' => $project_id, 'source' => $source, 'source_id'=>$source_id])->first(); 68 $info = self::where(['project_id' => $project_id, 'source' => $source, 'source_id'=>$source_id])->first();
69 $suffix = ''; 69 $suffix = '';