Browse Source

删除无用的方法

lizhen_gitee 1 year ago
parent
commit
f6179f487d
1 changed files with 1 additions and 139 deletions
  1. 1 139
      application/api/controller/Gift.php

+ 1 - 139
application/api/controller/Gift.php

@@ -20,144 +20,6 @@ class Gift extends Api
         $this->gifttypeModel = new \app\common\model\GiftType();
         $this->gifttypeModel = new \app\common\model\GiftType();
     }
     }
 
 
-    //仅用来测试
-    public function test2(){
-        $user_id = $this->auth->id;
-        $gift_id = input('gift_id');
-        $pay_total = input('pay_total');
-
-        Db::startTrans();
-        $rs = $this->baobi($user_id,$gift_id,$pay_total);
-        if($rs !== true){
-            Db::rollback();
-        }
-        Db::commit();
-        dump($rs);
-    }
-
-    //gift_id必须是爆币礼物才可以
-    //仅用来测试
-    public function baobi($user_id,$gift_id,$pay_total){
-
-        //奖项参数
-        $conf_arr = Db::name('gift_baobi_config')->where('gift_id',$gift_id)->select();
-        if(empty($conf_arr)){
-            return true;
-        }
-
-        //用户今天的爆币情况,与消费情况,不用区分具体哪个爆币礼物
-        $today_start = strtotime(date('Y-m-d'));
-        $today_end   = $today_start + 86399;
-        $map = [
-            'user_id' => $user_id,
-            'createtime' => ['BETWEEN',[$today_start,$today_end]],
-        ];
-        $today_data = Db::name('gift_baobi_log')->field('IFNULL(sum(pay_total),0) as today_pay_total,IFNULL(sum(baobi_total),0) as today_baobi_total')->where($map)->find();
-        //dump($today_data);
-        if($today_data['today_baobi_total'] >= $today_data['today_pay_total']){
-            //爆币比消费还高了,不用抽奖了,记录个日志,返回。这里的日志仅用来记录今日消费 sum(pay_total)
-            $data = [];
-            $data['user_id']   = $user_id;
-            $data['gift_id'] = $gift_id;
-            $data['baobi_id'] = 0;
-            $data['beilv'] = 0;
-            $data['rate'] = 0;
-            $data['pay_total'] = $pay_total;
-            $data['baobi_total'] = 0;
-            $data['createtime'] = time();
-
-            $log_id = Db::name('gift_baobi_log')->insertGetId($data);
-            if(!$log_id){
-                return false;
-            }
-
-            return true;
-        }
-
-
-        //概率新数组
-        $gailv = [];
-        $bei = 100; //小数变整数
-        foreach ($conf_arr as $key=>$value)
-        {
-            $gailv[$value['id']] = $value['rate']*$bei;
-        }
-        //dump($gailv);
-
-        //奖项新数组
-        $conf_column = [];
-        foreach ($conf_arr as $key=>$value)
-        {
-            $conf_column[$value['id']] = $value;
-        }
-        //dump($conf_column);
-
-        //抽
-        $rid = $this->getRand($gailv); //根据概率获取奖项id
-        //dump($rid);
-
-        //返回中奖结果
-        $result = $conf_column[$rid];
-
-        //爆币金额
-        $baobi_total = bcmul($pay_total,$result['beilv'],0);
-
-        //写入爆币记录,不论有没有钱。全都写入其实是为了方便查日志,比在money_log里找范围更小,而且可删除
-        $data = [];
-        $data['user_id']   = $user_id;
-        $data['gift_id'] = $gift_id;
-        $data['baobi_id'] = $result['id'];
-        $data['beilv'] = $result['beilv'];
-        $data['rate'] = $result['rate'];
-        $data['pay_total'] = $pay_total;
-        $data['baobi_total'] = $baobi_total;
-        $data['createtime'] = time();
-
-        $log_id = Db::name('gift_baobi_log')->insertGetId($data);
-        if(!$log_id){
-            return false;
-        }
-
-        //直接给用户钱
-        if($baobi_total > 0){
-            $rs_wallet = model('wallet')->lockChangeAccountRemain($user_id,$baobi_total,'+',0,'送礼物爆币'.$result['beilv'].'倍',21,'jewel');
-            if($rs_wallet['status'] === false){
-                return false;
-            }
-
-            //返回爆币金额
-            return [
-                'baobi_total' => $baobi_total,
-                'baobi_beilv' => $result['beilv'],
-            ];
-        }
-
-        //默认成功
-        return true;
-    }
-
-    //概率获得算法
-    private function getRand($proArr) {
-        //概率数组的总概率精度
-        $proSum = array_sum($proArr);
-
-        $key = rand(1, $proSum);
-//        echo $key;
-        $result = 0;
-        $now = 0;
-        foreach ($proArr as $k=>$v)
-        {
-            $now = $now + $v;
-            if($key<=$now)
-            {
-                $result = $k;
-                break;
-            }
-        }
-        unset ($proArr);
-        return $result;
-    }
-
     /**
     /**
      * 获取礼物列表
      * 获取礼物列表
      */
      */
@@ -170,7 +32,7 @@ class Gift extends Api
             $where['type'] = $type;
             $where['type'] = $type;
         }
         }
 
 
-        $giftList = Db::name('gift')->field('id,name,price,image,special')->where($where)->order("sort","asc")->select();
+        $giftList = Db::name('gift')->field('id,name,price,image,special,is_baobi')->where($where)->order("sort","asc")->select();
         $giftList = list_domain_image($giftList,['image','special']);
         $giftList = list_domain_image($giftList,['image','special']);
         $this->success("获取成功!",$giftList);
         $this->success("获取成功!",$giftList);
     }
     }