} $cur_page_url = $GLOBALS['host'] . strtok($_SERVER["REQUEST_URI"], '?') . "?" . ($order && $order != 'gnr' ? "order={$order}&" : "") . ($direction ? "dir={$direction}&" : ""); //Cсылка для new_paginator() $sHref = "%s" . $cur_page_url . "page=%d%s"; if ($page > 1) { $additional_header .= '<link rel="prev" href="' . $cur_page_url . 'page=' . ($page - 1) . '">'; } if ($page < $pages) { $additional_header .= '<link rel="next" href="' . $cur_page_url . 'page=' . ($page + 1) . '">'; } $content = "content.php"; } //------------------------------------------------------------------------------ // Попапы закреплений фрилансеров ---------------------------------------------- $popup = __paramInit('string', 'popup'); $freelancer_binds = new freelancer_binds(); $is_spec = $prof_id > 0; $prof_use = $is_spec ? professions::GetProfessionOrigin($prof_id) : $prof_group_id; $allow_frl_bind = $freelancer_binds->isAllowBind($uid, $prof_use, $is_spec); $binded_to = $freelancer_binds->getBindDateStop($uid, $prof_use, $is_spec); if ($allow_frl_bind || $binded_to) { quickPaymentPopupFrlbind::getInstance()->init(array('prof_id' => $prof_id, 'prof_group_id' => $prof_group_id, 'prof_use' => $prof_use, 'is_spec' => $is_spec, 'ammount' => $freelancer_binds->getPrice($prof_use, $is_spec, (bool) $binded_to, $uid), 'date_stop' => $binded_to, 'autoshow' => $popup == 'bind_prolong', 'addprof' => $is_spec && $freelancer_binds->needAddProf($uid, $prof_use))); } $is_bind_first = $freelancer_binds->isBindFirst($uid, $prof_use, $is_spec); if ($binded_to && !$is_bind_first) { quickPaymentPopupFrlbindup::getInstance()->init(array('prof_id' => $prof_use, 'is_spec' => $is_spec, 'ammount' => $freelancer_binds->getPriceUp($prof_use, $is_spec, $uid), 'autoshow' => $popup == 'bind_up')); } $is_binded_hide = $binded_to && !$freelancer_binds->isAllowBind($uid, $prof_use, $is_spec, false); //------------------------------------------------------------------------------ unset($_SESSION['payed_frl_' . md5($_SERVER['REQUEST_URI'])]); $first_pages = array();
/** * Оплата услуг. * * @param array $order Данные по оплачивоемой услуге * * @return bool */ public function paymentOrder($order) { $_op_code = self::getOpCodeByDiscount($order['op_code']); switch ($_op_code) { // Верификация банковской картой через ЯКассу case 191: $error = $this->account->Buy($account_operation_id, $this->transaction, $order['op_code'], $this->user['uid'], $order['descr'], $order['comment']); if (!$error) { $success = true; //Устанавливаем флаг верификации require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/Verification.php'; $verify = new Verification(); $verify->cardYK($this->user['uid']); //Обновляем сессию //@todo: эта штука не работает! $session = new session(); $session->UpdateVerification($this->user['login']); //Обновляем имя и фамилию $fio = mb_unserialize($order['option']); if (isset($fio['uname']) && isset($fio['usurname'])) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/users.php'; $u = new users(); $u->GetUserByUID($this->user['uid']); $u->uname = $fio['uname']; $u->usurname = $fio['usurname']; $u->Update($this->user['uid'], $db_errors); } //Назначаем возврат require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/billing/BillPayback.php'; BillPayback::getInstance()->requestPayback($order['id'], $this->paymentSysParams['invoiceId'], $order['ammount']); } break; //------------------------------------------------------------------ // Верификация через FF //------------------------------------------------------------------ // Верификация через FF case 117: require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/Verification.php'; $error = $this->account->Buy($account_operation_id, $this->transaction, Verification::FF_OP_CODE, $this->user['uid'], $order['comment'], $order['descr'], 1, 0); $verify = new Verification(); $verify->data = unserialize($order['option']); $this->_db->query('UPDATE verify_ff SET is_pro = ?, bill_id = ? WHERE id = ?', false, $account_operation_id, $order['src_id']); if ($verify->verify($this->user['uid'])) { $this->_db->query('UPDATE verify_ff SET result = TRUE WHERE id = ?', $order['src_id']); $success = true; } break; //------------------------------------------------------------------ // Конкурс //------------------------------------------------------------------ // Конкурс case 9: case 106: case 121: case 122: case 123: case 124: case 125: case 126: case 127: case 128: case 129: case 130: // Платный конкурс // Платный конкурс case 86: // Платный проект (вакансия, устаревший опкод) // Платный проект (вакансия, устаревший опкод) case 53: //Покупка вакансии //Покупка вакансии case 113: //пользователь не PRO //пользователь не PRO case 192: //пользователь PRO //Платные услуги проектов //пользователь PRO //Платные услуги проектов case 138: case 139: case 140: case 141: require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/drafts.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/uploader/uploader.php'; // Публикуем платный проект if ($order['parent_table'] == 'draft_projects') { $draft_id = $order['parent_id']; $this->project_key = md5(uniqid($this->user['uid'])); $tmpPrj = new tmp_project($this->project_key); $tmpPrj->initFromDraft($draft_id, $this->user['uid']); $tproject = $tmpPrj->getProject(); $isMovedToVacancy = false; // Нет конкурса значит его уже опубликовали и оплатили, оставляем деньги на личном счете if ((int) $tproject['prj_id'] <= 0) { // Не тратим деньги на такой конкурс if ($tmpPrj->isKonkurs() && strtotime($tproject['end_date']) <= time()) { $success = true; break; } $error = $tmpPrj->saveProject($this->user['uid'], $proj, $this->ordersPromoCodes); $success = !$error; // Отработали все по конкурсу удаляем его чтобы не мешал (после отработки всех операций) $this->setAfterQuery($this->_db->parse('DELETE FROM draft_projects WHERE id = ? AND uid = ?', $draft_id, $this->user['uid']), $order['parent_id']); $sql = 'UPDATE draft_projects SET prj_id = ? WHERE id = ? AND uid = ?'; $this->_db->query($sql, $proj['id'], $draft_id, $this->user['uid']); } else { $success = true; } } elseif ($order['parent_table'] == 'projects') { $prj_id = $order['parent_id']; $this->project_key = md5(uniqid($this->user['uid'])); $tmpPrj = new tmp_project($this->project_key); $tmpPrj->setInitFromDB($prj_id); $tproject = $tmpPrj->getProject(); $isMovedToVacancy = $tmpPrj->isStateMovedToVacancy(); // Если закрыт или заблокирован не тратим деньги if ($tproject['closed'] == 't' || $tproject['is_blocked'] == 't') { $success = true; break; } switch ($order['option']) { case 'top': $tmpPrj->setAddedTopDays($order['op_count']); break; case 'logo': $LogoFile = new CFile($order['src_id']); $tmpPrj->initLogo($LogoFile, $order['descr']); break; case 'urgent': $tmpPrj->setProjectField('urgent', 't'); break; case 'hide': $tmpPrj->setProjectField('hide', 't'); break; case 'office': $tmpPrj->setProjectField('old_state', $tproject['state']); $tmpPrj->setProjectField('state', projects::STATE_PUBLIC); //Если оплачивается не перемещенная вакансия //то работаем как обычно и подымаем вверх if ($tproject['state'] != projects::STATE_MOVED_TO_VACANCY) { $tmpPrj->setProjectField('post_now', true); } break; } $error = $tmpPrj->saveProject($this->user['uid'], $proj, $this->ordersPromoCodes); $success = !$error; if ($success) { if (isset($tmpPrj->account_operation_id) && $tmpPrj->account_operation_id > 0) { $account_operation_id = $tmpPrj->account_operation_id; } switch ($order['option']) { case 'office': if ($tproject['state'] == projects::STATE_MOVED_TO_VACANCY) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/smail.php'; $smail = new smail(); $smail->sendMovedToVacancySuccessPayed($tproject); require_once $_SERVER['DOCUMENT_ROOT'] . '/guest/models/GuestInviteModel.php'; $guestInviteModel = new GuestInviteModel(); $guestInviteModel->updateDatePublicBySrc($prj_id, array(GuestConst::TYPE_PROJECT, GuestConst::TYPE_VACANCY)); require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/autoresponse.php'; $autoresponse = new autoresponse(); $autoresponse->reduceByProject($prj_id); } break; } } } //Сохраняем, чтобы показать попап юзеру $memBuff = new memBuff(); $memBuff->add('bill_ok_project_' . $this->user['uid'], $proj['id']); //Если это оплата вакансии или конкусра то предлагаем еще купить платные опции if (in_array($order['option'], array('office', 'contest')) && !$isMovedToVacancy) { $memBuff->add('bill_ok_project_payed_' . $this->user['uid'], true); } break; //------------------------------------------------------------------ // Платное место в карусели //------------------------------------------------------------------ // Платное место в карусели case 65: // На главной странице $catalog = 0; case 73: // В каталоге require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/pay_place.php'; $payPlace = new pay_place(isset($catalog) ? $catalog : 1); $buyMain = $this->account->Buy($account_operation_id, $this->transaction, $order['op_code'], $this->user['uid'], $order['comment'], $order['descr'], $order['op_count'], 0, $order['promo_code']); if ($buyMain === 0) { $options = unserialize($order['option']); if (isset($options['adHead'])) { //поддержка старого режима $success = $payPlace->addUser($this->user['uid'], $options['adHead'], $options['adText'], $options['adImg']); } else { $success = $payPlace->addUserRequest($this->user['uid'], $options); } } break; //------------------------------------------------------------------ // ПРО аккаунт фрилансеры //------------------------------------------------------------------ // ПРО аккаунт фрилансеры case 47: // Тестовый ПРО на 1 неделю if (payed::IsUserWasPro($this->user['uid'])) { return false; break; } case 15: // Про на 1 месяц (emp) // Про на 1 месяц (emp) case 48: // Про на 1 месяц (frl) // Про на 1 месяц (frl) case 118: // Про на 3 месяца (emp) // Про на 3 месяца (emp) case 49: // Про на 3 месяца (frl) // Про на 3 месяца (frl) case 119: // Про на 6 месяцeв (emp) // Про на 6 месяцeв (emp) case 50: // Про на 6 месяцев (frl) // Про на 6 месяцев (frl) case 120: // Про на 1 год (emp) // Про на 1 год (emp) case 51: // Про на 1 год (frl) // Про на 1 год (frl) case 132: // Про на 1 день (frl) // Про на 1 день (frl) case 131: // Про на 1 неделю (frl) // Про на 1 неделю (frl) case 163: // Тестовый ПРО на месяц // Тестовый ПРО на месяц case 164: // PROFI на 1 месяц require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/payed.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/freelancer.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/employer.php'; $payed = new payed(); $user = is_emp($this->user['role']) ? new employer() : new freelancer(); $success = $payed->SetOrderedTarif($this->user['uid'], $this->transaction, $order['op_count'], $order['comment'], $order['op_code'], $order['promo_code'], $error); if ($success) { if (isset($payed->account_operation_id) && $payed->account_operation_id > 0) { $account_operation_id = $payed->account_operation_id; } // Обновим сессию сразу! if (get_uid(false) == $this->user['uid']) { $_SESSION['pro_last'] = payed::ProLast($this->user['login']); $_SESSION['pro_last'] = $_SESSION['pro_last']['is_freezed'] ? false : $_SESSION['pro_last']['cnt']; if ($_SESSION['pro_last']['is_freezed']) { $_SESSION['payed_to'] = $_SESSION['pro_last']['cnt']; } } else { $membuff = new memBuff(); $membuff->set('is_changed_pro_' . $this->user['uid'], true); //Этот подход не работает //$session = new session(); //$session->UpdateProEndingDate($this->user['login']); } if ($order['auto'] == 't') { $user->setPROAutoProlong('on', $this->user['uid']); } else { $user->setPROAutoProlong('off', $this->user['uid']); } //Опубликовать перемещенные вакансии при покупке ПРО //@todo: Теперь вакансии для всех платные разница лишь в цене для ПРО дешевле //поэтому отключаем публикацию после покупки ПРО //https://beta.free-lance.ru/mantis/view.php?id=28579 /* if (is_emp($this->user['role'])) { require_once($_SERVER['DOCUMENT_ROOT'] . "/classes/projects.php"); $project = new projects(); $project->publishedMovedToVacancy($this->user); }*/ //Чистим кеш каталога PROFI пользователей if ($order['op_code'] == 164) { freelancer::clearCacheProfiCatalog(); } } break; //------------------------------------------------------------------ //------------------------------------------------------------------ case 45: // рассылка по каталогу require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/masssending.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/messages.php'; $masssending = masssending::Get($order['parent_id']); $masssending = $masssending[0]; $error = $this->account->Buy($account_operation_id, $this->transaction, masssending::OPER_CODE, $this->user['uid'], $order['descr'], $order['comment'], $masssending['pre_sum'], 0, $order['promo_code']); if ($error) { break; } masssending::UpdateAcOpID($order['parent_id'], $account_operation_id); $success = (bool) messages::Masssending($masssending['user_id'], $masssending['id'], $masssending['msgtext'], $masssending['posted_time']); break; //------------------------------------------------------------------ /* * Погашение задолженности */ //------------------------------------------------------------------ /* * Погашение задолженности */ case 135: $error = $this->account->Buy($account_operation_id, $this->transaction, $order['op_code'], $this->user['uid'], $order['descr'], $order['comment'], 1, 1, 0, 0, $order['ammount']); if (!$error) { $success = true; //Начисление погашенной комиссии и удаление блокировки ТУ require_once $_SERVER['DOCUMENT_ROOT'] . '/tu/models/TServiceOrderModel.php'; TServiceOrderModel::model()->clearDebt($this->user['uid']); } break; //------------------------------------------------------------------- /* * Операции над бизнес логикой резерва средств * при успешном зачислении денег */ //------------------------------------------------------------------- /* * Операции над бизнес логикой резерва средств * при успешном зачислении денег */ case 136: $success = false; $data = @$this->list_service[$order['id']]['info']; if (!$data) { break; } require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/reserves/ReservesModelFactory.php'; $reserveInstance = ReservesModelFactory::getInstance($data['type']); //Уже была зарезервирована или нет нужный параметров то //ничего не покупаем деньги остаются на ЛС if (!$reserveInstance || !isset($this->paymentSysParams['invoiceId'])) { break; } //Невозможно сменить статус сделки выходим $reserveInstance->setReserveData($data); if (!$reserveInstance->allowChangeStatus(ReservesModel::STATUS_RESERVE)) { break; } $ret = $this->account->Buy($account_operation_id, $this->transaction, $order['op_code'], $this->user['uid'], $order['descr'], $order['comment'], $order['ammount']); if ($ret === 0) { //Успешно купили услугу и теперь меняем статус резерва $data['invoice_id'] = $this->paymentSysParams['invoiceId']; $data['acc_op_id'] = $account_operation_id; $reserveInstance->setReserveData($data); $success = $reserveInstance->changeStatus(ReservesModel::STATUS_RESERVE); } break; //------------------------------------------------------------------ /* * Завершение покупки автоответов. */ //------------------------------------------------------------------ /* * Завершение покупки автоответов. */ case 137: $success = false; $ret = $this->account->Buy($account_operation_id, $this->transaction, $order['op_code'], $this->user['uid'], $order['descr'], $order['comment'], $order['ammount'], 1, $order['promo_code']); if ($ret === 0 && isset($order['parent_id']) && intval($order['parent_id'])) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/autoresponse.php'; autoresponse::$db = $GLOBALS['DB']; // Активация покупки услуги автоответа if ($autoresponse = autoresponse::get($order['parent_id'])) { $autoresponse->activate(); $success = true; } } break; //------------------------------------------------------------------ // Закрепление в каталоге фрилансеров //------------------------------------------------------------------ // Закрепление в каталоге фрилансеров case 142: // В корневом разделе // В корневом разделе case 143: // В разделе $is_spec = false; case 144: // В подразделе if (!isset($is_spec)) { $is_spec = true; } $success = false; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/freelancer_binds.php'; $freelancer_binds = new freelancer_binds(); $freelancer_binds->prepare($this->user['uid'], $order['src_id'], $is_spec, $order['op_count']); $ret = $this->account->Buy($account_operation_id, $this->transaction, $order['op_code'], $this->user['uid'], $freelancer_binds->bind_info['descr'], $freelancer_binds->bind_info['comment'], $order['ammount'], 1, $order['promo_code']); if ($ret === 0) { $success = $freelancer_binds->create(); } break; //------------------------------------------------------------------ // Продление закрепления в каталоге фрилансеров //------------------------------------------------------------------ // Продление закрепления в каталоге фрилансеров case 148: // В корневом разделе // В корневом разделе case 149: // В разделе $is_spec = false; case 150: // В подразделе if (!isset($is_spec)) { $is_spec = true; } $success = false; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/freelancer_binds.php'; $freelancer_binds = new freelancer_binds(); $bind_id = $freelancer_binds->isUserBinded($this->user['uid'], $order['src_id'], $is_spec); $ret = true; if ($bind_id) { $freelancer_binds->getProlongInfo($this->user['uid'], $order['src_id'], $is_spec, $order['op_count']); $ret = $this->account->Buy($account_operation_id, $this->transaction, $order['op_code'], $this->user['uid'], $freelancer_binds->bind_info['descr'], $freelancer_binds->bind_info['comment'], $order['ammount']); } if ($ret === 0) { $success = $freelancer_binds->prolong($bind_id, $order['op_count'], $order['src_id'], $is_spec); } break; //------------------------------------------------------------------ // Поднятие закрепления в каталоге фрилансеров //------------------------------------------------------------------ // Поднятие закрепления в каталоге фрилансеров case 151: // В корневом разделе // В корневом разделе case 152: // В разделе $is_spec = false; case 153: // В подразделе // В подразделе case 194: //Оплата из буфера if (!isset($is_spec)) { $is_spec = $order['src_id'] > 0; } $success = false; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/freelancer_binds.php'; $freelancer_binds = new freelancer_binds(); $bind_id = $freelancer_binds->isUserBinded($this->user['uid'], $order['src_id'], $is_spec); if ($bind_id) { $freelancer_binds->getUpInfo($this->user['uid'], $order['src_id'], $is_spec); $ret = $this->account->Buy($account_operation_id, $this->transaction, $order['op_code'], $this->user['uid'], $freelancer_binds->bind_info['descr'], '', $order['ammount']); if ($ret === 0) { $success = $freelancer_binds->up($bind_id, $order['src_id'], $is_spec); } } break; //------------------------------------------------------------------ // Закрепление/продление в каталоге услуг //------------------------------------------------------------------ // Закрепление/продление в каталоге услуг case 155: // В лендинге // В лендинге case 156: // В корневом разделе // В корневом разделе case 157: // В разделе // В разделе case 158: // В подразделе $success = false; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/tservices/tservices_binds.php'; $tservices_binds = new tservices_binds(tservices_binds::KIND_LANDING); $tservices_binds->setKindByOpCode($_op_code); $option = unserialize($order['option']); $tservice_id = isset($option['tservice_id']) ? $option['tservice_id'] : $order['option']; $is_prolong = isset($option['is_prolong']) ? $option['is_prolong'] : false; $tservices_binds->prepare($this->user['uid'], $tservice_id, $order['src_id'], $order['op_count'], $is_prolong); if ($tservices_binds->bind_info) { $ret = $this->account->Buy($account_operation_id, $this->transaction, $order['op_code'], $this->user['uid'], $tservices_binds->bind_info['descr'], $tservices_binds->bind_info['comment'], $order['ammount']); if ($ret === 0) { $success = $is_prolong ? $tservices_binds->update() : $tservices_binds->create(); } } break; //------------------------------------------------------------------ // Поднятие закрепления в каталоге услуг //------------------------------------------------------------------ // Поднятие закрепления в каталоге услуг case 159: // В лендинге // В лендинге case 160: // В корневом разделе // В корневом разделе case 161: // В разделе // В разделе case 162: // В подразделе // В подразделе case 193: //Оплата из буфера $success = false; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/tservices/tservices_binds.php'; $tservices_binds = new tservices_binds(tservices_binds::KIND_LANDING); $tservices_binds->setKindByOpCode($_op_code); $bind = $tservices_binds->getItemById($order['src_id']); $tservices_binds->makeUpInfo($bind); if ($tservices_binds->bind_info) { $ret = $this->account->Buy($account_operation_id, $this->transaction, $order['op_code'], $this->user['uid'], $tservices_binds->bind_info['descr'], $tservices_binds->bind_info['comment'], $order['ammount']); if ($ret === 0) { $success = $tservices_binds->update(); } } break; } if ($success) { $update = array('status' => self::STATUS_COMPLETE); $this->update($order['id'], $update); $memBuff = new memBuff(); $memBuff->delete('last_operation_' . $order['uid'] . '_' . $order['service']); //Если только что была оплата из яндекс.кассы if ($this->paymentSysParams['invoiceId']) { //Фиксируем ID транзакции $label = op_codes::getLabel($order['op_code']); if (isset($account_operation_id) && $account_operation_id > 0) { $label = (empty($label) ? '' : "{$label},") . "trans_{$account_operation_id}"; } // Посылаем данные о покупке в google analytics $this->_db->query("SELECT pgq.insert_event('statistic', 'service_payed', ?)", http_build_query(array('is_emp' => is_emp($this->user['role']), 'label' => $label, 'ammount' => floatval($order['ammount']), 'cid' => $this->getCid()))); } } return $success; }
/** * Уведомление фрилансеру за 1 день до окончания * размещения в freelancer_binds. */ public function remindFreelancerbindsUp() { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/freelancer_binds.php'; $binds = freelancer_binds::getDowned(); if (!$binds) { return false; } foreach ($binds as $val) { if ($val['bill_subscribe'] == 'f') { continue; } $catalog_name = ''; $catalog_url = "{$GLOBALS['host']}/freelancers/"; if ($val['prof_id'] == 0) { $catalog_name = 'общем разделе'; } elseif ($val['is_spec'] == 'f') { $group = professions::GetGroup($val['prof_id'], $error); $catalog_url .= $group['link']; $catalog_name = "разделе <a href='{$catalog_url}'>{$group['name']}</a>"; } else { $prof_name = professions::GetProfName($val['prof_id']); $catalog_url .= professions::GetProfLink($val['prof_id']); $catalog_name = "подразделе <a href='{$catalog_url}'>{$prof_name}</a>"; } $this->recipient = "{$val['uname']} {$val['usurname']} [{$val['login']}] <{$val['email']}>"; $this->message = Template::render($_SERVER['DOCUMENT_ROOT'] . '/templates/mail/freelancer_binds/remind_up.tpl.php', array('smail' => &$this, 'catalog_url' => $catalog_url, 'catalog_name' => $catalog_name)); $ok = $this->send('text/html'); if ($ok) { freelancer_binds::markSent('up', $val['uid'], $val['prof_id'], $val['is_spec']); } } return 0; }
/** * Возвращает номер позиции юзера в каталоге * * @param integer $user_id ИД Пользователя * @param integer $user_spec специализация юзера. * @param integer $rating рейтинг юзера. * @param integer $prof_id рейтинг юзера. * @param integer $is_pro Пользователь ПРО или не ПРО. * @return NULL|multitype */ function GetCatalogPosition($user_id, $user_spec, $rating, $prof_id, $is_pro, $not_exact = false) { global $DB; $R = 'rating_get(fu.rating, fu.is_pro, fu.is_verify, fu.is_profi)'; $pos = NULL; $memBuff = new memBuff(); if (!$prof_id) { if (!$not_exact) { $pos_table = professions::GetCatalogPositionsTable(); //такого не должно быть, но на всякий if (!$pos_table) { return NULL; } $out = $DB->row("SELECT 0 as prof_id, 'В общем каталоге' as prof_name, pos FROM {$pos_table} WHERE uid = ?", $user_id); if ($out) { return $out; } } $sql = "SELECT 0 as prof_id, 'В общем каталоге' as prof_name, COUNT(fu.uid) + 1 as pos\n FROM fu\n INNER JOIN\n portf_choise pc\n ON pc.user_id = fu.uid\n\n AND pc.prof_id = fu.spec_orig\n WHERE fu.is_banned = '0'\n AND (fu.is_pro = true " . ($is_pro ? 'AND' : 'OR') . " ({$R} > {$rating} OR ({$R} = {$rating} AND fu.uid < {$user_id})))"; if (!($out = $memBuff->getSql($error, $sql, 300))) { return NULL; } return $out[0]; } $or_prof = $prof_id; $or_prof = professions::GetProfessionOrigin($prof_id); $freelancer_binds = new freelancer_binds(); $date_binded = $freelancer_binds->getBindDate($user_id, $or_prof); $bind_select = $bind_join = $spec_where = ''; if ($date_binded) { $bind_join = "INNER JOIN freelancer_binds ON freelancer_binds.user_id = fu.uid AND freelancer_binds.prof_id = {$or_prof} AND freelancer_binds.is_spec = TRUE AND freelancer_binds.date_stop > NOW() AND freelancer_binds.date_start > '{$date_binded}'"; } else { //Ищем всех закрепленных $bind_select = "SELECT fu.uid, fb.prof_id as spec FROM fu \n LEFT JOIN freelancer_binds fb ON fb.user_id = fu.uid AND fb.date_stop > NOW()\n LEFT JOIN spec_add_choise bsa ON bsa.user_id = fu.uid\n WHERE fu.is_banned = '0' \n AND fb.prof_id={$or_prof} AND (fu.spec_orig = {$or_prof} OR bsa.prof_id = {$or_prof})\n AND fu.uid<>{$user_id} AND fu.cat_show = TRUE\n UNION ALL "; $spec_where = "AND (fu.is_pro = true " . ($is_pro ? 'AND' : 'OR') . " ({$R} > {$rating} OR ({$R} = {$rating} AND fu.uid <> {$user_id})" . ($user_spec == $or_prof ? ") AND fu.spec_orig={$or_prof}" : " OR fu.spec_orig={$or_prof})") . ")"; } $user_where = "\n fu.is_banned = '0' \n AND fu.uid <> {$user_id} \n AND fu.cat_show = TRUE \n AND fu.last_time > now() - '6 months'::interval\n " . $spec_where; $sql = "SELECT \n p.id as prof_id,\n p.name as prof_name,\n COUNT(DISTINCT s.uid) + 1 as pos,\n link\n \n FROM professions p\n LEFT JOIN\n (\n {$bind_select}\n \n SELECT uid, spec_orig as spec\n FROM fu\n {$bind_join}\n WHERE " . $user_where . "\n \n UNION ALL\n \n SELECT fu.uid, sa.prof_id FROM fu\n INNER JOIN spec_add_choise sa ON sa.user_id = fu.uid\n {$bind_join}\n WHERE fu.is_pro = true AND " . $user_where . "\n \n ) AS s ON s.spec = p.id\n \n WHERE p.id = {$or_prof}\n GROUP BY p.id, p.name, link"; $out = $memBuff->getSql($error, $sql, 300, true, freelancer::getCatalogMemTags($or_prof, true)); return $out ? $out[0] : null; }
/** * Оплата через Плати потом * * @param type $type - тип оплаты * @param type $data - данные по параметрам покупаемой услуги * @return \xajaxResponse */ function quickPaymentFrlbindPlatipotom($type, $data) { $is_error = true; $uid = get_uid(false); $objResponse =& new xajaxResponse(); $prof_id = (int) @$data['prof_id']; $is_spec = (bool) @$data['is_spec']; $is_prolong = (bool) @$data['is_prolong']; $promo_code = (string) @$data['promo']; $freelancer_binds = new freelancer_binds(); $valid = $is_prolong ? $freelancer_binds->isUserBinded($uid, $prof_id, $is_spec) : $freelancer_binds->isAllowBind($uid, $prof_id, $is_spec); if ($valid) { $is_error = false; $bill = new billing($uid); //Допустимо использование промокодов $bill->setPromoCodes('SERVICE_FRLBIND', $promo_code); $op_code = $freelancer_binds->getOpCode($prof_id, $is_spec, $is_prolong); $option = array('weeks' => (int) @$data['weeks'], 'prof_id' => $prof_id); //Формируем заказ $billReserveId = $bill->addServiceAndCheckout($op_code, $option); $payed_sum = $bill->getRealPayedSum(); $platipotom = new platipotom(); $html_form = $platipotom->render($payed_sum, $bill->account->id, $billReserveId); if ($html_form) { $objResponse->script("\n var qp_form_wrapper = \$\$('#quick_payment_frlbind .__quick_payment_form');\n if(qp_form_wrapper){ \n qp_form_wrapper.set('html','{$html_form}');\n qp_form_wrapper.getElement('form')[0].submit();\n }\n "); $link = '/freelancers/'; if ($prof_id) { if ($is_spec) { $link .= professions::GetProfLink($prof_id) . '/'; } else { $group = professions::GetGroup($prof_id, $error); $link .= $group['link'] . '/'; } } //сохранаем в сессию куда перейти при успешной покупке $_SESSION[quickPaymentPopup::QPP_REDIRECT] = $link; } } // Показываем предупреждение в случае ошибки if ($is_error) { $action = $is_prolong ? 'продлении закрепления' : 'закреплении'; $objResponse->script("\n var qp = window.quick_payment_factory.getQuickPayment('frlbind');\n if(qp) qp.show_error('Возникла ошибка при {$action} в каталоге!');\n "); } return $objResponse; }