public function sendsms() { $end = session('smstime') + 90 - time(); if ($end > 1) { $this->error('距离上一次发送还有' . $end . '秒'); } else { $phone = session('user.phone'); $code = rand(10000, 99999); session('smscode', $code, 90); session('smstime', time()); if (is_sms()) { $sms_message = '验证码:' . $code; send_sms($phone, $sms_message); $this->success('短信已发送至手机!'); } else { $this->success($code); } } }
public function forgotpwd_sendsms() { $phone = I('post.phone'); $reged = M('user')->where(array('phone' => $phone))->find(); if (!$reged) { $this->error('用户未注册'); } $code = rand(10000, 99999); session('smscode', $code, 600); if (is_sms()) { $sms_message = '验证码:' . $code; send_sms($phone, $sms_message); $this->success('短信已发送至手机!'); } else { $this->success($code); } }
public function zmlpay() { if (IS_POST) { $HttpPost = I('post.'); $money = $HttpPost['money']; $User = M('user'); // 启动事务 $User->startTrans(); $User_Money_Details = M('user_money_details'); //查询用户信息 $userinfo = $User->where(array('uin' => $HttpPost['uin']))->find(); //增加用户资金 $set_money = $User->where(array('uin' => $HttpPost['uin']))->setInc('money', $money); //写入资金明细 $money_details_data['uin'] = $userinfo['uin']; $money_details_data['title'] = '在线转账'; $money_details_data['type'] = 1; //进账 $money_details_data['money'] = $money; $money_details_data['balance'] = $userinfo['money'] + $money; $money_details_data['user_ip'] = get_client_ip(); $money_details_data['status'] = 1; $money_details_data['remark'] = '在线转账:' . $money . '元,' . $HttpPost['remark']; $money_details_data['create_time'] = time(); $add_money_details = $User_Money_Details->data($money_details_data)->add(); if ($HttpPost['is_sms'] == 1 and is_sms()) { $sms_message = '您收到平台转账资金:' . $money . '元,请查收!'; send_sms($userinfo['phone'], $sms_message); } if ($set_money and $add_money_details) { // 成功,提交事务 $User->commit(); $this->success('转账成功!'); } else { // 失败,事务回滚 $User->rollback(); $this->success('转账失败,请重试~!'); } } else { $this->display(); } }