xiaosongshu007 il y a 5 ans
Parent
commit
5d163411fe

+ 13 - 13
Application/Admin/Controller/MengbaoController.class.php

@@ -47,7 +47,7 @@ class MengbaoController extends CommonController {
         if (isset($keyword) && !empty($keyword)) {
             $this->assign('keyword', $keyword);
         }
-        
+
 //        var_dump(I('post.'));die;
         $page = I('p') ? I('p') : 1;
         $this->assign('p', $page);
@@ -67,7 +67,7 @@ class MengbaoController extends CommonController {
         $this->display('Index');
     }
 
-        /**
+    /**
      * [ExcelExport excel文件导出]
      * @author   Devil
      * @blog     http://gong.gg/
@@ -76,17 +76,17 @@ class MengbaoController extends CommonController {
      */
     public function ExcelExport()
     {
-		$where = array();
+        $where = array();
         $data = M('activity_mengbao')->where($where)->order('score desc , id asc')->select();
 
-		$title = array(
-			'id'						 =>	array('col' => 'A', 'name' => 'ID'),
-			'name'						 =>	array('col' => 'B', 'name' => '名字'),
-			'uid'						 =>	array('col' => 'C', 'name' => 'uid'),
-			'phone'					     =>	array('col' => 'D', 'name' => '联系人手机号'),
-			'score'					     =>	array('col' => 'E', 'name' => '得票数'),
+        $title = array(
+            'id'						 =>	array('col' => 'A', 'name' => 'ID'),
+            'name'						 =>	array('col' => 'B', 'name' => '名字'),
+            'uid'						 =>	array('col' => 'C', 'name' => 'uid'),
+            'phone'					     =>	array('col' => 'D', 'name' => '联系人手机号'),
+            'score'					     =>	array('col' => 'E', 'name' => '得票数'),
             'is_show'                    => array('col' => 'F', 'name' => '在线状态(1在线,0下线)')
-		);
+        );
         // Excel驱动导出数据
         $excel = new \My\Excel(array('filename' => '萌宝排行榜', 'title' => $title, 'data' => $data, 'msg' => L('common_not_data_tips')));
         $excel->Export();
@@ -115,7 +115,7 @@ class MengbaoController extends CommonController {
         //素材列表
         if (I('id')) {
             $sourceList = M('activity_mengbao')->where(['id' => array('neq', I('id'))])->field('id as source_id,name as source_name')->select();
-        } 
+        }
         $this->assign('sourceList', $sourceList);
 
         $this->assign('data', $data);
@@ -254,7 +254,7 @@ class MengbaoController extends CommonController {
             "name"          => array('name' => 'name'),
             "age"           => array('name' => 'age'),
             "desc"          => array('name' => 'desc'),
-            'score'         => array('namr' => 'score'),
+            'score'         => array('name' => 'score'),
             "image"         => array('name' => 'image'),
             "video"         => array('name' => 'video'),
             "media_id"      => array('name' => 'media_id'),
@@ -312,7 +312,7 @@ class MengbaoController extends CommonController {
         }
         $msg = '导入完成';
         goto end;
-        
+
         end:
         $responsedata = array("msg" => $msg, "res" => 1, 'data' => []);
         echo json_encode($responsedata,JSON_UNESCAPED_UNICODE);

+ 15 - 12
Application/Home/Logic/Activityv2/MengbaoLogic.class.php

@@ -137,31 +137,32 @@ class MengbaoLogic extends BaseLogic
         if(($remain_chance = $remain_vote_chance - $score) < 0){
             $this->responseError('您没有足够的投票次数,投票失败');
         }
-
         //更新萌宝获得总票数
         M('activity_mengbao')->where(['id'=>$mengbao_id])->setInc('score',$score);
-
-        if($this->vip_level==2){
+        if($this->vip_level == 2){
             //已投票数
             $vip_vote = M('activity_vip_vote')->where(['uid'=>$this->uid,'act_id'=>$this->act_id])->field('id,num')->find();
-            $alrady_vip_vote = $vip_vote['num'] ? : 0;
+            $already_vip_vote = $vip_vote['num'] ? : 0;
             //剩余数
-            $remain_vip_vote = 200 - $alrady_vip_vote;
-
-            $diff = $remain_vip_vote - $score;
+            $remain_vip_vote = 200 - $already_vip_vote;
 
-            if($diff >= 0){
-                M('activity_vip_vote')->where(['id'=>$vip_vote['id']])->setInc('num',$diff);
+            $compare = $remain_vip_vote - $score;
+            if($compare >= 0){
+                M('activity_vip_vote')->where(['id'=>$vip_vote['id']])->setInc('num',$score);
+                $this->responseSuccess(['num'=>$remain_chance],'投票成功,去参与抽奖吧');
             }else{
                 M('activity_vip_vote')->where(['id'=>$vip_vote['id']])->save(['num'=>200]);
+                $x = abs($compare);
             }
+        }else{
+            $x = $remain_chance;
         }
 
         //插入
         $insert_data = [
             'act_id'=>$this->act_id,
             'uid'   =>$this->uid,
-            'num'   =>$score,
+            'num'   =>$x,
             'mengbao_id'=>$mengbao_id,
             'created_at'=>date('Y-m-d H:i:s'),   
             'date'  =>date('Ymd')
@@ -171,6 +172,10 @@ class MengbaoLogic extends BaseLogic
         $this->responseSuccess(['num'=>$remain_chance],'投票成功,去参与抽奖吧');
     }
 
+    public function _vip(){
+
+    }
+
     /**ascii码从小到大排序
      * @param array $params
      * @return bool|string
@@ -277,7 +282,6 @@ class MengbaoLogic extends BaseLogic
             }
             $add = 200 - $num;
         }
-
         $vote += $add;
 
         //查看当前已投票次数
@@ -287,7 +291,6 @@ class MengbaoLogic extends BaseLogic
         if($vote <= $alreay_num){
             return 0;
         }
-
         return $vote > $alreay_num ? $vote - $alreay_num : 0;
     }