RebateController.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. /**
  3. * Rebate.php UTF-8
  4. * 返利模块API
  5. *
  6. * @date : 2018/7/27 11:23
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : Huosdk 8.0
  11. */
  12. namespace api\rebate\controller;
  13. use api\common\controller\V2ApiBaseController;
  14. use huolib\constant\CommonConst;
  15. use huolib\status\AccountStatus;
  16. use huolib\status\GameStatus;
  17. use huolib\status\MemberStatus;
  18. use huolib\tool\StrUtils;
  19. use huoRebate\controller\RebateOut;
  20. class RebateController extends V2ApiBaseController {
  21. public function _initialize() {
  22. parent::_initialize();
  23. $this->checkLogin();
  24. }
  25. /**
  26. * 可返利游戏列表
  27. * http://doc.huosdk.com/138?page_id=3722
  28. * 【域名】/user/rebate/list
  29. */
  30. public function getGameList() {
  31. $_page = $this->request->param('page/d', 1); /* 页码 默认为1 代表第一页 1 */
  32. $_offset = $this->request->param('offset/d', 10); /* 每页显示数量 默认为10 */
  33. $_rdata = (new RebateOut())->getGameList($this->mem_id, $_page, $_offset);
  34. $this->returnData($_rdata);
  35. }
  36. /**
  37. * 提交返利申请
  38. * http://doc.huosdk.com/138?page_id=3727
  39. * 【域名】/user/rebate/add
  40. */
  41. public function add() {
  42. $_param['app_id'] = $this->request->param('game_id', 0);
  43. $_param['server_id'] = $this->request->param('server_id', '');
  44. $_param['server_name'] = $this->request->param('server_name', '');
  45. $_param['role_id'] = $this->request->param('role_id', '');
  46. $_param['role_name'] = $this->request->param('role_name', '');
  47. $_param['mobile'] = $this->request->param('mobile', '');
  48. $_param['remark'] = $this->request->param('remark', '');
  49. $_param['mg_mem_id'] = $this->request->param('mg_mem_id/d', 0);
  50. $_start_date = $this->request->param('start_date', '');
  51. $_end_date = $this->request->param('end_date', '');
  52. if (empty($_param['app_id']) || !is_numeric($_param['app_id'])) {
  53. $_code = GameStatus::GAME_ID_EMPTY;
  54. $this->error(GameStatus::getMsg($_code), [], $_code);
  55. }
  56. if (empty($_param['server_id']) || !is_numeric($_param['server_id'])) {
  57. $_code = GameStatus::SERVER_ID_EMPTY;
  58. $this->error(GameStatus::getMsg($_code), [], $_code);
  59. }
  60. if (empty($_param['role_id']) || !is_numeric($_param['role_id'])) {
  61. $_code = GameStatus::ROLE_ID_EMPTY;
  62. $this->error(GameStatus::getMsg($_code), [], $_code);
  63. }
  64. if (empty($_param['mg_mem_id']) || !is_numeric($_param['mg_mem_id'])) {
  65. $_code = AccountStatus::MEM_GAME_NOT_EXISTS;
  66. $this->error(AccountStatus::getMsg($_code), [], $_code);
  67. }
  68. if (empty($_param['mobile'])) {
  69. $_code = MemberStatus::PHONE_EMPTY;
  70. $this->error(MemberStatus::getMsg($_code), [], $_code);
  71. }
  72. if (true != StrUtils::checkPhone($_param['mobile'])) {
  73. $_code = MemberStatus::PHONE_ERROR;
  74. $this->error(MemberStatus::getMsg($_code), [], $_code);
  75. }
  76. $_start_time = 0;
  77. $_end_time = 0;
  78. if (!empty($_start_date)) {
  79. $_start_time = strtotime($_start_date);
  80. }
  81. if (!empty($_end_date)) {
  82. $_end_time = strtotime($_end_date) + CommonConst::CONST_DAY_SECONDS;
  83. }
  84. $_param['start_time'] = $_start_time;
  85. $_param['end_time'] = $_end_time;
  86. $_rdata = (new RebateOut())->addRebate($this->mem_id, $_param);
  87. $this->returnData($_rdata);
  88. }
  89. /**
  90. * 申请记录
  91. * http://doc.huosdk.com/138?page_id=3724
  92. * 【域名】/user/gratelist
  93. * 【域名】/user/rebate/rlist
  94. */
  95. public function getApplyList() {
  96. $_page = $this->request->param('page/d', 1); /* 页码 默认为1 代表第一页 1 */
  97. $_offset = $this->request->param('offset/d', 10); /* 每页显示数量 默认为10 */
  98. $_page = $_page.','.$_offset;
  99. $_rdata = (new RebateOut())->getRebateList($this->mem_id, [], $_page);
  100. $this->returnData($_rdata);
  101. }
  102. /**
  103. * 获取游戏区服列表
  104. * http://doc.huosdk.com/138?page_id=3725
  105. * 【域名】/user/rebate/roles_info
  106. */
  107. public function getRolesInfo() {
  108. $_app_id = $this->request->param('game_id/d', 0); /* 游戏ID */
  109. $_rdata = (new RebateOut())->getServerRoles($this->mem_id, $_app_id);
  110. $this->returnData($_rdata);
  111. }
  112. /**
  113. * 获取充值金额
  114. * http://doc.huosdk.com/138?page_id=3728
  115. * 【域名】/user/rebate/get_amount
  116. */
  117. public function getAmount() {
  118. $_app_id = $this->request->param('game_id/d', 0); /* 游戏ID */
  119. $_start_date = $this->request->param('start_date/s', ''); /* 开始日期 */
  120. $_end_date = $this->request->param('end_date/s', ''); /* 结束日期 */
  121. $_start_time = 0;
  122. $_end_time = 0;
  123. if (!empty($_start_date)) {
  124. $_start_time = strtotime($_start_date);
  125. }
  126. if (!empty($_end_date)) {
  127. $_end_time = strtotime($_end_date) + CommonConst::CONST_DAY_SECONDS;
  128. }
  129. $_rdata = (new RebateOut())->getAmount($this->mem_id, $_app_id, $_start_time, $_end_time);
  130. $this->returnData($_rdata);
  131. }
  132. /**
  133. * 返利详情
  134. * http://doc.huosdk.com/138?page_id=3800
  135. * 【域名】/user/rebate/orderdetail
  136. */
  137. public function getOrderDetail() {
  138. $_ro_id = $this->request->param('rebate_id/d', 0);
  139. if (empty($_ro_id)) {
  140. $this->success(lang('SUCCESS'));
  141. }
  142. $_rdata = (new RebateOut())->getRoDetail($this->mem_id, $_ro_id);
  143. $this->returnData($_rdata);
  144. }
  145. }