allen 3 years ago
parent
commit
3011fd9db8

+ 2 - 0
addDrawCount.sql

@@ -1,3 +1,5 @@
 
 
 ALTER TABLE `awards_user_info` ADD `draw_count` INT(11)  NULL  DEFAULT '0'  COMMENT '抽奖次数' AFTER `count`;
+
+ALTER TABLE `awards_order` CHANGE `mobile` `mobile` VARCHAR(255)  NULL  DEFAULT NULL  COMMENT '手机号';

+ 37 - 0
app/admin/controller/Award.php

@@ -185,4 +185,41 @@ class Award extends Controller
         header("Pragma: no-cache");
         $objWriter->save('php://output');
     }
+
+    public function dataEncode() {
+
+        $orders = $this->app->db->name('Order')->select();
+
+        foreach ($orders as $order) {
+
+            $name = $this->dataEncrypt($order['name']);
+            $mobile = $this->dataEncrypt($order['mobile']);
+            $address = $this->dataEncrypt($order['address']);
+
+            if (strlen($name) > 15) {
+                continue;
+            }
+
+            $this->app->db->name('Order')->where('id', $order['id'])->update([
+                'name' => $name,
+                'mobile' => $mobile,
+                'address' => $address
+            ]);
+        }
+
+        $this->success('加密成功');
+    }
+
+    public function dataEncrypt($str)
+    {
+        $aesKey = "sinaVideo1234";
+        $data = openssl_encrypt($str, 'AES-128-ECB', $aesKey, OPENSSL_RAW_DATA);
+        return base64_encode($data);
+    }
+
+    public function dataDecrypt($str)
+    {
+        $aesKey = "sinaVideo1234";
+        return openssl_decrypt(base64_decode($str), 'AES-128-ECB', $aesKey, OPENSSL_RAW_DATA);
+    }
 }

+ 1 - 1
app/admin/view/activity/index.html

@@ -10,7 +10,7 @@
         </div>
         <div class="layui-form-item">
             <span class="color-green font-w7 label-required-prev">结束时间</span>
-            <span class="color-desc margin-left-5">{:$activity['beginAt']}</span>
+            <span class="color-desc margin-left-5">{:$activity['endAt']}</span>
             <span class="help-block"></span>
         </div>
     </div>

+ 5 - 0
app/admin/view/award/index_search.html

@@ -5,6 +5,7 @@
             <button type="button" onclick="exportAward()" class="layui-btn layui-btn-primary">
                 <i class="layui-icon layui-icon-export"></i> 导 出
             </button>
+            <a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要加密用户信息吗?" data-action="{:url('dataEncode')}">数据加密</a>
         </div>
     </form>
 </fieldset>
@@ -14,4 +15,8 @@
     function exportAward() {
         window.location.href = '/admin/award/award.html';
     }
+
+    function dataEncode() {
+        window.location.href = '/admin/award/dataEncode.html';
+    }
 </script>

+ 5 - 1
app/index/controller/Index.php

@@ -484,10 +484,14 @@ class Index extends Controller
     public function getLuckDraw()
     {
         $userInfo = Db::table('awards_user_info')->where('uid', Safe::$user['uid'])->find();
-        if ($userInfo >= 30) {
+        if ($userInfo['draw_count'] >= 30) {
             return $this->response(5002, '抽奖次数已达上线~');
         }
 
+        Db::table('awards_user_info')->where('uid', Safe::$user['uid'])->update([
+            'draw_count' => $userInfo['draw_count'] + 1
+        ]);
+
         $orders = Db::table('awards_order')->where('uid', Safe::$user['uid'])->where('type', 1)->find();
         $isWinAward = 0;
         if ($orders) {

+ 3 - 0
update.sql

@@ -4,3 +4,6 @@ UPDATE `awards_gift` SET `name` = '电影之夜专属礼包(帆布袋、雨伞
 UPDATE `awards_gift` SET `name` = '电影通兑券' WHERE `id` = '5';
 UPDATE `awards_activity` SET `begin_at` = '1658678400', `end_at` = '1659283199' WHERE `id` = '1';
 
+ALTER TABLE `awards_order` CHANGE `mobile` `mobile` VARCHAR(255)  NULL  DEFAULT NULL  COMMENT '手机号';
+
+