本文整理汇总了PHP中Price::checkPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Price::checkPrice方法的具体用法?PHP Price::checkPrice怎么用?PHP Price::checkPrice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Price
的用法示例。
在下文中一共展示了Price::checkPrice方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: select
/**
* Acheter ou sélectionner un objet.
*
* @param int $obj_id
* @param int $obj_credit
* @param String $trace
* @param int $operator_id
* @return int $state
*/
public function select($obj_id, $obj_credit, $trace, $operator_id)
{
$Object = new Object($obj_id);
if (isset($this->SelectObject) and $this->SelectObject->getType() == 'promotion' and $obj_credit == 0) {
//on conserve la promo dans SelectObject et on incrémente la step
$this->promo_step++;
} else {
if ($Object->getType() == 'promotion') {
//on isset SelectIbject et on met la step à 1
$this->SelectObject = $Object;
$this->promo_step = 1;
} else {
if ($Object->getType() == 'category') {
$this->SelectObject = $Object;
} else {
unset($this->SelectObject);
}
}
}
if ($Object->getType() == 'product' or $Object->getType() == 'promotion') {
//on vérifie le prix
if ($obj_credit == 0 and isset($this->SelectObject) or Price::checkPrice($this->Buyer, $this->Point, $Object, $obj_credit) == 1) {
//on vérifie que le Buyer a l'argent
if ($this->Buyer->getCredit() >= $obj_credit) {
if ($Object->decStock()) {
//on décrémente le stock
//on encaisse
if ($obj_credit == 0) {
//promo... on décaisse juste le produit
$trace .= " via BUY";
$this->db->query("INSERT INTO t_purchase_pur (pur_date, pur_type, obj_id, pur_price, usr_id_buyer, usr_id_seller, poi_id, fun_id, pur_ip) VALUES (NOW(), '%s', '%u', '0', '%u', '%u', '%u', '%u', '%s')", array($Object->getType(), $Object->getId(), $this->Buyer->getId(), $operator_id, $this->Point->getId(), $Object->getFunId(), $trace));
$purchase_id = $this->db->insertId();
$this->Buyer->addToCart($Object, 0, $purchase_id);
return 1;
} else {
if ($this->Buyer->decCredit($obj_credit) == 1) {
//on enregistre
$trace .= " via BUY";
$this->db->query("INSERT INTO t_purchase_pur (pur_date, pur_type, obj_id, pur_price, usr_id_buyer, usr_id_seller, poi_id, fun_id, pur_ip) VALUES (NOW(), '%s', '%u', '%u', '%u', '%u', '%u', '%u', '%s')", array($Object->getType(), $Object->getId(), $obj_credit, $this->Buyer->getId(), $operator_id, $this->Point->getId(), $Object->getFunId(), $trace));
$purchase_id = $this->db->insertId();
$this->Buyer->addToCart($Object, $obj_credit, $purchase_id);
return 1;
} else {
return 400;
}
}
} else {
return 400;
}
} else {
//on annule l'éventuelle promo
unset($this->SelectObject);
return 462;
}
} else {
return 402;
}
} else {
return 1;
}
}
示例2: set_include_path
<?php
set_include_path(dirname(_FILE_) . '/../');
require_once 'class/Point.class.php';
require_once 'class/User.class.php';
require_once 'class/Proposition.class.php';
require_once 'class/Object.class.php';
require_once 'class/Price.class.php';
//Pour créer une proposition, on a besoin d'un user et d'un point
$User = new User('6362', 2, '', 1);
echo $User->getId();
$Point = new Point(2);
echo $Point->getId();
echo '<h2>Création</h2>';
$Proposition = new Proposition($User, $Point);
echo $Proposition->getUser()->getFirstname();
echo $Proposition->getPoint()->getName();
$Propo =& $Proposition->getObjectList();
echo '<pre>';
echo $Propo[0]->getName();
echo '</pre>';
$Object = new Object(2);
echo Price::checkPrice($User, $Point, $Object, 150);
echo Price::checkPrice($User, $Point, $Object, 50);