CustomSendStatsController.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace App\Http\Controllers\Wechat\OfficialAccount;
  3. use App\Http\Controllers\Channel\BaseController as ChannelBaseController;
  4. use App\Modules\OfficialAccount\Services\CustomSendStatsService;
  5. use App\Http\Controllers\Channel\OfficialAccount\Transformers\CustomSendStatsTransformers;
  6. use Illuminate\Http\Request;
  7. class CustomSendStatsController extends ChannelBaseController
  8. {
  9. /**
  10. * @apiDefine OfficialAccount 公众号
  11. */
  12. /**
  13. * @apiVersion 1.0.0
  14. * @api {GET} OfficialAccount/customSendDayStatsByChannelAndFrom 获取每日智能推送分析数据
  15. * @apiGroup OfficialAccount
  16. * @apiName customSendDayStatsByChannelAndFrom
  17. * @apiSuccessExample {json} Success-Response:
  18. *
  19. * {
  20. * "code": 0,
  21. * "msg": "",
  22. * "data": [
  23. *
  24. * ]
  25. * }
  26. */
  27. function customSendDayStatsByChannelAndFrom(Request $request) {
  28. $distribution_channel_id = $request->has('distribution_channel_id') ? $request->input('distribution_channel_id') : '';
  29. if(empty($distribution_channel_id)) {
  30. return response()->error("PARAM_EMPTY");
  31. }
  32. $from = $request->has('from') ? $request->input('from') : '';
  33. if(empty($from)) {
  34. return response()->error("PARAM_EMPTY");
  35. }
  36. $customMsgService = CustomSendStatsService::customSendDayStatsByChannelAndFrom($distribution_channel_id,$from);
  37. if (!empty($customMsgService)) {
  38. return response()->pagination(new CustomSendStatsTransformers(), $customMsgService);
  39. }else{
  40. return response()->success(['data'=>0]);
  41. }
  42. }
  43. /**
  44. * @apiVersion 1.0.0
  45. * @api {GET} OfficialAccount/customSendStatsByChannelAndFrom 获取渠道下智能推送分析总数据
  46. * @apiGroup OfficialAccount
  47. * @apiName customSendStatsByChannelAndFrom
  48. * @apiSuccessExample {json} Success-Response:
  49. *
  50. * {
  51. * "code": 0,
  52. * "msg": "",
  53. * "data": [
  54. *
  55. * ]
  56. * }
  57. */
  58. function customSendStatsByChannelAndFrom(Request $request) {
  59. $distribution_channel_id = $request->has('distribution_channel_id') ? $request->input('distribution_channel_id') : '';
  60. if(empty($distribution_channel_id)) {
  61. return response()->error("PARAM_EMPTY");
  62. }
  63. $from = $request->has('from') ? $request->input('from') : '';
  64. if(empty($from)) {
  65. return response()->error("PARAM_EMPTY");
  66. }
  67. $customMsgService = CustomSendStatsService::customSendStatsByChannelAndFrom($distribution_channel_id,$from);
  68. if (!empty($customMsgService)) {
  69. return response()->item(new CustomSendStatsTransformers(), $customMsgService);
  70. }else{
  71. return response()->success(['data'=>0]);
  72. }
  73. }
  74. }