|
@@ -224,9 +224,11 @@ class predeposit_helper
|
|
|
private $mBonusState;
|
|
|
private $mRateVersion; //用来记录,红包过期带来的红包变化
|
|
|
private $mFromSession;
|
|
|
+ private $mDirty;
|
|
|
|
|
|
public function __construct($member_id,$from_session = false)
|
|
|
{
|
|
|
+ $this->mDirty = false;
|
|
|
$this->model_pd = Model('predeposit');
|
|
|
$this->member_id = $member_id;
|
|
|
$this->mFromSession = $from_session;
|
|
@@ -236,6 +238,18 @@ class predeposit_helper
|
|
|
|
|
|
$this->init_rate();
|
|
|
}
|
|
|
+
|
|
|
+ public function __destruct()
|
|
|
+ {
|
|
|
+ if($this->mDirty)
|
|
|
+ {
|
|
|
+ if($this->mFromSession) {
|
|
|
+ $this->del_rates();
|
|
|
+ }
|
|
|
+ $this->inc_rate_version();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function member_id() {
|
|
|
return $this->member_id;
|
|
|
}
|
|
@@ -326,19 +340,6 @@ class predeposit_helper
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function __destruct()
|
|
|
- {
|
|
|
- if($this->mFromSession)
|
|
|
- {
|
|
|
- if($this->mPayRates != null && $this->mPayRates->dirty()) {
|
|
|
- $this->del_rates();
|
|
|
- }
|
|
|
- if($this->mShareRates != null && $this->mShareRates->dirty()) {
|
|
|
- $this->del_rates();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public function pay_bonus_rates() {
|
|
|
return $this->mPayRates;
|
|
|
}
|
|
@@ -421,7 +422,7 @@ class predeposit_helper
|
|
|
{
|
|
|
$bonuses = bonus_helper::topup_bonus($this,$mobile);
|
|
|
if($bonuses != false) {
|
|
|
- $this->del_rates();
|
|
|
+ $this->mDirty = true;
|
|
|
}
|
|
|
|
|
|
return $bonuses;
|
|
@@ -446,6 +447,7 @@ class predeposit_helper
|
|
|
$result = bonus_helper::make_bonus($param,$rate_moneys);
|
|
|
if($result == false) return false;
|
|
|
|
|
|
+ $this->mDirty = true;
|
|
|
foreach ($rate_moneys as $item) {
|
|
|
$rate = intval($item['rate']);
|
|
|
$val = $item['hold_amount'];
|
|
@@ -468,6 +470,7 @@ class predeposit_helper
|
|
|
$result = bonus_helper::make_bonus($param,$rate_moneys);
|
|
|
if($result == false) return false;
|
|
|
|
|
|
+ $this->mDirty = true;
|
|
|
$rates = [];
|
|
|
foreach ($rate_moneys as $item) {
|
|
|
$rate = intval($item['rate']);
|
|
@@ -487,11 +490,12 @@ class predeposit_helper
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
- public function make_vote_type($param,$rate_moneys)
|
|
|
+ public function make_vote_type($param, $rate_moneys)
|
|
|
{
|
|
|
$result = bonus_helper::make_vote_type($param,$rate_moneys);
|
|
|
if($result == false) return false;
|
|
|
|
|
|
+ $this->mDirty = true;
|
|
|
$rates = [];
|
|
|
foreach ($rate_moneys as $item) {
|
|
|
$rate = intval($item['rate']);
|
|
@@ -555,6 +559,7 @@ class predeposit_helper
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ $this->mDirty = true;
|
|
|
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'];
|
|
@@ -565,7 +570,7 @@ class predeposit_helper
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function admin_make_bonus($param,$rate_moneys)
|
|
|
+ static public function admin_make_bonus($param,$rate_moneys)
|
|
|
{
|
|
|
return bonus_helper::make_bonus($param,$rate_moneys);
|
|
|
}
|
|
@@ -578,8 +583,7 @@ class predeposit_helper
|
|
|
if($bonus_obj->spend_over()) {
|
|
|
return false;
|
|
|
}
|
|
|
- $this->inc_rate_version();
|
|
|
-
|
|
|
+ $this->mDirty = true;
|
|
|
$minfo = new member_info($this->member_id);
|
|
|
$data = array();
|
|
|
$data['member_id'] = $this->member_id;
|
|
@@ -596,12 +600,6 @@ class predeposit_helper
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function bonus_refund($bonus_type)
|
|
|
- {
|
|
|
- $types = bonus\type::create_by_paramer($bonus_type);
|
|
|
- QueueClient::push('onPredeposit',array('change_type' => 'bonus_refund','buyer_id'=>$types->sender_id(),'order_sn'=>$types->getType_sn()));
|
|
|
- }
|
|
|
-
|
|
|
public function transform_money($member_id,$name,$amount)
|
|
|
{
|
|
|
$data = array();
|
|
@@ -609,6 +607,7 @@ class predeposit_helper
|
|
|
$data['member_name'] = is_null($name) ? '' : $name;
|
|
|
$data['amount'] = $amount;
|
|
|
$order_sn = $this->model_pd->makeSn();
|
|
|
+ $this->mDirty = true;
|
|
|
|
|
|
$data['order_sn'] = $order_sn;
|
|
|
$data['admin_name'] = '平台管理员';
|
|
@@ -628,6 +627,7 @@ class predeposit_helper
|
|
|
$data['admin_name'] = $sender_name;
|
|
|
$data['pdr_sn'] = $bonus_sn;
|
|
|
$data['lg_desc'] = $info;
|
|
|
+ $this->mDirty = true;
|
|
|
$this->model_pd->changePd("bonus_add_money", $data);
|
|
|
}
|
|
|
|
|
@@ -642,8 +642,6 @@ class predeposit_helper
|
|
|
}
|
|
|
public function add_bonus(bonus\user_bonus $bonus,bonus\type $type)
|
|
|
{
|
|
|
- $this->inc_rate_version();
|
|
|
-
|
|
|
$minfo = new member_info($this->member_id);
|
|
|
$data = array();
|
|
|
$data['member_id'] = $this->member_id;
|
|
@@ -655,6 +653,7 @@ class predeposit_helper
|
|
|
$data['lg_desc'] = "";
|
|
|
$data['make_type'] = $type->make_type();
|
|
|
$this->model_pd->changePd("bonus_add_money", $data);
|
|
|
+ $this->mDirty = true;
|
|
|
}
|
|
|
|
|
|
public function reduce_pred($amount)
|
|
@@ -667,12 +666,12 @@ class predeposit_helper
|
|
|
$data['pdr_sn'] = '';
|
|
|
$data['lg_desc'] = "";
|
|
|
$this->model_pd->changePd("sys_del_money", $data);
|
|
|
- $this->inc_rate_version();
|
|
|
+ $this->mDirty = true;
|
|
|
}
|
|
|
|
|
|
public function handout_bonus($amount, $type_sn, $sender_name, $info,$make_type = 0)
|
|
|
{
|
|
|
- $this->inc_rate_version();
|
|
|
+ $this->mDirty = true;
|
|
|
$minfo = new member_info($this->member_id);
|
|
|
$data = array();
|
|
|
$data['member_id'] = $this->member_id;
|
|
@@ -683,7 +682,6 @@ class predeposit_helper
|
|
|
$data['pdr_sn'] = $type_sn;
|
|
|
$data['lg_desc'] = $info;
|
|
|
$data['make_type'] = $make_type;
|
|
|
-
|
|
|
$this->model_pd->changePd("hand_out_bonus", $data);
|
|
|
}
|
|
|
|
|
@@ -890,18 +888,10 @@ class predeposit_helper
|
|
|
public function pay_bonus($rates)
|
|
|
{
|
|
|
$ret = bonus_helper::withold($this->member_id,$rates,bonus_helper::pay_order_withold);
|
|
|
- if($ret == true) {
|
|
|
- $this->inc_rate_version();
|
|
|
- $this->del_rates();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- $cent = intval($ret * 100 + 0.5);
|
|
|
- if($cent > 0) {
|
|
|
- $this->inc_rate_version();
|
|
|
- $this->del_rates();
|
|
|
- }
|
|
|
+ foreach ($rates as $rate => $amount) {
|
|
|
+ $this->mPayRates->with_hold($rate,$amount);
|
|
|
}
|
|
|
+ $this->mDirty = true;
|
|
|
|
|
|
return $ret;
|
|
|
}
|
|
@@ -912,9 +902,10 @@ class predeposit_helper
|
|
|
return $bonus_rate->find_rate($amount);
|
|
|
}
|
|
|
|
|
|
- public function inc_rate_version()
|
|
|
+ private function inc_rate_version()
|
|
|
{
|
|
|
- Model('member')->inc_rate_version($this->member_id);
|
|
|
+ $mod_member = Model('member');
|
|
|
+ $mod_member->editMember(['member_id' => $this->member_id],['rate_version' => ['exp', "rate_version+1"] ]);
|
|
|
}
|
|
|
|
|
|
static public function order_cash($goods_amount, &$rates)
|
|
@@ -969,4 +960,10 @@ class predeposit_helper
|
|
|
return ($bonus_price - $discount) / 100;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ static public function bonus_refund($bonus_type)
|
|
|
+ {
|
|
|
+ $types = bonus\type::create_by_paramer($bonus_type);
|
|
|
+ QueueClient::push('onPredeposit',array('change_type' => 'bonus_refund','buyer_id' => $types->sender_id(),'order_sn' => $types->getType_sn()));
|
|
|
+ }
|
|
|
}
|