function debit($id, $amount) { #Debit amount from user with id $id = mysql_real_escape_string($id); $amount = mysql_real_escape_string($amount); $amount = btcToSatoshi($amount); $balance = getBalance($id); #Make sure enough balance is present if ($balance < $amount) { return -1; } $balance -= $amount; if (!newBalance($id, $balance)) { return -2; } return 0; }
function existing_user($action) { logToFile("existing user", "action = {$action}"); session_start(); if ($action == 999) { return; } // reset was initiated, skip sending text if ($action == 0) { $text = "BLUPAY :: Welcome back. Reply with SEND, REQUEST, BALANCE or '?'"; } if ($action == 1) { $text = "BLUPAY :: Send keyword detected"; } if ($action == 2) { $text = "BLUPAY :: Request keyword detected"; } if ($action == 3) { $balance = getBalance($GLOBALS['user_phone_num']); $text = "BLUPAY :: Your balance is {$balance} dollars."; } send_text(0, $text); }
$res = checkMsg($_REQUEST['content']); break; //发送短信 //发送短信 case "sendmsg": $sender = $_REQUEST['sender']; //发送人姓名 $reciever = $_REQUEST['reciever']; //接收人姓名 $recieverPhone = $_REQUEST['recieverPhone']; //接收人手机号 $content = $_REQUEST['content']; //content $time = isset($_REQUEST['time']) ? $_REQUEST['time'] : null; // 定时短信,时间格式20090101101010 $res = sendMsg($sender, $reciever, $recieverPhone, $content, $time, 'sendSMS'); break; //查询余额 //查询余额 case "getbalance": $res = getBalance(); break; //从运营商收取短信 --- 这个接口添加到定时任务里 //从运营商收取短信 --- 这个接口添加到定时任务里 case "getmsgfromvendor": $res = syncWithMsgVendorServer(); break; default: throw new Exception("unknown action:" . $action); } echo json_encode($res);
case 2: $errid = substr($result,strpos($result,"=")+1); break; } $i ++; } if($id != 0) { $smarty->assign("SMS_MONEY", $id/10); } else { $smarty->assign("SMS_MONEY", iconv_ec("GB2312","UTF-8",$err)); } fclose($fp); } */ //$result = logout(); //echo "logout:".print_r($result,true)."<br>"; //$result = loginSMS(); //echo "login:"******"<br>"; $info = getBalance($current_user->id); //$result = logout(); //echo "logout:".print_r($result,true)."<br>"; if ($info["error"] == 1) { $smarty->assign("SMS_MONEY", $info["message"]); } else { $smarty->assign("SMS_MONEY", $info["balance"] * 10); } $smarty->assign("MOD", return_module_language($current_language, 'Settings')); $smarty->assign("IMAGE_PATH", $image_path); $smarty->assign("APP", $app_strings); $smarty->assign("CMOD", $mod_strings); $smarty->display("Relsettings/MessageConfig.tpl");
function addTransaction($userId, $amount, $project_title, $project_id, $authorId) { global $db_con; $balance = getBalance($userId); $balance = intval($balance) - intval($amount); $amountToSave = 0 - $amount; $description = 'payment for ' . $project_title; $insertPayment = "INSERT INTO `payments` SET\n `transaction_id` = 'inner-transaction',\n `type` = 'payment',\n `description` = '" . $description . "',\n\t\t\t `amount` = " . $amountToSave . ",\n\t\t\t `user_id` = " . $userId . ",\n\t\t\t `balance` = " . $balance . ",\n\t\t\t `project_id` = " . $project_id . ",\n\t\t\t `created_by` = " . $userId; $db_con->query($insertPayment); updateBalance($userId, $balance); $balance = getBalance($authorId); $balance = intval($balance) + intval($amount); $amountToSave = $amount; $description = 'royalty for ' . $project_title; $insertRoyalty = "INSERT INTO `payments` SET\n `transaction_id` = 'inner-transaction',\n `type` = 'royalty',\n `description` = '" . $description . "',\n\t\t\t `amount` = " . $amountToSave . ",\n\t\t\t `user_id` = " . $authorId . ",\n\t\t\t `balance` = " . $balance . ",\n\t\t\t `project_id` = " . $project_id . ",\n\t\t\t `created_by` = " . $userId; $db_con->query($insertRoyalty); updateBalance($authorId, $balance); }
public function getMeMonery() { $jsoncode = file_get_contents("php://input"); $arr = array(); $arr = json_decode($jsoncode, true); if (!is_array($arr) || empty($arr) || empty($arr['uid'])) { ajaxmsg("查询错误!", 0); } $ids = M('members_status')->getFieldByUid($this->uid, 'id_status'); if ($ids != 1) { ajaxmsg('您还未完成身份验证,请先进行实名认证!', 0); } //判断是否手机认证 $phones = M('members_status')->getFieldByUid($this->uid, 'phone_status'); if ($phones != 1) { ajaxmsg('您还未手机认证,请先进行手机认证!', 0); } $res = get_cps_trader('shares_global'); $data = array(); $data['principal'] = $arr['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'] = $arr['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; */ ajaxmsg("成功"); } else { /*echo '1'; //失败 exit; */ ajaxmsg("失败", 1); } } else { /*echo '2'; //余额不足 exit; */ ajaxmsg("余额不足", 2); } } else { /*echo '1'; exit; */ ajaxmsg("退出", 1); } }
<?php include template("manage_header");?> <div id="bdw" class="bdw"> <div id="bd" class="cf"> <div id="coupons"> <div class="dashboard" id="dashboard"> <ul></ul> </div> <div id="content" class="coupons-box clear mainwide"> <div class="box clear"> <div class="box-top"></div> <div class="box-content"> <div class="head"> <h2>信息记录(剩余数量:<?php echo getBalance()*10; ?> 条 <?php echo $day; ?>发送: <?php echo $smsnum?$smsnum:0; ?> 条)</h2> </div> <div class="sect" style="padding:0 10px;"> <form method="get"> <p style="margin:5px 0;">手机号码:<input type="text" name="mobile" class="h-input number" value="<?php echo $mobile; ?>" > 关键字:<input type="text" name="title" class="h-input text" value="<?php echo $title; ?>" > 日期:<input type="text" class="h-input" onFocus="WdatePicker({isShowClear:false,readOnly:true})" name="cbday" value="<?php echo $cbday; ?>" /> - <input type="text" class="h-input" onFocus="WdatePicker({isShowClear:false,readOnly:true})" name="ceday" value="<?php echo $ceday; ?>" /> <input type="submit" value="筛选" class="formbutton" style="padding:1px 6px;"/></p> <form> </div> <div class="sect"> <table id="orders-list" cellspacing="0" cellpadding="0" border="0" class="coupons-table"> <tr><th width="40">ID</th><th width="100">手机号码</th><th width="400">信息记录</th><th width="100">发送数量</th><th width="100">日期</th></tr> <?php if(is_array($smslog)){foreach($smslog AS $index=>$one) { ?> <tr <?php echo $index%2?'':'class="alt"'; ?> id="team-list-id-<?php echo $one['id']; ?>"> <td><?php echo $one['id']; ?></a></td> <td><?php echo $one['mobile']; ?></td> <td><?php echo $one['smslog']; ?></td> <td><?php echo $one['number']; ?></td> <td nowrap><?php echo date('Y-m-d H:i:s',$one['sms_time']); ?></td> </tr>
global $current_language; global $adb; //Display the mail send status $smarty = new CRMSmarty(); $query = "select * from ec_smsaccount where userid='" . $current_user->id . "' "; $row = $adb->getFirstLine($query); if (!empty($row)) { $smarty->assign("userid", $row['userid']); $smarty->assign("username", $row['username']); $smarty->assign("password", $row['password']); } else { $smarty->assign("userid", $current_user->id); $smarty->assign("username", ''); $smarty->assign("password", ''); } $result = getBalance($current_user->id); if ($result['error'] == 0) { $smarty->assign("num", $result['balance']); } else { $smarty->assign("num", $result['message']); } $systems = getMessageAccount($current_user->id); //$sys_canuse = $systems->canuse; $sys_num = $systems->num; $sys_monthuse = $systems->monthuse; $sys_enddate = $systems->enddate; if ($sys_num <= $sys_monthuse) { $weiyong = 0; } else { $weiyong = $sys_num - $sys_monthuse; }
function sendSmsByTime($message, $phonenames, $sendtime, $userid) { //获取用户信息 if (!is_array($userinfo) || empty($userinfo)) { $userinfo = getSingleInfo($userid); } $info = getBalance($userid); if ($info['error'] == 1) { return array("error" => 1, "message" => "查询余额出错"); } elseif ($info['error'] == 0 && $info['balance'] == 0) { return array("error" => 1, "message" => "没有可用于发送短信的条数"); } $parameters = array('sendresult' => $phonenames, 'message' => $message, 'sendtime' => $sendtime, 'user_name' => $userinfo['username']); $method = "sms_sendSmsByTime"; $result = getCurlResult($parameters, $method); return array("error" => 0); }
$data = updateCustomer(Functions::get('id')); break; case 'info': $data = infoCustomer(Functions::get('id')); break; case 'delete': $data = deleteCustomer(Functions::get('id')); break; case 'total_entries': $data = getTotalEntries(Functions::get('id')); break; case 'total_sells': $data = getTotalSells(Functions::get('id')); break; case 'balance': $data = getBalance(Functions::get('id')); break; case 'favdrink': $data = getFavDrink(Functions::get('id')); break; case 'login': $data = loginUser(); break; case 'logout': $data = logoutUser(); break; case 'list': $data = listCustomers(); break; default: Functions::setResponse(400);
<div class="tel-title"></div> <div class="tel-inner"> <div class="tel-inner-left"> <div class="tel-balance"> <table class="tel-balance-table"> <tr> <td class="tel-balance-left"> <div class="tel-balance-title"><?php echo GetMessage('TELEPHONY_BALANCE'); ?> </div> <div class="tel-balance-sum-wrap"> <span class="tel-balance-box"> <span class="tel-balance-box-inner"> <?php echo getBalance($amount); ?> </span> <span class="tel-balance-box-line"></span> </span> <?php echo getCurrency($currency); ?> </div> </td> <td class="tel-balance-right"> <div class="tel-balance-btn-wrap"> <a href="?REFRESH" class="tel-balance-update-btn"> <img class="tel-balance-update-loader" src="/bitrix/images/1.gif"/> <span class="tel-balance-update-btn-icon"></span> <span class="tel-balance-update-btn-text"><?php
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; } }