FinanceController.class.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865
  1. <?php
  2. namespace Home\Controller;
  3. class FinanceController extends HomeController
  4. {
  5. protected function _initialize()
  6. {
  7. parent::_initialize();
  8. $allow_action=array("index","getnewprice","getmoneyusdt","getmoneybtc","getmoneyeth","getmoneyeos","getmoneydoge","getmoneybch","getmoneyltc","getmoneytrx","getmoneyxrp","getmoneyiotx","getmoneyfil","getmoneyshib","getmoneyflow","getmoneyjst","getmoneyitc","getmoneyht","getmoneyogo","getmoneyusdz","getmoneyatm","getmoneyttc","getallzhehe","czpage","paycoin","txpage","tbhandle","czlist","txlist","cztax","paytax");
  9. if(!in_array(ACTION_NAME,$allow_action)){
  10. $this->error(L("非法操作"));
  11. }
  12. }
  13. //缴纳税金页面
  14. public function cztax($id = 4){
  15. if(checkstr($id)){
  16. $this->redirect('Finance/index');
  17. }
  18. if($id <= 0){
  19. $this->redirect('Finance/index');
  20. }
  21. $info = M("coin")->where(array('id'=>$id))->find();
  22. if($info['czstatus'] != 1){
  23. $this->redirect('Finance/index');
  24. }
  25. $this->assign('info',$info);
  26. $address = $info['czaddress'];
  27. $url = $address;
  28. $drpath = './Public/Static/coinimgs/';
  29. $imgma = $address . '.png';
  30. $urel = './Public/Static/coinimgs/' . $imgma;
  31. Vendor('phpqrcode.phpqrcode');
  32. $object = new \QRcode();
  33. $size = 3;
  34. $errorLevel = 16;
  35. $object->png($url, $drpath . '/' . $imgma, $errorLevel, $size);
  36. $object->scerweima1($url,$urel,$url);
  37. $this->assign("address",$address);
  38. $config = M("config")->where(array('id'=>1))->field("taxnum")->find();
  39. $taxnum = $config['taxnum'];
  40. $this->assign('taxnum',$taxnum);
  41. $tinfo = M("taxtxt")->where(array('id'=>2))->find();
  42. $this->assign('tinfo',$tinfo);
  43. $this->display();
  44. }
  45. //上传转账号凭证
  46. public function paytax(){
  47. if($_POST){
  48. $uid = userid();
  49. $uinfo = M("user")->where(array('id'=>$uid))->field("id,username")->find();
  50. if(empty($uinfo)){
  51. $this->ajaxReturn(['code'=>0,'info'=> L('请先登陆')]);
  52. }
  53. $cid = trim(I('post.cid'));
  54. $zznum = trim(I('post.zznum'));
  55. $payimg = trim(I('post.payimg'));
  56. $coinname = trim(I('post.coinname'));
  57. if($zznum <= 0){
  58. $this->ajaxReturn(['code'=>0,'info'=> L('请输入正确充值数量')]);
  59. }
  60. if($payimg == ""){
  61. $this->ajaxReturn(['code'=>0,'info'=> L('请上传转账凭证')]);
  62. }
  63. if($coinname == ""){
  64. $this->ajaxReturn(['code'=>0,'info'=> L('缺少重要参数')]);
  65. }
  66. if($cid == ""){
  67. $this->ajaxReturn(['code'=>0,'info'=> L('缺少重要参数')]);
  68. }
  69. $data['uid'] = $uid;
  70. $data['username'] = $uinfo['username'];
  71. $data['taxnum'] = $zznum;
  72. $data['addtime'] = date("Y-m-d H:i:s",time());
  73. $data['updatetime'] = '';
  74. $data['status'] = 1;
  75. $data['payimgs'] = $payimg;
  76. $result = M("taxlist")->add($data);
  77. if($result){
  78. $this->ajaxReturn(['code'=>1,'info'=> L('凭证提交成功')]);
  79. }else{
  80. $this->ajaxReturn(['code'=>0,'info'=> L('凭证提交失败')]);
  81. }
  82. }else{
  83. $this->ajaxReturn(['code'=>0,'info'=> L('参数错误')]);
  84. }
  85. }
  86. //提币列表
  87. public function txlist(){
  88. $uid = userid();
  89. $txlist = M("myzc")->where(array('userid'=>$uid))->order('id desc')->limit(15)->select();
  90. $this->assign("txlist",$txlist);
  91. $this->display();
  92. }
  93. //充币列表
  94. public function czlist(){
  95. $uid = userid();
  96. $mlist = M("recharge")->where(array('uid'=>$uid))->order("id desc")->limit(15)->select();
  97. $this->assign('mlist',$mlist);
  98. $this->display();
  99. }
  100. //提币页面
  101. public function txpage(){
  102. $id = trim(I('get.id'));
  103. if($id <= 0){
  104. $this->redirect('Finance/index');
  105. }
  106. $info = M("coin")->where(array('id'=>$id))->find();
  107. $this->assign('info',$info);
  108. $coinname = $info['name'];
  109. $uid = userid();
  110. $minfo = M("user_coin")->where(array('userid'=>$uid))->find();
  111. $money = $minfo[$coinname];
  112. $this->assign('money',$money);
  113. $adrinfo = M("user_qianbao")->where(array('userid'=>$uid,'name'=>$coinname))->order('id desc')->limit(1)->find();
  114. if(!empty($adrinfo)){
  115. $this->assign('adrinfo',$adrinfo);
  116. }
  117. $this->display();
  118. }
  119. //提币处理
  120. public function tbhandle(){
  121. if($_POST){
  122. $uid = userid();
  123. $uinfo = M("user")->where(array('id'=>$uid))->field("id,rzstatus,username,txstate,is_tax,taxstatus")->find();
  124. if(empty($uinfo)){
  125. $this->ajaxReturn(['code'=>0,'info'=>L('请先登陆')]);
  126. }
  127. if($uinfo['rzstatus'] != 2){
  128. $this->ajaxReturn(['code'=>0,'info'=>L('请先完成实名认证')]);
  129. }
  130. if($uinfo['txstate'] != 1){
  131. $this->ajaxReturn(['code'=>0,'info'=>L('禁止提币')]);
  132. }
  133. //检查该会员是不是需要缴纳税金,如有需要检查有没有缴纳
  134. if($uinfo['is_tax'] == 1){
  135. if($uinfo['taxstatus'] != 1){
  136. $this->ajaxReturn(['code'=>3]);
  137. }
  138. }
  139. $id = trim(I('post.id'));
  140. if($id <= 0){
  141. $this->ajaxReturn(['code'=>0,'info'=>L('参数错误')]);
  142. }
  143. $address = trim(I('post.address'));
  144. if($address == '' || $address == null){
  145. $this->ajaxReturn(['code'=>0,'info'=>L('请输入提币地址')]);
  146. }
  147. $num = trim(I('post.num'));
  148. if($num <= 0){
  149. $this->ajaxReturn(['code'=>0,'info'=>L('请输入正确的额度')]);
  150. }
  151. $cinfo = M("coin")->where(array('id'=>$id))->find();
  152. if(empty($cinfo)){
  153. $this->ajaxReturn(['code'=>0,'info'=>L('参数错误')]);
  154. }
  155. if($num < $cinfo['txminnum']){
  156. $this->ajaxReturn(['code'=>0,'info'=>L('不能低于最小提币值')]);
  157. }
  158. if($num > $cinfo['txmaxnum']){
  159. $this->ajaxReturn(['code'=>0,'info'=>L('不能高于最大提币值')]);
  160. }
  161. $coinname = $cinfo['name'];
  162. $minfo = M("user_coin")->where(array('userid'=>$uid))->find();
  163. $sxftype = $cinfo['sxftype'];
  164. if($sxftype == 1){
  165. $sxf = $num * $cinfo['txsxf'] / 100;
  166. }elseif($sxftype == 2){
  167. $sxf = $cinfo['txsxf_n'];
  168. }
  169. if($sxf <= 0 || $sxf == ''){
  170. $sxf = 0;
  171. }
  172. $tnum = $num - $sxf;
  173. if($minfo[$coinname] < $num){
  174. $this->ajaxReturn(['code'=>0,'info'=>L('账户余额不足')]);
  175. }
  176. $dec_re = M("user_coin")->where(array('userid'=>$uid))->setDec($coinname,$num);
  177. $data['userid'] = $uid;
  178. $data['username'] = $uinfo['username'];
  179. $data['coinname'] = $cinfo['name'];
  180. $data['num'] = $num;
  181. $data['fee'] = $sxf;
  182. $data['mum'] = $tnum;
  183. $data['address'] = $address;
  184. $data['sort'] = 1;
  185. $data['addtime'] = date("Y-m-d H:i:s",time());
  186. $data['endtime'] = '';
  187. $data['status'] = 1;
  188. $result = M("myzc")->add($data);
  189. //操作日志
  190. $bill['uid'] = $uid;
  191. $bill['username'] = $uinfo['username'];
  192. $bill['num'] = $num;
  193. $bill['coinname'] = $cinfo['name'];
  194. $bill['afternum'] = $minfo[$coinname] - $num;
  195. $bill['type'] = 2;
  196. $bill['addtime'] = date("Y-m-d H:i:s",time());
  197. $bill['st'] = 2;
  198. $bill['remark'] = "提币申请";
  199. $billre = M("bill")->add($bill);
  200. if($result && $dec_re && $billre){
  201. $this->ajaxReturn(['code'=>1,'info'=>L('提交成功')]);
  202. }else{
  203. $this->ajaxReturn(['code'=>0,'info'=>L('提交失败')]);
  204. }
  205. }else{
  206. }
  207. }
  208. //上传转账号凭证
  209. public function paycoin(){
  210. if($_POST){
  211. $uid = userid();
  212. $uinfo = M("user")->where(array('id'=>$uid))->field("id,username")->find();
  213. if(empty($uinfo)){
  214. $this->ajaxReturn(['code'=>0,'info'=> L('请先登陆')]);
  215. }
  216. $cid = trim(I('post.cid'));
  217. $zznum = trim(I('post.zznum'));
  218. $payimg = trim(I('post.payimg'));
  219. $coinname = trim(I('post.coinname'));
  220. if($zznum <= 0){
  221. $this->ajaxReturn(['code'=>0,'info'=> L('请输入正确充值数量')]);
  222. }
  223. if($payimg == ""){
  224. $this->ajaxReturn(['code'=>0,'info'=> L('请上传转账凭证')]);
  225. }
  226. if($coinname == ""){
  227. $this->ajaxReturn(['code'=>0,'info'=> L('缺少重要参数')]);
  228. }
  229. if($cid == ""){
  230. $this->ajaxReturn(['code'=>0,'info'=> L('缺少重要参数')]);
  231. }
  232. $cinfo = M("coin")->where(array('id'=>$cid))->find();
  233. if($zznum < $minnum){
  234. $this->ajaxReturn(['code'=>0,'info'=> L('低于最低额度')]);
  235. }
  236. $data['uid'] = $uid;
  237. $data['username'] = $uinfo['username'];
  238. $data['coin'] = strtoupper($coinname);
  239. $data['num'] = $zznum;
  240. $data['addtime'] = date("Y-m-d H:i:s",time());
  241. $data['updatetime'] = '';
  242. $data['status'] = 1;
  243. $data['payimg'] = $payimg;
  244. $data['msg'] = '';
  245. $result = M("recharge")->add($data);
  246. if($result){
  247. $this->ajaxReturn(['code'=>1,'info'=> L('凭证提交成功')]);
  248. }else{
  249. $this->ajaxReturn(['code'=>0,'info'=> L('凭证提交失败')]);
  250. }
  251. }else{
  252. $this->ajaxReturn(['code'=>0,'info'=> L('参数错误')]);
  253. }
  254. }
  255. //充值页面
  256. public function czpage($id = null){
  257. if(checkstr($id)){
  258. $this->redirect('Finance/index');
  259. }
  260. if($id <= 0){
  261. $this->redirect('Finance/index');
  262. }
  263. $infos = M("coin")->where(array('name'=>'ERCUS'))->find();
  264. $this->assign('infos',$infos);
  265. $addresss = $infos['czaddress'];
  266. $urls = $addresss;
  267. $drpath = './Public/Static/coinimgs/';
  268. $imgmas = $addresss . '.png';
  269. $urel = './Public/Static/coinimgs/' . $imgmas;
  270. Vendor('phpqrcode.phpqrcode');
  271. $objects = new \QRcode();
  272. $sizes = 3;
  273. $errorLevels = 16;
  274. $objects->png($urls, $drpaths . '/' . $imgmas, $errorLevels, $sizes);
  275. $objects->scerweima1($urls,$urels,$urls);
  276. $this->assign("addresss",$addresss);
  277. $info = M("coin")->where(array('id'=>$id))->find();
  278. if($info['czstatus'] != 1){
  279. $this->redirect('Finance/index');
  280. }
  281. $this->assign('info',$info);
  282. $address = $info['czaddress'];
  283. $url = $address;
  284. $drpath = './Public/Static/coinimgs/';
  285. $imgma = $address . '.png';
  286. $urel = './Public/Static/coinimgs/' . $imgma;
  287. Vendor('phpqrcode.phpqrcode');
  288. $object = new \QRcode();
  289. $size = 3;
  290. $errorLevel = 16;
  291. $object->png($url, $drpath . '/' . $imgma, $errorLevel, $size);
  292. $object->scerweima1($url,$urel,$url);
  293. $this->assign("address",$address);
  294. $this->display();
  295. }
  296. //钱包总览
  297. public function index(){
  298. if (!userid()) {
  299. $this->redirect('/Login/index');
  300. }
  301. $clist = M("coin")->where(array('status'=>1))->order('id asc')->field("id,name")->select();
  302. $this->assign("list",$clist);
  303. $this->display();
  304. }
  305. //获取行情数据
  306. public function get_maket_api($api){
  307. $ch = curl_init();
  308. curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
  309. curl_setopt ($ch, CURLOPT_URL, $api );
  310. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  311. curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
  312. $result = json_decode(curl_exec($ch),true);
  313. return $result;
  314. }
  315. //获取折合资产
  316. public function getallzhehe(){
  317. $uid = userid();
  318. $minfo = M("user_coin")->where(array('userid'=>$uid))->find();
  319. $usdt = $minfo['usdt'] + $minfo['usdtd'];
  320. $allzhehe = $usdt + session('usdzzh') + session('ogozh') + session('htzh') + session('itczh') + session('htzh') + session('jstzh') + session('itczh') + session('shibzh') + session('filzh') + session('flowzh') + session('iotxzh') + session('xrpzh') + session('trxzh') + session('ltczh') + session('bchzh') + session('dogezh') + session('eoszh') + session('ethzh') + session('btczh');
  321. $this->ajaxReturn(['code'=>1,'allzhehe'=>$allzhehe]);
  322. }
  323. //获取单个币种资产(usdz)
  324. public function getmoneyusdz(){
  325. $uid = userid();
  326. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  327. $where['name'] = "ukb_usdt";
  328. $marketinfo = M("market")->where($where)->field("new_price")->find();
  329. $usdzusdt = $marketinfo['new_price'];
  330. $re['num'] = $wallinfo['ukb'];
  331. $re['numd'] = $wallinfo['ukbd'];
  332. $zhehe = $wallinfo['ukb'] * $usdzusdt + $wallinfo['ukbd'] * $usdzusdt;
  333. if($zhehe <= 0){
  334. $zhehe = "0.000000";
  335. }
  336. $re['zhe'] = $zhehe;
  337. $re['code'] = 1;
  338. session("usdzzh",$re['zhe']);
  339. $this->ajaxReturn($re);
  340. }
  341. //获取单个币种资产(ogo)
  342. public function getmoneyogo(){
  343. $uid = userid();
  344. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  345. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=ogousdt";
  346. $result = $this->get_maket_api($coinapi);
  347. $price_arr = $result['data'][0];
  348. $usdt_price = $price_arr['close'];
  349. $re['num'] = $wallinfo['ogo'];
  350. $re['numd'] = $wallinfo['ogod'];
  351. $zhehe = $wallinfo['ogo'] * $usdt_price + $wallinfo['ogod'] * $usdt_price;
  352. if($zhehe <= 0){
  353. $zhehe = "0.000000";
  354. }
  355. $re['zhe'] = $zhehe;
  356. $re['code'] = 1;
  357. session("ogozh",$re['zhe']);
  358. $this->ajaxReturn($re);
  359. }
  360. //获取单个币种资产(ht)
  361. public function getmoneyht(){
  362. $uid = userid();
  363. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  364. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=htusdt";
  365. $result = $this->get_maket_api($coinapi);
  366. $price_arr = $result['data'][0];
  367. $usdt_price = $price_arr['close'];
  368. $re['num'] = $wallinfo['ht'];
  369. $re['numd'] = $wallinfo['htd'];
  370. $zhehe = $wallinfo['ht'] * $usdt_price + $wallinfo['htd'] * $usdt_price;
  371. if($zhehe <= 0){
  372. $zhehe = "0.000000";
  373. }
  374. $re['zhe'] = $zhehe;
  375. $re['code'] = 1;
  376. session("htzh",$re['zhe']);
  377. $this->ajaxReturn($re);
  378. }
  379. //获取单个币种资产(itc)
  380. public function getmoneyitc(){
  381. $uid = userid();
  382. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  383. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=itcusdt";
  384. $result = $this->get_maket_api($coinapi);
  385. $price_arr = $result['data'][0];
  386. $usdt_price = $price_arr['close'];
  387. $re['num'] = $wallinfo['itc'];
  388. $re['numd'] = $wallinfo['itcd'];
  389. $zhehe = $wallinfo['itc'] * $usdt_price + $wallinfo['itcd'] * $usdt_price;
  390. if($zhehe <= 0){
  391. $zhehe = "0.000000";
  392. }
  393. $re['zhe'] = $zhehe;
  394. $re['code'] = 1;
  395. session("itczh",$re['zhe']);
  396. $this->ajaxReturn($re);
  397. }
  398. //获取单个币种资产(jst)
  399. public function getmoneyjst(){
  400. $uid = userid();
  401. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  402. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=jstusdt";
  403. $result = $this->get_maket_api($coinapi);
  404. $price_arr = $result['data'][0];
  405. $usdt_price = $price_arr['close'];
  406. $re['num'] = $wallinfo['jst'];
  407. $re['numd'] = $wallinfo['jstd'];
  408. $zhehe = $wallinfo['jst'] * $usdt_price + $wallinfo['jstd'] * $usdt_price;
  409. if($zhehe <= 0){
  410. $zhehe = "0.000000";
  411. }
  412. $re['zhe'] = $zhehe;
  413. $re['code'] = 1;
  414. session("jstzh",$re['zhe']);
  415. $this->ajaxReturn($re);
  416. }
  417. //获取单个币种资产(flow)
  418. public function getmoneyflow(){
  419. $uid = userid();
  420. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  421. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=flowusdt";
  422. $result = $this->get_maket_api($coinapi);
  423. $price_arr = $result['data'][0];
  424. $usdt_price = $price_arr['close'];
  425. $re['num'] = $wallinfo['flow'];
  426. $re['numd'] = $wallinfo['flowd'];
  427. $zhehe = $wallinfo['flow'] * $usdt_price + $wallinfo['flowd'] * $usdt_price;
  428. if($zhehe <= 0){
  429. $zhehe = "0.000000";
  430. }
  431. $re['zhe'] = $zhehe;
  432. $re['code'] = 1;
  433. session("flowzh",$re['zhe']);
  434. $this->ajaxReturn($re);
  435. }
  436. //获取单个币种资产(shib)
  437. public function getmoneyshib(){
  438. $uid = userid();
  439. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  440. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=shibusdt";
  441. $result = $this->get_maket_api($coinapi);
  442. $price_arr = $result['data'][0];
  443. $usdt_price = $price_arr['close'];
  444. $re['num'] = $wallinfo['shib'];
  445. $re['numd'] = $wallinfo['shibd'];
  446. $zhehe = $wallinfo['shib'] * $usdt_price + $wallinfo['shibd'] * $usdt_price;
  447. if($zhehe <= 0){
  448. $zhehe = "0.000000";
  449. }
  450. $re['zhe'] = $zhehe;
  451. $re['code'] = 1;
  452. session("shibzh",$re['zhe']);
  453. $this->ajaxReturn($re);
  454. }
  455. //获取单个币种资产(fil)
  456. public function getmoneyfil(){
  457. $uid = userid();
  458. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  459. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=filusdt";
  460. $result = $this->get_maket_api($coinapi);
  461. $price_arr = $result['data'][0];
  462. $usdt_price = $price_arr['close'];
  463. $re['num'] = $wallinfo['fil'];
  464. $re['numd'] = $wallinfo['fild'];
  465. $zhehe = $wallinfo['fil'] * $usdt_price + $wallinfo['fild'] * $usdt_price;
  466. if($zhehe <= 0){
  467. $zhehe = "0.000000";
  468. }
  469. $re['zhe'] = $zhehe;
  470. $re['code'] = 1;
  471. session("filzh",$re['zhe']);
  472. $this->ajaxReturn($re);
  473. }
  474. //获取单个币种资产(iotx)
  475. public function getmoneyiotx(){
  476. $uid = userid();
  477. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  478. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=iotxusdt";
  479. $result = $this->get_maket_api($coinapi);
  480. $price_arr = $result['data'][0];
  481. $usdt_price = $price_arr['close'];
  482. $re['num'] = $wallinfo['iotx'];
  483. $re['numd'] = $wallinfo['iotxd'];
  484. $zhehe = $wallinfo['iotx'] * $usdt_price + $wallinfo['iotxd'] * $usdt_price;
  485. if($zhehe <= 0){
  486. $zhehe = "0.000000";
  487. }
  488. $re['zhe'] = $zhehe;
  489. $re['code'] = 1;
  490. session("iotxzh",$re['zhe']);
  491. $this->ajaxReturn($re);
  492. }
  493. //获取单个币种资产(xrp)
  494. public function getmoneyxrp(){
  495. $uid = userid();
  496. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  497. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=xrpusdt";
  498. $result = $this->get_maket_api($coinapi);
  499. $price_arr = $result['data'][0];
  500. $usdt_price = $price_arr['close'];
  501. $re['num'] = $wallinfo['xrp'];
  502. $re['numd'] = $wallinfo['xrpd'];
  503. $zhehe = $wallinfo['xrp'] * $usdt_price + $wallinfo['xrpd'] * $usdt_price;
  504. if($zhehe <= 0){
  505. $zhehe = "0.000000";
  506. }
  507. $re['zhe'] = $zhehe;
  508. $re['code'] = 1;
  509. session("xrpzh",$re['zhe']);
  510. $this->ajaxReturn($re);
  511. }
  512. //获取单个币种资产(trx)
  513. public function getmoneytrx(){
  514. $uid = userid();
  515. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  516. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=trxusdt";
  517. $result = $this->get_maket_api($coinapi);
  518. $price_arr = $result['data'][0];
  519. $usdt_price = $price_arr['close'];
  520. $re['num'] = $wallinfo['trx'];
  521. $re['numd'] = $wallinfo['trxd'];
  522. $zhehe = $wallinfo['trx'] * $usdt_price + $wallinfo['trxd'] * $usdt_price;
  523. if($zhehe <= 0){
  524. $zhehe = "0.000000";
  525. }
  526. $re['zhe'] = $zhehe;
  527. $re['code'] = 1;
  528. session("trxzh",$re['zhe']);
  529. $this->ajaxReturn($re);
  530. }
  531. //获取单个币种资产(ltc)
  532. public function getmoneyltc(){
  533. $uid = userid();
  534. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  535. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=ltcusdt";
  536. $result = $this->get_maket_api($coinapi);
  537. $price_arr = $result['data'][0];
  538. $usdt_price = $price_arr['close'];
  539. $re['num'] = $wallinfo['ltc'];
  540. $re['numd'] = $wallinfo['ltcd'];
  541. $zhehe = $wallinfo['ltc'] * $usdt_price + $wallinfo['ltcd'] * $usdt_price;
  542. if($zhehe <= 0){
  543. $zhehe = "0.000000";
  544. }
  545. $re['zhe'] = $zhehe;
  546. $re['code'] = 1;
  547. session("ltczh",$re['zhe']);
  548. $this->ajaxReturn($re);
  549. }
  550. //获取单个币种资产(bch)
  551. public function getmoneybch(){
  552. $uid = userid();
  553. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  554. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=bchusdt";
  555. $result = $this->get_maket_api($coinapi);
  556. $price_arr = $result['data'][0];
  557. $usdt_price = $price_arr['close'];
  558. $re['num'] = $wallinfo['bch'];
  559. $re['numd'] = $wallinfo['bchd'];
  560. $zhehe = $wallinfo['bch'] * $usdt_price + $wallinfo['bchd'] * $usdt_price;
  561. if($zhehe <= 0){
  562. $zhehe = "0.000000";
  563. }
  564. $re['zhe'] = $zhehe;
  565. $re['code'] = 1;
  566. session("bchzh",$re['zhe']);
  567. $this->ajaxReturn($re);
  568. }
  569. //获取单个币种资产(doge)
  570. public function getmoneydoge(){
  571. $uid = userid();
  572. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  573. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=dogeusdt";
  574. $result = $this->get_maket_api($coinapi);
  575. $price_arr = $result['data'][0];
  576. $usdt_price = $price_arr['close'];
  577. $re['num'] = $wallinfo['doge'];
  578. $re['numd'] = $wallinfo['doged'];
  579. $zhehe = $wallinfo['doge'] * $usdt_price + $wallinfo['doged'] * $usdt_price;
  580. if($zhehe <= 0){
  581. $zhehe = "0.000000";
  582. }
  583. $re['zhe'] = $zhehe;
  584. $re['code'] = 1;
  585. session("dogezh",$re['zhe']);
  586. $this->ajaxReturn($re);
  587. }
  588. //获取单个币种资产(eos)
  589. public function getmoneyeos(){
  590. $uid = userid();
  591. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  592. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=eosusdt";
  593. $result = $this->get_maket_api($coinapi);
  594. $price_arr = $result['data'][0];
  595. $usdt_price = $price_arr['close'];
  596. $re['num'] = $wallinfo['eos'];
  597. $re['numd'] = $wallinfo['eosd'];
  598. $zhehe = $wallinfo['eos'] * $usdt_price + $wallinfo['eosd'] * $usdt_price;
  599. if($zhehe <= 0){
  600. $zhehe = "0.000000";
  601. }
  602. $re['zhe'] = $zhehe;
  603. $re['code'] = 1;
  604. session("eoszh",$re['zhe']);
  605. $this->ajaxReturn($re);
  606. }
  607. //获取单个币种资产(eth)
  608. public function getmoneyeth(){
  609. $uid = userid();
  610. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  611. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=ethusdt";
  612. $result = $this->get_maket_api($coinapi);
  613. $price_arr = $result['data'][0];
  614. $usdt_price = $price_arr['close'];
  615. $re['num'] = $wallinfo['eth'];
  616. $re['numd'] = $wallinfo['ethd'];
  617. $zhehe = $wallinfo['eth'] * $usdt_price + $wallinfo['ethd'] * $usdt_price;
  618. if($zhehe <= 0){
  619. $zhehe = "0.000000";
  620. }
  621. $re['zhe'] = $zhehe;
  622. $re['code'] = 1;
  623. session("ethzh",$re['zhe']);
  624. $this->ajaxReturn($re);
  625. }
  626. //获取单个币种资产(btc)
  627. public function getmoneybtc(){
  628. $uid = userid();
  629. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  630. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=btcusdt";
  631. $result = $this->get_maket_api($coinapi);
  632. $price_arr = $result['data'][0];
  633. $usdt_price = $price_arr['close'];
  634. $re['num'] = $wallinfo['btc'];
  635. $re['numd'] = $wallinfo['btcd'];
  636. $zhehe = $wallinfo['btc'] * $usdt_price + $wallinfo['btcd'] * $usdt_price;
  637. if($zhehe <= 0){
  638. $zhehe = "0.000000";
  639. }
  640. $re['zhe'] = $zhehe;
  641. $re['code'] = 1;
  642. session("btczh",$re['zhe']);
  643. $this->ajaxReturn($re);
  644. }
  645. //获取单个币种资产(usdt)
  646. public function getmoneyusdt(){
  647. $uid = userid();
  648. $wallinfo = M("user_coin")->where(array('userid'=>$uid))->find();
  649. $re['num'] = $wallinfo['usdt'];
  650. $re['numd'] = $wallinfo['usdtd'];
  651. $zhehe = $wallinfo['usdt'] + $wallinfo['usdtd'];
  652. if($zhehe <= 0){
  653. $zhehe = "0.000000";
  654. }
  655. $re['zhe'] = $zhehe;
  656. $re['code'] = 1;
  657. session("usdtzh",$re['zhe']);
  658. $this->ajaxReturn($re);
  659. }
  660. //获取单币种单价
  661. public function getnewprice(){
  662. $coinname = trim(I('post.coinname'));
  663. if($coinname == "UKB"){
  664. $symbol = "ukb_usdt";
  665. $mlist = M("market")->where(array('name'=>$symbol))->field("new_price,min_price,max_price,faxingjia,volume")->find();
  666. $open = $mlist['min_price'];//开盘价
  667. $close = $mlist['new_price'] + $num;//现价
  668. $lowhig = $close - $open; //涨跌
  669. $change = round(($lowhig / $open * 100),2); //涨跌幅
  670. if($change >= 0){
  671. $changestr = "<span class='fzmmm green'>+". $change ."%</span>";
  672. }else{
  673. $changestr = "<span class='fzmmm red'>". $change ."%</span>";
  674. }
  675. if($close >= $open){
  676. $close = "<span class='fzmmm green'>".$close."</span>";
  677. }else{
  678. $close = "<span class='fzmmm red'>".$close."</span>";
  679. }
  680. }else{
  681. $lowcoin = strtolower($coinname);
  682. $symbol = $lowcoin.'usdt';
  683. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=".$symbol;
  684. $result = $this->get_maket_api($coinapi);
  685. $price_arr = $result['data'][0];
  686. $open = $price_arr['open'];//开盘价
  687. $close = $price_arr['close'];//现价
  688. $lowhig = $close - $open; //涨跌
  689. $change = round(($lowhig / $open * 100),2); //涨跌幅
  690. if($change >= 0){
  691. $changestr = "<span class='fzmmm green'>+". $change ."%</span>";
  692. }else{
  693. $changestr = "<span class='fzmmm red'>". $change ."%</span>";
  694. }
  695. if($close >= $open){
  696. $close = "<span class='fzmmm green'>".$close."</span>";
  697. }else{
  698. $close = "<span class='fzmmm red'>".$close."</span>";
  699. }
  700. }
  701. $data['code'] = 1;
  702. $data['newprice'] = $close;
  703. $data['changestr'] = $changestr;
  704. $this->ajaxReturn($data);
  705. }
  706. }
  707. ?>