dyjh před 6 roky
rodič
revize
d96c79a39e

+ 165 - 1
app/Http/Controllers/Api/V1/AlbumBossController.php

xqd xqd
@@ -9,6 +9,7 @@
 namespace App\Http\Controllers\Api\V1;
 
 use App\Models\AlbumAgentModel;
+use App\Models\AlbumProductModel;
 use App\Models\AlbumUserModel;
 use App\Models\AlbumWatchRecord;
 use App\Models\CustomerDetailsModel;
@@ -284,11 +285,174 @@ class AlbumBossController extends Controller
         $totalCustomerCount = AlbumWatchRecord::where([
             ['agent_id', $data['agent_id']],
             ['store_id', $data['store_id']],
+            ['updated_at','>=',$start],
+            ['updated_at','<=',$end]
+        ])->orderByDesc('id')->groupBy('open_id')->count();
+
+        return $this->api(compact('shareCount', 'totalCustomerCount', 'newCustomerCount', 'downloadCount', 'favoriteCount'));
+    }
+
+    /**
+     * @api {post} /api/album_boss/agent_overview 经销商总览(agent_overview)
+     * @apiDescription 经销商总览(agent_overview)
+     * @apiGroup Boss
+     * @apiPermission none
+     * @apiVersion 0.1.0
+     * @apiParam {int}    [store_id]  商户id
+     * @apiParam {int}    [start]     开始时间
+     * @apiParam {int}    [end]       结束时间
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+     * {
+     *     "status": true,
+     *     "status_code": 0,
+     *     "message": "",
+     *     "data": {
+     *         "customerFollow":11,
+     *         "downloadCount":11,
+     *         "shareCount":11,
+     *         "newCustomerCount":11,
+     *         "totalCustomerCount":11,
+     *         "activeCustomers": [
+     *              {
+     *                  "day" : 03/25,
+     *                  "num" : 111
+     *              }
+     *          ],
+     *          "newCustomers": [
+     *              {
+     *                  "day" : 03/25,
+     *                  "num" : 111
+     *              }
+     *          ]
+     *          "arrFavorite": [
+     *              {
+     *                  'name':'asdawd',
+     *                  'point':'asdawd',
+     *                  'num':'1',
+     *              }
+     *          ]
+     *     }
+     * }
+     * @apiErrorExample {json} Error-Response:
+     * HTTP/1.1 400 Bad Request
+     * {
+     *     "state": false,
+     *     "code": 1000,
+     *     "message": "传入参数不正确",
+     *     "data": null or []
+     * }
+     * 可能出现的错误代码:
+     *    1000    CLIENT_WRONG_PARAMS             传入参数不正确
+     */
+    public function albumOverview(Request $request)
+    {
+
+        $userAuth = Auth('api')->user();
+        if (!$userAuth) {
+            return $this->error(ErrorCode::ERROR_POWER, '登陆过期!');
+        }
+        $validator = Validator::make($request->all(), [
+            'store_id' => 'required',
+        ], [
+            'store_id.required' => '缺少商户参数',
+        ]);
+
+        if ($userAuth->role != 4) {
+            return $this->error(ErrorCode::NOT_BOSS, '该用户没有Boss权限');
+        }
+
+        if ($validator->fails()) {
+            return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
+        }
+
+        $end = $request->input('end');
+        $start = $request->input('start');
+        $store_id = $request->input('store_id');
+        if (!$end) {
+            $end = time();
+        }
+        if (!$start) {
+            $start = 0;
+        }
+        $end = date('Y-m-d H:i:s', $end);
+        $start = date('Y-m-d H:i:s', $start);
+        $resGoods = AlbumWatchRecord::where([
+            ['store_id',$store_id],['action',3],['updated_at','>=',$start],
+            ['updated_at','<=',$end]
+        ])->get();
+        $arrFavorite = array();
+        $total = 0;
+
+        foreach ($resGoods as $key => $val) {
+            $goods_data = json_decode($val->detail, true);
+            $goods_id = $goods_data['goods_id'];
+            $goods = AlbumProductModel::find($goods_id);
+            if (!$goods) {
+                continue;
+            }
+            if (isset($arr[$goods->id])) {
+                $arrFavorite[$goods->id]['num']++;
+            } else {
+                $arrFavorite[$goods->id]['num'] = 1;
+                $arrFavorite[$goods->id]['name'] = $goods->name;
+            }
+            $total++;
+        }
+        $activeCustomers = array();
+        $newCustomers = array();
+        for ($d = 0; $d < 15; $d++) {
+            $Start = mktime(0, 0, 0, date('m'), date('d'), date('y')) + 86400 * $d;
+            $End = $Start + 86400;
+            $End = date('Y-m-d H:i:s', $End);
+            $Start = date('Y-m-d H:i:s', $Start);
+            $customerNum = AlbumWatchRecord::where([
+                ['store_id', $store_id],
+                ['updated_at','>=',$Start],
+                ['updated_at','<=',$End]
+            ])->orderByDesc('id')->groupBy('open_id')->count();
+            $newCustomer = AlbumWatchRecord::where([
+                ['store_id', $store_id],
+                ['is_new', 1],
+                ['updated_at','>=',$Start],
+                ['updated_at','<=',$End]
+            ])->orderByDesc('id')->count();
+            $activeCustomers[] = [
+                'day' => date('m', $Start) . '-' . date('d', $End),
+                'num' => $customerNum
+            ];
+            $newCustomers[] = [
+                'day' => date('m', $Start) . '-' . date('d', $End),
+                'num' => $newCustomer
+            ];
+        }
+        $customerFollow = CustomerDetailsModel::where('store_id', $store_id)->count();
+        $downloadCount = AlbumWatchRecord::where([
+            ['store_id', $store_id],
+            ['action', 9],
+            ['updated_at','>=',$start],
+            ['updated_at','<=',$end]
+        ])->orderByDesc('id')->count();
+
+        $shareCount = AlbumWatchRecord::where([
+            ['store_id', $store_id],
+            ['action', 8],
+            ['updated_at','>=',$start],
+            ['updated_at','<=',$end]
+        ])->orderByDesc('id')->count();
+
+        $newCustomerCount = AlbumWatchRecord::where([
+            ['store_id', $store_id],
             ['is_new', 1],
             ['updated_at','>=',$start],
             ['updated_at','<=',$end]
         ])->orderByDesc('id')->count();
 
-        return $this->api(compact('shareCount', 'totalCustomerCount', 'newCustomerCount', 'downloadCount', 'favoriteCount'));
+        $totalCustomerCount = AlbumWatchRecord::where([
+            ['store_id', $store_id],
+            ['updated_at','>=',$start],
+            ['updated_at','<=',$end]
+        ])->orderByDesc('id')->groupBy('open_id')->count();
+        return $this->api(compact('totalCustomerCount', 'newCustomerCount', 'shareCount', 'downloadCount', 'customerFollow', 'newCustomers', 'activeCustomers', 'arrFavorite'));
     }
 }

