Browse Source

Merge branch 'develop'

xielin 5 years ago
parent
commit
078b92cd45
56 changed files with 2775 additions and 15 deletions
  1. BIN
      .DS_Store
  2. 80 0
      app/Console/Commands/AddMessageRule.php
  3. 108 0
      app/Console/Commands/UpdateMessageRule.php
  4. 9 1
      app/Console/Kernel.php
  5. 19 0
      app/Helper/helper.php
  6. 0 2
      app/Http/Controllers/ConfigCityManagementController.php
  7. 39 0
      app/Http/Controllers/ConfigController.php
  8. 0 3
      app/Http/Controllers/ConfigPickupGroupController.php
  9. 0 1
      app/Http/Controllers/ConfigProvinceController.php
  10. 148 0
      app/Http/Controllers/MessageRuleController.php
  11. 19 2
      app/Http/Controllers/UploadController.php
  12. 78 0
      app/Http/Controllers/V2/ActivitiesController.php
  13. 115 0
      app/Http/Controllers/V2/BannerController.php
  14. 77 0
      app/Http/Controllers/V2/PlatformContentController.php
  15. 112 0
      app/Http/Controllers/V2/StarNewsController.php
  16. 18 0
      app/Models/Activities.php
  17. 24 0
      app/Models/Banner.php
  18. 17 0
      app/Models/MessageRule.php
  19. 20 0
      app/Models/PlatformContent.php
  20. 24 0
      app/Models/StarNews.php
  21. 87 0
      app/Repositories/ActivitiesRepository.php
  22. 192 0
      app/Repositories/BannerRepository.php
  23. 275 0
      app/Repositories/MessageRuleRepository.php
  24. 63 0
      app/Repositories/PlatformContentRepository.php
  25. 110 0
      app/Repositories/StarNewsRepository.php
  26. 87 0
      app/Service/RabbitMqUtil.php
  27. 24 0
      app/Transformers/ActivitiesTansformer.php
  28. 27 0
      app/Transformers/BannerTransformer.php
  29. 38 0
      app/Transformers/MessageRuleDetailTransformer.php
  30. 35 0
      app/Transformers/MessageRuleListTransformer.php
  31. 20 0
      app/Transformers/PlatformContentTransformer.php
  32. 23 0
      app/Transformers/StarNewsTransformer.php
  33. 5 3
      composer.json
  34. 71 0
      database/migrations/2019_06_04_060233_create_message_rule.php
  35. 42 0
      database/migrations/2019_06_05_065619_create_config_banner_table.php
  36. 30 0
      database/migrations/2019_06_12_024409_modify_status_to_table_message_rule.php
  37. 35 0
      database/migrations/2019_06_12_055639_add_acitvity_time_to_table_message_rule.php
  38. 30 0
      database/migrations/2019_06_12_072636_modify_show_type_to_table_message_rule.php
  39. 35 0
      database/migrations/2019_06_12_095415_add_content_to_table_message_rule.php
  40. 33 0
      database/migrations/2019_06_12_155904_create_activities_table.php
  41. 36 0
      database/migrations/2019_06_17_020159_create_star_news_table.php
  42. 33 0
      database/migrations/2019_06_17_020244_create_platform_content_table.php
  43. 32 0
      database/migrations/2019_06_17_024434_add_deleted_at_to_star_news_table.php
  44. 1 0
      database/seeds/DatabaseSeeder.php
  45. 62 0
      database/seeds/PlatformContentTableSeeder.php
  46. 1 0
      deploy/nginx/conf.d/app.beta.conf
  47. 1 0
      deploy/nginx/conf.d/app.dev.conf
  48. 19 0
      resources/lang/en/auth.php
  49. 19 0
      resources/lang/en/pagination.php
  50. 22 0
      resources/lang/en/passwords.php
  51. 146 0
      resources/lang/en/validation.php
  52. 17 0
      resources/lang/zh-CN/auth.php
  53. 17 0
      resources/lang/zh-CN/pagination.php
  54. 20 0
      resources/lang/zh-CN/passwords.php
  55. 114 0
      resources/lang/zh-CN/validation.php
  56. 66 3
      routes/api.php

BIN
.DS_Store


+ 80 - 0
app/Console/Commands/AddMessageRule.php

@@ -0,0 +1,80 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019/6/13
+ * Time: 9:13
+ */
+
+namespace App\Console\Commands;
+
+use App\Models\MessageRule;
+use App\Service\RabbitMqUtil;
+use Illuminate\Console\Command;
+use Illuminate\Database\QueryException;
+use Illuminate\Support\Carbon;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Log;
+use PhpAmqpLib\Connection\AMQPStreamConnection;
+
+class AddMessageRule extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'message:add';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '添加发送消息';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct(MessageRule $messageRule, RabbitMqUtil $rabbitMqUtil)
+    {
+        parent::__construct();
+        $this->messageRule = $messageRule;
+        $this->rabbitMqUtil = $rabbitMqUtil;
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle()
+    {
+        $this->line("开始添加发送消息");
+
+        $this->messageRule
+            ->where('message_status', 0)
+            ->where('send_time', '<', Carbon::now()->toDateTimeString())
+            ->whereNotNUll('send_time')
+            ->chunk(100, function($messages){
+                foreach($messages as $message){
+                    DB::beginTransaction();
+                    try{
+                        $this->rabbitMqUtil->push('add_message_rule', $message);
+                        $message->message_status = 1;
+                        $message->save();
+                        DB::commit();
+                        Log::info('添加发送消息成功:'.$message->id);
+                    }catch (QueryException $exception){
+                        DB::rollBack();
+                        Log::error('添加发送消息:'.$exception->getMessage());
+                    }
+                }
+            });
+
+        $this->line("添加发送消息结束");
+
+    }
+}

+ 108 - 0
app/Console/Commands/UpdateMessageRule.php

@@ -0,0 +1,108 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019/6/13
+ * Time: 18:07
+ */
+
+namespace App\Console\Commands;
+
+use App\Repositories\MessageRuleRepository;
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Log;
+use PhpAmqpLib\Connection\AMQPStreamConnection;
+
+class UpdateMessageRule extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'message:update_status';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '更新规则消息状态';
+
+    protected $channel;
+    protected $connection;
+
+    protected $queue = 'update_status_message_rule';
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct(MessageRuleRepository $messageRuleRepository)
+    {
+        parent::__construct();
+        $this->messageRuleRepository = $messageRuleRepository;
+        $this->connection = $this->getConnection();
+        $this->channel = $this->connection->channel();
+        $this->channel->exchange_declare($this->queue, 'fanout', false, true, false);
+    }
+
+    public function getConnection()
+    {
+        $conn = false;
+        if ($this->connection) {
+            return $this->connection;
+        }
+        for ($i = 0; $i < 3; $i++) {
+            $connection = $this->createConn();
+            if ($connection) {
+                $conn = $connection;
+                break;
+            }
+            Log::info("create amqp conn retry=" . $i);
+        }
+        return $conn;
+    }
+
+    public function createConn()
+    {
+        try {
+            $connection = new AMQPStreamConnection(env('MQ_HOST'), env('MQ_PORT'), env('MQ_USERNAME'), env('MQ_PWD'), env('MQ_VHOST'));
+        } catch (\Exception $exception) {
+            Log::info("AMQP connection Error" . $exception->getMessage());
+            $connection = false;
+        }
+        return $connection;
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle()
+    {
+        Log::info('发送消息结果');
+        $queue_name = $this->queue;
+        $this->channel->queue_declare($queue_name, false, true, false, false);
+        $this->channel->queue_bind($queue_name, $this->queue);
+        $callback = function ($msg) {
+            Log::info($msg->body);
+            $data = \GuzzleHttp\json_decode($msg->body, true);
+            $this->line('收到数据' . $msg->body);
+            $res = $this->messageRuleRepository->updateStatus($data);
+            if($res){
+                $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
+            }
+        };
+        $this->channel->basic_consume($queue_name, '', false, false, false, false, $callback);
+
+        while (count($this->channel->callbacks)) {
+            $this->channel->wait();
+        }
+        $this->channel->close();
+        $this->connection->close();
+
+
+    }
+}

+ 9 - 1
app/Console/Kernel.php

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

+ 19 - 0
app/Helper/helper.php

@@ -28,4 +28,23 @@ if (! function_exists('public_path')) {
     {
         return app()->basePath() . '/public' . ($path ? '/' . $path : $path);
     }
+
+
+}
+
+function http($url, $param, $method = 'post')
+{
+    try {
+        $client = new \GuzzleHttp\Client();
+        $response = $client->request($method, $url, $param);
+        $result = json_decode($response->getBody()->getContents(), true);
+        if ($result['code'] == 0) {
+            return $result['data'];
+        } else {
+            return [];
+        }
+    } catch (\Exception $exception) {
+        return [];
+    }
+
 }

+ 0 - 2
app/Http/Controllers/ConfigCityManagementController.php

@@ -3,12 +3,10 @@ namespace App\Http\Controllers;
 use App\Repositories\ConfigCityManagementRepository;
 use App\Transformers\CityTransformer;
 use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Validator;
 use League\Fractal\Pagination\IlluminatePaginatorAdapter;
 use League\Fractal\Resource\Collection;
 use League\Fractal\Manager;
