Bläddra i källkod

Merge branch 'develop' of http://git.caihongxingqiu.net/rainbow/community-manage into develop

zhangchangchun 5 år sedan
förälder
incheckning
69d96ca081

+ 1 - 0
.gitignore

@@ -6,3 +6,4 @@ Homestead.yaml
 composer.lock
 /storage/*
 /config/customer.php
+/public/export/*

+ 83 - 0
app/Console/Commands/Downloads.php

@@ -0,0 +1,83 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019/6/11
+ * Time: 13:39
+ */
+
+namespace App\Console\Commands;
+
+use App\Repositories\Post\PostRepository;
+use Illuminate\Console\Command;
+use App\Models\Download;
+use Illuminate\Support\Carbon;
+
+class Downloads extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'download:download';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '处理下载';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct(Download $download, PostRepository $postRepository)
+    {
+        parent::__construct();
+        $this->download = $download;
+        $this->postRepository = $postRepository;
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle()
+    {
+        $this->line("开始检索生成中下载");
+
+        $fileDir = 'export/';
+        $path = public_path($fileDir);
+        if(!file_exists($path)){
+            mkdir($path, 0775);
+        }
+
+        $download = $this->download->where('download_status', 0)->orderBy('id', 'desc')->first();
+        if(!$download) exit;
+
+        if($download->download_type == 'post'){
+            $filePath = $fileDir .$download->username.'内容-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
+        }elseif($download->download_type == 'post_waste'){
+            $filePath = $fileDir .$download->username.'回收站内容-'.Carbon::now()->format('Y-m-d') .'_' .uniqid() .'.csv';
+        }else{
+            exit;
+        }
+        $download->download_status = 1;
+        $download->save();
+
+        try {
+            $this->postRepository->download($filePath, $download->download_type, json_decode($download->params, true));
+            $download->url = $filePath;
+            $download->download_status = 2;
+            $download->save();
+        } catch (\Exception $e) {
+            $download->download_status = 3;
+            $download->url = $e->getMessage();
+            $download->save();
+        }
+    }
+}

+ 8 - 2
app/Console/Kernel.php

@@ -3,6 +3,7 @@
 namespace App\Console;
 
 use App\Console\Commands\Apollo;
+use App\Console\Commands\Downloads;
 use Illuminate\Console\Scheduling\Schedule;
 use Laravel\Lumen\Console\Kernel as ConsoleKernel;
 
@@ -14,7 +15,8 @@ class Kernel extends ConsoleKernel
      * @var array
      */
     protected $commands = [
-        Apollo::class
+        Apollo::class,
+        Downloads::class
     ];
 
     /**
@@ -25,6 +27,10 @@ class Kernel extends ConsoleKernel
      */
     protected function schedule(Schedule $schedule)
     {
-        //
+        $path = storage_path('logs/'.date('Y-m-d').'-schedule.log');
+
+        $schedule->command('download:download')
+            ->everyMinute()
+            ->withoutOverlapping()->appendOutputTo($path);
     }
 }

+ 62 - 4
app/Helper/helper.php

@@ -15,13 +15,71 @@ if ( ! function_exists('config_path'))
     {
         return app()->basePath() . '/config' . ($path ? '/' . $path : $path);
     }
+}
 
