Bläddra i källkod

Merge branch 'master' of http://git.9026.com/wesley/furniture

gq 7 år sedan
förälder
incheckning
50e0c1c88d

+ 33 - 19
app/Http/Controllers/Api/V1/AlbumController.php

xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -988,6 +988,9 @@ class AlbumController extends Controller
      *     "status_code": 0,
      *     "message": "",
      *     "data": [
+     *         "count_today":0,
+     *         "count_all":0,
+     *         "count_share":0,
      *         "user": {
      *              "username":"王小贱",
      *              "avatar":"awdawdawdawdawdawd",头像
@@ -1042,7 +1045,13 @@ class AlbumController extends Controller
        // if($userAuth->up_agent_id==0) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未选择经销商!', $validator->messages());
         $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
         $count_user = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id],['updated_at','>=',$start],['updated_at','<=',$end]])->orderBy('id','DESC')->groupBy('open_id')->get();
-
+        $checkAllstart = mktime(0,0,0,date('m'),date('d'),date('Y'));
+        $checkAllend = $checkAllstart+86400;
+        $checkAllstart = date('Y-m-d H:i:s',$checkAllstart);
+        $checkAllend = date('Y-m-d H:i:s',$checkAllend);
+        $count_today = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id],['updated_at','>=',$checkAllstart],['updated_at','<=',$checkAllend]])->groupBy('open_id')->count();
+        $count_all = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id]])->groupBy('open_id')->count();
+        $count_share = $user_agent->share_times;
         $users = Array();
         if($count_user){
             foreach($count_user as $key=>$val){
@@ -1067,7 +1076,7 @@ class AlbumController extends Controller
             $res = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id],['action',$i]])->get();
             $action['type'.$i] = count($res);
         }
