dyjh vor 6 Jahren
Ursprung
Commit
ceb7727a0e

+ 5 - 6
app/Http/Controllers/Api/V1/AlbumController.php

xqd xqd xqd xqd
@@ -239,12 +239,11 @@ class AlbumController extends Controller
 
         $session = $res['session_key'];
         $decryptedData = $app->encryptor->decryptData($session, $datas['iv'], $datas['encryptData']);
-        dd($decryptedData);die;
-            $check = AlbumUserModel::where('wechat_open_id',$res['openid'])->first();
+            $check = AlbumUserModel::where('wechat_union_id',$decryptedData['unionId'])->first();
             if(!$check){
                 $add['username'] = preg_replace('/[\xf0-\xf7].{3}/', '', $datas['nickName']);
                 $add['wechat_open_id'] = $res['openid'];
-                $add['wechat_union_id'] = '';
+                $add['wechat_union_id'] = $decryptedData['unionId'];
                 $add['avatar'] = $datas['avatar'];
                 $add['is_agent'] = 0;
                 $add['model'] = 1;
@@ -252,7 +251,7 @@ class AlbumController extends Controller
                 $res = AlbumUserModel::create($add);
               //  dd($res);
                 if($res){
-                    $check = AlbumUserModel::where([['wechat_open_id',$res->wechat_open_id],['store_id',$datas['store_id']]])->first();
+                    $check = AlbumUserModel::where([['wechat_union_id',$res->wechat_union_id],['store_id',$datas['store_id']]])->first();
                     $user = [
                         'user_id'=>$check['id'],
                         //'avatar'=>$check['avatar'],
@@ -271,7 +270,7 @@ class AlbumController extends Controller
                 $save['username'] = preg_replace('/[\xf0-\xf7].{3}/', '', $datas['nickName']);
                 $save['avatar'] = $datas['avatar'];
                 $save['model'] = 1;
-                $res = AlbumUserModel::where('wechat_open_id',$res['openid'])->update($save);
+              //  $res = AlbumUserModel::where('wechat_union_id',$decryptedData['unionId'])->update($save);
                 //echo 111;
                     //print_r($check);die;
                     if($check->is_dealer == 1){
@@ -300,7 +299,7 @@ class AlbumController extends Controller
                     $userAuth->up_agent_id = $request->input('agent_id');
                 }
                 $add_record['agent_id'] = $request->input('agent_id');
-                $add_record['open_id'] = $check->wechat_open_id;
+                $add_record['union_id'] = $check->wechat_union_id;
                 $add_record['action'] = 4;
                 $add_record['store_id'] = $datas['store_id'];
                 $add_record['detail'] = null;

+ 4 - 3
app/Http/Controllers/Api/V1/FurnitureController.php

xqd xqd
@@ -1008,7 +1008,7 @@ class FurnitureController extends Controller
      *          "store_id": 1,
      *          "username": "roger",
      *          "role": 0,                        //用户类型:0:普通用户;1:生产部 2:包装部 3:经理
-     *          "wechat_open_id": "olAS94uwfTdsL3nDnvG67p_v5Vks",
+     *          "wechat_union_id": "olAS94uwfTdsL3nDnvG67p_v5Vks",
      *          "avatar": "https://wx.qlogo.cn/mmopen/vi_32/IOcxico8l4A7W3qxDeA53Id5kVAj2ibUGvQib9QibicTp5c1RNshDj6EKz2PKWp3reHfib0xxT4wa7jJzcb7a4EggkVw/132",
      *          "is_dealer": 0                 //是否经销商 0:不是 1:是
      *          },
@@ -1079,11 +1079,12 @@ class FurnitureController extends Controller
         $openid = $session['openid'];
         $session_key = $session['session_key'];
         $decryptedData = $app->encryptor->decryptData($session_key, $iv, $encryptData);
-        dd($decryptedData);
-        $userinfo = AlbumUserModel::where('wechat_open_id', $openid)->where('store_id', $storeid)->first(['id', 'username', 'wechat_open_id', 'avatar']);
+       // dd($decryptedData);
+        $userinfo = AlbumUserModel::where('wechat_union_id', $decryptedData['unionId'])->where('store_id', $storeid)->first(['id', 'username', 'wechat_union_id', 'avatar']);
 
         if (!$userinfo) {
             $data['wechat_open_id'] = $openid;
+            $data['wechat_union_id'] = $decryptedData['unionId'];
             $data['username'] = $request->get('nickName');
             $data['avatar'] = $request->get('avatar');
             $data['store_id'] = $request->get('store_id');

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

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