123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <?php
- namespace General\Controllers\CompanyAuth;
- use App\Http\Controllers\Controller;
- use General\Controllers\CompanyAuth\Transformers\SubScribeRecordTransformer;
- use General\Controllers\CompanyAuth\Transformers\UserTransformer;
- use General\Requests\CompanyAuth\ChannelQueryRequest;
- use General\Services\User\UserService;
- class UserController extends Controller
- {
- /**
- * @apiDefine User 用户信息
- */
- /**
- * @api {post} company/auth/users 用户信息
- * @apiVersion 1.0.0
- * @apiName users
- * @apiGroup User
- * @apiParam {String} channel_id 站点id
- * @apiParam {Int} page 分页页码
- * @apiParam {String} app_id 分配好的{app_id}
- * @apiParam {String} nonce_str 随机字符串
- * @apiParam {String} timestamp 时间戳
- * @apiParam {String} uid (可以不传) 用户uid,','分隔;最多不超过100个
- * @apiParam {String} start_time (可以不传) 开始时间(时间区间小于30天,格式yyyy-MM-dd HH:mm:ss)
- * @apiParam {String} end_time (可以不传) 截止时间(时间区间小于30天,格式yyyy-MM-dd HH:mm:ss)
- * @apiParam {String} sign 签名 规则同微信支付签名MD5(排序好的请求字符串&key=分配好的{app_secret})
- * @apiSuccess {int} code 状态码
- * @apiSuccess {String} msg 信息
- * @apiSuccess {Object} data 结果集
- * @apiSuccess {Object} list 数据结果
- * @apiSuccess {Object} meta 分页信息
- * @apiSuccess {Int} total 分页总数
- * @apiSuccess {Int} id 用户id
- * @apiSuccess {Int} channel_id 站点ID
- * @apiSuccess {String} app_id 关注app_id
- * @apiSuccess {String} opend_id 关注open_id
- * @apiSuccess {String} register_openid 注册open_id
- * @apiSuccess {String} ua 用户user_agent
- * @apiSuccess {String} register_ip 注册IP
- * @apiSuccess {String} register_time 注册时间
- * @apiSuccess {String} subscribe_time 关注时间
- * @apiSuccess {String} is_subscribed 是否关注(1.已关注 0.未关注)
- * @apiSuccess {String} nickname 用户昵称
- * @apiSuccess {String} balance 总书币
- * @apiSuccess {String} sex 性别
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "code": 0,
- * "msg": "",
- * "data": {
- * "list": [
- * {
- * "id": 7475378,
- * "channel_id": 166,
- * "app_id": null,
- * "opend_id": "oq6ID0ovAjyxnWZRbm3YPz8Pz8nE",
- * "register_time": "2018-03-20 00:00:08",
- * "subscribe_time": "",
- * "nickname": "用户昵称"
- * }
- * ],
- * "meta": {
- * "total": 1,
- * "per_page": 100,
- * "current_page": 1,
- * "last_page": 1,
- * "next_page_url": "",
- * "prev_page_url": ""
- * }
- * }
- *}
- */
- public function users(ChannelQueryRequest $request)
- {
- $channel_id = $request->get('channel_id');
- $uid_str = $request->get('uid', '');
- $start_time = $request->get('start_time', '');
- $end_time = $request->get('end_time', '');
- $service = new UserService;
- 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);
- } else {
- $result = $service->companyAuthUsers($channel_id, $start_time, $end_time);
- }
- return response()->pagination(new UserTransformer, $result);
- }
- /**
- * @api {post} company/auth/users/subscribes 用户关注记录
- * @apiVersion 1.0.0
- * @apiName subscribeRecords
- * @apiGroup User
- * @apiParam {String} channel_id 站点id
- * @apiParam {String} uid 用户uid,','分隔;最多不超过100个
- * @apiParam {Int} page 分页页码
- * @apiParam {String} app_id 分配好的{app_id}
- * @apiParam {String} nonce_str 随机字符串
- * @apiParam {String} timestamp 时间戳
- * @apiParam {String} sign 签名 规则同微信支付签名MD5(排序好的请求字符串&key=分配好的{app_secret})
- * @apiSuccess {int} code 状态码
- * @apiSuccess {String} msg 信息
- * @apiSuccess {Object} data 结果集
- * @apiSuccess {Object} list 数据结果
- * @apiSuccess {Object} meta 分页信息
- * @apiSuccess {Int} total 分页总数
- * @apiSuccess {Int} uid 用户ID
- * @apiSuccess {Int} distribution_channel_id 站点ID
- * @apiSuccess {String} appid 关注app_id
- * @apiSuccess {String} openid 关注open_id
- * @apiSuccess {Int} is_subscribed 是否关注
- * @apiSuccess {String} subscribe_time 关注时间
- * @apiSuccess {String} unsubscribe_time 取关时间
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "code": 0,
- * "msg": "",
- * "data": {
- * "list": [
- * {
- * "id": 7475378,
- * "channel_id": 166,
- * "app_id": null,
- * "opend_id": "oq6ID0ovAjyxnWZRbm3YPz8Pz8nE",
- * "register_time": "2018-03-20 00:00:08",
- * "subscribe_time": ""
- * }
- * ],
- * "meta": {
- * "total": 1,
- * "per_page": 100,
- * "current_page": 1,
- * "last_page": 1,
- * "next_page_url": "",
- * "prev_page_url": ""
- * }
- * }
- *}
- */
- public function subscribeRecords(ChannelQueryRequest $request)
- {
- $uid_str = $request->get('uid', '');
- $channel_id = $request->get('channel_id');
- $result = [];
- if ($uid_str) {
- $uids = explode(',', $uid_str);
- $uids = count($uids) > 100 ? collect($uids)->take(100) : $uids;
- $service = new UserService;
- $result = $service->findSubscribeRecords($channel_id, $uids);
- }
- return response()->pagination(new SubScribeRecordTransformer, $result);
- }
- }
|