|
@@ -34,9 +34,9 @@ class bonus_helper
|
|
|
|
|
|
static public function filter_type($type_info)
|
|
|
{
|
|
|
- $type = \bonus\type::create_by_paramer($type_info);
|
|
|
+ $type = bonus\type::create_by_paramer($type_info);
|
|
|
$ret = $type->get_param();
|
|
|
- $ret['time_out'] = \bonus\manager::grab_period_timeout;
|
|
|
+ $ret['time_out'] = bonus\manager::grab_period_timeout;
|
|
|
if($type->binded_over()) {
|
|
|
$ret['binded_over'] = 1;
|
|
|
} else {
|
|
@@ -67,36 +67,36 @@ class bonus_helper
|
|
|
}
|
|
|
|
|
|
static public function isFixed($send_type) {
|
|
|
- return ($send_type == \bonus\type::SendType_Fixed);
|
|
|
+ return ($send_type == bonus\type::SendType_Fixed);
|
|
|
}
|
|
|
static public function isRandom($send_type) {
|
|
|
- return ($send_type == \bonus\type::SendType_Random);
|
|
|
+ return ($send_type == bonus\type::SendType_Random);
|
|
|
}
|
|
|
|
|
|
static public function create_type_input($param) {
|
|
|
- return \bonus\type::crate_by_input($param);
|
|
|
+ return bonus\type::create_by_input($param);
|
|
|
}
|
|
|
static public function create_by_paramer($param) {
|
|
|
- return \bonus\type::create_by_paramer($param);
|
|
|
+ return bonus\type::create_by_paramer($param);
|
|
|
}
|
|
|
static public function create_type_sn($type_sn) {
|
|
|
- return \bonus\type::create_by_sn($type_sn);
|
|
|
+ return bonus\type::create_by_sn($type_sn);
|
|
|
}
|
|
|
|
|
|
static public function make_bonus($param, $rate_moneys)
|
|
|
{
|
|
|
- $ret = \bonus\factory::make_bonus($param,$rate_moneys);
|
|
|
+ $ret = bonus\factory::make_bonus($param,$rate_moneys);
|
|
|
return $ret;
|
|
|
}
|
|
|
static public function make_vote_type($param, $rate_moneys)
|
|
|
{
|
|
|
- $ret = \bonus\factory::make_vote_type($param,$rate_moneys);
|
|
|
+ $ret = bonus\factory::make_vote_type($param,$rate_moneys);
|
|
|
return $ret; }
|
|
|
|
|
|
static public function last_invite_type($member_id)
|
|
|
{
|
|
|
$mod = Model('bonus_type');
|
|
|
- $items = $mod->get(array('relayer_id' => $member_id, 'make_type' => \bonus\type::MakeInviteType));
|
|
|
+ $items = $mod->get(['relayer_id' => $member_id, 'make_type' => bonus\type::MakeInviteType]);
|
|
|
if(empty($items)) {
|
|
|
return null;
|
|
|
} else {
|
|
@@ -106,39 +106,74 @@ class bonus_helper
|
|
|
|
|
|
static public function get_typeinfo($type_sn)
|
|
|
{
|
|
|
- $manager = new \bonus\manager();
|
|
|
+ $manager = new bonus\manager();
|
|
|
return $manager->get_typeinfo($type_sn);
|
|
|
}
|
|
|
|
|
|
static public function get_mine_by_typesn($type_sn) {
|
|
|
- $manager = new \bonus\manager();
|
|
|
+ $manager = new bonus\manager();
|
|
|
return $manager->get_mine_by_typesn($type_sn);
|
|
|
}
|
|
|
|
|
|
static public function get_mine_by_bonussn($bonus_sn) {
|
|
|
- $manager = new \bonus\manager();
|
|
|
+ $manager = new bonus\manager();
|
|
|
return $manager->get_mine_by_bonussn($bonus_sn);
|
|
|
}
|
|
|
|
|
|
static public function grab_bonus($type_sn)
|
|
|
{
|
|
|
- $manager = new \bonus\manager();
|
|
|
+ $manager = new bonus\manager();
|
|
|
return $manager->grab_bonus($type_sn);
|
|
|
}
|
|
|
|
|
|
+ static private function onBinded($bonus_sn,$mobile,$userid)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $bonus = bonus\user_bonus::create_by_sn($bonus_sn);
|
|
|
+ $type_sn = $bonus->type_sn();
|
|
|
+ $type = bonus\type::create_by_sn($type_sn);
|
|
|
+ if($type->grab_type() != bonus\type::GrabType_Invite) return true;
|
|
|
+
|
|
|
+ if($userid > 0) {
|
|
|
+ $member_id = $userid;
|
|
|
+ }
|
|
|
+ elseif(!empty($mobile)) {
|
|
|
+ $loginner = new login\mobile_log($mobile);
|
|
|
+ if($loginner->ismember() == false) return false;
|
|
|
+ $member_id = $loginner->memberid();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $member_id = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($member_id > 0) {
|
|
|
+ $mod_member = Model('member');
|
|
|
+ $mod_member->editMember(['member_id' => $member_id],['invited_bonus' => 1]);
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ catch (Exception $ex) {
|
|
|
+ Log::record(__METHOD__ . " " . $ex->getMessage(),Log::ERR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
static public function bind_bonus($bonus_sn,$session_id,$mobile,$userid,&$new_bonus_sn)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- $manager = new \bonus\manager();
|
|
|
- return $manager->bind_bonus($bonus_sn,$session_id,$mobile,$userid,$new_bonus_sn);
|
|
|
+ $manager = new bonus\manager();
|
|
|
+ $ret = $manager->bind_bonus($bonus_sn,$session_id,$mobile,$userid,$new_bonus_sn);
|
|
|
+ if($ret) self::onBinded($bonus_sn,$mobile,$userid);
|
|
|
+ return $ret;
|
|
|
} catch (Exception $ex) {
|
|
|
return array($ex->getCode(),$ex->getMessage());
|
|
|
}
|
|
|
}
|
|
|
static public function shake($bonus_sn,$strength,$direction)
|
|
|
{
|
|
|
- $manager = new \bonus\manager();
|
|
|
+ $manager = new bonus\manager();
|
|
|
return $manager->shake($bonus_sn,$strength,$direction);
|
|
|
}
|
|
|
|
|
@@ -146,7 +181,7 @@ class bonus_helper
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- $manager = new \bonus\manager();
|
|
|
+ $manager = new bonus\manager();
|
|
|
return $manager->comment($bonus_sn,$comment);
|
|
|
} catch (Exception $ex) {
|
|
|
return false;
|
|
@@ -161,13 +196,13 @@ class bonus_helper
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- $manager = new \bonus\manager();
|
|
|
+ $manager = new bonus\manager();
|
|
|
$bonusex = array();
|
|
|
foreach($bind_bonus as $val)
|
|
|
{
|
|
|
$type_id = $val['type_id'];
|
|
|
- $type = \bonus\type::create_by_id($type_id);
|
|
|
- $bonus = \bonus\user_bonus::create_by_param($val);
|
|
|
+ $type = bonus\type::create_by_id($type_id);
|
|
|
+ $bonus = bonus\user_bonus::create_by_param($val);
|
|
|
|
|
|
try
|
|
|
{
|
|
@@ -188,10 +223,10 @@ class bonus_helper
|
|
|
}
|
|
|
|
|
|
static public function direct_asc() {
|
|
|
- return \bonus\shaker::direct_asc;
|
|
|
+ return bonus\shaker::direct_asc;
|
|
|
}
|
|
|
static public function direct_dec() {
|
|
|
- return \bonus\shaker::direct_dec;
|
|
|
+ return bonus\shaker::direct_dec;
|
|
|
}
|
|
|
|
|
|
static public function get_direction($first)
|
|
@@ -250,7 +285,7 @@ class bonus_helper
|
|
|
{
|
|
|
$fsuccess = true;
|
|
|
$total = 0.00;
|
|
|
- $holder = new \bonus\witholder($member_id,$used_type);
|
|
|
+ $holder = new bonus\witholder($member_id,$used_type);
|
|
|
foreach ($rates as $rate => $money)
|
|
|
{
|
|
|
if($holder->withold($rate,$money) == true) {
|
|
@@ -270,7 +305,7 @@ class bonus_helper
|
|
|
|
|
|
static public function withold_money($member_id,$rate,$money,$used_type)
|
|
|
{
|
|
|
- $holder = new \bonus\witholder($member_id,$used_type);
|
|
|
+ $holder = new bonus\witholder($member_id,$used_type);
|
|
|
if($holder->withold($rate,$money) == false) {
|
|
|
Log::record("withold user member_id={$member_id} money={$money}.",Log::ERR);
|
|
|
}
|
|
@@ -279,7 +314,7 @@ class bonus_helper
|
|
|
|
|
|
static public function withold_bonus($member_id,$bonus_sn,$rate,$money,$used_type)
|
|
|
{
|
|
|
- $holder = new \bonus\witholder($member_id,$used_type);
|
|
|
+ $holder = new bonus\witholder($member_id,$used_type);
|
|
|
return $holder->withold_bonus($rate,$bonus_sn,$money);
|
|
|
}
|
|
|
|
|
@@ -287,7 +322,7 @@ class bonus_helper
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- $manager = new \bonus\manager();
|
|
|
+ $manager = new bonus\manager();
|
|
|
return $manager->send($type_sn,$member_ids);
|
|
|
} catch (Exception $ex) {
|
|
|
return false;
|
|
@@ -297,23 +332,23 @@ class bonus_helper
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- $manager = new \bonus\manager();
|
|
|
+ $manager = new bonus\manager();
|
|
|
return $manager->send_mobile($type_sn,$mobiles,$status);
|
|
|
} catch (Exception $ex) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
static public function get_share($share_id = 0) {
|
|
|
- return \bonus\open_sharer::instance()->get($share_id);
|
|
|
+ return bonus\open_sharer::instance()->get($share_id);
|
|
|
}
|
|
|
|
|
|
- static public function can_grab(\bonus\type $type,$member_id,$mobile)
|
|
|
+ static public function can_grab(bonus\type $type,$member_id,$mobile)
|
|
|
{
|
|
|
$grab_type = $type->grab_type();
|
|
|
- if($grab_type == \bonus\type::GrabType_All) {
|
|
|
+ if($grab_type == bonus\type::GrabType_All) {
|
|
|
return true;
|
|
|
}
|
|
|
- elseif($grab_type == \bonus\type::GrabType_EXSENDER)
|
|
|
+ elseif($grab_type == bonus\type::GrabType_ExSender)
|
|
|
{
|
|
|
if($type->sender_id() == $member_id) {
|
|
|
return false;
|
|
@@ -323,11 +358,31 @@ class bonus_helper
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
- else
|
|
|
+ elseif($grab_type == bonus\type::GrabType_Invite)
|
|
|
+ {
|
|
|
+ $member_id = intval($member_id);
|
|
|
+ if($member_id <= 0 && empty($mobile)) return true;
|
|
|
+
|
|
|
+ if($member_id > 0)
|
|
|
+ {
|
|
|
+ $loginner = new login\memberid_log($member_id);
|
|
|
+ if(!$loginner->ismember()) return true;
|
|
|
+ $mInfo = $loginner->member_info();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $loginner = new login\mobile_log($mobile);
|
|
|
+ if(!$loginner->ismember()) return true;
|
|
|
+ $mInfo = $loginner->member_info();
|
|
|
+ }
|
|
|
+
|
|
|
+ return ($mInfo->invited_bonus() == false);
|
|
|
+ }
|
|
|
+ elseif ($grab_type == bonus\type::GrabType_ExMember)
|
|
|
{
|
|
|
$member_id = intval($member_id);
|
|
|
if($member_id > 0 && !empty($mobile)) {
|
|
|
- $cond['member_id|member_mobile'] = array('_multi'=>true,$member_id,$mobile);
|
|
|
+ $cond['member_id|member_mobile'] = ['_multi'=>true,$member_id,$mobile];
|
|
|
}
|
|
|
elseif($member_id > 0) {
|
|
|
$cond['member_id'] = $member_id;
|
|
@@ -342,12 +397,15 @@ class bonus_helper
|
|
|
$items = Model('member')->getMemberInfo($cond);
|
|
|
return (empty($items) == true);
|
|
|
}
|
|
|
+ else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
static public function match_price($rate_moneys)
|
|
|
{
|
|
|
if(empty($rate_moneys)) return false;
|
|
|
- $scaler = new \bonus\scaler($rate_moneys);
|
|
|
+ $scaler = new bonus\scaler($rate_moneys);
|
|
|
return $scaler->calc();
|
|
|
}
|
|
|
}
|