예제 #1
0
 /**
  * ription 用户帐号充值处理
  * 
  * @param int $account_in_out
  *            增加/减少
  * @param int $txt_account
  *            数量
  * @param int $uid
  *            用户id
  * @param string $tex_memo
  *            备注
  */
 public function reset_account()
 {
     if (!$this->check_power('account_manage')) {
         return;
     }
     $account_in_out = intval($this->input->post('account_in_out'));
     $txt_account = intval($this->input->post('txt_account'));
     $uid = intval($this->input->post('uid'));
     $tex_memo = $this->input->post('tex_memo');
     // 检查是否存在该学生
     $account = CommonModel::get_student($uid, 'account,account_status');
     if (!$account) {
         output_json(CODE_ERROR, '不存在该学生.');
     } elseif ($account['account_status']) {
         output_json(CODE_ERROR, '学生帐号已被冻结');
     }
     $account = $account['account'];
     $vc = C('virtual_currency');
     if ($account_in_out == 2) {
         $account = $account - $txt_account;
         if ($account < 0) {
             output_json(CODE_ERROR, '学生帐号余额不足');
         }
         $txt_account = -$txt_account;
     } else {
         $account += $txt_account;
     }
     $insert_data = array('tr_uid' => $uid, 'tr_type' => 2, 'tr_flag' => 1, 'tr_comment' => $tex_memo, 'tr_money' => $account, 'tr_trade_amount' => $txt_account, 'tr_adminid' => $this->session->userdata('admin_id'));
     $db = Fn::db();
     if ($db->beginTransaction()) {
         TransactionRecordModel::addTransactionRecord($insert_data);
         // 修改学生帐号资金
         CommonModel::reset_account($uid, $account);
         $flag = $db->commit();
         if (!$flag) {
             $db->rollBack();
             output_json(CODE_ERROR, '帐号充值失败,请重试');
         }
         output_json(CODE_SUCCESS, '帐号充值成功.');
     }
     output_json(CODE_ERROR, '帐号充值失败,请重试');
 }
예제 #2
0
 /**
  * 充值
  */
 public function paying()
 {
     if (!$this->_uinfo['uid']) {
         redirect('student/index/login');
     }
     if (!C('paycharge_enable')) {
         message('您没有权限访问该功能');
     }
     $uid = $this->_uinfo['uid'];
     $data = array();
     $data['uinfo'] = $this->_uinfo;
     $account = trim($this->input->post('begin_time'));
     if (!is_numeric($account)) {
         message('请输入正确的数字');
     }
     $account2 = bcadd($account, 0.0, 1);
     if (bccomp($account2, $account, 6) != 0) {
         message('请输入正确的最多保留一位小数的数字');
     }
     if (bccomp($account2, '0.0', 1) <= 0) {
         message('请输入正确的大于零的数字');
     }
     $account = $account2;
     $insert_array = array();
     $insert_array = array();
     if ($uid) {
         /*
          * 基本信息
          */
         $uid = intval($uid);
         $student = CommonModel::get_student($uid);
         if (empty($student)) {
             message('信息不存在');
             return;
         }
         $tr_amount = $account * 10;
         $param = array('tr_uid' => $uid, 'tr_type' => 1, 'tr_flag' => 0, 'tr_money' => $student['account'] + $tr_amount, 'tr_cash' => $account, 'tr_trade_amount' => $tr_amount, 'tr_comment' => '支付宝充值');
         $number = TransactionRecordModel::addTransactionRecord($param);
         $html_text = StudentAlipayModel::paying($number, $account);
         $data = array('html_text' => $html_text);
         $this->load->view('profile/paying', $data);
     } else {
         $this->load->view('profile/paying');
     }
 }