/**
  * 添加金额变动同时更新用户的站内余额总额
  * @param unknown_type $uid
  * @param unknown_type $oid
  * @param unknown_type $typedesc
  * @param unknown_type $price
  * @param unknown_type $currentMoney
  * @param unknown_type $logtype
  * @param unknown_type $sno
  */
 function addMoneyLog($uid, $oid, $typedesc, $price, $currentMoney, $logtype, $sno = "")
 {
     $price = round($price, 2);
     $currentMoney = round($currentMoney, 2);
     if (empty($sno)) {
         $sno = getsno($this->table);
     }
     $data = array('sno' => $sno, 'uid' => $uid, 'oid' => $oid, 'logtype' => $logtype, 'typedesc' => $typedesc, 'price' => $price, 'currentMoney' => $currentMoney, 'pubdate' => time());
     $this->db->insert($this->table, $data);
     $this->updateTotalMoney($uid);
 }
 function addUserCharge($uid, $price)
 {
     if ($price <= 0) {
         $this->set_message("充值金额出错。");
         return false;
     }
     //添加记录
     $data = array('sno' => getsno($this->table), 'uid' => $uid, 'price' => $price, 'applydate' => time(), 'status' => USER_CHARGE_STATUS_UNDONE);
     $this->db->insert($this->table, $data);
     $cid = $this->db->insert_id();
     if ($cid) {
         return true;
     } else {
         $this->set_message("充值请求出错。");
         return false;
     }
 }
 function addUserCharge($uid, $price)
 {
     if ($price > 0) {
         //添加记录
         $sno = getsno($this->table);
         $data = array('sno' => $sno, 'uid' => $uid, 'wctype' => USER_WITHDRAW_WCTYPE_CHARGE, 'price' => $price, 'realprice' => $price, 'applydate' => time(), 'status' => USER_WITHDRAW_STATUS_UNDONE);
         $this->db->insert($this->table, $data);
         $wid = $this->db->insert_id();
         if ($wid) {
             return $wid;
         }
         $this->set_message("提交充值请求失败,请联系管理员。");
         return false;
     }
     $this->set_message("价格不正确");
     return false;
 }
示例#4
0
function getsno($tableName)
{
    /* 选择一个随机的方案 */
    mt_srand((double) microtime() * 1000000);
    $timestamp = gmtime();
    $sno = date('ymdhis') . str_pad(mt_rand(1, 99999), 4, '0', STR_PAD_LEFT);
    /* 到数据库里查找是否已存在 */
    $CI =& get_instance();
    $query = $CI->db->where('sno', $sno)->get($tableName);
    if ($query->num_rows() < 1) {
        /* 否则就使用这个订单号 */
        return $sno;
    }
    /* 如果有重复的,则重新生成 */
    return getsno();
}
示例#5
0
 function addmoney()
 {
     $uid = $this->uri->segment(4);
     $this->load->library('form_validation');
     $this->load->helper('url');
     $this->form_validation->set_rules('money', '金额', 'required|xss_clean|integer');
     $this->form_validation->set_rules('odesc', '说明', 'trim|required|xss_clean');
     if ($this->form_validation->run() == true) {
         //addMoney
         lm('user_moneylog_model');
         $sno = getsno($this->db->dbprefix('user_moneylog'));
         $this->user_moneylog_model->addUserMoney($uid, 0, p('money'), USER_MONEYLOG_LOGTYPE_CHARGE, p('odesc'));
         redirect('admin/auser');
     }
     lm('user_model');
     $userProfile = $this->user_model->getUserProfileByIdArray($uid);
     $data['userProfile'] = $userProfile;
     lav('admin/auser/auser_addmoney', $data);
 }