-use Illuminate\Validation\Rule;
 /**
  * Created by PhpStorm.
  * User: qinyaer

+ 39 - 0
app/Http/Controllers/ConfigController.php

@@ -78,6 +78,45 @@ class ConfigController extends Controller
                     '0' => '仅展示',
                     '2' => '链接',
                 ],
+                //社区-banner类型
+                'type' => [
+                    '1' => '内容',
+                    '0' => '纯展示',
+                    '2' => '用户',
+                    '3' => '活动',
+                    '4' => '话题'
+                ],
+                //使用后台
+                'use_background' =>[
+                    '1' => '社区后台',
+                    '0' => 'CMS'
+                ],
+                //通知群体
+                'notice_groups' =>[
+                    '1' => '原始用户',
+                    '0' => '全部',
+                    '2' => '正式用户',
+                ],
+                //消息类型
+                'message_type' =>[
+                    'star' => '星球活动消息',
+                    'system' => '系统通知消息'
+                ],
+                //展示类型
+                'message_show_type' =>[
+                    'only_show' => '纯展示',
+                    'user' => '用户',
+                    'post' => '内容',
+                    'activity' => '活动',
+                    'topic' => '话题',
+                ],
+                //消息状态
+                'message_status' =>[
+                    '1' => '发送中',
+                    '0' => '未发送',
+                    '2' => '已发送未隐藏',
+                    '3' => '已发送并隐藏',
+                ],
         ];
     }
 }

+ 0 - 3
app/Http/Controllers/ConfigPickupGroupController.php

@@ -1,12 +1,9 @@
 <?php
 namespace App\Http\Controllers;
-use App\Models\ConfigPickupGroup;
 use App\Repositories\ConfigPickupGroupRepository;
 use Illuminate\Http\Request;
-use App\Http\ApiHelper;
 use Illuminate\Support\Facades\Validator;
 use App\Transformers\PickupGroupTransformer;
-//use Illuminate\Support\Facades\Validator;
 use League\Fractal\Resource\Collection;
 use League\Fractal\Manager;
 use League\Fractal\Pagination\IlluminatePaginatorAdapter;

+ 0 - 1
app/Http/Controllers/ConfigProvinceController.php

@@ -1,6 +1,5 @@
 <?php
 namespace App\Http\Controllers;
-use App\Models\ConfigProvince;
 use App\Repositories\ConfigProvinceRepository;
 use App\Transformers\ProvinceTransformer;
 use Illuminate\Http\Request;

+ 148 - 0
app/Http/Controllers/MessageRuleController.php

@@ -0,0 +1,148 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019/6/12
+ * Time: 9:08
+ */
+
+namespace App\Http\Controllers;
+
+use App\Repositories\MessageRuleRepository;
+use App\Transformers\MessageRuleDetailTransformer;
+use App\Transformers\MessageRuleListTransformer;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Validator;
+use App\Http\Controllers\Controller;
+use Illuminate\Validation\Rule;
+use League\Fractal\Manager;
+use League\Fractal\Pagination\IlluminatePaginatorAdapter;
+use League\Fractal\Resource\Collection;
+use League\Fractal\Resource\Item;
+
+class MessageRuleController extends Controller
+{
+    public function __construct(MessageRuleRepository $messageRuleRepository)
+    {
+        $this->messageRuleRepository = $messageRuleRepository;
+    }
+
+    /**
+     * 消息规则列表
+     */
+    public function index(Request $request)
+    {
+        $productList = $this->messageRuleRepository->lists($request->all());
+        $fractal = new Manager();
+        $resource = new Collection($productList, new MessageRuleListTransformer());
+        $resource->setPaginator(new IlluminatePaginatorAdapter($productList));
+        $data = $fractal->createData($resource)->toArray();
+        $data['extra'] = [
+            'filters' => [
+                'title',
+                'message_type'
+            ],
+            'columns' => [
+                'id',
+                'title',
+                'message_type',
+                'cover',
+                'updated_at',
+                'sent_count',
+                'open_count',
+                'notice_groups',
+                'message_status'
+            ]
+        ];
+        return $data;
+    }
+
+    /**
+     * 创建消息规则
+     */
+    public function create(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'title' => 'required|string|max:20',
+            'notice_groups' => 'required|string|max:31',
+            'message_type' => ['required',Rule::in('star', 'system')],
+            'message_show_type' => ['required_if:message_type,star',Rule::in('only_show', 'user', 'post', 'activity', 'topic')],
+            'activity_url' => 'required_if:message_show_type,user,post,activity,topic|string|max:64',
+            'content' => 'required_if:message_type,system|string|max:200',
+            'cover' => 'required_if:message_type,star|url',
+            'send_time' => 'nullable|date',
+            'activity_time' => 'nullable|string|max:24',
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+        return  $this->messageRuleRepository->create($request->all());
+    }
+
+    /**
+     * 编辑消息规则
+     */
+    public function update(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'id' => 'required|exists:message_rule',
+            'title' => 'required|string|max:20',
+            'notice_groups' => 'required|string|max:31',
+            'message_type' => ['required',Rule::in('star', 'system')],
+            'message_show_type' => ['required_if:message_type,star',Rule::in('only_show', 'user', 'post', 'activity', 'topic')],
+            'activity_url' => 'required_if:message_show_type,user,post,activity,topic|string|max:64',
+            'content' => 'required_if:message_type,system|string|max:200',
+            'cover' => 'required_if:message_type,star|url',
+            'send_time' => 'nullable|date',
+            'activity_time' => 'nullable|string|max:24',
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+        return  $this->messageRuleRepository->update($request->all());
+    }
+
+    /**
+     * 消息规则详情
+     */
+    public function detail(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'id' => 'required|exists:message_rule'
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+
+        $post = $this->messageRuleRepository->detail($request->all());
+        return $this->response->item($post, new MessageRuleDetailTransformer());
+    }
+
+    /**
+     * 发送消息规则
+     */
+    public function send(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'id' => 'required|exists:message_rule'
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+        return  $this->messageRuleRepository->send($request->all());
+    }
+
+    /**
+     * 隐藏消息规则
+     */
+    public function hide(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'id' => 'required|exists:message_rule'
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+        return  $this->messageRuleRepository->hide($request->all());
+    }
+}

