AccountController.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <?php
  2. /**
  3. * AccountController.php UTF-8
  4. * 小号交易
  5. *
  6. * @date : 2018/7/30 18:19
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : Huosdk 8.0
  11. */
  12. namespace api\accountdeal\controller;
  13. use api\common\controller\V2ApiBaseController;
  14. use huoAccountDeal\controller\AccountOut;
  15. use huoAccountDeal\controller\MemGameOut;
  16. use think\Lang;
  17. class AccountController extends V2ApiBaseController {
  18. public function _initialize() {
  19. parent::_initialize();
  20. $langSet = $this->request->langset();
  21. Lang::load([APP_PATH.'accountdeal'.DS.'lang'.DS.$langSet.DS.'account'.EXT,]);
  22. }
  23. /**
  24. * 小号交易首页
  25. * http://doc.huosdk.com/138?page_id=3434
  26. * 【域名】/account/deal/index
  27. */
  28. public function index() {
  29. $this->checkLogin();
  30. $_mem_id = $this->getMemId();
  31. $_rdata = (new AccountOut())->getHomeIndex($_mem_id);
  32. $this->returnData($_rdata);
  33. }
  34. /**
  35. * 卖号-游戏列表
  36. * http://doc.huosdk.com/138?page_id=3427
  37. * 【域名】/user/account/game/list
  38. */
  39. public function getMyGameList() {
  40. $this->checkLogin();
  41. $_page = $this->request->param('page/d', 1);
  42. $_offset = $this->request->param('offset/d', 10);
  43. $_page = $_page.','.$_offset;
  44. $_rdata = (new MemGameOut())->getMyGameList($this->mem_id, $_page);
  45. $this->returnData($_rdata);
  46. }
  47. /**
  48. * 卖号-小号列表
  49. * http://doc.huosdk.com/138?page_id=3428
  50. * 【域名】/user/account/list
  51. */
  52. public function getAccountList() {
  53. $this->checkLogin();
  54. $_app_id = $this->request->param('game_id/d', 0);
  55. $_page = $this->request->param('page/d', 1);
  56. $_offset = $this->request->param('offset/d', 10);
  57. $_page = $_page.','.$_offset;
  58. $_rdata = (new MemGameOut())->getAccountList($this->mem_id, $_app_id, $_page);
  59. $this->returnData($_rdata);
  60. }
  61. /**
  62. * 卖号-小号区服列表
  63. * http://doc.huosdk.com/138?page_id=3429
  64. * 【域名】/user/server/list
  65. */
  66. public function getServerList() {
  67. $this->checkLogin();
  68. $_mem_id = $this->getMemId();
  69. $_mg_mem_id = $this->request->param('mg_mem_id/d', 0);
  70. $_page = $this->request->param('page/d', 1);
  71. $_offset = $this->request->param('offset/d', 10);
  72. $_page = $_page.','.$_offset;
  73. $_rdata = (new MemGameOut())->getMgRoleList($_mem_id, $_mg_mem_id, $_page);
  74. $this->returnData($_rdata);
  75. }
  76. /**
  77. * 添加小号
  78. * http://doc.huosdk.com/138?page_id=3393
  79. * 【域名】/user/account/add
  80. */
  81. public function add() {
  82. $this->checkLogin();
  83. $_param = $this->request->param();
  84. $_result = $this->validate($_param, 'Account.add');
  85. if ($_result !== true) {
  86. $this->error($_result);
  87. }
  88. $_mem_id = $this->mem_id;
  89. $_app_id = $this->request->param('app_id/d');
  90. $_nickname = $this->request->param('nickname/s');
  91. $_rs = (new MemGameOut())->addAccount($_mem_id, $_app_id, $_nickname);
  92. $this->returnData($_rs);
  93. }
  94. /**
  95. * 切换小号
  96. * http://doc.huosdk.com/138?page_id=3394
  97. * 【域名】/user/account/change
  98. */
  99. public function change() {
  100. $this->checkLogin();
  101. $_param = $this->request->param();
  102. $_result = $this->validate($_param, 'Account.change');
  103. if ($_result !== true) {
  104. $this->error($_result);
  105. }
  106. $_mem_id = $this->mem_id;
  107. $_app_id = $this->request->param('app_id/d');
  108. $_account_id = $this->request->param('account_id/d', 0);
  109. $_rs = (new MemGameOut())->changeAccount($_mem_id, $_app_id, $_account_id);
  110. $this->returnData($_rs);
  111. }
  112. //
  113. //
  114. //
  115. // /**
  116. // * 小号列表
  117. // * http://doc.huosdk.com/138?page_id=3392
  118. // * 【域名】/user/account/list
  119. // */
  120. // public function getAccountList() {
  121. // $this->checkLogin();
  122. // $_param = $this->request->param();
  123. // $_result = $this->validate($_param, 'Account.list');
  124. // if ($_result !== true) {
  125. // $this->error($_result);
  126. // }
  127. // $_page = $this->request->param('page/d', 1); /* 页码 默认为1 代表第一页 1 */
  128. // $_offset = $this->request->param('offset/d', 10); /* 每页显示数量 默认为10 */
  129. // $_app_id = $this->request->param('app_id/d', 0);
  130. // $_page = $_page.','.$_offset;
  131. // $_account_list = (new MemGameOut())->getMemGameList($this->mem_id, $_app_id, $_page);
  132. // $this->returnData($_account_list);
  133. // }
  134. //
  135. //
  136. // /**
  137. // * 添加出售小号商品
  138. // * http://doc.huosdk.com/138?page_id=3430
  139. // * 【域名】/account/sell
  140. // */
  141. // public function sell() {
  142. // $this->checkLogin();
  143. // $_param = $this->request->param();
  144. // $_result = $this->validate($_param, 'Account.sell');
  145. // if ($_result !== true) {
  146. // $this->error($_result);
  147. // }
  148. // $_mem_id = $this->mem_id;
  149. // $_mg_role_id = $this->request->param('mg_role_id/d');
  150. // $_title = $this->request->param('title/s');
  151. // $_description = $this->request->param('description/s');
  152. // $_price = $this->request->param('price');
  153. // $_image = $this->request->param('image', '', 'htmlspecialchars_decode');
  154. // $_smscode = $this->request->param('sms-code');
  155. // $_rs = (new AccountOut())->sell($_mem_id, $_mg_role_id, $_title, $_description, $_price, $_image, $_smscode);
  156. // $this->returnData($_rs);
  157. // }
  158. //
  159. // /**
  160. // * 小号商品列表
  161. // * http://doc.huosdk.com/138?page_id=3426
  162. // * 【域名】/account/goods/list
  163. // */
  164. // public function getGoodsList() {
  165. // $_sort_type = $this->request->param('sort_type/d', 1);
  166. // $_app_id = $this->request->param('app_id/d', 0);
  167. // $_keyword = $this->request->param('keyword/s', '');
  168. // $_is_like = $this->request->param('is_like/d', 0); // TODO: luowei 2018/6/12 未实现筛选
  169. // $_status = $this->request->param('status/d', 0);
  170. // $_is_me_sell = $this->request->param('is_me_sell/d', 0);
  171. // $_page = $this->request->param('page/d', 1);
  172. // $_offset = $this->request->param('offset/d', 10);
  173. // $_where = [];
  174. // !empty($_keyword) && $_where['keyword'] = $_keyword;
  175. // !empty($_app_id) && $_where['app_id'] = $_app_id;
  176. // !empty($_status) && $_where['status'] = $_status;
  177. // ($_is_me_sell == 2) && $_where['mem_id'] = $this->mem_id;
  178. // $_rs = (new AccountOut())->goodsList($_where, $_sort_type, $_page.','.$_offset);
  179. // $this->returnData($_rs);
  180. // }
  181. //
  182. // /**
  183. // * 收藏/取消收藏小号商品
  184. // * http://doc.huosdk.com/138?page_id=3431
  185. // * 【域名】/account/like
  186. // */
  187. // public function like() {
  188. // $this->checkLogin();
  189. // $_param = $this->request->param();
  190. // $_result = $this->validate($_param, 'Account.like');
  191. // if ($_result !== true) {
  192. // $this->error($_result);
  193. // }
  194. // $_mem_id = $this->getMemId();
  195. // $_ags_id = $this->request->param('ags_id/d');
  196. // $_rs = (new AccountOut())->like($_mem_id, $_ags_id);
  197. // if ($_rs) {
  198. // $_code = CommonStatus::NO_ERROR;
  199. // $this->success(CommonStatus::getMsg($_code), [], $_code);
  200. // } else {
  201. // $_code = CommonStatus::INNER_ERROR;
  202. // $this->error(CommonStatus::getMsg($_code), [], $_code);
  203. // }
  204. // }
  205. //
  206. // /**
  207. // * 购买小号商品 + 预下单
  208. // * http://doc.huosdk.com/138?page_id=3435
  209. // * 【域名】/account/buy
  210. // */
  211. // public function buy() {
  212. // $_param = $this->request->param();
  213. // $_result = $this->validate($_param, 'Account.buy');
  214. // if ($_result !== true) {
  215. // $this->error($_result);
  216. // }
  217. // $this->checkLogin();
  218. // $_mem_id = $this->getMemId();
  219. // $_ags_id = $this->request->param('ags_id/d');
  220. // $_payway = $this->request->param('payway');
  221. // $_rdata = (new AccountOrder())->preorder($_mem_id, $_ags_id, $_payway);
  222. // if (CommonStatus::NO_ERROR != $_rdata['code']) {
  223. // $this->returnData($_rdata);
  224. // }
  225. // $_order_id = $_rdata['data']['order_id'];
  226. // $_amount = $_rdata['data']['amount'];
  227. // $_product_name = $_rdata['data']['product_name'];
  228. // $_product_desc = $_rdata['data']['product_desc'];
  229. // try {
  230. // $_pay_class = Pay::ins()->get($_payway);
  231. // $_func = $this->getFunc($this->device_type);
  232. // $_show_url = url('wapapp/'.$_payway.'/show', ['order_id' => $_order_id], false, APISITE);
  233. // $_return_url = url(
  234. // 'wapapp/'.$_payway.'/return', ['order_id' => $_order_id], false, APISITE
  235. // );
  236. // $_pay_class->setReturnUrl($_return_url);
  237. // $_pay_class->setShowUrl($_show_url);
  238. // $_pay_class->setOrderId($_order_id);
  239. // $_pay_class->setProductName($_product_name);
  240. // $_pay_class->setProductDesc($_product_desc);
  241. // $_pay_class->setRealAmount($_amount);
  242. // $_pay_class->setProductId(WalletConst::WALLET_PRODUCT_ACCOUNT);
  243. // $_pay_class->setIp($this->request->ip());
  244. // $_pay_class->setOpenId(HuoSession::getOpenId());
  245. // $_pay_rs = $_pay_class->$_func();
  246. // if (empty($_pay_rs)) {
  247. // $_code = OrderStatus::PAYWAY_PREORDER_ERROR;
  248. // $this->error(OrderStatus::getMsg($_code), [], $_code);
  249. // }
  250. // $_code = OrderStatus::NO_ERROR;
  251. // $this->success(OrderStatus::getMsg($_code), $_pay_rs, $_code);
  252. // } catch (Exception $e) {
  253. // $_code = OrderStatus::PAYWAY_NOT_EXISTS;
  254. // $this->error(OrderStatus::getMsg($_code), [], $_code);
  255. // }
  256. // }
  257. //
  258. // /**
  259. // * 取消购买订单
  260. // * http://doc.huosdk.com/138?page_id=3550
  261. // * 【域名】/order/cancel
  262. // */
  263. // public function cancelOrder() {
  264. // $_param = $this->request->param();
  265. // $_result = $this->validate($_param, 'Account.cancelOrder');
  266. // if ($_result !== true) {
  267. // $this->error($_result);
  268. // }
  269. // $this->checkLogin();
  270. // $_mem_id = $this->getMemId();
  271. // $_order_id = $this->request->param('order_id');
  272. // $_rs = (new AccountOrder())->cancel($_mem_id, $_order_id);
  273. // $this->returnData($_rs);
  274. // }
  275. //
  276. // /**
  277. // * 玩家小号商品交易订单列表
  278. // * http://doc.huosdk.com/138?page_id=3433
  279. // * 【域名】/user/order/list
  280. // */
  281. // public function orderList() {
  282. // $_status = $this->request->param('status/d', 0);
  283. // $_page = $this->request->param('page/d', 1);
  284. // $_offset = $this->request->param('offset/d', 10);
  285. // $_map = ['buy_mem_id' => $this->getMemId()];
  286. // !empty($_status) && $_map['status'] = $_status;
  287. // $_rs = (new AccountOrder())->getOrderList($_map, $_page.','.$_offset);
  288. // $this->returnData($_rs);
  289. // }
  290. //
  291. // /**
  292. // * 小号区服列表
  293. // * http://doc.huosdk.com/138?page_id=3429
  294. // * 【域名】/account/role_server/list
  295. // */
  296. // public function serverList() {
  297. // $_param = $this->request->param();
  298. // $_result = $this->validate($_param, 'Account.serverList');
  299. // if ($_result !== true) {
  300. // $this->error($_result);
  301. // }
  302. // $_page = $this->request->param('page/d', 1);
  303. // $_offset = $this->request->param('offset/d', 10);
  304. // $_account_id = $this->request->param('account_id/d');
  305. // $_page = $_page.','.$_offset;
  306. // $_mem_id = $this->getMemId();
  307. // $_data = (new AccountLogic())->getMgServerList($_mem_id, $_account_id, $_page);
  308. // if (is_numeric($_data)) {
  309. // $this->error(AccountStatus::getMsg($_data), [], $_data);
  310. // }
  311. // $_code = CommonStatus::NO_ERROR;
  312. // $this->success(CommonStatus::getMsg($_code), $_data, $_code);
  313. // }
  314. //
  315. // /**
  316. // * 小号游戏列表
  317. // * http://doc.huosdk.com/138?page_id=3427
  318. // * 【域名】/account/game/list
  319. // */
  320. // public function gameList() {
  321. // $_page = $this->request->param('page/d', 1);
  322. // $_offset = $this->request->param('offset/d', 10);
  323. // $_page = $_page.','.$_offset;
  324. // $_mem_id = $this->getMemId();
  325. // $_data = (new MemGameLogic())->getMgAccountList($_mem_id, $_page);
  326. // $_code = CommonStatus::NO_ERROR;
  327. // $this->success(CommonStatus::getMsg($_code), $_data, $_code);
  328. // }
  329. //
  330. // /**
  331. // * 游戏的小号列表
  332. // * http://doc.huosdk.com/138?page_id=3428
  333. // * 【域名】/game/account/list
  334. // */
  335. // public function gameAccountList() {
  336. // $this->checkLogin();
  337. // $_param = $this->request->param();
  338. // $_result = $this->validate($_param, 'Account.gameAccountList');
  339. // if ($_result !== true) {
  340. // $this->error($_result);
  341. // }
  342. // $_page = $this->request->param('page/d', 1); /* 页码 默认为1 代表第一页 1 */
  343. // $_offset = $this->request->param('offset/d', 10); /* 每页显示数量 默认为10 */
  344. // $_app_id = $this->request->param('game_id/d');
  345. // $_page = $_page.','.$_offset;
  346. // $_account_list = (new MemGame())->getMemGameList($this->mem_id, $_app_id, $_page);
  347. // $this->returnData($_account_list);
  348. // }
  349. //
  350. // /**
  351. // * 出售账号玩过游戏列表
  352. // * http://doc.huosdk.com/138?page_id=3543
  353. // * 【域名】/account/goods/game/list
  354. // */
  355. // public function sellListByMyGame() {
  356. // $this->checkLogin();
  357. // $_page = $this->request->param('page/d', 1); /* 页码 默认为1 代表第一页 1 */
  358. // $_offset = $this->request->param('offset/d', 10); /* 每页显示数量 默认为10 */
  359. // $_page = $_page.','.$_offset;
  360. // $_account_list = (new AccountLogic())->getMgSellAccountList($this->mem_id, $_page);
  361. // $_code = CommonStatus::NO_ERROR;
  362. // $this->success(CommonStatus::getMsg($_code), $_account_list, $_code);
  363. // }
  364. //
  365. //
  366. }