|
@@ -67,7 +67,6 @@ class RateMoney
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public function resort()
|
|
|
{
|
|
|
ksort($this->mRates);
|
|
@@ -138,6 +137,55 @@ class RateMoney
|
|
|
public function clean() {
|
|
|
$this->mDirty = false;
|
|
|
}
|
|
|
+
|
|
|
+ public function calc_price($price)
|
|
|
+ {
|
|
|
+ $disc = 0;
|
|
|
+ $left = intval($price * 100 + 0.5);
|
|
|
+ foreach ($this->mRates as $rate => $total)
|
|
|
+ {
|
|
|
+ if($left <= 0) break;
|
|
|
+ if($rate > 100) continue;
|
|
|
+
|
|
|
+ $total = intval($total * 100 + 0.5);
|
|
|
+ if($total <= 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if($rate == 100)
|
|
|
+ {
|
|
|
+ if($total >= $left) {
|
|
|
+ $disc += $left;
|
|
|
+ $left = 0;
|
|
|
+ } else {
|
|
|
+ $disc += $total;
|
|
|
+ $left -= $total;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $max_rate = intval($left * $rate / 100 + 0.5);
|
|
|
+ if($total >= $max_rate) {
|
|
|
+ $disc += $max_rate;
|
|
|
+ $left = 0;
|
|
|
+ } else {
|
|
|
+ $disc += $total;
|
|
|
+ $left -= intval($total * 100 / $rate + 0.5);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $cur_price = $price * 100 - $disc;
|
|
|
+ $min_price = intval($price * (100 - self::PRED_RATE) + 0.5);
|
|
|
+
|
|
|
+ if($cur_price < $min_price) {
|
|
|
+ return $cur_price / 100;
|
|
|
+ } else {
|
|
|
+ return $min_price / 100;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
class predeposit_helper
|
|
@@ -216,6 +264,42 @@ class predeposit_helper
|
|
|
$this->del_rates();
|
|
|
}
|
|
|
}
|
|
|
+ private function bonus_rate() {
|
|
|
+ return $this->mRates;
|
|
|
+ }
|
|
|
+ static public function bonus_price($goods_price)
|
|
|
+ {
|
|
|
+ if(session_helper::isLogin())
|
|
|
+ {
|
|
|
+ if(isset($_SESSION['bonus_rate']) == false) {
|
|
|
+ $pred = new predeposit_helper($_SESSION['member_id']);
|
|
|
+ $bonus_rate = $pred->bonus_rate();
|
|
|
+ } else {
|
|
|
+ $bonus_rate = new RateMoney($_SESSION['bonus_rate']);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $bonus_rate->calc_price($goods_price);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(is_pushoms()) {
|
|
|
+ $scale = 0.30;
|
|
|
+ } else {
|
|
|
+ $scale = 0.99;
|
|
|
+ }
|
|
|
+ return $scale * $goods_price;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ static public function scale()
|
|
|
+ {
|
|
|
+ if(is_pushoms()) {
|
|
|
+ $scale = 0.30;
|
|
|
+ } else {
|
|
|
+ $scale = 0.99;
|
|
|
+ }
|
|
|
+ return $scale;
|
|
|
+ }
|
|
|
|
|
|
public function bonus_state() {
|
|
|
return $this->mBonusState;
|
|
@@ -639,16 +723,6 @@ class predeposit_helper
|
|
|
return $pdlogs;
|
|
|
}
|
|
|
|
|
|
- static public function scale()
|
|
|
- {
|
|
|
- if(is_pushoms()) {
|
|
|
- $scale = 0.30;
|
|
|
- } else {
|
|
|
- $scale = 0.99;
|
|
|
- }
|
|
|
- return $scale;
|
|
|
- }
|
|
|
-
|
|
|
public function calc_pred($order_info,$pd_amount,&$no_cash)
|
|
|
{
|
|
|
$order_id = intval($order_info['order_id']);
|