Quellcode durchsuchen

debug add friends

stanley-king vor 6 Jahren
Ursprung
Commit
38671ba32d

+ 1 - 1
helper/relation/mem_relation.php

@@ -324,7 +324,7 @@ class mem_relation
         if($this->member_id == $other_id) {
             return false;
         }
-        return (algorithm::binary_search($this->follower,$other_id)) || (algorithm::binary_search($this->subscriber,$other_id));
+        return (algorithm::binary_search($this->follower,$other_id)) && (algorithm::binary_search($this->subscriber,$other_id));
     }
 
     private function subscribed($mobile)

+ 15 - 0
helper/relation_helper.php

@@ -210,4 +210,19 @@ class relation_helper
             return false;
         }
     }
+
+    static public function is_friends($left,$right)
+    {
+        try{
+            $l = new relation\mem_relation($left);
+            $r = new relation\mem_relation($right);
+
+            return $l->is_friends($right) && $r->is_friends($left);
+        }
+        catch (Exception $ex)
+        {
+            Log::record(__METHOD__ . " {$ex->getMessage()}",Log::ERR);
+            return false;
+        }
+    }
 }

+ 2 - 2
helper/room/room_processor.php

@@ -316,12 +316,12 @@ class room_processor implements IProcessor
         elseif($type === proto_type::push_notify) {
             $pushid = 2;
             $msg_type = proto_type::msg_type_nofity;
-            $send[] = $msg;
+            $send['content'] = $msg;
         }
         elseif($type === proto_type::push_apply) {
             $pushid = 3;
             $msg_type = proto_type::msg_type_apply;
-            $send[] = $msg;
+            $send['content'] = $msg;
         }
         else {
             return $this->error(errcode::ErrParamter);

+ 1 - 0
mobile/control/member_talk.php

@@ -1347,6 +1347,7 @@ class member_talkControl extends mbMemberControl
         $isfriend =  $relateion->is_friends($user);
 
         if($isfriend == false) {
+            $relateion->subscribe($user);
             room\pusher::instance()->apply_friend(session_helper::memberid(),$user,$msg);
         }
 

+ 33 - 93
mobile/control/user_index.php

@@ -49,12 +49,12 @@ class user_indexControl extends mobileHomeControl
             return self::outerr(errcode::ErrParamter);
         }
 