-        return $this->api(compact('count','users','action'));
+        return $this->api(compact('count','users','action','count_today','count_all','count_share'));
     }
     /**
      * @api {get} /api/album/checklogin 登陆应用(checklogin)
@@ -2036,17 +2045,13 @@ class AlbumController extends Controller
         if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
         $validator = Validator::make($request->all(), [
             'store_id' => 'required',
-            'purpose_level' => 'required',
-            'comment' => 'required',
-            'address' => 'required',
-            'tips' => 'required',
-            'open_id'=>'required'
+            'key' => 'required',
+            'value' => 'required',
+            'open_id' => 'required',
         ],[
             'store_id.required'=>'缺少商户参数',
-            'address.required'=>'缺少地址参数',
-            'purpose_level.required'=>'缺少意向等级参数',
-            'comment.required'=>'缺少客户备注参数',
-            'tips.required'=>'缺少标签参数',
+            'key.required'=>'缺少键参数',
+            'value.required'=>'缺少值参数',
             'open_id.required'=>'缺少用户参数',
         ]);
         if ($validator->fails()) {
@@ -2054,18 +2059,19 @@ class AlbumController extends Controller
         }
         $store_id = $request->input('store_id');
         $open_id = $request->input('open_id');
-        $add = $request->input();
+        $key = $request->input('key');
+        $value = $request->input('value');
         if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
         $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
         $customer = CustomerDetailsModel::where([['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id]])->first(['purpose_level','comment','tips','address']);
         if($customer){
-            $customer->address = $add['address'];
-            $customer->purpose_level = $add['purpose_level'];
-            $customer->comment = $add['comment'];
-            $customer->tips = $add['tips'];
+            $customer->$key = $value;
             $customer->save();
         }else{
             $add['agent_id'] = $user_agent->id;
+            $add['open_id'] = $open_id;
+            $add['store_id'] = $store_id;
+            $add[$key] = $value;
             $user = CustomerDetailsModel::create($add);
         }
         return $this->api([],0,'success');
@@ -2126,7 +2132,7 @@ class AlbumController extends Controller
             $goods_id = $detail['goods_id'];
             $goods = AlbumProductModel::where([['id',$goods_id]])->first();
             if($goods){
-                $count=  AlbumWatchRecord::where([['action',3],['store_id',$store_id],['detail',$val['detail']]])->count();
+                $count=  AlbumWatchRecord::where([['action',3],['store_id',$store_id],['detail',$val['detail'],['agent_id',$user_agent->id]]])->count();
                 $arr[] = ['name'=>$goods->name,'count'=>$count];
             }
         }
@@ -2185,7 +2191,7 @@ class AlbumController extends Controller
         $open_id = $request->input('open_id');
         if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
         $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
-        if($user_agent) $res=  AlbumWatchRecord::where([['action',3],['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id]])->get(['detail','created_at'])->toArray();
+        if($user_agent) $res=  AlbumWatchRecord::where([['action',3],['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id]])->orderByDesc('id')->get(['detail','created_at'])->toArray();
         $arr = array();
         foreach ($res as $key=>$val){
             $detail = json_decode($val['detail'],true);
@@ -2195,7 +2201,7 @@ class AlbumController extends Controller
             if($goods){
                 $style = AlbumProductStyleModel::where([['store_id',$store_id],['id',$goods->style]])->first();
                 $cat = AlbumCatModel::where([['store_id',$store_id],['id',$goods->cat_id]])->first();
-                $arr[] = ['name'=>$goods->name,'time'=>date('Y-m-d-h',strtotime($val['created_at'])),'style'=>$style->name,'cat'=>$cat->name];
+                $arr[] = ['name'=>$goods->name,'time'=>date('Y-m-d H:i',strtotime($val['created_at'])),'style'=>$style->name,'cat'=>$cat->name];
             }
         }
         return $this->api($arr,0,'success');
@@ -2348,13 +2354,21 @@ class AlbumController extends Controller
     {
         $validator = Validator::make($request->all(), [
             'store_id' => 'required',
+            'agent_id' => 'required'
         ],[
             'store_id.required'=>'缺少商户参数',
+            'agent_id.required'=>'缺少经销商参数',
         ]);
         if ($validator->fails()) {
             return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
         }
         $store_id = $request->input('store_id');
+        $agent_id = $request->input('agent_id');
+        if($agent_id!=0){
+            $user_agent = AlbumAgentModel::where([['id',$agent_id],['status',1]])->first();
+            $user_agent->share_times++;
+            $user_agent->save();
+        }
         $userAuth = Auth('api')->user();
         if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
         $time = mktime(0,0,0,date('m'),date('d'),date('y'));

+ 1 - 0
app/Models/AlbumAgentModel.php

xqd
@@ -51,6 +51,7 @@ class AlbumAgentModel extends BaseModel
                            'status',
                            'realname',
                            'get_count',
+                           'share_times'
                           ];
 
 }

+ 33 - 0
database/migrations/2019_02_20_104023_add_column_to_album_agent.php

xqd
@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddColumnToAlbumAgent extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('album_agent', function (Blueprint $table) {
+            //
+            $table->unsignedInteger('share_times')->nullable()->default(0)->comment('分享次數');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('album_agent', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 1 - 1
public/apidoc/api_data.js

xqd
@@ -941,7 +941,7 @@ define({ "api": [
       "examples": [
         {
           "title": "Success-Response:",
-          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": [\n        \"user\": {\n             \"username\":\"王小贱\",\n             \"avatar\":\"awdawdawdawdawdawd\",头像\n              \"phone\":\"1123123123123\"\n              \"open_id\":\"1123123123123\"\n             }\n        \"count\":6,\n        \"action\":[\n             \"type1\":1,\n             \"type2\":1,\n             \"type3\":1,\n             \"type4\":1,\n             \"type5\":1,\n             \"type6\":1,\n             \"type7\":1,\n         ]\n     ]\n}",
+          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": [\n        \"count_today\":0,\n        \"count_all\":0,\n        \"count_share\":0,\n        \"user\": {\n             \"username\":\"王小贱\",\n             \"avatar\":\"awdawdawdawdawdawd\",头像\n              \"phone\":\"1123123123123\"\n              \"open_id\":\"1123123123123\"\n             }\n        \"count\":6,\n        \"action\":[\n             \"type1\":1,\n             \"type2\":1,\n             \"type3\":1,\n             \"type4\":1,\n             \"type5\":1,\n             \"type6\":1,\n             \"type7\":1,\n         ]\n     ]\n}",
           "type": "json"
         }
       ]

+ 1 - 1
public/apidoc/api_data.json

xqd
@@ -941,7 +941,7 @@
       "examples": [
         {
           "title": "Success-Response:",
-          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": [\n        \"user\": {\n             \"username\":\"王小贱\",\n             \"avatar\":\"awdawdawdawdawdawd\",头像\n              \"phone\":\"1123123123123\"\n              \"open_id\":\"1123123123123\"\n             }\n        \"count\":6,\n        \"action\":[\n             \"type1\":1,\n             \"type2\":1,\n             \"type3\":1,\n             \"type4\":1,\n             \"type5\":1,\n             \"type6\":1,\n             \"type7\":1,\n         ]\n     ]\n}",
+          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": [\n        \"count_today\":0,\n        \"count_all\":0,\n        \"count_share\":0,\n        \"user\": {\n             \"username\":\"王小贱\",\n             \"avatar\":\"awdawdawdawdawdawd\",头像\n              \"phone\":\"1123123123123\"\n              \"open_id\":\"1123123123123\"\n             }\n        \"count\":6,\n        \"action\":[\n             \"type1\":1,\n             \"type2\":1,\n             \"type3\":1,\n             \"type4\":1,\n             \"type5\":1,\n             \"type6\":1,\n             \"type7\":1,\n         ]\n     ]\n}",
           "type": "json"
         }
       ]

+ 1 - 1
public/apidoc/api_project.js

xqd
@@ -9,7 +9,7 @@ define({
   "apidoc": "0.3.0",
   "generator": {
     "name": "apidoc",
-    "time": "2019-02-18T09:32:54.002Z",
+    "time": "2019-02-20T02:48:30.664Z",
     "url": "http://apidocjs.com",
     "version": "0.17.6"
   }

+ 1 - 1
public/apidoc/api_project.json

xqd
@@ -9,7 +9,7 @@
   "apidoc": "0.3.0",
   "generator": {
     "name": "apidoc",
-    "time": "2019-02-18T09:32:54.002Z",
+    "time": "2019-02-20T02:48:30.664Z",
     "url": "http://apidocjs.com",
     "version": "0.17.6"
   }