dyjh 6 年之前
父节点
当前提交
eb9ef5785f

+ 68 - 3
app/Http/Controllers/Api/V1/AlbumController.php

xqd xqd xqd xqd
@@ -219,6 +219,8 @@ class AlbumController extends Controller
                 $user_agent = AlbumAgentModel::where('id',$add_record['agent_id'])->first();
                 //dd($user_agent);
                 if($user_agent){
+                    $user_agent->get_count++;
+                    $user_agent->save();
                     $agent = AlbumUserModel::where('id',$user_agent->user_id)->first();
                     try{
                         $this->sendLogsMessage($datas['store_id'],$agent->open_id,4,$userAuth->username);
@@ -2005,6 +2007,68 @@ class AlbumController extends Controller
      *    1000    CLIENT_WRONG_PARAMS             传入参数不正确
      */
     public function albumCustomerGoods(Request $request)
+    {
+        $userAuth = Auth('api')->user();
+        if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
+        $validator = Validator::make($request->all(), [
+            'store_id' => 'required',
+        ],[
+            'store_id.required'=>'缺少商户参数',
+        ]);
+        if ($validator->fails()) {
+            return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
+        }
+        $store_id = $request->input('store_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],['agent_id',$user_agent->id]])->groupBy('detail')->get('detail');
+        $arr = array();
+        foreach ($res as $key=>$val){
+            $detail = json_decode($val['detail'],true);
+            //dd($detail);die;
+            $goods_id = $detail['goods_id'];
+            $goods = AlbumProductModel::where([['id',$goods_id]])->first();
+            if($goods){
+                $count=  AlbumWatchRecord::where([['action',3],['store_id',$store_id],['detail',$detail]])->count();
+                $arr[] = ['name'=>$goods->name,'count'=>$count];
+            }
+        }
+        return $this->api($arr,0,'success');
+    }
+
+    /**
+     * @api {get} /api/album/customer-goods-detail 获取客户浏览商品详细(customer-goods-detail)
+     * @apiDescription 获取客户浏览商品详细(customer-goods-detail)
+     * @apiGroup Album
+     * @apiPermission none
+     * @apiVersion 0.1.0
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+     * {
+     *     "status": true,
+     *     "status_code": 0,
+     *     "message": "",
+     *     "data":[
+     *          {
+     *              "name":
+     *              "time":
+     *              "style":
+     *              "cat":
+     *          },
+     *      ]
+     * }
+     * @apiErrorExample {json} Error-Response:
+     * HTTP/1.1 400 Bad Request
+     * {
+     *     "state": false,
+     *     "code": 1000,
+     *     "message": "传入参数不正确",
+     *     "data": null or []
+     * }
+     * 可能出现的错误代码:
+     *    1000    CLIENT_WRONG_PARAMS             传入参数不正确
+     */
+    public function albumCustomerGoodsDetail(Request $request)
     {
         $userAuth = Auth('api')->user();
         if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
@@ -2022,7 +2086,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]])->get();
+        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();
         $arr = array();
         foreach ($res as $key=>$val){
             $detail = json_decode($val['detail'],true);
@@ -2030,8 +2094,9 @@ 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],['open_id',$open_id],['detail',$detail]])->count();
-                $arr[] = ['name'=>$goods->name,'count'=>$count];
+                $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];
             }
         }
         return $this->api($arr,0,'success');

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

xqd
@@ -22,7 +22,7 @@ class Controller extends BaseController
         $this->middleware('auth:api', [
             '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',
-                'albumGetWatchRecord','albumSetWatch','albumGetCartOfWatch','albumSaveFormId','albumAddAgent','albumGetBanner','albumGetDataGoods','newgoods_list','newgoods_index','albumGetAgentAdress','albumSetCustomer','albumGetCustomer','albumGetDataCat','albumCustomerGoods'
+                'albumGetWatchRecord','albumSetWatch','albumGetCartOfWatch','albumSaveFormId','albumAddAgent','albumGetBanner','albumGetDataGoods','newgoods_list','newgoods_index','albumGetAgentAdress','albumSetCustomer','albumGetCustomer','albumGetDataCat','albumCustomerGoods','albumCustomerGoodsDetail'
             ]
         ]);
 

+ 1 - 0
app/Models/AlbumAgentModel.php

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

+ 1 - 0
app/Models/CustomerDetailsModel.php

xqd
@@ -30,6 +30,7 @@ class CustomerDetailsModel extends BaseModel
         'agent_id',
         'store_id',
         'open_id',
+        'address',
         'tips',
         'comment',
         'purpose_level',

+ 33 - 0
database/migrations/2019_02_03_130930_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('get_count')->nullable()->default(0);
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('album_agent', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 5 - 0
routes/api.php

xqd
@@ -352,6 +352,11 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'uses' => 'AlbumController@albumCustomerGoods'
     ]);
 
+    $api->post('album/customer-goods-detail',[
+        'as' => 'album/customer-goods-detail',
+        'uses' => 'AlbumController@albumCustomerGoodsDetail'
+    ]);
+
     $api->get('furniture/getattr', [
         'as' => 'furniture.getattr',
         'uses' => 'FurnitureController@getAttr',