123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- <?php
- namespace App\Http\Controllers\Manage\Channel;
- use App\Http\Controllers\Manage\BaseController;
- use App\Http\Controllers\Manage\Channel\Transformers\ChannelUserTransformer;
- use App\Modules\Channel\Services\ChannelUserService;
- use App\Modules\Channel\Services\CompanyService;
- use Illuminate\Http\Request;
- /**
- * Class ChannelUserController 渠道
- * @package App\Http\Controllers\Manage\Channel
- */
- class ChannelUserController extends BaseController
- {
- /**
- * @apiDefine channel 渠道
- */
- /**
- * @apiVersion 1.0.0
- * @apiDescription 更新渠道信息新
- * @api {POST} channel/updateChannelUserInfo 更新渠道信息新
- * @apiGroup channel
- * @apiName channel/updateChannelUserInfo
- * @apiParam {Number} distribution_channel_id 渠道id
- * @apiParam {String} [name] 渠道名称
- * @apiParam {String} [nickname] 渠道昵称
- * @apiParam {Number} [pay_merchant_id] 渠道支付通道
- * @apiParam {Number} [distribution_manages_id] 渠道管理员
- * @apiParam {String} [phone] 渠道电话
- * @apiParam {String} [person_in_charge_name] 渠道负责人
- * @apiParam {String} [remark] 备注
- * @apiParam {Number} [is_enabled] 是否开通 0:未审核; 1:审核通过
- * @apiParam {Number} [company_id] 设置公司
- *
- * @apiSuccess {Number} id 渠道ID.
- * @apiSuccess {String} phone 手机号码.
- * @apiSuccess {String} name 渠道名称.
- * @apiSuccess {String} pay_merchant 支付商户.
- * @apiSuccess {String} nickname 昵称.
- * @apiSuccess {String} password 密码.
- * @apiSuccess {String} latest_login_time 最后登陆时间.
- * @apiSuccess {String} latest_login_ip 最后登陆IP.
- * @apiSuccess {String} remark 备注.
- * @apiSuccess {String} register_ip 注册IP.
- * @apiSuccessExample {json} Success-Response:
- *
- * {
- * "code": 0,
- * "msg": "",
- * "data":
- * {
- * "id": 1,
- * "phone": "1586810210",
- * "name": "分销1",
- * "pay_merchant": "ALLINPAY_NALAN",
- * "nickname": "昵称",
- * "password": "34sdfsdfdsf23",
- * "latest_login_time": "2017-12-12 12:12:12",
- * "latest_login_ip": "56.3.21.2",
- * "remark": "啦啦啦",
- * "register_ip": "123.25.21.21",
- * }
- *
- * }
- */
- function updateChannelData(Request $request)
- {
- $distribution_channel_id = $request->has('distribution_channel_id') ? $request->input('distribution_channel_id') : '';
- if (empty(ChannelUserService::getById($distribution_channel_id))) {
- return response()->error('PARAM_ERROR');
- }
- $distribution_channel_name = $request->has('distribution_channel_name') ? $request->input('distribution_channel_name') : '';
- $nickname = $request->has('nickname') ? $request->input('nickname') : '';
- $pay_merchant_id = $request->has('pay_merchant_id') ? $request->input('pay_merchant_id') : '';
- $phone = $request->has('phone') ? $request->input('phone') : '';
- $person_in_charge_name = $request->has('person_in_charge_name') ? $request->input('person_in_charge_name') : '';
- $remark = $request->has('remark') ? $request->input('remark') : '';
- $distribution_manages_id = $request->has('distribution_manages_id') ? $request->input('distribution_manages_id') : '';
- $isEnabled = $request->has('is_enabled') ? $request->input('is_enabled') : '';
- $params = [
- 'name' => $distribution_channel_name,
- 'nickname' => $nickname,
- 'pay_merchant_id' => $pay_merchant_id,
- 'phone' => $phone,
- 'person_in_charge_name' => $person_in_charge_name,
- 'distribution_manages_id' => $distribution_manages_id,
- 'remark' => $remark,
- 'is_enabled' => $isEnabled,
- ];
- $company_id = $request->has('company_id') ? $request->input('company_id') : '';
- if ($company_id) {
- $company = CompanyService::getCompany($company_id);
- if ($company) {
- $params['company_id'] = $company->id;
- $params['company_name'] = $company->name;
- }
- }
- $channel = ChannelUserService::updateChannelData($distribution_channel_id, $params);
- return response()->item(new ChannelUserTransformer(), $channel);
- }
- /**
- * @apiVersion 1.0.0
- * @apiDescription 获取渠道列表新
- * @api {GET} channel/getChannelUserList 获取渠道列表新
- * @apiGroup channel
- * @apiName channel/getChannelUserList
- * @apiParam {Number} [distribution_channel_id] 渠道id.(可不传,获取所有渠道)
- * @apiParam {String} [distribution_channel_name] 渠道名称.(可不传,获取所有渠道)
- * @apiParam {String} [search_name] 搜索名称
- * @apiParam {String} [phone] 搜索手机号码
- * @apiParam {String} [start_time] 开始时间(可不传)
- * @apiParam {String} [end_time] 结束时间(可不传)
- * @apiParam {Number} [is_enabled] 0:待审核; 1:已审核.(可不传)
- * @apiParam {Number} [distribution_manages_id] 管理员ID.(可不传)
- * @apiParam {Number} [company_id] 公司ID.(可不传)
- * @apiParam {Number} [is_important] 公司是否重要
- * @apiParam {String} [orderByDesc] 排序字段.(可不传)['nickname', 'phone', 'create_time', 'company_id']
- *
- * @apiSuccess {Number} id 渠道ID.
- * @apiSuccess {String} name 渠道名称.
- * @apiSuccess {String} phone 手机号码.
- * @apiSuccess {String} pay_merchant 支付商户.
- * @apiSuccess {String} nickname 昵称.
- * @apiSuccess {String} latest_login_time 最后登陆时间.
- * @apiSuccess {String} latest_login_ip 最后登陆IP.
- * @apiSuccess {String} remark 备注.
- * @apiSuccess {String} register_ip 注册IP.
- * @apiSuccess {String} person_in_charge_name 负责人.
- * @apiSuccess {String} create_time 注册时间
- * @apiSuccess {Number} distribution_manages_id 管理员ID
- * @apiSuccess {String} distribution_manages_account 管理员
- * @apiSuccess {String} distribution_manages_number 管理员
- * @apiSuccess {String} distribution_manages_nickname 管理员昵称
- * @apiSuccessExample {json} Success-Response:
- *
- * {
- * "code": 0,
- * "msg": "",
- * "data": [
- * {
- * "id": 1,
- * "phone": "",
- * "name": "121",
- * "pay_merchant_id": 1,
- * "nickname": "是说",
- * "latest_login_time": "",
- * "latest_login_ip": "",
- * "is_enabled": 1,
- * "register_ip": "",
- * "remark": "",
- * "person_in_charge_name": "波哥帅",
- * "create_time": "2017-11-20 18:34:17",
- * "distribution_manages_id": 0,
- * "distribution_manages_account": null,
- * "distribution_manages_number": null,
- * "distribution_manages_nickname": null
- * }
- * ]
- * }
- */
- function getList(Request $request)
- {
- $distribution_channel_id = $request->has('distribution_channel_id') ? $request->input('distribution_channel_id') : '';
- $distribution_channel_name = $request->has('distribution_channel_name') ? $request->input('distribution_channel_name') : '';
- $start_time = $request->has('start_time') && !empty($request->input('start_time')) ? date('Ymd', strtotime($request->input('start_time'))) : '';
- $end_time = $request->has('end_time') && !empty($request->input('end_time')) ? date('Ymd', strtotime($request->input('end_time'))) : '';
- $distribution_manages_id = $request->has('distribution_manages_id') ? $request->input('distribution_manages_id') : '';
- $company_id = $request->has('company_id') ? $request->input('company_id') : '';
- $is_important = $request->input('is_important');
- $isEnabled = $request->has('is_enabled') ? $request->input('is_enabled') : '';
- $search_name = $request->has('search_name') ? $request->input('search_name') : '';
- $phone = $request->has('phone') ? $request->input('phone') : '';
- $orderByDesc = $request->has('orderByDesc') ? $request->input('orderByDesc') : '';
- //商务,只获取到当前商务下的渠道列表
- if ($this->getLoginUserRole() == "business") {
- $distribution_manages_id = $this->getLoginUserId();
- }
- $params = [
- 'channel_id' => $distribution_channel_id,
- 'channel_name' => $distribution_channel_name,
- 'start_date' => $start_time,
- 'end_date' => $end_time,
- 'distribution_manages_id' => $distribution_manages_id,
- 'is_enabled' => $isEnabled,
- 'search_name' => $search_name,
- 'phone' => $phone,
- 'orderByDesc' => $orderByDesc,
- 'company_id' => $company_id,
- 'is_important' => $is_important,
- ];
- $result = ChannelUserService::getChannelList($params);
- return response()->pagination(new ChannelUserTransformer(), $result);
- }
- /**
- * @apiVersion 1.0.0
- * @apiDescription 获取所有渠道列表新
- * @api {GET} channel/getChannelAllUserList 获取所有渠道列表新
- * @apiGroup channel
- * @apiName channel/getChannelAllUserList
- *
- * @apiSuccess {Number} id 渠道ID.
- * @apiSuccess {String} name 渠道名称.
- * @apiSuccess {String} phone 手机号码.
- * @apiSuccess {String} pay_merchant 支付商户.
- * @apiSuccess {String} nickname 昵称.
- * @apiSuccess {String} latest_login_time 最后登陆时间.
- * @apiSuccess {String} latest_login_ip 最后登陆IP.
- * @apiSuccess {String} remark 备注.
- * @apiSuccess {String} register_ip 注册IP.
- * @apiSuccess {String} person_in_charge_name 负责人.
- * @apiSuccess {String} create_time 注册时间
- * @apiSuccess {Number} distribution_manages_id 管理员ID
- * @apiSuccess {String} distribution_manages_account 管理员
- * @apiSuccess {String} distribution_manages_number 管理员
- * @apiSuccess {String} distribution_manages_nickname 管理员昵称
- * @apiSuccessExample {json} Success-Response:
- *
- * {
- * "code": 0,
- * "msg": "",
- * "data": [
- * {
- * "id": 1,
- * "phone": "",
- * "name": "121",
- * "pay_merchant_id": 1,
- * "nickname": "是说",
- * "latest_login_time": "",
- * "latest_login_ip": "",
- * "is_enabled": 1,
- * "register_ip": "",
- * "remark": "",
- * "person_in_charge_name": "波哥帅",
- * "create_time": "2017-11-20 18:34:17",
- * "distribution_manages_id": 0,
- * "distribution_manages_account": null,
- * "distribution_manages_number": null,
- * "distribution_manages_nickname": null
- * }
- * ]
- * }
- */
- function getAllList(Request $request)
- {
- $isEnabled = 1;
- $params = [
- 'is_enabled' => $isEnabled,
- ];
- $result = ChannelUserService::getChannelList($params, true);
- return response()->collection(new ChannelUserTransformer(), $result);
- }
- }
|