+ 19 - 2
app/Http/Controllers/UploadController.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Storage;
+use Intervention\Image\Facades\Image;
 
 class UploadController extends Controller
 {
@@ -21,7 +22,15 @@ class UploadController extends Controller
 //            //获取文件的绝对路径,但是获取到的在本地不能打开
             $filePath = $request->file('image')->getRealPath();
             //要保存的文件名 时间+扩展名
-            $filename = time() . '_' . uniqid() . '.' . $kuoname;
+            if (in_array($kuoname, ['jpg', 'jpeg', 'png'])) {
+                $width = Image::make($filePath)->width();
+                $height = Image::make($filePath)->height();
+                //要保存的文件名 时间+扩展名
+                $filename = time() . '_' . uniqid() . '*' . $width . '_' . $height . '.' . $kuoname;
+            } else {
+                //要保存的文件名 时间+扩展名
+                $filename = time() . '_' . uniqid() . '.' . $kuoname;
+            }
             $imageUrl = Storage::put($path . $filename, file_get_contents($filePath));
             if ($imageUrl) {
                 return [
@@ -44,7 +53,15 @@ class UploadController extends Controller
             $kuoname = $files[$i]->getClientOriginalExtension();
             $filePath = $files[$i]->getRealPath();
             //要保存的文件名 时间+扩展名
-            $filename = time() . '_' . uniqid() . '.' . $kuoname;
+            if (in_array($kuoname, ['jpg', 'jpeg', 'png'])) {
+                $width = Image::make($filePath)->width();
+                $height = Image::make($filePath)->height();
+                //要保存的文件名 时间+扩展名
+                $filename = time() . '_' . uniqid() . '*' . $width . '_' . $height . '.' . $kuoname;
+            } else {
+                //要保存的文件名 时间+扩展名
+                $filename = time() . '_' . uniqid() . '.' . $kuoname;
+            }
             $imageUrl = Storage::put($filename, file_get_contents($filePath));
             if ($imageUrl) {
                 array_push($urls, $filename);

+ 78 - 0
app/Http/Controllers/V2/ActivitiesController.php

@@ -0,0 +1,78 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019-06-12
+ * Time: 16:10
+ */
+
+namespace App\Http\Controllers\V2;
+
+
+use App\Http\Controllers\Controller;
+use App\Repositories\ActivitiesRepository;
+use App\Transformers\ActivitiesTansformer;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Validator;
+use League\Fractal\Manager;
+use League\Fractal\Pagination\IlluminatePaginatorAdapter;
+use League\Fractal\Resource\Collection;
+use League\Fractal\Resource\Item;
+
+class ActivitiesController extends Controller {
+    public function __construct(ActivitiesRepository $activitiesRepository) {
+        $this->activitiesRepository = $activitiesRepository;
+    }
+
+    public function index(Request $request){
+        $activitie = $this->activitiesRepository->index($request->all());
+        $fractal = new Manager();
+        $resource = new Collection($activitie, new ActivitiesTansformer());
+        $resource->setPaginator(new IlluminatePaginatorAdapter($activitie));
+        $data = $fractal->createData($resource)->toArray();
+        $data['extra'] = [
+            'filters' => [
+                'name',
+            ],
+            'columns' => [
+                'id',
+                'name',
+                'created_at',
+            ]
+        ];
+        return $data;
+    }
+    public function create(Request $request){
+        $validator = Validator::make($request->all(), [
+            'name' => 'required|string|max:20',
+            'content' => 'required|string',
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+        return  $this->activitiesRepository->create($request->all());
+    }
+    public function edit(Request $request){
+        $validator = Validator::make($request->all(), [
+            'id' => 'required|integer|max:20    ',
+            'name' => 'required|string|max:12',
+            'content' => 'required|string',
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+
+        return  $this->activitiesRepository->edit($request->all());
+    }
+    public function view(Request $request){
+        $data = $request->only('id');
+        $validator = Validator::make($data, [
+            'id' => 'required|integer|max:12',
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+        $info = $this->activitiesRepository->view($data);
+        return $this->response->item($info, new ActivitiesTansformer());
+    }
+}

+ 115 - 0
app/Http/Controllers/V2/BannerController.php

@@ -0,0 +1,115 @@
+<?php
+namespace App\Http\Controllers\V2;
+use App\Http\Controllers\BaseController;
+use App\Repositories\BannerRepository;
+use App\Transformers\BannerTransformer;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Validator;
+use Illuminate\Validation\Rule;
+use League\Fractal\Pagination\IlluminatePaginatorAdapter;
+use League\Fractal\Resource\Collection;
+use League\Fractal\Manager;
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/10
+ * Time: 下午18:51
+ */
+
+class BannerController extends BaseController
+{
+    public function __construct(BannerRepository $bannerRepository)
+    {
+        $this->bannerRepository = $bannerRepository;
+    }
+
+    //banner列表
+    public function lists(Request $request)
+    {
+        $banner = $this->bannerRepository->index($request->all());
+
+        $fractal = new Manager();
+        $resource = new Collection($banner, new BannerTransformer());
+        $resource->setPaginator(new IlluminatePaginatorAdapter($banner));
+        $data = $fractal->createData($resource)->toArray();
+        $data['extra'] = [
+            'filters' => [
+                'id',
+                'name',
+                'is_open'
+            ],
+            'columns' => [
+                'id',
+                'tpl_id',
+                'rule',
+                'area_type',
+                'name',
+                'link_content_id',
+                'image',
+                'type',
+                'use_background',
+                'status',
+                'is_open',
+                'updated_at',
+            ]
+        ];
+        return $data;
+
+    }
+
+    //新增banner
+    public function bannerSet(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'use_background' => ['required',Rule::in(0,1)],
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+
+        return  $this->bannerRepository->bannerSets($request->all());
+
+    }
+
+    //修改banner
+    public function edit(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'id' => 'required|exists:config_banner',
+        ]);
+
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+        return  $this->bannerRepository->edit($request->all());
+    }
+
+    //删除banner
+    public function bannerDelete(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'id' => 'required|exists:config_banner'
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+        return $this->bannerRepository->bannerDelete($request->only('id'));
+
+    }
+
+    //修改banner状态
+    public function editStatus(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'id' => 'required|exists:config_banner',
+            'is_open' => ['required', Rule::in(0,1)],
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+
+        return  $this->bannerRepository->editStatus($request->all());
+    }
+
+
+}

+ 77 - 0
app/Http/Controllers/V2/PlatformContentController.php

@@ -0,0 +1,77 @@
+<?php
+namespace App\Http\Controllers\V2;
+use App\Http\Controllers\BaseController;
+use App\Repositories\PlatformContentRepository;
+use App\Transformers\PlatformContentTransformer;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Validator;
+use Illuminate\Validation\Rule;
+use League\Fractal\Pagination\IlluminatePaginatorAdapter;
+use League\Fractal\Resource\Collection;
+use League\Fractal\Manager;
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/17
+ * Time: 下午2:04
+ */
+
+class PlatformContentController extends BaseController
+{
+    public function __construct(PlatformContentRepository $platformContentRepository)
+    {
+        $this->platformContentRepository = $platformContentRepository;
+    }
+
+    //平台内容列表
+    public function index(Request $request)
+    {
+        $platformContent = $this->platformContentRepository->index($request->all());
+
+        $fractal = new Manager();
+        $resource = new Collection($platformContent, new PlatformContentTransformer());
+        $resource->setPaginator(new IlluminatePaginatorAdapter($platformContent));
+        $data = $fractal->createData($resource)->toArray();
+        $data['extra'] = [
+            'filters' => [
+                'id',
+            ],
+            'columns' => [
+                'id',
+                'title',
+                'content',
+                'updated_at'
+            ]
+        ];
+        return $data;
+    }
+
+    //新增平台内容
+    public function create(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'title' => 'required|string',
+            'content' => 'required|string',
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+
+        return  $this->platformContentRepository->create($request->all());
+
+    }
+
+    //修改平台内容
+    public function edit(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'id' => 'required|exists:platform_content',
+            'content' => 'required',
+        ]);
+
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+        return  $this->platformContentRepository->edit($request->all());
+    }
+}

+ 112 - 0
app/Http/Controllers/V2/StarNewsController.php

@@ -0,0 +1,112 @@
+<?php
+namespace App\Http\Controllers\V2;
+use App\Http\Controllers\BaseController;
+use App\Repositories\StarNewsRepository;
+use App\Transformers\StarNewsTransformer;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Validator;
+use Illuminate\Validation\Rule;
+use League\Fractal\Pagination\IlluminatePaginatorAdapter;
+use League\Fractal\Resource\Collection;
+use League\Fractal\Manager;
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/17
+ * Time: 上午10:53
+ */
+
+class StarNewsController extends BaseController
+{
+    public function __construct(StarNewsRepository $starNewsRepository)
+    {
+        $this->starNewsRepository = $starNewsRepository;
+    }
+
+    //星球新闻列表
+    public function index(Request $request)
+    {
+        $starNews = $this->starNewsRepository->index($request->all());
+
+        $fractal = new Manager();
+        $resource = new Collection($starNews, new StarNewsTransformer());
+        $resource->setPaginator(new IlluminatePaginatorAdapter($starNews));
+        $data = $fractal->createData($resource)->toArray();
+        $data['extra'] = [
+            'filters' => [
+                'id',
+                'sort',
+                'status'
+            ],
+            'columns' => [
+                'id',
+                'title',
+                'content',
+                'cover_img',
+                'status',
+                'sort',
+                'updated_at'
+            ]
+        ];
+        return $data;
+    }
+
+    //新增星球新闻
+    public function create(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'title' => 'required|string',
+            'content' => 'required|string',
+            'cover_img' => 'required',
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+
+        return  $this->starNewsRepository->create($request->all());
+
+    }
+
+    //修改星球新闻
+    public function edit(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'id' => 'required|exists:star_news',
+            'title' => 'required|string',
+            'content' => 'required|string',
+            'cover_img' => 'required',
+        ]);
+
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+        return  $this->starNewsRepository->edit($request->all());
+    }
+
+    //删除星球新闻
+    public function delete(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'id' => 'required|exists:star_news'
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+        return $this->starNewsRepository->delete($request->only('id'));
+
+    }
+
+    //修改星球新闻状态
+    public function editStatus(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'id' => 'required|exists:star_news',
+            'status' => ['required', Rule::in(0,1)],
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+
+        return  $this->starNewsRepository->editStatus($request->all());
+    }
+}

+ 18 - 0
app/Models/Activities.php

@@ -0,0 +1,18 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019-06-12
+ * Time: 16:29
+ */
+
+namespace App\Models;
+
+
+use Illuminate\Database\Eloquent\Model;
+
+class Activities extends Model {
+    protected $guarded = ['id'];
+
+    protected $hidden = ['deleted_at'];
+}

+ 24 - 0
app/Models/Banner.php

@@ -0,0 +1,24 @@
+<?php
+namespace App\Models;
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/3
+ * Time: 下午4:11
+ */
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class Banner extends BaseModel
+{
+    use SoftDeletes;
+
+    protected $dates = ['deleted_at'];
+    protected  $table = 'config_banner';
+    /**
+     * 可被批量赋值的字段
+     * @var array
+     */
+    protected $fillable = ['tpl_id','rule','status','area_type','name','link_content_id','image','type','is_open','use_background'];
+
+
+}

+ 17 - 0
app/Models/MessageRule.php

@@ -0,0 +1,17 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019/6/12
+ * Time: 9:11
+ */
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class MessageRule extends Model
+{
+    protected $table = 'message_rule';
+    protected $guarded = [];
+}

+ 20 - 0
app/Models/PlatformContent.php

@@ -0,0 +1,20 @@
+<?php
+namespace App\Models;
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/17
+ * Time: 下午12:11
+ */
+
+class PlatformContent extends BaseModel
+{
+    protected  $table = 'platform_content';
+    /**
+     * 可被批量赋值的字段
+     * @var array
+     */
+    protected $fillable = ['title','content'];
+
+
+}

+ 24 - 0
app/Models/StarNews.php

@@ -0,0 +1,24 @@
+<?php
+namespace App\Models;
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/17
+ * Time: 下午13:11
+ */
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class StarNews extends BaseModel
+{
+    use SoftDeletes;
+
+    protected $dates = ['deleted_at'];
+    protected  $table = 'star_news';
+    /**
+     * 可被批量赋值的字段
+     * @var array
+     */
+    protected $fillable = ['title','content','cover_img','status','sort'];
+
+
+}

+ 87 - 0
app/Repositories/ActivitiesRepository.php

@@ -0,0 +1,87 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019-06-12
+ * Time: 16:30
+ */
+
+namespace App\Repositories;
+
+
+use App\Models\Activities;
+use Dingo\Api\Http\Response;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Database\QueryException;
+use Illuminate\Support\Facades\Log;
+
+class ActivitiesRepository {
+    public function __construct(Activities $activities) {
+        $this->activities = $activities;
+    }
+    //列表
+    public function index($request){
+        $perPage = isset($request['per_page']) ? $request['per_page'] : 20;
+        $where = [];
+        if(isset($request['name'])){
+            $where[] = ['name', 'like', "%{$request['name']}%"];
+        }
+        return $this->activities->where($where)->paginate($perPage);
+    }
+    //详情
+    public function view($request){
+        return $this->activities->where(['id'=>$request['id']])->first();
+    }
+    //创建
+    public function create($request){
+        $activities = $this->activities->where(['name'=>$request['name']])->first();
+        if($activities){
+            return Response::create([
+                'message'  => '该活动已存在',
+                'status_code'   => 500
+            ]);
+        }
+        $data = [
+            'name' => $request['name'],
+            'content' => $request['content'],
+        ];
+        DB::beginTransaction();
+        try{
+            $this->activities->create($data);
+            DB::commit();
+            return Response::create();
+        }catch (QueryException $exception){
+            DB::rollBack();
+            Log::debug('新增活动:'.$exception->getMessage());
+            return Response::create([
+                'message'  => '新增活动失败,请重试',
+                'error' => $exception->getMessage(),
+                'status_code'   => 500
+            ]);
+        }
+    }
+    public function edit($request){
+        $activities = $this->activities->where(['id'=>$request['id']])->first();
+        if(!$activities){
+            return Response::create([
+                'message'  => '该活动不存在',
+                'status_code'   => 500
+            ]);
+        }
+        $activities->content = $request['content'];
+        DB::beginTransaction();
+        try{
+            $activities->save();
+            DB::commit();
+            return Response::create();
+        }catch (QueryException $exception){
+            DB::rollBack();
+            Log::debug('编辑活动:'.$exception->getMessage());
+            return Response::create([
+                'message'  => '编辑活动失败,请重试',
+                'error' => $exception->getMessage(),
+                'status_code'   => 500
+            ]);
+        }
+    }
+}

+ 192 - 0
app/Repositories/BannerRepository.php

@@ -0,0 +1,192 @@
+<?php
+namespace App\Repositories;
+use App\Models\Banner;
+use Dingo\Api\Http\Response;
+use Illuminate\Support\Facades\Log;
+use Symfony\Component\HttpKernel\Exception\HttpException;
+use Tymon\JWTAuth\Facades\JWTAuth;
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/4
+ * Time: 上午9:39
+ */
+
+class BannerRepository
+{
+    public function __construct(Banner $banner)
+    {
+        $this->banner = $banner;
+    }
+
+    public function index($request)
+    {
+        $perPage = isset($request['per_page']) ? $request['per_page'] : env('PER_PAGE');
+        $where = [];
+        if(isset($request['id'])){
+            $where[] = ['id', '=', $request['id']];
+        }
+        if(isset($request['is_open'])){
+            $where[] = ['is_open', '=', $request['is_open']];
+        }
+        if (isset($request['name'])){
+            $where[] = ['name', 'like', "%{$request['name']}%"];
+        }
+
+        if (isset($request['use_background'])){
+            $where[] = ['use_background', '=', $request['use_background']];
+        }
+
+        return $this->banner->where($where)->orderBy('id', 'desc')->paginate($perPage);
+
+    }
+
+    public function bannerSets($request)
+    {
+        if ($request['use_background'] == 0){
+            $banner = [
+                'status' => 0,
+                'tpl_id' => $request['tpl_id'],
+                'area_type' => $request['area_type'],
+                'rule' => json_encode($request['rule']),
+            ];
+        }else{
+            if (!is_int($request['link_content_id'])){
+                throw new HttpException(500, '链接内容必须是数字');
+            }
+            $banner = [
+                'name' => $request['name'],
+                'link_content_id' => $request['link_content_id'],
+                'image' => $request['image'],
+                'type' => $request['type'],
+                'is_open' => $request['is_open'] ?? '',
+            ];
+        }
+        $banner['use_background'] = $request['use_background'];
+        $banner['created_at'] = date('Y-m-d H:i:s');
+        $banner['updated_at'] = date('Y-m-d H:i:s');
+
+        $res = $this->banner->create($banner);
+
+        if (!$res) {
+            throw new HttpException(500, '添加失败,请重试');
+        }
+        if ($request['use_background'] == 0){
+            $request['type'] = 0;//0表示新增
+            $request['id'] = $res['id'];
+            $request['rule'] = $res['rule'];
+            $this->bannerIds($request);
+        }
+    }
+
+    public function edit($request)
+    {
+        $banner = $this->banner->where('id', $request['id'])->first();
+
+        $rule = $request['rule'];
+        $banner->use_background = $request['use_background'];
+        $banner->updated_at = date('Y-m-d H:i:s');
+        if ($request['use_background'] == 0){
+            $request['old_rule'] = $banner->rule;
+
+            $banner->tpl_id = $request['tpl_id'];
+            $banner->area_type = $request['area_type'];
+            $banner->rule = json_encode($rule);
+            $banner->status = 0;
+
+            $banner_update = $banner->save();
+            if (!$banner_update) {
+                throw new HttpException(500, 'cms-banner更新失败');
+            }
+            $request['id'] = $banner->id;
+            $request['rule'] = $rule;
+            $request['type'] = 1;//1表示修改
+            $this->bannerIds($request);
+
+        }else{
+            if (!is_int($request['link_content_id'])){
+                throw new HttpException(500, '链接内容必须是数字');
+            }
+            $banner->name = $request['name'];
+            $banner->link_content_id = $request['link_content_id'];
+            $banner->image = $request['image'];
+            $banner->type = $request['type'];
+            $banner->is_open = $request['is_open'] ?? '';
+
+            $banner_update = $banner->save();
+            if (!$banner_update) {
+                throw new HttpException(500, '社区banner更新失败');
+            }
+        }
+
+    }
+
+    function bannerIds($request)
+    {
+        try {
+            $url = config("customer.manage_service_url") . '/cms/v2/countSubject';
+            if ($request['type'] == 0){
+                $array = [
+                    'json' => ['id' => $request['id'],'rule' => $request['rule'],'type' => $request['type']], 'query' => [], 'http_errors' => false, 'headers' => ['Authorization' => "Bearer " . JWTAuth::getToken()]
+                ];
+            }else{
+                $array = [
+                    'json' => ['id' => $request['id'],'rule' => $request['rule'],'type' => $request['type'],'old_rule' =>$request['old_rule']], 'query' => [], 'http_errors' => false, 'headers' => ['Authorization' => "Bearer " . JWTAuth::getToken()]
+                ];
+            }
+
+            return http($url, $array, 'post');
+        } catch (\Exception $e) {
+            return [];
+        }
+
+    }
+
+    public function bannerDelete($request)
+    {
+        $advertisement = $this->banner->where('id', $request['id'])->first();
+        $res = $advertisement->delete();
+        if (!$res){
+            return Response::create([
+                'message'  => '删除失败,请重试',
+                'status_code'   => 500
+            ]);
+        }
+        $request['banner_id'] = $advertisement->id;
+        $this->editFloorBind($request);
+    }
+
+    public function editStatus($request)
+    {
+        $banner_id = $this->banner->find($request['id']);
+        $banner_id->is_open = $request['is_open'];
+        $banner_id->updated_at = date('Y-m-d H:i:s');
+
+        $res = $banner_id->save();
+
+        if (!$res) {
+            throw new HttpException(500, '修改状态失败');
+        }
+        //banner关闭检测绑定楼层是否只有一个banner
+        if ($request['is_open'] == 0){
+            $request['banner_id'] = $request['id'];
+            $this->editFloorBind($request);
+        }
+    }
+
+    function editFloorBind($request)
+    {
+        try {
+            $url = config("customer.manage_service_url") . '/cms/v2/floorBind';
+            $array = [
+                'json' => ['banner_id' => $request['banner_id']], 'query' => [], 'http_errors' => false, 'headers' => ['Authorization' => "Bearer " . JWTAuth::getToken()]
+            ];
+
+            return http($url, $array, 'post');
+        } catch (\Exception $e) {
+            return [];
+        }
+    }
+
+
+}

+ 275 - 0
app/Repositories/MessageRuleRepository.php

@@ -0,0 +1,275 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019/6/12
+ * Time: 9:13
+ */
+
+namespace App\Repositories;
+
+use App\Models\MessageRule;
+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;
+
+class MessageRuleRepository
+{
+    public function __construct(MessageRule $messageRule)
+    {
+        $this->messageRule = $messageRule;
+    }
+
+    /**
+     * 内容列表
+     */
+    public function lists($request)
+    {
+        $perPage = isset($request['per_page']) ? $request['per_page'] : 20;
+        $where = [];
+        if(isset($request['title'])){
+            $where[] = ['title', 'like', "%{$request['title']}%"];
+        }
+        if(isset($request['message_type'])){
+            $where[] = ['message_type', $request['message_type']];
+        }
+        return $this->messageRule
+            ->where($where)
+            ->orderBy('id','desc')
+            ->paginate($perPage);
+    }
+
+    /**
+     * 创建消息规则
+     */
+    public function create($request)
+    {
+        $noticeGroups = explode(',', $request['notice_groups']);
+
+        if(in_array(0, $noticeGroups)){
+            $noticeGroups = 0;
+        } else {
+            if(array_diff($noticeGroups, [1,2])){
+                return Response::create([
+                    'message'  => '通知群体参数有误',
+                    'status_code'   => 500
+                ]);
+            }
+            $noticeGroups = implode(',', array_unique($noticeGroups));
+        }
+
+
+        $data = [
+            'title' => $request['title'],
+            'content' => isset($request['content']) && $request['message_type'] == 'system'? $request['content']:'',
+            'notice_groups' => $noticeGroups,
+            'message_type' => $request['message_type'],
+            'message_show_type' => isset($request['message_show_type']) && $request['message_type'] == 'star'? $request['message_show_type']:'',
+            'activity_url' => isset($request['activity_url']) && $request['message_type'] == 'star'? $request['activity_url']:'',
+            'cover' => $request['message_type'] == 'star'? $request['cover']:'',
+            'message_status' => 0,
+            'send_time' => isset($request['send_time']) && $request['send_time']? $request['send_time']:null,
+            'activity_time' => $request['activity_time']??'',
+            'sent_count' => 0,
+            'open_count' => 0
+        ];
+
+        DB::beginTransaction();
+        try{
+            $this->messageRule->create($data);
+
+            DB::commit();
+            return Response::create();
+
+        }catch (QueryException $exception){
+            DB::rollBack();
+            Log::debug('创建消息规则:'.$exception->getMessage());
+            return Response::create([
+                'message'  => '添加失败,请重试',
+                'error' => $exception->getMessage(),
+                'status_code'   => 500
+            ]);
+        }
+    }
+
+    /**
+     * 编辑消息规则
+     */
+    public function update($request)
+    {
+        $message = $this->messageRule->find($request['id']);
+        if(!$message || $message->message_status != 0){
+            return Response::create([
+                'message'  => '只能编辑未发送消息',
+                'status_code'   => 500
+            ]);
+        }
+        $noticeGroups = explode(',', $request['notice_groups']);
+
+        if(in_array(0, $noticeGroups)){
+            $noticeGroups = 0;
+        } else {
+            if(array_diff($noticeGroups, [1,2])){
+                return Response::create([
+                    'message'  => '通知群体参数有误',
+                    'status_code'   => 500
+                ]);
+            }
+            $noticeGroups = implode(',', array_unique($noticeGroups));
+        }
+
+        $message->title = $request['title'];
+        $message->notice_groups = $noticeGroups;
+        $message->message_type = $request['message_type'];
+
+        if(isset($request['cover'])){
+            $message->cover = $request['cover'];
+        }
+
+        if(isset($request['activity_url'])){
+            $message->activity_url = $request['activity_url'];
+        }
+        if(isset($request['message_show_type'])){
+            $message->message_show_type = $request['message_show_type'];
+        }
+        if(isset($request['content'])){
+            $message->content = $request['content'];
+        }
+        if(isset($request['send_time'])){
+            if($request['send_time']){
+                $message->send_time = $request['send_time'];
+            }else{
+                $message->send_time = null;
+            }
+
+        }
+        if(isset($request['activity_time'])){
+            $message->activity_time = $request['activity_time'];
+        }
+
+        DB::beginTransaction();
+        try{
+            $message->save();
+
+            DB::commit();
+            return Response::create();
+
+        }catch (QueryException $exception){
+            DB::rollBack();
+            Log::debug('编辑消息规则:'.$exception->getMessage());
+            return Response::create([
+                'message'  => '编辑失败,请重试',
+                'error' => $exception->getMessage(),
+                'status_code'   => 500
+            ]);
+        }
+    }
+
+    /**
+     * 消息规则详情
+     */
+    public function detail($request)
+    {
+        return $this->messageRule->find($request['id']);
+    }
+
+    /**
+     * 发送消息规则
+     */
+    public function send($request)
+    {
+        $message = $this->messageRule->find($request['id']);
+        if(!$message || $message->message_status != 0){
+            return Response::create([
+                'message'  => '只能发送未发送消息',
+                'status_code'   => 500
+            ]);
+        }
+
+        $message->send_time = Carbon::now()->toDateTimeString();
+
+        DB::beginTransaction();
+        try{
+            $message->save();
+
+            DB::commit();
+            return Response::create();
+
+        }catch (QueryException $exception){
+            DB::rollBack();
+            Log::debug('发送消息规则:'.$exception->getMessage());
+            return Response::create([
+                'message'  => '发送失败,请重试',
+                'error' => $exception->getMessage(),
+                'status_code'   => 500
+            ]);
+        }
+    }
+
+    /**
+     * 隐藏消息规则
+     */
+    public function hide($request)
+    {
+        $message = $this->messageRule->find($request['id']);
+        if(!$message || $message->message_status != 2){
+            return Response::create([
+                'message'  => '只能隐藏已发送消息',
+                'status_code'   => 500
+            ]);
+        }
+
+        $message->message_status = 3;
+
+        DB::beginTransaction();
+        try{
+            $message->save();
+
+            DB::commit();
+            return Response::create();
+
+        }catch (QueryException $exception){
+            DB::rollBack();
+            Log::debug('隐藏消息规则:'.$exception->getMessage());
+            return Response::create([
+                'message'  => '隐藏失败,请重试',
+                'error' => $exception->getMessage(),
+                'status_code'   => 500
+            ]);
+        }
+    }
+
+    /**
+     * 更新消息规则
+     */
+    public function updateStatus($data)
+    {
+        Log::debug('更新消息规则收到数据:'.json_encode($data));
+        $message = $this->messageRule->find($data['id']);
+        if(!$message || $message->message_status != 1){
+            Log::error('更新消息规则状态失败:'.$data['id']);
+            return false;
+        }
+
+        $message->message_status = 2;
+        $message->sent_count = $data['num'];
+
+        DB::beginTransaction();
+        try{
+            $message->save();
+
+            DB::commit();
+            return true;
+
+        }catch (QueryException $exception){
+            DB::rollBack();
+            Log::error('更新消息规则状态:'.$data['id'].$exception->getMessage());
+            return false;
+        }
+    }
+}

+ 63 - 0
app/Repositories/PlatformContentRepository.php

@@ -0,0 +1,63 @@
+<?php
+namespace App\Repositories;
+use App\Models\PlatformContent;
+use Symfony\Component\HttpKernel\Exception\HttpException;
+
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/17
+ * Time: 下午2:06
+ */
+
+class PlatformContentRepository
+{
+    public function __construct(PlatformContent $platformContent)
+    {
+        $this->platformContent = $platformContent;
+    }
+
+    public function index($request)
+    {
+        $perPage = isset($request['per_page']) ? $request['per_page'] : env('PER_PAGE');
+        $where = [];
+        if(isset($request['id'])){
+            $where[] = ['id', '=', $request['id']];
+        }
+        if (isset($request['title'])){
+            $where[] = ['title', 'like', "%{$request['title']}%"];
+        }
+
+        return $this->platformContent->where($where)->orderBy('updated_at', 'desc')->paginate($perPage);
+
+    }
+
+    public function create($request)
+    {
+        if($this->platformContent->where('title', $request['title'])->exists()){
+            throw new HttpException(500, '该名称已经存在');
+        }
+
+        $data = [
+            'title' => $request['title'],
+            'content' => $request['content'],
+        ];
+
+        if (!$this->platformContent->create($data)) {
+            throw new HttpException(500, '添加失败');
+        }
+    }
+
+    public function edit($request)
+    {
+        $platforms = $this->platformContent->where('id', $request['id'])->first();
+        $platforms->content = $request['content'];
+        $platforms->updated_at = date('Y-m-d H:i:s');
+
+        $res = $platforms->save();
+        if (!$res) {
+            throw new HttpException(500, '平台内容更新失败');
+        }
+    }
+
+}

+ 110 - 0
app/Repositories/StarNewsRepository.php

@@ -0,0 +1,110 @@
+<?php
+namespace App\Repositories;
+use App\Models\StarNews;
+use Dingo\Api\Http\Response;
+use Symfony\Component\HttpKernel\Exception\HttpException;
+/**
+ * Created by PhpStorm.
+ * User: durong
+ * Date: 2019/6/17
+ * Time: 上午10:59
+ */
+
+class StarNewsRepository
+{
+    public function __construct(StarNews $starNews)
+    {
+        $this->starNews = $starNews;
+    }
+
+    public function index($request)
+    {
+        $perPage = isset($request['per_page']) ? $request['per_page'] : env('PER_PAGE');
+        $where = [];
+        if(isset($request['id'])){
+            $where[] = ['id', '=', $request['id']];
+        }
+        if(isset($request['status'])){
+            $where[] = ['status', '=', $request['status']];
+        }
+        if (isset($request['title'])){
+            $where[] = ['title', 'like', "%{$request['title']}%"];
+        }
+
+        return $this->starNews->where($where)->orderBy('status', 'desc')->orderBy('sort', 'asc')->paginate($perPage);
+
+    }
+
+    public function create($request)
+    {
+        if($this->starNews->where('title', $request['title'])->exists()){
+            throw new HttpException(500, '该新闻标题已经存在');
+        }
+
+        $data = [
+            'title' => $request['title'],
+            'content' => $request['content'],
+            'cover_img' => $request['cover_img'],
+            'sort' => $request['sort'] ?? 0,
+            'status' => $request['status'] ?? 0,
+        ];
+        $open_news = $this->starNews->where('status',1)->count();
+        if ($open_news >= 5 && $request['status'] == 1){
+            throw new HttpException(500, '最多开启5条新闻');
+        }
+
+        if (!$this->starNews->create($data)) {
+            throw new HttpException(500, '添加失败');
+        }
+    }
+
+    public function edit($request)
+    {
+        $starNew = $this->starNews->where('id', $request['id'])->first();
+        $starNew->title = $request['title'];
+        $starNew->content = $request['content'];
+        $starNew->cover_img = $request['cover_img'];
+        $starNew->sort = $request['sort'] ?? 0;
+        $starNew->status = $request['status'] ?? 0;
+        $starNew->updated_at = date('Y-m-d H:i:s');
+
+        $open_news = $this->starNews->where('status',1)->count();
+        if ($open_news > 5 && $request['status'] == 1){
+            throw new HttpException(500, '最多开启5条新闻');
+        }
+        $res = $starNew->save();
+            if (!$res) {
+                throw new HttpException(500, '星球新闻更新失败');
+            }
+        }
+
+
+    public function delete($request)
+    {
+        $starNew = $this->starNews->where('id', $request['id'])->first();
+        $res = $starNew->delete();
+        if (!$res){
+            return Response::create([
+                'message'  => '删除失败,请重试',
+                'status_code'   => 500
+            ]);
+        }
+    }
+
+    public function editStatus($request)
+    {
+        $starNew = $this->starNews->find($request['id']);
+        $starNew->status = $request['status'];
+        $starNew->updated_at = date('Y-m-d H:i:s');
+        $open_news = $this->starNews->where('status',1)->count();
+        if ($open_news >= 5 && $request['status'] == 1){
+            throw new HttpException(500, '最多开启5条新闻');
+        }
+        $res = $starNew->save();
+
+        if (!$res) {
+            throw new HttpException(500, '修改状态失败');
+        }
+    }
+
+}

+ 87 - 0
app/Service/RabbitMqUtil.php

@@ -0,0 +1,87 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: edz
+ * Date: 2019-04-30
+ * Time: 17:22
+ */
+namespace App\Service;
+
+use PhpAmqpLib\Connection\AMQPStreamConnection;
+use PhpAmqpLib\Message\AMQPMessage;
+
+class RabbitMqUtil
+{
+    protected $connection;
+    protected $queue;
+    protected $channel;
+    public function __construct()
+    {
+        $this->connection = $this->getConnection();
+        $this->channel = $this->connection->channel();
+    }
+
+    public function getConnection()
+    {
+        $conn = false;
+        if ($this->connection) {
+            return $this->connection;
+        }
+        for ($i = 0; $i < 3; $i++) {
+            $connection = $this->createConn();
+            if ($connection) {
+                $conn = $connection;
+                break;
+            }
+            Log::info("create amqp conn retry=" . $i);
+        }
+        return $conn;
+    }
+
+    public function createConn()
+    {
+        try {
+            $connection = new AMQPStreamConnection(env('MQ_HOST'), env('MQ_PORT'), env('MQ_USERNAME'), env('MQ_PWD'), env('MQ_VHOST'));
+        } catch (\Exception $exception) {
+            Log::info("AMQP connection Error" . $exception->getMessage());
+            $connection = false;
+        }
+        return $connection;
+    }
+
+    /**
+     * 生产消息-分布式任务模式(Work queues)
+     * @param $queue
+     * @param $data
+     */
+    public function push($queue,$data){
+        $this->channel->queue_declare($queue, false, true, false, false);
+        $msg = new AMQPMessage(
+            \GuzzleHttp\json_encode($data),
+            array('delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT)
+        );
+        return $this->channel->basic_publish($msg, '', $queue);
+    }
+
+    /**
+     * 生产消息-发布订阅模式(Publish/Subscribe)
+     *
+     * @param $queue
+     * @param $data
+     */
+    public function publish($queue,$data){
+        $this->channel->exchange_declare($queue, 'fanout', false, true, false);
+        $msg = new AMQPMessage(
+            \GuzzleHttp\json_encode($data),
+            array('delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT)
+        );
+        return $this->channel->basic_publish($msg, $queue);
+    }
+
+    public function __destruct()
+    {
+        // TODO: Implement __destruct() method.
+        $this->channel->close();
+        $this->connection->close();
+    }
+}

+ 24 - 0
app/Transformers/ActivitiesTansformer.php

@@ -0,0 +1,24 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019-06-12
+ * Time: 16:38
+ */
+
+namespace App\Transformers;
+use App\Models\Activities;
+use League\Fractal\TransformerAbstract;
+use Illuminate\Support\Carbon;
+
+class ActivitiesTansformer extends TransformerAbstract{
+    public function transform(Activities $activities)
+    {
+        return [
+            'id'  => $activities['id'],
+            'name'    => $activities['name'],
+            'content'    => $activities['content'],
+            'created_at' => Carbon::parse($activities['created_at'])->toDateTimeString(),
+        ];
+    }
+}

+ 27 - 0
app/Transformers/BannerTransformer.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Transformers;
+
+use App\Models\Banner;
+use League\Fractal\TransformerAbstract;
+
+class BannerTransformer extends TransformerAbstract
+{
+
+    public function transform(Banner $banner)
+    {
+        return [
+            'id'  => $banner['id'],
+            'tpl_id'  => $banner['tpl_id'],
+            'name'    => $banner['name'],
+            'link_content_id'    => $banner['link_content_id'],
+            'image'    => $banner['image'],
+            'type'    => $banner['type'],
+            'use_background'    => $banner['use_background'],
+            'rule'    => $banner['rule'],
+            'status'    => $banner['status'],
+            'is_open'    => $banner['is_open'],
+            'updated_at'    => date($banner['updated_at']),
+        ];
+    }
+}

+ 38 - 0
app/Transformers/MessageRuleDetailTransformer.php

@@ -0,0 +1,38 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019/6/12
+ * Time: 15:05
+ */
+
+namespace App\Transformers;
+
+use App\Models\MessageRule;
+use Illuminate\Support\Carbon;
+use League\Fractal\TransformerAbstract;
+
+class MessageRuleDetailTransformer extends TransformerAbstract
+{
+    public function transform(MessageRule $messageRule)
+    {
+        $messageStatus = $messageRule['message_status'];
+        if($messageStatus == 0 && $messageRule['send_time'] && $messageRule['send_time'] <= Carbon::now()->toDateTimeString()){
+            $messageStatus = 1;
+        }
+        return [
+            'id' => $messageRule['id'],
+            'title' => $messageRule['title'],
+            'content' => $messageRule['content'],
+            'message_type' => $messageRule['message_type'],
+            'cover' => $messageRule['cover'],
+            'send_time' => $messageRule['send_time'] ? Carbon::parse($messageRule['send_time'])->toDateTimeString():'',
+            'sent_count' => $messageRule['sent_count'],
+            'open_count' => $messageRule['open_count'],
+            'notice_groups' => $messageRule['notice_groups'],
+            'message_status' => $messageStatus,
+            'message_show_type' => $messageRule['message_show_type'],
+            'activity_time' => $messageRule['activity_time'],
+        ];
+    }
+}

+ 35 - 0
app/Transformers/MessageRuleListTransformer.php

@@ -0,0 +1,35 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019/6/12
+ * Time: 9:15
+ */
+
+namespace App\Transformers;
+
+use App\Models\MessageRule;
+use Illuminate\Support\Carbon;
+use League\Fractal\TransformerAbstract;
+
+class MessageRuleListTransformer extends TransformerAbstract
+{
+    public function transform(MessageRule $messageRule)
+    {
+        $messageStatus = $messageRule['message_status'];
+        if($messageStatus == 0 && $messageRule['send_time'] && $messageRule['send_time'] <= Carbon::now()->toDateTimeString()){
+            $messageStatus = 1;
+        }
+        return [
+            'id' => $messageRule['id'],
+            'title' => $messageRule['title'],
+            'message_type' => $messageRule['message_type'],
+            'cover' => $messageRule['cover'],
+            'updated_at' => Carbon::parse($messageRule['updated_at'])->toDateTimeString(),
+            'sent_count' => $messageRule['sent_count'],
+            'open_count' => $messageRule['open_count'],
+            'notice_groups' => $messageRule['notice_groups'],
+            'message_status' => $messageStatus,
+        ];
+    }
+}

+ 20 - 0
app/Transformers/PlatformContentTransformer.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Transformers;
+
+use App\Models\PlatformContent;
+use League\Fractal\TransformerAbstract;
+
+class PlatformContentTransformer extends TransformerAbstract
+{
+
+    public function transform(PlatformContent $platformContent)
+    {
+        return [
+            'id'  => $platformContent['id'],
+            'title'    => $platformContent['title'],
+            'content'    => $platformContent['content'],
+            'updated_at'    => date($platformContent['updated_at']),
+        ];
+    }
+}

+ 23 - 0
app/Transformers/StarNewsTransformer.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Transformers;
+
+use App\Models\StarNews;
+use League\Fractal\TransformerAbstract;
+
+class StarNewsTransformer extends TransformerAbstract
+{
+
+    public function transform(StarNews $starNews)
+    {
+        return [
+            'id'  => $starNews['id'],
+            'title'    => $starNews['title'],
+            'content'    => $starNews['content'],
+            'cover_img'    => $starNews['cover_img'],
+            'status'    => $starNews['status'],
+            'sort'    => $starNews['sort'],
+            'updated_at'    => date($starNews['updated_at']),
+        ];
+    }
+}

+ 5 - 3
composer.json

@@ -15,12 +15,14 @@
         "laravel/lumen-framework": "5.8.*",
         "tymon/jwt-auth": "1.0.0-rc.4.1",
         "multilinguals/apollo-client": "^0.1.2",
-        "vlucas/phpdotenv": "^3.3"
+        "vlucas/phpdotenv": "^3.3",
+        "php-amqplib/php-amqplib": "^2.9",
+        "guzzlehttp/guzzle": "^6.3"
     },
     "require-dev": {
         "fzaninotto/faker": "^1.4",
-        "phpunit/phpunit": "^7.0",
-        "mockery/mockery": "^1.0"
+        "mockery/mockery": "^1.0",
+        "phpunit/phpunit": "^7.0"
     },
     "autoload": {
         "classmap": [

+ 71 - 0
database/migrations/2019_06_04_060233_create_message_rule.php

@@ -0,0 +1,71 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateMessageRule extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('message_rule', function (Blueprint $table) {
+            $table->bigIncrements('id');
+
+            $table->string('title', 32)
+                ->comment('活动标题');
+
+            $table->string('notice_groups', 32)
+                ->default(0)
+                ->comment('通知群体:0:全部;1:原始用户;2.正式用户');
+
+            $table->string('message_type', 16)
+                ->default('system')
+                ->comment('消息类型:star星球活动消息;system系统通知消息');
+
+            $table->string('show_type', 16)
+                ->default('only_show')
+                ->comment('展示类型:only_show纯展示;user用户;post内容;activity活动;topic话题');
+
+            $table->string('activity_url', 255)
+                ->default('')
+                ->comment('活动链接');
+
+            $table->string('cover', 255)
+                ->default('')
+                ->comment('封面图');
+
+            $table->tinyInteger('status')
+                ->default(0)
+                ->comment('消息状态:0:未发送;1.已发送未隐藏2.已发送并隐藏');
+
+            $table->dateTime('send_time')
+                ->nullable()
+                ->comment('发送时间');
+
+            $table->integer('sent_count')
+                ->default(0)
+                ->comment('已发送数量');
+
+            $table->integer('open_count')
+                ->default(0)
+                ->comment('打开数量');
+
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('config_message');
+    }
+}

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

@@ -0,0 +1,42 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateConfigBannerTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('config_banner', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('name', 20)->nullable()->comment('社区-banner名称');
+            $table->integer('link_content_id')->nullable()->comment('社区-链接内容id:用户/内容/活动/话题ID');
+            $table->string('image', 255)->nullable()->comment('社区-banner图片');
+            $table->tinyInteger('type')->nullable()->comment('社区-banner类型:0.纯展示;1.内容;2.用户;3.活动;4.话题');
+            $table->tinyInteger('use_background')->comment('使用后台:0.CMS;1.社区后台');
+            $table->tinyInteger('is_open')->nullable()->comment('社区-开关状态:0:关闭;1:开启');
+            $table->integer('tpl_id')->nullable()->comment('cms-模板ID');
+            $table->json('rule')->nullable()->comment('cms-设置项');
+            $table->tinyInteger('status')->nullable()->comment('cms-状态:0:草稿;1:发布');
+            $table->tinyInteger('area_type')->nullable()->comment('cms-板块类型:0:banner;1:专题广告;2.商品楼层;3.分类专题(菜市场)');
+            $table->timestamps();
+            $table->softDeletes();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('config_banner');
+    }
+}

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

@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class ModifyStatusToTableMessageRule extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        DB::statement("ALTER TABLE message_rule CHANGE  COLUMN `status` `message_status` TINYINT (4) NOT NULL DEFAULT 0 COMMENT '消息状态:0:未发送,1发送中,2已发送未隐藏,3已发送并隐藏'");
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('table_message_rule', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 35 - 0
database/migrations/2019_06_12_055639_add_acitvity_time_to_table_message_rule.php

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddAcitvityTimeToTableMessageRule extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('message_rule', function (Blueprint $table) {
+            $table->string('activity_time', 32)
+                ->default('')
+                ->after('send_time')
+                ->comment('活动时间');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('message_rule', function (Blueprint $table) {
+            //
+        });
+    }
+}

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

@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class ModifyShowTypeToTableMessageRule extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        DB::statement("ALTER TABLE message_rule CHANGE  COLUMN `show_type` `message_show_type` varchar(16) NOT NULL DEFAULT 'only_show' COMMENT '展示类型:only_show纯展示;user用户;post内容;activity活动;topic话题'");
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('table_message_rule', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 35 - 0
database/migrations/2019_06_12_095415_add_content_to_table_message_rule.php

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddContentToTableMessageRule extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('message_rule', function (Blueprint $table) {
+            $table->string('content', 500)
+                ->default('')
+                ->after('title')
+                ->comment('文字说明');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('message_rule', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 33 - 0
database/migrations/2019_06_12_155904_create_activities_table.php

@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateActivitiesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('activities', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->string('name')->nullable()->comment('名称');
+            $table->text('content')->nullable()->comment('内容');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('activities');
+    }
+}

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

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateStarNewsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('star_news', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->string('title', 30)->comment('新闻标题');
+            $table->string('content', 200)->comment('文字说明');
+            $table->string('cover_img')->comment('封面图');
+            $table->tinyInteger('status')->default(0)->comment('状态: 0.禁用;1.启用');
+            $table->integer('sort')->nullable()->comment('排序');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('star_news');
+    }
+}

+ 33 - 0
database/migrations/2019_06_17_020244_create_platform_content_table.php

@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreatePlatformContentTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('platform_content', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->string('title', 30)->comment('内容名称');
+            $table->text('content')->comment('图文内容');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('platform_content');
+    }
+}

+ 32 - 0
database/migrations/2019_06_17_024434_add_deleted_at_to_star_news_table.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddDeletedAtToStarNewsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('star_news', function (Blueprint $table) {
+            $table->softDeletes();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('star_news', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 1 - 0
database/seeds/DatabaseSeeder.php

@@ -12,5 +12,6 @@ class DatabaseSeeder extends Seeder
     public function run()
     {
         // $this->call('UsersTableSeeder');
+        $this->call('PlatformContentTableSeeder');
     }
 }

+ 62 - 0
database/seeds/PlatformContentTableSeeder.php

@@ -0,0 +1,62 @@
+<?php
+
+use Illuminate\Database\Seeder;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Carbon;
+
+class PlatformContentTableSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        $date = Carbon::now()->toDateTimeString();
+        DB::table('platform_content')->insert([
+            [
+                'title'   => '小贴士',
+                'content'    => '这里有好多好多的内容~',
+                'created_at'    => $date,
+                'updated_at'    => $date
+            ],
+            [
+                'title'   => '彩虹豆介绍',
+                'content'    => '这里有好多好多的内容~',
+                'created_at'    => $date,
+                'updated_at'    => $date
+            ],
+            [
+                'title'   => '什么是彩虹星球',
+                'content'    => '这里有好多好多的内容~',
+                'created_at'    => $date,
+                'updated_at'    => $date
+            ],
+            [
+                'title'   => '教你如何日赚万豆',
+                'content'    => '这里有好多好多的内容~',
+                'created_at'    => $date,
+                'updated_at'    => $date
+            ],
+            [
+                'title'   => '什么是体力值',
+                'content'    => '这里有好多好多的内容~',
+                'created_at'    => $date,
+                'updated_at'    => $date
+            ],
+            [
+                'title'   => '用户协议',
+                'content'    => '这里有好多好多的内容~',
+                'created_at'    => $date,
+                'updated_at'    => $date
+            ],
+            [
+                'title'   => '内容授权协议',
+                'content'    => '这里有好多好多的内容~',
+                'created_at'    => $date,
+                'updated_at'    => $date
+            ],
+        ]);
+    }
+}

+ 1 - 0
deploy/nginx/conf.d/app.beta.conf

@@ -3,6 +3,7 @@ server {
     index index.php index.html;
     error_log  /var/log/nginx/error.log;
     access_log /var/log/nginx/access.log;
+    client_max_body_size 50m;
     root /var/www/public;
     location ~ \.php$ {
         try_files $uri =404;

+ 1 - 0
deploy/nginx/conf.d/app.dev.conf

@@ -4,6 +4,7 @@ server {
     error_log  /var/log/nginx/error.log;
     access_log /var/log/nginx/access.log;
     root /var/www/public;
+    client_max_body_size 50m;
     location ~ \.php$ {
         try_files $uri =404;
         fastcgi_split_path_info ^(.+\.php)(/.+)$;

+ 19 - 0
resources/lang/en/auth.php

@@ -0,0 +1,19 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Authentication Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | The following language lines are used during authentication for various
+    | messages that we need to display to the user. You are free to modify
+    | these language lines according to your application's requirements.
+    |
+    */
+
+    'failed' => 'These credentials do not match our records.',
+    'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
+
+];

+ 19 - 0
resources/lang/en/pagination.php

@@ -0,0 +1,19 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Pagination Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | The following language lines are used by the paginator library to build
+    | the simple pagination links. You are free to change them to anything
+    | you want to customize your views to better match your application.
+    |
+    */
+
+    'previous' => '&laquo; Previous',
+    'next' => 'Next &raquo;',
+
+];

+ 22 - 0
resources/lang/en/passwords.php

@@ -0,0 +1,22 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Password Reset Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | The following language lines are the default lines which match reasons
+    | that are given by the password broker for a password update attempt
+    | has failed, such as for an invalid token or invalid new password.
+    |
+    */
+
+    'password' => 'Passwords must be at least six characters and match the confirmation.',
+    'reset' => 'Your password has been reset!',
+    'sent' => 'We have e-mailed your password reset link!',
+    'token' => 'This password reset token is invalid.',
+    'user' => "We can't find a user with that e-mail address.",
+
+];

+ 146 - 0
resources/lang/en/validation.php

@@ -0,0 +1,146 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Validation Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | The following language lines contain the default error messages used by
+    | the validator class. Some of these rules have multiple versions such
+    | as the size rules. Feel free to tweak each of these messages here.
+    |
+    */
+
+    'accepted'             => 'The :attribute must be accepted.',
+    'active_url'           => 'The :attribute is not a valid URL.',
+    'after'                => 'The :attribute must be a date after :date.',
+    'after_or_equal'       => 'The :attribute must be a date after or equal to :date.',
+    'alpha'                => 'The :attribute may only contain letters.',
+    'alpha_dash'           => 'The :attribute may only contain letters, numbers, dashes and underscores.',
+    'alpha_num'            => 'The :attribute may only contain letters and numbers.',
+    'array'                => 'The :attribute must be an array.',
+    'before'               => 'The :attribute must be a date before :date.',
+    'before_or_equal'      => 'The :attribute must be a date before or equal to :date.',
+    'between'              => [
+        'numeric' => 'The :attribute must be between :min and :max.',
+        'file'    => 'The :attribute must be between :min and :max kilobytes.',
+        'string'  => 'The :attribute must be between :min and :max characters.',
+        'array'   => 'The :attribute must have between :min and :max items.',
+    ],
+    'boolean'              => 'The :attribute field must be true or false.',
+    'confirmed'            => 'The :attribute confirmation does not match.',
+    'date'                 => 'The :attribute is not a valid date.',
+    'date_format'          => 'The :attribute does not match the format :format.',
+    'different'            => 'The :attribute and :other must be different.',
+    'digits'               => 'The :attribute must be :digits digits.',
+    'digits_between'       => 'The :attribute must be between :min and :max digits.',
+    'dimensions'           => 'The :attribute has invalid image dimensions.',
+    'distinct'             => 'The :attribute field has a duplicate value.',
+    'email'                => 'The :attribute must be a valid email address.',
+    'exists'               => 'The selected :attribute is invalid.',
+    'file'                 => 'The :attribute must be a file.',
+    'filled'               => 'The :attribute field must have a value.',
+    'gt'                   => [
+        'numeric' => 'The :attribute must be greater than :value.',
+        'file'    => 'The :attribute must be greater than :value kilobytes.',
+        'string'  => 'The :attribute must be greater than :value characters.',
+        'array'   => 'The :attribute must have more than :value items.',
+    ],
+    'gte'                  => [
+        'numeric' => 'The :attribute must be greater than or equal :value.',
+        'file'    => 'The :attribute must be greater than or equal :value kilobytes.',
+        'string'  => 'The :attribute must be greater than or equal :value characters.',
+        'array'   => 'The :attribute must have :value items or more.',
+    ],
+    'image'                => 'The :attribute must be an image.',
+    'in'                   => 'The selected :attribute is invalid.',
+    'in_array'             => 'The :attribute field does not exist in :other.',
+    'integer'              => 'The :attribute must be an integer.',
+    'ip'                   => 'The :attribute must be a valid IP address.',
+    'ipv4'                 => 'The :attribute must be a valid IPv4 address.',
+    'ipv6'                 => 'The :attribute must be a valid IPv6 address.',
+    'json'                 => 'The :attribute must be a valid JSON string.',
+    'lt'                   => [
+        'numeric' => 'The :attribute must be less than :value.',
+        'file'    => 'The :attribute must be less than :value kilobytes.',
+        'string'  => 'The :attribute must be less than :value characters.',
+        'array'   => 'The :attribute must have less than :value items.',
+    ],
+    'lte'                  => [
+        'numeric' => 'The :attribute must be less than or equal :value.',
+        'file'    => 'The :attribute must be less than or equal :value kilobytes.',
+        'string'  => 'The :attribute must be less than or equal :value characters.',
+        'array'   => 'The :attribute must not have more than :value items.',
+    ],
+    'max'                  => [
+        'numeric' => 'The :attribute may not be greater than :max.',
+        'file'    => 'The :attribute may not be greater than :max kilobytes.',
+        'string'  => 'The :attribute may not be greater than :max characters.',
+        'array'   => 'The :attribute may not have more than :max items.',
+    ],
+    'mimes'                => 'The :attribute must be a file of type: :values.',
+    'mimetypes'            => 'The :attribute must be a file of type: :values.',
+    'min'                  => [
+        'numeric' => 'The :attribute must be at least :min.',
+        'file'    => 'The :attribute must be at least :min kilobytes.',
+        'string'  => 'The :attribute must be at least :min characters.',
+        'array'   => 'The :attribute must have at least :min items.',
+    ],
+    'not_in'               => 'The selected :attribute is invalid.',
+    'not_regex'            => 'The :attribute format is invalid.',
+    'numeric'              => 'The :attribute must be a number.',
+    'present'              => 'The :attribute field must be present.',
+    'regex'                => 'The :attribute format is invalid.',
+    'required'             => 'The :attribute field is required.',
+    'required_if'          => 'The :attribute field is required when :other is :value.',
+    'required_unless'      => 'The :attribute field is required unless :other is in :values.',
+    'required_with'        => 'The :attribute field is required when :values is present.',
+    'required_with_all'    => 'The :attribute field is required when :values is present.',
+    'required_without'     => 'The :attribute field is required when :values is not present.',
+    'required_without_all' => 'The :attribute field is required when none of :values are present.',
+    'same'                 => 'The :attribute and :other must match.',
+    'size'                 => [
+        'numeric' => 'The :attribute must be :size.',
+        'file'    => 'The :attribute must be :size kilobytes.',
+        'string'  => 'The :attribute must be :size characters.',
+        'array'   => 'The :attribute must contain :size items.',
+    ],
+    'string'               => 'The :attribute must be a string.',
+    'timezone'             => 'The :attribute must be a valid zone.',
+    'unique'               => 'The :attribute has already been taken.',
+    'uploaded'             => 'The :attribute failed to upload.',
+    'url'                  => 'The :attribute format is invalid.',
+
+    /*
+    |--------------------------------------------------------------------------
+    | Custom Validation Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | Here you may specify custom validation messages for attributes using the
+    | convention "attribute.rule" to name the lines. This makes it quick to
+    | specify a specific custom language line for a given attribute rule.
+    |
+    */
+
+    'custom' => [
+        'attribute-name' => [
+            'rule-name' => 'custom-message',
+        ],
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Custom Validation Attributes
+    |--------------------------------------------------------------------------
+    |
+    | The following language lines are used to swap attribute place-holders
+    | with something more reader friendly such as E-Mail Address instead
+    | of "email". This simply helps us make messages a little cleaner.
+    |
+    */
+
+    'attributes' => [],
+
+];

+ 17 - 0
resources/lang/zh-CN/auth.php

@@ -0,0 +1,17 @@
+<?php
+
+return [
+    /*
+    |--------------------------------------------------------------------------
+    | Authentication Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | The following language lines are used during authentication for various
+    | messages that we need to display to the user. You are free to modify
+    | these language lines according to your application's requirements.
+    |
+    */
+
+    'failed' => '用户名或密码错误。',
+    'throttle' => '您的尝试登录次数过多,请 :seconds 秒后再试。',
+];

+ 17 - 0
resources/lang/zh-CN/pagination.php

@@ -0,0 +1,17 @@
+<?php
+
+return [
+    /*
+    |--------------------------------------------------------------------------
+    | Pagination Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | The following language lines are used by the paginator library to build
+    | the simple pagination links. You are free to change them to anything
+    | you want to customize your views to better match your application.
+    |
+    */
+
+    'previous' => '&laquo; 上一页',
+    'next' => '下一页 &raquo;',
+];

+ 20 - 0
resources/lang/zh-CN/passwords.php

@@ -0,0 +1,20 @@
+<?php
+
+return [
+    /*
+    |--------------------------------------------------------------------------
+    | Password Reminder Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | The following language lines are the default lines which match reasons
+    | that are given by the password broker for a password update attempt
+    | has failed, such as for an invalid token or invalid new password.
+    |
+    */
+
+    'password' => '密码至少是六位字符并且匹配。',
+    'reset' => '密码重置成功!',
+    'sent' => '密码重置邮件已发送!',
+    'token' => '密码重置令牌无效。',
+    'user' => '找不到该邮箱对应的用户。',
+];

+ 114 - 0
resources/lang/zh-CN/validation.php

@@ -0,0 +1,114 @@
+<?php
+
+return [
+    /*
+    |--------------------------------------------------------------------------
+    | Validation Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | The following language lines contain the default error messages used by
+    | the validator class. Some of these rules have multiple versions such
+    | as the size rules. Feel free to tweak each of these messages.
+    |
+    */
+
+    'accepted' => ':attribute 必须接受。',
+    'active_url' => ':attribute 不是一个有效的网址。',
+    'after' => ':attribute 必须要晚于 :date。',
+    'after_or_equal' => ':attribute 必须要等于 :date 或更晚。',
+    'alpha' => ':attribute 只能由字母组成。',
+    'alpha_dash' => ':attribute 只能由字母、数字和斜杠组成。',
+    'alpha_num' => ':attribute 只能由字母和数字组成。',
+    'array' => ':attribute 必须是一个数组。',
+    'before' => ':attribute 必须要早于 :date。',
+    'before_or_equal' => ':attribute 必须要等于 :date 或更早。',
+    'between' => [
+        'numeric' => ':attribute 必须介于 :min - :max 之间。',
+        'file' => ':attribute 必须介于 :min - :max kb 之间。',
+        'string' => ':attribute 必须介于 :min - :max 个字符之间。',
+        'array' => ':attribute 必须只有 :min - :max 个单元。',
+    ],
+    'boolean' => ':attribute 必须为布尔值。',
+    'confirmed' => ':attribute 两次输入不一致。',
+    'date' => ':attribute 不是一个有效的日期。',
+    'date_format' => ':attribute 的格式必须为 :format。',
+    'different' => ':attribute 和 :other 必须不同。',
+    'digits' => ':attribute 必须是 :digits 位的数字。',
+    'digits_between' => ':attribute 必须是介于 :min 和 :max 位的数字。',
+    'dimensions' => ':attribute 图片尺寸不正确。',
+    'distinct' => ':attribute 已经存在。',
+    'email' => ':attribute 不是一个合法的邮箱。',
+    'exists' => ':attribute 不存在。',
+    'file' => ':attribute 必须是文件。',
+    'filled' => ':attribute 不能为空。',
+    'image' => ':attribute 必须是图片。',
+    'in' => '已选的属性 :attribute 非法。',
+    'in_array' => ':attribute 没有在 :other 中。',
+    'integer' => ':attribute 必须是整数。',
+    'ip' => ':attribute 必须是有效的 IP 地址。',
+    'ipv4' => ':attribute 必须是有效的 IPv4 地址。',
+    'ipv6' => ':attribute 必须是有效的 IPv6 地址。',
+    'json' => ':attribute 必须是正确的 JSON 格式。',
+    'max' => [
+        'numeric' => ':attribute 不能大于 :max。',
+        'file' => ':attribute 不能大于 :max kb。',
+        'string' => ':attribute 不能大于 :max 个字符。',
+        'array' => ':attribute 最多只有 :max 个单元。',
+    ],
+    'mimes' => ':attribute 必须是一个 :values 类型的文件。',
+    'mimetypes' => ':attribute 必须是一个 :values 类型的文件。',
+    'min' => [
+        'numeric' => ':attribute 必须大于等于 :min。',
+        'file' => ':attribute 大小不能小于 :min kb。',
+        'string' => ':attribute 至少为 :min 个字符。',
+        'array' => ':attribute 至少有 :min 个单元。',
+    ],
+    'not_in' => '已选的属性 :attribute 非法。',
+    'numeric' => ':attribute 必须是一个数字。',
+    'present' => ':attribute 必须存在。',
+    'regex' => ':attribute 格式不正确。',
+    'required' => ':attribute 不能为空。',
+    'required_if' => '当 :other 为 :value 时 :attribute 不能为空。',
+    'required_unless' => '当 :other 不为 :value 时 :attribute 不能为空。',
+    'required_with' => '当 :values 存在时 :attribute 不能为空。',
+    'required_with_all' => '当 :values 存在时 :attribute 不能为空。',
+    'required_without' => '当 :values 不存在时 :attribute 不能为空。',
+    'required_without_all' => '当 :values 都不存在时 :attribute 不能为空。',
+    'same' => ':attribute 和 :other 必须相同。',
+    'size' => [
+        'numeric' => ':attribute 大小必须为 :size。',
+        'file' => ':attribute 大小必须为 :size kb。',
+        'string' => ':attribute 必须是 :size 个字符。',
+        'array' => ':attribute 必须为 :size 个单元。',
+    ],
+    'string' => ':attribute 必须是一个字符串。',
+    'timezone' => ':attribute 必须是一个合法的时区值。',
+    'unique' => ':attribute 已经存在。',
+    'uploaded' => ':attribute 上传失败。',
+    'url' => ':attribute 格式不正确。',
+
+
+    /*
+    |--------------------------------------------------------------------------
+    | Custom Validation Attributes
+    |--------------------------------------------------------------------------
+    |
+    | The following language lines are used to swap attribute place-holders
+    | with something more reader friendly such as E-Mail Address instead
+    | of 'email'. This simply helps us make messages a little cleaner.
+    |
+    */
+
+    'attributes' => [
+        'title' => '标题',
+        'content' => '内容',
+        'notice_groups' => '通知群体',
+        'message_type' => '消息类型',
+        'message_show_type' => '展示类型',
+        'activity_url' => '活动链接',
+        'cover' => '封面图',
+        'send_time' => '发送时间',
+        'activity_time' => '活动时间',
+    ],
+
+];

+ 66 - 3
routes/api.php

@@ -19,12 +19,14 @@ $api->version('v1', [
     //百度编辑器
     $api->get('ueupload', 'UeditorController@index');
     $api->post('ueupload', 'UeditorController@index');
-    //上传
-    $api->post('upload', 'UploadController@uploadImage');
-    $api->post('multi_upload', 'UploadController@uploadImages');
+
     $api->group(['middleware' => 'jwt.chxq_auth'], function ($api) {
         $api->get('user', 'UserController@index');
 
+        //上传
+        $api->post('upload', 'UploadController@uploadImage');
+        $api->post('multi_upload', 'UploadController@uploadImages');
+
         //自提点列表
         $api->get('/pickupNode/index', 'ConfigPickupNodeController@index');
         //自提点新建
@@ -54,7 +56,68 @@ $api->version('v1', [
         //新增城市
         $api->post('/cityManagement/create', 'ConfigCityManagementController@create');
 
+        //消息规则列表
+        $api->get('message', 'MessageRuleController@index');
+        //创建消息规则
+        $api->post('message', 'MessageRuleController@create');
+        //编辑消息规则
+        $api->put('message', 'MessageRuleController@update');
+        //消息规则详情
+        $api->get('message/detail', 'MessageRuleController@detail');
+        //发送消息规则
+        $api->put('message/send', 'MessageRuleController@send');
+        //隐藏消息规则
+        $api->put('message/hide', 'MessageRuleController@hide');
+
     });
     //配置文件
     $api->get('/config', 'ConfigController@index');
+});
+
+$api->version('v1', [
+    'namespace' => 'App\Http\Controllers\V2',
+], function ($api) {
+
+    $api->group([
+        'prefix' => 'v2'
+    ], function ($api) {
+        $api->group(['middleware' => 'jwt.chxq_auth'], function ($api) {
+            //banner列表
+            $api->get('/bannerSet/lists', 'BannerController@lists');
+            //新增banner
+            $api->post('/bannerSet', 'BannerController@bannerSet');
+            //编辑banner
+            $api->put('/bannerSet/edit', 'BannerController@edit');
+            //删除banner
+            $api->delete('/bannerSet/delete', 'BannerController@bannerDelete');
+            //修改banner状态
+            $api->put('/bannerSet/editStatus', 'BannerController@editStatus');
+            //活动列表
+            $api->get('activitiesIndex', 'ActivitiesController@index');
+            //活动添加
+            $api->post('activitiesCreate', 'ActivitiesController@create');
+            //活动编辑
+            $api->put('activitiesEdit', 'ActivitiesController@edit');
+            //活动详情
+            $api->get('activitiesView', 'ActivitiesController@view');
+
+            //星球新闻列表
+            $api->get('/starNews/lists', 'StarNewsController@index');
+            //新增星球新闻
+            $api->post('/starNews/create', 'StarNewsController@create');
+            //编辑星球新闻
+            $api->put('/starNews/create', 'StarNewsController@edit');
+            //修改星球新闻状态
+            $api->put('/starNews/editStatus', 'StarNewsController@editStatus');
+            //删除星球新闻
+            $api->delete('/starNews/delete', 'StarNewsController@delete');
+
+            //平台内容列表
+            $api->get('/platformContent/lists', 'PlatformContentController@index');
+            //新增平台内容
+            $api->post('/platformContent/create', 'PlatformContentController@create');
+            //编辑平台内容
+            $api->put('/platformContent/create', 'PlatformContentController@edit');
+        });
+    });
 });