1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768 |
- <?php
- namespace Mobile\Controller;
- use Think\Exception;
- class UserController extends MobileController
- {
- protected function _initialize()
- {
- parent::_initialize();
- $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");
- if (!in_array(ACTION_NAME, $allow_action)) {
- $this->error("非法操作");
- }
- }
- public function update_levermoney($uid)
- {
- $uinfo = M("user")->where(array('id' => $uid))->field("id,username")->find();
- $data['uid'] = $uid;
- $data['username'] = $uinfo['username'];
- $data['money'] = 0;
- M("levermoney")->add($data);
- }
- //资产划转到合约账户
- public function transfer()
- {
- // if($_POST){
- $tbnum = trim(I('get.tbnum'));
- $type = trim(I('get.type'));
- $uid = userid();
- if ($tbnum <= 0) {
- $this->ajaxReturn(['code' => 2, 'info' => L('请输入正确的数量')]);
- exit();
- }
- $uinfo = M("user")->where(array('id' => $uid))->field("id,username")->find();
- $minfo = M("user_coin")->where(array('userid' => $uid))->find();
- $money = $minfo['usdt'];
- $lmoneyinfo = M("levermoney")->where(array('uid' => $uid))->find();
- $levermoney = $lmoneyinfo['money'];
- M()->startTrans();
- try {
- if ($type == 1) {
- if ($money < $tbnum) {
- $this->ajaxReturn(['code' => 2, 'info' => L('资金账户余额不足')]);
- exit();
- }
- $dec_re = M("user_coin")->where(array('userid' => $uid))->setDec('usdt', $tbnum);
- if ($dec_re) {
- if (!M("levermoney")->where(array('uid' => $uid))->find())
- M("levermoney")->add(['uid' => $uid, 'username' => $uinfo['username']]);
- // var_dump(M("levermoney")->where(array('uid' => $uid))->find());
- $inc_re = M("levermoney")->where(array('uid' => $uid))->setInc('money', $tbnum);
- // var_dump($inc_re);
- // var_dump(M("levermoney")->where(array('uid' => $uid))->find());
- if ($inc_re) {
- //操作日志
- $bill['uid'] = $uid;
- $bill['username'] = $uinfo['username'];
- $bill['num'] = $tbnum;
- $bill['coinname'] = 'usdt';
- $bill['afternum'] = $minfo['usdt'] - $tbnum;
- $bill['type'] = 18;
- $bill['addtime'] = date("Y-m-d H:i:s", time());
- $bill['st'] = 2;
- $bill['remark'] = L('资金账户转合约账户');
- M("bill")->add($bill);
- M()->commit();
- $this->ajaxReturn(['code' => 1, 'info' => L('划转成功')]);
- exit();
- } else {
- M()->rollback();
- $this->ajaxReturn(['code' => 2, 'info' => L('划转失败' . M('levermoney')->getLastSql())]);
- exit();
- }
- }
- } elseif ($type == 2) {
- if ($levermoney < $tbnum) {
- $this->ajaxReturn(['code' => 2, 'info' => L('合约账户余额不足')]);
- exit();
- }
- $order_count = M("leverorder")->where("uid = {$uid} and (status = 1 or status = 2)")->count();
- if ($order_count >= 1) {
- $this->ajaxReturn(['code' => 2, 'info' => L('有合约定单未结算,不能划转合约账户')]);
- exit();
- }
- $dec_re = M("levermoney")->where(array('uid' => $uid))->setDec('money', $tbnum);
- if ($dec_re) {
- if (!M("user_coin")->where(array('userid' => $uid))->find())
- M("user_coin")->add(['userid' => $uid]);
- $inc_re = M("user_coin")->where(array('userid' => $uid))->setInc('usdt', $tbnum);
- if ($inc_re) {
- //操作日志
- $bill['uid'] = $uid;
- $bill['username'] = $uinfo['username'];
- $bill['num'] = $tbnum;
- $bill['coinname'] = 'usdt';
- $bill['afternum'] = $minfo['usdt'] + $tbnum;
- $bill['type'] = 18;
- $bill['addtime'] = date("Y-m-d H:i:s", time());
- $bill['st'] = 2;
- $bill['remark'] = L('合约账户转资金账户');
- M("bill")->add($bill);
- M()->commit();
- $this->ajaxReturn(['code' => 1, 'info' => L('划转成功')]);
- exit();
- } else {
- M()->rollback();
- $this->ajaxReturn(['code' => 2, 'info' => L('划转失败' . M('user_coin')->getLastSql())]);
- exit();
- }
- }
- } else {
- M()->rollback();
- $this->ajaxReturn(['code' => 1, 'info' => L('参数错误')]);
- exit();
- }
- } catch (Exception $e) {
- M()->rollback();
- $this->ajaxReturn(['code' => 1, 'info' => L($e->getMessage())]);
- exit();
- }
- // }else{
- // $id = trim(I('get.id'));
- // if($id != 4){
- // $this->redirect('User/index');
- // }
- // $info = M("coin")->where(array('id'=>$id))->find();
- // $this->assign('info',$info);
- // $coinname = $info['name'];
- // $uid = userid();
- // $minfo = M("user_coin")->where(array('userid'=>$uid))->find();
- // $money = $minfo[$coinname];
- // $this->assign('money',$money);
- //
- // $lmoneyinfo = M("levermoney")->where(array('uid'=>$uid))->find();
- // if(empty($lmoneyinfo)){
- // $this->update_levermoney($uid);
- // $levermoney = 0;
- // }else{
- // $levermoney = $lmoneyinfo['money'];
- // }
- // $this->assign('levermoney',$levermoney);
- // $this->display();
- // }
- }
- //上传转账号凭证
- public function paytax()
- {
- if ($_POST) {
- $uid = userid();
- $uinfo = M("user")->where(array('id' => $uid))->field("id,username")->find();
- if (empty($uinfo)) {
- $this->ajaxReturn(['code' => 0, 'info' => L('请先登陆')]);
- }
- $cid = trim(I('post.cid'));
- $zznum = trim(I('post.zznum'));
- $payimg = trim(I('post.payimg'));
- $coinname = trim(I('post.coinname'));
- if ($zznum <= 0) {
- $this->ajaxReturn(['code' => 0, 'info' => L('请输入正确充值数量')]);
- }
- if ($payimg == "") {
- $this->ajaxReturn(['code' => 0, 'info' => L('请上传转账凭证')]);
- }
- if ($coinname == "") {
- $this->ajaxReturn(['code' => 0, 'info' => L('缺少重要参数')]);
- }
- if ($cid == "") {
- $this->ajaxReturn(['code' => 0, 'info' => L('缺少重要参数')]);
- }
- $data['uid'] = $uid;
- $data['username'] = $uinfo['username'];
- $data['taxnum'] = $zznum;
- $data['addtime'] = date("Y-m-d H:i:s", time());
- $data['updatetime'] = date("Y-m-d H:i:s", time());
- $data['status'] = 1;
- $data['payimgs'] = $payimg;
- $result = M("taxlist")->add($data);
- if ($result) {
- $this->ajaxReturn(['code' => 1, 'info' => L('凭证提交成功')]);
- } else {
- $this->ajaxReturn(['code' => 0, 'info' => L('凭证提交失败')]);
- }
- } else {
- $this->ajaxReturn(['code' => 0, 'info' => L('参数错误')]);
- }
- }
- //缴纳税金页面
- public function cztax()
- {
- $id = 4;
- if ($id <= 0) {
- $this->redirect('User/czcoin');
- }
- $info = M("coin")->where(array('id' => $id))->find();
- if ($info['czstatus'] != 1) {
- $this->redirect('User/czcoin');
- }
- $this->assign('info', $info);
- $address = $info['czaddress'];
- $url = $address;
- $drpath = './Public/Static/coinimgs/';
- $imgma = $address . '.png';
- $urel = './Public/Static/coinimgs/' . $imgma;
- Vendor('phpqrcode.phpqrcode');
- $object = new \QRcode();
- $size = 3;
- $errorLevel = 16;
- $object->png($url, $drpath . '/' . $imgma, $errorLevel, $size);
- $object->scerweima1($url, $urel, $url);
- $this->assign("address", $address);
- $config = M("config")->where(array('id' => 1))->field("taxnum")->find();
- $taxnum = $config['taxnum'];
- $this->assign('taxnum', $taxnum);
- $tinfo = M("taxtxt")->where(array('id' => 2))->find();
- $this->assign('tinfo', $tinfo);
- $this->display();
- }
- //在线客服
- public function online()
- {
- $uid = userid();
- if ($uid <= 0) {
- $this->redirect('Login/index');
- }
- $this->display();
- }
- public function getlineinfo()
- {
- $uid = userid();
- $list = M("online")->where(array('uid' => $uid))->order('id asc')->field("type,content,addtime")->select();
- foreach ($list as $k => $v) {
- $list[$k]['time'] = date("H:i", strtotime($v['addtime']));
- }
- $this->ajaxReturn(['code' => 1, 'data' => $list]);
- exit();
- }
- //提交聊天内容
- public function uptxt($txt = null)
- {
- if (checkstr($txt)) {
- $this->ajaxReturn(['code' => 0, 'info' => L('您输入的信息有误')]);
- }
- $uid = userid();
- $uinfo = M("user")->where(array('id' => $uid))->field("id,username")->find();
- if ($uid <= 0) {
- $this->ajaxReturn(['code' => 3, 'info' => L('请先登陆')]);
- }
- if ($txt == '') {
- $this->ajaxReturn(['code' => 0, 'info' => L('请输入信息内容')]);
- }
- $data['uid'] = $uid;
- $data['username'] = $uinfo['username'];
- $data['type'] = 2;
- $data['content'] = $txt;
- $data['addtime'] = date("Y-m-d H:i:s", time());
- $result = M("online")->add($data);
- if ($result) {
- $this->ajaxReturn(['code' => 1]);
- } else {
- $this->ajaxReturn(['code' => 0, 'info' => L('信息发送失败')]);
- }
- }
- //实名认证页面
- public function authrz()
- {
- $uid = userid();
- if ($uid <= 0) {
- $this->redirect('Login/index');
- }
- $userinfo = M("user")->where(array('id' => $uid))->find();
- $this->assign("info", $userinfo);
- $this->display();
- }
- //实名认证处理
- public function upauthrzs($name, $zhengjian)
- {
- // if (checkstr($phone) || checkstr($cardzm) || checkstr($cardfm)) {
- // $this->ajaxReturn(['code'=>0,'info'=>L('您输入的信息有误')]);
- // }
- $uid = userid();
- $userinfo = M("user")->where(array('id' => $uid))->find();
- if ($uid <= 0) {
- $this->ajaxReturn(['code' => 0, 'info' => L('请先登陆')]);
- }
- // $uinfo = M("user")->where(array('phone'=>$phone))->find();
- //if(!empty($uinfo)){
- //$this->ajaxReturn(['code'=>0,'info'=>L('手机号已绑定')]);
- //}
- //if($userinfo['rzstatus'] == 1){
- //$this->ajaxReturn(['code'=>0,'info'=>L('不能重复认证')]);
- //}
- //$data['phone'] = $phone;
- $data['name'] = $name;
- $data['zhengjian'] = $zhengjian;
- $data['rzstatus'] = 1;
- $data['rztime'] = time();
- $re = M("user")->where(array('id' => $uid))->save($data);
- if ($re) {
- $notice['uid'] = $uid;
- $notice['account'] = $userinfo['username'];
- $notice['title'] = L('认证资料提交成功,耐心等待管理员审核');
- $notice['content'] = L('实名资料提成功,耐心等待管理员审核');
- $notice['addtime'] = date("Y-m-d H:i:s", time());
- $notice['status'] = 1;
- M("notice")->add($notice);
- $this->ajaxReturn(['code' => 1, 'info' => L('认证资料提交成功')]);
- } else {
- $this->ajaxReturn(['code' => 0, 'info' => L('认证资料提交失败')]);
- }
- }
- //实名认证处理
- public function upauthrz($cardzm, $cardfm, $nickname, $card)
- {
- // if (checkstr($phone) || checkstr($cardzm) || checkstr($cardfm)) {
- // $this->ajaxReturn(['code'=>0,'info'=>L('您输入的信息有误')]);
- // }
- $uid = userid();
- $userinfo = M("user")->where(array('id' => $uid))->find();
- if ($uid <= 0) {
- $this->ajaxReturn(['code' => 0, 'info' => L('请先登陆')]);
- }
- if ($userinfo['rzstatus'] == 1) $this->ajaxReturn(['code' => 0, 'info' => L('已提交實名認證,請耐心等待')]);
- if ($userinfo['rzstatus'] == 2) $this->ajaxReturn(['code' => 0, 'info' => L('已認證成功')]);
- // $uinfo = M("user")->where(array('phone'=>$phone))->find();
- //if(!empty($uinfo)){
- //$this->ajaxReturn(['code'=>0,'info'=>L('手机号已绑定')]);
- //}
- //if($userinfo['rzstatus'] == 1){
- //$this->ajaxReturn(['code'=>0,'info'=>L('不能重复认证')]);
- //}
- if ($cardzm == "") {
- $this->ajaxReturn(['code' => 0, 'info' => L('请上传上传身份证正面')]);
- }
- if ($cardfm == "") {
- $this->ajaxReturn(['code' => 0, 'info' => L('请上传上传身份证背面')]);
- }
- if ($nickname == '') $this->ajaxReturn(['code' => 0, 'info' => L('輸入姓名')]);
- if ($card == '') $this->ajaxReturn(['code' => 0, 'info' => L('身份證')]);
- $data['cardzm'] = $cardzm;
- $data['cardfm'] = $cardfm;
- $data['name'] = $nickname;
- $data['zhengjian'] = $card;
- $data['rzstatus'] = 1;
- $data['rztime'] = time();
- $re = M("user")->where(array('id' => $uid))->save($data);
- if ($re) {
- $notice['uid'] = $uid;
- $notice['account'] = $userinfo['username'];
- $notice['title'] = L('认证资料提交成功');
- $notice['content'] = L('实名资料提成功,耐心等待管理员审核');
- $notice['addtime'] = date("Y-m-d H:i:s", time());
- $notice['status'] = 1;
- M("notice")->add($notice);
- $this->ajaxReturn(['code' => 1, 'info' => L('认证资料提交成功')]);
- } else {
- $this->ajaxReturn(['code' => 0, 'info' => L('认证资料提交失败')]);
- }
- }
- //获取折合资产
- public function getallzhehe()
- {
- $uid = userid();
- // $minfo = M("user_coin")->where(array('userid'=>$uid))->find();
- // $usdt = $minfo['usdt'] + $minfo['usdtd'];
- // $money = M('levermoney')->where(['uid' => $uid])->find();
- $allzhehe = session('user_price');
- $this->ajaxReturn(['code' => 1, 'allzhehe' => $allzhehe]);
- }
- //获取单个币种资产(ttc)
- public function getmoneyttc()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $ttcusdt = 0.01; //需要获取实时的行情
- $re['num'] = $wallinfo['ttc'];
- $re['numd'] = $wallinfo['ttcd'];
- $re['zhe'] = $wallinfo['ttc'] * 0.01 + $wallinfo['ttcd'] * 0.01;
- $re['code'] = 1;
- session("ttczh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(atm)
- public function getmoneyatm()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $atmusdt = 0.01; //需要获取实时的行情
- $re['num'] = $wallinfo['atm'];
- $re['numd'] = $wallinfo['atmd'];
- $re['zhe'] = $wallinfo['atm'] * 0.01 + $wallinfo['atmd'] * 0.01;
- $re['code'] = 1;
- session("atmzh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(usdz)
- public function getmoneyusdz()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $where['name'] = "ukb_usdt";
- $marketinfo = M("market")->where($where)->field("new_price")->find();
- $usdzusdt = $marketinfo['new_price'];
- $re['num'] = $wallinfo['ukb'];
- $re['numd'] = $wallinfo['ukbd'];
- $re['zhe'] = $wallinfo['ukb'] * $usdzusdt + $wallinfo['ukbd'] * $usdzusdt;
- $re['code'] = 1;
- session("usdzzh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(usdz)
- public function getmoneylever()
- {
- $uid = userid();
- $wallinfo = M("levermoney")->where(array('uid' => $uid))->find();
- $sy = 0;
- $list = M('leverorder')->where(['uid' => $uid])->where(['status' => 2])->select();
- foreach ($list as $item) {
- if ($item['coinname'] == 'ukbusdt') {
- $o_symbol = $item['symbol'];
- $symbol_arr = explode('/', $o_symbol);
- $symbol = strtolower($symbol_arr[0]) . "_" . strtolower($symbol_arr[1]);
- $mlist = M("market")->where(array('name' => $symbol))->field("new_price,min_price")->find();
- $close = $mlist['new_price'];
- } else {
- $url = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=" . $item['coinname'];
- $result = $this->getprice($url);
- $pdata = $result['data'][0];
- $close = $pdata['close'];//现价
- }
- $direction = $item['direction'];
- if ($direction == 1) { //做多
- $profit = sprintf("%.2f", ($close - $item['price']) * $item['num']);
- } elseif ($direction == 2) { //做空
- $profit = sprintf("%.2f", ($close - $item['price']) * $item['num']);
- }
- if ($profit >= 0) {
- $sy += $profit;
- } else {
- $sy -= $profit;
- }
- }
- $where['name'] = "ukb_usdt";
- $marketinfo = M("market")->where($where)->field("new_price")->find();
- $usdzusdt = $marketinfo['new_price'];
- $money = M('leverorder')->where(['uid' => $uid])->where('status = 1 or status = 2')->sum('bond');
- $re['num'] = $wallinfo['money'] + $sy;
- $re['numd'] = $money;
- $re['zhe'] = 0;
- $re['code'] = 1;
- session("lever", $re['num']);
- $this->ajaxReturn($re);
- }
- //获取行情数据
- public function getprice($api)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
- curl_setopt($ch, CURLOPT_URL, $api);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
- $result = json_decode(curl_exec($ch), true);
- return $result;
- }
- //获取单个币种资产(ogo)
- public function getmoneyogo()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=ogousdt";
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re['num'] = $wallinfo['ogo'];
- $re['numd'] = $wallinfo['ogod'];
- $re['zhe'] = $wallinfo['ogo'] * $usdt_price + $wallinfo['ogod'] * $usdt_price;
- $re['code'] = 1;
- session("ogozh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(ht)
- public function getmoneyht()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=htusdt";
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re['num'] = $wallinfo['ht'];
- $re['numd'] = $wallinfo['htd'];
- $re['zhe'] = $wallinfo['ht'] * $usdt_price + $wallinfo['htd'] * $usdt_price;
- $re['code'] = 1;
- session("htzh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(itc)
- public function getmoneyitc()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=itcusdt";
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re['num'] = $wallinfo['itc'];
- $re['numd'] = $wallinfo['itcd'];
- $re['zhe'] = $wallinfo['itc'] * $usdt_price + $wallinfo['itcd'] * $usdt_price;
- $re['code'] = 1;
- session("itczh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(jst)
- public function getmoneyjst()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=jstusdt";
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re['num'] = $wallinfo['jst'];
- $re['numd'] = $wallinfo['jstd'];
- $re['zhe'] = $wallinfo['jst'] * $usdt_price + $wallinfo['jstd'] * $usdt_price;
- $re['code'] = 1;
- session("jstzh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(flow)
- public function getmoneyflow()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=flowusdt";
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re['num'] = $wallinfo['flow'];
- $re['numd'] = $wallinfo['flowd'];
- $re['zhe'] = $wallinfo['flow'] * $usdt_price + $wallinfo['flowd'] * $usdt_price;
- $re['code'] = 1;
- session("flowzh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(shib)
- public function getmoneyshib()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=shibusdt";
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re['num'] = $wallinfo['shib'];
- $re['numd'] = $wallinfo['shibd'];
- $re['zhe'] = $wallinfo['shib'] * $usdt_price + $wallinfo['shibd'] * $usdt_price;
- $re['code'] = 1;
- session("shibzh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(fil)
- public function getmoneyfil()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=filusdt";
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re['num'] = $wallinfo['fil'];
- $re['numd'] = $wallinfo['fild'];
- $re['zhe'] = $wallinfo['fil'] * $usdt_price + $wallinfo['fild'] * $usdt_price;
- $re['code'] = 1;
- session("filzh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(iotx)
- public function getmoneyiotx()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=iotxusdt";
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re['num'] = $wallinfo['iotx'];
- $re['numd'] = $wallinfo['iotxd'];
- $re['zhe'] = $wallinfo['iotx'] * $usdt_price + $wallinfo['iotxd'] * $usdt_price;
- $re['code'] = 1;
- session("iotxzh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(xrp)
- public function getmoneyxrp()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=xrpusdt";
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re['num'] = $wallinfo['xrp'];
- $re['numd'] = $wallinfo['xrpd'];
- $re['zhe'] = $wallinfo['xrp'] * $usdt_price + $wallinfo['xrpd'] * $usdt_price;
- $re['code'] = 1;
- session("xrpzh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(trx)
- public function getmoneytrx()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=trxusdt";
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re['num'] = $wallinfo['trx'];
- $re['numd'] = $wallinfo['trxd'];
- $re['zhe'] = $wallinfo['trx'] * $usdt_price + $wallinfo['trxd'] * $usdt_price;
- $re['code'] = 1;
- session("trxzh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(ltc)
- public function getmoneyltc()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=ltcusdt";
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re['num'] = $wallinfo['ltc'];
- $re['numd'] = $wallinfo['ltcd'];
- $re['zhe'] = $wallinfo['ltc'] * $usdt_price + $wallinfo['ltcd'] * $usdt_price;
- $re['code'] = 1;
- session("ltczh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(bch)
- public function getmoneybch()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=bchusdt";
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re['num'] = $wallinfo['bch'];
- $re['numd'] = $wallinfo['bchd'];
- $re['zhe'] = $wallinfo['bch'] * $usdt_price + $wallinfo['bchd'] * $usdt_price;
- $re['code'] = 1;
- session("bchzh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(doge)
- public function getmoneydoge()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=dogeusdt";
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re['num'] = $wallinfo['doge'];
- $re['numd'] = $wallinfo['doged'];
- $re['zhe'] = $wallinfo['doge'] * $usdt_price + $wallinfo['doged'] * $usdt_price;
- $re['code'] = 1;
- session("dogezh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(eos)
- public function getmoneyeos()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=eosusdt";
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re['num'] = $wallinfo['eos'];
- $re['numd'] = $wallinfo['eosd'];
- $re['zhe'] = $wallinfo['eos'] * $usdt_price + $wallinfo['eosd'] * $usdt_price;
- $re['code'] = 1;
- session("eoszh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(eth)
- public function getmoneyeth()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=ethusdt";
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re['num'] = $wallinfo['eth'];
- $re['numd'] = $wallinfo['ethd'];
- $re['zhe'] = $wallinfo['eth'] * $usdt_price + $wallinfo['ethd'] * $usdt_price;
- $re['code'] = 1;
- session("ethzh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(btc)
- public function getmoneybtc()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=btcusdt";
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re['num'] = $wallinfo['btc'];
- $re['numd'] = $wallinfo['btcd'];
- $re['zhe'] = $wallinfo['btc'] * $usdt_price + $wallinfo['btcd'] * $usdt_price;
- $re['code'] = 1;
- session("btczh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取单个币种资产(usdt)
- public function getmoneyusdt()
- {
- $uid = userid();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $re['num'] = $wallinfo['usdt'];
- $re['numd'] = $wallinfo['usdtd'];
- $re['zhe'] = $wallinfo['usdt'] + $wallinfo['usdtd'];
- $re['code'] = 1;
- session("usdtzh", $re['zhe']);
- $this->ajaxReturn($re);
- }
- //获取资产列表
- public function getmoneyinfo()
- {
- $uid = userid();
- $coinlist = M("coin")->where(array('status' => 1))->field("name,id")->select();
- $wallinfo = M("user_coin")->where(array('userid' => $uid))->find();
- $allzhehe = 0;
- if (!empty($coinlist)) {
- foreach ($coinlist as $k => $v) {
- $coinname = strtoupper($v['name']);
- $symbol = $v['name'] . "usdt";
- $coinnames = $v['name'];
- $coinnamed = $v['name'] . "d";
- //获取币的行情
- //获取币的余额
- if ($coinname != "USDT") {
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=" . $symbol;
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $usdt_price = $price_arr['close'];
- $re[$k]['cid'] = $v['id'];
- $re[$k]['cname'] = $coinname;
- $re[$k]['num'] = $wallinfo[$coinnames];
- $re[$k]['numd'] = $wallinfo[$coinnamed];
- $re[$k]['zhe'] = $wallinfo[$coinnamed] * $usdt_price + $wallinfo[$coinnames] * $usdt_price;
- } else {
- $re[$k]['cid'] = $v['id'];
- $re[$k]['cname'] = $coinname;
- $re[$k]['num'] = $wallinfo['usdt'];
- $re[$k]['numd'] = $wallinfo['usdtd'];
- $re[$k]['zhe'] = $wallinfo['usdt'] + $wallinfo['usdtd'];
- }
- $allzhehe += $re[$k]['zhe'];
- }
- session("allzhehe", $allzhehe);
- $this->ajaxReturn(['code' => 1, 'data' => $re]);
- }
- }
- //获取单币种单价
- public function getnewprice()
- {
- $coinname = trim(I('post.coinname'));
- $num = 0;
- if ($coinname == "UKB") {
- $symbol = "ukb_usdt";
- $mlist = M("market")->where(array('name' => $symbol))->field("new_price,min_price,max_price,faxingjia,volume")->find();
- $open = $mlist['min_price'];//开盘价
- $close = $mlist['new_price'] + $num;//现价
- $lowhig = $close - $open; //涨跌
- $change = round(($lowhig / $open * 100), 2); //涨跌幅
- if ($change >= 0) {
- $changestr = "<span class='fzmmm green'>+" . $change . "%</span>";
- } else {
- $changestr = "<span class='fzmmm red'>" . $change . "%</span>";
- }
- if ($close >= $open) {
- $close = "<span class='fzmmm green'>" . $close . "</span>";
- } else {
- $close = "<span class='fzmmm red'>" . $close . "</span>";
- }
- } else {
- $lowcoin = strtolower($coinname);
- $symbol = $lowcoin . 'usdt';
- $coinapi = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=" . $symbol;
- $result = $this->get_maket_api($coinapi);
- $price_arr = $result['data'][0];
- $open = $price_arr['open'];//开盘价
- $close = $price_arr['close'];//现价
- $lowhig = $close - $open; //涨跌
- $change = round(($lowhig / $open * 100), 2); //涨跌幅
- if ($change >= 0) {
- $changestr = "<span class='fzmmm green'>+" . $change . "%</span>";
- } else {
- $changestr = "<span class='fzmmm red'>" . $change . "%</span>";
- }
- if ($close >= $open) {
- $close = "<span class='fzmmm green'>" . $close . "</span>";
- } else {
- $close = "<span class='fzmmm red'>" . $close . "</span>";
- }
- }
- $data['code'] = 1;
- $data['newprice'] = $close;
- $data['changestr'] = $changestr;
- $this->ajaxReturn($data);
- }
- //币种详情
- public function coininfo()
- {
- $id = trim(I('get.cid'));
- $cinfo = M("coin")->where(array('id' => $id))->find();
- $uid = userid();
- if ($uid <= 0) {
- $this->ajaxReturn(['code' => 3, 'data' => '', 'info' => L('未登录')]);
- }
- $user = M('user_coin')->where(['userid' => $uid])->find();
- if ($id == 30) {
- $money = M('levermoney')->where(['uid' => $uid])->find();
- $numd = M('leverorder')->where(['uid' => $uid])->where('status = 1 or status = 2')->sum('bond');
- $order = M('leverorder')->where(['uid' => $uid])->where(['status' => 2])->select();
- $orderPrice = 0;
- foreach ($order as $vo) {
- $oy_list = do_request(oy_url($vo['coinname'], 'api/v5/market/index-tickers?instId='), []);
- $oy_list = $oy_list->data[0];
- $close = $oy_list->idxPx;//现价
- if ($vo['direction'] == 1) { //做多
- $profit = sprintf("%.2f", ($close - $vo['price']) * $vo['num']);
- } elseif ($vo['direction'] == 2) { //做空
- $profit = sprintf("%.2f", ($vo['price'] - $close) * $vo['num']);
- }
- $orderPrice += $profit;
- }
- $data = [
- 'num' => $money['money'] + $orderPrice,
- 'numd' => $numd == false ? 0 : $numd,
- 'zhe' => $money['money'] + $orderPrice,
- 'name' => '合約賬戶',
- 'czstatus' => 2,
- 'txstatus' => 2,
- ];
- } elseif ($id == 4) {
- $data = [
- 'num' => $user[$cinfo['name']],
- 'numd' => $user[$cinfo['name'] . 'd'],
- 'zhe' => $user[$cinfo['name']],
- 'czstatus' => $cinfo['czstatus'],
- 'txstatus' => $cinfo['txstatus'],
- ];
- $data['name'] = '資金賬戶';
- }elseif ($id == 29) {
- $marketinfo = M("market")->where(array('name'=>"gcb_usdt"))->find();
- $data = [
- 'num' => $user[$cinfo['name']],
- 'numd' => $user[$cinfo['name'] . 'd'],
- 'zhe' => round($user[$cinfo['name']] * $marketinfo['new_price'], 6),
- 'czstatus' => $cinfo['czstatus'],
- 'txstatus' => $cinfo['txstatus'],
- ];
- $data['name'] = $cinfo['title'];
- } else {
- $oy_list = do_request(oy_url($cinfo['name'], 'api/v5/market/ticker?instId='), []);
- $oy_list = $oy_list->data[0];
- $close = $oy_list->last;//现价
- $data = [
- 'num' => $user[$cinfo['name']],
- 'numd' => $user[$cinfo['name'] . 'd'],
- 'zhe' => round($user[$cinfo['name']] * $close, 2),
- 'czstatus' => $cinfo['czstatus'],
- 'txstatus' => $cinfo['txstatus'],
- ];
- $data['name'] = $cinfo['title'];
- }
- $this->ajaxReturn(['code' => 1, 'data' => $data, 'info' => '']);
- }
- //提币详情
- public function txinfo()
- {
- $id = trim(I('get.oid'));
- $info = M("myzc")->where(array('id' => $id))->find();
- $this->ajaxReturn(['code' => 1, 'data' => $info]);
- // $this->assign('info',$info);
- // $this->display();
- }
- //提币列表
- public function txlist()
- {
- $uid = userid();
- $txlist = M("myzc")->where(array('userid' => $uid))->order('id desc')->select();
- $this->ajaxReturn(['code' => 1, 'data' => $txlist]);
- // $this->assign("txlist",$txlist);
- // $this->display();
- }
- //提币处理
- public function tbhandle()
- {
- // if($_POST){
- $uid = userid();
- $uinfo = M("user")->where(array('id' => $uid))->field("id,rzstatus,username,txstate,is_tax,taxstatus")->find();
- if (empty($uinfo)) {
- $this->ajaxReturn(['code' => 0, 'info' => L('请先登陆')]);
- }
- if ($uinfo['rzstatus'] != 2) {
- $this->ajaxReturn(['code' => 0, 'info' => L('请先完成实名认证')]);
- }
- if ($uinfo['txstate'] != 1) {
- $this->ajaxReturn(['code' => 0, 'info' => L('禁止提币')]);
- }
- //检查该会员是不是需要缴纳税金,如有需要检查有没有缴纳
- if ($uinfo['is_tax'] == 1) {
- if ($uinfo['taxstatus'] != 1) {
- $this->ajaxReturn(['code' => 2, '請繳納稅金']);
- }
- }
- $id = trim(I('get.id'));
- if ($id == 5) {
- $id = 4;
- }
- if ($id <= 0) {
- $this->ajaxReturn(['code' => 0, 'info' => L('参数错误')]);
- }
- $address = trim(I('get.address'));
- if ($address == '' || $address == null) {
- $this->ajaxReturn(['code' => 0, 'info' => L('请输入提币地址')]);
- }
- $num = trim(I('get.num'));
- if ($num <= 0) {
- $this->ajaxReturn(['code' => 0, 'info' => L('请输入正确的额度')]);
- }
- $cinfo = M("coin")->where(array('id' => $id))->find();
- if (empty($cinfo)) {
- $this->ajaxReturn(['code' => 0, 'info' => L('参数错误')]);
- }
- if ($num < $cinfo['txminnum']) {
- $this->ajaxReturn(['code' => 0, 'info' => L('不能低于最小提币值')]);
- }
- if ($num > $cinfo['txmaxnum']) {
- $this->ajaxReturn(['code' => 0, 'info' => L('不能高于最大提币值')]);
- }
- $coinname = $cinfo['name'];
- $minfo = M("user_coin")->where(array('userid' => $uid))->find();
- $sxftype = $cinfo['sxftype'];
- if ($sxftype == 1) {
- $sxf = $num * $cinfo['txsxf'] / 100;
- } elseif ($sxftype == 2) {
- $sxf = $cinfo['txsxf_n'];
- }
- if ($sxf <= 0 || $sxf == '') {
- $sxf = 0;
- }
- $tnum = $num - $sxf;
- if ($minfo[$coinname] < $num) {
- $this->ajaxReturn(['code' => 0, 'info' => L('账户余额不足')]);
- }
- $dec_re = M("user_coin")->where(array('userid' => $uid))->setDec($coinname, $num);
- $data['userid'] = $uid;
- $data['username'] = $uinfo['username'];
- $data['coinname'] = $cinfo['name'];
- $data['num'] = $num;
- $data['fee'] = $sxf;
- $data['mum'] = $tnum;
- $data['address'] = $address;
- $data['sort'] = 1;
- $data['addtime'] = date("Y-m-d H:i:s", time());
- $data['endtime'] = date("Y-m-d H:i:s", time());
- $data['status'] = 1;
- $result = M("myzc")->add($data);
- //操作日志
- $bill['uid'] = $uid;
- $bill['username'] = $uinfo['username'];
- $bill['num'] = $num;
- $bill['coinname'] = $cinfo['name'];
- $bill['afternum'] = $minfo[$coinname] - $num;
- $bill['type'] = 2;
- $bill['addtime'] = date("Y-m-d H:i:s", time());
- $bill['st'] = 2;
- $bill['remark'] = "提币申请";
- $billre = M("bill")->add($bill);
- if ($result && $dec_re && $billre) {
- $this->ajaxReturn(['code' => 1, 'info' => L('提交成功')]);
- } else {
- $this->ajaxReturn(['code' => 0, 'info' => L('提交失败')]);
- }
- // }else{
- //
- // }
- }
- //判断是否绑定提币地址
- public function getaddress()
- {
- if ($_POST) {
- $id = trim(I('post.id'));
- $coininfo = M("coin")->where(array('id' => $id))->field("id,name")->find();
- if (empty($coininfo)) {
- $this->ajaxReturn(['code' => 0]);
- }
- $coinname = $coininfo['name'];
- $uid = userid();
- $adrinfo = M("user_qianbao")->where(array('userid' => $uid, 'name' => $coinname))->order('id desc')->limit(1)->find();
- if (!empty($adrinfo)) {
- $this->ajaxReturn(['code' => 1]);
- } else {
- $this->ajaxReturn(['code' => 0]);
- }
- } else {
- $this->ajaxReturn(['code' => 0]);
- }
- }
- //添加地址处理
- public function upplusaddress()
- {
- // if($_POST){
- $uid = userid();
- if ($uid <= 0) {
- $this->ajaxReturn(['code' => 0, 'msg' => L('请先登陆')]);
- }
- $uinfo = M("user")->where(array('id' => $uid))->field("id,username")->find();
- $address = trim(I('get.address'));
- $remark = trim(I('get.remark'));
- $oid = trim(I('get.oid'));
- if ($oid <= 0) {
- $this->ajaxReturn(['code' => 0, 'msg' => L('缺少重要参数')]);
- }
- if ($address == '') {
- $this->ajaxReturn(['code' => 0, 'msg' => L('请输入提币地址')]);
- }
- if ($remark == '') {
- $this->ajaxReturn(['code' => 0, 'msg' => L('请输入备注')]);
- }
- $cinfo = M("coin")->where(array('id' => $oid))->find();
- $data['userid'] = $uid;
- $data['coinname'] = $uinfo['username'];
- $data['name'] = $cinfo['name'];
- $data['remark'] = $remark;
- $data['addr'] = $address;
- $data['sort'] = 1;
- $data['addtime'] = date("Y-m-d H:i:s", time());
- $data['status'] = 1;
- $result = M('user_qianbao')->add($data);
- if ($result) {
- $this->ajaxReturn(['code' => 1, 'msg' => L('添加成功')]);
- } else {
- $this->ajaxReturn(['code' => 0, 'msg' => L('添加失败')]);
- }
- }
- //添加地址
- public function plusaddress()
- {
- $id = trim(I('get.id'));
- $cinfo = M("coin")->where(array('id' => $id))->find();
- $this->assign('info', $cinfo);
- $this->display();
- }
- //添加的提币的地址
- public function txaddlist()
- {
- $id = trim(I('get.id'));
- $cinfo = M("coin")->where(array('id' => $id))->find();
- $coinname = $cinfo['name'];
- $uid = userid();
- $qblist = M("user_qianbao")->where(array('userid' => $uid, 'name' => $coinname))->order("id desc")->select();
- $this->assign('qblist', $qblist);
- $this->assign('id', $id);
- $this->assign('coinname', $coinname);
- $this->display();
- }
- //提币页面
- public function txpage()
- {
- $id = trim(I('get.id'));
- if ($id <= 0) {
- $this->redirect('User/txcoin');
- }
- $info = M("coin")->where(array('id' => $id))->find();
- if ($info['id'] == 5) {
- $coinname = 'usdt';
- } else {
- $coinname = $info['name'];
- }
- $uid = userid();
- $minfo = M("user_coin")->where(array('userid' => $uid))->find();
- $money = $minfo[$coinname];
- $adrinfo = M("user_qianbao")->where(array('userid' => $uid, 'name' => $coinname))->order('id desc')->limit(1)->find();
- $data = [
- 'info' => $info,
- 'adrinfo' => $adrinfo,
- 'money' => $money,
- ];
- $this->ajaxReturn(['code' => 1, 'data' => $data, 'info' => '']);
- }
- //提现币列表
- public function txcoin()
- {
- $uid = userid();
- if ($uid <= 0) {
- $this->ajaxReturn(['code' => 0, 'info' => L('请先登陆')]);
- }
- $clist = M("coin")->where(array('txstatus' => 1))->field("id,name,title")->select();
- $minfo = M("user_coin")->where(array('userid' => $uid))->find();
- if (!empty($clist)) {
- foreach ($clist as $k => $v) {
- if ($v['id'] == 5) {
- $coinname = 'usdt';
- } else {
- $coinname = $v['name'];
- }
- $coin_num = $minfo[$coinname];
- $data[$k]['cname'] = strtoupper($coinname);
- $data[$k]['title'] = $v['title'];
- $data[$k]['id'] = $v['id'];
- $data[$k]['cnum'] = $coin_num;
- }
- }
- $this->ajaxReturn(['code' => 1, 'data' => $data, 'info' => '']);
- }
- //提币地址管理
- public function addresslist()
- {
- $uid = userid();
- if ($uid <= 0) {
- $this->ajaxReturn(['code' => 0, 'info' => L('请先登陆')]);
- }
- $adrlist = M("user_qianbao")->where(array('uid' => $uid))->select();
- $this->ajaxReturn(['code' => 1, 'data' => $adrlist, 'info' => '']);
- }
- //删除提币地址
- public function deladdress($aid)
- {
- $uid = userid();
- if ($uid <= 0) {
- $this->ajaxReturn(['code' => 0, 'info' => L('请先登陆')]);
- }
- $ainfo = M("user_qianbao")->where(array('id' => $aid))->find();
- if (empty($ainfo)) {
- $this->ajaxReturn(['code' => 0, 'info' => L('提币地址不存在')]);
- }
- $delre = M("user_qianbao")->where(array('id' => $aid))->delete();
- if ($delre) {
- $this->ajaxReturn(['code' => 1, 'info' => L('删除成功')]);
- } else {
- $this->ajaxReturn(['code' => 0, 'info' => L('删除失败')]);
- }
- }
- //充值列表
- public function czlist()
- {
- $uid = userid();
- $mlist = M("recharge")->where(array('uid' => $uid))->order("id desc")->select();
- foreach ($mlist as &$item) {
- $item['payimg'] = 'https://' . $_SERVER['HTTP_HOST'] . '/Upload/public/' . $item['payimg'];
- }
- $this->ajaxReturn(['code' => 1, 'data' => $mlist, 'info' => '']);
- }
- public function czinfo()
- {
- $id = trim(I('get.oid'));
- $uid = userid();
- $info = M("recharge")->where(array('uid' => $uid, 'id' => $id))->order("id desc")->find();
- $info['payimg'] = 'https://' . $_SERVER['HTTP_HOST'] . '/Upload/public/' . $info['payimg'];
- $this->ajaxReturn(['code' => 1, 'data' => $info, 'info' => '']);
- // if(empty($info)){
- // $this->redirect('User/czlist');
- // }
- // $this->assign("info",$info);
- // $this->display();
- }
- //上传转账号凭证
- public function paycoin()
- {
- // if($_POST){
- $uid = userid();
- $uinfo = M("user")->where(array('id' => $uid))->field("id,username")->find();
- if (empty($uinfo)) {
- $this->ajaxReturn(['code' => 0, 'info' => L('请先登陆')]);
- }
- $cid = trim(I('get.cid'));
- $zznum = trim(I('get.zznum'));
- $payimg = trim(I('get.payimg'));
- $coinname = trim(I('get.coinname'));
- if ($zznum <= 0) {
- $this->ajaxReturn(['code' => 0, 'info' => L('请输入正确充值数量')]);
- }
- if ($payimg == "") {
- $this->ajaxReturn(['code' => 0, 'info' => L('请上传转账凭证')]);
- }
- if ($coinname == "") {
- $this->ajaxReturn(['code' => 0, 'info' => L('缺少重要参数')]);
- }
- if ($cid == "") {
- $this->ajaxReturn(['code' => 0, 'info' => L('缺少重要参数')]);
- }
- $cinfo = M("coin")->where(array('id' => $cid))->find();
- $minnum = $cinfo['czminnum'];
- if ($zznum < $minnum) {
- $this->ajaxReturn(['code' => 0, 'info' => L('低于最低额度')]);
- }
- $data['uid'] = $uid;
- $data['username'] = $uinfo['username'];
- $data['coin'] = strtoupper($coinname);
- $data['num'] = $zznum;
- $data['addtime'] = date("Y-m-d H:i:s", time());
- $data['updatetime'] = date("Y-m-d H:i:s", time());
- $data['status'] = 1;
- $data['payimg'] = $payimg;
- $data['msg'] = '';
- $result = M("recharge")->add($data);
- if ($result) {
- $this->ajaxReturn(['code' => 1, 'info' => L('凭证提交成功')]);
- } else {
- $this->ajaxReturn(['code' => 0, 'info' => L('凭证提交失败')]);
- }
- // }else{
- // $this->ajaxReturn(['code'=>0,'info'=> L('参数错误')]);
- // }
- }
- /* 币种列表页 */
- public function qianbao_coin_list()
- {
- $this->display();
- }
- public function qianbaoadd()
- {
- $this->display();
- }
- //我的资产中心
- public function index()
- {
- $uid = userid();
- if ($uid <= 0) {
- $this->redirect('Login/index');
- }
- $clist = M("coin")->where(array('status' => 1))->order('id asc')->field("id,name")->select();
- $clist[] = [
- 'id' => 30,
- 'name' => 'Futures-USDT'
- ];
- foreach ($clist as &$item) {
- if ($item['id'] == 4) {
- $item['name'] = 'Wallets-USDT';
- }
- }
- $this->assign("list", $clist);
- $this->display();
- }
- public function getsymbol()
- {
- $symbol = trim(I('post.symbol'));
- $symbol = strtolower($symbol);
- $map['name'] = array('like', "%$symbol%");
- $info = M("coin")->where($map)->field("name,title,id")->find();
- $uname = strtoupper($info['name']);
- $info['uname'] = $uname;
- //print_r($info);die;
- $this->ajaxReturn(['code' => 1, 'info' => $info]);
- }
- //获取单个提币币种列表
- public function getcoinnum()
- {
- $symbol = trim(I('post.symbol'));
- $symbol = strtolower($symbol);
- $map['name'] = array('like', "%$symbol%");
- $info = M("coin")->where($map)->field("name,title,id")->find();
- $coinname = $info['name'];
- $uid = userid();
- $minfo = M("user_coin")->where(array('userid' => $uid))->find();
- if (!empty($minfo)) {
- $cnum = $minfo[$coinname];
- }
- $data['cname'] = strtoupper($info['name']);
- $data['title'] = $info['title'];
- $data['cnum'] = $cnum;
- $data['id'] = $info['id'];
- $this->ajaxReturn(['code' => 1, 'info' => $data]);
- }
- //币种充值页面
- public function czpage()
- {
- $id = trim(I('get.id'));
- if ($id <= 0) {
- $this->ajaxReturn(['code' => 2, 'data' => '', 'info' => '选择充值币种']);
- }
- $infos = M("coin")->where(array('id' => $id))->find();
- if ($infos['czstatus'] != 1) {
- $this->ajaxReturn(['code' => 2, 'data' => '', 'info' => '不支持充值']);
- }
- $this->ajaxReturn(['code' => 1, 'data' => $infos, 'info' => '']);
- }
- //充值币明细
- public function czcoin()
- {
- $uid = userid();
- if ($uid <= 0) {
- $this->ajaxReturn(['code' => 3, 'data' => '', 'info' => L('未登录')]);
- }
- $name = I('get.name');
- $where = [];
- if ($name) $where[] = ['title' => strtoupper($name)];
- $list = M("coin")->where(array('status' => 1))->where($where)->order('sort asc')->field("name,title,id,czstatus")->select();
- foreach ($list as $k => $v) {
- if ($v['name'] == 'ercus') {
- unset($list[$k]);
- }
- }
- $this->ajaxReturn(['code' => 1, 'data' => $list, 'info' => '']);
- }
- //获取行情数据
- public function get_maket_api($api)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
- curl_setopt($ch, CURLOPT_URL, $api);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
- $result = json_decode(curl_exec($ch), true);
- return $result;
- }
- public function login()
- {
- $this->display();
- }
- public function qianbao()
- {
- $this->display();
- }
- public function upqianbao()
- {
- }
- public function delqianbao()
- {
- }
- //会员登陆日志
- public function log()
- {
- if (!userid()) {
- redirect("/Login/index.html");
- }
- $where['status'] = array('egt', 0);
- $where['userid'] = userid();
- $Model = M('UserLog');
- $count = $Model->db(1, 'DB_Read')->where($where)->count();
- $Page = new \Think\Page($count, 10);
- $show = $Page->show();
- $list = $Model->db(1, 'DB_Read')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
- $this->assign('list', $list);
- $this->assign('page', $show);
- $this->display();
- }
- //上传图片
- public function recharge_img()
- {
- $upload = new \Think\Upload();
- $upload->maxSize = 3145728;
- $upload->exts = array('jpg', 'gif', 'png', 'jpeg');
- $upload->rootPath = './Upload/public/';
- $upload->autoSub = false;
- $info = $upload->upload();
- $host = $_SERVER['HTTP_HOST'];
- foreach ($info as $k => $v) {
- $path = $v['savepath'] . $v['savename'];
- $response = array(
- 'code' => 0,
- 'msg' => L('上传成功'),
- 'data' => array(
- 'src' => 'https://' . $host . '/Upload/public/' . $path,
- 'img' => $path
- )
- );
- echo json_encode($response);
- exit();
- }
- }
- /**
- * 资金列表
- * @return void
- */
- public function usercoin()
- {
- $uid = userid();
- if ($uid <= 0) {
- $this->ajaxReturn(['code' => 3, 'data' => '', 'info' => L('未登录')]);
- }
- $clist[] = [
- 'id' => 30,
- 'name' => '合約賬戶'
- ];
- $clist = array_merge($clist, M("coin")->where(array('status' => 1))->order('id asc')->field("id,name")->select());
- $user = M('user_coin')->where(['userid' => $uid])->find();
- foreach ($clist as &$item) {
- if ($item['id'] == 4) {
- $item['name'] = '資金賬戶';
- }
- }
- unset($clist[2]);
- $price = 0;
- foreach ($clist as &$item) {
- if ($item['name'] == '合約賬戶') {
- $money = M('levermoney')->where(['uid' => $uid])->find();
- $numd = M('leverorder')->where(['uid' => $uid])->where('status = 1 or status = 2')->sum('bond');
- $order = M('leverorder')->where(['uid' => $uid])->where(['status' => 2])->select();
- $orderPrice = 0;
- foreach ($order as $vo) {
- $oy_list = do_request(oy_url($vo['coinname'], 'api/v5/market/ticker?instId='), []);
- $oy_list = $oy_list->data[0];
- $close = $oy_list->last;//现价
- if ($vo['direction'] == 1) { //做多
- $profit = sprintf("%.2f", ($close - $vo['price']) * $vo['num']);
- } elseif ($vo['direction'] == 2) { //做空
- $profit = sprintf("%.2f", ($vo['price'] - $close) * $vo['num']);
- }
- $orderPrice += $profit;
- }
- $item['data'] = [
- 'num' => $money['money'] + $orderPrice,
- 'numd' => $numd,
- 'zhe' => $money['money'] + $orderPrice,
- ];
- $price += ($money['money'] + $orderPrice);
- } elseif ($item['name'] == '資金賬戶') {
- $item['data'] = [
- 'num' => $user['usdt'],
- 'numd' => $user['usdtd'],
- 'zhe' => $user['usdt'],
- ];
- $price += ($user['usdt'] + $user['usdtd']);
- }elseif ($item['name'] == 'gcb') {
- $marketinfo = M("market")->where(array('name'=>"gcb_usdt"))->find();
- $item['data'] = [
- 'num' => $user['gcb'],
- 'numd' => $user['gcbd'],
- 'zhe' => round($user['gcb'] * $marketinfo['new_price'], 6),
- ];
- $price += ($user['gcb'] * $marketinfo['new_price']);
- } else {
- $oy_list = do_request(oy_url($item['name'], 'api/v5/market/ticker?instId='), []);
- $oy_list = $oy_list->data[0];
- $close = $oy_list->last;//现价
- $item['data'] = [
- 'num' => $user[$item['name']],
- 'numd' => $user[$item['name'] . 'd'],
- 'zhe' => $user[$item['name']] * $close,
- ];
- // $price += ($user[$item['name']]+$user[$item['name'].'d']);
- $price += ($user[$item['name']] * $close);
- }
- }
- session('user_price', $price);
- $this->ajaxReturn(['code' => 1, 'data' => $clist, 'info' => '']);
- }
- public function bill()
- {
- $uid = userid();
- if ($uid <= 0) {
- $this->ajaxReturn(['code' => 3, 'data' => '', 'info' => L('未登录')]);
- }
- $name = trim(I('get.name'));
- $page = I('get.page');
- if (!$page) $page = 1;
- $limit = I('get.limit');
- if (!$limit) $limit = 10;
- if ($name == '合約賬戶') {
- $list = M('bill')->where(['uid' => $uid])->where(['coinname' => 'lever'])->order('id DESC')->page($page, $limit)->select();
- } elseif ($name == '資金賬戶') {
- $list = M('bill')->where(['uid' => $uid])->where(['coinname' => 'usdt'])->order('id DESC')->page($page, $limit)->select();
- } else {
- $list = M('bill')->where(['uid' => $uid])->where(['coinname' => strtolower($name)])->order('id DESC')->page($page, $limit)->select();
- }
- $this->ajaxReturn(['code' => 1, 'data' => $list, 'info' => '']);
- }
- public function userinfo()
- {
- $uid = userid();
- if ($uid <= 0) {
- $this->ajaxReturn(['code' => 3, 'data' => '', 'info' => L('未登录')]);
- }
- $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();
- $icon = M('user_coin')->where(['userid' => $uid])->find();
- $money = M('levermoney')->where(['uid' => $uid])->find();
- if (!$money) $money['money'] = 0;
- $list['usdt'] = $icon['usdt'];
- $list['http'] = 'https://' . $_SERVER['HTTP_HOST'] . '/Upload/public/';
- $order = M('leverorder')->where(['uid' => $uid])->where(['status' => 2])->select();
- $orderPrice = 0;
- foreach ($order as $vo) {
- $oy_list = do_request(oy_url($vo['coinname'], 'api/v5/market/ticker?instId='), []);
- $oy_list = $oy_list->data[0];
- $close = $oy_list->last;//现价
- if ($vo['direction'] == 1) { //做多
- $profit = sprintf("%.2f", ($close - $vo['price']) * $vo['num']);
- } elseif ($vo['direction'] == 2) { //做空
- $profit = sprintf("%.2f", ($vo['price'] - $close) * $vo['num']);
- }
- $orderPrice += $profit;
- }
- $sy = $money['money'] + $orderPrice;
- if ($sy <= 0) {
- $sy = 0;
- }
- $list['money'] = $sy;
- $this->ajaxReturn(['code' => 1, 'data' => $list, 'info' => '']);
- }
- }
- ?>
|