OfficialAccountsController.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. namespace App\Http\Controllers\Manage\OfficialAccount;
  3. use App\Http\Controllers\Channel\BaseController;
  4. use App\Modules\OfficialAccount\Services\OfficialAccountService;
  5. use App\Http\Controllers\Manage\OfficialAccount\Transformers\OfficialAccountTransformer;
  6. use Illuminate\Http\Request;
  7. use GuzzleHttp\Client;
  8. use App\Libs\OSS;
  9. class OfficialAccountsController extends BaseController
  10. {
  11. /**
  12. * @apiVersion 1.0.0
  13. * @api {GET} OfficialAccount/allOfficialAccountBydistributionChannelId 根据分销渠道号获取服务号列表
  14. * @apiGroup OfficialAccount
  15. * @apiName allOfficialAccountBydistributionChannelId
  16. * @apiParam {String} distribution_channel_id 分销渠道id.
  17. * @apiSuccess {String} name 公众号原始名称.
  18. * @apiSuccess {String} nickname 公众号名称.
  19. * @apiSuccess {String} alias 唯一ID.
  20. * @apiSuccess {String} qrcode_url 二维码地址.
  21. * @apiSuccess {String} principal_name 公司名称.
  22. * @apiSuccess {String} func_info 功能信息.
  23. * @apiSuccess {String} head_img 头像地址.
  24. * @apiSuccess {String} appid 微信appID.
  25. * @apiSuccess {String} appsecret 微信appsecret.
  26. * @apiSuccess {String} verify_txt 验证文件.
  27. * @apiSuccess {String} verify_type_info 授权方认证类型.
  28. * @apiSuccess {String} authorizer_refresh_token 授权的刷新token.
  29. * @apiSuccess {String} cancel_auth_time 取消授权时间.
  30. * @apiSuccess {String} official_account_type 第三方平台关注公众号.
  31. * @apiSuccess {Number} is_auth 是否授权.
  32. * @apiSuccess {String} service_type_info 服务号类型.
  33. * @apiSuccess {Number} subscribe_top_num 强制关注总额.
  34. * @apiSuccess {Number} subscribe_day_maximum 强制关注日限额.
  35. * @apiSuccess {Number} todayForceSubscribeUsers 今日关注总数.
  36. * @apiSuccess {Number} allForceSubscribeUsers 关注总数.
  37. * @apiSuccess {Number} is_enabled 是否可用.
  38. * @apiSuccessExample {json} Success-Response:
  39. *
  40. * {
  41. * "code": 0,
  42. * "msg": "",
  43. * "data": {
  44. * {
  45. * "name": "测试呵呵",
  46. * "nickname": "大哥",
  47. * "alias": "23534dsgdsvdx",
  48. * "head_img": "www.baidu.com",
  49. * "appid": "1211",
  50. * "appsecret": "dsfsdf3452352",
  51. * "verify_txt": null,
  52. * "is_auth": 1,
  53. * "service_type_info": "546dsfwr23r",
  54. * "subscribe_top_num": null,
  55. * "subscribe_day_maximum": null,
  56. * "distribution_channel_id": 1,
  57. * "qrcode_url": "fdhgfds435gsdfg43t",
  58. * "principal_name": "dfgh435saf2332",
  59. * "func_info": "ry3t342trwe",
  60. * "authorizer_refresh_token": "4534dfsgdsgsdgsdg",
  61. * "cancel_auth_time": null,
  62. * "official_account_type": "32dfaw234yewf",
  63. * "verify_type_info": null,
  64. * "is_enabled": 1,
  65. * "todayForceSubscribeUsers": 0,
  66. * "allForceSubscribeUsers": 0
  67. * }
  68. * }
  69. * }
  70. */
  71. function allOfficialAccountBydistributionChannelId(Request $request)
  72. {
  73. $distribution_channel_id = $request->has('distribution_channel_id') ? $request->input('distribution_channel_id') : '';
  74. if(empty($distribution_channel_id)) {
  75. return response()->error("PARAM_EMPTY");
  76. }
  77. \Log::info('-------------------获取当前渠道下的所有服务号-----------------------------------');
  78. \Log::info($distribution_channel_id);
  79. $officialAccount['distribution_channel_id'] = $distribution_channel_id;
  80. $officialAccountService = OfficialAccountService::allOfficialAccountBydistributionChannelId($officialAccount);
  81. return response()->collection(new OfficialAccountTransformer(), $officialAccountService);
  82. }
  83. /**
  84. * @apiVersion 1.0.0
  85. * @api {GET} OfficialAccount/officialAccountCountByChannelId 通过渠道Id获取公众号数量
  86. * @apiGroup OfficialAccount
  87. * @apiName officialAccountCountByChannelId
  88. * @apiParam {String} distribution_channel_id 分销渠道id.
  89. * @apiSuccess {Number} official_num 公众号数量.
  90. * @apiSuccessExample {json} Success-Response:
  91. *
  92. * {
  93. * "code": 0,
  94. * "msg": "",
  95. * "data": {
  96. * "official_num": 2,
  97. * }
  98. * }
  99. */
  100. function officialAccountCountByChannelId(Request $request)
  101. {
  102. $distribution_channel_id = $request->has('distribution_channel_id') ? $request->input('distribution_channel_id') : '';
  103. if(empty($distribution_channel_id)) {
  104. return response()->error("PARAM_EMPTY");
  105. }
  106. $officialAccount['distribution_channel_id'] = $distribution_channel_id;
  107. $officialAccountService = OfficialAccountService::officialAccountCountByChannelId($officialAccount);
  108. return response()->success(['official_num'=>$officialAccountService]);
  109. }
  110. }