TradeController.class.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. <?php
  2. namespace Admin\Controller;
  3. class TradeController extends AdminController
  4. {
  5. protected function _initialize(){
  6. parent::_initialize();
  7. $allow_action=array("index","sethy","hylog","market","marketEdit","marketStatus","tradeclear","orderinfo","orderinfo_ty","setwinloss_ty","setwinloss","bbsetting","bbxjlist","bbsjlist","gethyorder","settzstatus","tyorder","getmyzrytz","getmyzrtz");
  8. if(!in_array(ACTION_NAME,$allow_action)){
  9. $this->error("页面不存在!");
  10. }
  11. }
  12. //设置已通知
  13. public function settzstatus(){
  14. $where['status'] = 1;
  15. $where['tznum'] = 0;
  16. $list = M("hyorder")->where($where)->field('id')->select();
  17. if(!empty($list)){
  18. foreach($list as $key=>$vo){
  19. $id = $vo['id'];
  20. M("hyorder")->where(array('id'=>$id))->save(array('tznum'=>1));
  21. }
  22. $this->ajaxReturn(['code'=>1]);
  23. }
  24. }
  25. //设置充值已通知
  26. public function getmyzrytz(){
  27. $where['status'] = 1;
  28. $where['tznum'] = 0;
  29. $list = M("recharge")->where($where)->field('id')->select();
  30. if(!empty($list)){
  31. foreach($list as $key=>$vo){
  32. $id = $vo['id'];
  33. M("recharge")->where(array('id'=>$id))->save(array('tznum'=>1));
  34. }
  35. $this->ajaxReturn(['code'=>1]);
  36. }
  37. }
  38. //充币通知
  39. public function getmyzrtz(){
  40. $where['status'] = 1;
  41. $where['tznm'] = 0;
  42. $count = M('recharge')->where($where)->count();
  43. $list = M("recharge")->where($where)->field('id')->select();
  44. if(!empty($list)){
  45. foreach($list as $key=>$vo){
  46. $whs['id'] = $vo['id'];
  47. $data['tznm'] = 1;
  48. M("recharge")->where($whs)->save($data);
  49. }
  50. $this->ajaxReturn(['code'=>1]);
  51. }
  52. }
  53. public function gethyorder(){
  54. $where['status'] = 1;
  55. $where['tznum'] = 0;
  56. $count = M("hyorder")->where($where)->count();
  57. if($count > 0){
  58. $this->ajaxReturn(['code'=>1]);
  59. }
  60. }
  61. //币币交易市价交易记录
  62. public function bbsjlist(){
  63. if(I('get.type') > 0){
  64. $hyzd = trim(I('get.type'));
  65. $where['type'] = $hyzd;
  66. }
  67. if(I('get.status') > 0){
  68. $status = trim(I('get.status'));
  69. $where['status'] = $status;
  70. }
  71. if(I('get.username') > 0){
  72. $username = trim(I('get.username'));
  73. $where['account'] = $username;
  74. }
  75. $where['ordertype'] = 2;
  76. $count = M('bborder')->where($where)->count();
  77. $Page = new \Think\Page($count, 15);
  78. $show = $Page->show();
  79. $list = M('bborder')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  80. $this->assign('list', $list);
  81. $this->assign('page', $show);
  82. $this->display();
  83. }
  84. //币币交易限价委托记录
  85. public function bbxjlist(){
  86. if(I('get.type') > 0){
  87. $hyzd = trim(I('get.type'));
  88. $where['type'] = $hyzd;
  89. }
  90. if(I('get.status') > 0){
  91. $status = trim(I('get.status'));
  92. $where['status'] = $status;
  93. }
  94. if(I('get.username') > 0){
  95. $username = trim(I('get.username'));
  96. $where['account'] = $username;
  97. }
  98. $where['ordertype'] = 1;
  99. $count = M('bborder')->where($where)->count();
  100. $Page = new \Think\Page($count, 15);
  101. $show = $Page->show();
  102. $list = M('bborder')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  103. $this->assign('list', $list);
  104. $this->assign('page', $show);
  105. $this->display();
  106. }
  107. //币币交易参数设置
  108. public function bbsetting(){
  109. if($_POST){
  110. $id = trim($_POST['bbid']);
  111. if($id <= 0){
  112. $result = M("bbsetting")->add($_POST);
  113. }else{
  114. unset($_POST['bbid']);
  115. $result = M("bbsetting")->where(array('id'=>$id))->save($_POST);
  116. }
  117. if($result){
  118. $this->success("操作成功!",U('Trade/bbsetting'));
  119. }else{
  120. $this->error("操作失败!",U('Trade/bbsetting'));
  121. }
  122. }else{
  123. $info = M("bbsetting")->where(array('id'=>1))->find();
  124. $this->assign("info",$info);
  125. $this->display();
  126. }
  127. }
  128. //单控盈亏
  129. public function setwinloss(){
  130. if($_POST){
  131. $id = trim(I('post.id'));
  132. $kongyk = trim(I('post.kongyk'));
  133. $info = M("hyorder")->where(array('id'=>$id))->find();
  134. if(empty($info)){
  135. $this->ajaxReturn(['code'=>0,'info'=>"参少重要参数"]);
  136. }
  137. $result = M("hyorder")->where(array('id'=>$id))->save(array('kongyk'=>$kongyk));
  138. if($result){
  139. $this->ajaxReturn(['code'=>1,'info'=>"操作成功"]);
  140. }else{
  141. $this->ajaxReturn(['code'=>0,'info'=>"操作失败"]);
  142. }
  143. }else{
  144. $this->ajaxReturn(['code'=>0,'info'=>"网络错误"]);
  145. }
  146. }
  147. //单控盈亏
  148. public function setwinloss_ty(){
  149. if($_POST){
  150. $id = trim(I('post.id'));
  151. $kongyk = trim(I('post.kongyk'));
  152. $info = M("tyhyorder")->where(array('id'=>$id))->find();
  153. if(empty($info)){
  154. $this->ajaxReturn(['code'=>0,'info'=>"参少重要参数"]);
  155. }
  156. $result = M("tyhyorder")->where(array('id'=>$id))->save(array('kongyk'=>$kongyk));
  157. if($result){
  158. $this->ajaxReturn(['code'=>1,'info'=>"操作成功"]);
  159. }else{
  160. $this->ajaxReturn(['code'=>0,'info'=>"操作失败"]);
  161. }
  162. }else{
  163. $this->ajaxReturn(['code'=>0,'info'=>"网络错误"]);
  164. }
  165. }
  166. //合约订单详情
  167. public function orderinfo(){
  168. $id = trim(I('get.id'));
  169. $info = M("hyorder")->where(array("id"=>$id))->find();
  170. $this->assign('info',$info);
  171. $this->display();
  172. }
  173. //合约订单详情
  174. public function orderinfo_ty(){
  175. $id = trim(I('get.id'));
  176. $info = M("tyhyorder")->where(array("id"=>$id))->find();
  177. $this->assign('info',$info);
  178. $this->display();
  179. }
  180. //快速合约参数设置
  181. public function sethy(){
  182. if($_POST){
  183. $id = trim($_POST['hy_id']);
  184. if($id <= 0){
  185. $result = M("hysetting")->add($_POST);
  186. }else{
  187. unset($_POST['hy_id']);
  188. $result = M("hysetting")->where(array('id'=>$id))->save($_POST);
  189. }
  190. if($result){
  191. $this->success("操作成功!",U('Trade/sethy'));
  192. }else{
  193. $this->error("操作失败!",U('Trade/sethy'));
  194. }
  195. }else{
  196. $info = M("hysetting")->where(array('id'=>1))->find();
  197. $this->assign("info",$info);
  198. $this->display();
  199. }
  200. }
  201. //体验订单记灵
  202. public function tyorder(){
  203. $where = array();
  204. if(I('get.username') != '' || I('get.username') != null){
  205. $username = trim(I('get.username'));
  206. $where['username'] = $username;
  207. }
  208. if(I('get.hyzd') > 0){
  209. $hyzd = trim(I('get.hyzd'));
  210. $where['hyzd'] = $hyzd;
  211. }
  212. $count = M('tyhyorder')->where($where)->count();
  213. $Page = new \Think\Page($count, 15);
  214. $show = $Page->show();
  215. $list = M('tyhyorder')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  216. $this->assign('list', $list);
  217. $this->assign('page', $show);
  218. $this->display();
  219. }
  220. //合约购买记录(未平仓的)
  221. public function index(){
  222. $where = array();
  223. if(I('get.username') != '' || I('get.username') != null){
  224. $username = trim(I('get.username'));
  225. $where['username'] = $username;
  226. }
  227. if(I('get.hyzd') > 0){
  228. $hyzd = trim(I('get.hyzd'));
  229. $where['hyzd'] = $hyzd;
  230. }
  231. $where['status'] = 1;
  232. $count = M('hyorder')->where($where)->count();
  233. $Page = new \Think\Page($count, 15);
  234. $show = $Page->show();
  235. $list = M('hyorder')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  236. $this->assign('list', $list);
  237. $this->assign('page', $show);
  238. $this->display();
  239. }
  240. //合约交易平仓记录
  241. public function hylog($invit=null){
  242. if($invit != ''){
  243. $where['username'] = ['like',"%{$invit}%"];
  244. }
  245. $where['status'] = 2;
  246. $count = M('hyorder')->where($where)->count();
  247. $Page = new \Think\Page($count, 15);
  248. $show = $Page->show();
  249. $list = M('hyorder')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  250. $this->assign('list', $list);
  251. $this->assign('page', $show);
  252. $this->display();
  253. }
  254. ///机器人刷单币种列表
  255. public function market($field = NULL, $name = NULL)
  256. {
  257. $where = array();
  258. if ($field && $name) {
  259. if ($field == 'username') {
  260. $where['userid'] = M('User')->where(array('username' => $name))->getField('id');
  261. }
  262. else {
  263. $where[$field] = $name;
  264. }
  265. }
  266. $count = M('Market')->where($where)->count();
  267. $Page = new \Think\Page($count, 15);
  268. $show = $Page->show();
  269. $list = M('Market')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  270. $this->assign('list', $list);
  271. $this->assign('page', $show);
  272. $this->display();
  273. }
  274. //编辑刷单
  275. public function marketEdit($id = NULL)
  276. {
  277. $getCoreConfig = getCoreConfig();
  278. if(!$getCoreConfig){
  279. $this->error('核心配置有误');
  280. }
  281. if (empty($_POST)) {
  282. if (empty($id)) {
  283. $this->data = array();
  284. }
  285. else {
  286. $this->data = M('Market')->where(array('id' => $id))->find();
  287. }
  288. $coin['coin'] = M('coin')->select();
  289. $time_arr = array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23');
  290. $time_minute = array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59');
  291. $this->assign('time_arr', $time_arr);
  292. $this->assign('C', $coin);
  293. $this->assign('time_minute', $time_minute);
  294. $this->assign('getCoreConfig',$getCoreConfig['indexcat']);
  295. $this->display();
  296. }
  297. else {
  298. if (APP_DEMO) {
  299. $this->error('测试站暂时不能修改!');
  300. }
  301. $round = array(0, 1, 2, 3, 4, 5, 6);
  302. if (!in_array($_POST['round'], $round)) {
  303. $this->error('小数位数格式错误!');
  304. }
  305. if ($_POST['id']) {
  306. $rs = M('Market')->save($_POST);
  307. }
  308. else {
  309. $_POST['name'] = $_POST['sellname'] . '_' . $_POST['buyname'];
  310. $_POST['new_price'] = $_POST['faxingjia'];
  311. unset($_POST['buyname']);
  312. unset($_POST['sellname']);
  313. if (M('Market')->where(array('name' => $_POST['name']))->find()) {
  314. $this->error('市场存在!');
  315. }
  316. $rs = M('Market')->add($_POST);
  317. }
  318. if ($rs) {
  319. $this->success('操作成功!');
  320. }
  321. else {
  322. $this->error('操作失败!');
  323. }
  324. }
  325. }
  326. public function marketStatus($id = NULL, $type = NULL, $mobile = 'Market')
  327. {
  328. if (APP_DEMO) {
  329. $this->error('测试站暂时不能修改!');
  330. }
  331. if (empty($id)) {
  332. $this->error('参数错误!');
  333. }
  334. if (empty($type)) {
  335. $this->error('参数错误1!');
  336. }
  337. if (strpos(',', $id)) {
  338. $id = implode(',', $id);
  339. }
  340. $where['id'] = array('in', $id);
  341. switch (strtolower($type)) {
  342. case 'forbid':
  343. $data = array('status' => 0);
  344. break;
  345. case 'resume':
  346. $data = array('status' => 1);
  347. break;
  348. case 'repeal':
  349. $data = array('status' => 2, 'endtime' => time());
  350. break;
  351. case 'delete':
  352. $data = array('status' => -1);
  353. break;
  354. case 'del':
  355. if (M($mobile)->where($where)->delete()) {
  356. $this->success('操作成功!');
  357. }
  358. else {
  359. $this->error('操作失败!');
  360. }
  361. break;
  362. default:
  363. $this->error('操作失败!');
  364. }
  365. if (M($mobile)->where($where)->save($data)) {
  366. $this->success('操作成功!');
  367. }
  368. else {
  369. $this->error('操作失败!');
  370. }
  371. }
  372. public function tradeclear($type=NULL,$id=NULL)
  373. {
  374. if(!$id){
  375. $this->error('请选择交易市场!');
  376. }
  377. if(!$type){
  378. $this->error('请选择清理类型!');
  379. }
  380. $market= M('Market')->where(array('id' => $id))->find();
  381. if($type==1){
  382. $allclear=M('Trade')->where(array('market'=>$market['name'],'userid'=>0))->delete();
  383. }
  384. if($type==2){
  385. if(!$market['sdhigh'] or !$market['sdlow']){
  386. $this->error('该市场未设置刷单最高价或最低价,无法部分清理');
  387. }
  388. $map['market']=$market['name'];
  389. $map['userid']=0;
  390. $map['price']=array('notbetween',array($market['sdhigh'],$market['sdlow']));
  391. $allclear=M('Trade')->where($map)->delete();
  392. }
  393. if($allclear){
  394. $this->success('清理成功,一共'.$allclear.'条刷单记录');
  395. }else{
  396. $this->error('清理失败!');
  397. }
  398. }
  399. }
  400. ?>