| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 | 
							- <?php
 
- /**
 
-  * Created by PhpStorm.
 
-  * User: Administrator
 
-  * Date: 2018/12/4
 
-  * Time: 10:23
 
-  */
 
- namespace App\Services\Common;
 
- use App\Repositories\HotWordRepository;
 
- use App\Repositories\MemberHotwordRepository;
 
- //use Illuminate\Support\Facades\Cache;
 
- class HotWordService
 
- {
 
-     protected $hotWordRepository;
 
-     protected $memberHotwordRepository;
 
-     /**
 
-      * HotWordService constructor.
 
-      * @param $hotWordRepository
 
-      */
 
-     public function __construct(HotWordRepository $hotWordRepository, MemberHotwordRepository $memberHotwordRepository)
 
-     {
 
-         $this->hotWordRepository = $hotWordRepository;
 
-         $this->memberHotwordRepository = $memberHotwordRepository;
 
-     }
 
-     public function getHotWord($key, $type = 1)
 
-     {
 
-         $where[] = array(
 
-             'w_word', 'like', '%'.$key.'%',
 
-         );
 
-         $where[] = array('type','=',$type);
 
-         $order = 'list_order desc,w_hot desc';
 
-         $lists = $this->hotWordRepository->getHotWords($where, $order);
 
-         //修改热门关键字记录
 
-         $word_rst = $this->hotWordRepository->setInc($key, $type);
 
-         if ($lists->toArray()) {
 
-             return array('key'=>$key,'list'=>$lists);
 
-         }
 
-         return false;
 
-     }
 
-     public function setMemberHotword($key, $type = 1)
 
-     {
 
-         $user = array(
 
-             'utype' => 0,
 
-             'uid'   => 0
 
-         );
 
-         if (auth('web-member')->check()) {
 
-             $user = array(
 
-                 'utype' => 2,
 
-                 'uid'   => auth('web-member')->user()->id
 
-             );
 
-         } elseif (auth('web-company')->check()) {
 
-             $user = array(
 
-                 'utype' => 1,
 
-                 'uid'   => auth('web-company')->user()->id
 
-             );
 
-         }
 
-         $where[] = array('w_word', 'like', '%'.$key.'%',);
 
-         $where[] = array('type','=',$type);
 
-         $where[] = array('utype','=',$user['utype']);
 
-         $where[] = array('uid','=',$user['uid']);
 
-         $order = 'list_order desc,w_hot desc';
 
-         $lists = $this->memberHotwordRepository->getHotWords($where, $order);
 
-         //修改热门关键字记录
 
-         $word_rst = $this->memberHotwordRepository->setInc($key, $type, $user);
 
-         if ($lists->toArray()) {
 
-             return array('key'=>$key,'list'=>$lists);
 
-         }
 
-     }
 
-     public function getHotWords($where = array (), $order = 'w_hot desc', $limit = '')
 
-     {
 
-         return $this->hotWordRepository->getHotWords($where, $order, $limit);
 
-     }
 
- }
 
 
  |