DemoController.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request as Req;
  5. use Request;
  6. /**
  7. *
  8. */
  9. class DemoController extends Controller {
  10. function index() {
  11. # code...
  12. }
  13. /**
  14. * 试玩用户列表
  15. * [demos description]
  16. * @return [type] [description]
  17. */
  18. function demos(Req $req) {
  19. $request=array();
  20. $request['account']=isset($req->account)?trim($req->account):null;
  21. $request['register_ip'] = isset($req->register_ip) ? trim($req->register_ip) : null;
  22. $request['last_ip'] = isset($req->last_ip) ? trim($req->last_ip) : null;
  23. $request['register_url'] = isset($req->register_url) ? trim($req->register_url) : null;
  24. $request['last_url'] = isset($req->last_url) ? trim($req->last_url) : null;
  25. $request['statuss'] = isset($req->statuss) ? trim($req->statuss) : null;
  26. $request['cash_small'] = isset($req->cash_small) ? trim($req->cash_small) : null;
  27. $request['cash_big'] = isset($req->cash_big) ? trim($req->cash_big) : null;
  28. $dt = \App\Lib\DataTable\DataTable::init();
  29. $dt->setDataSource('/admin/demo/demo');
  30. $dt->setLang('demo');
  31. $dt->addColsFields('id', array('width' => 80));
  32. $dt->addColsFields('account', array('templet' => '#userdetail', 'width' => 120));
  33. $dt->addColsFields('register_time', array('width' => 180));
  34. $dt->addColsFields('cash', array('templet' => '#moneyrecord', 'width' => 110));
  35. $dt->addColsFields('register_log_ip', array('templet' => '#selectip', 'width' => 150, 'sort' => false));
  36. $dt->addColsFields('register_log_url', array('templet' => '#selecturl', 'sort' => false));
  37. $dt->addColsFields('statuss', array('width' => 100, 'sort' => false));
  38. $dt->addColsFields('action_user', array('templet' => '#waterTool', 'sort' => false,'width' => 110));
  39. $dt->setPriKey('id');
  40. return view('admin.demo/demos', $dt->render($request));
  41. }
  42. /**
  43. * 注册ip列表
  44. * [detail description]
  45. * @return [type] [description]
  46. */
  47. function registipDetail() {
  48. $register_ip = Request::has('register_ip') ? Request::get('register_ip') : '';
  49. $dt = \App\Lib\DataTable\DataTable::init();
  50. $dt->setDataSource('/admin/demo/demo?register_ip=' . $register_ip);
  51. $dt->setLang('demo');
  52. $dt->addColsFields('id');
  53. $dt->addColsFields('account');
  54. $dt->addColsFields('register_time');
  55. $dt->addColsFields('cash');
  56. $dt->addColsFields('register_log_ip', array('sort' => false));
  57. $dt->addColsFields('register_log_url', array('sort' => false));
  58. $dt->addColsFields('statuss', array('sort' => false));
  59. $dt->setPriKey('id');
  60. $dt->setToolBar(array('view'));
  61. return view('admin.user/viewip', $dt->render());
  62. }
  63. /**
  64. * 最后登录ip列表
  65. * [detail description]
  66. * @return [type] [description]
  67. */
  68. function lastipDetail() {
  69. $last_ip = Request::has('last_ip') ? Request::get('last_ip') : '';
  70. $dt = \App\Lib\DataTable\DataTable::init();
  71. $dt->setDataSource('/admin/demo/demo?last_ip=' . $last_ip);
  72. $dt->setLang('demo');
  73. $dt->addColsFields('id');
  74. $dt->addColsFields('account');
  75. $dt->addColsFields('register_time');
  76. $dt->addColsFields('cash');
  77. $dt->addColsFields('register_log_ip', array('sort' => false));
  78. $dt->addColsFields('register_log_url', array('sort' => false));
  79. $dt->addColsFields('statuss', array('sort' => false));
  80. $dt->setToolBar(array('view'));
  81. $dt->setPriKey('id');
  82. return view('admin.user/viewip', $dt->render());
  83. }
  84. /**
  85. * 注册网址列表
  86. * [detail description]
  87. * @return [type] [description]
  88. */
  89. function registurlDetail() {
  90. $register_url = Request::has('register_url') ? Request::get('register_url') : '';
  91. $dt = \App\Lib\DataTable\DataTable::init();
  92. $dt->setDataSource('/admin/demo/demo?register_url=' . $register_url);
  93. $dt->setLang('demo');
  94. $dt->addColsFields('id');
  95. $dt->addColsFields('account');
  96. $dt->addColsFields('register_time');
  97. $dt->addColsFields('cash');
  98. $dt->addColsFields('register_log_ip', array('sort' => false));
  99. $dt->addColsFields('register_log_url', array('sort' => false));
  100. $dt->addColsFields('statuss', array('sort' => false));
  101. $dt->setPriKey('id');
  102. $dt->setToolBar(array('view'));
  103. return view('admin.user/viewip', $dt->render());
  104. }
  105. /**
  106. * 最后登录网址列表
  107. * [detail description]
  108. * @return [type] [description]
  109. */
  110. function lasturlDetail() {
  111. $last_url = Request::has('last_url') ? Request::get('last_url') : '';
  112. $dt = \App\Lib\DataTable\DataTable::init();
  113. $dt->setDataSource('/admin/demo/demo?last_url=' . $last_url);
  114. $dt->setLang('demo');
  115. $dt->addColsFields('id');
  116. $dt->addColsFields('account');
  117. $dt->addColsFields('register_time');
  118. $dt->addColsFields('cash');
  119. $dt->addColsFields('register_log_ip', array('sort' => false));
  120. $dt->addColsFields('register_log_url', array('sort' => false));
  121. $dt->addColsFields('statuss', array('sort' => false));
  122. $dt->setPriKey('id');
  123. $dt->setToolBar(array('view'));
  124. return view('admin.user/viewip', $dt->render());
  125. }
  126. /**
  127. * 试玩列表
  128. * 'demo description'
  129. * @return 'type' 'description'
  130. */
  131. function demo() {
  132. $page = Request::has('page') ? Request::get('page') : '';
  133. $list = Request::has('limit') ? Request::get('limit') : 10;
  134. $account = Request::has('account') ? Request::get('account') : '';
  135. $register_ip = Request::has('register_ip') ? Request::get('register_ip') : '';
  136. $last_ip = Request::has('last_ip') ? Request::get('last_ip') : '';
  137. $regist_startime = Request::get('regist_startime') ? Request::get('regist_startime').' 00:00:00' : '';
  138. $regist_endtime = Request::get('regist_endtime') ? Request::get('regist_endtime').' 23:59:59' : '';
  139. $statuss = Request::has('statuss') ? Request::get('statuss') : '';
  140. $cash_small = Request::has('cash_small') ? Request::get('cash_small') : '';
  141. $cash_big = Request::has('cash_big') ? Request::get('cash_big') : '';
  142. $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
  143. $where = array();
  144. if (!empty($account)) {
  145. if (empty($sureblur) || $sureblur == '模糊') {
  146. $where[] = array('account', 'like', '%' . $account . '%');
  147. } else {
  148. $where[] = array('account', '=', $account);
  149. }
  150. }
  151. if (!empty($register_ip)) {
  152. $where[] = array('register_ip', '=', $register_ip);
  153. }
  154. if (!empty($last_ip)) {
  155. $where[] = array('last_ip', '=', $last_ip);
  156. }
  157. if (!empty($regist_startime)) {
  158. $regist_startime = date('Y-m-d H:i:s', strtotime($regist_startime));
  159. $where[] = array('register_time', '>=', $regist_startime);
  160. }
  161. if (!empty($regist_endtime)) {
  162. $regist_endtime = date('Y-m-d H:i:s', strtotime($regist_endtime));
  163. $where[] = array('register_time', '<=', $regist_endtime);
  164. }
  165. if (!empty($statuss)) {
  166. $where[] = array('statuss', '=', $statuss);
  167. }
  168. if (!empty($cash_small)) {
  169. $where[] = array('cash', '>=', $cash_small);
  170. }
  171. if (!empty($cash_big)) {
  172. $where[] = array('cash', '<=', $cash_big);
  173. }
  174. $db = new \App\Models\Account;
  175. $data = $db->demo_account($list, $page, $where);
  176. if (!($data < 0)&&is_array($data)&&count($data)>0&&is_array($data['data'])&&count($data['data'])>0) {
  177. $langinfo = trans('status.account_detailed.statuss');
  178. foreach ($data['data'] as $k => $v) {
  179. $data['data'][$k]['statuss'] = ($v['statuss']==0)?$langinfo[2]:$langinfo[$v['statuss']];
  180. $data['data'][$k]['register_url'] = (empty($v['register_url'])) ? '' : $v['register_url'];
  181. $data['data'][$k]['last_url'] = (empty($v['last_url'])) ? '' : $v['last_url'];
  182. $data['data'][$k]['register_log_ip'] = $v['register_ip'] . '<br>' . $v['last_ip'];
  183. }
  184. }
  185. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
  186. }
  187. /**
  188. * 批量删除
  189. * [delete description]
  190. * @return [type] [description]
  191. */
  192. function delete(Req $req) {
  193. $id = $req->input('id');
  194. if (empty($id)) {
  195. return responseToJson(-2001); //id������
  196. }
  197. $ids = explode(',', $id);
  198. if (!is_array($ids) && intval($ids) < 0) {
  199. return responseToJson(-2002); //id����
  200. }
  201. if (is_array($ids) && count($ids) > 0) {
  202. foreach ($ids as $k => $v) {
  203. if (intval($v) < 1) {
  204. unset($ids[$k]);
  205. }
  206. }
  207. }
  208. $rows = \App\Models\Account::whereIn('id', $ids)->delete();
  209. if (!$rows) {
  210. return responseToJson(-2003); //id����
  211. }
  212. return responseToJson(1, trans('menu.delete_success')); //id����
  213. }
  214. function View(Req $req) {
  215. // $this->Edit($req);
  216. $id = $req->id;
  217. if (empty($id)) {
  218. abort(404);
  219. }
  220. $u_db = new \App\Models\Account();
  221. $u_details = new \App\Models\Account_detailed();
  222. $bank = new \App\Models\Account_bank();
  223. $data = $u_db::where('id', $id)->first();
  224. if (!$data) {
  225. abort(404);
  226. }
  227. $data = $data->toArray();
  228. $data_details = $u_details->getInfoBy($data['identity']);
  229. $data_details['account'] = $data['account'];
  230. $data_details['remark'] = $data['remark'];
  231. $bank_data = $bank->getInfoByUid($data['identity']);
  232. $data_details['bank_name'] = isset($bank_data['bank_name']) ? $bank_data['bank_name'] : '';
  233. $data_details['bank_address'] = isset($bank_data['bank_address']) ? $bank_data['bank_address'] : '';
  234. $data_details['bank_number'] = isset($bank_data['bank_number']) ? $bank_data['bank_number'] : '';
  235. unset($data_details['password']);
  236. return view('admin.menu/userAdd', ['data' => $data_details, 'look' => '12']);
  237. }
  238. //修改会员信息
  239. function Edit(Req $req) {
  240. $id = $req->id;
  241. if (empty($id)) {
  242. abort(404);
  243. }
  244. $u_db = new \App\Models\Account();
  245. $u_details = new \App\Models\Account_detailed();
  246. $bank = new \App\Models\Account_bank();
  247. if (!$req->isMethod('post')) {
  248. $data = $u_db::where('id', $id)->first();
  249. if (!$data) {
  250. abort(404);
  251. }
  252. $data = $data->toArray();
  253. $data_details = $u_details->getInfoBy($data['identity']);
  254. $data_details['account'] = $data['account'];
  255. $data_details['remark'] = $data['remark'];
  256. $bank_data = $bank->getInfoByUid($data['identity']);
  257. $data_details['bank_name'] = isset($bank_data['bank_name']) ? $bank_data['bank_name'] : '';
  258. $data_details['bank_address'] = isset($bank_data['bank_address']) ? $bank_data['bank_address'] : '';
  259. $data_details['bank_number'] = isset($bank_data['bank_number']) ? $bank_data['bank_number'] : '';
  260. unset($data_details['password']);
  261. return view('admin.menu/userAdd', ['data' => $data_details]);
  262. } else {
  263. $account = $u_db::where('id', $id)->first();
  264. if (!$account) {
  265. abort(404);
  266. }
  267. $account = $account->toArray();
  268. $data = array(
  269. 'name' => $req->input('name'),
  270. 'email' => $req->input('email'),
  271. 'phone' => $req->input('phone'),
  272. 'grade' => $req->input('grade'),
  273. );
  274. $res = $u_details->updateInfo($data, $account['identity']);
  275. return responseToJson(1);
  276. }
  277. }
  278. function demoAdd() {
  279. return view('admin.menu/demoAdd');
  280. }
  281. }