stanley-king 6 éve
szülő
commit
00b71de3c0

+ 4 - 2
helper/account_helper.php

@@ -56,6 +56,8 @@ class account_helper
         $ret = bonus_helper::make_bonus($param, $param['rate_money']);
         if ($ret != false) {
             $type_sn = $ret['type_sn'];
+            push_helper::invite_bonus($relay_id,$to_minfo,$amount);
+
             return $type_sn;
         } else {
             return false;
@@ -137,7 +139,7 @@ class account_helper
 
             bonus_helper::withold_money($from_id,$rate,$amount,bonus_helper::send_bonus_withold);
             $bonusex = bonus_helper::send($ret['type_sn'],[$to_id]);
-            push_helper::fly_bonus($minfo,$to_info,$amount);
+            push_helper::fly_bonus($minfo,$to_info,$amount,$ret['type_sn']);
 
             return $bonusex;
         } else {
@@ -192,7 +194,7 @@ class account_helper
         {
             $bonus = bonus_helper::send($ret['type_sn'],[$member_id]);
             if($bonus != false) {
-                push_helper::bonus_refund($member_id,$amount);
+                push_helper::bonus_refund($member_id,$amount,$ret['type_sn']);
             }
         }
         else {

+ 31 - 5
helper/push_helper.php

@@ -42,9 +42,13 @@ class push_helper
         $push_param['extra']['image']     = $to_info->avatar();
 
         QueueClient::push('upushSendMsg',$push_param);
+
+        $from = ['nickname' => $to_info->nickname(),'avatar' => $to_info->avatar(),'userid' => $to_info->member_id()];
+        $content = ['type' => 'stolen_bonus','from' => $from,'amount' => $amount,'txt' => "{偷走了您{$amount}元的红包}"];
+        room\factory_client::instance()->notice_users([$from_info->member_id()],room\proto_type::push_notify,$content,$text);
     }
 
-    public static function fly_bonus(member_info $from_info,member_info $to_info,$amount)
+    public static function fly_bonus(member_info $from_info,member_info $to_info,$amount,$type_sn)
     {
         $name = $from_info->nickname();
         $text = "{$name}的{$amount}元的红包,在向您飞来~.";
@@ -61,6 +65,11 @@ class push_helper
         $push_param['extra']['image']     = $from_info->avatar();
 
         QueueClient::push('upushSendMsg',$push_param);
+
+        $from = ['nickname' => $from_info->nickname(),'avatar' => $from_info->avatar(),'userid' => $from_info->member_id()];
+        $shema = schema_helper::bonus_detail($type_sn);
+        $content = ['type' => 'fly_bonus','from' => $from,'amount' => $amount,'schema' => $shema,'txt' => "{$name}摇飞了{$amount}元红包,到你账户."];
+        room\factory_client::instance()->notice_users([$to_info->member_id()],room\proto_type::push_notify,$content,$text);
     }
 
     public static function order_refund_bonus($member_id,$amount)
@@ -82,14 +91,15 @@ class push_helper
         QueueClient::push('upushSendMsg',$push_param);
     }
 
-    public static function send_bonus($member_id,$to_ids)
+    public static function send_bonus($member_id,$to_ids,$type_sn)
     {
         $sender = new member_info($member_id);
         $name = $sender->nickname();
+        $text = "新的红包:您的好友{$name}给您发了一个红包,请查收.";
+
         foreach ($to_ids as $member_id)
         {
             $push_param = [];
-            $text = "新的红包:您的好友{$name}给您发了一个红包,请查收.";
 
             $push_param['alias'] = $member_id;
             $push_param['title'] = "新到红包";
@@ -104,8 +114,14 @@ class push_helper
 
             QueueClient::push('upushSendMsg',$push_param);
         }
+
+        $from = ['nickname' => $sender->nickname(),'avatar' => $sender->avatar(),'userid' => $sender->member_id()];
+        $shema = schema_helper::bonus_detail($type_sn);
+        $content = ['type' => 'receive_bonus','from' => $from,'schema' => $shema,'txt' => "给您发了一个红包"];
+        room\factory_client::instance()->notice_users($to_ids,room\proto_type::push_notify,$content,$text);
     }
