|
@@ -219,7 +219,8 @@ class predeposit_helper
|
|
|
{
|
|
|
private $model_pd;
|
|
|
private $member_id;
|
|
|
- private $mRates;
|
|
|
+ private $mPayRates;
|
|
|
+ private $mShareRates;
|
|
|
private $mBonusState;
|
|
|
private $mRateVersion; //用来记录,红包过期带来的红包变化
|
|
|
|
|
@@ -247,8 +248,9 @@ class predeposit_helper
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if(isset($_SESSION['bonus_rate']) && isset($_SESSION['bonus_state'])) {
|
|
|
- $this->mRates = new RateMoney($_SESSION['bonus_rate']);
|
|
|
+ if(isset($_SESSION['bonus_rate']) && isset($_SESSION['bonus_state']) && isset($_SESSION['share_bonus_rate'])) {
|
|
|
+ $this->mPayRates = new RateMoney($_SESSION['bonus_rate']);
|
|
|
+ $this->mShareRates = new RateMoney($_SESSION['share_bonus_rate']);
|
|
|
$this->mBonusState = $_SESSION['bonus_state'];
|
|
|
} else {
|
|
|
$fUpdate = true;
|
|
@@ -259,10 +261,16 @@ class predeposit_helper
|
|
|
if($fUpdate || $this->need_update())
|
|
|
{
|
|
|
$mod_bonus = Model('user_bonus');
|
|
|
- $this->mRates = new RateMoney(array());
|
|
|
- $items = $mod_bonus->getUsableBonus($this->member_id);
|
|
|
- $this->mRates->add_bonuses($items);
|
|
|
- $bonus_rate = $this->mRates->format();
|
|
|
+ $this->mPayRates = new RateMoney(array());
|
|
|
+ $pay_items = $mod_bonus->getUsableBonus($this->member_id);
|
|
|
+ $this->mPayRates->add_bonuses($pay_items);
|
|
|
+ $pay_bonus_rate = $this->mPayRates->format();
|
|
|
+
|
|
|
+ $this->mShareRates = new RateMoney(array());
|
|
|
+ $share_items = $mod_bonus->getShareableBonus($this->member_id);
|
|
|
+ $this->mShareRates->add_bonuses($share_items);
|
|
|
+ $share_bonus_rate = $this->mShareRates->format();
|
|
|
+
|
|
|
|
|
|
$this->mBonusState = [];
|
|
|
$querys = array('usable','expiring','used','expired');
|
|
@@ -275,8 +283,10 @@ class predeposit_helper
|
|
|
}
|
|
|
$this->mBonusState[$state] = doubleval($sum);
|
|
|
}
|
|
|
- $this->write_rates($this->mBonusState,$bonus_rate);
|
|
|
- $this->mRates->clean();
|
|
|
+
|
|
|
+ $this->write_rates($this->mBonusState,$pay_bonus_rate,$share_bonus_rate);
|
|
|
+ $this->mPayRates->clean();
|
|
|
+ $this->mShareRates->clean();
|
|
|
$_SESSION['bonus_update_time'] = time();
|
|
|
}
|
|
|
}
|
|
@@ -295,20 +305,26 @@ class predeposit_helper
|
|
|
|
|
|
public function __destruct()
|
|
|
{
|
|
|
- if($this->mRates != null && $this->mRates->dirty()) {
|
|
|
+ if($this->mPayRates != null && $this->mPayRates->dirty()) {
|
|
|
+ $this->del_rates();
|
|
|
+ }
|
|
|
+ if($this->mShareRates != null && $this->mShareRates->dirty()) {
|
|
|
$this->del_rates();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function bonus_rate() {
|
|
|
- return $this->mRates;
|
|
|
+ public function pay_bonus_rates() {
|
|
|
+ return $this->mPayRates;
|
|
|
+ }
|
|
|
+ public function share_bonus_rates() {
|
|
|
+ return $this->mShareRates;
|
|
|
}
|
|
|
|
|
|
static public function order_cash($goods_amount, &$rates)
|
|
|
{
|
|
|
if(isset($_SESSION['bonus_rate']) == false) {
|
|
|
$pred = new predeposit_helper($_SESSION['member_id']);
|
|
|
- $bonus_rate = $pred->bonus_rate();
|
|
|
+ $bonus_rate = $pred->pay_bonus_rates();
|
|
|
} else {
|
|
|
$bonus_rate = new RateMoney($_SESSION['bonus_rate']);
|
|
|
}
|
|
@@ -322,7 +338,7 @@ class predeposit_helper
|
|
|
{
|
|
|
if(isset($_SESSION['bonus_rate']) == false) {
|
|
|
$pred = new predeposit_helper($_SESSION['member_id']);
|
|
|
- $bonus_rate = $pred->bonus_rate();
|
|
|
+ $bonus_rate = $pred->pay_bonus_rates();
|
|
|
} else {
|
|
|
$bonus_rate = new RateMoney($_SESSION['bonus_rate']);
|
|
|
}
|
|
@@ -392,10 +408,11 @@ class predeposit_helper
|
|
|
return $cond;
|
|
|
}
|
|
|
|
|
|
- private function write_rates($bonus_state,$bonus_rate)
|
|
|
+ private function write_rates($bonus_state, $pay_bonus_rate,$share_bonus_rate)
|
|
|
{
|
|
|
$_SESSION['bonus_state'] = $bonus_state;
|
|
|
- $_SESSION['bonus_rate'] = $bonus_rate;
|
|
|
+ $_SESSION['bonus_rate'] = $pay_bonus_rate;
|
|
|
+ $_SESSION['share_bonus_rate'] = $share_bonus_rate;
|
|
|
$_SESSION['bonus_rate_version'] = $this->mRateVersion;
|
|
|
}
|
|
|
|
|
@@ -407,7 +424,9 @@ class predeposit_helper
|
|
|
if(isset($_SESSION['bonus_rate'])) {
|
|
|
unset($_SESSION['bonus_rate']);
|
|
|
}
|
|
|
-
|
|
|
+ if(isset($_SESSION['share_bonus_rate'])) {
|
|
|
+ unset($_SESSION['share_bonus_rate']);
|
|
|
+ }
|
|
|
if(isset($_SESSION['bonus_rate_version'])) {
|
|
|
unset($_SESSION['bonus_rate_version']);
|
|
|
}
|
|
@@ -425,21 +444,21 @@ class predeposit_helper
|
|
|
|
|
|
public function total_bonus()
|
|
|
{
|
|
|
- return $this->mRates->total();
|
|
|
+ return $this->mPayRates->total();
|
|
|
}
|
|
|
|
|
|
public function is_enough($money) {
|
|
|
return intval($this->total_bonus() * 100) >= intval($money * 100);
|
|
|
}
|
|
|
|
|
|
- public function person_enough($money,&$bonus_rate)
|
|
|
+ public function share_enough($money, &$bonus_rate)
|
|
|
{
|
|
|
- if($this->mRates == null) return false;
|
|
|
- return $this->mRates->is_enough($bonus_rate,$money);
|
|
|
+ if($this->mPayRates == null) return false;
|
|
|
+ return $this->mShareRates->is_enough($bonus_rate,$money);
|
|
|
}
|
|
|
|
|
|
public function rates() {
|
|
|
- return $this->mRates == null ? false : $this->mRates;
|
|
|
+ return $this->mPayRates == null ? false : $this->mPayRates;
|
|
|
}
|
|
|
|
|
|
public function makeby_bonus($param, $rate_moneys, $bonus_sn)
|
|
@@ -458,7 +477,7 @@ class predeposit_helper
|
|
|
$this->handout_bonus($money,$type_sn,session_helper::nickname(),"发送了{$money}元的红包.",\bonus\type::MakeSendType);
|
|
|
|
|
|
foreach ($rate_moneys as $item) {
|
|
|
- $this->mRates->with_hold($item['rate'],$item['amount']);
|
|
|
+ $this->mPayRates->with_hold($item['rate'],$item['amount']);
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
@@ -482,7 +501,7 @@ class predeposit_helper
|
|
|
$this->handout_bonus($money,$type_sn,session_helper::nickname(),"发送了{$money}元的红包.",\bonus\type::MakeSendType);
|
|
|
|
|
|
foreach ($rate_moneys as $item) {
|
|
|
- $this->mRates->with_hold($item['rate'],$item['amount']);
|
|
|
+ $this->mPayRates->with_hold($item['rate'],$item['amount']);
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
@@ -506,7 +525,7 @@ class predeposit_helper
|
|
|
$this->handout_bonus($money,$type_sn,session_helper::nickname(),"发送了{$money}元的红包.",\bonus\type::MakeSendType);
|
|
|
|
|
|
foreach ($rate_moneys as $item) {
|
|
|
- $this->mRates->with_hold($item['rate'],$item['amount']);
|
|
|
+ $this->mPayRates->with_hold($item['rate'],$item['amount']);
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
@@ -556,8 +575,7 @@ class predeposit_helper
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if(bonus_helper::withold_bonus($this->member_id,$bonus->bonus_rate(),
|
|
|
- $bonus_sn,$type->getTotal_amount(),bonus_helper::send_bonus_withold))
|
|
|
+ if(bonus_helper::withold_bonus($this->member_id,$bonus->bonus_rate(),$bonus_sn,$type->getTotal_amount(),bonus_helper::send_bonus_withold))
|
|
|
{
|
|
|
$type_sn = $result['type_sn'];
|
|
|
$money = $result['money'];
|
|
@@ -855,7 +873,7 @@ class predeposit_helper
|
|
|
|
|
|
public function calc_rates($order_pd_amount)
|
|
|
{
|
|
|
- $rates = $this->mRates->calc_rates($order_pd_amount);
|
|
|
+ $rates = $this->mPayRates->calc_rates($order_pd_amount);
|
|
|
return $rates;
|
|
|
}
|
|
|
|
|
@@ -874,7 +892,7 @@ class predeposit_helper
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $pred_amount = $pred_amount - $this->mRates->calc_money($pred_amount,$rates);
|
|
|
+ $pred_amount = $pred_amount - $this->mPayRates->calc_money($pred_amount,$rates);
|
|
|
$cur_used = intval($pred_amount * 100 + 0.5);
|
|
|
$cur_used = $cur_used > $pd_amount ? $pd_amount : $cur_used;
|
|
|
|
|
@@ -909,9 +927,9 @@ class predeposit_helper
|
|
|
return $ret;
|
|
|
}
|
|
|
|
|
|
- public function find_bonus($amount)
|
|
|
+ public function find_share_bonus($amount)
|
|
|
{
|
|
|
- $bonus_rate = $this->bonus_rate();
|
|
|
+ $bonus_rate = $this->share_bonus_rates();
|
|
|
return $bonus_rate->find_rate($amount);
|
|
|
}
|
|
|
|