TradeController.class.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. <?php
  2. /* 交易中心 */
  3. namespace Mobile\Controller;
  4. class TradeController extends MobileController
  5. {
  6. protected function _initialize()
  7. {
  8. parent::_initialize(); $allow_action=array("index","bauhinia","tradelist","ordinary","trans","transinfo","upbbbuy","getprice","upbbsell","clearorder","tradebill","billinfo");
  9. if(!in_array(ACTION_NAME,$allow_action)){
  10. $this->error(L("非法操作"));
  11. }
  12. }
  13. //成交详情
  14. public function billinfo($id = null){
  15. $uid = userid();
  16. if($uid <= 0){
  17. $this->ajaxReturn(['code' => 3, 'info' => L('未登录')]);
  18. }
  19. $info = M("bborder")->where(array('id'=>$id))->find();
  20. $this->ajaxReturn(['code' => 1, 'data' => $info]);
  21. // $this->assign('info',$info);
  22. // $this->display();
  23. }
  24. public function bauhinia()
  25. {
  26. $uid = userid();
  27. $name = I('get.name');
  28. $minfo = M("user_coin")->where(array('userid'=>$uid))->find();
  29. $this->ajaxReturn(['code' => 1, 'data' => $minfo[strtolower($name)]]);
  30. }
  31. //全部委托订单及交易记录
  32. public function tradebill(){
  33. $uid = userid();
  34. if($uid <= 0){
  35. $this->ajaxReturn(['code' => 3, 'info' => L('未登录')]);
  36. }
  37. $type = I('get.type');
  38. if ($type == 1){
  39. //全总未交易委托
  40. $list = M("bborder")->where(array('uid'=>$uid,'ordertype'=>1,'status'=>1))->order('id desc')->select();
  41. }elseif ($type == 2){
  42. //全部交易记录
  43. $list = M("bborder")->where("uid = {$uid} and status != 1")->order('id desc')->select();
  44. }elseif ($type == 3){
  45. //全部成交记录
  46. $list = M("bborder")->where(array('uid'=>$uid,'status'=>2))->order('id desc')->select();
  47. }
  48. $this->ajaxReturn(['code' => 1, 'data' => $list]);
  49. }
  50. //取消委托订单
  51. public function clearorder($oid=null){
  52. if(checkstr($oid)){
  53. $this->ajaxReturn(['code'=>0,'info'=>L('缺少重要参数')]);
  54. }
  55. $oinfo = M("bborder")->where(array('id'=>$oid))->find();
  56. if(empty($oinfo)){
  57. $this->ajaxReturn(['code'=>0,'info'=>L('委托订单不存在')]);
  58. }
  59. $uid = $oinfo['uid'];
  60. $type = $oinfo['type'];
  61. //买入委托
  62. if($type == 1){
  63. $coin = "usdt";
  64. $num = $oinfo['usdtnum'];
  65. //出售委托
  66. }elseif($type == 2){
  67. $coin = strtolower($oinfo['coin']);
  68. $num = $oinfo['coinnum'];
  69. }
  70. M()->startTrans();
  71. $upre = M("bborder")->where(array('id'=>$oid))->lock(true)->save(array('status'=>3));
  72. $coind = $coin."d";
  73. //把冻结的资产转移到可用资产里
  74. $decre = M("user_coin")->where(array('userid'=>$uid))->setDec($coind,$num);
  75. $incre = M("user_coin")->where(array('userid'=>$uid))->setInc($coin,$num);
  76. if($upre && $decre && $incre){
  77. M()->commit();
  78. $this->ajaxReturn(['code'=>1,'info'=>"订单已撤消"]);
  79. }else{
  80. M()->rollback();
  81. $this->ajaxReturn(['code'=>0,'info'=>"订单撤消失败"]);
  82. }
  83. }
  84. //币币交易出售处理
  85. public function upbbsell($symbol=null,$mprice=null,$mnum=null,$selltype=null){
  86. if(checkstr($symbol)||checkstr($mprice)||checkstr($mnum)||checkstr($selltype)){
  87. $this->ajaxReturn(['code'=>0,'info'=>L('您输入的信息有误')]);
  88. }
  89. //判断是否开市
  90. $nowtime = date('H:i',time());
  91. $bbset = M("bbsetting")->where(array('id'=>1))->find();
  92. $kstime = explode("~",$bbset['bb_kstime']);
  93. $start = $kstime[0];
  94. $end = $kstime[1];
  95. if($nowtime < $start || $nowtime > $end){
  96. $this->ajaxReturn(['code' => 3, 'info' => L('未登录')]);
  97. }
  98. //判断登陆
  99. $uid = userid();
  100. $uinfo = M("user")->where(array('id'=>$uid))->field("id,username,rzstatus,is_tax,taxstatus")->find();
  101. if(empty($uinfo)){
  102. $this->ajaxReturn(['code'=>3,'info'=>L('请先登录')]);
  103. }
  104. if($uinfo['rzstatus'] != 2){
  105. $this->ajaxReturn(['code'=>0,'info'=>L('请先完成实名认证')]);
  106. }
  107. //检查该会员是不是需要缴纳税金,如有需要检查有没有缴纳
  108. if($uinfo['is_tax'] == 1){
  109. if($uinfo['taxstatus'] != 1){
  110. $this->ajaxReturn(['code'=>3]);
  111. }
  112. }
  113. if($symbol == ''){
  114. $this->ajaxReturn(['code'=>0,'info'=>L('缺少重要参数')]);
  115. }
  116. $arr = explode("/",$symbol);
  117. $coin = $arr[0];
  118. if($coin == "UKB"){
  119. $marketinfo = M("ctmarket")->where(array('coinname'=>"ukb"))->field("state")->find();
  120. if($marketinfo['state'] != 1){
  121. $this->ajaxReturn(['code'=>0,'info'=>L('禁止交易')]);
  122. }
  123. }
  124. if($coin == "GCB"){
  125. $marketinfo = M("ctmarket")->where(array('name'=>"gcb_usdt"))->field("state")->find();
  126. if($marketinfo['state'] != 1){
  127. $this->ajaxReturn(['code'=>0,'info'=>L('禁止交易')]);
  128. }
  129. }
  130. $lowercname = strtolower($arr[0]);
  131. $lowercoin = strtolower($arr[0]).strtolower($arr[1]);
  132. $coinname = strtoupper($coin);
  133. //查手续费比例
  134. $coininfo = M("coin")->where(array('name'=>$coinname))->field("bbsxf")->find();
  135. $sxf = $coininfo['bbsxf'];
  136. if($sxf < 0){
  137. $sxf = 0;
  138. }
  139. //查账户余额
  140. $minfo = M("user_coin")->where(array('userid'=>$uid))->find();
  141. $coin_blance = $minfo[$lowercname];
  142. if($coin_blance < $mnum){
  143. $this->ajaxReturn(['code'=>0,'info'=>L($lowercname.'余额不足')]);
  144. }
  145. //限价必须有出售数量 限价单价
  146. if($selltype == 1){
  147. if($mnum <= 0){
  148. $this->ajaxReturn(['code'=>0,'info'=>L('请输入出售额度')]);
  149. }
  150. if($mprice <= 0){
  151. $this->ajaxReturn(['code'=>0,'info'=>L('请输入限价价格')]);
  152. }
  153. //写入交易记录
  154. $xjdata['uid'] = $uid;
  155. $xjdata['account'] = $uinfo['username'];
  156. $xjdata['type'] = 2;
  157. $xjdata['ordertype'] = 1;
  158. $xjdata['symbol'] = $symbol;
  159. $xjdata['coin'] = $coin;
  160. $xjdata['coinnum'] = $mnum;
  161. $xjdata['xjprice'] = $mprice;
  162. $xjdata['addtime'] = date("Y-m-d H:i:s",time());
  163. $xjdata['coin'] = $coin;
  164. $xjdata['status'] = 1;
  165. $xjdata['sxfbl'] = $sxf;
  166. $addre = M("bborder")->add($xjdata);
  167. //把资产转入冻结字段
  168. $decre = M("user_coin")->where(array('userid'=>$uid))->setDec($lowercname,$mnum);
  169. $incre = M("user_coin")->where(array('userid'=>$uid))->setInc($lowercname."d",$mnum);
  170. if($addre && $decre && $incre){
  171. $this->ajaxReturn(['code'=>1,'info'=> L('订单委托成功')]);
  172. }else{
  173. $this->ajaxReturn(['code'=>0,'info'=> L('订单委托失败')]);
  174. }
  175. //市价 出售数量,获取当前单价
  176. }elseif($selltype == 2){
  177. if($mnum <= 0){
  178. $this->ajaxReturn(['code'=>0,'info'=>L('请输入出售额度')]);
  179. }
  180. if($coin == "UKB"){
  181. $priceinfo = M("market")->where(array('name'=>"ukb_usdt"))->field("new_price")->find();
  182. $close = $priceinfo['new_price'];//现价
  183. }elseif ($coin == 'GCB'){
  184. $priceinfo = M("market")->where(array('name'=>"gcb_usdt"))->field("new_price")->find();
  185. $close = $priceinfo['new_price'];//现价
  186. }else{
  187. //获取当前交易对价格
  188. $oy_list = do_request(oy_url($lowercname, 'api/v5/market/ticker?instId='), []);
  189. $oy_list = $oy_list->data[0];
  190. $close = $oy_list->last;//现价
  191. }
  192. //求出卖出所得USDT
  193. $allusdt = $mnum * $close;
  194. //手续费
  195. $sxfnum = $allusdt * $sxf / 100;
  196. //实际到账USDT
  197. $tusdt = $allusdt - $sxfnum;
  198. //写入交易记录
  199. $sjdata['uid'] = $uid;
  200. $sjdata['account'] = $uinfo['username'];
  201. $sjdata['type'] = 2;
  202. $sjdata['ordertype'] = 2;
  203. $sjdata['symbol'] = $symbol;
  204. $sjdata['coin'] = $coin;
  205. $sjdata['coinnum'] = $mnum;
  206. $sjdata['usdtnum'] = $tusdt;
  207. $sjdata['price'] = $close;
  208. $sjdata['xjprice'] = $close;
  209. $sjdata['addtime'] = date("Y-m-d H:i:s",time());
  210. $sjdata['tradetime'] = date("Y-m-d H:i:s",time());
  211. $sjdata['fee'] = $sxfnum;
  212. $sjdata['sxfbl'] = $sxf;
  213. $sjdata['status'] = 2;
  214. $addre = M("bborder")->add($sjdata);
  215. //扣除卖出额度并写入日志
  216. $decre = M("user_coin")->where(array('userid'=>$uid))->setDec($lowercname,$mnum);
  217. $cbill['uid'] = $uid;
  218. $cbill['username'] = $uinfo['username'];
  219. $cbill['num'] = $mnum;
  220. $cbill['coinname'] = $lowercname;
  221. $cbill['afternum'] = $minfo[$lowercname] - $mnum;
  222. $cbill['type'] = 10;
  223. $cbill['addtime'] = date("Y-m-d H:i:s",time());
  224. $cbill['st'] = 2;
  225. $cbill['remark'] = L('币币交易出售').$coin;
  226. $cbillre = M("bill")->add($cbill);
  227. //增加USDT数量并写入日志
  228. $incre = M("user_coin")->where(array('userid'=>$uid))->setInc("usdt",$tusdt);
  229. $ubill['uid'] = $uid;
  230. $ubill['username'] = $uinfo['username'];
  231. $ubill['num'] = $tusdt;
  232. $ubill['coinname'] = "usdt";
  233. $ubill['afternum'] = $minfo['usdt'] + $tusdt;
  234. $ubill['type'] = 9;
  235. $ubill['addtime'] = date("Y-m-d H:i:s",time());
  236. $ubill['st'] = 1;
  237. $ubill['remark'] = L('币币交易出售').$coin;
  238. $ubillre = M("bill")->add($ubill);
  239. if($addre && $decre && $cbillre && $incre && $ubillre){
  240. $this->ajaxReturn(['code'=>1,"info"=>L('出售成功')]);
  241. }else{
  242. $this->ajaxReturn(['code'=>0,"info"=>L('出售失败')]);
  243. }
  244. }
  245. }
  246. //币币交易购买处理
  247. public function upbbbuy($symbol=null,$mprice=null,$musdt=null,$buytype=null){
  248. if(checkstr($symbol)||checkstr($mprice)||checkstr($musdt)||checkstr($buytype)){
  249. $this->ajaxReturn(['code'=>0,'info'=>L('您输入的信息有误')]);
  250. }
  251. if ($musdt <= 0) $this->ajaxReturn(['code'=>0,'info'=>L('請輸入購買數量')]);
  252. //判断是否开市
  253. $nowtime = date('H:i',time());
  254. $bbset = M("bbsetting")->where(array('id'=>1))->find();
  255. $kstime = explode("~",$bbset['bb_kstime']);
  256. $start = $kstime[0];
  257. $end = $kstime[1];
  258. if($nowtime < $start || $nowtime > $end){
  259. $this->ajaxReturn(['code'=>0,'info'=>L('未开市')]);
  260. }
  261. $uid = userid();
  262. $uinfo = M("user")->where(array('id'=>$uid))->field("id,username,rzstatus,is_tax,taxstatus")->find();
  263. if(empty($uinfo)){
  264. $this->ajaxReturn(['code'=>3,'info'=>L('请先登录')]);
  265. }
  266. if($uinfo['rzstatus'] != 2){
  267. $this->ajaxReturn(['code'=>0,'info'=>L('请先完成实名认证')]);
  268. }
  269. //检查该会员是不是需要缴纳税金,如有需要检查有没有缴纳
  270. if($uinfo['is_tax'] == 1){
  271. if($uinfo['taxstatus'] != 1){
  272. $this->ajaxReturn(['code'=>3]);
  273. }
  274. }
  275. if($symbol == ''){
  276. $this->ajaxReturn(['code'=>0,'info'=>L('缺少重要参数')]);
  277. }
  278. $arr = explode("/",$symbol);
  279. $coin = $arr[0];
  280. if($coin == "UKB"){
  281. $marketinfo = M("ctmarket")->where(array('coinname'=>"ukb"))->field("state")->find();
  282. if($marketinfo['state'] != 1){
  283. $this->ajaxReturn(['code'=>0,'info'=>L('禁止交易')]);
  284. }
  285. }
  286. if($coin == "GCB"){
  287. $marketinfo = M("ctmarket")->where(array('name'=>"gcb_usdt"))->field("state")->find();
  288. if($marketinfo['state'] != 1){
  289. $this->ajaxReturn(['code'=>0,'info'=>L('禁止交易')]);
  290. }
  291. }
  292. $lowercoin = strtolower($arr[0]).strtolower($arr[1]);
  293. $coinname = strtoupper($coin);
  294. $coininfo = M("coin")->where(array('name'=>$coinname))->field("bbsxf")->find();
  295. $sxf = $coininfo['bbsxf'];
  296. if($sxf < 0){
  297. $sxf = 0;
  298. }
  299. //需要查会员的账号USDT余额
  300. $minfo = M("user_coin")->where(array('userid'=>$uid))->find();
  301. if($musdt > $minfo['usdt']){
  302. $this->ajaxReturn(['code'=>0,'info'=>L('USDT余额不足')]);
  303. }
  304. //限价必须有单价,USDT量
  305. //市价必须有USDT量,再获取当前最新单价
  306. if($buytype == 1){//限价
  307. if($mprice <= 0){
  308. $this->ajaxReturn(['code'=>0,'info'=>L('请输入限价价格')]);
  309. }
  310. $xjdata['uid'] = $uid;
  311. $xjdata['account'] = $uinfo['username'];
  312. $xjdata['type'] = 1;
  313. $xjdata['ordertype'] = 1;
  314. $xjdata['symbol'] = $symbol;
  315. $xjdata['coin'] = $coin;
  316. $xjdata['usdtnum'] = $musdt;
  317. $xjdata['xjprice'] = $mprice;
  318. $xjdata['addtime'] = date("Y-m-d H:i:s",time());
  319. $xjdata['coin'] = $coin;
  320. $xjdata['status'] = 1;
  321. $xjdata['sxfbl'] = $sxf;
  322. //添加限价委托记录
  323. $addre = M("bborder")->add($xjdata);
  324. //把USDT转入冻结字段
  325. $decre = M("user_coin")->where(array('userid'=>$uid))->setDec('usdt',$musdt);
  326. $incre = M("user_coin")->where(array('userid'=>$uid))->setInc('usdtd',$musdt);
  327. if($addre && $decre && $incre){
  328. $this->ajaxReturn(['code'=>1,'info'=> L('订单委托成功')]);
  329. }
  330. }elseif($buytype == 2){//市价
  331. //计算买入币的量
  332. //获取当前交易对价格
  333. //获取当前交易对价格
  334. if ($coin == 'GCB'){
  335. $priceinfo = M("market")->where(array('name'=>"gcb_usdt"))->field("new_price")->find();
  336. $close = $priceinfo['new_price'];//现价
  337. }else{
  338. //获取当前交易对价格
  339. $oy_list = do_request(oy_url($coinname, 'api/v5/market/ticker?instId='), []);
  340. $oy_list = $oy_list->data[0];
  341. $close = $oy_list->last;//现价
  342. }
  343. $coinnum = sprintf("%.8f",($musdt / $close));
  344. //计算手续费
  345. $sxfnum = $coinnum * $sxf / 100;
  346. //实际到账号的币量
  347. $tnum = $coinnum - $sxfnum;
  348. $sjdata['uid'] = $uid;
  349. $sjdata['account'] = $uinfo['username'];
  350. $sjdata['type'] = 1;
  351. $sjdata['ordertype'] = 2;
  352. $sjdata['symbol'] = $symbol;
  353. $sjdata['coin'] = $coin;
  354. $sjdata['coinnum'] = $coinnum;
  355. $sjdata['usdtnum'] = $musdt;
  356. $sjdata['price'] = $close;
  357. $sjdata['xjprice'] = $close;
  358. $sjdata['addtime'] = date("Y-m-d H:i:s",time());
  359. $sjdata['tradetime'] = date("Y-m-d H:i:s",time());
  360. $sjdata['fee'] = $sxfnum;
  361. $sjdata['sxfbl'] = $sxf;
  362. $sjdata['status'] = 2;
  363. $lowercoin = strtolower($coin);
  364. //生成交易记录
  365. $addre = M("bborder")->add($sjdata);
  366. //扣除USDT额度并写日志
  367. $decre = M("user_coin")->where(array('userid'=>$uid))->setDec('usdt',$musdt);
  368. $ubill['uid'] = $uid;
  369. $ubill['username'] = $uinfo['username'];
  370. $ubill['num'] = $musdt;
  371. $ubill['coinname'] = "usdt";
  372. $ubill['afternum'] = $minfo['usdt'] - $musdt;
  373. $ubill['type'] = 9;
  374. $ubill['addtime'] = date("Y-m-d H:i:s",time());
  375. $ubill['st'] = 2;
  376. $ubill['remark'] = L('币币交易购买').$coin;
  377. $ubillre = M("bill")->add($ubill);
  378. //增加币种额度并写日志
  379. $incre = M("user_coin")->where(array('userid'=>$uid))->setInc($lowercoin,$tnum);
  380. $cbill['uid'] = $uid;
  381. $cbill['username'] = $uinfo['username'];
  382. $cbill['num'] = $coinnum;
  383. $cbill['coinname'] = $lowercoin;
  384. $cbill['afternum'] = $minfo[$lowercoin] + $coinnum;
  385. $cbill['type'] = 10;
  386. $cbill['addtime'] = date("Y-m-d H:i:s",time());
  387. $cbill['st'] = 1;
  388. $cbill['remark'] = L('币币交易购买').$coin;
  389. $cbillre = M("bill")->add($cbill);
  390. if($addre && $decre && $ubillre && $incre && $cbillre){
  391. $this->ajaxReturn(['code'=>1,'info'=>L('交易成功')]);
  392. }else{
  393. $this->ajaxReturn(['code'=>0,'info'=>L('交易失败')]);
  394. }
  395. }
  396. }
  397. //获取行情数据
  398. public function getprice($api){
  399. $ch = curl_init();
  400. curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
  401. curl_setopt ($ch, CURLOPT_URL, $api );
  402. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  403. curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
  404. $result = json_decode(curl_exec($ch),true);
  405. return $result;
  406. }
  407. //币币交易详情页面
  408. public function transinfo(){
  409. $uid = userid();
  410. $symbol = trim(I('get.symbol'));
  411. $coin = strtolower($symbol);
  412. $minfo = M("user_coin")->where(array('userid'=>$uid))->find();
  413. $usdt_blance = $minfo['usdt'];
  414. $coin_blance = $minfo[$coin];
  415. $this->assign('usdt_blance',$usdt_blance);
  416. $this->assign('coin_blance',$coin_blance);
  417. $this->assign('uid',$uid);
  418. $coinname = $symbol."/"."USDT";
  419. $this->assign('coinname',$coinname);
  420. $this->assign('symbol',$symbol);
  421. $where['ordertype'] = 1;
  422. $where['status'] = 1;
  423. $where['uid'] = $uid;
  424. $where['coin'] = array('eq',$symbol);
  425. $list = M("bborder")->where($where)->select();
  426. $this->assign('list',$list);
  427. $this->display();
  428. }
  429. //币币交易页面
  430. public function trans(){
  431. $uid = userid();
  432. $this->assign('uid',$uid);
  433. $sytx = trim(I('get.sytx'));
  434. $txarr = explode('/',$sytx);
  435. $symbol = $txarr[0];
  436. $market = strtolower($txarr[0].$txarr[1]);
  437. if($symbol == ''){
  438. $symbol = 'btc';
  439. }
  440. if($market == ''){
  441. $market = 'btcusdt';
  442. }
  443. $upmarket = strtoupper($symbol)."/USDT";
  444. $this->assign('upmarket',$upmarket);
  445. $this->assign('market', $market);
  446. $this->assign('smybol',$symbol);
  447. $lowercoin = strtolower($symbol);
  448. $cmarket = M("ctmarket")->where(array('coinname'=>$lowercoin))->field("state")->find();
  449. $state = $cmarket['state'];
  450. $this->assign('state',$state);
  451. $this->display();
  452. }
  453. //网站首页
  454. public function tradelist(){
  455. $uid = userid();
  456. $this->assign('uid',$uid);
  457. $clist = M("config")->where(array('id'=>1))->field("websildea,websildeb,websildec")->find();
  458. $this->assign('clist',$clist);
  459. $websildec = $clist['websildec'];
  460. foreach ($clist as &$item){
  461. $item = 'http://'.$_SERVER['HTTP_HOST'].'/Upload/public/'.$item;
  462. }
  463. // $this->assign('websildec',$websildec);
  464. $nlist = M("content")->where(array('status'=>1))->order("id desc")->field("title,id")->select();
  465. $this->assign('nlist',$nlist);
  466. if($uid > 0){
  467. $sum = M("notice")->where(array('uid'=>$uid,'status'=>1))->count();
  468. }else{
  469. $sum = 0;
  470. }
  471. $this->assign('sum',$sum);
  472. $list = M("ctmarket")->where(array('status'=>1))->field("coinname,id")->select();
  473. $this->assign("market",$list);
  474. $info = M("content")->where(array('status'=>1))->order("id desc")->find();
  475. $data = [
  476. 'uid' => $uid,
  477. 'clist' => $clist,
  478. 'websildec' => $websildec,
  479. 'sum' => $sum,
  480. 'ctmarket' => $list,
  481. 'info' => $info
  482. ];
  483. $this->ajaxReturn(['code' => 1, 'data' => $data, 'info' => '']);
  484. }
  485. //交易市场
  486. public function index(){
  487. $where['status'] = 1;
  488. //$where['coinname'] = array('eq','ukb');
  489. $list = M("ctmarket")->where($where)->field("coinname,id")->select();
  490. $this->assign("market",$list);
  491. $this->display();
  492. }
  493. /**
  494. * 普通K线图
  495. */
  496. public function ordinary($market = NULL)
  497. {
  498. $market = trim(I('get.market'));
  499. if($market == ''){
  500. $market = "btcusdt";
  501. }
  502. $this->assign('market', $market);
  503. $this->display();
  504. }
  505. /**
  506. * 专业K线图
  507. * @param [type] $market [description]
  508. * @return [type] [description]
  509. */
  510. public function specialty($market = NULL)
  511. {
  512. // 过滤非法字符----------------S
  513. if (checkstr($market)) {
  514. $this->error(L('您输入的信息有误'));
  515. }
  516. // 过滤非法字符----------------E
  517. if (!$market) {
  518. $market = C('market_mr');
  519. }
  520. $this->assign('market', $market);
  521. $this->display();
  522. }
  523. }
  524. ?>