-    function subtext($text, $length)
+if (! function_exists('public_path')) {
+    /**
+     * Get the path to the public folder.
+     *
+     * @param  string  $path
+     * @return string
+     */
+    function public_path($path = '')
     {
-        if(mb_strlen($text, 'utf8') > $length) {
-            return mb_substr($text, 0, $length, 'utf8').'...';
-        } else {
+        return app()->basePath() . '/public' . ($path ? '/' . $path : $path);
+    }
+}
+
+function subtext($text, $length)
+{
+    if(mb_strlen($text, 'utf8') > $length) {
+        return mb_substr($text, 0, $length, 'utf8').'...';
+    } else {
         return $text;
     }
 }
+
+
+function http($url, $param, $isCheck = true, $method = 'post')
+{
+    try {
+        $client = new \GuzzleHttp\Client();
+        $response = $client->request($method, $url, $param);
+        $result = json_decode($response->getBody()->getContents(), true);
+        if ($isCheck == true) {
+            if ($result['code'] == 0) {
+                return $result['data'];
+            } else {
+                return [];
+            }
+        } else {
+            return $result;
+        }
+
+    } catch (\Exception $exception) {
+        return [];
+    }
+}
+
+
+function generateSign(array $params, $secret_key)
+{
+    unset($params['sign']);
+    // 将删除参数组中所有等值为FALSE的参数(包括:NULL, 空字符串,0, false)
+    $params = array_filter($params);
+
+    // 按照键名对参数数组进行升序排序
+    ksort($params);
+
+    // 给参数数组追加密钥,键名为 key, 值为签名配置中配置的 secret_key 的值
+    $params['chxq_key'] = $secret_key;
+    \Illuminate\Support\Facades\Log::debug($params);
+    // 生成 URL-encode 之后的请求字符串
+    $str = http_build_query($params);
+    $str = urldecode($str);
+    \Illuminate\Support\Facades\Log::debug($str);
+    //$str = "address=计算机啊手机壳阿看见手机卡&address_type=1&area_id=2&area_name=西安市&city_id=2&city_name=西安市&contact_mobile
+    //=18458881890&contact_name=刘德华&province_id=1&province_name=陕西省&uid=0&zipcode=1000000";
+    // 将请求字符串使用MD5加密后,再转换成大写,并返回
+    return strtoupper(MD5($str));
 }

+ 54 - 0
app/Http/Controllers/Behavior/BehaviorController.php

@@ -0,0 +1,54 @@
+<?php
+namespace App\Http\Controllers\Behavior;
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/10
+ * Time: 上午11:09
+ */
+use App\Http\Controllers\Controller;
+use App\Repositories\BehaviorRepository;
+use App\Transformers\Behavior\BehaviorTransformer;
+use Illuminate\Http\Request;
+use Illuminate\Validation\Rule;
+use League\Fractal\Manager;
+use League\Fractal\Pagination\IlluminatePaginatorAdapter;
+use League\Fractal\Resource\Collection;
+
+class BehaviorController extends Controller
+{
+    public function __construct(BehaviorRepository $behaviorRepository)
+    {
+        $this->behaviorRepository = $behaviorRepository;
+    }
+
+    /**
+     * 行为列表
+     */
+    public function index(Request $request)
+    {
+        $behavior_list = $this->behaviorRepository->index($request->all());
+        if ($behavior_list){
+            return $behavior_list;
+        }else{
+            return '没有找到对应行为列表';
+        }
+        $fractal = new Manager();
+        $resource = new Collection($behavior_list, new BehaviorTransformer());
+        $resource->setPaginator(new IlluminatePaginatorAdapter($behavior_list));
+        $data = $fractal->createData($resource)->toArray();
+        $data['extra'] = [
+            'filters' => [
+                '_id',
+                'behavior_name',
+            ],
+            'columns' => [
+                '_id',
+                'behavior_name',
+            ]
+        ];
+        return $data;
+
+    }
+
+}

+ 4 - 3
app/Http/Controllers/ConfigController.php

@@ -71,9 +71,10 @@ class ConfigController extends Controller
             ],
             //下载状态
             'download_status' => [
-                '1' => '成功',
-                '0' => '生成中',
-                '2' => '失败',
+                '1' => '生成中',
+                '0' => '待处理',
+                '2' => '成功',
+                '3' => '失败',
             ],
             'topic_status'=>[
                 'is_suggest'=>'推荐话题',

+ 1 - 1
app/Http/Controllers/Post/PostController.php

@@ -173,7 +173,7 @@ class PostController extends Controller
             'topic_ids' => 'required|string|max:64',
             'title' => 'nullable|string|max:20',
             'content' => 'required|string|max:1000',
-            'location' => 'required|string',
+            'location' => 'nullable|string|max:20',
             'imgs' => 'required_if:type,image|array|max:9',
             'imgs.*' => 'required|url',
         ]);

+ 16 - 0
app/Models/Behavior.php

@@ -0,0 +1,16 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/10
+ * Time: 11:22
+ */
+
+namespace App\Models;
+use Illuminate\Database\Eloquent\Model;
+
+class Behavior extends Model
+{
+    protected $table = 'behavior';
+    protected $guarded = [];
+}

+ 43 - 0
app/Repositories/Behavior/BehaviorRepository.php

