1 个管道
的构建
通过
耗费
0 秒
正在显示
4 个修改的文件
包含
24 行增加
和
11 行删除
@@ -39,6 +39,7 @@ class IndexController extends RestBaseController | @@ -39,6 +39,7 @@ class IndexController extends RestBaseController | ||
39 | '40011' => '该产品不存在', | 39 | '40011' => '该产品不存在', |
40 | '40012' => '您已被管理员拉黑', | 40 | '40012' => '您已被管理员拉黑', |
41 | '40013' => '余额不足2元', | 41 | '40013' => '余额不足2元', |
42 | + '40014' => '不能申请自己的产品', | ||
42 | ] | 43 | ] |
43 | ]; | 44 | ]; |
44 | $this->success("恭喜您,API访问成功!", $data); | 45 | $this->success("恭喜您,API访问成功!", $data); |
@@ -149,16 +149,20 @@ class CardController extends RestBaseController | @@ -149,16 +149,20 @@ class CardController extends RestBaseController | ||
149 | } else { | 149 | } else { |
150 | $result['is_like'] = 0; | 150 | $result['is_like'] = 0; |
151 | } | 151 | } |
152 | - //添加该名片的被浏览记录 | 152 | + //添加该名片的被浏览记录 名片入口 |
153 | Db::startTrans(); | 153 | Db::startTrans(); |
154 | $is_exist = Db::name('browse_log') | 154 | $is_exist = Db::name('browse_log') |
155 | - ->where(['topic_id' => $data['id'],'user_id' => $this->userId]) | 155 | + ->where(['topic_id' => $data['id'],'user_id' => $this->userId,'type' =>1]) |
156 | ->field('id') | 156 | ->field('id') |
157 | ->find(); | 157 | ->find(); |
158 | - if ($is_exist) { | ||
159 | - $do1 = Db::name('browse_log')->where(['topic_id' => $data['id'],'user_id' => $this->userId])->update(['create_time' => date('Y-m-d H:i:s')]); | ||
160 | - } else { | ||
161 | - $do1 = Db::name('browse_log')->insert(['topic_id' => $data['id'],'user_id' => $this->userId]); | 158 | + if (!$is_exist) { |
159 | + //排除业务员自己 | ||
160 | + if ($this->userType == 3) { | ||
161 | + $card_id = Db::name('card')->where(['user_id' => $this->userId])->value('id'); | ||
162 | + } | ||
163 | + if (isset($card_id) && $card_id != $data['id']) { | ||
164 | + $do1 = Db::name('browse_log')->insert(['topic_id' => $data['id'],'user_id' => $this->userId]); | ||
165 | + } | ||
162 | } | 166 | } |
163 | //浏览数+1 | 167 | //浏览数+1 |
164 | $do2 = Db::name('card')->where(['id' => $data['id']])->setInc('browse_num'); | 168 | $do2 = Db::name('card')->where(['id' => $data['id']])->setInc('browse_num'); |
@@ -484,11 +484,6 @@ class ProductController extends RestBaseController | @@ -484,11 +484,6 @@ class ProductController extends RestBaseController | ||
484 | if ($check) { | 484 | if ($check) { |
485 | $this->error(['code'=>'40006','msg'=>'该产品您已申请']); | 485 | $this->error(['code'=>'40006','msg'=>'该产品您已申请']); |
486 | } | 486 | } |
487 | - //添加该名片的被浏览记录 产品 入口 | ||
488 | - $is_exist = Db::name('browse_log') | ||
489 | - ->where(['topic_id' => $data['id'],'user_id' => $this->userId]) | ||
490 | - ->field('id') | ||
491 | - ->find(); | ||
492 | $cardID = Db::name('product') | 487 | $cardID = Db::name('product') |
493 | ->alias('p') | 488 | ->alias('p') |
494 | ->join('card c','p.user_id =c.user_id') | 489 | ->join('card c','p.user_id =c.user_id') |
@@ -497,6 +492,18 @@ class ProductController extends RestBaseController | @@ -497,6 +492,18 @@ class ProductController extends RestBaseController | ||
497 | if (!$cardID) { | 492 | if (!$cardID) { |
498 | $this->error(['code'=>'40011','msg'=>'该产品不存在']); | 493 | $this->error(['code'=>'40011','msg'=>'该产品不存在']); |
499 | } | 494 | } |
495 | + //排除业务员自己 不能申请自己产品 | ||
496 | + if ($this->userType == 3) { | ||
497 | + $card_id = Db::name('card')->where(['user_id' => $this->userId])->value('id'); | ||
498 | + if ($cardID == $card_id) { | ||
499 | + $this->error(['code'=>'40014','msg'=>'不能申请自己的产品']); | ||
500 | + } | ||
501 | + } | ||
502 | + //添加该名片的被浏览记录 产品 入口 | ||
503 | + $is_exist = Db::name('browse_log') | ||
504 | + ->where(['topic_id' => $data['id'],'user_id' => $this->userId,'type' =>2]) | ||
505 | + ->field('id') | ||
506 | + ->find(); | ||
500 | if (!$is_exist) { | 507 | if (!$is_exist) { |
501 | Db::name('browse_log')->insert(['topic_id' => $cardID,'user_id' => $this->userId,'type'=>2]); | 508 | Db::name('browse_log')->insert(['topic_id' => $cardID,'user_id' => $this->userId,'type'=>2]); |
502 | } | 509 | } |
@@ -130,6 +130,7 @@ class UserController extends RestBaseController | @@ -130,6 +130,7 @@ class UserController extends RestBaseController | ||
130 | ->join('browse_log b','c.id = b.topic_id') | 130 | ->join('browse_log b','c.id = b.topic_id') |
131 | ->field('b.user_id') | 131 | ->field('b.user_id') |
132 | ->where(['c.user_id' => $this->userId]) | 132 | ->where(['c.user_id' => $this->userId]) |
133 | + ->group('b.user_id') | ||
133 | ->buildSql(); | 134 | ->buildSql(); |
134 | $result = Db::table($subQuery) | 135 | $result = Db::table($subQuery) |
135 | ->alias('a') | 136 | ->alias('a') |
-
请 注册 或 登录 后发表评论