sku
This commit is contained in:
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\controller;
|
||||||
|
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use app\apis\model\VehicleNewAttributeValuesModel;
|
||||||
|
use app\apis\service\VehicleNewAttributeValuesService;
|
||||||
|
use app\apis\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\apis\controller;
|
||||||
|
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use app\apis\model\VehicleNewAttributeValuesTranslationModel;
|
||||||
|
use app\apis\service\VehicleNewAttributeValuesTranslationService;
|
||||||
|
use app\apis\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,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\controller;
|
||||||
|
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use app\apis\model\VehicleNewAttributesModel;
|
||||||
|
use app\apis\service\VehicleNewAttributesService;
|
||||||
|
use app\apis\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') {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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\apis\controller;
|
||||||
|
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use app\apis\model\VehicleNewAttributesTranslationModel;
|
||||||
|
use app\apis\service\VehicleNewAttributesTranslationService;
|
||||||
|
use app\apis\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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace app\apis\controller;
|
namespace app\apis\controller;
|
||||||
|
|
||||||
|
use app\apis\model\VehicleNewAttributesTranslationModel;
|
||||||
|
use app\apis\model\VehicleNewAttributeValuesTranslationModel;
|
||||||
use support\Request;
|
use support\Request;
|
||||||
use support\Response;
|
use support\Response;
|
||||||
use app\apis\model\VehicleNewModel;
|
use app\apis\model\VehicleNewModel;
|
||||||
@@ -104,6 +106,16 @@ class VehicleNewController extends BaseController
|
|||||||
$contentRes['content'] = isset($content['translation']) ? $content['translation']['content']:'';
|
$contentRes['content'] = isset($content['translation']) ? $content['translation']['content']:'';
|
||||||
$result['content'][] = $contentRes;
|
$result['content'][] = $contentRes;
|
||||||
}
|
}
|
||||||
|
foreach ($item['sku'] as &$sku) {
|
||||||
|
foreach ($sku['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'];
|
||||||
|
}
|
||||||
|
$result['sku'][] = $sku;
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\controller;
|
||||||
|
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use app\apis\model\VehicleNewSkuAttributesModel;
|
||||||
|
use app\apis\service\VehicleNewSkuAttributesService;
|
||||||
|
use app\apis\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') {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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,98 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\controller;
|
||||||
|
|
||||||
|
use app\apis\model\VehicleNewAttributesTranslationModel;
|
||||||
|
use app\apis\model\VehicleNewAttributeValuesTranslationModel;
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use app\apis\model\VehicleNewSkusModel;
|
||||||
|
use app\apis\service\VehicleNewSkusService;
|
||||||
|
use app\apis\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 {
|
||||||
|
return parent::index($request, $scene);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\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', 'color_code', 'price_modifier', 'sort_order', 'created_at', 'updated_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\apis\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,77 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\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', '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\apis\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 = [];
|
||||||
|
}
|
||||||
@@ -118,4 +118,9 @@ class VehicleNewModel extends Model
|
|||||||
{
|
{
|
||||||
return $this->hasMany(VehicleNewContentModel::class, 'vehicle_id', 'id');
|
return $this->hasMany(VehicleNewContentModel::class, 'vehicle_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sku()
|
||||||
|
{
|
||||||
|
return $this->hasMany(VehicleNewSkusModel::class, 'vehicle_id', 'id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\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', 'updated_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,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\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,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\service;
|
||||||
|
|
||||||
|
use app\apis\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,
|
||||||
|
// ]
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\service;
|
||||||
|
|
||||||
|
use app\apis\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,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\service;
|
||||||
|
|
||||||
|
use app\apis\model\VehicleNewAttributesModel;
|
||||||
|
use app\mzl\common\services\BaseService;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class VehicleNewAttributesService extends BaseService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 定义模型
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getModel(): string
|
||||||
|
{
|
||||||
|
return VehicleNewAttributesModel::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,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\service;
|
||||||
|
|
||||||
|
use app\apis\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,
|
||||||
|
// ]
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -78,6 +78,10 @@ class VehicleNewService extends BaseService
|
|||||||
'types.translation' => ['type_id', 'name'],
|
'types.translation' => ['type_id', 'name'],
|
||||||
'energy.translation' => ['energy_id', 'name'],
|
'energy.translation' => ['energy_id', 'name'],
|
||||||
'models.translation' => ['model_id', 'name'],
|
'models.translation' => ['model_id', 'name'],
|
||||||
|
'sku' => [],
|
||||||
|
'sku.skuAttributes' => [],
|
||||||
|
'sku.skuAttributes.attribute' => ['id', 'input_type', 'is_img', 'status'],
|
||||||
|
'sku.skuAttributes.value' => ['id','color_code'],
|
||||||
],
|
],
|
||||||
'sorts' => [
|
'sorts' => [
|
||||||
['field' => 'id', 'direction' => 'desc']
|
['field' => 'id', 'direction' => 'desc']
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\service;
|
||||||
|
|
||||||
|
use app\apis\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) {
|
||||||
|
// $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,93 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\service;
|
||||||
|
|
||||||
|
use app\apis\model\VehicleNewSkusModel;
|
||||||
|
use app\mzl\common\services\BaseService;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class VehicleNewSkusService extends BaseService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 定义模型
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getModel(): string
|
||||||
|
{
|
||||||
|
return VehicleNewSkusModel::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多场景配置
|
||||||
|
*/
|
||||||
|
public function queryScenes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'default' => function ($params) {
|
||||||
|
return [
|
||||||
|
'filters' => [
|
||||||
|
['field' => 'status', 'operator' => '=', 'value' => '1'],
|
||||||
|
],
|
||||||
|
'fields' => ['id','status'],
|
||||||
|
'relations' => [
|
||||||
|
'skuAttributes' => [],
|
||||||
|
'skuAttributes.attribute' => ['id', 'input_type', 'is_img', 'status'],
|
||||||
|
'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'],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
},
|
||||||
|
// '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,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\validate;
|
||||||
|
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
|
class VehicleNewAttributeValuesTranslationValidator extends Validate
|
||||||
|
{
|
||||||
|
// 规则
|
||||||
|
protected $rule = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 提示
|
||||||
|
protected $message = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 场景
|
||||||
|
protected $scene = [
|
||||||
|
'store' => [
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'update' => [
|
||||||
|
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\validate;
|
||||||
|
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
|
class VehicleNewAttributeValuesValidator extends Validate
|
||||||
|
{
|
||||||
|
// 规则
|
||||||
|
protected $rule = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 提示
|
||||||
|
protected $message = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 场景
|
||||||
|
protected $scene = [
|
||||||
|
'store' => [
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'update' => [
|
||||||
|
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\validate;
|
||||||
|
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
|
class VehicleNewAttributesTranslationValidator extends Validate
|
||||||
|
{
|
||||||
|
// 规则
|
||||||
|
protected $rule = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 提示
|
||||||
|
protected $message = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 场景
|
||||||
|
protected $scene = [
|
||||||
|
'store' => [
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'update' => [
|
||||||
|
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\validate;
|
||||||
|
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
|
class VehicleNewAttributesValidator extends Validate
|
||||||
|
{
|
||||||
|
// 规则
|
||||||
|
protected $rule = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 提示
|
||||||
|
protected $message = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 场景
|
||||||
|
protected $scene = [
|
||||||
|
'store' => [
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'update' => [
|
||||||
|
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\validate;
|
||||||
|
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
|
class VehicleNewSkuAttributesValidator extends Validate
|
||||||
|
{
|
||||||
|
// 规则
|
||||||
|
protected $rule = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 提示
|
||||||
|
protected $message = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 场景
|
||||||
|
protected $scene = [
|
||||||
|
'store' => [
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'update' => [
|
||||||
|
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\apis\validate;
|
||||||
|
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
|
class VehicleNewSkusValidator extends Validate
|
||||||
|
{
|
||||||
|
// 规则
|
||||||
|
protected $rule = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 提示
|
||||||
|
protected $message = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// 场景
|
||||||
|
protected $scene = [
|
||||||
|
'store' => [
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'update' => [
|
||||||
|
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -49,6 +49,9 @@ Route::group('/apis', function() {
|
|||||||
// 新车管理
|
// 新车管理
|
||||||
Route::any('/vehicle/new/list', [\app\apis\controller\VehicleNewController::class, 'index']);
|
Route::any('/vehicle/new/list', [\app\apis\controller\VehicleNewController::class, 'index']);
|
||||||
Route::any('/vehicle/new/{id}/detail', [\app\apis\controller\VehicleNewController::class, 'detail']);
|
Route::any('/vehicle/new/{id}/detail', [\app\apis\controller\VehicleNewController::class, 'detail']);
|
||||||
|
//新车属性
|
||||||
|
Route::any('/vehicle/new/sku/{id}/detail', [\app\apis\controller\VehicleNewSkusController::class, 'detail']);
|
||||||
|
Route::any('/vehicle/new/sku/list', [\app\apis\controller\VehicleNewSkusController::class, 'index']);
|
||||||
// 能源列表
|
// 能源列表
|
||||||
Route::any('/energy/preset', [\app\console\controller\EnergyController::class, 'presets']);
|
Route::any('/energy/preset', [\app\console\controller\EnergyController::class, 'presets']);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user