+ 1 - 1
app/Http/Controllers/Api/V1/Controller.php

xqd
@@ -23,7 +23,7 @@ class Controller extends BaseController
             'except' => [
                 'upload', 'getCode', 'reset', 'login', 'get', 'register', 'alipayNotify', 'wechatpayNotify', 'get', 'area', 'get_province', 'get_city', 'get_county', 'albumStyle', 'test', 'index', 'companyInfo', 'shop2', 'cardIndex', 'cardUserInfo', 'cardUserProgress', 'cardUserHonor', 'cardUserProject', 'CardUserTrend', 'projectDetail', 'trendDetail', 'albumSetting', 'albumXyxLogin', 'albumCat', 'albumchecklogin', 'albumGoods', 'albumGoodsDetail', 'albumSetPrice', 'albumXcxLogin', 'albumContentList', 'albumSearchGoods','albumContentDetail','albumFavoriteList','albumAddFavorite','albumFavoriteDel','getAttr','getOrder','getProgress','getReviewCount', 'furnitureNewsDetail','furnitureSetting','furnitureXcxLogin','furnitureGoodsList','serviceLogin','getFurnitureAds','getPhoneNumber','getQrcode','orderCount','searchList','printOrder','saveFormId','furnitureNewsList','getMoreComments','addToLike','albumSavePhone','albumGetStatistical','test',
                 'albumGetWatchRecord','albumSetWatch','albumGetCartOfWatch','albumSaveFormId','albumAddAgent','albumGetBanner','albumGetDataGoods','newgoods_list','newgoods_index','albumGetAgentAdress','albumSetCustomer','albumGetCustomer','albumGetDataCat','albumCustomerGoods','albumCustomerGoodsDetail','albumGetDataCatSingle','albumGetCountOfFavorite','albumGetUserInfo','albumStatistical','posterInfo','createPoster','posterDel','albumAgentPriceSet', 'getTop', 'agentCustomer'
-                , 'agentStatistical'
+                , 'agentStatistical', 'albumOverview'
             ]
         ]);
 

