Merge branch 'feature/vehicle_new_sku' into develop
This commit is contained in:
@@ -130,9 +130,6 @@ class BrandController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function index(Request $request, string $scene = 'default'): Response
|
public function index(Request $request, string $scene = 'default'): Response
|
||||||
{
|
{
|
||||||
// $Brand = BrandModel::with('banner')->with('trait')->where('id',314)->first()->toArray();
|
|
||||||
// var_dump($Brand);
|
|
||||||
// return json($Brand);
|
|
||||||
try {
|
try {
|
||||||
return parent::index($request, $scene);
|
return parent::index($request, $scene);
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
|
|||||||
@@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\controller;
|
||||||
|
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use app\console\model\VehicleNewAttributeCategoriesModel;
|
||||||
|
use app\console\service\VehicleNewAttributeCategoriesService;
|
||||||
|
use app\console\validate\VehicleNewAttributeCategoriesValidator;
|
||||||
|
use app\mzl\common\controller\BaseController;
|
||||||
|
|
||||||
|
class VehicleNewAttributeCategoriesController extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不需要验证token的接口
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $noNeedJwt = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证器
|
||||||
|
*/
|
||||||
|
protected mixed $validator = VehicleNewAttributeCategoriesValidator::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回业务 Service 实例
|
||||||
|
*/
|
||||||
|
protected function getService()
|
||||||
|
{
|
||||||
|
return new VehicleNewAttributeCategoriesService(new VehicleNewAttributeCategoriesModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 额外字段处理 (根据场景处理)
|
||||||
|
* @param array $item
|
||||||
|
* @param string $scene
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function postProcessItem(array $item, string $scene): array
|
||||||
|
{
|
||||||
|
if ($scene === 'default' || $scene === 'show') {
|
||||||
|
$result = [
|
||||||
|
'id' => $item['id'],
|
||||||
|
'sort_order' => $item['sort_order'],
|
||||||
|
'category_name' => isset($item['translation']) ? $item['translation']['category_name'] : '',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数预处理 (根据场景处理)
|
||||||
|
* @param Request $request
|
||||||
|
* @param string $scene
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function prepareParams(Request $request, string $scene): array
|
||||||
|
{
|
||||||
|
$params = parent::prepareParams($request, $scene);
|
||||||
|
|
||||||
|
if ($scene === 'default') {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*
|
||||||
|
* @param Request $request 请求对象
|
||||||
|
* @return Response 响应对象
|
||||||
|
*/
|
||||||
|
public function index(Request $request, string $scene = 'default'): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return parent::index($request, $scene);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function add(Request $request): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->getService()->add($request->all())
|
||||||
|
? $this->successResponse()
|
||||||
|
: $this->errorResponse();
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage().$th->getLine().$th->getFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(Request $request, int $id): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->getService()->edit($request->all(), $id)
|
||||||
|
? $this->successResponse()
|
||||||
|
: $this->errorResponse();
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage().$th->getLine().$th->getFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function detail(Request $request, int $id, string $scene = 'show'): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$request->setGet(['id'=>$id]);
|
||||||
|
return parent::one($request, $scene);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage().$th->getLine().$th->getFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\controller;
|
||||||
|
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use app\console\model\VehicleNewAttributeCategoriesTranslationModel;
|
||||||
|
use app\console\service\VehicleNewAttributeCategoriesTranslationService;
|
||||||
|
use app\console\validate\VehicleNewAttributeCategoriesTranslationValidator;
|
||||||
|
use app\mzl\common\controller\BaseController;
|
||||||
|
|
||||||
|
class VehicleNewAttributeCategoriesTranslationController extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不需要验证token的接口
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $noNeedJwt = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证器
|
||||||
|
*/
|
||||||
|
protected mixed $validator = VehicleNewAttributeCategoriesTranslationValidator::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回业务 Service 实例
|
||||||
|
*/
|
||||||
|
protected function getService()
|
||||||
|
{
|
||||||
|
return new VehicleNewAttributeCategoriesTranslationService(new VehicleNewAttributeCategoriesTranslationModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 额外字段处理 (根据场景处理)
|
||||||
|
* @param array $item
|
||||||
|
* @param string $scene
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function postProcessItem(array $item, string $scene): array
|
||||||
|
{
|
||||||
|
|
||||||
|
if ($scene === 'default') {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数预处理 (根据场景处理)
|
||||||
|
* @param Request $request
|
||||||
|
* @param string $scene
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function prepareParams(Request $request, string $scene): array
|
||||||
|
{
|
||||||
|
$params = parent::prepareParams($request, $scene);
|
||||||
|
|
||||||
|
if ($scene === 'default') {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*
|
||||||
|
* @param Request $request 请求对象
|
||||||
|
* @return Response 响应对象
|
||||||
|
*/
|
||||||
|
public function index(Request $request, string $scene = 'default'): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return parent::index($request, $scene);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\controller;
|
||||||
|
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use app\console\model\VehicleNewAttributeValuesModel;
|
||||||
|
use app\console\service\VehicleNewAttributeValuesService;
|
||||||
|
use app\console\validate\VehicleNewAttributeValuesValidator;
|
||||||
|
use app\mzl\common\controller\BaseController;
|
||||||
|
|
||||||
|
class VehicleNewAttributeValuesController extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不需要验证token的接口
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $noNeedJwt = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证器
|
||||||
|
*/
|
||||||
|
protected mixed $validator = VehicleNewAttributeValuesValidator::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回业务 Service 实例
|
||||||
|
*/
|
||||||
|
protected function getService()
|
||||||
|
{
|
||||||
|
return new VehicleNewAttributeValuesService(new VehicleNewAttributeValuesModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 额外字段处理 (根据场景处理)
|
||||||
|
* @param array $item
|
||||||
|
* @param string $scene
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function postProcessItem(array $item, string $scene): array
|
||||||
|
{
|
||||||
|
|
||||||
|
if ($scene === 'default') {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数预处理 (根据场景处理)
|
||||||
|
* @param Request $request
|
||||||
|
* @param string $scene
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function prepareParams(Request $request, string $scene): array
|
||||||
|
{
|
||||||
|
$params = parent::prepareParams($request, $scene);
|
||||||
|
|
||||||
|
if ($scene === 'default') {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*
|
||||||
|
* @param Request $request 请求对象
|
||||||
|
* @return Response 响应对象
|
||||||
|
*/
|
||||||
|
public function index(Request $request, string $scene = 'default'): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return parent::index($request, $scene);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\controller;
|
||||||
|
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use app\console\model\VehicleNewAttributeValuesTranslationModel;
|
||||||
|
use app\console\service\VehicleNewAttributeValuesTranslationService;
|
||||||
|
use app\console\validate\VehicleNewAttributeValuesTranslationValidator;
|
||||||
|
use app\mzl\common\controller\BaseController;
|
||||||
|
|
||||||
|
class VehicleNewAttributeValuesTranslationController extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不需要验证token的接口
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $noNeedJwt = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证器
|
||||||
|
*/
|
||||||
|
protected mixed $validator = VehicleNewAttributeValuesTranslationValidator::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回业务 Service 实例
|
||||||
|
*/
|
||||||
|
protected function getService()
|
||||||
|
{
|
||||||
|
return new VehicleNewAttributeValuesTranslationService(new VehicleNewAttributeValuesTranslationModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 额外字段处理 (根据场景处理)
|
||||||
|
* @param array $item
|
||||||
|
* @param string $scene
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function postProcessItem(array $item, string $scene): array
|
||||||
|
{
|
||||||
|
|
||||||
|
if ($scene === 'default') {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数预处理 (根据场景处理)
|
||||||
|
* @param Request $request
|
||||||
|
* @param string $scene
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function prepareParams(Request $request, string $scene): array
|
||||||
|
{
|
||||||
|
$params = parent::prepareParams($request, $scene);
|
||||||
|
|
||||||
|
if ($scene === 'default') {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*
|
||||||
|
* @param Request $request 请求对象
|
||||||
|
* @return Response 响应对象
|
||||||
|
*/
|
||||||
|
public function index(Request $request, string $scene = 'default'): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return parent::index($request, $scene);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\controller;
|
||||||
|
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use app\console\model\VehicleNewAttributesModel;
|
||||||
|
use app\console\service\VehicleNewAttributesService;
|
||||||
|
use app\console\validate\VehicleNewAttributesValidator;
|
||||||
|
use app\mzl\common\controller\BaseController;
|
||||||
|
|
||||||
|
class VehicleNewAttributesController extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不需要验证token的接口
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $noNeedJwt = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证器
|
||||||
|
*/
|
||||||
|
protected mixed $validator = VehicleNewAttributesValidator::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回业务 Service 实例
|
||||||
|
*/
|
||||||
|
protected function getService()
|
||||||
|
{
|
||||||
|
return new VehicleNewAttributesService(new VehicleNewAttributesModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 额外字段处理 (根据场景处理)
|
||||||
|
* @param array $item
|
||||||
|
* @param string $scene
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function postProcessItem(array $item, string $scene): array
|
||||||
|
{
|
||||||
|
if ($scene === 'default' || $scene === 'show') {
|
||||||
|
|
||||||
|
$result = [
|
||||||
|
'id' => $item['id'],
|
||||||
|
'status' => $item['status'],
|
||||||
|
'attribute_name' => isset($item['translation']) ? $item['translation']['attribute_name'] : '',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($item['value'] as $value) {
|
||||||
|
$valueRes['id'] = $value['id'];
|
||||||
|
$valueRes['attribute_id'] = $value['attribute_id'];
|
||||||
|
$valueRes['value_name'] = isset($value['translation']) ? $value['translation']['value_name']:'';
|
||||||
|
$result['value'][] = $valueRes;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
if ($scene === 'preset') {
|
||||||
|
return [
|
||||||
|
'id' => $item['id'],
|
||||||
|
'attribute_name' => isset($item['translation']) ? $item['translation']['attribute_name'] : '',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数预处理 (根据场景处理)
|
||||||
|
* @param Request $request
|
||||||
|
* @param string $scene
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function prepareParams(Request $request, string $scene): array
|
||||||
|
{
|
||||||
|
$params = parent::prepareParams($request, $scene);
|
||||||
|
|
||||||
|
if ($scene === 'default') {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*
|
||||||
|
* @param Request $request 请求对象
|
||||||
|
* @return Response 响应对象
|
||||||
|
*/
|
||||||
|
public function index(Request $request, string $scene = 'default'): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return parent::index($request, $scene);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage().$th->getFile().$th->getLine());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add(Request $request): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->getService()->add($request->all())
|
||||||
|
? $this->successResponse()
|
||||||
|
: $this->errorResponse();
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage().$th->getLine().$th->getFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function presets(Request $request, string $scene = 'preset'): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return parent::all($request, $scene);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage().$th->getLine().$th->getFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(Request $request, int $id): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->getService()->edit($request->all(), $id)
|
||||||
|
? $this->successResponse()
|
||||||
|
: $this->errorResponse();
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage().$th->getLine().$th->getFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function detail(Request $request, int $id, string $scene = 'show'): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$request->setGet(['id'=>$id]);
|
||||||
|
return parent::one($request, $scene);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage().$th->getLine().$th->getFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\controller;
|
||||||
|
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use app\console\model\VehicleNewAttributesTranslationModel;
|
||||||
|
use app\console\service\VehicleNewAttributesTranslationService;
|
||||||
|
use app\console\validate\VehicleNewAttributesTranslationValidator;
|
||||||
|
use app\mzl\common\controller\BaseController;
|
||||||
|
|
||||||
|
class VehicleNewAttributesTranslationController extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不需要验证token的接口
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $noNeedJwt = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证器
|
||||||
|
*/
|
||||||
|
protected mixed $validator = VehicleNewAttributesTranslationValidator::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回业务 Service 实例
|
||||||
|
*/
|
||||||
|
protected function getService()
|
||||||
|
{
|
||||||
|
return new VehicleNewAttributesTranslationService(new VehicleNewAttributesTranslationModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 额外字段处理 (根据场景处理)
|
||||||
|
* @param array $item
|
||||||
|
* @param string $scene
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function postProcessItem(array $item, string $scene): array
|
||||||
|
{
|
||||||
|
|
||||||
|
if ($scene === 'default') {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数预处理 (根据场景处理)
|
||||||
|
* @param Request $request
|
||||||
|
* @param string $scene
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function prepareParams(Request $request, string $scene): array
|
||||||
|
{
|
||||||
|
$params = parent::prepareParams($request, $scene);
|
||||||
|
|
||||||
|
if ($scene === 'default') {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*
|
||||||
|
* @param Request $request 请求对象
|
||||||
|
* @return Response 响应对象
|
||||||
|
*/
|
||||||
|
public function index(Request $request, string $scene = 'default'): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return parent::index($request, $scene);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\controller;
|
||||||
|
|
||||||
|
use app\console\model\VehicleNewAttributesTranslationModel;
|
||||||
|
use app\console\model\VehicleNewAttributeValuesTranslationModel;
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use app\console\model\VehicleNewSkuAttributesModel;
|
||||||
|
use app\console\service\VehicleNewSkuAttributesService;
|
||||||
|
use app\console\validate\VehicleNewSkuAttributesValidator;
|
||||||
|
use app\mzl\common\controller\BaseController;
|
||||||
|
|
||||||
|
class VehicleNewSkuAttributesController extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不需要验证token的接口
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $noNeedJwt = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证器
|
||||||
|
*/
|
||||||
|
protected mixed $validator = VehicleNewSkuAttributesValidator::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回业务 Service 实例
|
||||||
|
*/
|
||||||
|
protected function getService()
|
||||||
|
{
|
||||||
|
return new VehicleNewSkuAttributesService(new VehicleNewSkuAttributesModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 额外字段处理 (根据场景处理)
|
||||||
|
* @param array $item
|
||||||
|
* @param string $scene
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function postProcessItem(array $item, string $scene): array
|
||||||
|
{
|
||||||
|
|
||||||
|
if ($scene === 'default' || $scene === 'show') {
|
||||||
|
$attribute = VehicleNewAttributesTranslationModel::where(['attributes_id' => $item['attribute']['id'],'locale'=>locale()])->first();
|
||||||
|
$value = VehicleNewAttributeValuesTranslationModel::where(['values_id' => $item['value']['id'],'locale'=>locale()])->first();
|
||||||
|
|
||||||
|
$item['attribute']['attribute_name'] = $attribute['attribute_name'] ;
|
||||||
|
$item['value']['value_name'] = $value['value_name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数预处理 (根据场景处理)
|
||||||
|
* @param Request $request
|
||||||
|
* @param string $scene
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function prepareParams(Request $request, string $scene): array
|
||||||
|
{
|
||||||
|
$params = parent::prepareParams($request, $scene);
|
||||||
|
|
||||||
|
if ($scene === 'default') {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*
|
||||||
|
* @param Request $request 请求对象
|
||||||
|
* @return Response 响应对象
|
||||||
|
*/
|
||||||
|
public function index(Request $request, string $scene = 'default'): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return parent::index($request, $scene);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage().$th->getLine().$th->getFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\controller;
|
||||||
|
|
||||||
|
use app\console\model\VehicleNewAttributesTranslationModel;
|
||||||
|
use app\console\model\VehicleNewAttributeValuesTranslationModel;
|
||||||
|
use app\console\model\VehicleNewSkuAttributesModel;
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use app\console\model\VehicleNewSkusModel;
|
||||||
|
use app\console\service\VehicleNewSkusService;
|
||||||
|
use app\console\validate\VehicleNewSkusValidator;
|
||||||
|
use app\mzl\common\controller\BaseController;
|
||||||
|
|
||||||
|
class VehicleNewSkusController extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不需要验证token的接口
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $noNeedJwt = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证器
|
||||||
|
*/
|
||||||
|
protected mixed $validator = VehicleNewSkusValidator::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回业务 Service 实例
|
||||||
|
*/
|
||||||
|
protected function getService()
|
||||||
|
{
|
||||||
|
return new VehicleNewSkusService(new VehicleNewSkusModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 额外字段处理 (根据场景处理)
|
||||||
|
* @param array $item
|
||||||
|
* @param string $scene
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function postProcessItem(array $item, string $scene): array
|
||||||
|
{
|
||||||
|
|
||||||
|
if ($scene === 'default' || $scene === 'show') {
|
||||||
|
foreach ($item['skuAttributes'] as &$skuAttribute){
|
||||||
|
$attribute = VehicleNewAttributesTranslationModel::where(['attributes_id' => $skuAttribute['attribute']['id'],'locale'=>locale()])->first();
|
||||||
|
$value = VehicleNewAttributeValuesTranslationModel::where(['values_id' => $skuAttribute['value']['id'],'locale'=>locale()])->first();
|
||||||
|
|
||||||
|
$skuAttribute['attribute']['attribute_name'] = $attribute['attribute_name'] ;
|
||||||
|
$skuAttribute['value']['value_name'] = $value['value_name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数预处理 (根据场景处理)
|
||||||
|
* @param Request $request
|
||||||
|
* @param string $scene
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function prepareParams(Request $request, string $scene): array
|
||||||
|
{
|
||||||
|
$params = parent::prepareParams($request, $scene);
|
||||||
|
|
||||||
|
if ($scene === 'default') {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*
|
||||||
|
* @param Request $request 请求对象
|
||||||
|
* @return Response 响应对象
|
||||||
|
*/
|
||||||
|
public function index(Request $request, string $scene = 'default'): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// $res = VehicleNewSkusModel::with('skuAttributes')->find(9);
|
||||||
|
// return $this->successResponse($res);
|
||||||
|
return parent::index($request, $scene);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add(Request $request): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->getService()->add($request->all())
|
||||||
|
? $this->successResponse()
|
||||||
|
: $this->errorResponse();
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage().$th->getLine().$th->getFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(Request $request, int $id): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->getService()->edit($request->all(), $id)
|
||||||
|
? $this->successResponse()
|
||||||
|
: $this->errorResponse();
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage().$th->getLine().$th->getFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function detail(Request $request, int $id, string $scene = 'show'): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$request->setGet(['id'=>$id]);
|
||||||
|
return parent::one($request, $scene);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\model;
|
||||||
|
|
||||||
|
use support\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VehicleNewAttributeCategoriesModel
|
||||||
|
*/
|
||||||
|
class VehicleNewAttributeCategoriesModel extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The connection name for the model.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected $connection = 'mysql';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'hs_vehicle_new_attribute_categories';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The primary key associated with the table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the model should be timestamped.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型的数据字段的保存格式。
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dateFormat = 'U';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $fillable = ['id', 'category_name', 'sort_order', 'created_at'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单条翻译
|
||||||
|
*/
|
||||||
|
public function translation()
|
||||||
|
{
|
||||||
|
return $this->hasOne(VehicleNewAttributeCategoriesTranslationModel::class, 'categories_id')->where('locale', locale());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多条翻译
|
||||||
|
*/
|
||||||
|
public function translations()
|
||||||
|
{
|
||||||
|
return $this->hasMany(VehicleNewAttributeCategoriesTranslationModel::class, 'categories_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function attribute()
|
||||||
|
{
|
||||||
|
return $this->hasMany(VehicleNewAttributesModel::class, 'category_id', 'id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\model;
|
||||||
|
|
||||||
|
use support\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VehicleNewAttributeCategoriesTranslationModel
|
||||||
|
*/
|
||||||
|
class VehicleNewAttributeCategoriesTranslationModel extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The connection name for the model.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected $connection = 'mysql';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'hs_vehicle_new_attribute_categories_translation';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The primary key associated with the table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the model should be timestamped.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型的数据字段的保存格式。
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dateFormat = 'U';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $fillable = ['id', 'categories_id', 'locale', 'category_name', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $guarded = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\model;
|
||||||
|
|
||||||
|
use support\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VehicleNewAttributeValuesModel
|
||||||
|
*/
|
||||||
|
class VehicleNewAttributeValuesModel extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The connection name for the model.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected $connection = 'mysql';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'hs_vehicle_new_attribute_values';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The primary key associated with the table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the model should be timestamped.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型的数据字段的保存格式。
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dateFormat = 'U';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $fillable = ['id', 'attribute_id', 'value_name', 'color_code', 'price_modifier', 'sort_order', 'created_at'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单条翻译
|
||||||
|
*/
|
||||||
|
public function translation()
|
||||||
|
{
|
||||||
|
return $this->hasOne(VehicleNewAttributeValuesTranslationModel::class, 'values_id')->where('locale', locale());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多条翻译
|
||||||
|
*/
|
||||||
|
public function translations()
|
||||||
|
{
|
||||||
|
return $this->hasMany(VehicleNewAttributeValuesTranslationModel::class, 'values_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\model;
|
||||||
|
|
||||||
|
use support\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VehicleNewAttributeValuesTranslationModel
|
||||||
|
*/
|
||||||
|
class VehicleNewAttributeValuesTranslationModel extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The connection name for the model.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected $connection = 'mysql';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'hs_vehicle_new_attribute_values_translation';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The primary key associated with the table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the model should be timestamped.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型的数据字段的保存格式。
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dateFormat = 'U';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $fillable = ['id', 'values_id', 'locale', 'value_name', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $guarded = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\model;
|
||||||
|
|
||||||
|
use support\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VehicleNewAttributesModel
|
||||||
|
*/
|
||||||
|
class VehicleNewAttributesModel extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The connection name for the model.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected $connection = 'mysql';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'hs_vehicle_new_attributes';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The primary key associated with the table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the model should be timestamped.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型的数据字段的保存格式。
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dateFormat = 'U';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $fillable = ['id', 'category_id', 'attribute_name', 'is_required', 'input_type', 'is_img', 'status', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单条翻译
|
||||||
|
*/
|
||||||
|
public function translation()
|
||||||
|
{
|
||||||
|
return $this->hasOne(VehicleNewAttributesTranslationModel::class, 'attributes_id','id')->where('locale', locale());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多条翻译
|
||||||
|
*/
|
||||||
|
public function translations()
|
||||||
|
{
|
||||||
|
return $this->hasMany(VehicleNewAttributesTranslationModel::class, 'attributes_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function value()
|
||||||
|
{
|
||||||
|
return $this->hasMany(VehicleNewAttributeValuesModel::class, 'attribute_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\model;
|
||||||
|
|
||||||
|
use support\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VehicleNewAttributesTranslationModel
|
||||||
|
*/
|
||||||
|
class VehicleNewAttributesTranslationModel extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The connection name for the model.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected $connection = 'mysql';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'hs_vehicle_new_attributes_translation';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The primary key associated with the table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the model should be timestamped.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型的数据字段的保存格式。
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dateFormat = 'U';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $fillable = ['id', 'attributes_id', 'locale', 'attribute_name', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $guarded = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\model;
|
||||||
|
|
||||||
|
use support\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VehicleNewSkuAttributesModel
|
||||||
|
*/
|
||||||
|
class VehicleNewSkuAttributesModel extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The connection name for the model.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected $connection = 'mysql';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'hs_vehicle_new_sku_attributes';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The primary key associated with the table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the model should be timestamped.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型的数据字段的保存格式。
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dateFormat = 'U';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $fillable = ['id', 'sku_id', 'attribute_id', 'value_id', 'img', 'created_at'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
|
public function attribute()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(VehicleNewAttributesModel::class, 'attribute_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function value()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(VehicleNewAttributeValuesModel::class, 'value_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function skuAttributes()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(VehicleNewSkusModel::class, 'sku_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\model;
|
||||||
|
|
||||||
|
use support\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VehicleNewSkusModel
|
||||||
|
*/
|
||||||
|
class VehicleNewSkusModel extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The connection name for the model.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected $connection = 'mysql';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'hs_vehicle_new_skus';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The primary key associated with the table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the model should be timestamped.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型的数据字段的保存格式。
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dateFormat = 'U';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $fillable = ['id', 'vehicle_id', 'sku_code', 'stock', 'price', 'status', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
|
public function skuAttributes()
|
||||||
|
{
|
||||||
|
return $this->hasMany(VehicleNewSkuAttributesModel::class, 'sku_id', 'id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\service;
|
||||||
|
|
||||||
|
use app\console\model\VehicleNewAttributeCategoriesModel;
|
||||||
|
use app\mzl\common\services\BaseService;
|
||||||
|
use app\mzl\modules\translation\service\TranslationService;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use support\Db;
|
||||||
|
use support\exception\BusinessException;
|
||||||
|
|
||||||
|
class VehicleNewAttributeCategoriesService extends BaseService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 定义模型
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getModel(): string
|
||||||
|
{
|
||||||
|
return VehicleNewAttributeCategoriesModel::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多场景配置
|
||||||
|
*/
|
||||||
|
public function queryScenes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'default' => function ($params) {
|
||||||
|
return [
|
||||||
|
'filters' => [
|
||||||
|
],
|
||||||
|
'fields' => ['id','sort_order'],
|
||||||
|
'relations' => [
|
||||||
|
'translation' => ['categories_id', 'locale', 'category_name'],
|
||||||
|
'attribute' => ['id','status'],
|
||||||
|
'attribute.translation' => ['attributes_id', 'locale', 'attribute_name'],
|
||||||
|
],
|
||||||
|
'sorts' => [
|
||||||
|
['field' => 'created_at', 'direction' => 'desc']
|
||||||
|
],
|
||||||
|
'pagination' => [
|
||||||
|
'page' => $params['page'] ?? 1,
|
||||||
|
'per_page' => $params['per_page'] ?? 10,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
},
|
||||||
|
'show' => function ($params) {
|
||||||
|
return [
|
||||||
|
'filters' => [
|
||||||
|
['field'=>'id', 'operator'=>'=', 'value'=> $params['id']],
|
||||||
|
],
|
||||||
|
'fields' => ['id', 'status'],
|
||||||
|
'relations' => [
|
||||||
|
'translation' => ['categories_id', 'locale', 'category_name'],
|
||||||
|
'attribute' => ['id','status'],
|
||||||
|
'attribute.translation' => ['attributes_id', 'locale', 'attribute_name'],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 声明需要多语言翻译
|
||||||
|
protected array $translatable = [
|
||||||
|
'category_name',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function add(array $params)
|
||||||
|
{
|
||||||
|
$sourceLocale = locale();
|
||||||
|
$sourceFields = $this->extractSourceFields($params);
|
||||||
|
|
||||||
|
if (empty($sourceFields)) {
|
||||||
|
throw new \InvalidArgumentException("请传递至少一条 {$sourceLocale} 语言的翻译字段");
|
||||||
|
};
|
||||||
|
|
||||||
|
Db::beginTransaction();
|
||||||
|
try {
|
||||||
|
$info = $this->create($params);
|
||||||
|
if (!$info) {
|
||||||
|
throw new BusinessException('提交失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 异步翻译并写入 hs_vehicle_data_translation 表
|
||||||
|
(new TranslationService())->queueTranslations(
|
||||||
|
'vehicleNewAttributeCategories',
|
||||||
|
$info->id,
|
||||||
|
$sourceLocale,
|
||||||
|
$sourceFields
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Db::rollBack();
|
||||||
|
throw $th;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(array $params, int $id)
|
||||||
|
{
|
||||||
|
$sourceLocale = locale();
|
||||||
|
$sourceFields = $this->extractSourceFields($params);
|
||||||
|
|
||||||
|
if (empty($sourceFields)) {
|
||||||
|
throw new \InvalidArgumentException("请传递至少一条 {$sourceLocale} 语言的翻译字段");
|
||||||
|
};
|
||||||
|
|
||||||
|
Db::beginTransaction();
|
||||||
|
try {
|
||||||
|
$info = $this->update($id, $params);
|
||||||
|
if (!$info) {
|
||||||
|
throw new BusinessException('提交失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 异步翻译并写入 hs_vehicle_data_translation 表
|
||||||
|
(new TranslationService())->queueTranslations(
|
||||||
|
'vehicleNewAttributeCategories',
|
||||||
|
$id,
|
||||||
|
$sourceLocale,
|
||||||
|
$sourceFields
|
||||||
|
);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Db::rollBack();
|
||||||
|
throw $th;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\service;
|
||||||
|
|
||||||
|
use app\console\model\VehicleNewAttributeCategoriesTranslationModel;
|
||||||
|
use app\mzl\common\services\BaseService;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class VehicleNewAttributeCategoriesTranslationService extends BaseService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 定义模型
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getModel(): string
|
||||||
|
{
|
||||||
|
return VehicleNewAttributeCategoriesTranslationModel::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多场景配置
|
||||||
|
*/
|
||||||
|
public function queryScenes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// 'default' => function ($params) {
|
||||||
|
// $keyword = $params['keyword'] ?? '';
|
||||||
|
// return [
|
||||||
|
// 'filters' => [
|
||||||
|
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||||
|
// ],
|
||||||
|
// 'fields' => ['id'],
|
||||||
|
// 'relations' => [],
|
||||||
|
// 'custom' => function(Builder $q) use ($keyword) {
|
||||||
|
// // 示例
|
||||||
|
// if ($keyword) {
|
||||||
|
// $q->where(function($q2) use($keyword) {
|
||||||
|
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||||
|
// $q3->where('***', 'like', "%{$keyword}%");
|
||||||
|
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||||
|
// $q4->where('***', 'like', "%{$keyword}%");
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// 'sorts' => [
|
||||||
|
// ['field' => 'created_at', 'direction' => 'desc']
|
||||||
|
// ],
|
||||||
|
// 'pagination' => [
|
||||||
|
// 'page' => $params['page'] ?? 1,
|
||||||
|
// 'per_page' => $params['per_page'] ?? 10,
|
||||||
|
// ]
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\service;
|
||||||
|
|
||||||
|
use app\console\model\VehicleNewAttributeValuesModel;
|
||||||
|
use app\mzl\common\services\BaseService;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class VehicleNewAttributeValuesService extends BaseService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 定义模型
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getModel(): string
|
||||||
|
{
|
||||||
|
return VehicleNewAttributeValuesModel::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多场景配置
|
||||||
|
*/
|
||||||
|
public function queryScenes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// 'default' => function ($params) {
|
||||||
|
// $keyword = $params['keyword'] ?? '';
|
||||||
|
// return [
|
||||||
|
// 'filters' => [
|
||||||
|
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||||
|
// ],
|
||||||
|
// 'fields' => ['id'],
|
||||||
|
// 'relations' => [],
|
||||||
|
// 'custom' => function(Builder $q) use ($keyword) {
|
||||||
|
// // 示例
|
||||||
|
// if ($keyword) {
|
||||||
|
// $q->where(function($q2) use($keyword) {
|
||||||
|
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||||
|
// $q3->where('***', 'like', "%{$keyword}%");
|
||||||
|
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||||
|
// $q4->where('***', 'like', "%{$keyword}%");
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// 'sorts' => [
|
||||||
|
// ['field' => 'created_at', 'direction' => 'desc']
|
||||||
|
// ],
|
||||||
|
// 'pagination' => [
|
||||||
|
// 'page' => $params['page'] ?? 1,
|
||||||
|
// 'per_page' => $params['per_page'] ?? 10,
|
||||||
|
// ]
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 声明需要多语言翻译
|
||||||
|
protected array $translatable = [
|
||||||
|
'value_name',
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\service;
|
||||||
|
|
||||||
|
use app\console\model\VehicleNewAttributeValuesTranslationModel;
|
||||||
|
use app\mzl\common\services\BaseService;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class VehicleNewAttributeValuesTranslationService extends BaseService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 定义模型
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getModel(): string
|
||||||
|
{
|
||||||
|
return VehicleNewAttributeValuesTranslationModel::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多场景配置
|
||||||
|
*/
|
||||||
|
public function queryScenes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// 'default' => function ($params) {
|
||||||
|
// $keyword = $params['keyword'] ?? '';
|
||||||
|
// return [
|
||||||
|
// 'filters' => [
|
||||||
|
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||||
|
// ],
|
||||||
|
// 'fields' => ['id'],
|
||||||
|
// 'relations' => [],
|
||||||
|
// 'custom' => function(Builder $q) use ($keyword) {
|
||||||
|
// // 示例
|
||||||
|
// if ($keyword) {
|
||||||
|
// $q->where(function($q2) use($keyword) {
|
||||||
|
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||||
|
// $q3->where('***', 'like', "%{$keyword}%");
|
||||||
|
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||||
|
// $q4->where('***', 'like', "%{$keyword}%");
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// 'sorts' => [
|
||||||
|
// ['field' => 'created_at', 'direction' => 'desc']
|
||||||
|
// ],
|
||||||
|
// 'pagination' => [
|
||||||
|
// 'page' => $params['page'] ?? 1,
|
||||||
|
// 'per_page' => $params['per_page'] ?? 10,
|
||||||
|
// ]
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,207 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\service;
|
||||||
|
|
||||||
|
use app\console\model\VehicleNewAttributesModel;
|
||||||
|
use app\console\model\VehicleNewAttributeValuesModel;
|
||||||
|
use app\mzl\common\services\BaseService;
|
||||||
|
use app\mzl\modules\translation\service\TranslationService;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use support\Db;
|
||||||
|
use support\exception\BusinessException;
|
||||||
|
|
||||||
|
class VehicleNewAttributesService extends BaseService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 定义模型
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getModel(): string
|
||||||
|
{
|
||||||
|
return VehicleNewAttributesModel::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多场景配置
|
||||||
|
*/
|
||||||
|
public function queryScenes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'default' => function ($params) {
|
||||||
|
return [
|
||||||
|
'filters' => [
|
||||||
|
],
|
||||||
|
'fields' => ['id','status'],
|
||||||
|
'relations' => [
|
||||||
|
'translation' => ['attributes_id', 'locale', 'attribute_name'],
|
||||||
|
'value' => ['id', 'attribute_id', 'sort_order'],
|
||||||
|
'value.translation' => ['id', 'values_id', 'locale', 'value_name'],
|
||||||
|
],
|
||||||
|
'sorts' => [
|
||||||
|
['field' => 'created_at', 'direction' => 'desc']
|
||||||
|
],
|
||||||
|
'pagination' => [
|
||||||
|
'page' => $params['page'] ?? 1,
|
||||||
|
'per_page' => $params['per_page'] ?? 10,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
},
|
||||||
|
'preset' => function ($params) {
|
||||||
|
return [
|
||||||
|
'filters' => [
|
||||||
|
],
|
||||||
|
'fields' => ['id','status'],
|
||||||
|
'relations' => [
|
||||||
|
'translation' => ['attributes_id', 'locale', 'attribute_name'],
|
||||||
|
'value' => ['id', 'attribute_id', 'sort_order'],
|
||||||
|
'value.translation' => ['id', 'values_id', 'locale', 'value_name'],
|
||||||
|
],
|
||||||
|
'sorts' => [
|
||||||
|
['field' => 'created_at', 'direction' => 'desc']
|
||||||
|
],
|
||||||
|
];
|
||||||
|
},
|
||||||
|
'show' => function ($params) {
|
||||||
|
return [
|
||||||
|
'filters' => [
|
||||||
|
['field'=>'id', 'operator'=>'=', 'value'=> $params['id']],
|
||||||
|
],
|
||||||
|
'fields' => ['id', 'status'],
|
||||||
|
'relations' => [
|
||||||
|
'translation' => ['attributes_id', 'locale', 'attribute_name'],
|
||||||
|
'value' => ['id', 'attribute_id', 'sort_order'],
|
||||||
|
'value.translation' => ['id', 'values_id', 'locale', 'value_name'],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 声明需要多语言翻译
|
||||||
|
protected array $translatable = [
|
||||||
|
'attribute_name',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function add(array $params)
|
||||||
|
{
|
||||||
|
$sourceLocale = locale();
|
||||||
|
$sourceFields = $this->extractSourceFields($params);
|
||||||
|
|
||||||
|
if (empty($sourceFields)) {
|
||||||
|
throw new \InvalidArgumentException("请传递至少一条 {$sourceLocale} 语言的翻译字段");
|
||||||
|
};
|
||||||
|
|
||||||
|
$values = $params['value'];
|
||||||
|
unset($params['value']);
|
||||||
|
$VehicleNewAttributeValuesService = new VehicleNewAttributeValuesService(new VehicleNewAttributeValuesModel());
|
||||||
|
Db::beginTransaction();
|
||||||
|
try {
|
||||||
|
$info = $this->create($params);
|
||||||
|
if (!$info) {
|
||||||
|
throw new BusinessException('提交失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 异步翻译并写入 hs_vehicle_data_translation 表
|
||||||
|
(new TranslationService())->queueTranslations(
|
||||||
|
'vehicleNewAttributes',
|
||||||
|
$info->id,
|
||||||
|
$sourceLocale,
|
||||||
|
$sourceFields
|
||||||
|
);
|
||||||
|
|
||||||
|
$valuesId = [];
|
||||||
|
foreach ($values as $value) {
|
||||||
|
$askedsourceFields = $VehicleNewAttributeValuesService->extractSourceFields($value);
|
||||||
|
$value['attribute_id'] = $info->id;
|
||||||
|
$value_res = $VehicleNewAttributeValuesService->create($value);
|
||||||
|
if (!$value_res) {
|
||||||
|
throw new BusinessException('提交失败');
|
||||||
|
}
|
||||||
|
(new TranslationService())->queueTranslations(
|
||||||
|
'vehicleNewAttributeValues',
|
||||||
|
$value_res->id,
|
||||||
|
$sourceLocale,
|
||||||
|
$askedsourceFields
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Db::rollBack();
|
||||||
|
throw $th;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(array $params, int $id)
|
||||||
|
{
|
||||||
|
$sourceLocale = locale();
|
||||||
|
$sourceFields = $this->extractSourceFields($params);
|
||||||
|
|
||||||
|
if (empty($sourceFields)) {
|
||||||
|
throw new \InvalidArgumentException("请传递至少一条 {$sourceLocale} 语言的翻译字段");
|
||||||
|
};
|
||||||
|
|
||||||
|
$values = $params['value'];
|
||||||
|
unset($params['value']);
|
||||||
|
$VehicleNewAttributeValuesService = new VehicleNewAttributeValuesService(new VehicleNewAttributeValuesModel());
|
||||||
|
Db::beginTransaction();
|
||||||
|
try {
|
||||||
|
$info = $this->update($id, $params);
|
||||||
|
if (!$info) {
|
||||||
|
throw new BusinessException('提交失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 异步翻译并写入 hs_vehicle_data_translation 表
|
||||||
|
(new TranslationService())->queueTranslations(
|
||||||
|
'vehicleNewAttributes',
|
||||||
|
$id,
|
||||||
|
$sourceLocale,
|
||||||
|
$sourceFields
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$valuesId = [];
|
||||||
|
foreach ($values as $value) {
|
||||||
|
$valuesourceFields = $VehicleNewAttributeValuesService->extractSourceFields($value);
|
||||||
|
$value['attribute_id'] = $id;
|
||||||
|
|
||||||
|
if(!empty($value['id'])){
|
||||||
|
$valueId = $value['id'];
|
||||||
|
$valuesId[] = $valueId;
|
||||||
|
$value_res = $VehicleNewAttributeValuesService->update($valueId, $value);
|
||||||
|
if (!$value_res) {
|
||||||
|
throw new BusinessException('提交失败:属性值');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unset($value['id']);
|
||||||
|
$value_res = $VehicleNewAttributeValuesService->create($value);
|
||||||
|
if (!$value_res) {
|
||||||
|
throw new BusinessException('提交失败:属性值');
|
||||||
|
}
|
||||||
|
$valueId = $value_res->id;
|
||||||
|
$valuesId[] = $valueId;
|
||||||
|
}
|
||||||
|
|
||||||
|
(new TranslationService())->queueTranslations(
|
||||||
|
'vehicleNewAttributeValues',
|
||||||
|
$valueId,
|
||||||
|
$sourceLocale,
|
||||||
|
$valuesourceFields
|
||||||
|
);
|
||||||
|
}
|
||||||
|
VehicleNewAttributeValuesModel::whereNotIn('id', $valuesId)->where('attribute_id',$id)->delete();
|
||||||
|
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Db::rollBack();
|
||||||
|
throw $th;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\service;
|
||||||
|
|
||||||
|
use app\console\model\VehicleNewAttributesTranslationModel;
|
||||||
|
use app\mzl\common\services\BaseService;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class VehicleNewAttributesTranslationService extends BaseService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 定义模型
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getModel(): string
|
||||||
|
{
|
||||||
|
return VehicleNewAttributesTranslationModel::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多场景配置
|
||||||
|
*/
|
||||||
|
public function queryScenes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// 'default' => function ($params) {
|
||||||
|
// $keyword = $params['keyword'] ?? '';
|
||||||
|
// return [
|
||||||
|
// 'filters' => [
|
||||||
|
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||||
|
// ],
|
||||||
|
// 'fields' => ['id'],
|
||||||
|
// 'relations' => [],
|
||||||
|
// 'custom' => function(Builder $q) use ($keyword) {
|
||||||
|
// // 示例
|
||||||
|
// if ($keyword) {
|
||||||
|
// $q->where(function($q2) use($keyword) {
|
||||||
|
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||||
|
// $q3->where('***', 'like', "%{$keyword}%");
|
||||||
|
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||||
|
// $q4->where('***', 'like', "%{$keyword}%");
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// 'sorts' => [
|
||||||
|
// ['field' => 'created_at', 'direction' => 'desc']
|
||||||
|
// ],
|
||||||
|
// 'pagination' => [
|
||||||
|
// 'page' => $params['page'] ?? 1,
|
||||||
|
// 'per_page' => $params['per_page'] ?? 10,
|
||||||
|
// ]
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\service;
|
||||||
|
|
||||||
|
use app\console\model\VehicleNewSkuAttributesModel;
|
||||||
|
use app\mzl\common\services\BaseService;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class VehicleNewSkuAttributesService extends BaseService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 定义模型
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getModel(): string
|
||||||
|
{
|
||||||
|
return VehicleNewSkuAttributesModel::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多场景配置
|
||||||
|
*/
|
||||||
|
public function queryScenes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'default' => function ($params) {
|
||||||
|
return [
|
||||||
|
'filters' => [
|
||||||
|
['field' => 'id', 'operator' => '=', 'value' => '7']
|
||||||
|
],
|
||||||
|
'fields' => ['id','attribute_id','value_id','img'],
|
||||||
|
'relations' => [
|
||||||
|
'attribute' => ['id', 'input_type', 'is_img', 'status'],
|
||||||
|
'attribute.translation' => ['attribute_name'],
|
||||||
|
'value' => ['id','color_code'],
|
||||||
|
'value.translation' => ['value_name'],
|
||||||
|
],
|
||||||
|
'sorts' => [
|
||||||
|
['field' => 'created_at', 'direction' => 'desc']
|
||||||
|
],
|
||||||
|
'pagination' => [
|
||||||
|
'page' => $params['page'] ?? 1,
|
||||||
|
'per_page' => $params['per_page'] ?? 10,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
},
|
||||||
|
// 'default' => function ($params) {
|
||||||
|
// $keyword = $params['keyword'] ?? '';
|
||||||
|
// return [
|
||||||
|
// 'filters' => [
|
||||||
|
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||||
|
// ],
|
||||||
|
// 'fields' => ['id'],
|
||||||
|
// 'relations' => [],
|
||||||
|
// 'custom' => function(Builder $q) use ($keyword) {
|
||||||
|
// // 示例
|
||||||
|
// if ($keyword) {
|
||||||
|
// $q->where(function($q2) use($keyword) {
|
||||||
|
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||||
|
// $q3->where('***', 'like', "%{$keyword}%");
|
||||||
|
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||||
|
// $q4->where('***', 'like', "%{$keyword}%");
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// 'sorts' => [
|
||||||
|
// ['field' => 'created_at', 'direction' => 'desc']
|
||||||
|
// ],
|
||||||
|
// 'pagination' => [
|
||||||
|
// 'page' => $params['page'] ?? 1,
|
||||||
|
// 'per_page' => $params['per_page'] ?? 10,
|
||||||
|
// ]
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,177 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\service;
|
||||||
|
|
||||||
|
use app\console\model\VehicleNewAttributeValuesModel;
|
||||||
|
use app\console\model\VehicleNewSkuAttributesModel;
|
||||||
|
use app\console\model\VehicleNewSkusModel;
|
||||||
|
use app\mzl\common\services\BaseService;
|
||||||
|
use app\mzl\modules\translation\service\TranslationService;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use support\Db;
|
||||||
|
use support\exception\BusinessException;
|
||||||
|
|
||||||
|
class VehicleNewSkusService extends BaseService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 定义模型
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getModel(): string
|
||||||
|
{
|
||||||
|
return VehicleNewSkusModel::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多场景配置
|
||||||
|
*/
|
||||||
|
public function queryScenes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Sitech' => function ($params) {
|
||||||
|
return [
|
||||||
|
'filters' => [
|
||||||
|
['field' => 'status', 'operator' => '=', 'value' => '1'],
|
||||||
|
],
|
||||||
|
'fields' => ['id','status'],
|
||||||
|
'relations' => [
|
||||||
|
'skuAttributes' => [],
|
||||||
|
'skuAttributes.attribute' => ['id', 'input_type', 'is_img', 'status'],
|
||||||
|
// 'skuAttributes.attribute.translation' => ['attribute_name'],
|
||||||
|
'skuAttributes.value' => ['id','color_code'],
|
||||||
|
],
|
||||||
|
'sorts' => [
|
||||||
|
['field' => 'created_at', 'direction' => 'desc']
|
||||||
|
],
|
||||||
|
'pagination' => [
|
||||||
|
'page' => $params['page'] ?? 1,
|
||||||
|
'per_page' => $params['per_page'] ?? 10,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
},
|
||||||
|
'show' => function ($params) {
|
||||||
|
return [
|
||||||
|
'filters' => [
|
||||||
|
['field'=>'id', 'operator'=>'=', 'value'=> $params['id']],
|
||||||
|
],
|
||||||
|
'fields' => ['id', 'status'],
|
||||||
|
'relations' => [
|
||||||
|
'skuAttributes' => [],
|
||||||
|
'skuAttributes.attribute' => ['id', 'input_type', 'is_img', 'status'],
|
||||||
|
// 'skuAttributes.attribute.translation' => ['attribute_name'],
|
||||||
|
'skuAttributes.value' => ['id','color_code'],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function add(array $params)
|
||||||
|
{
|
||||||
|
$sourceLocale = locale();
|
||||||
|
// $sourceFields = $this->extractSourceFields($params);
|
||||||
|
//
|
||||||
|
// if (empty($sourceFields)) {
|
||||||
|
// throw new \InvalidArgumentException("请传递至少一条 {$sourceLocale} 语言的翻译字段");
|
||||||
|
// };
|
||||||
|
|
||||||
|
$skuAttributes = $params['skuAttributes'];
|
||||||
|
unset($params['skuAttributes']);
|
||||||
|
$VehicleNewSkuAttributesService = new VehicleNewSkuAttributesService(new VehicleNewSkuAttributesModel());
|
||||||
|
Db::beginTransaction();
|
||||||
|
try {
|
||||||
|
$sku_code = sprintf("%05d", $params['vehicle_id']);
|
||||||
|
$params['sku_code'] = rand(100,999).$sku_code[0].' '.substr($sku_code,1).' '.sprintf("%04d", $skuAttributes[0]['attribute_id']).' '.sprintf("%04d", $skuAttributes[0]['value_id']);
|
||||||
|
|
||||||
|
$info = $this->create($params);
|
||||||
|
if (!$info) {
|
||||||
|
throw new BusinessException('提交失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 异步翻译并写入 hs_vehicle_data_translation 表
|
||||||
|
// (new TranslationService())->queueTranslations(
|
||||||
|
// 'vehicleNewAttributes',
|
||||||
|
// $info->id,
|
||||||
|
// $sourceLocale,
|
||||||
|
// $sourceFields
|
||||||
|
// );
|
||||||
|
|
||||||
|
foreach ($skuAttributes as $skuAttribute) {
|
||||||
|
$skuAttribute['sku_id'] = $info->id;
|
||||||
|
$skuAttribute_res = $VehicleNewSkuAttributesService->create($skuAttribute);
|
||||||
|
if (!$skuAttribute_res) {
|
||||||
|
throw new BusinessException('提交失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Db::rollBack();
|
||||||
|
throw $th;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(array $params, int $id)
|
||||||
|
{
|
||||||
|
$sourceLocale = locale();
|
||||||
|
// $sourceFields = $this->extractSourceFields($params);
|
||||||
|
//
|
||||||
|
// if (empty($sourceFields)) {
|
||||||
|
// throw new \InvalidArgumentException("请传递至少一条 {$sourceLocale} 语言的翻译字段");
|
||||||
|
// };
|
||||||
|
|
||||||
|
$skuAttributes = $params['skuAttributes'];
|
||||||
|
unset($params['skuAttributes']);
|
||||||
|
$VehicleNewSkuAttributesService = new VehicleNewSkuAttributesService(new VehicleNewSkuAttributesModel());
|
||||||
|
Db::beginTransaction();
|
||||||
|
try {
|
||||||
|
$info = $this->update($id, $params);
|
||||||
|
if (!$info) {
|
||||||
|
throw new BusinessException('提交失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 异步翻译并写入 hs_vehicle_data_translation 表
|
||||||
|
// (new TranslationService())->queueTranslations(
|
||||||
|
// 'vehicleNewAttributes',
|
||||||
|
// $id,
|
||||||
|
// $sourceLocale,
|
||||||
|
// $sourceFields
|
||||||
|
// );
|
||||||
|
|
||||||
|
|
||||||
|
$skuAttributesId = [];
|
||||||
|
foreach ($skuAttributes as $skuAttribute) {
|
||||||
|
$skuAttribute['sku_id'] = $id;
|
||||||
|
|
||||||
|
if(!empty($skuAttribute['id'])){
|
||||||
|
$skuAttributeId = $skuAttribute['id'];
|
||||||
|
$skuAttributesId[] = $skuAttributeId;
|
||||||
|
$skuAttribute_res = $VehicleNewSkuAttributesService->update($skuAttributeId, $skuAttribute);
|
||||||
|
if (!$skuAttribute_res) {
|
||||||
|
throw new BusinessException('提交失败:属性值');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unset($skuAttribute['id']);
|
||||||
|
$skuAttribute_res = $VehicleNewSkuAttributesService->create($skuAttribute);
|
||||||
|
if (!$skuAttribute_res) {
|
||||||
|
throw new BusinessException('提交失败:属性值');
|
||||||
|
}
|
||||||
|
$skuAttributeId = $skuAttribute_res->id;
|
||||||
|
$skuAttributesId[] = $skuAttributeId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
VehicleNewSkuAttributesModel::whereNotIn('id', $skuAttributesId)->where('attribute_id',$id)->delete();
|
||||||
|
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Db::rollBack();
|
||||||
|
throw $th;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\validate;
|
||||||
|
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
|
class VehicleNewAttributeCategoriesTranslationValidator extends Validate
|
||||||
|
{
|
||||||
|
// 规则
|
||||||
|
protected $rule = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 提示
|
||||||
|
protected $message = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 场景
|
||||||
|
protected $scene = [
|
||||||
|
'store' => [
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'update' => [
|
||||||
|
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\validate;
|
||||||
|
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
|
class VehicleNewAttributeCategoriesValidator extends Validate
|
||||||
|
{
|
||||||
|
// 规则
|
||||||
|
protected $rule = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 提示
|
||||||
|
protected $message = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 场景
|
||||||
|
protected $scene = [
|
||||||
|
'store' => [
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'update' => [
|
||||||
|
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\validate;
|
||||||
|
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
|
class VehicleNewAttributeValuesTranslationValidator extends Validate
|
||||||
|
{
|
||||||
|
// 规则
|
||||||
|
protected $rule = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 提示
|
||||||
|
protected $message = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 场景
|
||||||
|
protected $scene = [
|
||||||
|
'store' => [
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'update' => [
|
||||||
|
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\validate;
|
||||||
|
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
|
class VehicleNewAttributeValuesValidator extends Validate
|
||||||
|
{
|
||||||
|
// 规则
|
||||||
|
protected $rule = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 提示
|
||||||
|
protected $message = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 场景
|
||||||
|
protected $scene = [
|
||||||
|
'store' => [
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'update' => [
|
||||||
|
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\validate;
|
||||||
|
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
|
class VehicleNewAttributesTranslationValidator extends Validate
|
||||||
|
{
|
||||||
|
// 规则
|
||||||
|
protected $rule = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 提示
|
||||||
|
protected $message = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 场景
|
||||||
|
protected $scene = [
|
||||||
|
'store' => [
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'update' => [
|
||||||
|
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\validate;
|
||||||
|
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
|
class VehicleNewAttributesValidator extends Validate
|
||||||
|
{
|
||||||
|
// 规则
|
||||||
|
protected $rule = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 提示
|
||||||
|
protected $message = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 场景
|
||||||
|
protected $scene = [
|
||||||
|
'store' => [
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'update' => [
|
||||||
|
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\validate;
|
||||||
|
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
|
class VehicleNewSkuAttributesValidator extends Validate
|
||||||
|
{
|
||||||
|
// 规则
|
||||||
|
protected $rule = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 提示
|
||||||
|
protected $message = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 场景
|
||||||
|
protected $scene = [
|
||||||
|
'store' => [
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'update' => [
|
||||||
|
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\console\validate;
|
||||||
|
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
|
class VehicleNewSkusValidator extends Validate
|
||||||
|
{
|
||||||
|
// 规则
|
||||||
|
protected $rule = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 提示
|
||||||
|
protected $message = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 场景
|
||||||
|
protected $scene = [
|
||||||
|
'store' => [
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'update' => [
|
||||||
|
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -67,6 +67,18 @@ return [
|
|||||||
'translation_model' => \app\console\model\VehicleNewContentTranslationModel::class,
|
'translation_model' => \app\console\model\VehicleNewContentTranslationModel::class,
|
||||||
'foreign_key' => 'content_id',
|
'foreign_key' => 'content_id',
|
||||||
],
|
],
|
||||||
|
'vehicleNewAttributes' => [
|
||||||
|
'translation_model' => \app\console\model\VehicleNewAttributesTranslationModel::class,
|
||||||
|
'foreign_key' => 'attributes_id',
|
||||||
|
],
|
||||||
|
'vehicleNewAttributeValues' => [
|
||||||
|
'translation_model' => \app\console\model\VehicleNewAttributeValuesTranslationModel::class,
|
||||||
|
'foreign_key' => 'values_id',
|
||||||
|
],
|
||||||
|
'vehicleNewAttributeCategories' => [
|
||||||
|
'translation_model' => \app\console\model\VehicleNewAttributeCategoriesTranslationModel::class,
|
||||||
|
'foreign_key' => 'categories_id',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
// 默认支持的目标语种列表
|
// 默认支持的目标语种列表
|
||||||
|
|||||||
@@ -186,6 +186,29 @@ Route::group('/console', function() {
|
|||||||
Route::any('/vehicle/new/{id}/delete', [\app\console\controller\VehicleNewController::class, 'destroy']);
|
Route::any('/vehicle/new/{id}/delete', [\app\console\controller\VehicleNewController::class, 'destroy']);
|
||||||
Route::any('/vehicle/new/{id}/detail', [\app\console\controller\VehicleNewController::class, 'detail']);
|
Route::any('/vehicle/new/{id}/detail', [\app\console\controller\VehicleNewController::class, 'detail']);
|
||||||
|
|
||||||
|
//新车sku
|
||||||
|
Route::any('/vehicle/new/sku/list', [\app\console\controller\VehicleNewSkusController::class, 'index']);
|
||||||
|
Route::any('/vehicle/new/sku/attributes/list', [\app\console\controller\VehicleNewSkuAttributesController::class, 'index']);
|
||||||
|
Route::any('/vehicle/new/sku/add', [\app\console\controller\VehicleNewSkusController::class, 'add']);
|
||||||
|
Route::any('/vehicle/new/sku/{id}/update', [\app\console\controller\VehicleNewSkusController::class, 'edit']);
|
||||||
|
Route::any('/vehicle/new/sku/{id}/delete', [\app\console\controller\VehicleNewSkusController::class, 'destroy']);
|
||||||
|
Route::any('/vehicle/new/sku/{id}/detail', [\app\console\controller\VehicleNewSkusController::class, 'detail']);
|
||||||
|
|
||||||
|
//新车属性
|
||||||
|
Route::any('/vehicle/new/attributes/list', [\app\console\controller\VehicleNewAttributesController::class, 'index']);
|
||||||
|
Route::any('/vehicle/new/attributes/preset', [\app\console\controller\VehicleNewAttributesController::class, 'presets']);
|
||||||
|
Route::any('/vehicle/new/attributes/add', [\app\console\controller\VehicleNewAttributesController::class, 'add']);
|
||||||
|
Route::any('/vehicle/new/attributes/{id}/update', [\app\console\controller\VehicleNewAttributesController::class, 'edit']);
|
||||||
|
Route::any('/vehicle/new/attributes/{id}/delete', [\app\console\controller\VehicleNewAttributesController::class, 'destroy']);
|
||||||
|
Route::any('/vehicle/new/attributes/{id}/detail', [\app\console\controller\VehicleNewAttributesController::class, 'detail']);
|
||||||
|
|
||||||
|
//新车属性分类
|
||||||
|
Route::any('/vehicle/new/categories/list', [\app\console\controller\VehicleNewAttributeCategoriesController::class, 'index']);
|
||||||
|
Route::any('/vehicle/new/categories/add', [\app\console\controller\VehicleNewAttributeCategoriesController::class, 'add']);
|
||||||
|
Route::any('/vehicle/new/categories/{id}/update', [\app\console\controller\VehicleNewAttributeCategoriesController::class, 'edit']);
|
||||||
|
Route::any('/vehicle/new/categories/{id}/delete', [\app\console\controller\VehicleNewAttributeCategoriesController::class, 'destroy']);
|
||||||
|
Route::any('/vehicle/new/categories/{id}/detail', [\app\console\controller\VehicleNewAttributeCategoriesController::class, 'detail']);
|
||||||
|
|
||||||
// 上传
|
// 上传
|
||||||
Route::any('/upload/image', [\app\mzl\modules\upload\controller\UploadController::class, 'uploadImage']);
|
Route::any('/upload/image', [\app\mzl\modules\upload\controller\UploadController::class, 'uploadImage']);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user