public function postdata() { $this->glob = get_global_setting(); $user_money = M("member_money")->where("uid = {$this->uid}")->find(); //判断是否满足免费体验资格 $quota_map['status'] = array("not in", "1,4"); $quota_map['uid'] = $this->uid; $quata_num = D("shares_apply")->where("(status not in(1,4) AND uid = {$this->uid}) OR (status = 1 AND type_id = 4 AND uid = {$this->uid})")->count(); //$quata_num = D("shares_apply")->where(" uid = {$this->uid}")->count(); //dump($quata_num);die; if ($quata_num != 0) { echo jsonmsg('很抱歉,您不具备免费体验配资资格!', 0); exit; } //当天范围 $today_start = strtotime(date("Y-m-d 00:00:00", time())); $today_end = strtotime(date("Y-m-d 23:59:59", time())); $free_map = array(); $free_map['type_id'] = 4; $free_map['status'] = array("in", "1,2,3"); $free_map['add_time'] = array("between", array($today_start, $today_end)); $free_num = D("shares_apply")->where($free_map)->count(); //判断是否满足免费体验名额 if ($free_num >= $this->glob['free_num']) { echo jsonmsg('今日免费体验名额已满,请明天再来!', 0); exit; } //判断用户是否登录 if (session('u_id') == null) { echo jsonmsg('您还没有登录,请先登录!', 2); exit; } //判断是否实名认证 /*$ids = M('members_status')->getFieldByUid($this->uid,'id_status'); if($ids!=1){ echo jsonmsg('您还未完成身份验证,请先进行实名认证!',2);exit; }*/ //判断是否手机认证 /*$phones = M('members_status')->getFieldByUid($this->uid,'phone_status'); if($phones!=1){ echo jsonmsg('您还未手机认证,请先进行手机认证!',3);exit; }*/ $uid = $this->uid; $count = getMoneylimit($this->uid); $all_money = $count + 1; if ($all_money > $user_money['account_money'] + $user_money['back_money']) { echo jsonmsg('您的可用余额不足以支付您所有的配资申请费用,请等待审核完成或进行充值!', 4); exit; } //执行添加 $_POST['uid'] = $this->uid; $ret = D("SharesApply")->addFreeStock(); if ($ret) { echo jsonmsg('恭喜配资成功!', 1); exit; } else { echo jsonmsg('恭喜配资失败!', 0); exit; } }
public function postdata() { $datag = get_global_setting(); $this->assign("glo", $datag); //查询余额是否充足 $member_money = M('member_money')->where("uid = {$this->uid}")->find(); /* //判断是否实名认证 $ids = M('members_status')->getFieldByUid($this->uid,'id_status'); if($ids!=1){ echo jsonmsg('您还未完成身份验证,请先进行实名认证!',0);exit; } */ //判断是否手机认证 /*$phones = M('members_status')->getFieldByUid($this->uid,'phone_status'); if($phones!=1){ echo jsonmsg('您还未手机认证,请先进行手机认证!',0);exit; }*/ $term_config = D("SharesType")->getMonthtermConfig(); foreach ($term_config as $k => $v) { $overterm_config[] = $k; } $money_config = D("SharesType")->getMonthmoneyConfig(); if ($this->_post("principal") > $money_config[1] || $this->_post("principal") < $money_config[0]) { echo jsonmsg("数据有误", 0); exit; } elseif (!in_array($this->_post('lever_id'), $overterm_config)) { echo jsonmsg("数据有误", 0); exit; } elseif ($this->_post("duration") < 1 || $this->_post("duration") > 24) { echo jsonmsg("数据有误", 0); exit; } elseif ($_POST['trading_time'] > 2 || $_POST['trading_time'] < 1) { echo jsonmsg("数据有误", 0); exit; } $uid = $this->uid; $money = D("SharesApply")->where("uid = {$uid} and status = 1")->sum("principal + one_manage_fee"); $all_money = $money + $this->_post("principal"); if ($all_money > $member_money['account_money'] + $member_money['back_money']) { echo jsonmsg('您的可用余额不足以支付您所有的配资申请费用,请等待审核完成或进行充值!', 0); exit; } //执行添加 $_POST['uid'] = $this->uid; $ret = D("SharesApply")->addMonthStock(); if ($ret) { echo jsonmsg('恭喜配资成功!', 1); exit; } else { echo jsonmsg('配资失败!', 0); exit; } }
/** * 购买债权提示框 * */ public function buydebt() { //判断用户是否登录 if (session('u_id') == null) { echo jsonmsg('您还没有登录,请先登录!', 2); exit; } $invest_id = intval($_REQUEST['invest_id']); !$invest_id && ajaxmsg(L('参数错误'), 0); $debt = M("invest_detb")->field("transfer_price, money")->where("invest_id={$invest_id}")->find(); $buy_user = M("member_money")->field("account_money, back_money")->where("uid={$this->uid}")->find(); $account = $buy_user['account_money'] + $buy_user['back_money']; $this->assign('debt', $debt); $this->assign('account', $account); $this->assign('invest_id', $invest_id); $d['content'] = $this->fetch(); echo json_encode($d); }
public function edit() { $invest_id = $_POST['id']; $status = array(); $status['status'] = 2; $map = array(); $map['id'] = $invest_id; $ret = M("current_investor")->where($map)->save($status); $vo = M('current_investor')->find($invest_id); $day = buy_day($vo['add_time']); if ($day < 0) { echo jsonmsg('活期理财为次日计息方式!', 0); die; } if ($ret) { echo jsonmsg('提取成功,请耐心等待审核:)!', 1); } else { echo jsonmsg('提取失败!', 0); } }
public function doopens() { $id = $_GET['id']; $map = array(); $map['id'] = $id; $savedata = array(); $savedata['is_want_open'] = 1; $ret = M('shares_apply')->where($map)->save($savedata); if ($ret) { echo jsonmsg("申请成功,请耐心等待管理员审核!", 1); } else { echo jsonmsg("申请失败!", 0); } }
function applyeven($id) { //配资id $savedata['is_want_open'] = 1; $savedata['id'] = $id; $savedata['want_open_time'] = time(); $ret = M("shares_apply")->save($savedata); if ($ret) { echo jsonmsg("平仓申请成功,请等待处理!", 1); exit; } else { echo jsonmsg("平仓申请失败或已申请并正在处理中!", 0); exit; } }
$return = jsonmsg(array($lang['ajaxstatus_err1'], false)); } break; case 'delete': $status_history = unserialize($CURUSER['archive']); if (isset($status_history[$id])) { unset($status_history[$id]); if (sql_query('UPDATE ustatus SET archive = ' . sqlesc(serialize($status_history)) . ' WHERE userid = ' . sqlesc($CURUSER['id']))) { $return = jsonmsg(array('ok', true)); } else { $return = jsonmsg(array($lang['ajaxstatus_err2'], false)); } } else { $return = jsonmsg(array($lang['ajaxstatus_err3'], false)); } break; case 'new': $status_archive = isset($CURUSER['archive']) && is_array(unserialize($CURUSER['archive'])) ? unserialize($CURUSER['archive']) : array(); if (!empty($CURUSER['last_status'])) { $status_archive[] = array('status' => $CURUSER['last_status'], 'date' => $CURUSER['last_update']); } if (sql_query('INSERT INTO ustatus(userid,last_status,last_update,archive) VALUES(' . sqlesc($CURUSER['id']) . ',' . sqlesc(url2short($ss)) . ',' . TIME_NOW . ',' . sqlesc(serialize($status_archive)) . ') ON DUPLICATE KEY UPDATE last_status=values(last_status),last_update=values(last_update),archive=values(archive)')) { $return = jsonmsg(array('<h2>' . $lang['ajaxstatus_successfully'] . '</h2>', true)); } else { $return = jsonmsg(array($lang['ajaxstatus_err'] . (is_object($GLOBALS["___mysqli_ston"]) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)), false)); } break; default: $return = jsonmsg(array($lang['ajaxstatus_err4'], false)); } echo $return;
$return = jsonmsg(array('nothing to update, string empty', false)); } break; case 'delete': $status_history = unserialize($CURUSER['archive']); if (isset($status_history[$id])) { unset($status_history[$id]); if (sql_query('UPDATE ustatus SET archive = ' . sqlesc(serialize($status_history)) . ' WHERE userid = ' . sqlesc($CURUSER['id']))) { $return = jsonmsg(array('ok', true)); } else { $return = jsonmsg(array('there was an error', false)); } } else { $return = jsonmsg(array('incorrect id', false)); } break; case 'new': $status_archive = isset($CURUSER['archive']) && is_array(unserialize($CURUSER['archive'])) ? unserialize($CURUSER['archive']) : array(); if (!empty($CURUSER['last_status'])) { $status_archive[] = array('status' => $CURUSER['last_status'], 'date' => $CURUSER['last_update']); } if (sql_query('INSERT INTO ustatus(userid,last_status,last_update,archive) VALUES(' . sqlesc($CURUSER['id']) . ',' . sqlesc(url2short($ss)) . ',' . TIME_NOW . ',' . sqlesc(serialize($status_archive)) . ') ON DUPLICATE KEY UPDATE last_status=values(last_status),last_update=values(last_update),archive=values(archive)')) { $return = jsonmsg(array('<h2>Status update successful</h2>', true)); } else { $return = jsonmsg(array('There was an error, mysql error' . (is_object($GLOBALS["___mysqli_ston"]) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)), false)); } break; default: $return = jsonmsg(array('Unknow action', false)); } echo $return;
public function getMeMonery() { /* //判断是否实名认证 $ids = M('members_status')->getFieldByUid($this->uid,'id_status'); if($ids!=1){ echo jsonmsg('<font style="color:#E74A4A;font-weight:bold;font-size:16px;margin-bottom:30px;">您还未完成身份验证,请先进行实名认证!</font>',0);exit; } */ //判断是否手机认证 /*$phones = M('members_status')->getFieldByUid($this->uid,'phone_status'); if($phones!=1){ echo jsonmsg('<font style="color:#E74A4A;font-weight:bold;font-size:16px;margin-bottom:30px;">您还未手机认证,请先进行手机认证!</font>',1);exit; }*/ $res = M("shares_global")->where("code='cps_1'")->getField("text"); if ($this->_post('memonery') < $res) { echo jsonmsg('<font style="color:#E74A4A;font-weight:bold;font-size:16px;margin-bottom:30px;">数据有误!</font>', 4); exit; } $res = get_cps_trader('shares_global'); $data = array(); $data['principal'] = $_POST['memonery']; //用户的本金 $data['type_id'] = 3; //类型id 3代表操盘手 $data['uid'] = $_SESSION['u_id']; //申请人uid $data['lever_ratio'] = $res[2]; //倍率 $data['order'] = 'cps_' . time() . mt_rand(1000, 100000); //订单号 $data['shares_money'] = $data['principal'] * $res[2]; //配资金额 $noticerate = $res[3] / 100; $closerate = $res[4] / 100; $data['open'] = $closerate * $data['principal'] + $data['shares_money']; //平仓线 = 平仓线比率*本金+操盘资金 $data['alert'] = $noticerate * $data['principal'] + $data['shares_money']; //警戒线 = 平仓线比率*本金+操盘资金 $data['open_ratio'] = $res[4]; //平仓线比率 $data['alert_ratio'] = $res[3]; //警戒线比率 $data['add_time'] = time(); $data['ip_address'] = get_client_ip(); //获取客户端ip $data['status'] = 1; //待审核 $data['duration'] = $res[5]; //交易天数 $data['total_money'] = $data['principal'] + $data["shares_money"]; //总操盘资金 = 用户本金+配资金额 $data['trading_time'] = $_POST['istoday']; //是否今天交易 $data['u_name'] = $_SESSION['u_user_name']; /** 查询用户余额 如果用户余额足以支付则提交申请,不足以支付的时候返回配资失败 */ //用户id $id = $_SESSION['u_id']; $result = getBalance('member_money', "back_money,account_money", "uid={$id}"); if ($result) { //查询成功 $total_money = $result['back_money'] + $result['account_money']; //获取用户的余额 if ($total_money - $data['principal'] >= 0) { //用户的余额足够支付保证金 //扣除保证金 $deduct = $result["back_money"] - $data['principal']; if ($deduct >= 0) { $update['back_money'] = $deduct; $umoney = M("member_money")->where("uid={$id}")->save($update); if (!$umoney) { echo '1'; exit; } else { //写入到日志 $ainfo = $data['order'] . '我是操盘手订单支付保证金'; $areturnlog = pzmembermoneylod($data['principal'], $data['uid'], $ainfo, '', 52); } } else { $update['account_money'] = $result['account_money'] - abs($deduct); $umoney = M("member_money")->where("uid={$id}")->save($update); if (!$umoney) { //更新失败 echo '1'; exit; } else { $ainfo = $data['order'] . '我是操盘手订单支付保证金'; $areturnlog = pzmembermoneylod($data['principal'], $data['uid'], $ainfo, '', 52); } } $addapply = M('shares_apply'); $res = $addapply->add($data); if ($res) { echo '0'; //成功 exit; } else { echo '1'; //失败 exit; } } else { echo '2'; //余额不足 exit; } } else { echo '1'; exit; } }
public function doexapplyeven() { $id = $this->_post("id"); $counttrader = $this->_post("counttrader"); if ($this->_post("status") == 0) { $ret = M("shares_apply")->where("id = {$id}")->setField("is_want_open", 0); if ($ret) { echo jsonmsg("处理完成", 1); exit; } } elseif ($this->_post("status") == 1) { $ret = doapplyeven($id, $counttrader); if ($ret) { echo jsonmsg("处理完成", 1); exit; } } }
public function postdata() { $days = intval($_POST['days']); $stock_money = $_POST['stock_money']; $type = $_POST['type']; $istoday = $_POST['istoday']; if (!$istoday) { echo jsonmsg('数据有误!', 0); exit; } elseif (!$type) { echo jsonmsg('数据有误!', 0); exit; } elseif ($days < 2 || $days > 30) { echo jsonmsg('配资天数有误!', 0); exit; } elseif ($stock_money < 1000) { echo jsonmsg('配资金额小于最小配资金额!', 0); exit; } $uid = $this->uid; $glo = M('shares_global')->field('text')->where("code = " . "'{$type}'")->find(); $glos = explode('|', $glo['text']); $guarantee_money = $stock_money / $glos[0]; //保证金 $interest = $stock_money * ($glos[1] / 1000) * $days; //总利息 $user_money = M('member_money')->where("uid = {$this->uid}")->find(); $uid = $this->uid; $count = getMoneylimit($this->uid); $all_money = $count + $guarantee_money + $interest; if ($all_money > $user_money['account_money'] + $user_money['back_money']) { echo jsonmsg('您的可用余额不足以支付您所有的配资申请费用,请等待审核完成或进行充值!', 4); exit; } /* //判断是否实名认证 $ids = M('members_status')->getFieldByUid($this->uid,'id_status'); if($ids!=1){ echo jsonmsg('您还未完成身份验证,请先进行实名认证!',2);exit; } //判断是否手机认证 $phones = M('members_status')->getFieldByUid($this->uid,'phone_status'); if($phones!=1){ echo jsonmsg('您还未手机认证,请先进行手机认证!',3);exit; } */ $ret = stockmoney($days, $stock_money, $type, $istoday, $uid); if ($ret) { echo jsonmsg('恭喜配资成功!', 1); } else { echo jsonmsg('Sorry,配资失败!', 0); } //dump($daydata);die; }