+ 129 - 0
public/apidoc/api_data.js

xqd
@@ -2142,6 +2142,135 @@ define({ "api": [
     "groupTitle": "Boss",
     "name": "PostApiAlbum_bossAgent_customer"
   },
+  {
+    "type": "post",
+    "url": "/api/album_boss/agent_overview",
+    "title": "经销商总览(agent_overview)",
+    "description": "<p>经销商总览(agent_overview)</p>",
+    "group": "Boss",
+    "permission": [
+      {
+        "name": "none"
+      }
+    ],
+    "version": "0.1.0",
+    "parameter": {
+      "fields": {
+        "Parameter": [
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "store_id",
+            "description": "<p>商户id</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "start",
+            "description": "<p>开始时间</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "end",
+            "description": "<p>结束时间</p>"
+          }
+        ]
+      }
+    },
+    "success": {
+      "examples": [
+        {
+          "title": "Success-Response:",
+          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"customerFollow\":11,\n        \"downloadCount\":11,\n        \"shareCount\":11,\n        \"newCustomerCount\":11,\n        \"totalCustomerCount\":11,\n        \"activeCustomers\": [\n             {\n                 \"day\" : 03/25,\n                 \"num\" : 111\n             }\n         ],\n         \"newCustomers\": [\n             {\n                 \"day\" : 03/25,\n                 \"num\" : 111\n             }\n         ]\n         \"arrFavorite\": [\n             {\n                 'name':'asdawd',\n                 'point':'asdawd',\n                 'num':'1',\n             }\n         ]\n    }\n}",
+          "type": "json"
+        }
+      ]
+    },
+    "error": {
+      "examples": [
+        {
+          "title": "Error-Response:",
+          "content": "HTTP/1.1 400 Bad Request\n{\n    \"state\": false,\n    \"code\": 1000,\n    \"message\": \"传入参数不正确\",\n    \"data\": null or []\n}\n可能出现的错误代码:\n   1000    CLIENT_WRONG_PARAMS             传入参数不正确",
+          "type": "json"
+        }
+      ]
+    },
+    "filename": "app/Http/Controllers/Api/V1/AlbumBossController.php",
+    "groupTitle": "Boss",
+    "name": "PostApiAlbum_bossAgent_overview"
+  },
+  {
+    "type": "post",
+    "url": "/api/album_boss/agent_statistical",
+    "title": "经销商数据(agent_statistical)",
+    "description": "<p>经销商数据(agent_statistical)</p>",
+    "group": "Boss",
+    "permission": [
+      {
+        "name": "none"
+      }
+    ],
+    "version": "0.1.0",
+    "parameter": {
+      "fields": {
+        "Parameter": [
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "store_id",
+            "description": "<p>商户id</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "agent_id",
+            "description": "<p>经销商id</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "start",
+            "description": "<p>开始时间</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "end",
+            "description": "<p>结束时间</p>"
+          }
+        ]
+      }
+    },
+    "success": {
+      "examples": [
+        {
+          "title": "Success-Response:",
+          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"favoriteCount\":11,\n        \"downloadCount\":11,\n        \"shareCount\":11,\n        \"newCustomerCount\":11,\n        \"totalCustomerCount\":11,\n    }\n}",
+          "type": "json"
+        }
+      ]
+    },
+    "error": {
+      "examples": [
+        {
+          "title": "Error-Response:",
+          "content": "HTTP/1.1 400 Bad Request\n{\n    \"state\": false,\n    \"code\": 1000,\n    \"message\": \"传入参数不正确\",\n    \"data\": null or []\n}\n可能出现的错误代码:\n   1000    CLIENT_WRONG_PARAMS             传入参数不正确",
+          "type": "json"
+        }
+      ]
+    },
+    "filename": "app/Http/Controllers/Api/V1/AlbumBossController.php",
+    "groupTitle": "Boss",
+    "name": "PostApiAlbum_bossAgent_statistical"
+  },
   {
     "type": "get",
     "url": "/api/car/delete",

+ 129 - 0
public/apidoc/api_data.json

xqd
@@ -2142,6 +2142,135 @@
     "groupTitle": "Boss",
     "name": "PostApiAlbum_bossAgent_customer"
   },
