function addUserWithDraw($uid, $price) { //判断一天只可提现一次 $query = $this->getUserTodayWithdrawQuery($uid); if ($query->num_rows() > 0) { $this->set_message("每天只可提现一次,英雄请明天再来。"); return false; } //判断余额够不够 lm('user_profile_model'); $userprofile = $this->user_profile_model->getUserProfileArray($uid); if (element('totalmoney', $userprofile) - element('totalmoney_lock', $userprofile) < $price) { $this->set_message("可提现余额没有这么多了"); return false; } $this->db->trans_begin(); //添加记录 $data = array('sno' => getsno($this->table), 'uid' => $uid, 'wctype' => USER_WITHDRAW_WCTYPE_WITHDRAW, 'price' => $price, 'realprice' => $price, 'applydate' => time(), 'status' => USER_WITHDRAW_STATUS_UNDONE); $this->db->insert($this->table, $data); //修改余额 $this->user_profile_model->updateUserTotalMoneyLock($uid); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $this->set_message("提现请求出错,请联系管理员。"); return false; } else { $this->db->trans_commit(); } return true; }
/** * 未达保留价支付金额 */ function failedPay() { $did = p('did'); $result = 0; $message = "未做任何操作"; if (is_numeric($did)) { lm('user_moneylog_model'); lm('bid_report_model'); $bidReport = $this->bid_report_model->getDidReportAndDomainArray($did); if (element('optstatus', $bidReport) == DOMAIN_BID_REPORT_OPTSTATUS_UNDONE) { $sellerId = element('uid', $bidReport); $firstUserId = element('uid1', $bidReport); $adminId = adminId(); $compensation = getCompensation($bidReport); $compensationUser = round($compensation / 2, 2); //$this->user_moneylog_model->addUserMoney($sellerId,0,$price,USER_MONEYLOG_LOGTYPE_GIVERESERVEFEE,'发放域名补偿金'); $this->user_moneylog_model->addUserMoney($firstUserId, 0, $compensationUser, USER_MONEYLOG_LOGTYPE_RECEIVERESERVEFEE, '收到域名' . element('domainname', $bidReport) . '小费'); $this->user_moneylog_model->addUserMoney($adminId, 0, $compensationUser, USER_MONEYLOG_LOGTYPE_RECEIVERESERVEFEE, '收到域名' . element('domainname', $bidReport) . '小费'); $this->bid_report_model->updateDidReportOptStatus($did, DOMAIN_BID_REPORT_OPTSTATUS_DONE); $result = 1; $message = "处理成功"; } else { $message = '已处理,无需重复处理。'; } } echo '{"code":"' . $result . '","message":"' . $message . '"}'; }
function totalMoneyConverter() { lm('user_profile_model'); $users = $this->db->get('b_user_users')->result_array(); foreach ($users as $item) { $this->user_profile_model->updateUserTotalMoneyLock(element('id', $item)); } }
function addUserMoney($uid, $oid, $price, $logtype, $typedesc = "", $sno = "") { $price = round($price, 2); //检查站内余额 lm('user_profile_model'); $profile = $this->user_profile_model->getUserProfileArray($uid); if (element('totalmoney', $profile) + $price < 0) { return false; } if (empty($oid) || !empty($oid) && $this->db->where('uid', $uid)->where('oid', $oid)->get($this->table)->num_rows() < 1) { $this->addMoneyLog($uid, $oid, $typedesc, $price, element('totalmoney', $profile) + $price, $logtype, $sno); return true; } return false; }
function header($view) { //view同级下是否存在对应的header $header = $view . '_header'; $viewPath = APPPATH . 'views/'; $data['controller'] = $this->CI->router->fetch_class(); if (uli()) { //获取用户信息 lm('user_model'); $data['userprofile'] = $this->CI->user_model->getUserProfileByIdArray(uid()); } if (file_exists($viewPath . $header . '.php')) { lv($header, $data); } else { lv('header', $data); } }
public function get_cities_by_box() { $sWest = $this->getQueryVal('west'); $sEast = $this->getQueryVal('east'); $sNorth = $this->getQueryVal('north'); $sSouth = $this->getQueryVal('south'); $aConditions = array('City.lon >' => $sWest, 'City.lon <' => $sEast, 'City.lat <' => $sNorth, 'City.lat >' => $sSouth); $tmp = $this->City->find('all', array('conditions' => $aConditions)); lm('konds ' . print_r($aConditions, true) . ' tmp ' . print_r($tmp, true)); $result = array(); foreach ($tmp as $item) { $result[] = $item['City']; } $data = array('success' => true, 'data' => $result); $this->layout = 'ajax'; $this->set('data', $data); $this->render('/Site/Common/JsonResponse'); }
/** * 投过标的、管理员、卖家可以看结果。 * @param unknown_type $uid * @param unknown_type $did * @return boolean */ function canAccessDomainBidList($uid, $did) { $CI =& get_instance(); ll('ion_auth'); if (!uli()) { return false; } if ($CI->ion_auth->is_admin()) { return true; } lm('domain_model'); if ($CI->domain_model->isDomainBelongtoUser($did, $uid)) { return true; } lm('bid_model'); if ($CI->bid_model->getUserDidDetailQuery($uid, $did)->num_rows() > 0) { return true; } return false; }
function index() { if (!uli()) { redirect('auth/login'); } $day = intval($this->uri->segment(3)); if (empty($day) || $day <= 0 || $day > 7) { $day = 1; } $time = time(); $pageStartDate = $time + 86400 * ($day - 1); $pageEndDate = 86400 + $pageStartDate; //首页放出所有域名,临时加上的 if ($day == 1) { $pageEndDate = 604800 + $pageStartDate; } lm('domain_model'); $data['day'] = $day; $data['todaySelling'] = $this->domain_model->getTodayDomainListArray(uid(), $pageStartDate, $pageEndDate); $data['todayOver'] = $this->domain_model->getTodayOverListArray($time); lfv('home/home_index', $data); }
function createBidReport($did, $bidResultQuery, $bidLimit) { //每个域名只有一个报表 $this->db->where('did', $did)->delete($this->table); $data = array(); $data['did'] = $did; $data['bidcount'] = $bidResultQuery->num_rows(); $data['pubdate'] = time(); $data['optstatus'] = DOMAIN_BID_REPORT_OPTSTATUS_UNDONE; $count = 1; foreach ($bidResultQuery->result_array() as $item) { $data['uid' . $count] = element('uid', $item); $data['price' . $count] = element('price', $item); $count++; if ($count > 3) { break; } } lm('domain_model'); $domain = $this->domain_model->getDomainByIdArray($did); if ($bidResultQuery->num_rows() < $bidLimit) { //出价数少于10算流拍 $data['status'] = DOMAIN_SELL_FAILED; $data['failreason'] = DOMAIN_BID_REPORT_FAILREASON_LESSBIDCOUNT; } else { if (!empty($data['price2']) && $data['price2'] < element('reserveprice', $domain)) { $data['status'] = DOMAIN_SELL_FAILED; $data['failreason'] = DOMAIN_BID_REPORT_FAILREASON_RESERVEPRICE; } else { $data['status'] = DOMAIN_SELL_SUCCESSED; } } $this->db->insert($this->table, $data); return $this->db->affected_rows(); }
$val = isset($arr[$o][$i]) ? $arr[$o][$i] : 0; @($sum[$i] += $val); } } return $sum; } function carry($arr) { for ($i = 0; $i < count($arr); $i++) { $s = (string) $arr[$i]; switch (strlen($s)) { case 2: $arr[$i] = $s[1]; @($arr[$i + 1] += $s[0]); break; case 3: $arr[$i] = $s[2]; @($arr[$i + 1] += $s[0] . $s[1]); break; } } return ltrim(implode('', array_reverse($arr)), '0'); } function lm($a, $b) { return carry(longAdd(longMult($a, $b))); } if (lm('18446744073709551616', '18446744073709551616') == '340282366920938463463374607431768211456') { echo 'pass!'; } // 2^64 * 2^64
function getPage($code) { $CI =& get_instance(); lm('page_model'); return $CI->page_model->getPageByCodeArray($code); }
function addUserBid($uid, $did, $price) { $credit = $price; //大于1元的出价要计算信用额度 if ($price <= 1) { //1元党不扣费用 $credit = 0; } //更新b_user_creditlocklog表 lm('user_creditlocklog_model'); lm('user_profile_model'); if (empty($price)) { //出价为0,删除出价记录 $this->db->where('uid', $uid)->where('did', $did)->delete($this->table); $this->user_creditlocklog_model->updateCreditlockLogPriceByDidAndUid($uid, $did, $credit, $price, USER_CREDITLOCK_ISLOCK_FALSE); $this->user_creditlocklog_model->updateUserProfileCreditLock($uid); return true; } else { //计算信用额度是否够用, //1000的额度,同一个域名,先出价100,再出价950,就会提示额度不足,所以需要判断同一个域名的情况,解决方法:先调价,再算额度,不够回滚---不可行,表死锁。 $userProfile = $this->user_profile_model->getUserProfileArray($uid); $bidQuery = $this->getUserDidDetailQuery($uid, $did); $creditCanUse = element('totalcredit', $userProfile) - element('totalcredit_lock', $userProfile); if (element('totalcredit', $userProfile) < 1 && $credit != 0) { return false; } //第一次对该域名出价 if ($bidQuery->num_rows() < 1) { //用户可用额度大于消耗额度 if ($creditCanUse >= 0) { $data = array('uid' => $uid, 'did' => $did, 'isvalid' => B_BID_ISVALID_TRUE, 'price' => $price, 'credit' => $credit, 'pubdate' => time()); $this->db->insert($this->table, $data); $lid = $this->user_creditlocklog_model->addUserCreditlockLog(uid(), $did, $credit, $price, USER_CREDITLOCK_LOGTYPE_BID, USER_CREDITLOCK_ISLOCK_TRUE); } else { return false; } } else { $bidCredit = element('credit', $bidQuery->row_array()); //用户可用额度大于消耗额度(要减去已出价的额度) if ($creditCanUse + $bidCredit >= 0) { //删除旧出价 $this->db->where('uid', $uid)->where('did', $did)->delete($this->table); //增加新出价 $data = array('uid' => $uid, 'did' => $did, 'isvalid' => B_BID_ISVALID_TRUE, 'price' => $price, 'credit' => $credit, 'pubdate' => time()); $this->db->insert($this->table, $data); //删除出价日志 $this->db->where('uid', $uid)->where('did', $did)->delete($this->userCreditlockTable); $this->user_creditlocklog_model->addUserCreditlockLog(uid(), $did, $credit, $price, USER_CREDITLOCK_LOGTYPE_BID, USER_CREDITLOCK_ISLOCK_TRUE); } else { return false; } } //出价日志,暂时不记了,creditylog只用来记用户调整额度 //lm('User_creditylog_model'); //$this->User_creditylog_model->addUserCreditLog($uid,element('bid', element('bid', $bidQuery->row_array())),$price,$credit,'出价'); //调整锁定额度 lm('user_creditlocklog_model'); $this->user_creditlocklog_model->updateUserProfileCreditLock($uid); // //判断额度不够用回滚,参考前面注释 // lm('user_profile_model'); // $newProfile = $this->user_profile_model->getUserProfileArray($uid); // if(element('totalcredit_lock', $newProfile) > element('totalcredit', $newProfile)) // { // $this->db->trans_rollback(); // return false; // } } return true; }
function show() { $did = $this->uri->segment(3); if (is_numeric($did)) { lm('domain_model'); $domain = $this->domain_model->getDomainAndBidCountByIdArray($did); if (!empty($domain)) { lm('bid_model'); if (uli()) { $userbid = $this->bid_model->getUserBidByUseridAndBidArray(uid(), $did); $data['userbid'] = $userbid; } if (element('deadline', $domain) < time()) { //已过期,判断是否需要生成结果报表 lm('bid_report_model'); lm('user_creditlocklog_model'); $domainBidlist = $this->bid_model->getDomainBidListQuery($did); if ($this->bid_report_model->getDidReportQuery($did)->num_rows() < 1) { $this->db->trans_start(); $this->bid_report_model->createBidReport($did, $domainBidlist, element('bidlimit', $domain)); $bidReport = $this->bid_report_model->getDidReportQuery($did)->row_array(); $reCalculateCreditLockUsers = array(); //如果拍卖成功,除了卖家和第一名的买家,其它人的信用额度要返还,流拍时,返还所有人的额度 if (element('status', $bidReport) == DOMAIN_SELL_FAILED) { $this->user_creditlocklog_model->updateCreditlockLogIslockByDid($did, USER_CREDITLOCK_ISLOCK_FALSE); foreach ($domainBidlist->result_array() as $biditem) { $reCalculateCreditLockUsers[] = element('uid', $biditem); } //卖家不出价,上面的列表中没有,需要加上卖家; $reCalculateCreditLockUsers[] = element('uid', $domain); } else { if (element('status', $bidReport) == DOMAIN_SELL_SUCCESSED) { //除了卖家和买家(第一名)其它都解锁 $exceptUidArray = array(element('uid', $domain), element('uid1', $bidReport)); $this->user_creditlocklog_model->updateCreditlockLogIslockWithRange($did, array(), $exceptUidArray, USER_CREDITLOCK_ISLOCK_FALSE); foreach ($domainBidlist->result_array() as $biditem) { if (element('uid', $biditem) != element('uid1', $bidReport)) { $reCalculateCreditLockUsers[] = element('uid', $biditem); } } } } foreach ($reCalculateCreditLockUsers as $tempUserId) { $this->user_creditlocklog_model->updateUserProfileCreditLock($tempUserId); } //非流拍才需要处理 //系统 站内余额功能2013年7月3日0点(1372780800)上线,这之前不生成订单 if (element('pubdate', $bidReport) > 1372867200 && !empty($bidReport) && element('status', $bidReport) == DOMAIN_SELL_SUCCESSED && element('mark', $bidReport) == 0 && element('mark1', $bidReport) == 0) { //生成订单处理业务 lm('domain_order_model'); //如果已生成就无需再生成 if ($this->domain_order_model->getDomainOrderQuery($did)->num_rows() < 1) { //生成初始的order信息 $this->domain_order_model->addInitDomainOrder($domain, $bidReport); $this->bid_report_model->updateDidReportOptStatus($did, DOMAIN_BID_REPORT_OPTSTATUS_UNDONE); } } $this->db->trans_complete(); } else { $bidReport = $this->bid_report_model->getDidReportQuery($did)->row_array(); } $data['bidReport'] = $bidReport; //出价列表被查了两次,需优化 TODO $data['bidListArray'] = $this->bid_model->getDomainBidListArray($did); } lm('user_model'); lm('bid_model'); lm('page_model'); $data['user'] = $this->user_model->getUserProfileByIdArray($domain['uid']); $data['userProfile'] = $this->user_model->getUserProfileByIdArray(uid()); $data['relDomain'] = $this->domain_model->getUserRelDomainArray($domain['uid'], $did); $data['domain'] = $domain; lfv('domain/domain_show', $data); } else { redirect(''); } } else { redirect(''); } }
function rules() { lm('page_model'); $data['page'] = $this->page_model->getPageByCodeArray('rules'); lfv('page/page_rules', $data); }
function updateOrderStatus($did, $oid, $opt) { $opts = array('break', 'pay'); if (!in_array($opt, $opts)) { $this->session->set_flashdata('messages', '不允许的操作。'); return false; } $domainOrder = $this->getDomainOrderQuery($did)->result_array(); if (count($domainOrder) != 4) { $this->session->set_flashdata('messages', '数据有误, 请联系开发人员。'); return false; } lm('bid_report_model'); $bidReport = $this->bid_report_model->getDidReportAndDomainArray($did); if (element('status', $bidReport) == DOMAIN_SELL_FAILED) { $this->session->set_flashdata('messages', '域名流拍,无需处理。'); return false; } if (element('optstatus', $bidReport) == DOMAIN_BID_REPORT_OPTSTATUS_DONE) { $this->session->set_flashdata('messages', '域名已处理,不能重复处理。'); return false; } $isBreak = isDomainBreak($domainOrder); $seller = $domainOrder[0]; $buyer = $domainOrder[1]; $prize2 = $domainOrder[2]; $prize3 = $domainOrder[3]; $this->db->trans_start(); $data = array(); $data['update'] = time(); switch ($opt) { case 'pay': lm('user_moneylog_model'); $price = 0; $uid = 0; $data['optuid'] = uid(); //卖家支付 if ($oid == element('oid', $seller)) { $data['status'] = DOMAIN_ORDER_PAID; $uid = element('uid', $seller); $price = element('price', $seller); $this->updateStatusByData($did, $oid, $data); /*暂不扣减站内余额 //修改站内余额 站内余额不够时回滚记录 $res = $this->user_moneylog_model->addUserMoney($uid,$oid,$price,USER_MONEYLOG_LOGTYPE_GIVEBREAKFEE); if(!$res) { $this->session->set_flashdata('messages','支付出错,请确认是否余额不足。'); $this->db->trans_rollback(); return false; } */ //如果是违约,给购买者违约金 if ($isBreak) { $price = element('price', $buyer); $uid = element('uid', $buyer); $oid = element('oid', $buyer); $data['status'] = DOMAIN_ORDER_RECEIVED; $this->updateStatusByData($did, $oid, $data); $this->user_moneylog_model->addUserMoney($uid, $oid, $price, USER_MONEYLOG_LOGTYPE_RECEIVEBREAKFEE); } } else { if ($oid == element('oid', $buyer)) { $data['status'] = DOMAIN_ORDER_PAID; $uid = element('uid', $buyer); $price = element('price', $buyer); $this->updateStatusByData($did, $oid, $data); //暂不扣减站内余额 //修改站内余额 站内余额不够时回滚记录 /*$res = $this->user_moneylog_model->addUserMoney($uid,$oid,$price,USER_MONEYLOG_LOGTYPE_GIVEBREAKFEE); if(!$res) { $this->session->set_flashdata('messages','支付出错,请确认是否余额不足。'); $this->db->trans_rollback(); return false; }*/ //给卖家发违约金 $price = element('price', $seller); $uid = element('uid', $seller); $oid = element('oid', $seller); $data['status'] = DOMAIN_ORDER_RECEIVED; $this->updateStatusByData($did, $oid, $data); $this->user_moneylog_model->addUserMoney($uid, $oid, $price, USER_MONEYLOG_LOGTYPE_RECEIVEBREAKFEE); } } $logType = USER_MONEYLOG_LOGTYPE_RECEIVEPRIZE; if ($isBreak) { $logType = USER_MONEYLOG_LOGTYPE_RECEIVEBREAKFEE; } // 付款给中奖的人 $price = element('price', $prize2); $uid = element('uid', $prize2); $oid = element('oid', $prize2); $data['status'] = DOMAIN_ORDER_RECEIVED; $this->updateStatusByData($did, $oid, $data); $this->user_moneylog_model->addUserMoney($uid, $oid, $price, $logType, '收到' . element('domainname', $bidReport) . '的奖金,第2名'); $price = element('price', $prize3); $uid = element('uid', $prize3); $oid = element('oid', $prize3); $data['status'] = DOMAIN_ORDER_RECEIVED; $this->updateStatusByData($did, $oid, $data); $this->user_moneylog_model->addUserMoney($uid, $oid, $price, $logType, '收到' . element('domainname', $bidReport) . '的奖金,第3名'); //处理完成 lm('bid_report_model'); $bidStatus = array('optstatus' => DOMAIN_BID_REPORT_OPTSTATUS_DONE); $this->bid_report_model->updateFieldWithValueByDid($did, $bidStatus); //释放信用额度 lm('user_creditlocklog_model'); $this->user_creditlocklog_model->updateCreditlockLogIslockWithRange($did, array(element('uid', $buyer), element('uid', $seller)), array(), USER_CREDITLOCK_ISLOCK_FALSE); $this->user_creditlocklog_model->updateUserProfileCreditLock(element('uid', $buyer)); $this->user_creditlocklog_model->updateUserProfileCreditLock(element('uid', $seller)); break; case 'break': if (!$isBreak) { $data['otype'] = DOMAIN_ORDER_TYPE_BREAK; // 重新计算费用 $data['price'] = -getDomainBreakFee($bidReport, element('price2', $bidReport)); $data['status'] = DOMAIN_ORDER_UNPAID; $this->updateStatusByData($did, $oid, $data); //谁被违约了,计算被违约人费用 //默认卖家违约 $breakedId = element('oid', $buyer); $reportStatus = DOMAIN_SELL_SELLERBREAK; //买家违约 if ($oid == element('oid', $buyer)) { $breakedId = element('oid', $seller); $reportStatus = DOMAIN_SELL_BUYERBREAK; } $data['status'] = DOMAIN_ORDER_UNRECEIVED; $data['otype'] = DOMAIN_ORDER_TYPE_BREAKED; $data['price'] = getDomainBreakedFee($bidReport, element('price2', $bidReport)); $this->updateStatusByData($did, $breakedId, $data); lm('bid_report_model'); $this->bid_report_model->updateDidReportStatus($did, $reportStatus); } break; } $this->db->trans_complete(); return true; }
function creditlog() { ll('pagination'); lm('bid_model'); lm('user_creditlog_model'); lm('user_profile_model'); $query = $this->user_creditlog_model->getUserCreditLogListQuery(uid()); $config['base_url'] = site_url('profile/in'); $config['total_rows'] = $query->num_rows(); $config['per_page'] = 20; $config['uri_segment'] = 3; $config['full_tag_open'] = '<div class="cf"><ul class="pagination pagination_bottom tac">'; $config['full_tag_close'] = '</ul></div>'; $config['first_tag_close'] = '<li>'; $config['num_tag_close'] = '</li>'; $config['num_tag_open'] = '<li>'; $config['num_tag_close'] = '</li>'; $config['prev_tag_open'] = '<li>'; $config['prev_tag_close'] = '</li>'; $config['next_tag_open'] = '<li>'; $config['next_tag_close'] = '</li>'; $config['cur_tag_open'] = '<li class="current"><a href="javascript:void(0)">'; $config['cur_tag_close'] = '</a></li>'; $this->pagination->initialize($config); $data['userprofile'] = $this->user_profile_model->getUserProfileArray(uid()); $data['creditlog'] = $this->user_creditlog_model->getUserCreditLogListQuery(uid(), $config['per_page'], $this->uri->segment(3))->result_array(); $data['pagelinks'] = $this->pagination->create_links(); lfv('profile/profile_creditlog', $data); }
function chargeJsonList() { $iDisplayStart = $this->input->get('iDisplayStart'); $limit = $this->input->get('iDisplayLength'); $keywords = $this->input->get('sSearch'); lm('user_withdraw_charge_model'); $data['userCharge'] = $this->user_withdraw_charge_model->getAllWithdrawChargeListQuery(USER_WITHDRAW_WCTYPE_CHARGE, $keywords, $limit, $iDisplayStart)->result_array(); $data['userChargecount'] = $this->user_withdraw_charge_model->getAllWithdrawChargeListQuery(USER_WITHDRAW_WCTYPE_CHARGE, $keywords)->num_rows(); lv('admin/auser/auser_chargejsonlist', $data); }
function domainavgpricedata() { lm('bid_report_model'); $data['bidReportDataReport'] = $this->bid_report_model->getDomainAvgPriceDataReport(); lv('admin/areport/areport_domainavgpricedata', $data); }