| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- /**
- * @package merchant
- *
- * @author xaboy
- * @day 2020-04-15
- *
- *
- */
- namespace app\common\middleware;
- use app\common\repositories\user\UserVisitRepository;
- use app\Request;
- use crmeb\services\SwooleTaskService;
- use think\Response;
- class VisitProductMiddleware extends BaseMiddleware
- {
- public function before(Request $request)
- {
- // TODO: Implement before() method.
- }
- public function after(Response $response)
- {
- $id = intval($this->request->param('id'));
- if ($this->request->isLogin() && $id) {
- $uid = $this->request->uid();
- if(!app()->make(UserVisitRepository::class)->getWhereCount(['type'=>'product','uid' => $uid,'type_id' => $id])){
- SwooleTaskService::visit(intval($uid), $id, 'product');
- }
- }
- }
- }
|