$bill->cancelAllNewAndReserved(); //Здесь впервые считается цена if ($tmpPrj->getAmmount()) { $tmpProject = $tmpPrj->getProject(); //Цена считается повторно, в $items формируется список услуг $price = $tmpPrj->getPrice($items, $__temp, true); $option = array('is_edit' => $tmpPrj->isEdit(), 'items' => $items, 'prj_id' => $project['id'], 'logo_id' => $logo['id'], 'logo_link' => $tmpProject['link']); if ($items['top']) { $option['addTop'] = $tmpPrj->getAddedTopDays(); } if ($tmpPrj->isKonkurs()) { if (new_projects::isNewContestBudget()) { $cost = $tmpPrj->getCostRub(); $op_code = new_projects::getContestTaxOpCode($tmpPrj->getCostRub(), is_pro()); $items['contest']['no_pro'] = $tmpPrj->isEdit() ? 0 : new_projects::getContestTax($cost, is_pro()); $items['contest']['pro'] = $tmpPrj->isEdit() ? 0 : new_projects::getContestTax($cost, true); } else { //Здесь счет создастся при редактировании конкурса $items['contest']['no_pro'] = $tmpPrj->isEdit() ? 0 : 3300; $items['contest']['pro'] = $tmpPrj->isEdit() ? 0 : 3000; $op_code = is_pro() ? new_projects::OPCODE_KON : new_projects::OPCODE_KON_NOPRO; } $op_code_pay = new_projects::OPCODE_PAYED_KON; } else { $op_code = new_projects::OPCODE_PAYED; $op_code_pay = new_projects::OPCODE_PAYED; } if ($items) { $bill->start(); // Конкурс if ($items['contest'] > 0) {
/** * Расчет стоимости сформированного проекта * * @param array $items Возвращает данные по проекту (а точнее массив со значениями цены по соответствующим категориям (логотип, цвет,выделение,место наверху)) * @param double &$PROprice сумма оплаты, если бы у покупателя был PRO * @param bool $pricesAsArray = false если true, тогда для свойств $items["logo"] и $items["top"] будет задан * массив array("no_pro" => a, "pro" => b), где b - стоимость опции при наличии у покупателя pro * a - стоимость опции расчитанная в зависимости от наличия pro в момент расчета * @return integer Сумма оплаты */ function getPrice(&$items = NULL, &$PROprice = 0, $pricesAsArray = false) { $isPayedUrgent = $this->_project['o_urgent'] == 't'; $isPayedHide = $this->_project['o_hide'] == 't'; $is_pro = is_pro(true, $this->_project["user_id"]); $addedPrc = $is_pro ? 0 : self::PRICE_ADDED; $items['logo']["no_pro"] = ($this->getLogo() && !(int) $this->_project['payed_items'][self::PAYED_IDX_LOGO]) * ($is_pro ? self::PRICE_LOGO : self::PRICE_LOGO_NOPRO); $nPrice = $this->isKonkurs() ? ($is_pro ? self::PRICE_CONTEST_TOP1DAY_PRO : self::PRICE_CONTEST_TOP1DAY) + $addedPrc : ($is_pro ? self::PRICE_TOP1DAYPRO : self::PRICE_TOP1DAY) + $addedPrc; $nProPrice = $this->isKonkurs() ? self::PRICE_CONTEST_TOP1DAY_PRO : self::PRICE_TOP1DAYPRO; $items['urgent'] = array("no_pro" => $this->_project['urgent'] == 't' && !$isPayedUrgent ? self::PRICE_URGENT : 0); $items['hide'] = array("no_pro" => $this->_project['hide'] == 't' && !$isPayedHide ? self::PRICE_HIDE : 0); $items['top'] = array("no_pro" => $this->getAddedTopDays() * $nPrice); if (!$pricesAsArray) { $items['top'] = $items["top"]["no_pro"]; $items['urgent'] = $items["urgent"]["no_pro"]; $items['hide'] = $items["hide"]["no_pro"]; $items['logo'] = $items['logo']["no_pro"]; $price = $items['logo'] + $items['top'] + $items['urgent'] + $items['hide']; } else { $price = $items['logo']["no_pro"] + $items['top']["no_pro"] + $items['urgent']['no_pro'] + $items['hide']['no_pro']; } $PROitems['urgent'] = $this->_project['urgent'] == 't' && !$isPayedUrgent ? self::PRICE_URGENT : 0; $PROitems['hide'] = $this->_project['hide'] == 't' && !$isPayedHide ? self::PRICE_HIDE : 0; $PROitems['logo'] = ($this->getLogo() && !(int) $this->_project['payed_items'][self::PAYED_IDX_LOGO]) * self::PRICE_LOGO; $PROnPrice = $this->isKonkurs() ? $is_pro ? self::PRICE_CONTEST_TOP1DAY_PRO : self::PRICE_CONTEST_TOP1DAY : ($is_pro ? self::PRICE_TOP1DAYPRO : self::PRICE_TOP1DAY); $PROitems['top'] = $this->getAddedTopDays() * $nProPrice; if ($pricesAsArray) { $items['top']["pro"] = $PROitems['top']; $items['logo']["pro"] = $PROitems['logo']; $items['urgent']["pro"] = $PROitems['urgent']; $items['hide']["pro"] = $PROitems['hide']; $PROprice = $PROitems['logo']["pro"] + $PROitems['top']["pro"] + $PROitems['urgent']["pro"] + $PROitems['hide']["pro"]; } else { $PROprice = $PROitems['logo'] + $PROitems['top'] + $PROitems['urgent'] + $PROitems['hide']; } if ($this->isKonkurs() && !$this->isEdit()) { if (new_projects::isNewContestBudget()) { //Блок никогда не выполняется, т.к. метод в условии всегда возвращает false $isPro = $this->_project['is_pro'] === 't'; $cost = $this->_costRub; $contestPrice = new_projects::getContestTax($cost, $isPro); $price += new_projects::getContestTax($cost, $isPro); $PROprice += new_projects::getContestTax($cost, true); } else { $items['contest']['pro'] = $this->getKonkursPrice(true); $items['contest']['no_pro'] = $this->getKonkursPrice(); $contestPrice = $is_pro ? $items['contest']['pro'] : $items['contest']['no_pro']; $price = $price + $contestPrice; $PROprice = $PROprice + $items['contest']['pro']; if (!$pricesAsArray) { $items['contest'] = $contestPrice; } } } if ($this->isVacancy() && (!$this->isEdit() || $this->isStateChangedToPublic())) { $items['office'] = $this->getProjectInOfficePrice($is_pro); $price = $price + $this->getProjectInOfficePrice($is_pro); $PROprice = $PROprice + $this->getProjectInOfficePrice(true); } return $price > 0 ? $price : 0; }