zz 6 年 前
コミット
d84fd8f952
1 ファイル変更48 行追加5 行削除
  1. 48 5
      app/Http/Controllers/Wap/User/UserController.php

+ 48 - 5
app/Http/Controllers/Wap/User/UserController.php

@@ -2,6 +2,7 @@
 
 namespace App\Http\Controllers\Wap\User;
 
+use App\Modules\Statistic\Services\AdVisitStatService;
 use App\Modules\Subscribe\Services\OrderService;
 use App\Modules\User\Services\ReadRecordService;
 use App\Modules\User\Services\WapReaderPageFissionService;
@@ -75,16 +76,16 @@ class UserController extends BaseController
         $year_record = YearOrderService::getRecord($this->uid);
         if($year_record){
             $data['is_vip'] = 1;
-            
+
             $time = strtotime($year_record['end_time'])-time();
             if($time>=86400){
-                  $data['vip_days'] = floor($time/86400).'天';  
+                $data['vip_days'] = floor($time/86400).'天';
             }elseif ($time>3600) {
-                 $data['vip_days'] = floor($time/3600).'小时';  
+                $data['vip_days'] = floor($time/3600).'小时';
             }elseif ($time>60) {
-                 $data['vip_days'] = floor($time/60).'分钟';  
+                $data['vip_days'] = floor($time/60).'分钟';
             }else{
-                $data['vip_days'] = $time.'秒';  
+                $data['vip_days'] = $time.'秒';
             }
         }
         $data['is_all_life'] = 0;
@@ -210,6 +211,48 @@ class UserController extends BaseController
         return response()->success($data);
     }
 
+    /**
+     * @apiVersion 1.0.0
+     * @apiDescription 用户点击广告统计
+     * @api {post} user/advisitstat 用户点击广告统计
+     * @apiGroup User
+     * @apiName signRecord
+     * @apiParam {Int} bid      bid
+     * @apiParam {Int} cid      cid
+     * @apiParam {Int} type     type类型(CLICK|UNLOCK)
+     * @apiSuccess {int}         code 状态码
+     * @apiSuccess {String}      msg  信息
+     * @apiSuccess {object}      data 结果集
+     * @apiParam {page}  page
+     * @apiSuccessExample {json} Success-Response:
+     *
+     *    {
+     *       code: 0,
+     *       msg: "",
+     *       data: {
+     *           {
+     *               reward: 50,
+     *               sign_time: "2018-03-20 13:43:11"
+     *           },
+     *           {
+     *               reward: 50,
+     *               sign_time: "2018-01-18 16:22:33"
+     *           },
+     *       }
+     *   }
+     */
+    public function adVisitStat(Request $request){
+        $bid = $request->get('bid');
+        $cid = $request->get('cid',0);
+        $type = $request->get('type');
+        if(!$bid || !$type){
+            return response()->error('PARAM_ERROR');
+        }
+        !is_numeric($bid) && $bid = Hashids::decode($bid)[0];
+        AdVisitStatService::create($this->uid,$bid,$cid,$type);
+        return response()->success();
+    }
+
     function logout()
     {
         setcookie(env('COOKIE_AUTH_WEB_WECHAT'), '', -1);