Example #1
0
 /**
  * 完成抽奖动作,返回抽奖结果
  * @return array 抽奖结果
  */
 public function loterry()
 {
     $tmpArr = array();
     $db = new DbConn();
     foreach ($this->prizeArr as $k => $v) {
         $tmpArr[$v['id']] = $v['v'];
     }
     do {
         $prizeId = $this->getPrizeId($tmpArr);
         // 奖项id
         $nums = $db->countByPid($prizeId);
         // 查询已获取当前奖项的人数
     } while ($nums >= $this->prizeArr[$prizeId - 1]['num']);
     //$prizeId = $this->getPrizeId($tmpArr); // 奖项id
     //$angle = $this->getRotation($this->prizeArr[$prizeId-1]); // 旋转角度
     // 插入数据库,记录用户中奖情况
     $db->add($this->uid, $prizeId, $this->prizeArr[$prizeId - 1]['prize'], time());
     return array('prize' => $prizeId);
 }