|
@@ -105,7 +105,80 @@ class account_helper
|
|
return $param;
|
|
return $param;
|
|
}
|
|
}
|
|
|
|
|
|
- public static function invite_bonus($relay_id,&$err)
|
|
|
|
|
|
+ private static function evaluate_param(&$rate_moneys)
|
|
|
|
+ {
|
|
|
|
+ $param['make_type'] = \bonus\type::MakeSendType;
|
|
|
|
+ $param['type_name'] = "评论奖励红包";
|
|
|
|
+ $param['fixed_money'] = 10;
|
|
|
|
+ $param['total_num'] = 1;
|
|
|
|
+ $param['send_type'] = \bonus\type::SendType_Fixed;
|
|
|
|
+ $param['grab_type'] = \bonus\type::GrabType_All;
|
|
|
|
+ $param['bonus_rate'] = 50;
|
|
|
|
+ $param['sender_id'] = self::admin_member_id;
|
|
|
|
+ $param['sender_name'] = self::admin_name;
|
|
|
|
+
|
|
|
|
+ $rate_moneys = [];
|
|
|
|
+ $item['amount'] = 10;
|
|
|
|
+ $item['num'] = 1;
|
|
|
|
+ $item['rate'] = 50;
|
|
|
|
+ $rate_moneys[] = $item;
|
|
|
|
+
|
|
|
|
+ return $param;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static function evaluate_bonus($member_id,&$money)
|
|
|
|
+ {
|
|
|
|
+ $param = self::evaluate_param($rates);
|
|
|
|
+ $type = bonus_helper::create_by_paramer($param);
|
|
|
|
+ $money = $type->getTotal_amount();
|
|
|
|
+ $ret = bonus_helper::make_bonus($param,$rates);
|
|
|
|
+ if($ret != false) {
|
|
|
|
+ $type_sn = $ret['type_sn'];
|
|
|
|
+ bonus_helper::send($type_sn,array($member_id));
|
|
|
|
+ return $type_sn;
|
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static function guide_param(&$rate_moneys)
|
|
|
|
+ {
|
|
|
|
+ $param['make_type'] = \bonus\type::MakeSendType;
|
|
|
|
+ $param['type_name'] = "评论奖励红包";
|
|
|
|
+ $param['fixed_money'] = 10;
|
|
|
|
+ $param['total_num'] = 1;
|
|
|
|
+ $param['send_type'] = \bonus\type::SendType_Fixed;
|
|
|
|
+ $param['grab_type'] = \bonus\type::GrabType_All;
|
|
|
|
+ $param['bonus_rate'] = 50;
|
|
|
|
+ $param['sender_id'] = self::admin_member_id;
|
|
|
|
+ $param['sender_name'] = self::admin_name;
|
|
|
|
+
|
|
|
|
+ $rate_moneys = [];
|
|
|
|
+ $item['amount'] = 10;
|
|
|
|
+ $item['num'] = 1;
|
|
|
|
+ $item['rate'] = 50;
|
|
|
|
+ $rate_moneys[] = $item;
|
|
|
|
+
|
|
|
|
+ return $param;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static function guide_bonus($member_id,&$money)
|
|
|
|
+ {
|
|
|
|
+ $param = self::guide_param($rates);
|
|
|
|
+ $type = bonus_helper::create_by_paramer($param);
|
|
|
|
+ $money = $type->getTotal_amount();
|
|
|
|
+ $ret = bonus_helper::make_bonus($param,$rates);
|
|
|
|
+ if($ret != false) {
|
|
|
|
+ $type_sn = $ret['type_sn'];
|
|
|
|
+ bonus_helper::send($type_sn,array($member_id));
|
|
|
|
+ return $type_sn;
|
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public static function invite_bonus($relay_id)
|
|
{
|
|
{
|
|
$last_type = bonus_helper::last_invite_type($relay_id);
|
|
$last_type = bonus_helper::last_invite_type($relay_id);
|
|
if(is_null($last_type) == false) {
|
|
if(is_null($last_type) == false) {
|
|
@@ -402,8 +475,6 @@ class account_helper
|
|
}
|
|
}
|
|
static public function paysuccess_bonus($buyer_id, $total_amount)
|
|
static public function paysuccess_bonus($buyer_id, $total_amount)
|
|
{
|
|
{
|
|
- Log::record("paysuccess_bonus total_amount={$total_amount}");
|
|
|
|
-
|
|
|
|
$rate_moneys = self::make_rates($total_amount);
|
|
$rate_moneys = self::make_rates($total_amount);
|
|
|
|
|
|
$val = 0.00;
|
|
$val = 0.00;
|
|
@@ -447,7 +518,6 @@ class account_helper
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
public static function onPredeposit($change_type,$member_id,$sn)
|
|
public static function onPredeposit($change_type,$member_id,$sn)
|
|
{
|
|
{
|
|
if($change_type == 'order_pay' || $change_type == 'order_freeze') {
|
|
if($change_type == 'order_pay' || $change_type == 'order_freeze') {
|
|
@@ -464,15 +534,114 @@ class account_helper
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+ //和营销相关的事件区域
|
|
public static function onRegister($member_id)
|
|
public static function onRegister($member_id)
|
|
{
|
|
{
|
|
account_helper::register_bonus($member_id);
|
|
account_helper::register_bonus($member_id);
|
|
- //relation_helper::onRegister($member_id,$mobile,$member_info['member_nickname']);
|
|
|
|
|
|
+ relation_helper::onRegister($member_id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static function onRegisterBonus($member_info,\bonus\type $type,$relay_id)
|
|
|
|
+ {
|
|
|
|
+ $member_id = intval($member_info['member_id']);
|
|
|
|
+ relation_helper::onRegister($member_id);
|
|
|
|
+
|
|
|
|
+ if($relay_id > 0) {
|
|
|
|
+ $share_user = $relay_id;
|
|
|
|
+ } else {
|
|
|
|
+ $share_user = $type->sender_id();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $ret = relation_helper::onSubscribe($member_id,$share_user);
|
|
|
|
+ if($ret) {
|
|
|
|
+ $mem = new member_info($member_info);
|
|
|
|
+ push_helper::notice_subscribe($share_user,$mem);
|
|
|
|
+ }
|
|
|
|
+ relation_helper::onInvite($share_user,$member_id);
|
|
|
|
+ $amount = self::register_bonus($member_id);
|
|
|
|
+
|
|
|
|
+ return $amount;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static function onStatus($member_id)
|
|
|
|
+ {
|
|
|
|
+ relation_helper::onLogin($member_id);
|
|
|
|
+
|
|
|
|
+ $member_info = Model('member')->getMemberInfoByID($member_id);
|
|
|
|
+
|
|
|
|
+ $update_info['member_login_num'] = $member_info['member_login_num'] + 1;
|
|
|
|
+ $update_info['member_login_time'] = time();
|
|
|
|
+ $update_info['member_old_login_time'] = $member_info['member_login_time'];
|
|
|
|
+ $update_info['member_login_ip'] = getIp();
|
|
|
|
+ $update_info['member_old_login_ip'] = $member_info['member_login_ip'];
|
|
|
|
+
|
|
|
|
+ Model('member')->editMember(array('member_id' => $member_id), $update_info);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
public static function onLogin($member_id)
|
|
public static function onLogin($member_id)
|
|
{
|
|
{
|
|
relation_helper::onLogin($member_id);
|
|
relation_helper::onLogin($member_id);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public static function onEvaluate($member_id)
|
|
|
|
+ {
|
|
|
|
+ if(self::evaluate_bonus($member_id,$money) != false) {
|
|
|
|
+ push_helper::evaluation_bonus($member_id,$money);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static function onInvite($sender_id,$relay_id)
|
|
|
|
+ {
|
|
|
|
+ if($relay_id > 0) {
|
|
|
|
+ $member_id = $relay_id;
|
|
|
|
+ } else {
|
|
|
|
+ $member_id = $sender_id;
|
|
|
|
+ }
|
|
|
|
+ if($member_id < 0) return false;
|
|
|
|
+
|
|
|
|
+ if(self::guide_bonus($member_id,$money) != false) {
|
|
|
|
+ push_helper::evaluation_bonus($member_id,$money);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //在发货之后,可以提醒用户留意收货,在订单中查看物流
|
|
|
|
+ public static function onOrderSend($member_id)
|
|
|
|
+ {
|
|
|
|
+ Log::record("account_helper::onOrderSend {$member_id}",Log::DEBUG);
|
|
|
|
+ }
|
|
|
|
+ //在支付成功之后,可以提醒用户收到货后,可以收到红包奖励。
|
|
|
|
+ public static function onPaySuccess($member_id)
|
|
|
|
+ {
|
|
|
|
+ Log::record("account_helper::onOrderSuccess {$member_id}",Log::DEBUG);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static function onOrderSuccess($pay_sn)
|
|
|
|
+ {
|
|
|
|
+ $data = &$result['data'];
|
|
|
|
+ $order_amount = 0.0;
|
|
|
|
+ $goods_amount = 0.0;
|
|
|
|
+ if(is_array($data['order_list']))
|
|
|
|
+ {
|
|
|
|
+ foreach($data['order_list'] as $key => $order) {
|
|
|
|
+ $order_amount += doubleval($order['order_amount']);
|
|
|
|
+ $goods_amount += doubleval($order['goods_amount']);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $mod = Model('order');
|
|
|
|
+ $info = $mod->getOrderInfo(array('pay_sn' => $pay_sn));
|
|
|
|
+ $buyer_id = intval($info['buyer_id']);
|
|
|
|
+ $goods_amount = intval($info['goods_amount']);
|
|
|
|
+
|
|
|
|
+ $ret = account_helper::paysuccess_bonus($buyer_id,$goods_amount);
|
|
|
|
+ if($ret == false) {
|
|
|
|
+ Log::record("向用户发送购物后分享红包失败",log::ERR);
|
|
|
|
+ return false;
|
|
|
|
+ } else {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|