AccountController.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * AccountController.php UTF-8
  4. *
  5. *
  6. * @date : 2018/6/1 17:10
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : luowei <lw@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace api\cfloat\controller;
  13. use api\common\controller\CFloatBaseController;
  14. use huoAccountDeal\controller\MemGameOut;
  15. use think\Lang;
  16. class AccountController extends CFloatBaseController {
  17. public function _initialize() {
  18. parent::_initialize();
  19. $langSet = $this->request->langset();
  20. Lang::load([APP_PATH.'cfloat'.DS.'lang'.DS.$langSet.DS.'account'.EXT,]);
  21. $this->checkLogin();
  22. }
  23. /**
  24. * 小号列表
  25. * http://doc.1tsdk.com/138?page_id=3395
  26. * 【域名】/cfloat/account/list
  27. */
  28. public function index() {
  29. $_param = $this->request->param();
  30. $_result = $this->validate($_param, 'Account.list');
  31. if ($_result !== true) {
  32. $this->error($_result);
  33. }
  34. $_page = $this->request->param('page/d', 1); /* 页码 默认为1 代表第一页 1 */
  35. $_offset = $this->request->param('offset/d', 10); /* 每页显示数量 默认为10 */
  36. $_app_id = $this->request->param('app_id/d');
  37. $_page = $_page.','.$_offset;
  38. $_account_list = (new MemGameOut())->getAccountList($this->mem_id, $_app_id, $_page);
  39. $this->returnData($_account_list);
  40. }
  41. /**
  42. * 添加小号
  43. * http://doc.1tsdk.com/138?page_id=3396
  44. * 【域名】/cfloat/account/add
  45. */
  46. public function add() {
  47. $_param = $this->request->param();
  48. $_result = $this->validate($_param, 'Account.add');
  49. if ($_result !== true) {
  50. $this->error($_result);
  51. }
  52. $_mem_id = $this->mem_id;
  53. $_app_id = $this->request->param('app_id/d');
  54. $_nickname = $this->request->param('nickname/s');
  55. $_rs = (new MemGameOut())->addAccount($_mem_id, $_app_id, $_nickname);
  56. $this->returnData($_rs);
  57. }
  58. /**
  59. * 切换小号
  60. * http://doc.1tsdk.com/138?page_id=3397
  61. * 【域名】/cfloat/account/change
  62. */
  63. public function change() {
  64. $_param = $this->request->param();
  65. $_result = $this->validate($_param, 'Account.change');
  66. if ($_result !== true) {
  67. $this->error($_result);
  68. }
  69. $_mem_id = $this->mem_id;
  70. $_app_id = $this->request->param('app_id/d');
  71. $_account_id = $this->request->param('mg_mem_id/d');
  72. $_rs = (new MemGameOut())->changeAccount($_mem_id, $_app_id, $_account_id);
  73. $this->returnData($_rs);
  74. }
  75. }