123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 |
- <?php
- namespace Admin\Controller;
- class TradeController extends AdminController
- {
-
- protected function _initialize(){
- parent::_initialize();
- $allow_action=array("index","sethy","hylog","market","marketEdit","marketStatus","tradeclear","orderinfo","orderinfo_ty","setwinloss_ty","setwinloss","bbsetting","bbxjlist","bbsjlist","gethyorder","settzstatus","tyorder","getmyzrytz","getmyzrtz");
- if(!in_array(ACTION_NAME,$allow_action)){
- $this->error("页面不存在!");
- }
- }
-
- //设置已通知
- public function settzstatus(){
- $where['status'] = 1;
- $where['tznum'] = 0;
- $list = M("hyorder")->where($where)->field('id')->select();
- if(!empty($list)){
- foreach($list as $key=>$vo){
- $id = $vo['id'];
- M("hyorder")->where(array('id'=>$id))->save(array('tznum'=>1));
- }
- $this->ajaxReturn(['code'=>1]);
- }
-
- }
- //设置充值已通知
- public function getmyzrytz(){
- $where['status'] = 1;
- $where['tznum'] = 0;
- $list = M("recharge")->where($where)->field('id')->select();
- if(!empty($list)){
- foreach($list as $key=>$vo){
- $id = $vo['id'];
- M("recharge")->where(array('id'=>$id))->save(array('tznum'=>1));
- }
- $this->ajaxReturn(['code'=>1]);
- }
-
- }
- //充币通知
- public function getmyzrtz(){
- $where['status'] = 1;
- $where['tznm'] = 0;
- $count = M('recharge')->where($where)->count();
- $list = M("recharge")->where($where)->field('id')->select();
- if(!empty($list)){
- foreach($list as $key=>$vo){
-
- $whs['id'] = $vo['id'];
- $data['tznm'] = 1;
- M("recharge")->where($whs)->save($data);
- }
- $this->ajaxReturn(['code'=>1]);
- }
-
- }
- public function gethyorder(){
- $where['status'] = 1;
- $where['tznum'] = 0;
- $count = M("hyorder")->where($where)->count();
- if($count > 0){
- $this->ajaxReturn(['code'=>1]);
- }
- }
-
- //币币交易市价交易记录
- public function bbsjlist(){
- if(I('get.type') > 0){
- $hyzd = trim(I('get.type'));
- $where['type'] = $hyzd;
- }
-
- if(I('get.status') > 0){
- $status = trim(I('get.status'));
- $where['status'] = $status;
- }
-
- if(I('get.username') > 0){
- $username = trim(I('get.username'));
- $where['account'] = $username;
- }
-
-
-
-
- $where['ordertype'] = 2;
- $count = M('bborder')->where($where)->count();
- $Page = new \Think\Page($count, 15);
- $show = $Page->show();
- $list = M('bborder')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
- $this->assign('list', $list);
- $this->assign('page', $show);
- $this->display();
- }
-
- //币币交易限价委托记录
- public function bbxjlist(){
-
- if(I('get.type') > 0){
- $hyzd = trim(I('get.type'));
- $where['type'] = $hyzd;
- }
-
- if(I('get.status') > 0){
- $status = trim(I('get.status'));
- $where['status'] = $status;
- }
-
- if(I('get.username') > 0){
- $username = trim(I('get.username'));
- $where['account'] = $username;
- }
-
-
-
-
- $where['ordertype'] = 1;
- $count = M('bborder')->where($where)->count();
- $Page = new \Think\Page($count, 15);
- $show = $Page->show();
- $list = M('bborder')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
- $this->assign('list', $list);
- $this->assign('page', $show);
-
- $this->display();
- }
-
-
- //币币交易参数设置
- public function bbsetting(){
- if($_POST){
- $id = trim($_POST['bbid']);
- if($id <= 0){
- $result = M("bbsetting")->add($_POST);
- }else{
- unset($_POST['bbid']);
- $result = M("bbsetting")->where(array('id'=>$id))->save($_POST);
- }
- if($result){
- $this->success("操作成功!",U('Trade/bbsetting'));
- }else{
- $this->error("操作失败!",U('Trade/bbsetting'));
- }
-
- }else{
-
- $info = M("bbsetting")->where(array('id'=>1))->find();
- $this->assign("info",$info);
- $this->display();
- }
-
- }
-
- //单控盈亏
- public function setwinloss(){
- if($_POST){
- $id = trim(I('post.id'));
- $kongyk = trim(I('post.kongyk'));
- $info = M("hyorder")->where(array('id'=>$id))->find();
- if(empty($info)){
- $this->ajaxReturn(['code'=>0,'info'=>"参少重要参数"]);
- }
- $result = M("hyorder")->where(array('id'=>$id))->save(array('kongyk'=>$kongyk));
- if($result){
- $this->ajaxReturn(['code'=>1,'info'=>"操作成功"]);
- }else{
- $this->ajaxReturn(['code'=>0,'info'=>"操作失败"]);
- }
- }else{
- $this->ajaxReturn(['code'=>0,'info'=>"网络错误"]);
- }
- }
-
- //单控盈亏
- public function setwinloss_ty(){
- if($_POST){
- $id = trim(I('post.id'));
- $kongyk = trim(I('post.kongyk'));
- $info = M("tyhyorder")->where(array('id'=>$id))->find();
- if(empty($info)){
- $this->ajaxReturn(['code'=>0,'info'=>"参少重要参数"]);
- }
-
- $result = M("tyhyorder")->where(array('id'=>$id))->save(array('kongyk'=>$kongyk));
- if($result){
- $this->ajaxReturn(['code'=>1,'info'=>"操作成功"]);
- }else{
- $this->ajaxReturn(['code'=>0,'info'=>"操作失败"]);
- }
- }else{
- $this->ajaxReturn(['code'=>0,'info'=>"网络错误"]);
- }
- }
-
- //合约订单详情
- public function orderinfo(){
- $id = trim(I('get.id'));
- $info = M("hyorder")->where(array("id"=>$id))->find();
- $this->assign('info',$info);
- $this->display();
- }
- //合约订单详情
- public function orderinfo_ty(){
- $id = trim(I('get.id'));
- $info = M("tyhyorder")->where(array("id"=>$id))->find();
- $this->assign('info',$info);
- $this->display();
- }
-
- //快速合约参数设置
- public function sethy(){
- if($_POST){
- $id = trim($_POST['hy_id']);
- if($id <= 0){
- $result = M("hysetting")->add($_POST);
- }else{
- unset($_POST['hy_id']);
- $result = M("hysetting")->where(array('id'=>$id))->save($_POST);
- }
- if($result){
- $this->success("操作成功!",U('Trade/sethy'));
- }else{
- $this->error("操作失败!",U('Trade/sethy'));
- }
-
- }else{
-
- $info = M("hysetting")->where(array('id'=>1))->find();
- $this->assign("info",$info);
- $this->display();
- }
-
- }
-
- //体验订单记灵
- public function tyorder(){
-
- $where = array();
- if(I('get.username') != '' || I('get.username') != null){
- $username = trim(I('get.username'));
- $where['username'] = $username;
- }
-
- if(I('get.hyzd') > 0){
- $hyzd = trim(I('get.hyzd'));
- $where['hyzd'] = $hyzd;
- }
- $count = M('tyhyorder')->where($where)->count();
- $Page = new \Think\Page($count, 15);
- $show = $Page->show();
- $list = M('tyhyorder')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
- $this->assign('list', $list);
- $this->assign('page', $show);
-
- $this->display();
- }
-
- //合约购买记录(未平仓的)
- public function index(){
-
- $where = array();
- if(I('get.username') != '' || I('get.username') != null){
- $username = trim(I('get.username'));
- $where['username'] = $username;
- }
-
- if(I('get.hyzd') > 0){
- $hyzd = trim(I('get.hyzd'));
- $where['hyzd'] = $hyzd;
- }
-
- $where['status'] = 1;
- $count = M('hyorder')->where($where)->count();
- $Page = new \Think\Page($count, 15);
- $show = $Page->show();
- $list = M('hyorder')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
- $this->assign('list', $list);
- $this->assign('page', $show);
-
- $this->display();
- }
- //合约交易平仓记录
- public function hylog($invit=null){
-
- if($invit != ''){
- $where['username'] = ['like',"%{$invit}%"];
- }
-
- $where['status'] = 2;
- $count = M('hyorder')->where($where)->count();
- $Page = new \Think\Page($count, 15);
- $show = $Page->show();
- $list = M('hyorder')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
- $this->assign('list', $list);
- $this->assign('page', $show);
- $this->display();
- }
- ///机器人刷单币种列表
- public function market($field = NULL, $name = NULL)
- {
- $where = array();
- if ($field && $name) {
- if ($field == 'username') {
- $where['userid'] = M('User')->where(array('username' => $name))->getField('id');
- }
- else {
- $where[$field] = $name;
- }
- }
- $count = M('Market')->where($where)->count();
- $Page = new \Think\Page($count, 15);
- $show = $Page->show();
- $list = M('Market')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
- $this->assign('list', $list);
- $this->assign('page', $show);
- $this->display();
- }
-
- //编辑刷单
- public function marketEdit($id = NULL)
- {
- $getCoreConfig = getCoreConfig();
- if(!$getCoreConfig){
- $this->error('核心配置有误');
- }
- if (empty($_POST)) {
- if (empty($id)) {
- $this->data = array();
- }
- else {
- $this->data = M('Market')->where(array('id' => $id))->find();
- }
- $coin['coin'] = M('coin')->select();
- $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');
- $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');
- $this->assign('time_arr', $time_arr);
- $this->assign('C', $coin);
- $this->assign('time_minute', $time_minute);
- $this->assign('getCoreConfig',$getCoreConfig['indexcat']);
- $this->display();
- }
- else {
- if (APP_DEMO) {
- $this->error('测试站暂时不能修改!');
- }
- $round = array(0, 1, 2, 3, 4, 5, 6);
- if (!in_array($_POST['round'], $round)) {
- $this->error('小数位数格式错误!');
- }
- if ($_POST['id']) {
- $rs = M('Market')->save($_POST);
- }
- else {
- $_POST['name'] = $_POST['sellname'] . '_' . $_POST['buyname'];
- $_POST['new_price'] = $_POST['faxingjia'];
- unset($_POST['buyname']);
- unset($_POST['sellname']);
- if (M('Market')->where(array('name' => $_POST['name']))->find()) {
- $this->error('市场存在!');
- }
- $rs = M('Market')->add($_POST);
- }
- if ($rs) {
- $this->success('操作成功!');
- }
- else {
- $this->error('操作失败!');
- }
- }
- }
- public function marketStatus($id = NULL, $type = NULL, $mobile = 'Market')
- {
- if (APP_DEMO) {
- $this->error('测试站暂时不能修改!');
- }
- if (empty($id)) {
- $this->error('参数错误!');
- }
- if (empty($type)) {
- $this->error('参数错误1!');
- }
- if (strpos(',', $id)) {
- $id = implode(',', $id);
- }
- $where['id'] = array('in', $id);
- switch (strtolower($type)) {
- case 'forbid':
- $data = array('status' => 0);
- break;
- case 'resume':
- $data = array('status' => 1);
- break;
- case 'repeal':
- $data = array('status' => 2, 'endtime' => time());
- break;
- case 'delete':
- $data = array('status' => -1);
- break;
- case 'del':
- if (M($mobile)->where($where)->delete()) {
- $this->success('操作成功!');
- }
- else {
- $this->error('操作失败!');
- }
- break;
- default:
- $this->error('操作失败!');
- }
- if (M($mobile)->where($where)->save($data)) {
- $this->success('操作成功!');
- }
- else {
- $this->error('操作失败!');
- }
- }
- public function tradeclear($type=NULL,$id=NULL)
- {
- if(!$id){
- $this->error('请选择交易市场!');
- }
- if(!$type){
- $this->error('请选择清理类型!');
- }
- $market= M('Market')->where(array('id' => $id))->find();
- if($type==1){
- $allclear=M('Trade')->where(array('market'=>$market['name'],'userid'=>0))->delete();
- }
- if($type==2){
- if(!$market['sdhigh'] or !$market['sdlow']){
- $this->error('该市场未设置刷单最高价或最低价,无法部分清理');
- }
- $map['market']=$market['name'];
- $map['userid']=0;
- $map['price']=array('notbetween',array($market['sdhigh'],$market['sdlow']));
- $allclear=M('Trade')->where($map)->delete();
- }
- if($allclear){
- $this->success('清理成功,一共'.$allclear.'条刷单记录');
- }else{
- $this->error('清理失败!');
- }
- }
- }
- ?>
|