| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 | 
							- <?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[] = [
 
-             'w_word', 'like', '%' . $key . '%',
 
-         ];
 
-         $where[] = ['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 ['key' => $key, 'list' => $lists];
 
-         }
 
-         return false;
 
-     }
 
-     public function setMemberHotword($key, $type = 1)
 
-     {
 
-         $user = [
 
-             'utype' => 0,
 
-             'uid'   => 0,
 
-         ];
 
-         if (auth('web-member')->check()) {
 
-             $user = [
 
-                 'utype' => 2,
 
-                 'uid'   => auth('web-member')->user()->id,
 
-             ];
 
-         } elseif (auth('web-company')->check()) {
 
-             $user = [
 
-                 'utype' => 1,
 
-                 'uid'   => auth('web-company')->user()->id,
 
-             ];
 
-         }
 
-         $where[] = ['w_word', 'like', '%' . $key . '%',];
 
-         $where[] = ['type', '=', $type];
 
-         $where[] = ['utype', '=', $user['utype']];
 
-         $where[] = ['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 ['key' => $key, 'list' => $lists];
 
-         }
 
-     }
 
-     public function getHotWords($where = [], $order = 'w_hot desc', $limit = '')
 
-     {
 
-         return $this->hotWordRepository->getHotWords($where, $order, $limit);
 
-     }
 
-     public function searchHostWords($key, $type = 1)
 
-     {
 
-         $this->hotWordRepository->setInc($key, $type);
 
-     }
 
- }
 
 
  |