allen 3 năm trước cách đây
mục cha
commit
1a02f33840

+ 15 - 12
app/admin/controller/Award.php

@@ -36,11 +36,15 @@ class Award extends Controller
      */
     public function index()
     {
-        $lists = Db::query("select l.id, l.uid, u.nickname, o.name, o.mobile, o.address, g.name as giftName, FROM_UNIXTIME(o.create_at) as createAt, l.duration, l.number from awards_user_task_log as l 
-    left join awards_user_info as u on l.uid = u.uid 
-    left join awards_order as o on o.uid = l.uid 
-    left join awards_gift as g on o.gift_id = g.id
-where u.portrait != '' and u.portrait is not null  and l.number >= 15 group by l.uid order by l.id desc limit 100");
+//        $lists = Db::query("select l.id, l.uid, u.nickname, o.name, o.mobile, o.address, g.name as giftName, FROM_UNIXTIME(o.create_at) as createAt, l.duration, l.number from awards_user_task_log as l
+//    left join awards_user_info as u on l.uid = u.uid
+//    left join awards_order as o on o.uid = l.uid
+//    left join awards_gift as g on o.gift_id = g.id
+//where u.portrait != '' and u.portrait is not null  and l.number >= 15 group by l.uid order by l.id desc limit 100");
+
+        $lists = Db::query("select u.uid,u.nickname, o.name, o.mobile, o.address, g.name as giftName, o.rank as giftName from awards_order as o 
+    left join awards_user_info as u on o.uid = u.uid 
+    left join awards_gift as g on o.gift_id = g.id where o.type = 2 order by rank asc");
         $this->assign('lists', $lists);
         $this->fetch();
     }
@@ -55,11 +59,10 @@ where u.portrait != '' and u.portrait is not null  and l.number >= 15 group by l
      */
     public function award()
     {
-        $data = Db::query("select l.id, l.uid, u.nickname, o.name, o.mobile, o.address, g.name as giftName, FROM_UNIXTIME(o.create_at) as createAt, l.duration, l.number from awards_user_task_log as l 
-    left join awards_user_info as u on l.uid = u.uid 
-    left join awards_order as o on o.uid = l.uid 
-    left join awards_gift as g on o.gift_id = g.id
-where u.portrait != '' and u.portrait is not null and l.number >= 15 group by l.uid order by l.id desc limit 100");
+
+        $data = Db::query("select u.uid, u.nickname, o.name, o.mobile, o.address, g.name as giftName, o.rank as giftName from awards_order as o 
+    left join awards_user_info as u on o.uid = u.uid 
+    left join awards_gift as g on o.gift_id = g.id where o.type = 2 order by rank asc");
 
         //实例化
         $objExcel = new \PHPExcel();
@@ -68,7 +71,7 @@ where u.portrait != '' and u.portrait is not null and l.number >= 15 group by l.
         //设置内容
         $objActSheet = $objExcel->getActiveSheet();
         $letter = explode(',', "A,B,C,D,E,F,G");
-        $arrHeader = ['微博UID', '微博昵称', '收件人姓名', '联系人电话', '收件地址', '奖品名称','中奖时间'];
+        $arrHeader = ['微博UID', '微博昵称', '收件人姓名', '联系人电话', '收件地址', '奖品名称','排名'];
         //填充表头信息
         $lenth = count($arrHeader);
         for ($i = 0; $i < $lenth; $i++) {
@@ -84,7 +87,7 @@ where u.portrait != '' and u.portrait is not null and l.number >= 15 group by l.
             $objActSheet->setCellValue('D' . $k, $v['mobile']." ");
             $objActSheet->setCellValue('E' . $k, $v['address']);
             $objActSheet->setCellValue('F' . $k, $v['giftName']);
-            $objActSheet->setCellValue('G' . $k, $v['createAt']);
+            $objActSheet->setCellValue('G' . $k, $v['rank']);
         }
 
         $outfile = "排行榜前50名" . date('Ymd') . ".xlsx";

+ 2 - 2
app/admin/view/award/index.html

@@ -47,7 +47,7 @@
                         </th>
                         <th data-field="createAt" data-key="2-0-8" class="">
                             <div class="layui-table-cell laytable-cell-2-0-8">
-                                <span>中奖时间</span>
+                                <span>排名</span>
                             </div>
                         </th>
                     </tr>
@@ -81,7 +81,7 @@
                             <div class="layui-table-cell laytable-cell-2-0-7">{$val['giftName']}</div>
                         </td>
                         <td data-field="createAt" data-key="2-0-8" class="">
-                            <div class="layui-table-cell laytable-cell-2-0-8">{$val['createAt']}</div>
+                            <div class="layui-table-cell laytable-cell-2-0-8">{$val['rank']}</div>
                         </td>
                     </tr>
                     {/foreach}

+ 8 - 4
app/index/controller/Index.php

@@ -456,18 +456,22 @@ class Index extends Controller
 
     public function rankingDrawList()
     {
-//        $activity = Db::table('awards_activity')->where('end_at', '<', time())->find();
-        $isBeginActivity = 1;
+//        $activity = Db::table('awards_activity')->where('end_at', '>', time())->find();
+//        $isBeginActivity = 1;
 //        if ($activity) {
-//            $isBeginActivity = 0;
+            $isBeginActivity = 0;
 //        }
 
-        $orders = [];
+//        $orders = [];
 //        if ($isBeginActivity == 0) {
 //            $orders = Db::query("select u.nickname, u.portrait, l.uid, l.duration, l.number from awards_user_task_log as l left join awards_user_info as u on l.uid = u.uid
 //where u.portrait != '' and u.portrait is not null and l.number >= 15 group by l.uid order by l.id desc limit 50");
 //        }
 
+        $orders = Db::query("select u.nickname, u.portrait, g.name as giftName from awards_order as o 
+    left join awards_user_info as u on o.uid = u.uid 
+    left join awards_gift as g on o.gift_id = g.id where o.type = 2 order by rank asc");
+
         return $this->successResponse([
             'isBeginActivity' => $isBeginActivity,
             'list' => $orders

+ 63 - 0
updateRank.sql

@@ -0,0 +1,63 @@
+
+
+/**
+  清除排名中奖旧数据
+ */
+DELETE FROM `awards_order` where `type` = 2;
+
+
+/**
+  插入排名中奖数据
+ */
+INSERT INTO `awards_order` (`uid`, `rank`, `gift_id`, `type`)
+VALUES
+(7331841275,1,1,2),
+(7312220225,2,2,2),
+(5482542453,3,2,2),
+(5748693260,4,2,2),
+(5315483631,5,2,2),
+(5997609128,6,2,2),
+(7290034423,7,2,2),
+(7489453887,8,2,2),
+(7415584948,9,2,2),
+(7339328286,10,2,2),
+(7464895722,11,2,2),
+(5658990124,12,2,2),
+(6875044323,13,2,2),
+(7097905055,14,2,2),
+(7415831414,15,2,2),
+(7239588166,16,2,2),
+(5958366188,17,2,2),
+(6010782013,18,2,2),
+(6598247984,19,2,2),
+(7313444351,20,2,2),
+(5633153495,21,2,2),
+(2286803047,22,3,2),
+(7318797027,23,3,2),
+(7356918008,24,3,2),
+(7475149404,25,3,2),
+(7340921714,26,3,2),
+(5744850460,27,3,2),
+(6858477359,28,3,2),
+(7554779923,29,3,2),
+(7488338078,30,3,2),
+(7596786506,31,3,2),
+(7755185060,32,3,2),
+(7757399795,33,3,2),
+(7375001827,34,3,2),
+(7326050091,35,3,2),
+(7670433967,36,3,2),
+(5130640517,37,3,2),
+(5828405802,38,3,2),
+(6834665781,39,3,2),
+(7027494474,40,3,2),
+(7385200551,41,3,2),
+(6475365595,42,3,2),
+(7340925502,43,3,2),
+(7416155809,44,3,2),
+(5969206432,45,3,2),
+(7292625182,46,3,2),
+(7729775165,47,3,2),
+(7514560063,48,3,2),
+(7690280141,49,3,2),
+(7744805791,50,3,2)