feat: 产品相关接口

This commit is contained in:
2025-01-24 17:54:04 +08:00
parent 65bd37042a
commit db489a8429
18 changed files with 787 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
<?php
declare (strict_types = 1);
namespace app\common\model;
use think\Model;
/**
* @mixin \think\Model
*/
class BaseModel extends Model
{
/**
* 根据主键查询
*/
public function scopeBypk($query, $pk)
{
$query->where((new static)->pk, '=', $pk);
}
/**
* 根据多主键查询
*/
public function scopeBypks($query, $pks)
{
if (!is_array($pks) && (is_string($pks) && false === strpos($pks, ','))) {
throw new \Exception('pks参数为级数或逗号分隔字符串');
}
$query->where((new static)->pk, 'in', $pks);
}
}

View File

@@ -0,0 +1,28 @@
<?php
declare (strict_types = 1);
namespace app\common\model;
/**
* 产品属性模型
* @mixin \think\Model
*/
class ProductAttrBaseModel extends BaseModel
{
// 表名
protected $name = 'product_attr';
// 主键
protected $pk = 'id';
// 字段信息
protected $schema = [
'id' => 'int',
'language_id' => 'int',
'attr_name' => 'string',
'is_system' => 'string',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];
}

View File

@@ -0,0 +1,26 @@
<?php
declare (strict_types = 1);
namespace app\common\model;
/**
* 产品属性特征模型
* @mixin \think\Model
*/
class ProductAttrPropBaseModel extends BaseModel
{
// 表名
protected $name = 'product_attr_prop';
// 主键
protected $pk = 'id';
// 字段信息
protected $schema = [
'id' => 'int',
'prop_name' => 'string',
'prop_value' => 'string',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
}

View File

@@ -0,0 +1,43 @@
<?php
declare (strict_types = 1);
namespace app\common\model;
/**
* 产品spu模型
* @mixin \think\Model
*/
class ProductBaseModel extends BaseModel
{
// 表名
protected $name = 'product';
// 主键
protected $pk = 'id';
// 字段信息
protected $schema = [
'id' => 'int',
'language_id' => 'int',
'category_id' => 'int',
'spu' => 'string',
'name' => 'string',
'short_name' => 'string',
'cover_image' => 'string',
'desc' => 'string',
'video_img' => 'string',
'video_url' => 'string',
'is_sale' => 'int',
'is_new' => 'int',
'is_hot' => 'int',
'sort' => 'int',
'detail' => 'string',
'status' => 'int',
'seo_title' => 'string',
'seo_keywords' => 'string',
'seo_desc' => 'string',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime'
];
}

View File

@@ -0,0 +1,38 @@
<?php
declare (strict_types = 1);
namespace app\common\model;
/**
* 产品分类模型
* @mixin \think\Model
*/
class ProductCategoryBaseModel extends BaseModel
{
// 表名
protected $name = 'product_category';
// 主键
protected $pk = 'id';
// 字段信息
protected $schema = [
'id' => 'int',
'language_id' => 'int',
'unique_id' => 'string',
'pid' => 'int',
'name' => 'string',
'icon' => 'string',
'desc' => 'string',
'related_tco_category' => 'string',
'sort' => 'int',
'level' => 'int',
'is_show' => 'int',
'seo_title' => 'string',
'seo_keywords' => 'string',
'seo_desc' => 'string',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];
}

View File

@@ -0,0 +1,32 @@
<?php
declare (strict_types = 1);
namespace app\common\model;
/**
* 产品询盘记录模型
* @mixin \think\Model
*/
class ProductInquiryBaseModel extends BaseModel
{
// 表名
protected $name = 'product_inquiry';
// 主键
protected $pk = 'id';
// 字段信息
protected $schema = [
'id' => 'int',
'language_id' => 'int',
'corp_name' => 'string',
'fisrt_name' => 'string',
'last_name' => 'string',
'email' => 'string',
'phone' => 'string',
'country_name' => 'string',
'industry' => 'string',
'message' => 'string',
'created_at' => 'datetime'
];
}

View File

@@ -0,0 +1,27 @@
<?php
declare (strict_types = 1);
namespace app\common\model;
/**
* 产品参数模型
* @mixin \think\Model
*/
class ProductParamsBaseModel extends BaseModel
{
// 表名
protected $name = 'product_params';
// 主键
protected $pk = 'id';
// 字段信息
protected $schema = [
'id' => 'int',
'product_id' => 'int',
'name' => 'string',
'value' => 'string',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
}

View File

@@ -0,0 +1,28 @@
<?php
declare (strict_types = 1);
namespace app\common\model;
/**
* 产品购买链接模型
* @mixin \think\Model
*/
class ProductPurchaseLinkBaseModel extends BaseModel
{
// 表名
protected $name = 'product_purchase_link';
// 主键
protected $pk = 'id';
// 字段信息
protected $schema = [
'id' => 'int',
'language_id' => 'int',
'product_id' => 'int',
'platform_id' => 'int',
'link' => 'string',
'sort' => 'int',
'created_at' => 'datetime',
];
}

View File

@@ -0,0 +1,27 @@
<?php
declare (strict_types = 1);
namespace app\common\model;
/**
* 产品购买平台模型
* @mixin \think\Model
*/
class ProductPurchasePlatformBaseModel extends BaseModel
{
// 表名
protected $name = 'product_purchase_platform';
// 主键
protected $pk = 'id';
// 字段信息
protected $schema = [
'id' => 'int',
'language_id' => 'int',
'platform' => 'string',
'desc' => 'string',
'sort' => 'int',
'created_at' => 'datetime'
];
}

View File

@@ -0,0 +1,28 @@
<?php
declare (strict_types = 1);
namespace app\common\model;
/**
* 产品 - 关联产品模型
* @mixin \think\Model
*/
class ProductRelatedBaseModel extends BaseModel
{
// 表名
protected $name = 'product_related';
// 主键
protected $pk = 'id';
// 字段信息
protected $schema = [
'id' => 'int',
'product_id' => 'int',
'related_product_id' => 'int',
'desc' => 'string',
'sort' => 'int',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
}

View File

@@ -0,0 +1,23 @@
<?php
declare (strict_types = 1);
namespace app\common\model;
use think\Model;
/**
* 产品sku属性模型
* @mixin \think\Model
*/
class ProductSkuAttrBaseModel extends Model
{
// 表名
protected $name = 'product_sku_attr';
// 字段信息
protected $schema = [
'sku_id' => 'int',
'attr_id' => 'int',
'prop_id' => 'int',
];
}

View File

@@ -0,0 +1,29 @@
<?php
declare (strict_types = 1);
namespace app\common\model;
/**
* 产品sku模型
* @mixin \think\Model
*/
class ProductSkuBaseModel extends BaseModel
{
// 表名
protected $name = 'product_sku';
// 主键
protected $pk = 'id';
// 字段信息
protected $schema = [
'id' => 'int',
'product_id' => 'int',
'sku' => 'string',
'main_image' => 'string',
'photo_album' => 'string',
'sort' => 'int',
'created_at' => 'datetime',
'updated_at' => 'datetime'
];
}

View File

@@ -0,0 +1,35 @@
<?php
declare (strict_types = 1);
namespace app\common\model;
/**
* 产品 - 产品目录分类同步记录模型
* @mixin \think\Model
*/
class ProductTcoCategoryBaseModel extends BaseModel
{
// 表名
protected $name = 'product_tco_category';
// 主键
protected $pk = 'id';
// 字段信息
protected $schema = [
'id' => 'int',
'language_id' => 'int',
'name' => 'int',
'tco_id' => 'int',
'tco_pid' => 'int',
'tco_path' => 'string',
'erp_id' => 'int',
'erp_pid' => 'int',
'erp_path' => 'string',
'disabled' => 'int',
'sync_time' => 'int',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];
}