zhangxiaobin 1 anno fa
parent
commit
4ee7a3f09f

+ 39 - 0
application/api/controller/Guild.php

@@ -639,5 +639,44 @@ class Guild extends Api
         }
     }
 
+    /**
+     * 家族贡献榜排行
+     * @return void
+     */
+    public function getRankList()
+    {
+        try {
+            $id = $this->request->param('guild_id',0);
+            $guildMemberWhere['guild_id'] = $id;
+            $guildMemberWhere['status'] = 1;
+            $guildMember = model('GuildMember')->field('id,user_id')->where($guildMemberWhere)->select();
+            $list = [];
+            if (!empty($guildMember)) {
+                $userIds = array_column($guildMember,'user_id');
+                $where = [];
+                $where['a.user_to_id'] = ['in', $userIds];
+                $list = model('GiftUserParty')->alias("a")
+                    ->field('sum(a.value) as total_price,a.user_id,u.avatar,u.nickname')
+                    ->where($where)
+                    ->join('hx_user u','u.id = a.user_id')
+                    ->group('a.user_to_id')
+                    ->order('total_price',"desc")
+                    ->limit(100)
+                    ->select();
+                if (!empty($list)) {
+                    foreach ($list as $key => &$value) {
+                        $value['total_price_text'] = $value['total_price'];
+                        if ($value['total_price'] >= 10000) {
+                            $value['total_price_text'] = bcdiv($value['total_price'],10000,1).'w';
+                        }
+                        unset($value['total_price']);
+                    }
+                }
+            }
 
+            $this->success(__('Operation completed'),$list);
+        } catch (Exception $e) {
+            $this->error($e->getMessage());
+        }
+    }
 }

+ 7 - 7
application/api/controller/Party.php

@@ -1606,7 +1606,7 @@ class Party extends Common
             }
             // 事务处理余额与记录信息
             $userjewellogModel = new \app\common\model\UserJewelLog();
-            $usersoundcoinlogModel = new \app\common\model\UserSoundcoinLog();
+            //$usersoundcoinlogModel = new \app\common\model\UserSoundcoinLog();
 
             // 获取当天零点
             $day = date("Ymd");
@@ -1677,15 +1677,15 @@ class Party extends Common
                 $res5 = $giftuserpartyModel->allowField(true)->save($data);
 
                 // 添加赠送用户声币余额
-                $where = [];
+               /* $where = [];
                 $where["id"] = $user_id;
                 $res3 = $userModel->where($where)->setInc("sound_coin", $getValue);
-                $getValue == 0 && $res3 = true;
+                $getValue == 0 && $res3 = true;*/
                 // 添加赠送用户声币流水记录soundCoin
                 // xxx送你
-                $res4 = $usersoundcoinlogModel->addUserSoundcoinLog($user_id, $getValue, "+", $touserInfo["sound_coin"], "{$this->auth->nickname}送你{$giftInfo['name']}x{$number}", 1, $giftuserpartyModel->id);
+                //$res4 = $usersoundcoinlogModel->addUserSoundcoinLog($user_id, $getValue, "+", $touserInfo["sound_coin"], "{$this->auth->nickname}送你{$giftInfo['name']}x{$number}", 1, $giftuserpartyModel->id);
 
-                if ($partyInfo && $guilderValue > 0) {
+                /*if ($partyInfo && $guilderValue > 0) {
                     // 增加房主抽成
                     $where = [];
                     $where["id"] = $partyInfo->user_id;
@@ -1693,9 +1693,9 @@ class Party extends Common
                     // 添加赠送用户声币流水记录soundCoin
                     // xxx送礼物给xxx,房间礼物抽成
                     $usersoundcoinlogModel->addUserSoundcoinLog($partyInfo->user_id, $guilderValue, "+", $touserInfo["sound_coin"], "{$this->auth->nickname}送礼物{$giftInfo['name']}x{$number}给{$touserInfo['nickname']},房间礼物抽成", 4, $giftuserpartyModel->id);
-                }
+                }*/
 
-                if ($res1 && $res2 && $res3 && $res4 && $res5) {
+                if ($res1 && $res2 && $res5) {
                     $i++;
                     if($party_id > 0) {
                         // 添加redis记录做财富排行榜日榜用

+ 23 - 0
application/api/controller/User.php

@@ -763,4 +763,27 @@ class User extends Api
             $this->error($this->auth->getError());
         }
     }
+
+    //获取openid
+    public function getopenid() {
+        //code
+        $code = $this->request->post('code', '', 'trim');// code值
+        if (!$code) {
+            $this->error(__('Invalid parameters'));
+        }
+
+        $config = config('wxMiniProgram');
+        $getopenid_url = 'https://api.weixin.qq.com/sns/jscode2session?appid='.$config['appid'].'&secret='.$config['secret'].'&js_code='.$code.'&grant_type=authorization_code';
+
+        $openidInfo = httpRequest($getopenid_url, 'GET');//$this->getJson($getopenid_url);
+        $openidInfo = json_decode($openidInfo,true);
+
+        if(!isset($openidInfo['openid'])) {
+            $this->error('用户openid获取失败', $openidInfo);
+        }
+        $user = Db::name('user')->where('mini_openid',$openidInfo['openid'])->find();
+        //$openidInfo['mobile'] = isset($user['mobile']) ? $user['mobile'] : '';
+
+        $this->success('获取成功', $openidInfo);
+    }
 }

+ 4 - 6
application/config.php

@@ -336,12 +336,10 @@ return [
 //        'secret'      => 'b7077da7c1de5d2ce0e652bb5fae630e',
 //    ],
 // 客户音聊
-    // 'wxMiniProgram'        => [
-    //     //
-    //     'appid'     => 'wx5d584795df007aaa',
-    //     //
-    //     'secret'      => '318db32d3d127aebdab712ce0b333893',
-    // ],
+     'wxMiniProgram' => [
+         'appid'  => 'wx5d584795df007aaa',
+         'secret' => '318db32d3d127aebdab712ce0b333893',
+     ],
     'imgurl' => ["image","icon_image","avatar","back_image","skill_icon","file_image","gif_image","party_logo","special","gift_gif","gift_image","music","android_image"],
 
     'tcp' => "tcp://1.14.197.70:2962",