diff --git a/beike/Models/Rma.php b/beike/Models/Rma.php index fc14760c..a15e4d65 100644 --- a/beike/Models/Rma.php +++ b/beike/Models/Rma.php @@ -38,7 +38,7 @@ class Rma extends Base public function reason() :BelongsTo { - return $this->belongsTo(RmaReason::class); + return $this->belongsTo(RmaReason::class)->where('locale', locale()); } public function histories() :HasMany diff --git a/beike/Repositories/RmaRepo.php b/beike/Repositories/RmaRepo.php index a8420eb4..f800acfb 100644 --- a/beike/Repositories/RmaRepo.php +++ b/beike/Repositories/RmaRepo.php @@ -130,8 +130,9 @@ class RmaRepo } $results = []; - foreach ($customer->rmas as $rma) { - $results[$rma->first][] = (new RmaDetail($rma))->jsonSerialize(); + + foreach ($customer->rmas()->with('reason')->get() as $rma) { + $results[] = (new RmaDetail($rma))->jsonSerialize(); } return $results; diff --git a/beike/Shop/Http/Controllers/Account/RmaController.php b/beike/Shop/Http/Controllers/Account/RmaController.php index 0a39d062..e6222d0c 100644 --- a/beike/Shop/Http/Controllers/Account/RmaController.php +++ b/beike/Shop/Http/Controllers/Account/RmaController.php @@ -26,6 +26,7 @@ class RmaController extends Controller public function index() { $rmas = RmaRepo::listByCustomer(current_customer()); + $data = [ 'rmas' => $rmas, ]; @@ -63,6 +64,6 @@ class RmaController extends Controller { $rma = RmaService::createFromShop($request->only('order_product_id', 'quantity', 'opened', 'rma_reason_id', 'type', 'comment')); - return redirect()->to(shop_route('account.rmas.index'))->with('success', '售后服务申请提交成功'); + return redirect()->to(shop_route('account.rma.index'))->with('success', '售后服务申请提交成功'); } } diff --git a/beike/Shop/Http/Resources/RmaDetail.php b/beike/Shop/Http/Resources/RmaDetail.php index cf569eaa..828b59b2 100644 --- a/beike/Shop/Http/Resources/RmaDetail.php +++ b/beike/Shop/Http/Resources/RmaDetail.php @@ -17,6 +17,22 @@ class RmaDetail extends JsonResource { public function toArray($request): array { - return $this->toArray($request); + return [ + 'id' => $this->id, + 'order_product_id' => $this->order_product_id, + 'quantity' => $this->quantity, + 'opened' => $this->opened, + 'type' => $this->type, + 'comment' => $this->comment, + 'status' => $this->status, + 'created_at' => time_format($this->created_at), + 'email' => $this->email, + 'telephone' => $this->telephone, + 'product_name' => $this->product_name, + 'name' => $this->name, + 'sku' => $this->sku, + 'reason' => $this->reason, + 'type_text' => $this->type_text, + ]; } } diff --git a/beike/Shop/Services/RmaService.php b/beike/Shop/Services/RmaService.php index 5f61316a..55c7a585 100644 --- a/beike/Shop/Services/RmaService.php +++ b/beike/Shop/Services/RmaService.php @@ -28,7 +28,7 @@ class RmaService 'customer_id' => $customer->id, 'name' => $customer->name, 'email' => $customer->email, - 'telephone' => $customer->telephone, + 'telephone' => $customer->telephone ?? '', 'product_name' => $orderProduct->name, 'sku' => $orderProduct->product_sku, 'product_name' => $orderProduct->name, @@ -37,6 +37,7 @@ class RmaService 'rma_reason_id' => $data['rma_reason_id'], 'type' => $data['type'], 'comment' => $data['comment'], + 'status' => true, ]; $rma = RmaRepo::create($params); diff --git a/themes/default/account/rmas/index.blade.php b/themes/default/account/rmas/index.blade.php index e69de29b..93be643b 100644 --- a/themes/default/account/rmas/index.blade.php +++ b/themes/default/account/rmas/index.blade.php @@ -0,0 +1 @@ +{{-- {{ dd($rmas) }} --}} \ No newline at end of file