DataController.php 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: tandunzhao
  5. * Date: 2018/6/20
  6. * Time: 下午4:53
  7. */
  8. namespace App\Http\Controllers\Manage\OfficialAccount;
  9. use App\Http\Controllers\Manage\Finance\BaseController;
  10. use App\Http\Controllers\Manage\OfficialAccount\Transformers\OfficialAccountDaySubStatTransformer;
  11. use App\Modules\Subscribe\Services\OfficialAccountDaySubStatService;
  12. use Illuminate\Http\Request;
  13. class DataController extends BaseController
  14. {
  15. /**
  16. * @apiVersion 1.0.0
  17. * @apiDescription 每个服务号每月订阅数据
  18. * @api {GET} OfficialAccount/day/sub/stat
  19. * @apiGroup OfficialAccount
  20. * @apiName get_list
  21. * @apiParam {String} [appid] 服务号ID
  22. * @apiParam {String} [search_name] 搜索服务号名称
  23. * @apiParam {String} [type] month, day 按月,按天
  24. * @apiParam {String} [start_time] 开始时间2017-01-01.(可不传)
  25. * @apiParam {String} [end_time] 结束时间2017-02-01.(可不传)
  26. *
  27. * @apiSuccess {String} appid 服务号ID
  28. * @apiSuccess {String} official_account_name 服务号名称
  29. * @apiSuccess {String} date 日期.
  30. * @apiSuccess {String} month 日期.
  31. * @apiSuccess {Number} reward_balance 赠送币金额.
  32. * @apiSuccess {Number} charge_balance 充值消耗币金额.
  33. * @apiSuccess {Number} fee 总额金额.
  34. * @apiSuccessExample {json} Success-Response:
  35. *
  36. * {
  37. * "code": 0,
  38. * "msg": "",
  39. * "data":
  40. * {
  41. * "list":[
  42. * {
  43. * "appid": "wx6f0d9d775ef72b9a",
  44. * "official_account_name": "择天小说",
  45. * "month": "2018-05",
  46. * "date": "",
  47. * "reward_balance": "287950",
  48. * "charge_balance": "275964",
  49. * "fee": "563914"
  50. * }
  51. * ]
  52. * "meta":{
  53. * "total": 4,
  54. * "per_page": 15,
  55. * "current_page": 1,
  56. * "last_page": 1,
  57. * "next_page_url": "",
  58. * "prev_page_url": ""
  59. * }
  60. * }
  61. * }
  62. */
  63. function get_list(Request $request) {
  64. $appid = $request->has('appid') ? $request->input('appid') : '';
  65. $official_account_name = $request->has('search_name') ? $request->input('search_name') : '';
  66. $start_time = $request->has('start_time') && !empty($request->input('start_time')) ? date('Ymd',strtotime($request->input('start_time'))) : '';
  67. $end_time = $request->has('end_time') && !empty($request->input('end_time')) ? date('Ymd',strtotime($request->input('end_time'))) : '';
  68. $end_time = self::getMaxDay($end_time);
  69. $params = [
  70. 'appid'=>$appid,
  71. 'official_account_name'=>$official_account_name,
  72. 'start_date'=>$start_time,
  73. 'end_date'=>$end_time,
  74. ];
  75. $type = $request->has('type') ? $request->input('type') : 'month';
  76. $data = [];
  77. if($type == 'day') {
  78. $data = OfficialAccountDaySubStatService::getDayListData($params);
  79. } else {
  80. $data = OfficialAccountDaySubStatService::getMonthListData($params);
  81. }
  82. return response()->pagination(new OfficialAccountDaySubStatTransformer(), $data);
  83. }
  84. }