售后服务
This commit is contained in:
parent
d9523418a1
commit
88f00f21c4
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace Beike\Admin\Http\Controllers;
|
||||
|
||||
use Beike\Admin\Http\Resources\RmaReasonDetail;
|
||||
use Beike\Repositories\RmaReasonRepo;
|
||||
use Beike\Repositories\LanguageRepo;
|
||||
use Exception;
|
||||
|
|
@ -21,9 +22,10 @@ class RmaReasonController extends Controller
|
|||
public function index(Request $request)
|
||||
{
|
||||
$rmaReasons = RmaReasonRepo::list($request->only('name'));
|
||||
|
||||
$data = [
|
||||
'languages' => LanguageRepo::all(),
|
||||
'rmaReasons' => $rmaReasons,
|
||||
'rmaReasons' => RmaReasonDetail::collection($rmaReasons)->jsonSerialize(),
|
||||
];
|
||||
|
||||
return view('admin::pages.rma_reasons.index', $data);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* RmaReasonDetail.php
|
||||
*
|
||||
* @copyright 2022 opencart.cn - All Rights Reserved
|
||||
* @link http://www.guangdawangluo.com
|
||||
* @author TL <mengwb@opencart.cn>
|
||||
* @created 2022-08-31 11:56:28
|
||||
* @modified 2022-08-31 11:56:28
|
||||
*/
|
||||
|
||||
namespace Beike\Admin\Http\Resources;
|
||||
|
||||
use Beike\Repositories\RmaRepo;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class RmaReasonDetail extends JsonResource
|
||||
{
|
||||
public function toArray($request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => json_decode($this->name, true)[locale()] ?? '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -29,6 +29,7 @@ class RmaReasonRepo
|
|||
*/
|
||||
public static function create($data)
|
||||
{
|
||||
$data['name'] = json_encode($data['name']);
|
||||
$item = RmaReason::query()->create($data);
|
||||
return $item;
|
||||
}
|
||||
|
|
@ -47,6 +48,7 @@ class RmaReasonRepo
|
|||
if (!$reason) {
|
||||
throw new Exception("退换货原因id $reason 不存在");
|
||||
}
|
||||
$data['name'] = json_encode($data['name']);
|
||||
$reason->update($data);
|
||||
return $reason;
|
||||
}
|
||||
|
|
@ -78,10 +80,11 @@ class RmaReasonRepo
|
|||
*/
|
||||
public static function list(array $data = [])
|
||||
{
|
||||
$builder = RmaReason::query()->where('locale', locale());
|
||||
$builder = RmaReason::query();
|
||||
|
||||
if (isset($data['name'])) {
|
||||
$builder->where('name', 'like', "%{$data['name']}%");
|
||||
$locale = locale();
|
||||
$builder->whereJsonContains("name->$locale", 'like', "%{$data['name']}%");
|
||||
}
|
||||
|
||||
return $builder->get();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
namespace Beike\Shop\Http\Controllers\Account;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Beike\Admin\Http\Resources\RmaReasonDetail;
|
||||
use Beike\Repositories\RmaReasonRepo;
|
||||
use Beike\Repositories\RmaRepo;
|
||||
use Beike\Shop\Http\Requests\RmaRequest;
|
||||
|
|
@ -54,7 +55,7 @@ class RmaController extends Controller
|
|||
$data = [
|
||||
'orderProduct' => OrderProductRepo::find($orderProductId),
|
||||
'statuses' => RmaRepo::getStatuses(),
|
||||
'reasons' => RmaReasonRepo::list()->toArray(),
|
||||
'reasons' => RmaReasonDetail::collection(RmaReasonRepo::list())->jsonSerialize(),
|
||||
'types' => RmaRepo::getTypes(),
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* RmaReasonDetail.php
|
||||
*
|
||||
* @copyright 2022 opencart.cn - All Rights Reserved
|
||||
* @link http://www.guangdawangluo.com
|
||||
* @author TL <mengwb@opencart.cn>
|
||||
* @created 2022-08-31 11:56:28
|
||||
* @modified 2022-08-31 11:56:28
|
||||
*/
|
||||
|
||||
namespace Beike\Admin\Http\Resources;
|
||||
|
||||
use Beike\Repositories\RmaRepo;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class RmaReasonDetail extends JsonResource
|
||||
{
|
||||
public function toArray($request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => json_decode($this->name, true)[locale()] ?? '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -40,9 +40,9 @@ class ReturnTable extends Migration
|
|||
$table->timestamps();
|
||||
});
|
||||
Schema::create('rma_reasons', function (Blueprint $table) {
|
||||
$table->bigInteger('id');
|
||||
$table->string('locale');
|
||||
$table->string('name');
|
||||
$table->id();
|
||||
$table->json('name'); // 值示例: {"en":"cannot to use","zh_cn":"无法使用"}
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue