浏览代码

新的礼物逻辑

lizhen_gitee 9 月之前
父节点
当前提交
06ceb38aba
共有 2 个文件被更改,包括 10 次插入161 次删除
  1. 8 159
      application/api/controller/Gift.php
  2. 2 2
      public/assets/css/skins/skin-green-light.css

+ 8 - 159
application/api/controller/Gift.php

@@ -26,7 +26,7 @@ class Gift extends Api
     /**
      * 获取礼物类型
      */
-    public function getGiftType() {
+    public function getgifttype() {
         // 获取基本信息
         $where = [];
         $where["is_show"] = 1;
@@ -81,10 +81,6 @@ class Gift extends Api
                 $this->error("您的金币余额不足");
             }
 
-
-
-
-
             // 添加礼物赠送记录表
             $data = [
                 'user_id' => $this->auth->id,
@@ -101,7 +97,6 @@ class Gift extends Api
                 $this->error('赠送失败');
             }
 
-
             if($giftvalue > 0){
 
                 // 扣除当前用户余额
@@ -124,24 +119,6 @@ class Gift extends Api
                     $this->error($wallet_rs['msg']);
                 }
 
-               /* //增加赠送用户上级金币
-                if ($touserinfo['intro_uid']) {
-                    //获取返利比率
-                    $intro_gift_rebate_rate = (int)config('site.intro_gift_rebate_rate'); //邀请人收礼物返利比率
-                    if ($intro_gift_rebate_rate > 0 && $intro_gift_rebate_rate <= 100) {
-                        //上级获得金币数量
-                        $intro_uid_gold = floor($giftvalue * $intro_gift_rebate_rate / 100);
-                        if ($intro_uid_gold > 0) {
-                            $intro_result = model('Wallet')->lockChangeAccountRemain($touserinfo['intro_uid'],$user_id,'gold',$intro_uid_gold,66, '聊天礼物获赠奖励','gift_user_typing',$log_id);
-                            if($intro_result['status']===false)
-                            {
-                                Db::rollback();
-                                $this->error($intro_result['msg']);
-                            }
-                        }
-                    }
-                }*/
-
                 //增加赠送用户上级余额
                 if ($touserinfo['intro_uid']) {
                     //获取返利比率
@@ -172,14 +149,6 @@ class Gift extends Api
             }
         }
 
-        //tag任务赠送金币
-        //搭讪奖励
-//        $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,15);
-//        if($task_rs === false){
-//            Db::rollback();
-//            $this->error('完成任务赠送奖励失败');
-//        }
-
         Db::commit();
 
         //发送消息
@@ -194,137 +163,17 @@ class Gift extends Api
         $this->success('赠送成功', $return_data);
     }
 
-    //打招呼送礼物
-    public function givechatgift() {
-        exit; //作废
-        // 接口防并发
-        if (!$this->apiLimit(1, 1)) {
-            $this->error(__('Operation frequently'));
-        }
-
-        $user_id = input('user_id');// 赠送对象
-        if (!$user_id) {
-            $this->error();
-        }
-        // 不可以赠送给自己
-        if($this->auth->id == $user_id) {
-            $this->error("不可以赠送给自己");
-        }
-        //查询是否打过招呼
-        $count = Db::name('gift_user_greet')->where(['user_id' => $this->auth->id, 'user_to_id' => $user_id])->count('id');
-        if ($count) {
-            $this->error('已经打过招呼了');
-        }
-        // 获取礼物信息
-        $giftinfo = Db::name('gift_greet')->find();
-        if (!$giftinfo) {
-            $this->error('打招呼礼物异常,请联系管理员');
-        }
-        $giftvalue = $giftinfo['value'];
-
-        //被赠送人信息
-        $touserinfo = Db::name('user')->where('id',$user_id)->find();
-        if (!$touserinfo) {
-            $this->error("不存在的用户");
-        }
-        // 判断当前用户余额
-        $user_gold = model('wallet')->getWallet($this->auth->id,'gold');
-        if($user_gold < $giftvalue) {
-            $this->error("您的金币余额不足");
-        }
-
-        Db::startTrans();
-        // 添加礼物赠送记录表
-        $data = [
-            'user_id' => $this->auth->id,
-            'user_to_id' => $user_id,
-            'gift_id' => $giftinfo['id'],
-            'gift_name' => $giftinfo['name'],
-            'number' => 1,
-            'price' => $giftvalue,
-            'createtime' => time(),
-        ];
-        $log_id = Db::name('gift_user_greet')->insertGetId($data);
-        if(!$log_id){
-            Db::rollback();
-            $this->error('赠送失败');
-        }
-
-        if($giftvalue > 0){
-            // 扣除当前用户余额
-            $wallet_rs = model('wallet')->lockChangeAccountRemain($this->auth->id,$user_id,'gold',-$giftvalue,57,'赠送礼物:'.$giftinfo["name"],'gift_user_greet',$log_id);
-            if($wallet_rs['status'] === false){
-                Db::rollback();
-                $this->error($wallet_rs['msg']);
-            }
-
-            // 添加赠送用户余额
-            $money_to_gold = config('site.money_to_gold');
-            $gift_plat_scale = config('site.gift_plat_scale');
-
-            $giftmoney = bcdiv($giftvalue,$money_to_gold,2);
-
-            $money = bcdiv(bcmul($giftmoney,100 - $gift_plat_scale,2),100,2);
-            $wallet_rs = model('wallet')->lockChangeAccountRemain($user_id,$this->auth->id,'money',$money,58,'获得礼物:'.$giftinfo["name"],'gift_user_greet',$log_id,2);
-            if($wallet_rs['status'] === false){
-                Db::rollback();
-                $this->error($wallet_rs['msg']);
-            }
-
-            /*//增加赠送用户上级金币
-            if ($touserinfo['intro_uid']) {
-                //获取返利比率
-                $intro_gift_rebate_rate = (int)config('site.intro_gift_rebate_rate'); //邀请人收礼物返利比率
-                if ($intro_gift_rebate_rate > 0 && $intro_gift_rebate_rate <= 100) {
-                    //上级获得金币数量
-                    $intro_uid_gold = floor($giftvalue * $intro_gift_rebate_rate / 100);
-                    if ($intro_uid_gold > 0) {
-                        $intro_result = model('Wallet')->lockChangeAccountRemain($touserinfo['intro_uid'],$user_id,'gold',$intro_uid_gold,66, '打招呼礼物获赠奖励','gift_user_greet',$log_id);
-                        if($intro_result['status']===false)
-                        {
-                            Db::rollback();
-                            $this->error($intro_result['msg']);
-                        }
-                    }
-                }
-            }*/
-
-            if ($this->auth->gender == 1 && $touserinfo['gender'] == 0) {
-                //增加亲密度
-                $user_intimacy_rs = addintimacy($this->auth->id, $user_id, $giftvalue);
-                if (!$user_intimacy_rs['status']) {
-                    Db::rollback();
-                    $this->error('您的网络开小差啦~');
-                }
-            }
-        }
-
-        //tag任务赠送金币
-        //搭讪奖励
-        $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,24);
-        if($task_rs === false){
-            Db::rollback();
-            $this->error('完成任务赠送奖励失败');
-        }
-
-        Db::commit();
-
-        //发送消息
-        if (isset($user_intimacy_rs) && $user_intimacy_rs['level_remark']) {
-            $tenim = new \app\api\controller\Tenim;
-            $tenim->sendMessageToUser($this->auth->id, $user_id, $user_intimacy_rs['level_remark'], 1);
-        }
-
-        $return_data['money'] = $money; //获得金额
-        $return_data['level_remark'] = isset($user_intimacy_rs) ? $user_intimacy_rs['level_remark'] : ''; //亲密度等级提示语
-        $return_data['special'] = one_domain_image($giftinfo['special']);
-        $this->success('赠送成功', $return_data);
-    }
 
     //礼物列表
     public function giftlist() {
+        $type = input('type',0);
+
         $where['status'] = 1;
-        $giftList = Db::name('gift')->field('id, name, value, image, special,md5_str')->where($where)->order("sort, value")->select();
+        if($type){
+            $where['type'] = $type;
+        }
+
+        $giftList = Db::name('gift')->field('id, name, value, image, special, wallettype')->where($where)->order("sort, value")->select();
         $giftList = list_domain_image($giftList,['image','special']);
         $this->success("获取成功!",$giftList);
     }

+ 2 - 2
public/assets/css/skins/skin-green-light.css

@@ -35,7 +35,7 @@
   color: #fff;
 }
 .skin-green-light .main-header .navbar .sidebar-toggle:hover {
-  background-color: #15a589;
+  background-color: #F93098;
 }
 @media (max-width: 767px) {
   .skin-green-light .main-header .navbar .dropdown-menu li.divider {
@@ -54,7 +54,7 @@
   border-bottom: 0 solid transparent;
 }
 .skin-green-light .main-header .logo:hover {
-  background-color: #17b798;
+  background-color: #F93098;
 }
 .skin-green-light .main-header li.user-header {
   background-color: #F93098;