dyjh преди 6 години
родител
ревизия
e633289735

+ 113 - 0
app/Http/Controllers/Api/V1/AlbumBossController.php

xqd
@@ -178,4 +178,117 @@ class AlbumBossController extends Controller
 
         return $this->api(compact('agent', 'customer'), 0, 'success');
     }
+
+
+
+    /**
+     * @api {post} /api/album_boss/agent_statistical 经销商数据(agent_statistical)
+     * @apiDescription 经销商数据(agent_statistical)
+     * @apiGroup Boss
+     * @apiPermission none
+     * @apiVersion 0.1.0
+     * @apiParam {int}    [store_id]  商户id
+     * @apiParam {int}    [agent_id]  经销商id
+     * @apiParam {int}    [start]     开始时间
+     * @apiParam {int}    [end]       结束时间
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+     * {
+     *     "status": true,
+     *     "status_code": 0,
+     *     "message": "",
+     *     "data": {
+     *         "favoriteCount":11,
+     *         "downloadCount":11,
+     *         "shareCount":11,
+     *         "newCustomerCount":11,
+     *         "totalCustomerCount":11,
+     *     }
+     * }
+     * @apiErrorExample {json} Error-Response:
+     * HTTP/1.1 400 Bad Request
+     * {
+     *     "state": false,
+     *     "code": 1000,
+     *     "message": "传入参数不正确",
+     *     "data": null or []
+     * }
+     * 可能出现的错误代码:
+     *    1000    CLIENT_WRONG_PARAMS             传入参数不正确
+     */
+    public function agentStatistical(Request $request)
+    {
+        $userAuth = Auth('api')->user();
+        if (!$userAuth) {
+            return $this->error(ErrorCode::ERROR_POWER, '登陆过期!');
+        }
+        $validator = Validator::make($request->all(), [
+            'store_id' => 'required',
+            'agent_id' => 'required',
+        ], [
+            'store_id.required' => '缺少商户参数',
+            'agent_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());
+        }
+
+        $data = $request->input();
+        $end = $request->input('end');
+        $start = $request->input('start');
+        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);
+        $favoriteCount = AlbumWatchRecord::where([
+            ['agent_id', $data['agent_id']],
+            ['store_id', $data['store_id']],
+            ['action', 1],
+            ['updated_at','>=',$start],
+            ['updated_at','<=',$end]
+        ])->orderByDesc('id')->count();
+
+        $downloadCount = AlbumWatchRecord::where([
+            ['agent_id', $data['agent_id']],
+            ['store_id', $data['store_id']],
+            ['action', 9],
+            ['updated_at','>=',$start],
+            ['updated_at','<=',$end]
+        ])->orderByDesc('id')->count();
+
+        $shareCount = AlbumWatchRecord::where([
+            ['agent_id', $data['agent_id']],
+            ['store_id', $data['store_id']],
+            ['action', 8],
+            ['updated_at','>=',$start],
+            ['updated_at','<=',$end]
+        ])->orderByDesc('id')->count();
+
+        $newCustomerCount = AlbumWatchRecord::where([
+            ['agent_id', $data['agent_id']],
+            ['store_id', $data['store_id']],
+            ['is_new', 1],
+            ['updated_at','>=',$start],
+            ['updated_at','<=',$end]
+        ])->orderByDesc('id')->count();
+
+        $totalCustomerCount = AlbumWatchRecord::where([
+            ['agent_id', $data['agent_id']],
+            ['store_id', $data['store_id']],
+            ['is_new', 1],
+            ['updated_at','>=',$start],
+            ['updated_at','<=',$end]
+        ])->orderByDesc('id')->count();
+
+        return $this->api(compact('shareCount', 'totalCustomerCount', 'newCustomerCount', 'downloadCount', 'favoriteCount'));
+    }
 }

+ 8 - 0
app/Http/Controllers/Api/V1/AlbumController.php

xqd
@@ -223,6 +223,14 @@ class AlbumController extends Controller
                 $add_record['action'] = 4;
                 $add_record['store_id'] = $datas['store_id'];
                 $add_record['detail'] = null;
+                $check_new_customer = AlbumWatchRecord::where([
+                    ['agent_id', $userAuth->up_agent_id],['open_id', $check->open_id],['store_id', $datas['store_id']]
+                ])->first();
+                if ($check_new_customer) {
+                    $add_record['is_new'] = 0;
+                } else {
+                    $add_record['is_new'] = 1;
+                }
                 AlbumWatchRecord::create($add_record);
                 //   dd($add_record);
                 // print_r($add_record['agent_id']);die;

+ 19 - 0
app/Http/Controllers/Api/V1/AlbumPosterController.php

xqd xqd
@@ -11,6 +11,8 @@ namespace App\Http\Controllers\Api\V1;
 use App\Models\AlbumAgentModel;
 use App\Models\AlbumManufacturerModel;
 use App\Models\AlbumPosterModel;
+use App\Models\AlbumUserModel;
+use App\Models\AlbumWatchRecord;
 use App\Services\Base\ErrorCode;
 use EasyWeChat\Factory;
 use Grafika\Color;
@@ -215,7 +217,24 @@ class AlbumPosterController extends Controller
         } else {
             $agent_id = $userAuth->up_agent_id == 0 ? 0 : $userAuth->up_agent_id;
         }
+
         $data = $request->input();
+
+        if ($userAuth->up_agent_id != 0) {
+            $add_record['agent_id'] = $userAuth->up_agent_id;
+            $add_record['open_id'] = $userAuth->open_id;
+            $add_record['action'] = 9;
+            $add_record['store_id'] = $data['store_id'];
+            $add_record['detail'] = '保存了图片';
+            $user_agent = AlbumAgentModel::where('id', $userAuth->up_agent_id)->first();
+            $agent = AlbumUserModel::where('id', $user_agent->user_id)->first();
+
+            $album = new AlbumController();
+            $album->sendLogsMessage($data['store_id'], $agent->open_id, 9, $userAuth->username, $agent->g_open_id);
+
+            AlbumWatchRecord::create($add_record);
+        }
+
         $info = AlbumPosterModel::where('store_id', $data['store_id'])->first()->toArray();
         $editor = Grafika::createEditor();
         $editor->open($image_poster, public_path() . '/base/poster/img/poster_canvas.png');

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

xqd
@@ -23,6 +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'
             ]
         ]);
 

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

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

+ 5 - 0
routes/api.php

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