-//        if(session_helper::need_wechat_author()) {
-//            $author = new thrid_author\wxauthor();
-//            $url = url_helper::member_index($idolid);
-//            $url = $author->enter($url);
-//            return self::outsuccess(['direct_uri' => $url],"redirect");
-//        }
+        if(session_helper::need_wechat_author()) {
+            $author = new thrid_author\wxauthor();
+            $url = url_helper::member_index($idolid);
+            $url = $author->enter($url);
+            return self::outsuccess(['direct_uri' => $url],"redirect");
+        }
 
         if(session_helper::logined() == false)
         {
@@ -85,20 +85,32 @@ class user_indexControl extends mobileHomeControl
 
     private function open_page($idolid,$output = [])
     {
-        $minfo = new member_info($idolid);
-        $relateion = new relation\mem_relation(session_helper::memberid());
-        $isfriend =  $relateion->is_friends($idolid);
-        if($output['scene'] != 'applyer') {
-            if(!$isfriend) {
-                $output['scene'] = 'stranger';
-            } else {
-                $output['scene'] = 'friends';
+        try
+        {
+            $relation = new relation\mem_relation(session_helper::memberid());
+            $isfriend = $relation->is_friends($idolid);
+
+            if($output['scene'] != 'applyer')
+            {
+                if(!$isfriend) {
+                    $output['scene'] = 'stranger';
+                } else {
+                    $output['scene'] = 'friends';
+                }
             }
-        }
-        $output['member_info'] = $minfo->filter();
-        $output['is_friend'] = $isfriend;
 
-        return self::outsuccess($output,"member/index",'wap');
+            $minfo = new member_info($idolid);
+            $output['member_info'] = $minfo->filter();
+            $output['is_friend'] = $isfriend;
+
+            return self::outsuccess($output,"member/index",'wap');
+
+        }
+        catch (Exception $ex)
+        {
+            Log::record(__METHOD__ . " {$ex->getMessage()}",Log::ERR);
+            return false;
+        }
     }
 
     /**
@@ -111,7 +123,7 @@ class user_indexControl extends mobileHomeControl
         if(!session_helper::logined()) {
             return self::outerr(errcode::ErrUnLogin);
         }
-        $idolid = $_GET['member_id'];
+        $idolid = intval($_GET['member_id']);
         if($idolid <= 0) {
             return self::outerr(errcode::ErrParamter);
         }
@@ -156,7 +168,7 @@ class user_indexControl extends mobileHomeControl
         }
 
         $msg = json_decode($item['orgmsg'],true);
-        $idolid = $msg['from']['userid'];
+        $idolid = intval($msg['from']['userid']);
         if($idolid <= 0) {
             return self::outerr(errcode::ErrParamter);
         }
@@ -176,7 +188,7 @@ class user_indexControl extends mobileHomeControl
         }
 
         $msg = json_decode($item['orgmsg'],true);
-        $idolid = $msg['from']['userid'];
+        $idolid = intval($msg['from']['userid']);
         if($idolid <= 0) {
             return self::outerr(errcode::ErrParamter);
         }
@@ -184,75 +196,3 @@ class user_indexControl extends mobileHomeControl
         return $this->open_page($idolid,['from_type' => '来自于好友申请','scene' => 'applyer','note' => $msg['note']]);
     }
 }
-
-class tpl_member
-{
-    private $mOutput;
-    private $mInfo;
-    private $mIsFriend;
-    private $mPred;
-    public function __construct($output)
-    {
-        $this->mOutput = $output;
-        $this->mInfo = $this->mOutput['info'];
-        $this->mIsFriend = $this->mOutput['is_friend'];
-        $userid = $this->mInfo->member_id();
-        $this->mPred = new bonus\account($userid);
-    }
-
-    public function output_group()
-    {
-        $amount = $this->mPred->total_bonus();
-        $amount = intval($amount * 100 + 0.5) / 100;
-        $discount = $this->mInfo->discount_self();
-        $discount = intval($discount * 100 + 0.5) / 100;
-
-        $result = "<div class=\"cell\">
-            <span class=\"cell_label\">红包余额</span><span class=\"cell_content\"><span class=\"letter_pro\">$amount</span>元</span>
-        </div>
-        <div class=\"cell\">
-            <span class=\"cell_label\">累计节省</span><span class=\"cell_content\"><span class=\"letter_pro\">$discount</span>元</span>
-        </div>";
-
-        if(!session_helper::isapp()) {
-            $from = '<div class="cell">
-                <span class="cell_label">信息来源</span><span class="cell_content">来自扫一扫</span>
-            </div>';
-            $result .= $from;
-        }
-        return $result;
-    }
-
-    public function output_btn()
-    {
-        $is_friend = $this->mOutput['is_friend'];
-        if(!session_helper::isapp())
-        {
-
-            $result = '<div class="submit">';
-            if($is_friend) {
-                $result .= '<p class="cell_label">你已经是他的粉丝了</p>';
-            } else {
-                $result .= '<button type="button" id="btn_add_friend" class="add_friend_btn">关注</button>';
-            }
-            $result .= '</div>';
-        }
-        else
-        {
-            $result =  '<div class="submit">
-                            <button type="button" id="btn_thief_bonus" class="add_friend_btn">偷一点</button>
-                        </div>
-                        <div class="submit">
-                            <button type="button" id="btn_send_bonus" class="send_bonus_btn">发红包</button>
-                        </div>';
-
-            if(!$is_friend) {
-                $result .= '<div class="submit">';
-                $result .= '<button type="button" id="btn_add_friend" class="add_friend_btn">关注</button>';
-                $result .= '</div>';
-            }
-        }
-
-        return $result;
-    }
-}