Ver código fonte

优化角色查询

songdb 4 anos atrás
pai
commit
05e0a9a0e8

+ 2 - 1
app/Http/Controllers/Wechat/OfficialAccount/OfficialInteractiveEventController.php

@@ -217,7 +217,8 @@ class OfficialInteractiveEventController extends Controller
                 $booksInfo = BookConfig::getBooksByKey($content, 1);
                 try {
                     if (count($booksInfo) == 0) {
-                        $role_book = BookConfig::getFromRole($content);
+                        //$role_book = BookConfig::getFromRole($content);
+                        $role_book = BookConfigService::getBookByRole($content);
                         if ($role_book) {
                             $booksInfo[] = [
                                 'book_name' => $role_book->book_name,

+ 7 - 0
app/Modules/Book/Models/BookConfig.php

@@ -1244,4 +1244,11 @@ class BookConfig extends Model
         \Log::info('last_bids:' . json_encode($last_bids));
         return [$last_bids, $test_bid];
     }
+
+    //获取图书
+    public static function getSimpleBooksByIds($bids)
+    {
+        $fields = ['book_name','bid','cover'];
+        return self::select($fields)->whereIn('id',$bids)->where('is_on_shelf',2)->order('id','desc')->get();
+    }
 }

+ 19 - 0
app/Modules/Book/Services/BookConfigService.php

@@ -10,6 +10,7 @@ namespace App\Modules\Book\Services;
 
 
 use App\Modules\Book\Models\BookConfig;
+use App\Modules\Book\Models\BookRole;
 use App\Modules\Product\Services\ProductService;
 use App\Modules\Book\Models\Book;
 use Redis;
@@ -31,6 +32,24 @@ class BookConfigService
     }
 
     /**
+     * 获取角色图书
+     */
+    public static function getBookByRole($role)
+    {
+        $book = [];
+        if($role)
+        {
+            $bids = BookRole::getBidByRole($role);
+            if($bids)
+            {
+                $books = BookConfig::getSimpleBooksByIds($bids);
+                $books && $book = array_shift($books);
+            }
+        }
+        return $book;
+    }
+
+    /**
      * 根据bid数组获取多本图书
      * @param $where
      * @param null $order

+ 1 - 26
readme.md

@@ -1,27 +1,2 @@
-## Laravel PHP Framework
+# wangdu_modify_wechat
 
-[![Build Status](https://travis-ci.org/laravel/framework.svg)](https://travis-ci.org/laravel/framework)
-[![Total Downloads](https://poser.pugx.org/laravel/framework/d/total.svg)](https://packagist.org/packages/laravel/framework)
-[![Latest Stable Version](https://poser.pugx.org/laravel/framework/v/stable.svg)](https://packagist.org/packages/laravel/framework)
-[![Latest Unstable Version](https://poser.pugx.org/laravel/framework/v/unstable.svg)](https://packagist.org/packages/laravel/framework)
-[![License](https://poser.pugx.org/laravel/framework/license.svg)](https://packagist.org/packages/laravel/framework)
-
-Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, queueing, and caching.
-
-Laravel is accessible, yet powerful, providing powerful tools needed for large, robust applications. A superb inversion of control container, expressive migration system, and tightly integrated unit testing support give you the tools you need to build any application with which you are tasked.
-
-## Official Documentation
-
-Documentation for the framework can be found on the [Laravel website](http://laravel.com/docs).
-
-## Contributing
-
-Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions).
-
-## Security Vulnerabilities
-
-If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed.
-
-### License
-
-The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)