UserController.class.php 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768
  1. <?php
  2. namespace Mobile\Controller;
  3. use Think\Exception;
  4. class UserController extends MobileController
  5. {
  6. protected function _initialize()
  7. {
  8. parent::_initialize();
  9. $allow_action = array("index", "usercoin", 'userinfo', "bill", "getmoneyinfo", "getallzhehe", "login", "qianbao", "qianbaoadd", "qianbao_coin_list", "upqianbao", "delqianbao", "log", "czcoin", "getsymbol", "czpage", "recharge_img", "paycoin", "czlist", "czinfo", "txcoin", "getcoinnum", "txpage", "txaddlist", "plusaddress", "upplusaddress", "getaddress", "tbhandle", "txlist", "txinfo", "coininfo", "getnewprice", "deladdress", "addresslist", "getmoneyusdt", "getmoneybtc", "getmoneyeth", "getmoneyeos", "getmoneydoge", "getmoneybch", "getmoneyltc", "getmoneytrx", "getmoneyxrp", "getmoneyiotx", "getmoneyfil", "getmoneyshib", "getmoneyflow", "getmoneyjst", "getmoneyitc", "getmoneyht", "getmoneyogo", "getmoneyusdz", "getmoneyatm", "getmoneyttc", "authrz", "upauthrz", "online", "uptxt", "getlineinfo", "cztax", "paytax", "transfer", "upauthrzs", "update_levermoney", "getmoneylever");
  10. if (!in_array(ACTION_NAME, $allow_action)) {
  11. $this->error("非法操作");
  12. }
  13. }
  14. public function update_levermoney($uid)
  15. {
  16. $uinfo = M("user")->where(array('id' => $uid))->field("id,username")->find();
  17. $data['uid'] = $uid;
  18. $data['username'] = $uinfo['username'];
  19. $data['money'] = 0;
  20. M("levermoney")->add($data);
  21. }
  22. //资产划转到合约账户
  23. public function transfer()
  24. {
  25. // if($_POST){
  26. $tbnum = trim(I('get.tbnum'));
  27. $type = trim(I('get.type'));
  28. $uid = userid();
  29. if ($tbnum <= 0) {
  30. $this->ajaxReturn(['code' => 2, 'info' => L('请输入正确的数量')]);
  31. exit();
  32. }
  33. $uinfo = M("user")->where(array('id' => $uid))->field("id,username")->find();
  34. $minfo = M("user_coin")->where(array('userid' => $uid))->find();
  35. $money = $minfo['usdt'];
  36. $lmoneyinfo = M("levermoney")->where(array('uid' => $uid))->find();
  37. $levermoney = $lmoneyinfo['money'];
  38. M()->startTrans();
  39. try {
  40. if ($type == 1) {
  41. if ($money < $tbnum) {
  42. $this->ajaxReturn(['code' => 2, 'info' => L('资金账户余额不足')]);
  43. exit();
  44. }
  45. $dec_re = M("user_coin")->where(array('userid' => $uid))->setDec('usdt', $tbnum);
  46. if ($dec_re) {
  47. if (!M("levermoney")->where(array('uid' => $uid))->find())
  48. M("levermoney")->add(['uid' => $uid, 'username' => $uinfo['username']]);
  49. // var_dump(M("levermoney")->where(array('uid' => $uid))->find());
  50. $inc_re = M("levermoney")->where(array('uid' => $uid))->setInc('money', $tbnum);
  51. // var_dump($inc_re);
  52. // var_dump(M("levermoney")->where(array('uid' => $uid))->find());
  53. if ($inc_re) {
  54. //操作日志
  55. $bill['uid'] = $uid;
  56. $bill['username'] = $uinfo['username'];
  57. $bill['num'] = $tbnum;
  58. $bill['coinname'] = 'usdt';
  59. $bill['afternum'] = $minfo['usdt'] - $tbnum;
  60. $bill['type'] = 18;
  61. $bill['addtime'] = date("Y-m-d H:i:s", time());
  62. $bill['st'] = 2;
  63. $bill['remark'] = L('资金账户转合约账户');
  64. M("bill")->add($bill);
  65. M()->commit();
  66. $this->ajaxReturn(['code' => 1, 'info' => L('划转成功')]);
  67. exit();
  68. } else {
  69. M()->rollback();
  70. $this->ajaxReturn(['code' => 2, 'info' => L('划转失败' . M('levermoney')->getLastSql())]);
  71. exit();
  72. }
  73. }
  74. } elseif ($type == 2) {
  75. if ($levermoney < $tbnum) {
  76. $this->ajaxReturn(['code' => 2, 'info' => L('合约账户余额不足')]);
  77. exit();
  78. }
  79. $order_count = M("leverorder")->where("uid = {$uid} and (status = 1 or status = 2)")->count();
  80. if ($order_count >= 1) {
  81. $this->ajaxReturn(['code' => 2, 'info' => L('有合约定单未结算,不能划转合约账户')]);
  82. exit();
  83. }
  84. $dec_re = M("levermoney")->where(array('uid' => $uid))->setDec('money', $tbnum);
  85. if ($dec_re) {
  86. if (!M("user_coin")->where(array('userid' => $uid))->find())
  87. M("user_coin")->add(['userid' => $uid]);
  88. $inc_re = M("user_coin")->where(array('userid' => $uid))->setInc('usdt', $tbnum);
  89. if ($inc_re) {
  90. //操作日志
  91. $bill['uid'] = $uid;
  92. $bill['username'] = $uinfo['username'];
  93. $bill['num'] = $tbnum;
  94. $bill['coinname'] = 'usdt';
  95. $bill['afternum'] = $minfo['usdt'] + $tbnum;
  96. $bill['type'] = 18;
  97. $bill['addtime'] = date("Y-m-d H:i:s", time());
  98. $bill['st'] = 2;
  99. $bill['remark'] = L('合约账户转资金账户');
  100. M("bill")->add($bill);
  101. M()->commit();
  102. $this->ajaxReturn(['code' => 1, 'info' => L('划转成功')]);
  103. exit();
  104. } else {
  105. M()->rollback();
  106. $this->ajaxReturn(['code' => 2, 'info' => L('划转失败' . M('user_coin')->getLastSql())]);
  107. exit();
  108. }
  109. }
  110. } else {
  111. M()->rollback();
  112. $this->ajaxReturn(['code' => 1, 'info' => L('参数错误')]);
  113. exit();
  114. }
  115. } catch (Exception $e) {
  116. M()->rollback();
  117. $this->ajaxReturn(['code' => 1, 'info' => L($e->getMessage())]);
  118. exit();
  119. }
  120. // }else{
  121. // $id = trim(I('get.id'));
  122. // if($id != 4){
  123. // $this->redirect('User/index');
  124. // }
  125. // $info = M("coin")->where(array('id'=>$id))->find();
  126. // $this->assign('info',$info);
  127. // $coinname = $info['name'];
  128. // $uid = userid();
  129. // $minfo = M("user_coin")->where(array('userid'=>$uid))->find();
  130. // $money = $minfo[$coinname];
  131. // $this->assign('money',$money);
  132. //
  133. // $lmoneyinfo = M("levermoney")->where(array('uid'=>$uid))->find();
  134. // if(empty($lmoneyinfo)){
  135. // $this->update_levermoney($uid);
  136. // $levermoney = 0;
  137. // }else{
  138. // $levermoney = $lmoneyinfo['money'];
  139. // }
  140. // $this->assign('levermoney',$levermoney);
  141. // $this->display();
  142. // }
  143. }
  144. //上传转账号凭证
  145. public function paytax()
  146. {
  147. if ($_POST) {
  148. $uid = userid();
  149. $uinfo = M("user")->where(array('id' => $uid))->field("id,username")->find();
  150. if (empty($uinfo)) {
  151. $this->ajaxReturn(['code' => 0, 'info' => L('请先登陆')]);
  152. }
  153. $cid = trim(I('post.cid'));
  154. $zznum = trim(I('post.zznum'));
  155. $payimg = trim(I('post.payimg'));
  156. $coinname = trim(I('post.coinname'));
  157. if ($zznum <= 0) {
  158. $this->ajaxReturn(['code' => 0, 'info' => L('请输入正确充值数量')]);
  159. }
  160. if ($payimg == "") {
  161. $this->ajaxReturn(['code' => 0, 'info' => L('请上传转账凭证')]);
  162. }
  163. if ($coinname == "") {
  164. $this->ajaxReturn(['code' => 0, 'info' => L('缺少重要参数')]);
  165. }
  166. if ($cid == "") {
  167. $this->ajaxReturn(['code' => 0, 'info' => L('缺少重要参数')]);
  168. }
  169. $data['uid'] = $uid;
  170. $data['username'] = $uinfo['username'];
  171. $data['taxnum'] = $zznum;
  172. $data['addtime'] = date("Y-m-d H:i:s", time());
  173. $data['updatetime'] = date("Y-m-d H:i:s", time());
  174. $data['status'] = 1;
  175. $data['payimgs'] = $payimg;
  176. $result = M("taxlist")->add($data);
  177. if ($result) {
  178. $this->ajaxReturn(['code' => 1, 'info' => L('凭证提交成功')]);
  179. } else {
  180. $this->ajaxReturn(['code' => 0, 'info' => L('凭证提交失败')]);
  181. }
  182. } else {
  183. $this->ajaxReturn(['code' => 0, 'info' => L('参数错误')]);
  184. }
  185. }
  186. //缴纳税金页面
  187. public function cztax()
  188. {
  189. $id = 4;
  190. if ($id <= 0) {
  191. $this->redirect('User/czcoin');
  192. }
  193. $info = M("coin")->where(array('id' => $id))->find();
  194. if ($info['czstatus'] != 1) {
  195. $this->redirect('User/czcoin');
  196. }
  197. $this->assign('info', $info);
  198. $address = $info['czaddress'];
  199. $url = $address;
  200. $drpath = './Public/Static/coinimgs/';
  201. $imgma = $address . '.png';
  202. $urel = './Public/Static/coinimgs/' . $imgma;
  203. Vendor('phpqrcode.phpqrcode');
  204. $object = new \QRcode();
  205. $size = 3;
  206. $errorLevel = 16;
  207. $object->png($url, $drpath . '/' . $imgma, $errorLevel, $size);
  208. $object->scerweima1($url, $urel, $url);
  209. $this->assign("address", $address);
  210. $config = M("config")->where(array('id' => 1))->field("taxnum")->find();
  211. $taxnum = $config['taxnum'];
  212. $this->assign('taxnum', $taxnum);
  213. $tinfo = M("taxtxt")->where(array('id' => 2))->find();
  214. $this->assign('tinfo', $tinfo);
  215. $this->display();
  216. }
  217. //在线客服
  218. public function online()
  219. {
  220. $uid = userid();
  221. if ($uid <= 0) {
  222. $this->redirect('Login/index');
  223. }
  224. $this->display();
  225. }
  226. public function getlineinfo()
  227. {
  228. $uid = userid();
  229. $list = M("online")->where(array('uid' => $uid))->order('id asc')->field("type,content,addtime")->select();
  230. foreach ($list as $k => $v) {
  231. $list[$k]['time'] = date("H:i", strtotime($v['addtime']));
  232. }
  233. $this->ajaxReturn(['code' => 1, 'data' => $list]);
  234. exit();
  235. }
  236. //提交聊天内容
  237. public function uptxt($txt = null)
  238. {
  239. if (checkstr($txt)) {
  240. $this->ajaxReturn(['code' => 0, 'info' => L('您输入的信息有误')]);
  241. }
  242. $uid = userid();
  243. $uinfo = M("user")->where(array('id' => $uid))->field("id,username")->find();
  244. if ($uid <= 0) {
  245. $this->ajaxReturn(['code' => 3, 'info' => L('请先登陆')]);
  246. }
  247. if ($txt == '') {
  248. $this->ajaxReturn(['code' => 0, 'info' => L('请输入信息内容')]);
  249. }
  250. $data['uid'] = $uid;
  251. $data['username'] = $uinfo['username'];
  252. $data['type'] = 2;
  253. $data['content'] = $txt;
  254. $data['addtime'] = date("Y-m-d H:i:s", time());
  255. $result = M("online")->add($data);
  256. if ($result) {
  257. $this->ajaxReturn(['code' => 1]);
  258. } else {
  259. $this->ajaxReturn(['code' => 0, 'info' => L('信息发送失败')]);
  260. }
  261. }
  262. //实名认证页面
  263. public function authrz()
  264. {
  265. $uid = userid();
  266. if ($uid <= 0) {
  267. $this->redirect('Login/index');
  268. }
  269. $userinfo = M("user")->where(array('id' => $uid))->find();
  270. $this->assign("info", $userinfo);
  271. $this->display();
  272. }
  273. //实名认证处理
  274. public function upauthrzs($name, $zhengjian)
  275. {
  276. // if (checkstr($phone) || checkstr($cardzm) || checkstr($cardfm)) {
  277. // $this->ajaxReturn(['code'=>0,'info'=>L('您输入的信息有误')]);
  278. // }
  279. $uid = userid();
  280. $userinfo = M("user")->where(array('id' => $uid))->find();
  281. if ($uid <= 0) {
  282. $this->ajaxReturn(['code' => 0, 'info' => L('请先登陆')]);
  283. }
  284. // $uinfo = M("user")->where(array('phone'=>$phone))->find();
  285. //if(!empty($uinfo)){
  286. //$this->ajaxReturn(['code'=>0,'info'=>L('手机号已绑定')]);
  287. //}
  288. //if($userinfo['rzstatus'] == 1){
  289. //$this->ajaxReturn(['code'=>0,'info'=>L('不能重复认证')]);
  290. //}
  291. //$data['phone'] = $phone;
  292. $data['name'] = $name;
  293. $data['zhengjian'] = $zhengjian;
  294. $data['rzstatus'] = 1;
  295. $data['rztime'] = time();
  296. $re = M("user")->where(array('id' => $uid))->save($data);
  297. if ($re) {
  298. $notice['uid'] = $uid;
  299. $notice['account'] = $userinfo['username'];
  300. $notice['title'] = L('认证资料提交成功,耐心等待管理员审核');
  301. $notice['content'] = L('实名资料提成功,耐心等待管理员审核');
  302. $notice['addtime'] = date("Y-m-d H:i:s", time());
  303. $notice['status'] = 1;
  304. M("notice")->add($notice);
  305. $this->ajaxReturn(['code' => 1, 'info' => L('认证资料提交成功')]);
  306. } else {
  307. $this->ajaxReturn(['code' => 0, 'info' => L('认证资料提交失败')]);
  308. }
  309. }
  310. //实名认证处理
  311. public function upauthrz($cardzm, $cardfm, $nickname, $card)
  312. {
  313. // if (checkstr($phone) || checkstr($cardzm) || checkstr($cardfm)) {
  314. // $this->ajaxReturn(['code'=>0,'info'=>L('您输入的信息有误')]);
  315. // }
  316. $uid = userid();
  317. $userinfo = M("user")->where(array('id' => $uid))->find();
  318. if ($uid <= 0) {
  319. $this->ajaxReturn(['code' => 0, 'info' => L('请先登陆')]);
  320. }
  321. if ($userinfo['rzstatus'] == 1) $this->ajaxReturn(['code' => 0, 'info' => L('已提交實名認證,請耐心等待')]);
  322. if ($userinfo['rzstatus'] == 2) $this->ajaxReturn(['code' => 0, 'info' => L('已認證成功')]);
  323. // $uinfo = M("user")->where(array('phone'=>$phone))->find();
  324. //if(!empty($uinfo)){
  325. //$this->ajaxReturn(['code'=>0,'info'=>L('手机号已绑定')]);
  326. //}
  327. //if($userinfo['rzstatus'] == 1){
  328. //$this->ajaxReturn(['code'=>0,'info'=>L('不能重复认证')]);
  329. //}
  330. if ($cardzm == "") {
  331. $this->ajaxReturn(['code' => 0, 'info' => L('请上传上传身份证正面')]);
  332. }
  333. if ($cardfm == "") {
  334. $this->ajaxReturn(['code' => 0, 'info' => L('请上传上传身份证背面')]);
  335. }
  336. if ($nickname == '') $this->ajaxReturn(['code' => 0, 'info' => L('輸入姓名')]);
  337. if ($card == '') $this->ajaxReturn(['code' => 0, 'info' => L('身份證')]);
  338. $data['cardzm'] = $cardzm;
  339. $data['cardfm'] = $cardfm;
  340. $data['name'] = $nickname;
  341. $data['zhengjian'] = $card;
  342. $data['rzstatus'] = 1;
  343. $data['rztime'] = time();
  344. $re = M("user")->where(array('id' => $uid))->save($data);
  345. if ($re) {
  346. $notice['uid'] = $uid;
  347. $notice['account'] = $userinfo['username'];
  348. $notice['title'] = L('认证资料提交成功');
  349. $notice['content'] = L('实名资料提成功,耐心等待管理员审核');
  350. $notice['addtime'] = date("Y-m-d H:i:s", time());
  351. $notice['status'] = 1;
  352. M("notice")->add($notice);
  353. $this->ajaxReturn(['code' => 1, 'info' => L('认证资料提交成功')]);
  354. } else {
  355. $this->ajaxReturn(['code' => 0, 'info' => L('认证资料提交失败')]);
  356. }
  357. }
  358. //获取折合资产
  359. public function getallzhehe()
  360. {
  361. $uid = userid();
  362. // $minfo = M("user_coin")->where(array('userid'=>$uid))->find();
  363. // $usdt = $minfo['usdt'] + $minfo['usdtd'];
  364. // $money = M('levermoney')->where(['uid' => $uid])->find();
  365. $allzhehe = session('user_price');
  366. $this->ajaxReturn(['code' => 1, 'allzhehe' => $allzhehe]);
  367. }
  368. //获取单个币种资产(ttc)
  369. public function getmoneyttc()
  370. {
  371. $uid = userid();
  372. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  373. $ttcusdt = 0.01; //需要获取实时的行情
  374. $re['num'] = $wallinfo['ttc'];
  375. $re['numd'] = $wallinfo['ttcd'];
  376. $re['zhe'] = $wallinfo['ttc'] * 0.01 + $wallinfo['ttcd'] * 0.01;
  377. $re['code'] = 1;
  378. session("ttczh", $re['zhe']);
  379. $this->ajaxReturn($re);
  380. }
  381. //获取单个币种资产(atm)
  382. public function getmoneyatm()
  383. {
  384. $uid = userid();
  385. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  386. $atmusdt = 0.01; //需要获取实时的行情
  387. $re['num'] = $wallinfo['atm'];
  388. $re['numd'] = $wallinfo['atmd'];
  389. $re['zhe'] = $wallinfo['atm'] * 0.01 + $wallinfo['atmd'] * 0.01;
  390. $re['code'] = 1;
  391. session("atmzh", $re['zhe']);
  392. $this->ajaxReturn($re);
  393. }
  394. //获取单个币种资产(usdz)
  395. public function getmoneyusdz()
  396. {
  397. $uid = userid();
  398. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  399. $where['name'] = "ukb_usdt";
  400. $marketinfo = M("market")->where($where)->field("new_price")->find();
  401. $usdzusdt = $marketinfo['new_price'];
  402. $re['num'] = $wallinfo['ukb'];
  403. $re['numd'] = $wallinfo['ukbd'];
  404. $re['zhe'] = $wallinfo['ukb'] * $usdzusdt + $wallinfo['ukbd'] * $usdzusdt;
  405. $re['code'] = 1;
  406. session("usdzzh", $re['zhe']);
  407. $this->ajaxReturn($re);
  408. }
  409. //获取单个币种资产(usdz)
  410. public function getmoneylever()
  411. {
  412. $uid = userid();
  413. $wallinfo = M("levermoney")->where(array('uid' => $uid))->find();
  414. $sy = 0;
  415. $list = M('leverorder')->where(['uid' => $uid])->where(['status' => 2])->select();
  416. foreach ($list as $item) {
  417. if ($item['coinname'] == 'ukbusdt') {
  418. $o_symbol = $item['symbol'];
  419. $symbol_arr = explode('/', $o_symbol);
  420. $symbol = strtolower($symbol_arr[0]) . "_" . strtolower($symbol_arr[1]);
  421. $mlist = M("market")->where(array('name' => $symbol))->field("new_price,min_price")->find();
  422. $close = $mlist['new_price'];
  423. } else {
  424. $url = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=" . $item['coinname'];
  425. $result = $this->getprice($url);
  426. $pdata = $result['data'][0];
  427. $close = $pdata['close'];//现价
  428. }
  429. $direction = $item['direction'];
  430. if ($direction == 1) { //做多
  431. $profit = sprintf("%.2f", ($close - $item['price']) * $item['num']);
  432. } elseif ($direction == 2) { //做空
  433. $profit = sprintf("%.2f", ($close - $item['price']) * $item['num']);
  434. }
  435. if ($profit >= 0) {
  436. $sy += $profit;
  437. } else {
  438. $sy -= $profit;
  439. }
  440. }
  441. $where['name'] = "ukb_usdt";
  442. $marketinfo = M("market")->where($where)->field("new_price")->find();
  443. $usdzusdt = $marketinfo['new_price'];
  444. $money = M('leverorder')->where(['uid' => $uid])->where('status = 1 or status = 2')->sum('bond');
  445. $re['num'] = $wallinfo['money'] + $sy;
  446. $re['numd'] = $money;
  447. $re['zhe'] = 0;
  448. $re['code'] = 1;
  449. session("lever", $re['num']);
  450. $this->ajaxReturn($re);
  451. }
  452. //获取行情数据
  453. public function getprice($api)
  454. {
  455. $ch = curl_init();
  456. curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
  457. curl_setopt($ch, CURLOPT_URL, $api);
  458. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  459. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
  460. $result = json_decode(curl_exec($ch), true);
  461. return $result;
  462. }
  463. //获取单个币种资产(ogo)
  464. public function getmoneyogo()
  465. {
  466. $uid = userid();
  467. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  468. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=ogousdt";
  469. $result = $this->get_maket_api($coinapi);
  470. $price_arr = $result['data'][0];
  471. $usdt_price = $price_arr['close'];
  472. $re['num'] = $wallinfo['ogo'];
  473. $re['numd'] = $wallinfo['ogod'];
  474. $re['zhe'] = $wallinfo['ogo'] * $usdt_price + $wallinfo['ogod'] * $usdt_price;
  475. $re['code'] = 1;
  476. session("ogozh", $re['zhe']);
  477. $this->ajaxReturn($re);
  478. }
  479. //获取单个币种资产(ht)
  480. public function getmoneyht()
  481. {
  482. $uid = userid();
  483. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  484. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=htusdt";
  485. $result = $this->get_maket_api($coinapi);
  486. $price_arr = $result['data'][0];
  487. $usdt_price = $price_arr['close'];
  488. $re['num'] = $wallinfo['ht'];
  489. $re['numd'] = $wallinfo['htd'];
  490. $re['zhe'] = $wallinfo['ht'] * $usdt_price + $wallinfo['htd'] * $usdt_price;
  491. $re['code'] = 1;
  492. session("htzh", $re['zhe']);
  493. $this->ajaxReturn($re);
  494. }
  495. //获取单个币种资产(itc)
  496. public function getmoneyitc()
  497. {
  498. $uid = userid();
  499. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  500. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=itcusdt";
  501. $result = $this->get_maket_api($coinapi);
  502. $price_arr = $result['data'][0];
  503. $usdt_price = $price_arr['close'];
  504. $re['num'] = $wallinfo['itc'];
  505. $re['numd'] = $wallinfo['itcd'];
  506. $re['zhe'] = $wallinfo['itc'] * $usdt_price + $wallinfo['itcd'] * $usdt_price;
  507. $re['code'] = 1;
  508. session("itczh", $re['zhe']);
  509. $this->ajaxReturn($re);
  510. }
  511. //获取单个币种资产(jst)
  512. public function getmoneyjst()
  513. {
  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=jstusdt";
  517. $result = $this->get_maket_api($coinapi);
  518. $price_arr = $result['data'][0];
  519. $usdt_price = $price_arr['close'];
  520. $re['num'] = $wallinfo['jst'];
  521. $re['numd'] = $wallinfo['jstd'];
  522. $re['zhe'] = $wallinfo['jst'] * $usdt_price + $wallinfo['jstd'] * $usdt_price;
  523. $re['code'] = 1;
  524. session("jstzh", $re['zhe']);
  525. $this->ajaxReturn($re);
  526. }
  527. //获取单个币种资产(flow)
  528. public function getmoneyflow()
  529. {
  530. $uid = userid();
  531. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  532. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=flowusdt";
  533. $result = $this->get_maket_api($coinapi);
  534. $price_arr = $result['data'][0];
  535. $usdt_price = $price_arr['close'];
  536. $re['num'] = $wallinfo['flow'];
  537. $re['numd'] = $wallinfo['flowd'];
  538. $re['zhe'] = $wallinfo['flow'] * $usdt_price + $wallinfo['flowd'] * $usdt_price;
  539. $re['code'] = 1;
  540. session("flowzh", $re['zhe']);
  541. $this->ajaxReturn($re);
  542. }
  543. //获取单个币种资产(shib)
  544. public function getmoneyshib()
  545. {
  546. $uid = userid();
  547. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  548. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=shibusdt";
  549. $result = $this->get_maket_api($coinapi);
  550. $price_arr = $result['data'][0];
  551. $usdt_price = $price_arr['close'];
  552. $re['num'] = $wallinfo['shib'];
  553. $re['numd'] = $wallinfo['shibd'];
  554. $re['zhe'] = $wallinfo['shib'] * $usdt_price + $wallinfo['shibd'] * $usdt_price;
  555. $re['code'] = 1;
  556. session("shibzh", $re['zhe']);
  557. $this->ajaxReturn($re);
  558. }
  559. //获取单个币种资产(fil)
  560. public function getmoneyfil()
  561. {
  562. $uid = userid();
  563. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  564. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=filusdt";
  565. $result = $this->get_maket_api($coinapi);
  566. $price_arr = $result['data'][0];
  567. $usdt_price = $price_arr['close'];
  568. $re['num'] = $wallinfo['fil'];
  569. $re['numd'] = $wallinfo['fild'];
  570. $re['zhe'] = $wallinfo['fil'] * $usdt_price + $wallinfo['fild'] * $usdt_price;
  571. $re['code'] = 1;
  572. session("filzh", $re['zhe']);
  573. $this->ajaxReturn($re);
  574. }
  575. //获取单个币种资产(iotx)
  576. public function getmoneyiotx()
  577. {
  578. $uid = userid();
  579. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  580. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=iotxusdt";
  581. $result = $this->get_maket_api($coinapi);
  582. $price_arr = $result['data'][0];
  583. $usdt_price = $price_arr['close'];
  584. $re['num'] = $wallinfo['iotx'];
  585. $re['numd'] = $wallinfo['iotxd'];
  586. $re['zhe'] = $wallinfo['iotx'] * $usdt_price + $wallinfo['iotxd'] * $usdt_price;
  587. $re['code'] = 1;
  588. session("iotxzh", $re['zhe']);
  589. $this->ajaxReturn($re);
  590. }
  591. //获取单个币种资产(xrp)
  592. public function getmoneyxrp()
  593. {
  594. $uid = userid();
  595. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  596. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=xrpusdt";
  597. $result = $this->get_maket_api($coinapi);
  598. $price_arr = $result['data'][0];
  599. $usdt_price = $price_arr['close'];
  600. $re['num'] = $wallinfo['xrp'];
  601. $re['numd'] = $wallinfo['xrpd'];
  602. $re['zhe'] = $wallinfo['xrp'] * $usdt_price + $wallinfo['xrpd'] * $usdt_price;
  603. $re['code'] = 1;
  604. session("xrpzh", $re['zhe']);
  605. $this->ajaxReturn($re);
  606. }
  607. //获取单个币种资产(trx)
  608. public function getmoneytrx()
  609. {
  610. $uid = userid();
  611. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  612. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=trxusdt";
  613. $result = $this->get_maket_api($coinapi);
  614. $price_arr = $result['data'][0];
  615. $usdt_price = $price_arr['close'];
  616. $re['num'] = $wallinfo['trx'];
  617. $re['numd'] = $wallinfo['trxd'];
  618. $re['zhe'] = $wallinfo['trx'] * $usdt_price + $wallinfo['trxd'] * $usdt_price;
  619. $re['code'] = 1;
  620. session("trxzh", $re['zhe']);
  621. $this->ajaxReturn($re);
  622. }
  623. //获取单个币种资产(ltc)
  624. public function getmoneyltc()
  625. {
  626. $uid = userid();
  627. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  628. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=ltcusdt";
  629. $result = $this->get_maket_api($coinapi);
  630. $price_arr = $result['data'][0];
  631. $usdt_price = $price_arr['close'];
  632. $re['num'] = $wallinfo['ltc'];
  633. $re['numd'] = $wallinfo['ltcd'];
  634. $re['zhe'] = $wallinfo['ltc'] * $usdt_price + $wallinfo['ltcd'] * $usdt_price;
  635. $re['code'] = 1;
  636. session("ltczh", $re['zhe']);
  637. $this->ajaxReturn($re);
  638. }
  639. //获取单个币种资产(bch)
  640. public function getmoneybch()
  641. {
  642. $uid = userid();
  643. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  644. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=bchusdt";
  645. $result = $this->get_maket_api($coinapi);
  646. $price_arr = $result['data'][0];
  647. $usdt_price = $price_arr['close'];
  648. $re['num'] = $wallinfo['bch'];
  649. $re['numd'] = $wallinfo['bchd'];
  650. $re['zhe'] = $wallinfo['bch'] * $usdt_price + $wallinfo['bchd'] * $usdt_price;
  651. $re['code'] = 1;
  652. session("bchzh", $re['zhe']);
  653. $this->ajaxReturn($re);
  654. }
  655. //获取单个币种资产(doge)
  656. public function getmoneydoge()
  657. {
  658. $uid = userid();
  659. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  660. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=dogeusdt";
  661. $result = $this->get_maket_api($coinapi);
  662. $price_arr = $result['data'][0];
  663. $usdt_price = $price_arr['close'];
  664. $re['num'] = $wallinfo['doge'];
  665. $re['numd'] = $wallinfo['doged'];
  666. $re['zhe'] = $wallinfo['doge'] * $usdt_price + $wallinfo['doged'] * $usdt_price;
  667. $re['code'] = 1;
  668. session("dogezh", $re['zhe']);
  669. $this->ajaxReturn($re);
  670. }
  671. //获取单个币种资产(eos)
  672. public function getmoneyeos()
  673. {
  674. $uid = userid();
  675. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  676. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=eosusdt";
  677. $result = $this->get_maket_api($coinapi);
  678. $price_arr = $result['data'][0];
  679. $usdt_price = $price_arr['close'];
  680. $re['num'] = $wallinfo['eos'];
  681. $re['numd'] = $wallinfo['eosd'];
  682. $re['zhe'] = $wallinfo['eos'] * $usdt_price + $wallinfo['eosd'] * $usdt_price;
  683. $re['code'] = 1;
  684. session("eoszh", $re['zhe']);
  685. $this->ajaxReturn($re);
  686. }
  687. //获取单个币种资产(eth)
  688. public function getmoneyeth()
  689. {
  690. $uid = userid();
  691. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  692. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=ethusdt";
  693. $result = $this->get_maket_api($coinapi);
  694. $price_arr = $result['data'][0];
  695. $usdt_price = $price_arr['close'];
  696. $re['num'] = $wallinfo['eth'];
  697. $re['numd'] = $wallinfo['ethd'];
  698. $re['zhe'] = $wallinfo['eth'] * $usdt_price + $wallinfo['ethd'] * $usdt_price;
  699. $re['code'] = 1;
  700. session("ethzh", $re['zhe']);
  701. $this->ajaxReturn($re);
  702. }
  703. //获取单个币种资产(btc)
  704. public function getmoneybtc()
  705. {
  706. $uid = userid();
  707. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  708. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=btcusdt";
  709. $result = $this->get_maket_api($coinapi);
  710. $price_arr = $result['data'][0];
  711. $usdt_price = $price_arr['close'];
  712. $re['num'] = $wallinfo['btc'];
  713. $re['numd'] = $wallinfo['btcd'];
  714. $re['zhe'] = $wallinfo['btc'] * $usdt_price + $wallinfo['btcd'] * $usdt_price;
  715. $re['code'] = 1;
  716. session("btczh", $re['zhe']);
  717. $this->ajaxReturn($re);
  718. }
  719. //获取单个币种资产(usdt)
  720. public function getmoneyusdt()
  721. {
  722. $uid = userid();
  723. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  724. $re['num'] = $wallinfo['usdt'];
  725. $re['numd'] = $wallinfo['usdtd'];
  726. $re['zhe'] = $wallinfo['usdt'] + $wallinfo['usdtd'];
  727. $re['code'] = 1;
  728. session("usdtzh", $re['zhe']);
  729. $this->ajaxReturn($re);
  730. }
  731. //获取资产列表
  732. public function getmoneyinfo()
  733. {
  734. $uid = userid();
  735. $coinlist = M("coin")->where(array('status' => 1))->field("name,id")->select();
  736. $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
  737. $allzhehe = 0;
  738. if (!empty($coinlist)) {
  739. foreach ($coinlist as $k => $v) {
  740. $coinname = strtoupper($v['name']);
  741. $symbol = $v['name'] . "usdt";
  742. $coinnames = $v['name'];
  743. $coinnamed = $v['name'] . "d";
  744. //获取币的行情
  745. //获取币的余额
  746. if ($coinname != "USDT") {
  747. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=" . $symbol;
  748. $result = $this->get_maket_api($coinapi);
  749. $price_arr = $result['data'][0];
  750. $usdt_price = $price_arr['close'];
  751. $re[$k]['cid'] = $v['id'];
  752. $re[$k]['cname'] = $coinname;
  753. $re[$k]['num'] = $wallinfo[$coinnames];
  754. $re[$k]['numd'] = $wallinfo[$coinnamed];
  755. $re[$k]['zhe'] = $wallinfo[$coinnamed] * $usdt_price + $wallinfo[$coinnames] * $usdt_price;
  756. } else {
  757. $re[$k]['cid'] = $v['id'];
  758. $re[$k]['cname'] = $coinname;
  759. $re[$k]['num'] = $wallinfo['usdt'];
  760. $re[$k]['numd'] = $wallinfo['usdtd'];
  761. $re[$k]['zhe'] = $wallinfo['usdt'] + $wallinfo['usdtd'];
  762. }
  763. $allzhehe += $re[$k]['zhe'];
  764. }
  765. session("allzhehe", $allzhehe);
  766. $this->ajaxReturn(['code' => 1, 'data' => $re]);
  767. }
  768. }
  769. //获取单币种单价
  770. public function getnewprice()
  771. {
  772. $coinname = trim(I('post.coinname'));
  773. $num = 0;
  774. if ($coinname == "UKB") {
  775. $symbol = "ukb_usdt";
  776. $mlist = M("market")->where(array('name' => $symbol))->field("new_price,min_price,max_price,faxingjia,volume")->find();
  777. $open = $mlist['min_price'];//开盘价
  778. $close = $mlist['new_price'] + $num;//现价
  779. $lowhig = $close - $open; //涨跌
  780. $change = round(($lowhig / $open * 100), 2); //涨跌幅
  781. if ($change >= 0) {
  782. $changestr = "<span class='fzmmm green'>+" . $change . "%</span>";
  783. } else {
  784. $changestr = "<span class='fzmmm red'>" . $change . "%</span>";
  785. }
  786. if ($close >= $open) {
  787. $close = "<span class='fzmmm green'>" . $close . "</span>";
  788. } else {
  789. $close = "<span class='fzmmm red'>" . $close . "</span>";
  790. }
  791. } else {
  792. $lowcoin = strtolower($coinname);
  793. $symbol = $lowcoin . 'usdt';
  794. $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=" . $symbol;
  795. $result = $this->get_maket_api($coinapi);
  796. $price_arr = $result['data'][0];
  797. $open = $price_arr['open'];//开盘价
  798. $close = $price_arr['close'];//现价
  799. $lowhig = $close - $open; //涨跌
  800. $change = round(($lowhig / $open * 100), 2); //涨跌幅
  801. if ($change >= 0) {
  802. $changestr = "<span class='fzmmm green'>+" . $change . "%</span>";
  803. } else {
  804. $changestr = "<span class='fzmmm red'>" . $change . "%</span>";
  805. }
  806. if ($close >= $open) {
  807. $close = "<span class='fzmmm green'>" . $close . "</span>";
  808. } else {
  809. $close = "<span class='fzmmm red'>" . $close . "</span>";
  810. }
  811. }
  812. $data['code'] = 1;
  813. $data['newprice'] = $close;
  814. $data['changestr'] = $changestr;
  815. $this->ajaxReturn($data);
  816. }
  817. //币种详情
  818. public function coininfo()
  819. {
  820. $id = trim(I('get.cid'));
  821. $cinfo = M("coin")->where(array('id' => $id))->find();
  822. $uid = userid();
  823. if ($uid <= 0) {
  824. $this->ajaxReturn(['code' => 3, 'data' => '', 'info' => L('未登录')]);
  825. }
  826. $user = M('user_coin')->where(['userid' => $uid])->find();
  827. if ($id == 30) {
  828. $money = M('levermoney')->where(['uid' => $uid])->find();
  829. $numd = M('leverorder')->where(['uid' => $uid])->where('status = 1 or status = 2')->sum('bond');
  830. $order = M('leverorder')->where(['uid' => $uid])->where(['status' => 2])->select();
  831. $orderPrice = 0;
  832. foreach ($order as $vo) {
  833. $oy_list = do_request(oy_url($vo['coinname'], 'api/v5/market/index-tickers?instId='), []);
  834. $oy_list = $oy_list->data[0];
  835. $close = $oy_list->idxPx;//现价
  836. if ($vo['direction'] == 1) { //做多
  837. $profit = sprintf("%.2f", ($close - $vo['price']) * $vo['num']);
  838. } elseif ($vo['direction'] == 2) { //做空
  839. $profit = sprintf("%.2f", ($vo['price'] - $close) * $vo['num']);
  840. }
  841. $orderPrice += $profit;
  842. }
  843. $data = [
  844. 'num' => $money['money'] + $orderPrice,
  845. 'numd' => $numd == false ? 0 : $numd,
  846. 'zhe' => $money['money'] + $orderPrice,
  847. 'name' => '合約賬戶',
  848. 'czstatus' => 2,
  849. 'txstatus' => 2,
  850. ];
  851. } elseif ($id == 4) {
  852. $data = [
  853. 'num' => $user[$cinfo['name']],
  854. 'numd' => $user[$cinfo['name'] . 'd'],
  855. 'zhe' => $user[$cinfo['name']],
  856. 'czstatus' => $cinfo['czstatus'],
  857. 'txstatus' => $cinfo['txstatus'],
  858. ];
  859. $data['name'] = '資金賬戶';
  860. }elseif ($id == 29) {
  861. $marketinfo = M("market")->where(array('name'=>"gcb_usdt"))->find();
  862. $data = [
  863. 'num' => $user[$cinfo['name']],
  864. 'numd' => $user[$cinfo['name'] . 'd'],
  865. 'zhe' => round($user[$cinfo['name']] * $marketinfo['new_price'], 6),
  866. 'czstatus' => $cinfo['czstatus'],
  867. 'txstatus' => $cinfo['txstatus'],
  868. ];
  869. $data['name'] = $cinfo['title'];
  870. } else {
  871. $oy_list = do_request(oy_url($cinfo['name'], 'api/v5/market/ticker?instId='), []);
  872. $oy_list = $oy_list->data[0];
  873. $close = $oy_list->last;//现价
  874. $data = [
  875. 'num' => $user[$cinfo['name']],
  876. 'numd' => $user[$cinfo['name'] . 'd'],
  877. 'zhe' => round($user[$cinfo['name']] * $close, 2),
  878. 'czstatus' => $cinfo['czstatus'],
  879. 'txstatus' => $cinfo['txstatus'],
  880. ];
  881. $data['name'] = $cinfo['title'];
  882. }
  883. $this->ajaxReturn(['code' => 1, 'data' => $data, 'info' => '']);
  884. }
  885. //提币详情
  886. public function txinfo()
  887. {
  888. $id = trim(I('get.oid'));
  889. $info = M("myzc")->where(array('id' => $id))->find();
  890. $this->ajaxReturn(['code' => 1, 'data' => $info]);
  891. // $this->assign('info',$info);
  892. // $this->display();
  893. }
  894. //提币列表
  895. public function txlist()
  896. {
  897. $uid = userid();
  898. $txlist = M("myzc")->where(array('userid' => $uid))->order('id desc')->select();
  899. $this->ajaxReturn(['code' => 1, 'data' => $txlist]);
  900. // $this->assign("txlist",$txlist);
  901. // $this->display();
  902. }
  903. //提币处理
  904. public function tbhandle()
  905. {
  906. // if($_POST){
  907. $uid = userid();
  908. $uinfo = M("user")->where(array('id' => $uid))->field("id,rzstatus,username,txstate,is_tax,taxstatus")->find();
  909. if (empty($uinfo)) {
  910. $this->ajaxReturn(['code' => 0, 'info' => L('请先登陆')]);
  911. }
  912. if ($uinfo['rzstatus'] != 2) {
  913. $this->ajaxReturn(['code' => 0, 'info' => L('请先完成实名认证')]);
  914. }
  915. if ($uinfo['txstate'] != 1) {
  916. $this->ajaxReturn(['code' => 0, 'info' => L('禁止提币')]);
  917. }
  918. //检查该会员是不是需要缴纳税金,如有需要检查有没有缴纳
  919. if ($uinfo['is_tax'] == 1) {
  920. if ($uinfo['taxstatus'] != 1) {
  921. $this->ajaxReturn(['code' => 2, '請繳納稅金']);
  922. }
  923. }
  924. $id = trim(I('get.id'));
  925. if ($id == 5) {
  926. $id = 4;
  927. }
  928. if ($id <= 0) {
  929. $this->ajaxReturn(['code' => 0, 'info' => L('参数错误')]);
  930. }
  931. $address = trim(I('get.address'));
  932. if ($address == '' || $address == null) {
  933. $this->ajaxReturn(['code' => 0, 'info' => L('请输入提币地址')]);
  934. }
  935. $num = trim(I('get.num'));
  936. if ($num <= 0) {
  937. $this->ajaxReturn(['code' => 0, 'info' => L('请输入正确的额度')]);
  938. }
  939. $cinfo = M("coin")->where(array('id' => $id))->find();
  940. if (empty($cinfo)) {
  941. $this->ajaxReturn(['code' => 0, 'info' => L('参数错误')]);
  942. }
  943. if ($num < $cinfo['txminnum']) {
  944. $this->ajaxReturn(['code' => 0, 'info' => L('不能低于最小提币值')]);
  945. }
  946. if ($num > $cinfo['txmaxnum']) {
  947. $this->ajaxReturn(['code' => 0, 'info' => L('不能高于最大提币值')]);
  948. }
  949. $coinname = $cinfo['name'];
  950. $minfo = M("user_coin")->where(array('userid' => $uid))->find();
  951. $sxftype = $cinfo['sxftype'];
  952. if ($sxftype == 1) {
  953. $sxf = $num * $cinfo['txsxf'] / 100;
  954. } elseif ($sxftype == 2) {
  955. $sxf = $cinfo['txsxf_n'];
  956. }
  957. if ($sxf <= 0 || $sxf == '') {
  958. $sxf = 0;
  959. }
  960. $tnum = $num - $sxf;
  961. if ($minfo[$coinname] < $num) {
  962. $this->ajaxReturn(['code' => 0, 'info' => L('账户余额不足')]);
  963. }
  964. $dec_re = M("user_coin")->where(array('userid' => $uid))->setDec($coinname, $num);
  965. $data['userid'] = $uid;
  966. $data['username'] = $uinfo['username'];
  967. $data['coinname'] = $cinfo['name'];
  968. $data['num'] = $num;
  969. $data['fee'] = $sxf;
  970. $data['mum'] = $tnum;
  971. $data['address'] = $address;
  972. $data['sort'] = 1;
  973. $data['addtime'] = date("Y-m-d H:i:s", time());
  974. $data['endtime'] = date("Y-m-d H:i:s", time());
  975. $data['status'] = 1;
  976. $result = M("myzc")->add($data);
  977. //操作日志
  978. $bill['uid'] = $uid;
  979. $bill['username'] = $uinfo['username'];
  980. $bill['num'] = $num;
  981. $bill['coinname'] = $cinfo['name'];
  982. $bill['afternum'] = $minfo[$coinname] - $num;
  983. $bill['type'] = 2;
  984. $bill['addtime'] = date("Y-m-d H:i:s", time());
  985. $bill['st'] = 2;
  986. $bill['remark'] = "提币申请";
  987. $billre = M("bill")->add($bill);
  988. if ($result && $dec_re && $billre) {
  989. $this->ajaxReturn(['code' => 1, 'info' => L('提交成功')]);
  990. } else {
  991. $this->ajaxReturn(['code' => 0, 'info' => L('提交失败')]);
  992. }
  993. // }else{
  994. //
  995. // }
  996. }
  997. //判断是否绑定提币地址
  998. public function getaddress()
  999. {
  1000. if ($_POST) {
  1001. $id = trim(I('post.id'));
  1002. $coininfo = M("coin")->where(array('id' => $id))->field("id,name")->find();
  1003. if (empty($coininfo)) {
  1004. $this->ajaxReturn(['code' => 0]);
  1005. }
  1006. $coinname = $coininfo['name'];
  1007. $uid = userid();
  1008. $adrinfo = M("user_qianbao")->where(array('userid' => $uid, 'name' => $coinname))->order('id desc')->limit(1)->find();
  1009. if (!empty($adrinfo)) {
  1010. $this->ajaxReturn(['code' => 1]);
  1011. } else {
  1012. $this->ajaxReturn(['code' => 0]);
  1013. }
  1014. } else {
  1015. $this->ajaxReturn(['code' => 0]);
  1016. }
  1017. }
  1018. //添加地址处理
  1019. public function upplusaddress()
  1020. {
  1021. // if($_POST){
  1022. $uid = userid();
  1023. if ($uid <= 0) {
  1024. $this->ajaxReturn(['code' => 0, 'msg' => L('请先登陆')]);
  1025. }
  1026. $uinfo = M("user")->where(array('id' => $uid))->field("id,username")->find();
  1027. $address = trim(I('get.address'));
  1028. $remark = trim(I('get.remark'));
  1029. $oid = trim(I('get.oid'));
  1030. if ($oid <= 0) {
  1031. $this->ajaxReturn(['code' => 0, 'msg' => L('缺少重要参数')]);
  1032. }
  1033. if ($address == '') {
  1034. $this->ajaxReturn(['code' => 0, 'msg' => L('请输入提币地址')]);
  1035. }
  1036. if ($remark == '') {
  1037. $this->ajaxReturn(['code' => 0, 'msg' => L('请输入备注')]);
  1038. }
  1039. $cinfo = M("coin")->where(array('id' => $oid))->find();
  1040. $data['userid'] = $uid;
  1041. $data['coinname'] = $uinfo['username'];
  1042. $data['name'] = $cinfo['name'];
  1043. $data['remark'] = $remark;
  1044. $data['addr'] = $address;
  1045. $data['sort'] = 1;
  1046. $data['addtime'] = date("Y-m-d H:i:s", time());
  1047. $data['status'] = 1;
  1048. $result = M('user_qianbao')->add($data);
  1049. if ($result) {
  1050. $this->ajaxReturn(['code' => 1, 'msg' => L('添加成功')]);
  1051. } else {
  1052. $this->ajaxReturn(['code' => 0, 'msg' => L('添加失败')]);
  1053. }
  1054. }
  1055. //添加地址
  1056. public function plusaddress()
  1057. {
  1058. $id = trim(I('get.id'));
  1059. $cinfo = M("coin")->where(array('id' => $id))->find();
  1060. $this->assign('info', $cinfo);
  1061. $this->display();
  1062. }
  1063. //添加的提币的地址
  1064. public function txaddlist()
  1065. {
  1066. $id = trim(I('get.id'));
  1067. $cinfo = M("coin")->where(array('id' => $id))->find();
  1068. $coinname = $cinfo['name'];
  1069. $uid = userid();
  1070. $qblist = M("user_qianbao")->where(array('userid' => $uid, 'name' => $coinname))->order("id desc")->select();
  1071. $this->assign('qblist', $qblist);
  1072. $this->assign('id', $id);
  1073. $this->assign('coinname', $coinname);
  1074. $this->display();
  1075. }
  1076. //提币页面
  1077. public function txpage()
  1078. {
  1079. $id = trim(I('get.id'));
  1080. if ($id <= 0) {
  1081. $this->redirect('User/txcoin');
  1082. }
  1083. $info = M("coin")->where(array('id' => $id))->find();
  1084. if ($info['id'] == 5) {
  1085. $coinname = 'usdt';
  1086. } else {
  1087. $coinname = $info['name'];
  1088. }
  1089. $uid = userid();
  1090. $minfo = M("user_coin")->where(array('userid' => $uid))->find();
  1091. $money = $minfo[$coinname];
  1092. $adrinfo = M("user_qianbao")->where(array('userid' => $uid, 'name' => $coinname))->order('id desc')->limit(1)->find();
  1093. $data = [
  1094. 'info' => $info,
  1095. 'adrinfo' => $adrinfo,
  1096. 'money' => $money,
  1097. ];
  1098. $this->ajaxReturn(['code' => 1, 'data' => $data, 'info' => '']);
  1099. }
  1100. //提现币列表
  1101. public function txcoin()
  1102. {
  1103. $uid = userid();
  1104. if ($uid <= 0) {
  1105. $this->ajaxReturn(['code' => 0, 'info' => L('请先登陆')]);
  1106. }
  1107. $clist = M("coin")->where(array('txstatus' => 1))->field("id,name,title")->select();
  1108. $minfo = M("user_coin")->where(array('userid' => $uid))->find();
  1109. if (!empty($clist)) {
  1110. foreach ($clist as $k => $v) {
  1111. if ($v['id'] == 5) {
  1112. $coinname = 'usdt';
  1113. } else {
  1114. $coinname = $v['name'];
  1115. }
  1116. $coin_num = $minfo[$coinname];
  1117. $data[$k]['cname'] = strtoupper($coinname);
  1118. $data[$k]['title'] = $v['title'];
  1119. $data[$k]['id'] = $v['id'];
  1120. $data[$k]['cnum'] = $coin_num;
  1121. }
  1122. }
  1123. $this->ajaxReturn(['code' => 1, 'data' => $data, 'info' => '']);
  1124. }
  1125. //提币地址管理
  1126. public function addresslist()
  1127. {
  1128. $uid = userid();
  1129. if ($uid <= 0) {
  1130. $this->ajaxReturn(['code' => 0, 'info' => L('请先登陆')]);
  1131. }
  1132. $adrlist = M("user_qianbao")->where(array('uid' => $uid))->select();
  1133. $this->ajaxReturn(['code' => 1, 'data' => $adrlist, 'info' => '']);
  1134. }
  1135. //删除提币地址
  1136. public function deladdress($aid)
  1137. {
  1138. $uid = userid();
  1139. if ($uid <= 0) {
  1140. $this->ajaxReturn(['code' => 0, 'info' => L('请先登陆')]);
  1141. }
  1142. $ainfo = M("user_qianbao")->where(array('id' => $aid))->find();
  1143. if (empty($ainfo)) {
  1144. $this->ajaxReturn(['code' => 0, 'info' => L('提币地址不存在')]);
  1145. }
  1146. $delre = M("user_qianbao")->where(array('id' => $aid))->delete();
  1147. if ($delre) {
  1148. $this->ajaxReturn(['code' => 1, 'info' => L('删除成功')]);
  1149. } else {
  1150. $this->ajaxReturn(['code' => 0, 'info' => L('删除失败')]);
  1151. }
  1152. }
  1153. //充值列表
  1154. public function czlist()
  1155. {
  1156. $uid = userid();
  1157. $mlist = M("recharge")->where(array('uid' => $uid))->order("id desc")->select();
  1158. foreach ($mlist as &$item) {
  1159. $item['payimg'] = 'https://' . $_SERVER['HTTP_HOST'] . '/Upload/public/' . $item['payimg'];
  1160. }
  1161. $this->ajaxReturn(['code' => 1, 'data' => $mlist, 'info' => '']);
  1162. }
  1163. public function czinfo()
  1164. {
  1165. $id = trim(I('get.oid'));
  1166. $uid = userid();
  1167. $info = M("recharge")->where(array('uid' => $uid, 'id' => $id))->order("id desc")->find();
  1168. $info['payimg'] = 'https://' . $_SERVER['HTTP_HOST'] . '/Upload/public/' . $info['payimg'];
  1169. $this->ajaxReturn(['code' => 1, 'data' => $info, 'info' => '']);
  1170. // if(empty($info)){
  1171. // $this->redirect('User/czlist');
  1172. // }
  1173. // $this->assign("info",$info);
  1174. // $this->display();
  1175. }
  1176. //上传转账号凭证
  1177. public function paycoin()
  1178. {
  1179. // if($_POST){
  1180. $uid = userid();
  1181. $uinfo = M("user")->where(array('id' => $uid))->field("id,username")->find();
  1182. if (empty($uinfo)) {
  1183. $this->ajaxReturn(['code' => 0, 'info' => L('请先登陆')]);
  1184. }
  1185. $cid = trim(I('get.cid'));
  1186. $zznum = trim(I('get.zznum'));
  1187. $payimg = trim(I('get.payimg'));
  1188. $coinname = trim(I('get.coinname'));
  1189. if ($zznum <= 0) {
  1190. $this->ajaxReturn(['code' => 0, 'info' => L('请输入正确充值数量')]);
  1191. }
  1192. if ($payimg == "") {
  1193. $this->ajaxReturn(['code' => 0, 'info' => L('请上传转账凭证')]);
  1194. }
  1195. if ($coinname == "") {
  1196. $this->ajaxReturn(['code' => 0, 'info' => L('缺少重要参数')]);
  1197. }
  1198. if ($cid == "") {
  1199. $this->ajaxReturn(['code' => 0, 'info' => L('缺少重要参数')]);
  1200. }
  1201. $cinfo = M("coin")->where(array('id' => $cid))->find();
  1202. $minnum = $cinfo['czminnum'];
  1203. if ($zznum < $minnum) {
  1204. $this->ajaxReturn(['code' => 0, 'info' => L('低于最低额度')]);
  1205. }
  1206. $data['uid'] = $uid;
  1207. $data['username'] = $uinfo['username'];
  1208. $data['coin'] = strtoupper($coinname);
  1209. $data['num'] = $zznum;
  1210. $data['addtime'] = date("Y-m-d H:i:s", time());
  1211. $data['updatetime'] = date("Y-m-d H:i:s", time());
  1212. $data['status'] = 1;
  1213. $data['payimg'] = $payimg;
  1214. $data['msg'] = '';
  1215. $result = M("recharge")->add($data);
  1216. if ($result) {
  1217. $this->ajaxReturn(['code' => 1, 'info' => L('凭证提交成功')]);
  1218. } else {
  1219. $this->ajaxReturn(['code' => 0, 'info' => L('凭证提交失败')]);
  1220. }
  1221. // }else{
  1222. // $this->ajaxReturn(['code'=>0,'info'=> L('参数错误')]);
  1223. // }
  1224. }
  1225. /* 币种列表页 */
  1226. public function qianbao_coin_list()
  1227. {
  1228. $this->display();
  1229. }
  1230. public function qianbaoadd()
  1231. {
  1232. $this->display();
  1233. }
  1234. //我的资产中心
  1235. public function index()
  1236. {
  1237. $uid = userid();
  1238. if ($uid <= 0) {
  1239. $this->redirect('Login/index');
  1240. }
  1241. $clist = M("coin")->where(array('status' => 1))->order('id asc')->field("id,name")->select();
  1242. $clist[] = [
  1243. 'id' => 30,
  1244. 'name' => 'Futures-USDT'
  1245. ];
  1246. foreach ($clist as &$item) {
  1247. if ($item['id'] == 4) {
  1248. $item['name'] = 'Wallets-USDT';
  1249. }
  1250. }
  1251. $this->assign("list", $clist);
  1252. $this->display();
  1253. }
  1254. public function getsymbol()
  1255. {
  1256. $symbol = trim(I('post.symbol'));
  1257. $symbol = strtolower($symbol);
  1258. $map['name'] = array('like', "%$symbol%");
  1259. $info = M("coin")->where($map)->field("name,title,id")->find();
  1260. $uname = strtoupper($info['name']);
  1261. $info['uname'] = $uname;
  1262. //print_r($info);die;
  1263. $this->ajaxReturn(['code' => 1, 'info' => $info]);
  1264. }
  1265. //获取单个提币币种列表
  1266. public function getcoinnum()
  1267. {
  1268. $symbol = trim(I('post.symbol'));
  1269. $symbol = strtolower($symbol);
  1270. $map['name'] = array('like', "%$symbol%");
  1271. $info = M("coin")->where($map)->field("name,title,id")->find();
  1272. $coinname = $info['name'];
  1273. $uid = userid();
  1274. $minfo = M("user_coin")->where(array('userid' => $uid))->find();
  1275. if (!empty($minfo)) {
  1276. $cnum = $minfo[$coinname];
  1277. }
  1278. $data['cname'] = strtoupper($info['name']);
  1279. $data['title'] = $info['title'];
  1280. $data['cnum'] = $cnum;
  1281. $data['id'] = $info['id'];
  1282. $this->ajaxReturn(['code' => 1, 'info' => $data]);
  1283. }
  1284. //币种充值页面
  1285. public function czpage()
  1286. {
  1287. $id = trim(I('get.id'));
  1288. if ($id <= 0) {
  1289. $this->ajaxReturn(['code' => 2, 'data' => '', 'info' => '选择充值币种']);
  1290. }
  1291. $infos = M("coin")->where(array('id' => $id))->find();
  1292. if ($infos['czstatus'] != 1) {
  1293. $this->ajaxReturn(['code' => 2, 'data' => '', 'info' => '不支持充值']);
  1294. }
  1295. $this->ajaxReturn(['code' => 1, 'data' => $infos, 'info' => '']);
  1296. }
  1297. //充值币明细
  1298. public function czcoin()
  1299. {
  1300. $uid = userid();
  1301. if ($uid <= 0) {
  1302. $this->ajaxReturn(['code' => 3, 'data' => '', 'info' => L('未登录')]);
  1303. }
  1304. $name = I('get.name');
  1305. $where = [];
  1306. if ($name) $where[] = ['title' => strtoupper($name)];
  1307. $list = M("coin")->where(array('status' => 1))->where($where)->order('sort asc')->field("name,title,id,czstatus")->select();
  1308. foreach ($list as $k => $v) {
  1309. if ($v['name'] == 'ercus') {
  1310. unset($list[$k]);
  1311. }
  1312. }
  1313. $this->ajaxReturn(['code' => 1, 'data' => $list, 'info' => '']);
  1314. }
  1315. //获取行情数据
  1316. public function get_maket_api($api)
  1317. {
  1318. $ch = curl_init();
  1319. curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
  1320. curl_setopt($ch, CURLOPT_URL, $api);
  1321. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  1322. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
  1323. $result = json_decode(curl_exec($ch), true);
  1324. return $result;
  1325. }
  1326. public function login()
  1327. {
  1328. $this->display();
  1329. }
  1330. public function qianbao()
  1331. {
  1332. $this->display();
  1333. }
  1334. public function upqianbao()
  1335. {
  1336. }
  1337. public function delqianbao()
  1338. {
  1339. }
  1340. //会员登陆日志
  1341. public function log()
  1342. {
  1343. if (!userid()) {
  1344. redirect("/Login/index.html");
  1345. }
  1346. $where['status'] = array('egt', 0);
  1347. $where['userid'] = userid();
  1348. $Model = M('UserLog');
  1349. $count = $Model->db(1, 'DB_Read')->where($where)->count();
  1350. $Page = new \Think\Page($count, 10);
  1351. $show = $Page->show();
  1352. $list = $Model->db(1, 'DB_Read')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  1353. $this->assign('list', $list);
  1354. $this->assign('page', $show);
  1355. $this->display();
  1356. }
  1357. //上传图片
  1358. public function recharge_img()
  1359. {
  1360. $upload = new \Think\Upload();
  1361. $upload->maxSize = 3145728;
  1362. $upload->exts = array('jpg', 'gif', 'png', 'jpeg');
  1363. $upload->rootPath = './Upload/public/';
  1364. $upload->autoSub = false;
  1365. $info = $upload->upload();
  1366. $host = $_SERVER['HTTP_HOST'];
  1367. foreach ($info as $k => $v) {
  1368. $path = $v['savepath'] . $v['savename'];
  1369. $response = array(
  1370. 'code' => 0,
  1371. 'msg' => L('上传成功'),
  1372. 'data' => array(
  1373. 'src' => 'https://' . $host . '/Upload/public/' . $path,
  1374. 'img' => $path
  1375. )
  1376. );
  1377. echo json_encode($response);
  1378. exit();
  1379. }
  1380. }
  1381. /**
  1382. * 资金列表
  1383. * @return void
  1384. */
  1385. public function usercoin()
  1386. {
  1387. $uid = userid();
  1388. if ($uid <= 0) {
  1389. $this->ajaxReturn(['code' => 3, 'data' => '', 'info' => L('未登录')]);
  1390. }
  1391. $clist[] = [
  1392. 'id' => 30,
  1393. 'name' => '合約賬戶'
  1394. ];
  1395. $clist = array_merge($clist, M("coin")->where(array('status' => 1))->order('id asc')->field("id,name")->select());
  1396. $user = M('user_coin')->where(['userid' => $uid])->find();
  1397. foreach ($clist as &$item) {
  1398. if ($item['id'] == 4) {
  1399. $item['name'] = '資金賬戶';
  1400. }
  1401. }
  1402. unset($clist[2]);
  1403. $price = 0;
  1404. foreach ($clist as &$item) {
  1405. if ($item['name'] == '合約賬戶') {
  1406. $money = M('levermoney')->where(['uid' => $uid])->find();
  1407. $numd = M('leverorder')->where(['uid' => $uid])->where('status = 1 or status = 2')->sum('bond');
  1408. $order = M('leverorder')->where(['uid' => $uid])->where(['status' => 2])->select();
  1409. $orderPrice = 0;
  1410. foreach ($order as $vo) {
  1411. $oy_list = do_request(oy_url($vo['coinname'], 'api/v5/market/ticker?instId='), []);
  1412. $oy_list = $oy_list->data[0];
  1413. $close = $oy_list->last;//现价
  1414. if ($vo['direction'] == 1) { //做多
  1415. $profit = sprintf("%.2f", ($close - $vo['price']) * $vo['num']);
  1416. } elseif ($vo['direction'] == 2) { //做空
  1417. $profit = sprintf("%.2f", ($vo['price'] - $close) * $vo['num']);
  1418. }
  1419. $orderPrice += $profit;
  1420. }
  1421. $item['data'] = [
  1422. 'num' => $money['money'] + $orderPrice,
  1423. 'numd' => $numd,
  1424. 'zhe' => $money['money'] + $orderPrice,
  1425. ];
  1426. $price += ($money['money'] + $orderPrice);
  1427. } elseif ($item['name'] == '資金賬戶') {
  1428. $item['data'] = [
  1429. 'num' => $user['usdt'],
  1430. 'numd' => $user['usdtd'],
  1431. 'zhe' => $user['usdt'],
  1432. ];
  1433. $price += ($user['usdt'] + $user['usdtd']);
  1434. }elseif ($item['name'] == 'gcb') {
  1435. $marketinfo = M("market")->where(array('name'=>"gcb_usdt"))->find();
  1436. $item['data'] = [
  1437. 'num' => $user['gcb'],
  1438. 'numd' => $user['gcbd'],
  1439. 'zhe' => round($user['gcb'] * $marketinfo['new_price'], 6),
  1440. ];
  1441. $price += ($user['gcb'] * $marketinfo['new_price']);
  1442. } else {
  1443. $oy_list = do_request(oy_url($item['name'], 'api/v5/market/ticker?instId='), []);
  1444. $oy_list = $oy_list->data[0];
  1445. $close = $oy_list->last;//现价
  1446. $item['data'] = [
  1447. 'num' => $user[$item['name']],
  1448. 'numd' => $user[$item['name'] . 'd'],
  1449. 'zhe' => $user[$item['name']] * $close,
  1450. ];
  1451. // $price += ($user[$item['name']]+$user[$item['name'].'d']);
  1452. $price += ($user[$item['name']] * $close);
  1453. }
  1454. }
  1455. session('user_price', $price);
  1456. $this->ajaxReturn(['code' => 1, 'data' => $clist, 'info' => '']);
  1457. }
  1458. public function bill()
  1459. {
  1460. $uid = userid();
  1461. if ($uid <= 0) {
  1462. $this->ajaxReturn(['code' => 3, 'data' => '', 'info' => L('未登录')]);
  1463. }
  1464. $name = trim(I('get.name'));
  1465. $page = I('get.page');
  1466. if (!$page) $page = 1;
  1467. $limit = I('get.limit');
  1468. if (!$limit) $limit = 10;
  1469. if ($name == '合約賬戶') {
  1470. $list = M('bill')->where(['uid' => $uid])->where(['coinname' => 'lever'])->order('id DESC')->page($page, $limit)->select();
  1471. } elseif ($name == '資金賬戶') {
  1472. $list = M('bill')->where(['uid' => $uid])->where(['coinname' => 'usdt'])->order('id DESC')->page($page, $limit)->select();
  1473. } else {
  1474. $list = M('bill')->where(['uid' => $uid])->where(['coinname' => strtolower($name)])->order('id DESC')->page($page, $limit)->select();
  1475. }
  1476. $this->ajaxReturn(['code' => 1, 'data' => $list, 'info' => '']);
  1477. }
  1478. public function userinfo()
  1479. {
  1480. $uid = userid();
  1481. if ($uid <= 0) {
  1482. $this->ajaxReturn(['code' => 3, 'data' => '', 'info' => L('未登录')]);
  1483. }
  1484. $list = M('user')->where(['id' => $uid])->field('id,username,phone,money,rzstatus,level,invit_1,invit_2,invit_3,status,txstate,invit,taxstatus,rzstatus,cardzm,cardfm,name,zhengjian')->find();
  1485. $icon = M('user_coin')->where(['userid' => $uid])->find();
  1486. $money = M('levermoney')->where(['uid' => $uid])->find();
  1487. if (!$money) $money['money'] = 0;
  1488. $list['usdt'] = $icon['usdt'];
  1489. $list['http'] = 'https://' . $_SERVER['HTTP_HOST'] . '/Upload/public/';
  1490. $order = M('leverorder')->where(['uid' => $uid])->where(['status' => 2])->select();
  1491. $orderPrice = 0;
  1492. foreach ($order as $vo) {
  1493. $oy_list = do_request(oy_url($vo['coinname'], 'api/v5/market/ticker?instId='), []);
  1494. $oy_list = $oy_list->data[0];
  1495. $close = $oy_list->last;//现价
  1496. if ($vo['direction'] == 1) { //做多
  1497. $profit = sprintf("%.2f", ($close - $vo['price']) * $vo['num']);
  1498. } elseif ($vo['direction'] == 2) { //做空
  1499. $profit = sprintf("%.2f", ($vo['price'] - $close) * $vo['num']);
  1500. }
  1501. $orderPrice += $profit;
  1502. }
  1503. $sy = $money['money'] + $orderPrice;
  1504. if ($sy <= 0) {
  1505. $sy = 0;
  1506. }
  1507. $list['money'] = $sy;
  1508. $this->ajaxReturn(['code' => 1, 'data' => $list, 'info' => '']);
  1509. }
  1510. }
  1511. ?>