songdb 6 年之前
父节点
当前提交
b104b75e3a

+ 16 - 0
app/Http/Controllers/Wap/User/UserController.php

@@ -13,6 +13,7 @@ use Illuminate\Http\Request;
 use App\Http\Controllers\Wap\BaseController;
 use App\Modules\Subscribe\Services\YearOrderService;
 use App\Modules\User\Services\UserService;
+use App\Modules\User\Services\UserRandSignService;
 use App\Modules\User\Services\UserSignService;
 use App\Http\Controllers\Wap\User\Transformers\SignRecordTransformer;
 use Log;
@@ -412,6 +413,21 @@ class UserController extends BaseController
     	return response('add_cookie:'.$uid);
     }
 
+    //日常随机签到
+    function day_rand_sign(Request $request)
+    {
+        $uid = $this->uid;
+        $day = date('Y-m-d');
+        $hasSigned = UserRandSignService::hasSigned(compact('uid','day'));
+        $fee = 0;
+        if(!$hasSigned)
+        {
+            $fee = mt_rand(5,15);
+            UserRandSignService::sign(compact('uid','day','fee'));
+        }
+        return view('wap.rand_sign',compact('hasSigned','fee'));
+    }
+
     private function bindTelephoneStatus(){
 
     }

+ 3 - 0
app/Http/Routes/Wap/WapRoutes.php

@@ -267,6 +267,9 @@ Route::group(['domain'=>env('WAP_DOMAIN'),'namespace'=>'App\Http\Controllers\Wap
 
         Route::get('sign','User\UserController@signi');
 
+        //随机每日领5-15书币
+        Route::get('randSign','User\UserController@day_rand_sign');
+
         Route::any('{slug}','Web\WelcomeController@index')->where('slug', '(.*)?');
 
     });

+ 22 - 0
app/Modules/User/Models/UserRandSign.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Modules\User\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class UserRandSign extends Model
+{
+    protected $table = 'user_rand_sign';
+    protected $fillable = ['uid','fee','day'];
+
+
+    static function add($params)
+    {
+        return self::create($params);
+    }
+
+    static function hasSigned($params)
+    {
+        return self::where('uid',$params['uid'])->where('day',$params['day'])->count();
+    }
+}

+ 34 - 0
app/Modules/User/Services/UserRandSignService.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Modules\User\Services;
+
+use Redis;
+use App\Modules\User\Models\UserRandSign;
+
+class UserRandSignService
+{
+    protected $table = 'user_sign';
+    protected $fillable = ['uid', 'price', 'day', 'sign_time'];
+
+    static function sign($params)
+    {
+        $params = [
+            'uid'=>$params['uid'],
+            'fee'=>$params['fee'],
+            'day'=>$params['day']
+        ];
+        UserRandSign::add($params);
+    }
+
+
+    static function hasSigned($params)
+    {
+        $params = [
+            'uid'=>$params['uid'],
+            'day'=>$params['day']
+        ];
+        return UserRandSign::hasSigned($params);
+    }
+
+
+}

+ 103 - 0
resources/views/wap/rand_sign.blade.php

@@ -0,0 +1,103 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
+    <title>微信阅读小管家福利</title>
+    <style>
+        html,
+        body {
+            margin: 0 auto;
+            padding: 0;
+            height: 100%;
+            max-width: 450px;
+        }
+
+        .main_box {
+            height: inherit;
+            font-size: 0;
+            position: relative;
+        }
+
+        .main_box img {
+            height: inherit;
+            width: 100%;
+        }
+
+        .button {
+            position: absolute;
+            top: 50%;
+            width: 80%;
+            left: 50%;
+            transform: translate(-50%);
+        }
+
+        .floatWindow {
+            background-color: rgba(0, 0, 0, 0.4);
+            width: 100%;
+            height: 100%;
+            position: fixed;
+            top: 0;
+            left: 0;
+        }
+
+        .floatWindow-body {
+            position: absolute;
+            top: 20%;
+            left: 50%;
+            transform: translate(-50%);
+            width: 80%;
+        }
+
+        .floatWindow-body .money {
+            font-size: 22px;
+            font-weight: bold;
+            position: absolute;
+            top: 48%;
+            color: #e54100;
+            left: 28%;
+        }
+
+        .floatWindow-body .floatWindow-button {
+            width: 80%;
+            position: absolute;
+            left: 50%;
+            transform: translate(-50%);
+            top: 70%;
+        }
+    </style>
+</head>
+
+<body>
+<main class="main_box">
+    <img src="//cdn-novel.iycdm.com/wap/sign/main_back.jpg" alt="" />
+    <div class="recharge_box_one">
+        <a href="#" class="button">
+            <img src="//cdn-novel.iycdm.com/wap/sign/main_button.png" alt="" />
+        </a>
+    </div>
+    @if($fee >0)
+        <div class="floatWindow" id="floatWindow">
+            <div class="floatWindow-body">
+                <img src="//cdn-novel.iycdm.com/wap/sign/pop_back.png" alt="" />
+                <div class="money">{{ $fee }}书币</div>
+                <img
+                        src="//cdn-novel.iycdm.com/wap/sign/pop_button.png"
+                        id="floatWindow-button"
+                        class="floatWindow-button"
+                        onclick="close()"
+                />
+            </div>
+        </div>
+    @endif
+</main>
+</body>
+<script>
+    document
+        .getElementById("floatWindow-button")
+        .addEventListener("click", function() {
+            document.getElementById("floatWindow").style.display = "none";
+        });
+</script>
+</html>