KuangmController.class.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <?php
  2. namespace Admin\Controller;
  3. class KuangmController extends AdminController
  4. {
  5. public function __construct()
  6. {
  7. parent::__construct();
  8. }
  9. //矿机收益列表
  10. public function djprofit($username = null){
  11. if($username != ''){
  12. $where['username'] = array('eq',$username);
  13. }
  14. $count = M('djprofit')->where($where)->count();
  15. $Page = new \Think\Page($count, 15);
  16. $show = $Page->show();
  17. $list = M('djprofit')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  18. $this->assign('list', $list);
  19. $this->assign('page', $show);
  20. $this->display();
  21. }
  22. //矿机收益列表
  23. public function kjsylist($username = null){
  24. if($username != ''){
  25. $where['username'] = array('eq',$username);
  26. }
  27. $count = M('kjprofit')->where($where)->count();
  28. $Page = new \Think\Page($count, 15);
  29. $show = $Page->show();
  30. $list = M('kjprofit')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  31. $this->assign('list', $list);
  32. $this->assign('page', $show);
  33. $this->display();
  34. }
  35. //启用会员矿机,停用会员矿机,删除会员矿机
  36. public function userkjStatus($id = NULL, $type = NULL, $mobile = 'User'){
  37. if($mobile != "Admin"){
  38. $this->error("参数错误");
  39. }
  40. $where['id'] = array('in', $id);
  41. switch (strtolower($type)) {
  42. case 1:
  43. $result = M("kjorder")->where($where)->save(array('status'=>1));
  44. break;
  45. case 2:
  46. $result = M("kjorder")->where($where)->save(array('status'=>2));
  47. break;
  48. case 3:
  49. $result = M("kjorder")->where($where)->delete();
  50. break;
  51. default:
  52. $this->error('操作失败!');
  53. }
  54. if($result){
  55. $this->success('操作成功!');
  56. }else{
  57. $this->error('操作失败!');
  58. }
  59. }
  60. //会员过期的矿机列表
  61. public function overlist(){
  62. $where['status'] = array('eq',3);
  63. $count = M('kjorder')->where($where)->count();
  64. $Page = new \Think\Page($count, 15);
  65. $show = $Page->show();
  66. $list = M('kjorder')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  67. $this->assign('list', $list);
  68. $this->assign('page', $show);
  69. $this->display();
  70. }
  71. //会员运行中的矿机列表
  72. public function kjlist($username = null){
  73. if($username != ''){
  74. $where['username'] = array('eq',$username);
  75. }
  76. $where['status'] = array('lt',3);
  77. $count = M('kjorder')->where($where)->count();
  78. $Page = new \Think\Page($count, 15);
  79. $show = $Page->show();
  80. $list = M('kjorder')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  81. $this->assign('list', $list);
  82. $this->assign('page', $show);
  83. $this->display();
  84. }
  85. //启用,停用矿机,删除矿机
  86. public function kuangjStatus($id = NULL, $type = NULL, $mobile = 'User'){
  87. if($mobile != "Admin"){
  88. $this->error("参数错误");
  89. }
  90. $where['id'] = array('in', $id);
  91. switch (strtolower($type)) {
  92. case 1:
  93. $result = M("kuangji")->where($where)->save(array('status'=>1));
  94. break;
  95. case 2:
  96. $result = M("kuangji")->where($where)->save(array('status'=>2));
  97. break;
  98. case 3:
  99. $result = M("kuangji")->where($where)->delete();
  100. break;
  101. default:
  102. $this->error('操作失败!');
  103. }
  104. if($result){
  105. $this->success('操作成功!');
  106. }else{
  107. $this->error('操作失败!');
  108. }
  109. }
  110. //矿机列表页面
  111. public function index(){
  112. $count = M('kuangji')->count();
  113. $Page = new \Think\Page($count, 15);
  114. $show = $Page->show();
  115. $list = M('kuangji')->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  116. $this->assign('list', $list);
  117. $this->assign('page', $show);
  118. $this->display();
  119. }
  120. //添加矿机
  121. public function addkj(){
  122. if($_POST){
  123. $data['title'] = trim($_POST['title']);
  124. $data['rtype'] = trim($_POST['rtype']);
  125. $data['type'] = trim($_POST['type']);
  126. if($data['type'] == 1){
  127. $data['sharebl'] = 0;
  128. $data['sharecode'] = '';
  129. }elseif($data['type'] == 2){
  130. $data['sharebl'] = trim($_POST['sharebl']);
  131. $data['sharecode'] = creat_sharecode(13);
  132. }
  133. $data['content'] = trim($_POST['content']);
  134. $data['imgs'] = trim($_POST['imgs']);
  135. $data['dayoutnum'] = trim($_POST['dayoutnum']);
  136. $data['outtype'] = trim($_POST['outtype']);
  137. $data['outcoin'] = trim($_POST['outcoin']);
  138. $data['pricenum'] = trim($_POST['pricenum']);
  139. $data['pricecoin'] = trim($_POST['pricecoin']);
  140. $data['buymax'] = trim($_POST['buymax']);
  141. $data['cycle'] = trim($_POST['cycle']);
  142. $data['suanl'] = trim($_POST['suanl']);
  143. $data['allnum'] = trim($_POST['allnum']);
  144. $data['ycnum'] = trim($_POST['ycnum']);
  145. $data['jlnum'] = trim($_POST['jlnum']);
  146. $data['di'] = trim($_POST['di']);
  147. $data['gao'] = trim($_POST['gao']);
  148. $data['jlcoin'] = trim($_POST['jlcoin']);
  149. $data['status'] = 1;
  150. $data['buyask'] = trim($_POST['buyask']);
  151. $data['asknum'] = trim($_POST['asknum']);
  152. $data['djout'] = trim($_POST['djout']);
  153. if(trim($_POST['djout']) == 2){
  154. $data['djday'] = trim($_POST['djday']);
  155. }else{
  156. $data['djday'] = trim($_POST['djday']);
  157. }
  158. $data['addtime'] = date("Y-m-d H:i:s",time());
  159. $kid = trim($_POST['kid']);
  160. if($kid > 0){
  161. $result = M("kuangji")->where(array('id'=>$kid))->save($data);
  162. $msg = "编辑成功";
  163. }else{
  164. $result = M("kuangji")->add($data);
  165. $msg = "添加成功";
  166. }
  167. if($result){
  168. $this->success($msg);
  169. }else{
  170. $this->error($msg);
  171. }
  172. }else{
  173. $this->error("非法操作");exit();
  174. }
  175. }
  176. //添加矿机页面
  177. public function addkuangj(){
  178. $id = trim(I('get.id'));
  179. $info = M("kuangji")->where(array('id'=>$id))->find();
  180. if(!empty($info)){
  181. $list = M("coin")->where(array('status'=>1))->field("id,name,title")->select();
  182. $data = array();
  183. foreach($list as $k=>$v){
  184. $data[$k]['id'] = $v['id'];
  185. $data[$k]['name'] = trim($v['name']);
  186. $data[$k]['title'] = $v['title'];
  187. }
  188. $this->assign('coind',$data);
  189. $this->assign('data',$info);
  190. }else{
  191. $list = M("coin")->where(array('status'=>1))->field("id,name,title")->select();
  192. $data = array();
  193. foreach($list as $k=>$v){
  194. $data[$k]['id'] = $v['id'];
  195. $data[$k]['name'] = trim($v['name']);
  196. $data[$k]['title'] = $v['title'];
  197. }
  198. $this->assign('coind',$data);
  199. }
  200. $this->display();
  201. }
  202. //上传矿机图片
  203. public function image(){
  204. $upload = new \Think\Upload();
  205. $upload->maxSize = 3145728;
  206. $upload->exts = array('jpg', 'gif', 'png', 'jpeg');
  207. $upload->rootPath = './Upload/public/';
  208. $upload->autoSub = false;
  209. $info = $upload->upload();
  210. foreach ($info as $k => $v) {
  211. $path = $v['savepath'] . $v['savename'];
  212. echo $path;
  213. exit();
  214. }
  215. }
  216. }
  217. ?>