ContractController.class.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <?php
  2. namespace Mobile\Controller;
  3. class ContractController extends MobileController
  4. {
  5. protected function _initialize()
  6. {
  7. parent::_initialize(); $allow_action=array("index","creatorder","ty_creatorder","get_maket_api","ctbill","cbillinfo","gethyorder","get_tyhyorder","cbillinfo_ty","get_tyhyorder_one","get_hyorder_one");
  8. if(!in_array(ACTION_NAME,$allow_action)){
  9. $this->error(L("非法操作"));
  10. }
  11. }
  12. //体验合约倒计时
  13. public function get_tyhyorder_one(){
  14. $uid = userid();
  15. $id = trim(I('post.oid'));
  16. if($id == '' || $id <= 0){
  17. $info = M("tyhyorder")->where(array('uid'=>$uid,'status'=>1))->order('id desc')->find();
  18. if(empty($info)){
  19. $info = M("tyhyorder")->where(array('uid'=>$uid))->order('id desc')->find();
  20. }
  21. }else{
  22. $info = M("tyhyorder")->where(array('id'=>$id))->find();
  23. }
  24. if(!empty($info)){
  25. if($info['status'] == 1){
  26. $alltime = $info['time'] * 60;
  27. $endtime = strtotime($info['selltime']);
  28. $t = $endtime - time();
  29. if($t <= 0){
  30. //表示已结算
  31. $data['statusstr'] = '<span style="font-size:16px;font-weight:bold;">'. L("正在结算中"). '...</span>';
  32. $data['code'] = 2;
  33. $this->ajaxReturn($data);
  34. }else{
  35. //获取当前交易对的单价
  36. $coinarr = explode('/',$info['coinname']);
  37. $symbol = strtolower($coinarr[0].$coinarr[1]);
  38. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=".$symbol;
  39. $result = $this->get_maket_api($coinapi);
  40. $price_arr = $result['data'][0];
  41. $close = $price_arr['close'];//现价
  42. $data['code'] = 1;
  43. $data['time'] = $t;
  44. $data['timer_newprice'] = $close;
  45. $this->ajaxReturn($data);
  46. }
  47. }else{
  48. //表示已经结算,则显示盈亏即可
  49. if($info['is_win'] == 1){
  50. $data['statusstr'] = '<span style="font-size:24px;font-weight:bold;color:green;">+'. $info['ploss'] .'</span>';
  51. }elseif($info['is_win'] == 2){
  52. $data['statusstr'] = '<span style="font-size:24px;font-weight:bold;color:red;">-'. $info['ploss'] .'</span>';
  53. }
  54. $data['code'] = 2;
  55. $this->ajaxReturn($data);
  56. }
  57. }else{
  58. $this->ajaxReturn(['code'=>0]);
  59. }
  60. }
  61. //合约倒计时
  62. public function get_hyorder_one(){
  63. $uid = userid();
  64. $id = trim(I('post.oid'));
  65. if($id == '' || $id <= 0){
  66. $info = M("hyorder")->where(array('uid'=>$uid,'status'=>1))->order('id desc')->find();
  67. if(empty($info)){
  68. $info = M("hyorder")->where(array('uid'=>$uid))->order('id desc')->find();
  69. }
  70. }else{
  71. $info = M("hyorder")->where(array('id'=>$id))->find();
  72. }
  73. if(!empty($info)){
  74. if($info['status'] == 1){
  75. $alltime = $info['time'] * 60;
  76. $endtime = strtotime($info['selltime']);
  77. $t = $endtime - time();
  78. if($t <= 0){
  79. //表示已结算
  80. $data['statusstr'] = '<span style="font-size:16px;font-weight:bold;">'. L("正在结算中"). '...</span>';
  81. $data['code'] = 2;
  82. $this->ajaxReturn($data);
  83. }else{
  84. //获取当前交易对的单价
  85. $coinarr = explode('/',$info['coinname']);
  86. $symbol = strtolower($coinarr[0].$coinarr[1]);
  87. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=".$symbol;
  88. $result = $this->get_maket_api($coinapi);
  89. $price_arr = $result['data'][0];
  90. $close = $price_arr['close'];//现价
  91. $data['code'] = 1;
  92. $data['time'] = $t;
  93. $data['timer_newprice'] = $close;
  94. $this->ajaxReturn($data);
  95. }
  96. }else{
  97. //表示已经结算,则显示盈亏即可
  98. if($info['is_win'] == 1){
  99. $data['statusstr'] = '<span style="font-size:24px;font-weight:bold;color:green;">+'. $info['ploss'] .'</span>';
  100. }elseif($info['is_win'] == 2){
  101. $data['statusstr'] = '<span style="font-size:24px;font-weight:bold;color:red;">-'. $info['ploss'] .'</span>';
  102. }
  103. $data['code'] = 2;
  104. $this->ajaxReturn($data);
  105. }
  106. }else{
  107. $this->ajaxReturn(['code'=>0]);
  108. }
  109. }
  110. //获取体验合约记录
  111. public function get_tyhyorder(){
  112. $uid = userid();
  113. $list = M("tyhyorder")->where(array('uid'=>$uid))->field("id,num,coinname,status,buytime,selltime,buyprice,time")->order("id desc")->select();
  114. $data = array();
  115. foreach($list as $k=>$v){
  116. $data[$k]['coinanme'] = $v['coinname'];
  117. $data[$k]['num'] = $v['num'];
  118. if($v['status'] == 1){
  119. $data[$k]['statusstr'] = L("待结算");
  120. }elseif($v['status'] == 2){
  121. $data[$k]['statusstr'] = L("已结算");
  122. }elseif($v['status'] == 3){
  123. $data[$k]['statusstr'] = L("无效结算");
  124. }
  125. $data[$k]['buyprice'] = $v['buyprice'];
  126. $data[$k]['buytime'] = date("m-d H:i",strtotime($v['buytime']));
  127. $alltime = $v['time'] * 60;
  128. $endtime = strtotime($v['selltime']);
  129. $t = $endtime - time();
  130. if($t <= 0){
  131. $t = 0;
  132. }
  133. $bl = round($t / $alltime * 100);
  134. if($bl <= 0){
  135. $bl = 0;
  136. }
  137. $data[$k]['bl'] = $bl."%";
  138. $data[$k]['t'] = $t;
  139. $data[$k]['href'] = U('Contract/cbillinfo_ty') . "?bid=" . $v['id'];
  140. }
  141. $this->ajaxReturn(['code'=>1,'data'=>$data]);
  142. }
  143. //获取合约记录
  144. public function gethyorder(){
  145. $uid = userid();
  146. $list = M("hyorder")->where(array('uid'=>$uid))->field("id,num,coinname,status,buytime,selltime,buyprice,time")->order("id desc")->select();
  147. $data = array();
  148. foreach($list as $k=>$v){
  149. $data[$k]['coinanme'] = $v['coinname'];
  150. $data[$k]['num'] = $v['num'];
  151. if($v['status'] == 1){
  152. $data[$k]['statusstr'] = L("待结算");
  153. }elseif($v['status'] == 2){
  154. $data[$k]['statusstr'] = L("已结算");
  155. }elseif($v['status'] == 3){
  156. $data[$k]['statusstr'] = L("无效结算");
  157. }
  158. $data[$k]['buyprice'] = $v['buyprice'];
  159. $data[$k]['buytime'] = date("m-d H:i",strtotime($v['buytime']));
  160. $alltime = $v['time'] * 60;
  161. $endtime = strtotime($v['selltime']);
  162. $t = $endtime - time();
  163. if($t <= 0){
  164. $t = 0;
  165. }
  166. $bl = round($t / $alltime * 100);
  167. if($bl <= 0){
  168. $bl = 0;
  169. }
  170. $data[$k]['bl'] = $bl."%";
  171. $data[$k]['t'] = $t;
  172. $data[$k]['href'] = U('Contract/cbillinfo') . "?bid=" . $v['id'];
  173. }
  174. $this->ajaxReturn(['code'=>1,'data'=>$data]);
  175. }
  176. //购买合约详情
  177. public function cbillinfo(){
  178. $bid = trim(I('get.bid'));
  179. if($bid <= 0){
  180. $this->redirect('Contract/ctbill');
  181. }
  182. $uid = userid();
  183. $info = M("hyorder")->where(array('uid'=>$uid,'id'=>$bid))->find();
  184. $this->assign('info',$info);
  185. $this->display();
  186. }
  187. //体验合约详情
  188. public function cbillinfo_ty(){
  189. $bid = trim(I('get.bid'));
  190. if($bid <= 0){
  191. $this->redirect('Contract/ctbill');
  192. }
  193. $uid = userid();
  194. $info = M("tyhyorder")->where(array('uid'=>$uid,'id'=>$bid))->find();
  195. $this->assign('info',$info);
  196. $this->display();
  197. }
  198. //合约购买记录
  199. public function ctbill(){
  200. $uid = userid();
  201. if($uid <= 0){
  202. $this->redirect('Login/index');
  203. }
  204. $fields = "num,coinname,buytime,buyprice,time,status,id";
  205. $hylist = M("hyorder")->where(array('uid'=>$uid))->field($fields)->order("id desc")->limit(20)->select();
  206. $this->assign("list",$hylist);
  207. $this->display();
  208. }
  209. //获取行情数据
  210. public function get_maket_api($api){
  211. $ch = curl_init();
  212. curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
  213. curl_setopt ($ch, CURLOPT_URL, $api );
  214. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  215. curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
  216. $result = json_decode(curl_exec($ch),true);
  217. return $result;
  218. }
  219. //快速合约建仓
  220. public function ty_creatorder(){
  221. if($_POST){
  222. $uid = userid();
  223. $uinfo = M("user")->where(array('id'=>$uid))->field("id,username,money,rzstatus,invit_1,is_tax,taxstatus")->find();
  224. if(empty($uinfo)){
  225. $this->ajaxReturn(['code'=>0,'msg'=> L('请先登陆')]);
  226. }
  227. if($uinfo['rzstatus'] != 2){
  228. $this->ajaxReturn(['code'=>0,'msg'=>L('请先完成实名认证')]);
  229. }
  230. //检查该会员是不是需要缴纳税金,如有需要检查有没有缴纳
  231. // if($uinfo['is_tax'] == 1){
  232. // if($uinfo['taxstatus'] != 1){
  233. // $this->ajaxReturn(['code'=>3]);
  234. // }
  235. // }
  236. $puid = $uinfo['invit_1'];
  237. $puser = M("user")->where(array('id'=>$puid))->field("invit")->find();
  238. $ctime = trim(I('post.ctime'));
  239. if($ctime <= 0){
  240. $this->ajaxReturn(['code'=>0,'msg'=> L('请选择结算时间')]);
  241. }
  242. $ctzed = trim(I('post.ctzed'));
  243. if($ctzed <= 0){
  244. $this->ajaxReturn(['code'=>0,'msg'=> L('请选择投资额度')]);
  245. }
  246. $ccoinname = trim(I('post.ccoinname'));
  247. if($ccoinname == ''){
  248. $this->ajaxReturn(['code'=>0,'msg'=> L('缺少重要参数')]);
  249. }
  250. $ctzfx = trim(I('post.ctzfx'));
  251. if($ctzfx <= 0){
  252. $this->ajaxReturn(['code'=>0,'msg'=> L('缺少重要参数')]);
  253. }
  254. $cykbl = trim(I('post.cykbl'));
  255. if($ctzfx <= 0){
  256. $this->ajaxReturn(['code'=>0,'msg'=> L('缺少重要参数')]);
  257. }
  258. //获取会员资产
  259. //$minfo = M("user_coin")->where(array('userid'=>$uid))->find();
  260. $usdtnum = $uinfo['money'];
  261. //获取合约手续费比例
  262. $setting = M("hysetting")->where(array('id'=>1))->field("hy_sxf,hy_min")->find();
  263. $hymin = $setting['hy_min'];
  264. if($hymin > $ctzed){
  265. $this->ajaxReturn(['code'=>0,'msg'=> L('不能小于最低投资额度')]);
  266. }
  267. $sxf = $setting['hy_sxf'];
  268. $tmoney = $ctzed + $ctzed * $sxf / 100;
  269. if($tmoney > $usdtnum){
  270. $this->ajaxReturn(['code'=>0,'msg' => L('体验金余额不足')]);
  271. }
  272. $o = M("tyhyorder")->where([
  273. 'status'=>1,
  274. 'uid'=>$uid
  275. ])->find();
  276. /* if($o){
  277. $this->ajaxReturn(['code'=>0,'msg' => L('还有未完成订单')]);
  278. }*/
  279. //获取当前交易对的单价
  280. $coinarr = explode('/',$ccoinname);
  281. $symbol = strtolower($coinarr[0].$coinarr[1]);
  282. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=".$symbol;
  283. $result = $this->get_maket_api($coinapi);
  284. $price_arr = $result['data'][0];
  285. $close = $price_arr['close'];//现价
  286. //创建订单
  287. $odata['uid'] = $uid;
  288. $odata['username'] = $uinfo['username'];
  289. $odata['num'] = $ctzed;
  290. $odata['hybl'] = $cykbl;
  291. $odata['hyzd'] = $ctzfx;
  292. $odata['coinname'] = $ccoinname;
  293. $odata['status'] = 1;
  294. $odata['is_win'] = 0;
  295. $odata['buytime'] = date("Y-m-d H:i:s",time());
  296. $odata['selltime'] = date("Y-m-d H:i:s",(time()+$ctime*60));
  297. $odata['intselltime'] = time() + $ctime*60;
  298. $odata['buyprice'] = $close;
  299. $odata['sellprice'] = '';
  300. $odata['ploss'] = 0;
  301. $odata['time'] = $ctime;
  302. $odata['kongyk'] = 0;
  303. if($puser['invit'] == ''){
  304. $puser['invit'] = 0;
  305. }
  306. $odata['invit'] = $puser['invit'];
  307. $order = M("tyhyorder")->add($odata);
  308. //扣除体验金
  309. $decre = M("user")->where(array('id'=>$uid))->setDec('money',$tmoney);
  310. //创建财务日志
  311. // $bill['uid'] = $uid;
  312. // $bill['username'] = $uinfo['username'];
  313. // $bill['num'] = $ctzed;
  314. // $bill['coinname'] = "usdt";
  315. // $bill['afternum'] = $minfo['usdt'] - $ctzed;
  316. // $bill['type'] = 3;
  317. // $bill['addtime'] = date("Y-m-d H:i:s",time());
  318. // $bill['st'] = 2;
  319. // $bill['remark'] = L('购买').$ccoinname.L('快速合约');
  320. // $billre = M("bill")->add($bill);
  321. if($order && $decre){
  322. //这里应该是获取我下的体验合约的最后一单未结算的ID号
  323. $lastorder = M("tyhyorder")->where(array('status'=>1,'uid'=>$uid))->order("id desc")->field("id")->find();
  324. $lastid = $lastorder['id'];
  325. $orderinfo = M("tyhyorder")->where(array('id'=>$lastid))->field("id,hyzd,coinname,buyprice,time,num")->find();
  326. $ajax['code'] = 1;
  327. $ajax['id'] = $orderinfo['id'];
  328. if($orderinfo['hyzd'] == 1){
  329. $ajax['timer_type'] = '<span style="color:green;font-weight:bold;">'.L("买涨").'</span>';
  330. }else{
  331. $ajax['timer_type'] = '<span style="color:red;font-weight:bold;">'.L("买跌").'</span>';
  332. }
  333. $ajax['coinname'] = $orderinfo['coinname'];
  334. $ajax['buyprice'] = $orderinfo['buyprice'];
  335. $ajax['time'] = $orderinfo['time'] * 60;
  336. $ajax['timer_newprice'] = $close;
  337. $ajax['timer_buynum'] = $orderinfo['num'];
  338. $ajax['timer_buyprice'] = $orderinfo['buyprice'];
  339. $ajax['hyzd'] = $orderinfo['hyzd'];
  340. $this->ajaxReturn($ajax);
  341. }else{
  342. $this->ajaxReturn(['code'=>0,'msg' => L('体验订单建仓失败')]);
  343. }
  344. }else{
  345. $this->ajaxReturn(['code'=>0,'msg' => L('网络错误')]);
  346. }
  347. }
  348. //快速合约建仓
  349. public function creatorder(){
  350. if($_POST){
  351. $uid = userid();
  352. $uinfo = M("user")->where(array('id'=>$uid))->field("id,username,rzstatus,invit_1,is_tax,taxstatus")->find();
  353. if(empty($uinfo)){
  354. $this->ajaxReturn(['code'=>0,'msg'=> L('请先登陆')]);
  355. }
  356. if($uinfo['rzstatus'] != 2){
  357. $this->ajaxReturn(['code'=>0,'msg'=>L('请先完成实名认证')]);
  358. }
  359. //检查该会员是不是需要缴纳税金,如有需要检查有没有缴纳
  360. if($uinfo['is_tax'] == 1){
  361. if($uinfo['taxstatus'] != 1){
  362. $this->ajaxReturn(['code'=>3]);
  363. }
  364. }
  365. $puid = $uinfo['invit_1'];
  366. $puser = M("user")->where(array('id'=>$puid))->field("invit")->find();
  367. $ctime = trim(I('post.ctime'));
  368. if($ctime <= 0){
  369. $this->ajaxReturn(['code'=>0,'msg'=> L('请选择结算时间')]);
  370. }
  371. $ctzed = trim(I('post.ctzed'));
  372. if($ctzed <= 0){
  373. $this->ajaxReturn(['code'=>0,'msg'=> L('请选择投资额度')]);
  374. }
  375. $ccoinname = trim(I('post.ccoinname'));
  376. if($ccoinname == ''){
  377. $this->ajaxReturn(['code'=>0,'msg'=> L('缺少重要参数')]);
  378. }
  379. $ctzfx = trim(I('post.ctzfx'));
  380. if($ctzfx <= 0){
  381. $this->ajaxReturn(['code'=>0,'msg'=> L('缺少重要参数')]);
  382. }
  383. $cykbl = trim(I('post.cykbl'));
  384. if($ctzfx <= 0){
  385. $this->ajaxReturn(['code'=>0,'msg'=> L('缺少重要参数')]);
  386. }
  387. //获取会员资产
  388. $minfo = M("user_coin")->where(array('userid'=>$uid))->find();
  389. $usdtnum = $minfo['usdt'];
  390. //获取合约手续费比例
  391. $setting = M("hysetting")->where(array('id'=>1))->field("hy_sxf,hy_min")->find();
  392. $hymin = $setting['hy_min'];
  393. if($hymin > $ctzed){
  394. $this->ajaxReturn(['code'=>0,'msg'=> L('不能小于最低投资额度')]);
  395. }
  396. $sxf = $setting['hy_sxf'];
  397. $tmoney = $ctzed + $ctzed * $sxf / 100;
  398. if($tmoney > $usdtnum){
  399. $this->ajaxReturn(['code'=>0,'msg' => L('USDT余额不足')]);
  400. }
  401. $o = M("hyorder")->where([
  402. 'status'=>1,
  403. 'uid'=>$uid
  404. ])->find();
  405. /*if($o){
  406. $this->ajaxReturn(['code'=>0,'msg' => L('还有未完成订单')]);
  407. }*/
  408. //获取当前交易对的单价
  409. $coinarr = explode('/',$ccoinname);
  410. $symbol = strtolower($coinarr[0].$coinarr[1]);
  411. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=".$symbol;
  412. $result = $this->get_maket_api($coinapi);
  413. $price_arr = $result['data'][0];
  414. $close = $price_arr['close'];//现价
  415. //创建订单
  416. $odata['uid'] = $uid;
  417. $odata['username'] = $uinfo['username'];
  418. $odata['num'] = $ctzed;
  419. $odata['hybl'] = $cykbl;
  420. $odata['hyzd'] = $ctzfx;
  421. $odata['coinname'] = $ccoinname;
  422. $odata['status'] = 1;
  423. $odata['is_win'] = 0;
  424. $odata['buytime'] = date("Y-m-d H:i:s",time());
  425. $odata['selltime'] = date("Y-m-d H:i:s",(time()+$ctime*60));
  426. $odata['intselltime'] = time() + $ctime*60;
  427. $odata['buyprice'] = $close;
  428. $odata['sellprice'] = '';
  429. $odata['ploss'] = 0;
  430. $odata['time'] = $ctime;
  431. $odata['kongyk'] = 0;
  432. if($puser['invit'] == ''){
  433. $puser['invit'] = 0;
  434. }
  435. $odata['invit'] = $puser['invit'];
  436. $order = M("hyorder")->add($odata);
  437. //扣除USDT额度
  438. $decre = M("user_coin")->where(array('userid'=>$uid))->setDec('usdt',$tmoney);
  439. //创建财务日志
  440. $bill['uid'] = $uid;
  441. $bill['username'] = $uinfo['username'];
  442. $bill['num'] = $ctzed;
  443. $bill['coinname'] = "usdt";
  444. $bill['afternum'] = $minfo['usdt'] - $ctzed;
  445. $bill['type'] = 3;
  446. $bill['addtime'] = date("Y-m-d H:i:s",time());
  447. $bill['st'] = 2;
  448. $bill['remark'] = L('购买').$ccoinname.L('快速合约');
  449. $billre = M("bill")->add($bill);
  450. if($order && $decre && $billre){
  451. $lastorder = M("hyorder")->where(array('status'=>1,'uid'=>$uid))->order("id desc")->field("id")->find();
  452. $lastid = $lastorder['id'];
  453. $orderinfo = M("hyorder")->where(array('id'=>$lastid))->field("id,hyzd,coinname,buyprice,time,num")->find();
  454. $ajax['code'] = 1;
  455. $ajax['id'] = $orderinfo['id'];
  456. if($orderinfo['hyzd'] == 1){
  457. $ajax['timer_type'] = '<span style="color:green;font-weight:bold;">'.L("买涨").'</span>';
  458. }else{
  459. $ajax['timer_type'] = '<span style="color:red;font-weight:bold;">'.L("买跌").'</span>';
  460. }
  461. $ajax['coinname'] = $orderinfo['coinname'];
  462. $ajax['buyprice'] = $orderinfo['buyprice'];
  463. $ajax['time'] = $orderinfo['time'] * 60;
  464. $ajax['timer_newprice'] = $close;
  465. $ajax['timer_buynum'] = $orderinfo['num'];
  466. $ajax['timer_buyprice'] = $orderinfo['buyprice'];
  467. $ajax['hyzd'] = $orderinfo['hyzd'];
  468. $this->ajaxReturn($ajax);
  469. }else{
  470. $this->ajaxReturn(['code'=>0,'msg' => L('建仓失败')]);
  471. }
  472. }else{
  473. $this->ajaxReturn(['code'=>0,'msg' => L('网络错误')]);
  474. }
  475. }
  476. //快速合约首页面
  477. public function index(){
  478. $uid = userid();
  479. if($uid <= 0 || $uid == ''){
  480. $uid = 0;
  481. }
  482. $this->assign('uid',$uid);
  483. $smybol = trim(I('get.coin'));
  484. if($smybol != ''){
  485. $map['status'] = 1;
  486. $map['coinname'] = array('like',"%$smybol%");
  487. $list = M("ctmarket")->where($map)->field("coinname")->find();
  488. if(!empty($list)){
  489. $smybol = $list['coinname'];
  490. }else{
  491. $smybol = "btc";
  492. }
  493. }else{
  494. $smybol = "btc";
  495. }
  496. $market = $smybol."usdt";
  497. $upmarket = strtoupper($smybol)."/USDT";
  498. $this->assign('upmarket',$upmarket);
  499. $this->assign('market',$market);
  500. $this->assign('smybol',$smybol);
  501. //获取合约设置项
  502. $hyset = M("hysetting")->where(array('id'=>1))->field("hy_time,hy_ykbl,hy_tzed")->find();
  503. $hy_time = $hyset['hy_time'];
  504. $hy_ykbl = $hyset['hy_ykbl'];
  505. $hy_tzed = $hyset['hy_tzed'];
  506. $time_arr = explode(',',$hy_time);
  507. $ykbl_arr = explode(',',$hy_ykbl);
  508. $tzed_arr = explode(',',$hy_tzed);
  509. $cd=array();
  510. $ed=array();
  511. $len = count($time_arr);
  512. for($i=0;$i<$len;$i++){
  513. $cd[$i]['sort'] = $i+1;
  514. $cd[$i]['time'] = $time_arr[$i];
  515. $cd[$i]['ykbl'] = $ykbl_arr[$i];
  516. $ed[$i]['sort'] = $i+1;
  517. $ed[$i]['tzed'] = $tzed_arr[$i];
  518. }
  519. $this->assign("cd",$cd);
  520. $this->assign('ed',$ed);
  521. //获取会员资产
  522. $minfo = M("user_coin")->where(array('userid'=>$uid))->find();
  523. $usdt_blan = $minfo['usdt'];
  524. $this->assign('eusdt_blan',$usdt_blan);
  525. //体验金
  526. $uinfo = M("user")->where(array('id'=>$uid))->field("money")->find();
  527. $tj_money = $uinfo['money'];
  528. $this->assign('tj_money',$tj_money);
  529. $this->display();
  530. }
  531. }
  532. ?>