diff --git a/composer.json b/composer.json index 28a82f5..e4910e8 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,8 @@ "preferred-install": "dist", "sort-packages": true, "allow-plugins": { - "easywechat-composer/easywechat-composer": true + "easywechat-composer/easywechat-composer": true, + "joshbrw/laravel-module-installer": true } }, "extra": { diff --git a/composer.lock b/composer.lock index 132be3d..aa68954 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,59 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "45f31b9b608c75013e7dc35bd97f7160", + "content-hash": "c9605f626936e8a5a7288c3bb2f5cc37", "packages": [ + { + "name": "aliyuncs/oss-sdk-php", + "version": "v2.6.0", + "source": { + "type": "git", + "url": "https://github.com/aliyun/aliyun-oss-php-sdk.git", + "reference": "572d0f8e099e8630ae7139ed3fdedb926c7a760f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/572d0f8e099e8630ae7139ed3fdedb926c7a760f", + "reference": "572d0f8e099e8630ae7139ed3fdedb926c7a760f", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "*", + "satooshi/php-coveralls": "*" + }, + "type": "library", + "autoload": { + "psr-4": { + "OSS\\": "src/OSS" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aliyuncs", + "homepage": "http://www.aliyun.com" + } + ], + "description": "Aliyun OSS SDK for PHP", + "homepage": "http://www.aliyun.com/product/oss/", + "support": { + "issues": "https://github.com/aliyun/aliyun-oss-php-sdk/issues", + "source": "https://github.com/aliyun/aliyun-oss-php-sdk/tree/v2.6.0" + }, + "time": "2022-08-03T08:06:01+00:00" + }, { "name": "asm89/stack-cors", "version": "v2.1.1", @@ -2298,6 +2349,213 @@ }, "time": "2020-11-26T19:24:33+00:00" }, + { + "name": "iidestiny/flysystem-oss", + "version": "2.7", + "source": { + "type": "git", + "url": "https://github.com/iiDestiny/flysystem-oss.git", + "reference": "c943ce550e973129955275bb17e8182fe8a74020" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/iiDestiny/flysystem-oss/zipball/c943ce550e973129955275bb17e8182fe8a74020", + "reference": "c943ce550e973129955275bb17e8182fe8a74020", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "aliyuncs/oss-sdk-php": "^2.4", + "ext-curl": "*", + "ext-json": "*", + "ext-openssl": "*", + "league/flysystem": "^1.0", + "nesbot/carbon": "^1.24.1 || ^2.0", + "php": "^7.0 || ^8.0" + }, + "require-dev": { + "mockery/mockery": "^1.2", + "phpunit/phpunit": "^6.5", + "symfony/var-dumper": "^3.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Iidestiny\\Flysystem\\Oss\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "iidestiny", + "email": "iidestiny@vip.qq.com" + } + ], + "description": "Flysystem adapter for the Oss storage.", + "keywords": [ + "alioss", + "laravel", + "oss", + "阿里oss" + ], + "support": { + "issues": "https://github.com/iiDestiny/flysystem-oss/issues", + "source": "https://github.com/iiDestiny/flysystem-oss/tree/2.7" + }, + "time": "2021-06-14T10:18:58+00:00" + }, + { + "name": "iidestiny/laravel-filesystem-oss", + "version": "2.1", + "source": { + "type": "git", + "url": "https://github.com/iiDestiny/laravel-filesystem-oss.git", + "reference": "ae3cd6fd3cd727eedda0e2bcd0403a6d79fe4223" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/iiDestiny/laravel-filesystem-oss/zipball/ae3cd6fd3cd727eedda0e2bcd0403a6d79fe4223", + "reference": "ae3cd6fd3cd727eedda0e2bcd0403a6d79fe4223", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "iidestiny/flysystem-oss": "~2.0", + "php": "^7.0|^8.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Iidestiny\\LaravelFilesystemOss\\OssStorageServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Iidestiny\\LaravelFilesystemOss\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "iidestiny", + "email": "iidestiny@vip.qq.com" + } + ], + "description": "Oss storage filesystem for Laravel.", + "support": { + "issues": "https://github.com/iiDestiny/laravel-filesystem-oss/issues", + "source": "https://github.com/iiDestiny/laravel-filesystem-oss/tree/2.1" + }, + "time": "2020-11-30T06:17:22+00:00" + }, + { + "name": "intervention/image", + "version": "2.7.2", + "source": { + "type": "git", + "url": "https://github.com/Intervention/image.git", + "reference": "04be355f8d6734c826045d02a1079ad658322dad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Intervention/image/zipball/04be355f8d6734c826045d02a1079ad658322dad", + "reference": "04be355f8d6734c826045d02a1079ad658322dad", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "ext-fileinfo": "*", + "guzzlehttp/psr7": "~1.1 || ^2.0", + "php": ">=5.4.0" + }, + "require-dev": { + "mockery/mockery": "~0.9.2", + "phpunit/phpunit": "^4.8 || ^5.7 || ^7.5.15" + }, + "suggest": { + "ext-gd": "to use GD library based image processing.", + "ext-imagick": "to use Imagick based image processing.", + "intervention/imagecache": "Caching extension for the Intervention Image library" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + }, + "laravel": { + "providers": [ + "Intervention\\Image\\ImageServiceProvider" + ], + "aliases": { + "Image": "Intervention\\Image\\Facades\\Image" + } + } + }, + "autoload": { + "psr-4": { + "Intervention\\Image\\": "src/Intervention/Image" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oliver Vogel", + "email": "oliver@intervention.io", + "homepage": "https://intervention.io/" + } + ], + "description": "Image handling and manipulation library with support for Laravel integration", + "homepage": "http://image.intervention.io/", + "keywords": [ + "gd", + "image", + "imagick", + "laravel", + "thumbnail", + "watermark" + ], + "support": { + "issues": "https://github.com/Intervention/image/issues", + "source": "https://github.com/Intervention/image/tree/2.7.2" + }, + "funding": [ + { + "url": "https://paypal.me/interventionio", + "type": "custom" + }, + { + "url": "https://github.com/Intervention", + "type": "github" + } + ], + "time": "2022-05-21T17:30:32+00:00" + }, { "name": "jasonc/api", "version": "5.0.5", @@ -2357,6 +2615,119 @@ }, "time": "2022-01-25T02:15:36+00:00" }, + { + "name": "joshbrw/laravel-module-installer", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/joshbrw/laravel-module-installer.git", + "reference": "667820efd0652df8ed61420cd0dec8df1b3ecdd2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joshbrw/laravel-module-installer/zipball/667820efd0652df8ed61420cd0dec8df1b3ecdd2", + "reference": "667820efd0652df8ed61420cd0dec8df1b3ecdd2", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "7.* || 8.*" + }, + "require-dev": { + "composer/composer": "^2.0", + "mockery/mockery": "~1.0", + "phpunit/phpunit": "~8.0 || ~9.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Joshbrw\\LaravelModuleInstaller\\LaravelModuleInstallerPlugin" + }, + "autoload": { + "psr-4": { + "Joshbrw\\LaravelModuleInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "support": { + "issues": "https://github.com/joshbrw/laravel-module-installer/issues", + "source": "https://github.com/joshbrw/laravel-module-installer/tree/v2.0.1" + }, + "time": "2021-01-17T21:51:00+00:00" + }, + { + "name": "laravel-admin-ext/grid-lightbox", + "version": "v1.0.3", + "source": { + "type": "git", + "url": "https://github.com/laravel-admin-extensions/grid-lightbox.git", + "reference": "f8a247f0d017eb05830cc720fb621401b1bfbc2c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel-admin-extensions/grid-lightbox/zipball/f8a247f0d017eb05830cc720fb621401b1bfbc2c", + "reference": "f8a247f0d017eb05830cc720fb621401b1bfbc2c", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "encore/laravel-admin": "~1.6", + "php": ">=7.0.0" + }, + "require-dev": { + "phpunit/phpunit": "~6.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Encore\\Grid\\Lightbox\\LightboxServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Encore\\Grid\\Lightbox\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "song", + "email": "zosong@126.com" + } + ], + "description": "Turn your grid into a lightbox & gallery", + "homepage": "https://github.com/laravel-admin-ext/grid-lightbox", + "keywords": [ + "extension", + "gallery", + "grid", + "laravel-admin", + "lightbox" + ], + "support": { + "issues": "https://github.com/laravel-admin-extensions/grid-lightbox/issues", + "source": "https://github.com/laravel-admin-extensions/grid-lightbox/tree/v1.0.3" + }, + "time": "2019-10-11T06:38:51+00:00" + }, { "name": "laravel-lang/lang", "version": "10.9.5", @@ -3119,6 +3490,53 @@ ], "time": "2022-04-17T13:12:02+00:00" }, + { + "name": "liuhelong/laravel-admin-wechat", + "version": "1.4.1", + "source": { + "type": "git", + "url": "https://gitee.com/liuhelong/laravel-admin-wechat", + "reference": "47ba2e90cba38126baf3395e3e43555c4a7010c2" + }, + "require": { + "encore/laravel-admin": "~1.8", + "overtrue/laravel-wechat": ">=5", + "php": ">=7.0.0" + }, + "require-dev": { + "phpunit/phpunit": "~6.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Liuhelong\\LaravelAdmin\\Wechat\\LaravelAdminWechatServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Liuhelong\\LaravelAdmin\\Wechat\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "liuhelong", + "email": "854583481@qq.com" + } + ], + "description": "description...", + "homepage": "https://github.com/Liuhelong/LaravelAdminWechat", + "keywords": [ + "extension", + "laravel-admin" + ], + "time": "2022-12-10T06:20:42+00:00" + }, { "name": "maatwebsite/excel", "version": "3.1.48", @@ -4129,6 +4547,63 @@ }, "time": "2022-01-27T09:35:39+00:00" }, + { + "name": "overtrue/chinese-calendar", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/overtrue/chinese-calendar.git", + "reference": "d78e86d66a4b225defac6828bf1de42c4a9d4bdf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/overtrue/chinese-calendar/zipball/d78e86d66a4b225defac6828bf1de42c4a9d4bdf", + "reference": "d78e86d66a4b225defac6828bf1de42c4a9d4bdf", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=5.5.9" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Overtrue\\ChineseCalendar\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "overtrue", + "email": "anzhengchao@gmail.com" + } + ], + "description": "中国农历转换与查询工具", + "keywords": [ + "Chinese", + "calendar", + "lunar", + "lunar2solar", + "solar", + "solar2lunar" + ], + "support": { + "issues": "https://github.com/overtrue/chinese-calendar/issues", + "source": "https://github.com/overtrue/chinese-calendar/tree/master" + }, + "time": "2020-03-09T07:21:26+00:00" + }, { "name": "overtrue/easy-sms", "version": "2.3.1", @@ -8989,6 +9464,94 @@ ], "time": "2023-02-21T19:46:44+00:00" }, + { + "name": "symfony/workflow", + "version": "v5.4.21", + "source": { + "type": "git", + "url": "https://github.com/symfony/workflow.git", + "reference": "96ec1843a27c7d3574bd521b807aa18101e31764" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/workflow/zipball/96ec1843a27c7d3574bd521b807aa18101e31764", + "reference": "96ec1843a27c7d3574bd521b807aa18101e31764", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.15" + }, + "conflict": { + "symfony/event-dispatcher": "<4.4" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/event-dispatcher": "^4.4|^5.0|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/security-core": "^4.4|^5.0|^6.0", + "symfony/validator": "^4.4|^5.0|^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Workflow\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Grégoire Pineau", + "email": "lyrixx@lyrixx.info" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools for managing a workflow or finite state machine", + "homepage": "https://symfony.com", + "keywords": [ + "petrinet", + "place", + "state", + "statemachine", + "transition", + "workflow" + ], + "support": { + "source": "https://github.com/symfony/workflow/tree/v5.4.21" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-02-24T08:13:13+00:00" + }, { "name": "tijsverkoyen/css-to-inline-styles", "version": "2.2.6", @@ -10154,16 +10717,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.11.0", + "version": "1.11.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", "shasum": "", "mirrors": [ { @@ -10207,7 +10770,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" }, "funding": [ { @@ -10215,7 +10778,7 @@ "type": "tidelift" } ], - "time": "2022-03-03T13:19:32+00:00" + "time": "2023-03-08T13:26:56+00:00" }, { "name": "nikic/php-parser", diff --git a/config/favorite.php b/config/favorite.php new file mode 100644 index 0000000..0bc6e39 --- /dev/null +++ b/config/favorite.php @@ -0,0 +1,23 @@ + false, + + /* + * User tables foreign key name. + */ + 'user_foreign_key' => 'user_id', + + /* + * Table name for favorites records. + */ + 'favorites_table' => 'favorites', + + /* + * Model name for favorite record. + */ + 'favorite_model' => 'Overtrue\LaravelFavorite\Favorite', +]; diff --git a/config/subscribe.php b/config/subscribe.php new file mode 100644 index 0000000..72e173c --- /dev/null +++ b/config/subscribe.php @@ -0,0 +1,23 @@ + false, + + /* + * User tables foreign key name. + */ + 'user_foreign_key' => 'user_id', + + /* + * Table name for subscriptions records. + */ + 'subscriptions_table' => 'subscriptions', + + /* + * Model name for Subscribe record. + */ + 'subscription_model' => \Overtrue\LaravelSubscribe\Subscription::class, +]; diff --git a/modules/Mall/Http/Controllers/Api/IndexController.php b/modules/Mall/Http/Controllers/Api/IndexController.php index e9b796f..e396571 100644 --- a/modules/Mall/Http/Controllers/Api/IndexController.php +++ b/modules/Mall/Http/Controllers/Api/IndexController.php @@ -28,8 +28,6 @@ class IndexController extends Controller public function index(): JsonResponse { $banners = Banner::query()->ofPosition(Banner::POSITION_INDEX)->get(); - $centers = Banner::query()->ofPosition(Banner::POSITION_INDEX_CENTER)->get(); - $show_goods_id = app('Conf_mall')['show_goods_id'] ?? 0; $show_goods = ''; @@ -79,15 +77,13 @@ class IndexController extends Controller ->get(); $data = [ - 'show_goods' => $show_goods ? new GoodsBaseResource($show_goods) : '', - 'videos' => VideoResource::collection($videos), - 'goods' => GoodsBaseResource::collection($goods), - 'banners' => BannerResource::collection($banners), - 'center' => BannerResource::collection($centers), - 'memories' => $memoriesData, - 'healths' => ArticleBaseResource::collection($healths), - 'water_mobile' => app('Conf_mall')['water_mobile'] ?? '', - 'categories' => [ + 'show_goods' => $show_goods ? new GoodsBaseResource($show_goods) : '', + 'videos' => VideoResource::collection($videos), + 'goods' => GoodsBaseResource::collection($goods), + 'banners' => BannerResource::collection($banners), + 'memories' => $memoriesData, + 'healths' => ArticleBaseResource::collection($healths), + 'categories' => [ 'memory' => Category::query()->where('slug', 'MEMORY')->value('id') ?? 0, 'health' => Category::query()->where('slug', 'HEALTH')->value('id') ?? 0, ], diff --git a/modules/Mall/Models/Banner.php b/modules/Mall/Models/Banner.php index 89974d5..9ab097e 100644 --- a/modules/Mall/Models/Banner.php +++ b/modules/Mall/Models/Banner.php @@ -25,7 +25,6 @@ class Banner extends Model public array $position_map = [ self::POSITION_INDEX => '首页顶部', - self::POSITION_INDEX_CENTER => '体检官介绍', ]; protected $table = 'mall_banners'; diff --git a/modules/User/Http/Controllers/Admin/IdentitiesController.php b/modules/User/Http/Controllers/Admin/IdentitiesController.php index d6893a0..058ed70 100644 --- a/modules/User/Http/Controllers/Admin/IdentitiesController.php +++ b/modules/User/Http/Controllers/Admin/IdentitiesController.php @@ -40,7 +40,7 @@ class IdentitiesController extends AdminController $grid->column('id', '#ID#'); $grid->column('cover', '展示图片')->image('', 40); $grid->column('name', '身份名称'); - $grid->column('order', '排序'); + $grid->column('order', '排序')->editable(); $grid->column('status', '状态')->bool(); $grid->column('serial_open', '是否开启编号')->bool(); $grid->column('serial_places', '编号长度'); diff --git a/modules/User/Http/Controllers/Admin/IndexController.php b/modules/User/Http/Controllers/Admin/IndexController.php index 06e1b9a..d302a8d 100644 --- a/modules/User/Http/Controllers/Admin/IndexController.php +++ b/modules/User/Http/Controllers/Admin/IndexController.php @@ -98,10 +98,10 @@ class IndexController extends AdminController return $this->isOfficialSubscribe(); }) ->bool(); - $grid->column('邀请码') - ->display(function () { - return Hashids::connection('code')->encode($this->id); - }); +// $grid->column('邀请码') +// ->display(function () { +// return Hashids::connection('code')->encode($this->id); +// }); $grid->column('created_at', '注册时间'); return $grid; diff --git a/modules/User/Http/Controllers/Api/Identity/IndexController.php b/modules/User/Http/Controllers/Api/Identity/IndexController.php index a2f18e6..e069300 100644 --- a/modules/User/Http/Controllers/Api/Identity/IndexController.php +++ b/modules/User/Http/Controllers/Api/Identity/IndexController.php @@ -9,9 +9,12 @@ use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Jason\Api\Api; use Modules\User\Http\Resources\IdentityMiddleResource; +use Modules\User\Http\Resources\UserAndIdentityResource; +use Modules\User\Http\Resources\UserIdentityBaseResource; use Modules\User\Http\Resources\UserIdentityResource; use Modules\User\Models\Identity; use Modules\User\Models\Order; +use Modules\User\Models\User; use Validator; class IndexController extends Controller @@ -19,20 +22,17 @@ class IndexController extends Controller public function index(): JsonResponse { - - $type = $request->type ?? ''; $user = Api::user(); - $list = Identity::where('order', '>', 1)->where('can_buy', 1)->get(); + $list = Identity::where('can_buy', 1)->get(); + $vips = User::query() + ->whereHas('identities', function ($q) { + $q->where('order', '>', 1); + }) + ->take(10) + ->get(); $data = [ - 'user' => [ - 'username' => $user->username, - 'nickname' => $user->info->nickname, - 'avatar' => $user->info->avatar, - 'identity' => $user->identities->count() - ? new IdentityMiddleResource($user->identityMiddle()->first()) - : '', - ], - 'identities' => UserIdentityResource::collection($list), + 'vips' => UserAndIdentityResource::collection($vips), + 'identities' => UserIdentityBaseResource::collection($list), ]; return $this->success($data); diff --git a/modules/User/Http/Resources/IdentityMiddleResource.php b/modules/User/Http/Resources/IdentityMiddleResource.php index 8d48345..00454c2 100644 --- a/modules/User/Http/Resources/IdentityMiddleResource.php +++ b/modules/User/Http/Resources/IdentityMiddleResource.php @@ -19,7 +19,7 @@ class IdentityMiddleResource extends JsonResource return [ 'name' => $this->identity->name, 'serial' => $this->identity->serial_prefix.$this->serial, - 'started_at' => $this->started_at ?? '', + 'started_at' => (string)$this->started_at ?? '', 'ended_at' => $ended_at, ]; } diff --git a/modules/User/Http/Resources/UserIdentityBaseResource.php b/modules/User/Http/Resources/UserIdentityBaseResource.php index a7cf4d4..12661b5 100644 --- a/modules/User/Http/Resources/UserIdentityBaseResource.php +++ b/modules/User/Http/Resources/UserIdentityBaseResource.php @@ -10,10 +10,17 @@ class UserIdentityBaseResource extends JsonResource public function toArray($request): array { return [ - 'id' => $this->id, - 'name' => $this->name, - 'cover' => $this->cover_url, - 'order' => $this->order, + 'id' => $this->id, + 'name' => $this->name, + 'cover' => $this->cover_url, + 'order' => $this->order, + 'stock' => $this->stock,//多少箱 + 'bottle' => bcmul($this->stock, 24),//多少瓶 + 'price' => $this->getCondition('price', 0),//多少钱 + 'rights' => $this->rights,//可享受权益 + 'rules' => $this->getRules(),//身份权益 + 'not_rules' => $this->getNotRules(), + ]; } diff --git a/modules/User/Models/Identity.php b/modules/User/Models/Identity.php index ab8ecf1..6a6f82e 100644 --- a/modules/User/Models/Identity.php +++ b/modules/User/Models/Identity.php @@ -140,11 +140,11 @@ class Identity extends Model public function getNotRules() { $rules = $this->rules; - if ($this->job == Identity::JOB_JK) { + if (in_array($this->job, [Identity::JOB_YK, Identity::JOB_JK, Identity::JOB_NK])) { return [ 'give_crystal' => [ - 'cover' => $this->getRuleIcon('give_crystal'), - 'value' => $this->getRule('give_crystal'), + 'cover' => $this->getRuleIcon('give_crystal', ''), + 'value' => $this->getRule('give_crystal', 0), 'text' => '赠送水滴' ], 'stock' => [ @@ -158,19 +158,6 @@ class Identity extends Model ]; } - if ($this->job == Identity::JOB_NK) { - return [ - 'stock' => [ - 'value' => $this->stock, - 'text' => "赠送{$this->stock}箱水" - ], - 'year' => [ - 'value' => $this->years, - 'text' => $this->years."个月有效期" - ], - ]; - } - return $rules; } diff --git a/modules/User/Routes/api.php b/modules/User/Routes/api.php index 3199661..dd5e8d2 100644 --- a/modules/User/Routes/api.php +++ b/modules/User/Routes/api.php @@ -72,8 +72,6 @@ Route::group([ 'prefix' => 'identities', 'middleware' => config('api.route.middleware_auth'), ], function (Router $router) { - $router->get('', 'IndexController@index'); -// $router->get('{identity}', 'IndexController@show'); $router->get('create/{identity}', 'IndexController@create'); $router->post('create/{identity}', 'IndexController@store'); //获取支付数据 @@ -85,6 +83,7 @@ Route::group([ 'prefix' => 'identities', 'middleware' => config('api.route.middleware_guess'), ], function (Router $router) { + $router->get('', 'IndexController@index'); $router->get('{identity}', 'IndexController@show'); }); Route::group([