7 커밋 5f6d03f5f4 ... 44e816e147

작성자 SHA1 메시지 날짜
  zhuchengjie 44e816e147 '用户接口新增企微信息' 2 년 전
  zhuchengjie 6f3bb79fdb 'test' 2 년 전
  zhuchengjie 4830ee5d14 '兜底' 3 년 전
  zhuchengjie 5c141dd3e5 'temp表兜底' 3 년 전
  zhuchengjie 0f6e2c200f '过滤快应用站点' 3 년 전
  zhuchengjie 8c0a09a944 '补充chennel_user_ids' 3 년 전
  zhuchengjie 32f5a99c87 '结果集返回数组,调整判断' 3 년 전

+ 14 - 2
src/Controllers/CompanyAuth/AppController.php

@@ -155,8 +155,8 @@ class AppController extends Controller
         $is_enable = $request->get('is_enabled', '');
         if(!empty($phone)) {
             $channel = new ChannelService();
-            $distribution_channels = $channel->getChannelsByChannelUserIds([],$is_enable,$phone);
-            if(!$distribution_channels->isEmpty()){
+            $distribution_channels = $channel->getChannelsByChannelUserIds($this->channel_user_ids,$is_enable,$phone);
+            if($distribution_channels){
                 $distribution_channels = $distribution_channels->toArray();
                 $this->channel_ids = array_column($distribution_channels,'id');
             }
@@ -166,6 +166,7 @@ class AppController extends Controller
         return response()->success($result);
     }
 
+
     /**
      * @api {post} company/auth/orders 订单
      * @apiVersion 1.0.0
@@ -414,6 +415,17 @@ class AppController extends Controller
             $user_info = $prev_coin = DB::connection('mysql')->table('users')
                 ->where(['distribution_channel_id'=>$channel_id, 'openid'=>$openid])
                 ->select('id', 'distribution_channel_id', 'balance', 'reward_balance')->first();
+            if(empty($user_info)){
+                $temp_user_id = DB::connection('mysql')->table('temp_force_subscribe_users')
+                    ->where('distribution_channel_id',$channel_id)
+                    ->where('openid',$openid)
+                    ->value('uid');
+                if(isset($temp_user_id) && !empty($temp_user_id)){
+                    $user_info = $prev_coin = DB::connection('mysql')->table('users')
+                        ->select('id', 'distribution_channel_id', 'balance', 'reward_balance')
+                        ->find($temp_user_id);
+                }
+            }
         }
         $user_info = (array)$user_info;
         if (!$user_info) return response()->json(['code'=>-1, 'msg'=>'用户不存在!']);

+ 8 - 4
src/Controllers/CompanyAuth/Transformers/UserTransformer.php

@@ -20,10 +20,14 @@ class UserTransformer
             'register_ip' => $item->register_ip,
             'register_time' =>  (string)$item->created_at,
             'ua' => $item->user_env ? $item->user_env->ua : '',
-            'app_id' => $item->force_subscribe_user ? $item->force_subscribe_user->appid : '',
-            'opend_id' => $item->force_subscribe_user ? $item->force_subscribe_user->openid : '',
-            'is_subscribed' => $item->force_subscribe_user && $item->force_subscribe_user->is_subscribed ? (string)$item->force_subscribe_user->is_subscribed : '0',
-            'subscribe_time' => $item->force_subscribe_user ? (string)$item->force_subscribe_user->subscribe_time : '',
+            'app_id' => $item->appid ?? '',
+            'opend_id' => $item->openid ?? '',
+            'ewechat_external_user_id' => $item->external_user_id ?? '',
+            'ewechat_open_external_user_id' => $item->open_external_user_id ?? '',
+            'ewechat_agent_id' => $item->agent_id ?? '',
+            'ewechat_unionid' => $item->unionid ?? '',
+            'is_subscribed' => $item->is_subscribed ?? '0',
+            'subscribe_time' => $item->subscribe_time ?? '',
             'nickname' => $item->nickname ? (string)$item->nickname : '',
             'balance' => $item->balance ? (string)$item->balance : '',
             'sex' => isset($sex[$item->sex]) ? $sex[$item->sex] : ''

+ 6 - 2
src/Controllers/CompanyAuth/UserController.php

@@ -47,6 +47,10 @@ class UserController extends Controller
      * @apiSuccess {String}      nickname 用户昵称
      * @apiSuccess {String}      balance 总书币
      * @apiSuccess {String}      sex 性别
+     * @apiSuccess {String}      ewechat_external_user_id  相对于企微真实的外部联系人id
+     * @apiSuccess {String}      ewechat_open_external_user_id  相对于代开发应用的外部联系人id
+     * @apiSuccess {String}      ewechat_agent_id    企业安装的代自建应用id
+     * @apiSuccess {String}      ewechat_unionid  外部联系人在微信开放平台的唯一身份标识(微信unionid),通过此字段企业可将外部联系人与公众号/小程序用户关联起来
      * @apiSuccessExample {json} Success-Response:
      *     HTTP/1.1 200 OK
      *{
@@ -85,9 +89,9 @@ class UserController extends Controller
         if ($uid_str) {
             $uids = explode(',', $uid_str);
             $uids = count($uids) > 100 ? collect($uids)->take(100) : $uids;
-            $result = $service->companyAuthUsers($channel_id, $start_time, $end_time, $uids);
+            $result = $service->companyAuthUsersNew($channel_id, $start_time, $end_time, $uids);
         } else {
-            $result = $service->companyAuthUsers($channel_id, $start_time, $end_time);
+            $result = $service->companyAuthUsersNew($channel_id, $start_time, $end_time);
         }
         return response()->pagination(new UserTransformer, $result);
     }

+ 7 - 1
src/Models/Channel/Channel.php

@@ -32,6 +32,12 @@ class Channel extends Model
         'site_nick_name',
         'is_outer_site',
         'is_old_user_site',
-        'is_yq_move'
+        'is_yq_move',
+        'allows_change_chapter_price',
+        'is_domain_simple',
+        'default_pay_merchant_id',
+        'property',
+        'first_charge_template_status',
+        'is_qapp'
     ];
 }

+ 2 - 2
src/Services/Channel/ChannelService.php

@@ -31,8 +31,8 @@ class ChannelService
         }
 
         if ($where) {
-            return Channel::whereIn('channel_user_id', $channel_user_ids)->where($where)->get();
+            return Channel::whereIn('channel_user_id', $channel_user_ids)->where($where)->where('is_qapp',0)->get();
         }
-        return Channel::whereIn('channel_user_id', $channel_user_ids)->get();
+        return Channel::whereIn('channel_user_id', $channel_user_ids)->where('is_qapp',0)->get();
     }
 }

+ 23 - 0
src/Services/User/UserService.php

@@ -30,6 +30,29 @@ class UserService
         return $sql->paginate(100);
     }
 
+    public function companyAuthUsersNew($channel_id,$start_time = '',$end_time = '',$uids = [])
+    {
+        $query = User::leftjoin('force_subscribe_user','force_subscribe_user.uid','users.id')
+            ->leftjoin('ww_external_contact_infos','ww_external_contact_infos.uid','users.id')
+            ->leftjoin('ww_corp_infos','ww_corp_infos.corp_id','ww_external_contact_infos.corp_id')
+            ->select('users.*','force_subscribe_user.appid','force_subscribe_user.openid','force_subscribe_user.is_subscribed',
+                'force_subscribe_user.subscribe_time','ww_external_contact_infos.external_user_id','ww_external_contact_infos.open_external_user_id','ww_corp_infos.agent_id','ww_external_contact_infos.unionid')
+            ->where('ww_corp_infos.state','normal')
+            ->where('users.distribution_channel_id',$channel_id)
+            ->orderBy('id', 'desc');
+
+        if($start_time){
+            $query->where('users.created_at', '>=', $start_time);
+        }
+        if ($end_time) {
+            $query->where('users.created_at', '<=', $end_time);
+        }
+        if ($uids) {
+            $query->whereIn('users.id', $uids);
+        }
+        return $query->paginate(100);
+    }
+
     public function findSubscribeRecords(int $channel_id, array $uids)
     {
         return SubscribeRecord::where('distribution_channel_id', $channel_id)