Przeglądaj źródła

wesmiler 更新第5期更新代码合并

wesmiler 4 lat temu
rodzic
commit
507edf6fdb

+ 33 - 46
app/weixin/model/Wechat.php

@@ -174,10 +174,9 @@ class Wechat
         // 验证微信信息是否存在
         $cacheKey = 'updateWeixinInfo:' . $openid;
         $updateCheck = cache($cacheKey);
-        $nickname = isset($wxInfo['nickname']) ? $wxInfo['nickname'] : '';
         $wxData = [
             'openid' => $openid,
-            'nickname' => $nickname,
+            'nickname' => isset($wxInfo['nickname']) ? $wxInfo['nickname'] : '',
             'headimgurl' => isset($wxInfo['headimgurl']) ? $wxInfo['headimgurl'] : '',
             'sex' => isset($wxInfo['sex']) ? $wxInfo['sex'] : 0,
             'country' => isset($wxInfo['country']) ? $wxInfo['country'] : '',
@@ -193,7 +192,7 @@ class Wechat
             $expire = config('weixin.update_expire');
             $expire = $expire ? $expire : 3 * 3600;
             cache($cacheKey, date('Y-m-d H:i:s'), ['expire' => $expire]);
-        } else if (empty($updateCheck) && $nickname) {
+        } else if (empty($updateCheck)) {
             // 更新微信用户信息
             db('fans')->where(['openid' => $openid])->update($wxData);
 
@@ -212,11 +211,10 @@ class Wechat
      */
     private static function wxInit()
     {
-        $info = Wechat::getWxInfo();
-        $openid = isset($info['openid']) ? $info['openid'] : '';
-        $userInfo = Wechat::getUserInfo($openid);
-        $wxInfo = $userInfo? $userInfo : $info;
+        $wxInfo = Wechat::getWxInfo();
         $openid = isset($wxInfo['openid']) ? $wxInfo['openid'] : '';
+        $userInfo = Wechat::getUserInfo($openid);
+        $wxInfo = $userInfo? $userInfo : $wxInfo;
         $cacheKey = 'weixin:init:'.get_client_ip().'_'.$openid;
         if (empty($wxInfo) || empty($openid)) {
             if(PRedis::get($cacheKey)<10){
@@ -236,9 +234,9 @@ class Wechat
         $updateCheck = cache($cacheKey);
         $wxData = [
             'openid' => $openid,
-            'nickname' => isset($info['nickname']) ? $info['nickname'] : '',
-            'headimgurl' => isset($info['headimgurl']) ? $info['headimgurl'] : '',
-            'sex' => isset($info['sex']) ? $info['sex'] : 0,
+            'nickname' => isset($wxInfo['nickname']) ? $wxInfo['nickname'] : '',
+            'headimgurl' => isset($wxInfo['headimgurl']) ? $wxInfo['headimgurl'] : '',
+            'sex' => isset($wxInfo['sex']) ? $wxInfo['sex'] : 0,
             'country' => isset($wxInfo['country']) ? $wxInfo['country'] : '',
             'province' => isset($wxInfo['province']) ? $wxInfo['province'] : '',
             'city' => isset($wxInfo['city']) ? $wxInfo['city'] : '',
@@ -318,25 +316,19 @@ class Wechat
             }
 
             // 更新微信用户信息
-            if($wxData['nickname']){
-                db('fans')->where(['openid' => $openid])->update($wxData);
-
-                // 每3个小时才更新一次微信信息
-                $expire = config('weixin.update_expire');
-                $expire = $expire ? $expire : 3 * 3600;
-                cache($cacheKey, date('Y-m-d H:i:s'), ['expire' => $expire]);
-            }
+            db('fans')->where(['openid' => $openid])->update($wxData);
 
+            // 每3个小时才更新一次微信信息
+            $expire = config('weixin.update_expire');
+            $expire = $expire ? $expire : 3 * 3600;
+            cache($cacheKey, date('Y-m-d H:i:s'), ['expire' => $expire]);
         }else{
             $updateData = [
+                'is_follow'=> isset($wxInfo['subscribe']) ? intval($wxInfo['subscribe']) : 0,
                 'last_login_time'=> time(),
                 'last_login_ip'=> get_client_ip(),
                 'updated_at'=> date('Y-m-d H:i:s')
             ];
-
-            if(isset($wxInfo['subscribe'])){
-                $updateData['is_follow'] = intval($wxInfo['subscribe']);
-            }
             db('user')->where(['openid' => $openid])
                 ->where('user_status','>=', 0)
                 ->update($updateData);
@@ -374,15 +366,15 @@ class Wechat
             $countKey = "token:count";
             $requestCount = PRedis::get($countKey);
             if($type == 'accessToken'){
-                if($requestCount >=500){
+                if($requestCount >=5000){
                     PRedis::set("token:error", ['error'=> 'token请求次数超出警告值8000:'.date('Y-m-d H:i:s'),'date'=> date('Y-m-d H:i:s')], 7 * 24 *3600);
                     return false;
                 }
-                PRedis::set($countKey, $requestCount+1, 86400);
+                PRedis::set($countKey, $requestCount+1, 20*3600);
             }
 
             $tokenData = httpRequest($url);
-            PRedis::set("token:result:{$type}", $tokenData, 86400);
+            PRedis::set("token:result:{$type}", $tokenData, 3600);
             $code = isset($tokenData['errcode']) ? $tokenData['errcode'] : '';
             if ($code || empty($tokenData)) {
                 return $tokenData;
@@ -396,13 +388,13 @@ class Wechat
                 'date' => date('Y-m-d H:i:s'),
                 'expire' => $type == 'tempToken' ? time() + 7000 : time() + 7000,
             ];
-            PRedis::set($cacheKey, $tokenData, 7000);
+            PRedis::set($cacheKey, $tokenData, 7200);
         }
 
         $expire = isset($tokenData['expire']) ? intval($tokenData['expire']) : 0;
         $token = isset($tokenData['token']) ? trim($tokenData['token']) : '';
-        if (($expire && $expire < time()) || empty($token) && $refresh == false) {
-           // $tokenData = Wechat::getAccessToken($key, $type, true);
+        if (($expire && $expire < time()) || empty($token)) {
+            $tokenData = Wechat::getAccessToken($key, $type, true);
         }
 
         if ($key) {
@@ -458,11 +450,10 @@ class Wechat
         $result = httpRequest($url);
         $errcode = isset($result['errcode']) ? $result['errcode'] : '';
         $cacheCount = PRedis::get('weixin:getWxInfo:' . $key);
-        $cacheCount = $cacheCount? $cacheCount : 0;
-        if (empty($result) || ($errcode && $cacheCount <= 3)) {
+        if (empty($result) || ($errcode && $cacheCount <= 5)) {
             // 更新TOKEN重新获取
             PRedis::set('weixin:getWxInfo:' . $key, $cacheCount + 1, 600);
-            $result = Wechat::getWxInfo($curOpenid, $errcode ? true : false);
+            //$result = Wechat::getWxInfo($curOpenid, $errcode ? true : false);
         }
         PRedis::set('weixin:wxInfo:'.$key, $result, 600);
         if ($saveData && empty($errcode)) {
@@ -508,7 +499,6 @@ class Wechat
         $result = httpRequest($url);
         $errcode = isset($result['errcode']) ? $result['errcode'] : '';
         $cacheCount = PRedis::get('weixin:getInfo:' . $key);
-        $cacheCount = $cacheCount? $cacheCount : 0;
         if (empty($result) || ($errcode && $cacheCount <= 3)) {
             // 更新TOKEN重新获取
             PRedis::set('weixin:getInfo:' . $key, $cacheCount + 1, 600);
@@ -574,7 +564,7 @@ class Wechat
             $ticket = Wechat::getTicket(true);
         }
 
-        if (empty($ticket) && $refreshToken == false) {
+        if (empty($ticket)) {
             $ticket = Wechat::getTicket(true, true);
         }
 
@@ -1204,7 +1194,6 @@ class Wechat
         if ($lock) {
             return false;
         }
-        $wxInfo = [];
         PRedis::set($lockKey, $postObj, 8);
         PRedis::set('weixin:events:'.$openid,$postObj, 3600);
         if ($event && $eventKey) {
@@ -1266,11 +1255,7 @@ class Wechat
 
 
                     $siteInfo = cmf_get_site_info();
-                    $nickname = isset($wxInfo['nickname']) ? $wxInfo['nickname'] : '';
-                    if(empty($nickname)){
-                        $info = Fans::getWxInfo($openid);
-                        $nickname = isset($info['nickname']) && $info['nickname']? $info['nickname'] : '拾光用户';
-                    }
+                    $nickname = isset($wxInfo['nickname']) && $wxInfo['nickname']? $wxInfo['nickname'] : '拾光用户';
                     $siteName = isset($siteInfo['site_name']) ? $siteInfo['site_name'] : '本公众号';
                     $followMsg = isset($siteInfo['follow_msg']) ? $siteInfo['follow_msg'] : '';
                     $contentStr = $followMsg ? str_replace('{nickname}', $nickname, $followMsg) : "Hi{$wxInfo['nickname']},欢迎关注{$siteName}!";
@@ -1278,9 +1263,10 @@ class Wechat
             }
         }
 
+
         // 已关注
         if (in_array($event, ['SCAN', 'text', 'subscribe'])) {
-            if ($event === 'SCAN' || ($event == 'subscribe' && $contentStr == '') || $event == 'text') {
+            if ($event === 'SCAN' || ($event === 'subscribe' && $contentStr == '') || $event == 'text') {
                 $wxInfo = Wechat::getUserInfo($openid, false, true);
                 if ($wxInfo) {
                     // 用户信息
@@ -1296,11 +1282,12 @@ class Wechat
                     PRedis::set('weixin:reg:'.$openid, ['info'=> $wxInfo, 'invite'=> $postObj, 'regInfo'=> $userData], 600);
                     Member::regMember($userData);
                     $siteInfo = cmf_get_site_info();
-                    $nickname = isset($wxInfo['nickname']) ? $wxInfo['nickname'] : '';
+                    $nickname = isset($wxInfo['nickname'])? $wxInfo['nickname'] : '';
                     if(empty($nickname)){
                         $info = Fans::getWxInfo($openid);
                         $nickname = isset($info['nickname']) && $info['nickname']? $info['nickname'] : '拾光用户';
                     }
+
                     $siteName = isset($siteInfo['site_name']) ? $siteInfo['site_name'] : '本公众号';
                     $followMsg = isset($siteInfo['follow_msg']) ? $siteInfo['follow_msg'] : '';
                     $contentStr = $followMsg ? str_replace('{nickname}', $nickname, $followMsg) : "Hi【{$nickname}】,欢迎关注{$siteName}!";
@@ -1308,15 +1295,16 @@ class Wechat
             }
 
             // 更新关注
-            if($event == 'subscribe'){
-                Member::saveData(['openid'=> $openid],['is_follow'=> 1]);
+            if(in_array($event, ['subscribe','unsubscribe'])){
+                Member::saveData(['openid'=> $openid],['is_follow'=> $event == 'unsubscribe'? 0 : 1]);
             }
             $userInfo = Member::getInfo(['openid' => $openid]);
-            PRedis::set('follow:'.$openid, ['info'=>$wxInfo,'event'=> $event,'text'=> $contentStr], 600);
+            PRedis::set('follow:'.$openid, $wxInfo, 600);
             session('userInfo', $userInfo);
 
             // 推送用户注册消息
             $contentStr = $contentStr ? $contentStr : '您好,欢迎关注本公众号';
+            // $info = Member::where(['openid' => $openid])->field('id,real_name,mobile')->find();
             $replyUrl = config('weixin.reply_url');
             if ($replyUrl) {
                 $url = Wechat::makeRedirectUrl(url('/weixin/match/index', '', '', true));
@@ -1329,13 +1317,12 @@ class Wechat
                 $inviteOpenid = isset($inviteData['openid']) ? $inviteData['openid'] : '';
                 $message = isset($inviteData['message']) ? $inviteData['message'] : '';
                 if ($inviteOpenid && $message) {
-                    Wechat::sendCustomMsg($openid, ['content' => $message]);
+                    Wechat::sendCustomMsg($openid, ['content' => $contentStr]);
                 }
             }
         }else if($event == 'unsubscribe'){
             $cacheKey = "weixin:auth:".$openid;
             PRedis::del($cacheKey);
-            Member::saveData(['openid'=> $openid],['is_follow'=> 0]);
             session('userInfo', null);
         }
 

+ 10 - 5
public/themes/admin_simpleboot3/admin/market/marketexamine.html

@@ -3,9 +3,16 @@
 <body>
 <div class="wrap js-check-wrap">
     <ul class="nav nav-tabs">
-        <li class="active">
-        <a> 分销用户待审核</a>
+        <li <if condition="params.type==0">class="active"</if> href="{:url('Market/marketexamine',array('u'=>1,'type'=>0))}">
+        <a> 推广用户待审核</a>
         </li>
+        <li <if condition="params.type==1">class="active"</if> href="{:url('Market/marketexamine',array('u'=>1,'type'=>1))}">
+            <a> 商户用户待审核</a>
+        </li>
+        <li <if condition="params.type==2">class="active"</if>  href="{:url('Market/marketexamine',array('u'=>1,'type'=>1))}">
+            <a> 机构用户待审核</a>
+        </li>
+
     </ul>
 
     
@@ -160,9 +167,7 @@
     </form>
     <form method="post" class="js-ajax-form">
     <div class="table-actions">
-       
-         
-         <if condition="$Request.action eq 'custom' || $Request.param.u eq 2">
+        <if condition="$Request.action eq 'custom' || $Request.param.u eq 2">
             
             
 

+ 17 - 25
public/themes/default/weixin/member/index.html

@@ -2,7 +2,7 @@
 <title>个人中心</title>
 <link rel="stylesheet" href="__TMPL__/weixin/public/assets/css/member.css?v={$version}">
 <div id="app" v-cloak >
-    <div id="main" class="main-box">
+    <div id="main" class="main-box" @click.stop="hideMenu">
         <div class="tox_box">
             <img src="__TMPL__/weixin/public/assets/img/tubiao9.png">
             <div class="tox_xx">
@@ -69,14 +69,6 @@
                         <img src="__TMPL__/weixin/public/assets/img/new-vip.png">
                         <span>开通会员</span>
                     </a>
-                    <a href="/weixin/auth/hand">
-                        <img src="__TMPL__/weixin/public/assets/img/new-hand.png">
-                        <span>人工牵线</span>
-                    </a>
-                    <a href="/weixin/page/custom?type=1">
-                        <img src="__TMPL__/weixin/public/assets/img/custom.png">
-                        <span>联系客服</span>
-                    </a>
                 </div>
             </div>
             <div class="menu-list">
@@ -99,18 +91,22 @@
             <div class="menu-list">
                 <div class="title">其他</div>
                 <div class="menu-box">
-                    <a href="/weixin/member/signs">
+                    <!--<a href="/weixin/member/signs">
                         <img src="__TMPL__/weixin/public/assets/img/new-sign.png">
                         <span>每日签到</span>
-                    </a>
-                    <a href="/weixin/member/privacy">
+                    </a>-->
+                    <div class="menu" @click.stop="hideMenu">
                         <img src="__TMPL__/weixin/public/assets/img/new-privacy.png">
-                        <span>隐私设置</span>
-                    </a>
-                    <a href="/weixin/member/wechat" class="icon-wechat">
-                        <img src="__TMPL__/weixin/public/assets/img/new-wechat.png">
-                        <span>我的微信</span>
-                    </a>
+                        <span>设置</span>
+                        <div class="sub-menu">
+                            <a href="/weixin/member/privacy">隐私设置</a>
+                            <a href="/weixin/member/wechat" class="icon-wechat">
+                                我的微信
+                            </a>
+                            <a href="/weixin/member/advice">反馈建议</a>
+                            <a href="/weixin/page/about">关于拾光</a>
+                        </div>
+                    </div>
                     <a href="/weixin/page/rule">
                         <img src="__TMPL__/weixin/public/assets/img/new-rule.png">
                         <span>违规处罚</span>
@@ -119,13 +115,9 @@
                         <img src="__TMPL__/weixin/public/assets/img/user_black.png">
                         <span>黑名单用户</span>
                     </a>
-                    <a href="/weixin/member/advice">
-                        <img src="__TMPL__/weixin/public/assets/img/advice.png">
-                        <span>反馈建议</span>
-                    </a>
-                    <a href="/weixin/page/about">
-                        <img src="__TMPL__/weixin/public/assets/img/new-about.png">
-                        <span>关于拾光</span>
+                    <a href="/weixin/page/custom?type=1">
+                        <img src="__TMPL__/weixin/public/assets/img/custom.png">
+                        <span>联系客服</span>
                     </a>
                 </div>
             </div>

+ 29 - 0
public/themes/default/weixin/public/assets/css/member.css

@@ -45,6 +45,16 @@ body {
     font-size: 14px;
     vertical-align: top;
 }
+.menu-list .menu-box .menu {
+    display: inline-block;
+    width: 24%;
+    margin-right: 1%;
+    margin-bottom: 10px;
+    text-align: center;
+    font-size: 14px;
+    vertical-align: top;
+    position: relative;
+}
 .menu-list .menu-box img {
     display: block;
 }
@@ -65,6 +75,25 @@ body {
     width: 42px;
     max-width: 42px;
 }
+
+.menu-box .sub-menu {
+    display: none;
+    width: 120px;
+    position: absolute;
+    z-index: 2;
+    bottom: 50px;
+    left: 35px;
+    background: #fff;
+    border: 1px solid #999;
+    border-radius: 4px;
+}
+
+.menu-box .sub-menu a {
+    padding: 8px 2px;
+    color: #f1c21f;
+    width: auto;
+    margin: 0;
+}
 /* 菜单样式 end */
 
 .zhobu_box{width: 100%;height:86px;overflow: hidden;background: #fff;margin-top: -2px;}

+ 9 - 0
public/themes/default/weixin/public/assets/js/member.js

@@ -9,7 +9,16 @@ var app = new Vue({
     created: function () {
         this.getInfo();
     },
+    mounted(){
+        $(".menu").click(function(){
+            console.log($(this).find('.sub-menu').html())
+            $(this).find('.sub-menu').show();
+        })
+    },
     methods: {
+        hideMenu: function(){
+            $('.sub-menu').hide();
+        },
         // 获取用户信息
         getInfo: function () {
             var _this = this;

+ 6 - 0
vendor/thinkcmf/cmf-app/src/admin/controller/MarketController.php

@@ -252,6 +252,7 @@ class MarketController extends AdminBaseController
      //分销员审核
      public function marketexamine(){
         $data = $this->request->param();
+        $data['type'] = isset($data['type'])? $data['type'] : 0;
         session('search',[
             'uid' => isset($data['uid'])? intval($data['uid']) : 0,
             'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
@@ -387,6 +388,10 @@ class MarketController extends AdminBaseController
                     $query->where('u.sex',input('sex'));
                 }
 
+                $type = isset($data['type'])? $data['type'] : 0;
+                if($type>=0){
+                    $query->where('u.shop_type', $type);
+                }
 
             })
 
@@ -396,6 +401,7 @@ class MarketController extends AdminBaseController
       //echo Db::name('user')->getLastSql();die;
         // 获取分页显示
         $page = $list->render();
+        $this->assign('params', $data);
         $this->assign('list', $list);
         $this->assign('page', $page);