阶段更新
This commit is contained in:
@@ -4,15 +4,10 @@ namespace Modules\User\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Jason\Api\Api;
|
||||
use Modules\Coupon\Models\Coupon;
|
||||
use Modules\Coupon\Traits\WithCoupon;
|
||||
use Modules\User\Models\Identity;
|
||||
use Modules\User\Models\Order;
|
||||
|
||||
class UserIdentityResource extends JsonResource
|
||||
{
|
||||
use WithCoupon;
|
||||
|
||||
public function toArray($request): array
|
||||
{
|
||||
$user = Api::user();
|
||||
@@ -44,36 +39,17 @@ class UserIdentityResource extends JsonResource
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($this->job == Identity::JOB_JK) {
|
||||
$openIdentity = Identity::find($this->id);
|
||||
$coupons = $this->getCreateOrderCoupon($user, $openIdentity, 0);
|
||||
if ($coupons->isNotEmpty()) {
|
||||
$user_coupon = $coupons->first();
|
||||
$coupon_price = $user_coupon->price;
|
||||
if ($user_coupon->coupon->type == Coupon::TYPE_REDUCTION) {
|
||||
$price = $price > $user_coupon->price ? bcsub($price, $coupon_price, 2) : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->job == Identity::JOB_HH && $identity->job == Identity::JOB_HH) {
|
||||
$star = $identity->getOriginal('pivot_star', 0);
|
||||
if ($star > 0) {
|
||||
$identityName = config('identity.stars.'.$star, '').$identityName;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$open = true;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'identity_id' => $this->id,
|
||||
'name' => $identityName,
|
||||
'stock' => $this->stock,
|
||||
'years' => $this->years,
|
||||
'times' => $this->when($user && $this->id == $user->identityFirst()->id, function () use ($user) {
|
||||
'identity_id' => $this->id,
|
||||
'name' => $identityName,
|
||||
'stock' => $this->stock,
|
||||
'years' => $this->years,
|
||||
'times' => $this->when($user && $this->id == $user->identityFirst()->id, function () use ($user) {
|
||||
return new IdentityMiddleResource($user->identityMiddle()->first());
|
||||
}, [
|
||||
'name' => '---',
|
||||
@@ -81,22 +57,22 @@ class UserIdentityResource extends JsonResource
|
||||
'started_at' => '---',
|
||||
'ended_at' => '---',
|
||||
]),
|
||||
'cover' => $this->cover_url,
|
||||
'order' => $this->order,
|
||||
'description' => $this->description ?? "",
|
||||
'coupon_price' => floatval($coupon_price),//开通金额
|
||||
'cost' => floatval($cost),//开通金额
|
||||
'price' => floatval($price),//开通金额
|
||||
'can' => [
|
||||
'cover' => $this->cover_url,
|
||||
'order' => $this->order,
|
||||
'description' => $this->description ?? "",
|
||||
'coupon_price' => floatval($coupon_price),//开通金额
|
||||
'cost' => floatval($cost),//开通金额
|
||||
'price' => floatval($price),//开通金额
|
||||
'can' => [
|
||||
'buy' => (bool) $this->can_buy,
|
||||
'open' => $this->can_buy ? $open : false,//开通
|
||||
'renew' => $this->can_buy ? $renew : false,//续费
|
||||
],
|
||||
'buttonText' => $text,
|
||||
'rights' => $this->rights,
|
||||
'rules' => $this->getRules(),
|
||||
'not_rules' => $this->getNotRules(),
|
||||
'is_open' => $user && $this->id == $user->identityFirst()->id
|
||||
'buttonText' => $text,
|
||||
'rights' => $this->rights,
|
||||
'rules' => $this->getRules(),
|
||||
'not_rules' => $this->getNotRules(),
|
||||
'is_open' => $user && $this->id == $user->identityFirst()->id
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ class UserInfoBaseResource extends JsonResource
|
||||
'identity' => new UserIdentityBaseResource($this->identities->first()),
|
||||
'status' => $this->getStateData(),
|
||||
'canPick' => $this->canPick(),
|
||||
'nowStatus' => $this->getNowStatus(),
|
||||
'tag' => $this->tag
|
||||
];
|
||||
}
|
||||
|
||||
@@ -37,12 +37,9 @@ class UserInfoResource extends JsonResource
|
||||
'created_at' => (string) $this->created_at,
|
||||
'sign' => $this->getSignData(),
|
||||
'status' => $this->getStateData(),
|
||||
'nowStatus' => $this->getNowStatus(),
|
||||
'canPick' => $this->canPick(),
|
||||
'count' => [
|
||||
'coupon' => $this->couponGrants()->count(),//<2F>Ż<EFBFBD>ȯ<EFBFBD><C8AF><EFBFBD><EFBFBD>
|
||||
'relation' => $this->getRelationCount(),//<2F>¼<EFBFBD>
|
||||
'invites' => $this->invites()->count(),//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
'notifications' => $this->unreadNotifications()->count(),//<2F><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
||||
'orders' => Order::byUser(Api::user())->common()->count(),//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
'refunds' => RefundModel::byUser(Api::user())->count(),//<2F>˿<CBBF><EEB5A5><EFBFBD><EFBFBD>
|
||||
|
||||
Reference in New Issue
Block a user