Ver código fonte

fix 新微信用户扫描已注册用户app内二维码,没有领取红包界面

stanley-king 7 anos atrás
pai
commit
3b9f24dbb8
4 arquivos alterados com 41 adições e 24 exclusões
  1. 3 1
      helper/account_helper.php
  2. 20 4
      helper/session_helper.php
  3. 17 15
      mobile/control/index.php
  4. 1 4
      test/DBTest.php

+ 3 - 1
helper/account_helper.php

@@ -103,7 +103,9 @@ class account_helper
         {
             $to_minfo = new member_info($to_id);
             $thief = $to_minfo->nickname();
-            bonus_helper::withold_money($from_id,$bonus_rate['rate'],$bonus_rate['amount'],bonus_helper::send_bonus_withold);
+
+            $amount = $bonus_rate['amount'];
+            bonus_helper::withold_money($from_id,$bonus_rate['rate'],$amount,bonus_helper::send_bonus_withold);
             $pred_from->handout_bonus($amount,$ret['type_sn'],$thief,"{$thief}摇走了您{$amount}元的红包.",\bonus\type::MakeShakeGainType);
             $bonusex = bonus_helper::send($ret['type_sn'],[$to_id]);
             push_helper::stolen_bonus($minfo,$to_minfo,$amount);

+ 20 - 4
helper/session_helper.php

@@ -305,6 +305,7 @@ class session_helper
                         $wechat_loginer->register($user_info,$relay_id,session_helper::mobile());
                         $wechat_loginer->login();
                         account_helper::onRegister(session_helper::memberid(),$relay_id);
+                        wechat_helper::set_invite_bonus(); //如果用户从扫二维码来的,需要领红包
                     }
                 }
 
@@ -559,7 +560,6 @@ class wechat_helper
     static public function has_userinfo() {
         return !empty(self::userinfo());
     }
-
     static public function userinfo()
     {
         if(array_key_exists('wx_author',$_SESSION)) {
@@ -568,18 +568,15 @@ class wechat_helper
             return "";
         }
     }
-
     static public function set_userinfo($userinfo) {
         $_SESSION['wx_author']['user_info'] = $userinfo;
     }
-
     static public function clear_wxinfo()
     {
         if(array_key_exists('wx_author',$_SESSION)) {
             unset($_SESSION['wx_author']);
         }
     }
-
     static public function has_origin_url()
     {
         return array_key_exists('author_orgin_url',$_SESSION);
@@ -600,4 +597,23 @@ class wechat_helper
             unset($_SESSION['author_orgin_url']);
         }
     }
+    static public function set_invite_bonus()
+    {
+        $_SESSION['invite_bonus_qrcode'] = true;
+    }
+    static public function clear_invite_bonus()
+    {
+        if(array_key_exists('invite_bonus_qrcode',$_SESSION)) {
+            unset($_SESSION['invite_bonus_qrcode']);
+        }
+    }
+    static public function invite_bonus_tag()
+    {
+        if(array_key_exists('invite_bonus_qrcode',$_SESSION)) {
+            return $_SESSION['invite_bonus_qrcode'];
+        }
+        else {
+            return false;
+        }
+    }
 }

+ 17 - 15
mobile/control/index.php

@@ -75,36 +75,38 @@ class indexControl extends specialControl
             return self::outerr(errcode::ErrParamter);
         }
 
+        $memkey = urldecode($idol);
+        $relay_id = intval(util::decrypt_data($memkey));
+
         if(session_helper::need_wechat_author()) {
             $author = new thrid_author\wxauthor();
-            $url = BASE_SITE_URL . "/mobile/index.php?act=index&op=member&member_id={$idol}";
+            $url = BASE_SITE_URL . "/mobile/index.php?act=index&op=member&member_id={$idol}&relay_id={$relay_id}";
             $url = $author->enter($url);
             return self::outsuccess(['direct_uri' => $url],"redirect");
         }
 
-        $idol = urldecode($idol);
-        $idol = intval(util::decrypt_data($idol));
-
-        if(session_helper::logined())
+        if(session_helper::logined() == false || wechat_helper::invite_bonus_tag())
         {
-            $myself = session_helper::memberid();
-            $relateion = new \relation\mem_relation($myself);
-            $isfriend =  $relateion->is_follower($idol);
+            if(wechat_helper::invite_bonus_tag()) {
+                wechat_helper::clear_invite_bonus();
+            }
 
-            return self::outsuccess(array('info' => new member_info($idol),'is_friend' => $isfriend),"member/index",'wap');
-        }
-        else
-        {
-            $type_sn = account_helper::invite_bonus($idol);
+            $type_sn = account_helper::invite_bonus($relay_id);
             if($type_sn == false) {
                 return self::outerr(errcode::ErrBonus,"生成邀请红包失败.");
             }
-            else
-            {
+            else {
                 $ref_url = url_helper::bonus_open_url($type_sn);
                 return self::outsuccess(['direct_uri' => $ref_url],"redirect");
             }
         }
+        else {
+            $myself = session_helper::memberid();
+            $relateion = new \relation\mem_relation($myself);
+            $isfriend =  $relateion->is_follower($relay_id);
+
+            return self::outsuccess(array('info' => new member_info($relay_id),'is_friend' => $isfriend),"member/index",'wap');
+        }
     }
 }
 

+ 1 - 4
test/DBTest.php

@@ -25,27 +25,24 @@ class DBTest extends PHPUnit_Framework_TestCase
 
     public function testTranslog()
     {
-    }
 
+    }
     public function testSyscount()
     {
         $bonus_type = Model('bonus_type');
         $result = $bonus_type->field('*')->where(['send_start_date' => ['between',[1495592858,1495601456]]])->limit(false)->select();
     }
-
     public function testCount()
     {
         $mod_member = Model('member');
         $num = $mod_member->count();
     }
-
     public function testQuery()
     {
         $mobile = '18911779278';
         $sql = "select * from lrlz_member where member_mobile='{$mobile}'";
         $items = Db::getAll($sql);
     }
-
     public static function tearDownAfterClass()
     {