CommissionRateController.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: tandunzhao
  5. * Date: 2017/11/20
  6. * Time: 下午4:23
  7. */
  8. namespace App\Http\Controllers\Channel\Finance;
  9. use App\Http\Controllers\Manage\Channel\Transformers\CommissionRateTransformer;
  10. use App\Modules\Finance\Services\CommissionRateService;
  11. use Illuminate\Http\Request;
  12. class CommissionRateController extends BaseController
  13. {
  14. /**
  15. * @apiDefine Finance 结算提现模块
  16. */
  17. /**
  18. * @apiVersion 1.0.0
  19. * @apiDescription 获取佣金结算比例列表
  20. * @api {GET} commissionRates 佣金结算比例列表
  21. * @apiGroup Finance
  22. * @apiName commissionRates
  23. * @apiSuccess {Number} begin_amount 起始金额.
  24. * @apiSuccess {Number} end_amount 结束金额.
  25. * @apiSuccess {Number} rate 比例.
  26. * @apiSuccessExample {json} Success-Response:
  27. *
  28. * {
  29. * "code": 0,
  30. * "msg": "",
  31. * "data":
  32. * [
  33. * {
  34. * "begin_amount": 0,
  35. * "end_amount": 1000,
  36. * "rate": "0.10"
  37. * }
  38. * ]
  39. * }
  40. */
  41. function get_list(Request $request) {
  42. if(self::checkParamValueNumber($request, ['channel_id'])) {
  43. return response()->error("PARAM_ERROR");
  44. }
  45. $distribution_channel_id = $request->has('channel_id') ? $request->input('channel_id') : '';
  46. $result = CommissionRateService::getCommissionRateList($distribution_channel_id);
  47. return response()->collection(new CommissionRateTransformer(), $result);
  48. }
  49. /**
  50. * @apiVersion 1.0.0
  51. * @apiDescription 获取当前渠道当前佣金比例
  52. * @api {GET} getCommissionRate 获取当前渠道当前佣金比例
  53. * @apiGroup Finance
  54. * @apiName getCommissionRate
  55. * @apiSuccess {Number} rate 当前佣金比例.
  56. * @apiSuccessExample {json} Success-Response:
  57. *
  58. * {
  59. * "code": 0,
  60. * "msg": "",
  61. * "data":
  62. * {
  63. * "rate": "0.60"
  64. * }
  65. * }
  66. */
  67. function get_commissionRate(Request $request) {
  68. $distribution_channel_id = $this->getChannelId();
  69. $distribution_channel_name = $this->getChannelName();
  70. $distribution_channel_name = '';
  71. $rate = CommissionRateService::getRateCommissionRate($distribution_channel_id);
  72. return response()->success(compact('rate'));
  73. }
  74. }