-    public static function bonus_refund($member_id,$amount)
+
+    public static function bonus_refund($member_id,$amount,$type_sn)
     {
         $sender = new member_info($member_id);
         $text = "红包退还通知:您发送的红包已超过24小时,退还未被领取的金额{$amount}元,您可以重新发送并通知小伙伴及时领取.";
@@ -122,6 +138,11 @@ class push_helper
         $push_param['extra']['image']     = $sender->avatar();
 
         QueueClient::push('upushSendMsg',$push_param);
+
+        $from = ['nickname' => $sender->nickname(),'avatar' => $sender->avatar(),'userid' => $sender->member_id()];
+        $shema = schema_helper::bonus_detail($type_sn);
+        $content = ['type' => 'bonus_refund','from' => $from,'schema' => $shema,'txt' => "红包过期退款¥{$amount}"];
+        room\factory_client::instance()->notice_users([$member_id],room\proto_type::push_notify,$content,$text);
     }
 
     public static function invite_bonus($member_id,$money)
@@ -141,6 +162,11 @@ class push_helper
         $push_param['extra']['image']    = $minfo->avatar();
 
         QueueClient::push('upushSendMsg',$push_param);
+
+//        $from = ['nickname' => $minfo->nickname(),'avatar' => $minfo->avatar(),'userid' => $minfo->member_id()];
+//        $shema = schema_helper::bonus_detail($type_sn);
+//        $content = ['type' => 'bonus_refund','from' => $from,'schema' => $shema,'txt' => "红包过期退款¥{$amount}"];
+//        room\factory_client::instance()->notice_users([$member_id],room\proto_type::push_notify,$content,$text);
     }
 
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -795,7 +821,7 @@ class push_helper
             }
             $param['text'] = $text;
 
-            $param['extra']['go_type']   = 'fcode';
+            $param['extra']['go_type'] = 'fcode';
             $param['extra']['title']= "用户评价";
             $param['extra']['text'] = $text;
             $param['extra']['show_type'] = 'pop';

+ 3 - 5
helper/room/room_processor.php

@@ -342,11 +342,9 @@ class room_processor implements IProcessor
         }
         else
         {
-            foreach ($users as $user) {
-                $send['msgid'] = 0;
-                $send['send_time'] = time();
-                $this->write_push_users($pushid,[$user],$send);
-            }
+            $send['msgid'] = 0;
+            $send['send_time'] = time();
+            $this->write_push_users($pushid,$users,$send);
         }
 
         return $this->success(NULL);

+ 1 - 1
mobile/control/member_bonus.php

@@ -281,7 +281,7 @@ class member_bonusControl extends mbMemberControl
                 $mids = explode(',',$strids);
                 $bonusex = bonus_helper::send($type_sn,$mids);
                 if($bonusex != false) {
-                    push_helper::send_bonus(session_helper::memberid(),$mids);
+                    push_helper::send_bonus(session_helper::memberid(),$mids,$type_sn);
                 }
             }
 

+ 11 - 0
test/TestRoomFactory.php

@@ -162,4 +162,15 @@ class TestRoomFactory extends PHPUnit_Framework_TestCase
         room\pusher::instance()->apply_friend(39674,39689,'我是你叔叔');
     }
 
+    public function testSysNotice()
+    {
+        $to_info = new member_info(39689);
+        $amount = 1;
+        $text = "{$to_info->nickname()}偷走了您{$amount}元的红包.";
+
+        $from = ['nickname' => $to_info->nickname(),'avatar' => $to_info->avatar(),'userid' => $to_info->member_id()];
+        $content = ['type' => 'stolen_bonus','from' => $from,'amount' => $amount];
+        room\factory_client::instance()->notice_users([39653],room\proto_type::push_notify,$content,$text);
+    }
+
 }