调整开通身份
This commit is contained in:
@@ -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,
|
||||
],
|
||||
|
||||
@@ -25,7 +25,6 @@ class Banner extends Model
|
||||
|
||||
public array $position_map = [
|
||||
self::POSITION_INDEX => '首页顶部',
|
||||
self::POSITION_INDEX_CENTER => '体检官介绍',
|
||||
];
|
||||
|
||||
protected $table = 'mall_banners';
|
||||
|
||||
@@ -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', '编号长度');
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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([
|
||||
|
||||
Reference in New Issue
Block a user