@@ -0,0 +1,43 @@
+<?php
+namespace App\Repositories;
+use App\Models\Behavior;
+use GuzzleHttp\Client;
+use GuzzleHttp\Exception\RequestException;
+use Tymon\JWTAuth\Facades\JWTAuth;
+
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/10
+ * Time: 上午11:11
+ */
+
+class BehaviorRepository
+{
+    public function __construct(Behavior $behavior)
+    {
+        $this->behavior = $behavior;
+    }
+
+    public function index($request)
+    {
+        try {
+            $app = config('constants.VIRUS_APP_ID');
+            $signKey = [
+                'app' => config('constants.VIRUS_APP_ID')
+            ];
+            ksort($signKey);
+            $signKey = urldecode(http_build_query($signKey));
+            $sign = md5(config('constants.VIRUS_APP_SECRET') . $signKey);
+            $url = config('constants.VIRUS_URL') . '/behaviorList';
+            $array = [
+                'json' => ['app' => $app,'sign' => $sign], 'query' => [], 'http_errors' => false, 'headers' => ['Authorization' => "Bearer " . JWTAuth::getToken()]
+            ];
+
+            return http($url, $array, 'get');
+        } catch (\Exception $e) {
+            return [];
+        }
+    }
+}
+

+ 177 - 7
app/Repositories/Post/PostRepository.php

@@ -16,17 +16,22 @@ use App\Models\PostImgs;
 use App\Models\PostLog;
 use App\Models\Topic;
 use App\Traits\PostTrait;
+use App\Traits\UserTrait;
 use Illuminate\Database\QueryException;
 use Dingo\Api\Http\Response;
+use Illuminate\Support\Carbon;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Redis;
 use Symfony\Component\HttpKernel\Exception\HttpException;
 use Tymon\JWTAuth\Facades\JWTAuth;
