PaymentStatisticController.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: tandunzhao
  5. * Date: 2017/12/8
  6. * Time: 下午3:25
  7. */
  8. namespace App\Http\Controllers\Manage\Finance;
  9. use App\Http\Controllers\Manage\Finance\Transformers\PaymentStatisticTransformer;
  10. use App\Modules\Finance\Services\PaymentStatisticService;
  11. use Illuminate\Http\Request;
  12. class PaymentStatisticController extends BaseController
  13. {
  14. /**
  15. * @apiVersion 1.0.0
  16. * @apiDescription 每天对账统计
  17. * @api {GET} paymentStaticDay 每天对账统计
  18. * @apiGroup Finance
  19. * @apiName paymentStaticDay
  20. * @apiParam {String} [start_time] 开始时间(可不传)
  21. * @apiParam {String} [end_time] 结束时间(可不传)
  22. * @apiSuccess {Number} amount 打款成功金额.
  23. * @apiSuccess {Number} amount_num 打款成功笔.
  24. * @apiSuccess {Number} amount_person 对私打款成功金额.
  25. * @apiSuccess {Number} amount_person_num 对私打款成功笔.
  26. * @apiSuccess {Number} amount_company 对公打款成功金额.
  27. * @apiSuccess {Number} amount_company_num 对公打款成功笔.
  28. * @apiSuccess {Number} amount_audit_fail 审核不通过金额.
  29. * @apiSuccess {Number} amount_audit_fail_num 审核不通过笔数.
  30. * @apiSuccess {Number} amount_fail 打款失败金额.
  31. * @apiSuccess {Number} amount_fail_num 打款失败笔数.
  32. * @apiSuccess {Number} tallage 扣税金额.
  33. * @apiSuccess {String} created_time 每天对账统计时间
  34. * @apiSuccessExample {json} Success-Response:
  35. *
  36. * {
  37. * "code": 0,
  38. * "msg": "",
  39. * "data":{
  40. * "list": [
  41. * {
  42. * "amount": "2664.0000",
  43. * "amount_num": "9",
  44. * "amount_person": "2664.0000",
  45. * "amount_person_num": "9",
  46. * "amount_company": "2664.0000",
  47. * "amount_company_num": "9",
  48. * "amount_audit_fail": "6660.0000",
  49. * "amount_audit_fail_num": "12",
  50. * "amount_fail": "3663.0000",
  51. * "amount_fail_num": "9",
  52. * "tallage": "264.0000",
  53. * "created_time": "2017-12-04 00:00:00"
  54. * }
  55. * ],
  56. * "meta": {
  57. * "total": 1,
  58. * "per_page": 15,
  59. * "current_page": 1,
  60. * "last_page": 1,
  61. * "next_page_url": "",
  62. * "prev_page_url": ""
  63. * }
  64. * }
  65. * }
  66. */
  67. function get_list_day(Request $request) {
  68. $start_time = $request->has('start_time') && !empty($request->input('start_time')) ? date('Ymd',strtotime($request->input('start_time'))) : '';
  69. $end_time = $request->has('end_time') && !empty($request->input('end_time')) ? date('Ymd',strtotime($request->input('end_time'))) : '';
  70. $end_time = self::getMaxDay($end_time);
  71. $payments = PaymentStatisticService::getGroupByDayDataStatistic($start_time, $end_time);
  72. return response()->pagination(new PaymentStatisticTransformer(), $payments);
  73. }
  74. /**
  75. * @apiVersion 1.0.0
  76. * @apiDescription 每天对账统计导出
  77. * @api {GET} paymentStaticDayExport 每天对账统计导出
  78. * @apiGroup Finance
  79. * @apiName paymentStaticDayExport
  80. * @apiParam {String} [start_time] 开始时间(可不传)
  81. * @apiParam {String} [end_time] 结束时间(可不传)
  82. */
  83. function get_list_day_export(Request $request) {
  84. $start_time = $request->has('start_time') && !empty($request->input('start_time')) ? date('Ymd',strtotime($request->input('start_time'))) : '';
  85. $end_time = $request->has('end_time') && !empty($request->input('end_time')) ? date('Ymd',strtotime($request->input('end_time'))) : '';
  86. $end_time = self::getMaxDay($end_time);
  87. $payments = PaymentStatisticService::getGroupByDayDataStatistic($start_time, $end_time, true);
  88. header("Content-type:application/vnd.ms-excel");
  89. header("Content-Disposition:attachment;filename=" . "对账统计" . date("YmdHis") . ".csv");
  90. echo iconv("UTF-8","GBK","\"操作日期\",\"打款成功金额\",\"打款成功笔数\",\"对私成功金额\",\"对私成功笔数\",\"对公成功金额\",\"对公成功笔数\",\"审核不通过金额\",\"审核不通过笔数\",\"打款失败金额\",\"打款失败笔数\",\"扣税金额\"\r\n");
  91. if($payments)
  92. {
  93. foreach($payments as $item)
  94. {
  95. echo("\"" . iconv("UTF-8","GBK",date('Y-m-d H:i:s',strtotime($item->created_at))) . "\",");
  96. echo("\"" . $item->amount . "\",");
  97. echo("\"" . $item->amount_num . "\",");
  98. echo("\"" . $item->amount_person . "\",");
  99. echo("\"" . $item->amount_person_num . "\",");
  100. echo("\"" . $item->amount_company . "\",");
  101. echo("\"" . $item->amount_company_num . "\",");
  102. echo("\"" . $item->amount_audit_fail . "\",");
  103. echo("\"" . ($item->amount_audit_fail_num) . "\",");
  104. echo("\"" . $item->amount_fail . "\",");
  105. echo("\"" . $item->amount_fail_num . "\",");
  106. echo("\"" . $item->tallage . "\"\r\n");
  107. }
  108. }
  109. exit();
  110. }
  111. }