阶段更新
This commit is contained in:
@@ -463,12 +463,12 @@ class WeChatController extends Controller
|
||||
}
|
||||
|
||||
if ($delivery_code) {
|
||||
if (! $user->info->delivery_code) {
|
||||
$areaCode = AreaCode::query()->where('code', $delivery_code)->first();
|
||||
if ($areaCode->user_id) {
|
||||
return $this->failed('当前提货码已被别人使用');
|
||||
}
|
||||
$areaCode = AreaCode::query()->where('code', $delivery_code)->first();
|
||||
if ($areaCode->user_id) {
|
||||
return $this->failed('当前提货码已被别人使用');
|
||||
}
|
||||
|
||||
if (! $user->info->delivery_code) {
|
||||
$user->info->update([
|
||||
'delivery_code' => $delivery_code
|
||||
]);
|
||||
|
||||
@@ -11,11 +11,7 @@ class UserAccountResource extends JsonResource
|
||||
{
|
||||
return [
|
||||
'balance' => floatval($this->balance),//现金
|
||||
'score' => [
|
||||
'surplus' => floatval($this->score),//水滴余量
|
||||
'use' => 0,//水滴使用
|
||||
'plan' => 300,//水滴赠送
|
||||
],
|
||||
'score' => floatval($this->score),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -29,18 +29,21 @@ class UserInfoResource extends JsonResource
|
||||
'avatar' => $this->info->avatar ?? '',
|
||||
'account' => new UserAccountResource($this->account),
|
||||
'identity' => new UserIdentityBaseResource($identity),
|
||||
'service' => new UserServiceResource($identity->identities()->first()),
|
||||
'water_mobile' => app('Conf_mall')['water_mobile'] ?? '',
|
||||
// 'service' => new UserServiceResource($identity->identities()->first()),
|
||||
// 'water_mobile' => app('Conf_mall')['water_mobile'] ?? '',
|
||||
'invite' => Hashids::connection('code')->encode($this->id),
|
||||
'case' => $this->getStockData(),
|
||||
'area_code' => $this->info->area_code,
|
||||
// 'case' => $this->getStockData(),
|
||||
'created_at' => (string) $this->created_at,
|
||||
'status' => $this->getStateData(),
|
||||
'nowStatus' => $this->getNowStatus(),
|
||||
'canPick' => $this->canPick(),
|
||||
// 'nowStatus' => $this->getNowStatus(),
|
||||
// 'canPick' => $this->canPick(),
|
||||
'count' => [
|
||||
'relation' => $this->getRelationCount(),//下级
|
||||
'orders' => $this->getOrderCount(),
|
||||
'refunds' => RefundModel::byUser(Api::user())->count(),//退款单数量
|
||||
],
|
||||
'can' => [
|
||||
'area' => $this->areas()->exists(),
|
||||
],
|
||||
'identityShow' => $this->when(true, function () use ($identity) {
|
||||
return [
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Modules\User\Models;
|
||||
|
||||
use App\Models\Area;
|
||||
use App\Models\AreaClerk;
|
||||
use App\Models\AreaCode;
|
||||
use App\Traits\Macroable;
|
||||
use App\Traits\OrderByIdDesc;
|
||||
@@ -308,5 +310,13 @@ class User extends Authenticate
|
||||
return sprintf("%s (%s)", $this->username, $this->info->nickname);
|
||||
}
|
||||
|
||||
public function areas()
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
Area::class,
|
||||
(new AreaClerk())->getTable())->using(AreaClerk::class
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user