+use League\Csv\Writer;
+use League\Csv\CannotInsertRecord;
 
 class PostRepository
 {
     use PostTrait;
+    use UserTrait;
 
     public function __construct(Post $post,
                                 PostData $postData,
@@ -51,11 +56,17 @@ class PostRepository
     public function create($request)
     {
         //验证小号
-
+        $userInfo = $this->getUserInfo($request['uid']);
+        if(!$userInfo || $userInfo['type'] != 1){
+            return Response::create([
+                'message'  => '所选小号信息有误',
+                'status_code'   => 500
+            ]);
+        }
         //验证话题
         $topicIds = $this->topic->whereIn('id', explode(',', $request['topic_ids']))->pluck('id')->toArray();
         $topicCount = count($topicIds);
-        if($topicCount == 0 || $topicCount >= 5){
+        if($topicCount == 0 || $topicCount > 5){
             return Response::create([
                 'message'  => '所选话题必须1-5个',
                 'status_code'   => 500
@@ -65,9 +76,9 @@ class PostRepository
 
         $data = [
             'uid' => $request['uid'],
-            'username' => '暂无',
-            'mobile' => '暂无',
-            'avatar' => '暂无',
+            'username' => $userInfo['username'],
+            'mobile' => $userInfo['mobile'],
+            'avatar' => $userInfo['avatar'],
             'type' => $request['type'],
             'img' => $request['img'],
             'video' => $request['video']??'',
@@ -211,6 +222,13 @@ class PostRepository
     public function comment($request)
     {
         //验证小号
+        $userInfo = $this->getUserInfo($request['uid']);
+        if(!$userInfo || $userInfo['type'] != 1){
+            return Response::create([
+                'message'  => '所选小号信息有误',
+                'status_code'   => 500
+            ]);
+        }
 
         $post = $this->post->find($request['post_id']);
         if(!$post){
@@ -223,8 +241,8 @@ class PostRepository
             'uid' => $request['uid'],
             'post_id' => $request['post_id'],
             'parent_id' => 0,
-            'username' => '暂无',
-            'avatar' => '暂无',
+            'username' => $userInfo['username'],
+            'avatar' => $userInfo['avatar'],
             'content' => $request['content'],
             'is_delete' => 0,
         ];
@@ -551,4 +569,156 @@ class PostRepository
             ->paginate($perPage);
     }
 
+    public function download($filePath, $type, $request)
+    {
+        try {
+            set_time_limit(0);
+            if (!ini_get("auto_detect_line_endings")) {
+                ini_set("auto_detect_line_endings", '1');
+            }
+
+            // 文件路径
+            $writer = Writer::createFromPath(public_path($filePath), 'w+');
+
+            // 设置标题
+            if($type == 'post'){
+                $title = [
+                    '内容', date('Y年m月d日')
+                ];
+            }else{
+                $title = [
+                    '回收站内容', date('Y年m月d日')
+                ];
+            }
+
+            $title = eval('return ' . iconv('utf-8', 'gbk//IGNORE', var_export($title, true) . ';'));
+            $writer->insertone($title);
+
+            // 内容
+            if($type == 'post') {
+                $header = [
+                    '内容ID', '发布时间', '用户昵称', '城市', '内容标签', '内容前20个字',
+                    '真实浏览量', '总浏览量', '真实点赞数', '总赞数', '真实分享数', '总分享数',
+                    '真实收藏数', '总收藏数', '评论数'
+                ];
+            } else {
+                $header = [
+                    '内容ID', '发布时间', '用户昵称', '内容标签', '内容前20个字',
+                    '真实浏览量', '真实点赞数', '真实点赞数', '真实分享数', '真实收藏数', '评论数'
+                ];
+            }
+
+            $header = eval('return ' . iconv('utf-8', 'gbk//IGNORE', var_export($header, true) . ';'));
+//            $writer->setOutputBOM(Reader::BOM_UTF8);
+            $writer->insertone($header);
+
+            $where = [];
+            if(isset($request['content'])){
+                $where[] = ['content', 'like', "%{$request['content']}%"];
+            }
+            if(isset($request['is_suggest'])){
+                $where[] = ['is_suggest', $request['is_suggest']];
+            }
+            if(isset($request['type'])){
+                $where[] = ['type', $request['type']];
+            }
+
+            $sort = 'post.id';
+            if(isset($request['sort']) && in_array($request['sort'], ['praise_count', 'share_count', 'pv', 'comment_count', 'create_bean'])){
+                $sort = $request['sort'];
+            }
+            $post = $this->post;
+            if($type == 'post_waste'){
+                $post = $post->onlyTrashed();
+            }
+
+            $post->join('post_data', 'post_data.post_id', '=', 'post.id')
+                ->select('post.*')
+                ->where($where)
+                ->where(function($query) use ($request){
+                    if(isset($request['keyword'])){
+                        $query->where('uid', '=', $request['keyword'])
+                            ->orWhere('username', 'like', "%{$request['keyword']}%")
+                            ->orWhere('mobile', 'like', "%{$request['keyword']}%");
+                    }
+                })
+                ->where(function($query) use ($request){
+                    if(isset($request['created_at'])){
+                        $time = explode('_', $request['created_at']);
+                        $query->whereBetween('post.created_at', $time);
+                    }
+                })
+                ->where(function ($query) use ($request){
+                    if(isset($request['category_ids']) || isset($request['topic_ids'])){
+                        $ids = [];
+                        if (isset($request['category_ids'])) {
+                            $categoryIds = explode('_', $request['category_ids']);
+                            $ids = $this->categoryTopic->whereIn('category_id', $categoryIds)->pluck('topic_id')->toArray();
+                        }
+                        if (isset($request['topic_ids'])) {
+                            $ids = array_merge($ids, explode('_', $request['topic_ids']));
+                        }
+                        Log::debug('话题ids:'.json_encode($ids));
+                        foreach ($ids as $key=>$id) {
+                            if ($key==0) {
+                                $query = $query->whereRaw('FIND_IN_SET('.$id.',topic_ids)');
+                            } else {
+                                $query = $query->orWhereRaw('FIND_IN_SET('.$id.',topic_ids)');
+                            }
+                        }
+                    }
+                })
+                ->orderBy($sort,'desc')
+                ->chunk(1, function ($posts) use ($writer, $type){
+                    $data = [];
+                    foreach ($posts as $post) {
+                        if($type == 'post'){
+                            $tmp = [
+                                $post->id,
+                                Carbon::parse($post->created_at)->toDateTimeString(),
+                                $post->username,
+                                $post->location,
+                                implode(' ', $post->topic()->toArray()),
+                                subtext($post->content, 20),
+                                $post->data->pv_real,
+                                $post->data->pv,
+                                $post->data->praise_real_count,
+                                $post->data->praise_count,
+                                $post->data->share_real_count,
+                                $post->data->share_count,
+                                $post->data->collect_real_count,
+                                $post->data->collect_count,
+                                $post->data->comment_count
+                            ];
+                        }else{
+                            $tmp = [
+                                $post->id,
+                                Carbon::parse($post->created_at)->toDateTimeString(),
+                                $post->username,
+                                Carbon::parse($post->created_at)->toDateTimeString(),
+                                subtext($post->content, 20),
+                                $post->data->pv_real,
+                                $post->data->praise_real_count,
+                                $post->data->share_real_count,
+                                $post->data->collect_real_count,
+                                $post->data->comment_count
+                            ];
+                        }
+                        foreach ($tmp as $key => $value) {
+                            $tmp[$key] = iconv('utf-8', 'gbk//IGNORE', $value);
+                        }
+
+                        $data[] = $tmp;
+                    }
+                    $writer->insertAll($data);
+            });
+            Log::channel('download')->info('内容导出成功!');
+
+        } catch (CannotInsertRecord $e) {
+            $e->getRecord();
+            Log::channel('download')->info('内容导出失败!');
+        }
+
+    }
+
 }

+ 26 - 0
app/Traits/UserTrait.php

@@ -0,0 +1,26 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019/6/11
+ * Time: 17:50
+ */
+
+namespace App\Traits;
+use Tymon\JWTAuth\Facades\JWTAuth;
+
+trait UserTrait
+{
+    public function getUserInfo($uid) {
+        try {
+            $url = config("customer.manage_service_url").'/user/memberView';
+            $array = [
+                'json' => ['uid' => $uid], 'query' => [], 'http_errors' => false,'headers'=>['Authorization'=>"Bearer ".JWTAuth::getToken()]
+            ];
+            return http($url,$array, true, 'get');
+        } catch (\Exception $e) {
+            return [];
+        }
+
+    }
+}

+ 21 - 0
app/Transformers/Behavior/BehaviorTransformer.php

@@ -0,0 +1,21 @@
+<?php
+namespace App\Transformers\Behavior;
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/10
+ * Time: 上午11:39
+ */
+use App\Models\Behavior;
+use League\Fractal\TransformerAbstract;
+
+class BehaviorTransformer extends TransformerAbstract
+{
+    public function transform(Behavior $behavior_list)
+    {
+        return [
+            '_id' => $behavior_list['_id'],
+            'behavior_name' => $behavior_list['behavior_name']
+        ];
+    }
+}

+ 1 - 0
app/Transformers/Post/DetailTransformer.php

@@ -28,6 +28,7 @@ class DetailTransformer extends  TransformerAbstract
             'topic' => $post->topic(),
             'title' => $post['title'],
             'content' => $post['content'],
+            'type' => $post['type'],
             'img' => $post['img'],
             'video' => $post['video'],
             'imgs' => $imgs,

+ 1 - 0
bootstrap/app.php

@@ -30,6 +30,7 @@ $app->configure('auth');
 $app->configure('jwt');
 $app->configure('customer');
 $app->configure('database');
+$app->configure('constants');
 
 /*
 |--------------------------------------------------------------------------

+ 7 - 6
composer.json

@@ -6,22 +6,23 @@
     "type": "project",
     "require": {
         "php": ">=7.1.3",
+        "cviebrock/laravel-elasticsearch": "^3.5",
         "dingo/api": "^2.2",
         "guzzlehttp/guzzle": "^6.3",
-        "cviebrock/laravel-elasticsearch": "^3.5",
-        "php-amqplib/php-amqplib": "^2.9",
         "hhxsv5/laravel-s": "~3.4.0",
         "laravel/lumen-framework": "5.8.*",
-        "vlucas/phpdotenv": "^3.3",
         "multilinguals/apollo-client": "^0.1.2",
+        "php-amqplib/php-amqplib": "^2.9",
+        "tymon/jwt-auth": "1.0.0-rc.4.1",
+        "vlucas/phpdotenv": "^3.3",
         "illuminate/redis": "^5.8",
         "predis/predis": "^1.1",
-        "tymon/jwt-auth": "1.0.0-rc.4.1"
+        "league/csv": "^9.1"
     },
     "require-dev": {
         "fzaninotto/faker": "^1.4",
-        "phpunit/phpunit": "^7.0",
-        "mockery/mockery": "^1.0"
+        "mockery/mockery": "^1.0",
+        "phpunit/phpunit": "^7.0"
     },
     "autoload": {
         "classmap": [

+ 11 - 0
config/constants.php

@@ -0,0 +1,11 @@
+<?php
+
+/**
+ * 常量配置
+ */
+
+return [
+    'VIRUS_APP_ID' => env('VIRUS_APP_ID', '5cfdcf97249e6a00082639d3'),
+    'VIRUS_APP_SECRET' => env('VIRUS_APP_SECRET', '4f2afc9c4099ee1f39c9f551123e54bd'),
+    'VIRUS_URL' => env('VIRUS_URL', 'https://api.dev.caihongxingqiu.com/virus'),
+];

+ 36 - 0
database/migrations/2019_06_01_062519_create_behavior_operation_log_table.php

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateBehaviorOperationLogTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('behavior_operation_log', function (Blueprint $table) {
+            $table->increments('id');
+            $table->integer('operator_id')->comment('操作人ID');
+            $table->integer('behavior_id')->comment('行为ID');
+            $table->string('username')->comment('用户名');
+            $table->tinyInteger('type')->nullable()->comment('操作类型:0.登记行为;1.编辑行为;2.开/关行为');
+            $table->string('content')->nullable()->comment('操作内容');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::drop('behavior_operation_log');
+    }
+}

+ 49 - 0
database/migrations/2019_06_01_074135_create_behavior_table.php

@@ -0,0 +1,49 @@
+<?php
+
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateBehaviorTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('behavior', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('virus_behavior_id')->comment('virus对应行为ID');
+            $table->string('name')->comment('行为名称');
+            $table->tinyInteger('behavior_level')->default(0)->comment('行为级别:0.唯一/基础行为;1.多级行为');
+            $table->tinyInteger('behavior_cycle_type')->default(0)->comment('行为周期类型:0.普通/短期;1.长期');
+            $table->integer('behavior_action_id')->nullable()->comment('绑定的动作ID');
+            $table->string('behavior_cycle')->nullable()->comment('行为时间周期');
+            $table->integer('behavior_binding_users')->nullable()->comment('行为绑定用户:0.所有用户');
+            $table->string('physical_strength')->nullable()->comment('行为消耗体力值');
+            $table->string('rainbow_beans')->nullable()->comment('行为生成彩虹豆');
+            $table->string('remarks',100)->nullable()->comment('备注');
+            $table->tinyInteger('is_open')->comment('是否开启:0.关闭;1.开启');
+            $table->date('behavioral_cycle_start_time')->nullable()->comment('行为时间周期开始时间');
+            $table->date('behavioral_cycle_end_time')->nullable()->comment('行为时间周期结束时间');
+            $table->json('allotted_quantity_rule')->nullable()->comment('彩虹豆分配规则');
+            $table->string('behavior_identification')->nullable()->comment('行为标识');//英文的行为名称
+            $table->integer('trigger_times')->nullable()->comment('触发次数');
+            $table->integer('effective_trigger')->nullable()->comment('有效触发次数');
+            $table->integer('relative_series')->nullable()->comment('相对级数');
+            $table->integer('absolute_progression')->nullable()->comment('绝对级数');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::drop('behavior');
+    }
+}

+ 41 - 0
database/migrations/2019_06_03_011812_create_registered_accounts_record_table.php

@@ -0,0 +1,41 @@
+<?php
+
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateRegisteredAccountsRecordTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('registered_accounts_record', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('virus_behavior_id')->comment('virus行为ID');
+            $table->integer('uid')->comment('用户ID');
+            $table->date('trigger_time')->comment('触发时间');
+            $table->string('physical_exertion')->nullable()->comment('消耗体力值');
+            $table->tinyInteger('trigger_type')->nullable()->comment('触发类型:0:无效触发;1.有效触发');
+            $table->tinyInteger('generation_type')->nullable()->comment('生成类型:1:彩虹豆');
+            $table->integer('absolute_progression')->nullable()->comment('绝对级数');
+            $table->integer('superior_uid')->nullable()->comment('上级用户ID');
+            $table->tinyInteger('release_status')->nullable()->comment('发放状态:0.异常;1.正常');
+            $table->integer('generation_quantity')->nullable()->comment('生成数量');
+            $table->integer('quantity_issued')->nullable()->comment('发放数量');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::drop('registered_accounts_record');
+    }
+}

+ 42 - 0
database/migrations/2019_06_03_021228_create_comment_account_record_table.php

@@ -0,0 +1,42 @@
+<?php
+
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateCommentAccountRecordTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('comment_account_record', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('virus_behavior_id')->comment('virus行为ID');
+            $table->integer('uid')->comment('用户ID');
+            $table->date('upper_trigger_time')->comment('上级评论触发时间');
+            $table->integer('related_content_id')->comment('关联内容id');
+            $table->integer('content_author_id')->comment('内容作者id');
+            $table->integer('superior_commentator_id')->comment('上级评论者ID');
+            $table->string('physical_exertion')->nullable()->comment('消耗体力值');
+            $table->tinyInteger('trigger_type')->nullable()->comment('触发类型:0:无效触发;1.有效触发');
+            $table->tinyInteger('generation_type')->nullable()->comment('生成类型:1:彩虹豆');
+            $table->tinyInteger('release_status')->nullable()->comment('发放状态:0.异常;1.正常');
+            $table->integer('generation_quantity')->nullable()->comment('生成数量');
+            $table->integer('quantity_issued')->nullable()->comment('发放数量');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::drop('comment_account_record');
+    }
+}

+ 41 - 0
database/migrations/2019_06_03_024134_create_general_ledger_record_table.php

@@ -0,0 +1,41 @@
+<?php
+
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateGeneralLedgerRecordTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('general_ledger_record', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('virus_behavior_id')->comment('virus行为ID');
+            $table->integer('uid')->comment('用户ID');
+            $table->date('trigger_time')->comment('触发时间');
+            $table->integer('related_content_id')->comment('关联内容id');
+            $table->integer('content_author_id')->comment('内容作者id');
+            $table->string('physical_exertion')->nullable()->comment('消耗体力值');
+            $table->tinyInteger('trigger_type')->nullable()->comment('触发类型:0:无效触发;1.有效触发');
+            $table->tinyInteger('generation_type')->nullable()->comment('生成类型:1:彩虹豆');
+            $table->tinyInteger('release_status')->nullable()->comment('发放状态:0.异常;1.正常');
+            $table->integer('generation_quantity')->nullable()->comment('生成数量');
+            $table->integer('quantity_issued')->nullable()->comment('发放数量');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::drop('general_ledger_record');
+    }
+}

+ 40 - 0
database/migrations/2019_06_04_011501_create_release_record_table.php

@@ -0,0 +1,40 @@
+<?php
+
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateReleaseRecordTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('release_record', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('virus_behavior_id')->comment('virus行为ID');
+            $table->integer('uid')->comment('用户ID');
+            $table->date('trigger_time')->comment('触发时间');
+            $table->integer('related_content_id')->comment('关联内容id');
+            $table->string('physical_exertion')->nullable()->comment('消耗体力值');
+            $table->tinyInteger('trigger_type')->nullable()->comment('触发类型:0:无效触发;1.有效触发');
+            $table->tinyInteger('generation_type')->nullable()->comment('生成类型:1:彩虹豆');
+            $table->tinyInteger('release_status')->nullable()->comment('发放状态:0.异常;1.正常');
+            $table->integer('generation_quantity')->nullable()->comment('生成数量');
+            $table->integer('quantity_issued')->nullable()->comment('发放数量');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::drop('release_record');
+    }
+}

+ 30 - 0
database/migrations/2019_06_11_163708_modify_download_status_to_table_download.php

@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class ModifyDownloadStatusToTableDownload extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        DB::statement("ALTER TABLE downloads MODIFY COLUMN download_status TINYINT (4) NOT NULL DEFAULT 0 COMMENT '下载状态:0待处理,1生成中,2成功,3失败'");
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('download', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 5 - 0
routes/api.php

@@ -85,4 +85,9 @@ $api->version('v1', [
         });
 
     });
+    //行为
+    $api->group(['namespace' => 'Behavior'], function ($api) {
+        //行为列表
+        $api->get('behavior/list', 'BehaviorController@index');
+    });
 });