+  {
+    "type": "post",
+    "url": "/api/album_boss/agent_overview",
+    "title": "经销商总览(agent_overview)",
+    "description": "<p>经销商总览(agent_overview)</p>",
+    "group": "Boss",
+    "permission": [
+      {
+        "name": "none"
+      }
+    ],
+    "version": "0.1.0",
+    "parameter": {
+      "fields": {
+        "Parameter": [
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "store_id",
+            "description": "<p>商户id</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "start",
+            "description": "<p>开始时间</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "end",
+            "description": "<p>结束时间</p>"
+          }
+        ]
+      }
+    },
+    "success": {
+      "examples": [
+        {
+          "title": "Success-Response:",
+          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"customerFollow\":11,\n        \"downloadCount\":11,\n        \"shareCount\":11,\n        \"newCustomerCount\":11,\n        \"totalCustomerCount\":11,\n        \"activeCustomers\": [\n             {\n                 \"day\" : 03/25,\n                 \"num\" : 111\n             }\n         ],\n         \"newCustomers\": [\n             {\n                 \"day\" : 03/25,\n                 \"num\" : 111\n             }\n         ]\n         \"arrFavorite\": [\n             {\n                 'name':'asdawd',\n                 'point':'asdawd',\n                 'num':'1',\n             }\n         ]\n    }\n}",
+          "type": "json"
+        }
+      ]
+    },
+    "error": {
+      "examples": [
+        {
+          "title": "Error-Response:",
+          "content": "HTTP/1.1 400 Bad Request\n{\n    \"state\": false,\n    \"code\": 1000,\n    \"message\": \"传入参数不正确\",\n    \"data\": null or []\n}\n可能出现的错误代码:\n   1000    CLIENT_WRONG_PARAMS             传入参数不正确",
+          "type": "json"
+        }
+      ]
+    },
+    "filename": "app/Http/Controllers/Api/V1/AlbumBossController.php",
+    "groupTitle": "Boss",
+    "name": "PostApiAlbum_bossAgent_overview"
+  },
+  {
+    "type": "post",
+    "url": "/api/album_boss/agent_statistical",
+    "title": "经销商数据(agent_statistical)",
+    "description": "<p>经销商数据(agent_statistical)</p>",
+    "group": "Boss",
+    "permission": [
+      {
+        "name": "none"
+      }
+    ],
+    "version": "0.1.0",
+    "parameter": {
+      "fields": {
+        "Parameter": [
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "store_id",
+            "description": "<p>商户id</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "agent_id",
+            "description": "<p>经销商id</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "start",
+            "description": "<p>开始时间</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "end",
+            "description": "<p>结束时间</p>"
+          }
+        ]
+      }
+    },
+    "success": {
+      "examples": [
+        {
+          "title": "Success-Response:",
+          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"\",\n    \"data\": {\n        \"favoriteCount\":11,\n        \"downloadCount\":11,\n        \"shareCount\":11,\n        \"newCustomerCount\":11,\n        \"totalCustomerCount\":11,\n    }\n}",
+          "type": "json"
+        }
+      ]
+    },
+    "error": {
+      "examples": [
+        {
+          "title": "Error-Response:",
+          "content": "HTTP/1.1 400 Bad Request\n{\n    \"state\": false,\n    \"code\": 1000,\n    \"message\": \"传入参数不正确\",\n    \"data\": null or []\n}\n可能出现的错误代码:\n   1000    CLIENT_WRONG_PARAMS             传入参数不正确",
+          "type": "json"
+        }
+      ]
+    },
+    "filename": "app/Http/Controllers/Api/V1/AlbumBossController.php",
+    "groupTitle": "Boss",
+    "name": "PostApiAlbum_bossAgent_statistical"
+  },
   {
     "type": "get",
     "url": "/api/car/delete",

+ 1 - 1
public/apidoc/api_project.js

xqd
@@ -9,7 +9,7 @@ define({
   "apidoc": "0.3.0",
   "generator": {
     "name": "apidoc",
-    "time": "2019-04-14T03:53:44.446Z",
+    "time": "2019-04-14T07:43:32.349Z",
     "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-04-14T03:53:44.446Z",
+    "time": "2019-04-14T07:43:32.349Z",
     "url": "http://apidocjs.com",
     "version": "0.17.6"
   }

+ 5 - 0
routes/api.php

xqd
@@ -511,4 +511,9 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'uses' => 'AlbumBossController@agentStatistical',
     ]);
 
+    $api->post('album_boss/agent_overview', [
+        'as' => 'album_boss.agent_overview',
+        'uses' => 'AlbumBossController@albumOverview',
+    ]);
+
 });