初始化
缺陷:主题配色需要优化整体的同风格
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\BaseApp\BaseModel;
|
||||
use App\Models\business\DepartmentModel;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
class AdminModel extends BaseModel
|
||||
@@ -20,4 +21,15 @@ class AdminModel extends BaseModel
|
||||
{
|
||||
return $this->hasOne(RoleModel::class, 'id', 'role_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 所属部门
|
||||
*
|
||||
* 部门表在 business 连接(cc_ 前缀),Eloquent 关联可以跨连接,
|
||||
* 但不能和本表做 SQL join,需要 join 时只能分两次查再在 PHP 里拼。
|
||||
*/
|
||||
public function department(): HasOne
|
||||
{
|
||||
return $this->hasOne(DepartmentModel::class, 'id', 'department_id');
|
||||
}
|
||||
}
|
||||
|
||||
24
app/Models/FileFolderModel.php
Normal file
24
app/Models/FileFolderModel.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\BaseApp\BaseModel;
|
||||
|
||||
/**
|
||||
* 素材文件夹(nl_file_folder)
|
||||
*
|
||||
* 只做素材的逻辑归类,与对象在 OSS 上的实际路径无关:
|
||||
* 移动素材如果跟着改对象键,已经发出去的历史地址会全部 404。
|
||||
*/
|
||||
class FileFolderModel extends BaseModel
|
||||
{
|
||||
protected $table = 'file_folder';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected $casts = [
|
||||
'pid' => 'integer',
|
||||
'sort' => 'integer',
|
||||
'status' => 'integer',
|
||||
];
|
||||
}
|
||||
@@ -4,14 +4,71 @@ namespace App\Models;
|
||||
|
||||
use App\BaseApp\BaseModel;
|
||||
|
||||
/**
|
||||
* 文件 / 素材表(nl_file)
|
||||
*
|
||||
* 原表只是上传流水(user_id + url)。素材库扩了对象键、体积、哈希与引用计数之后,
|
||||
* 它同时充当素材主表,type / source 的取值被同步、回收、前端筛选三处共用,
|
||||
* 所以固化成常量,免得三边各写一套魔法数字、还各写错一个。
|
||||
*/
|
||||
class FileModel extends BaseModel
|
||||
{
|
||||
/*
|
||||
* type 取值。0~4 是老表原有语义,5、6 是素材库补的:
|
||||
* 图册 PDF、报价 Excel 这类文件原先全落在「其他」里没法筛。
|
||||
*/
|
||||
public const TYPE_IMAGE = 0;
|
||||
public const TYPE_VIDEO = 1;
|
||||
public const TYPE_AUDIO = 2;
|
||||
public const TYPE_EXCEL = 3;
|
||||
public const TYPE_ARCHIVE = 4;
|
||||
public const TYPE_DOCUMENT = 5;
|
||||
public const TYPE_OTHER = 6;
|
||||
|
||||
/** source:经上传接口进来的 */
|
||||
public const SOURCE_UPLOAD = 0;
|
||||
/** source:从 OSS 反向列举补录的历史文件 */
|
||||
public const SOURCE_OSS = 1;
|
||||
|
||||
protected $table = 'file';
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* 数值列显式转型:MySQL 驱动会把 bigint / int 读成字符串,
|
||||
* 前端拿 size 做体积换算、拿 ref_count 判断能否回收时会被字符串坑到
|
||||
*
|
||||
* created_at / updated_at 不在此列:BaseModel 已经用访问器格式化成了日期串,
|
||||
* 再加 cast 只会让两套逻辑互相打架
|
||||
*/
|
||||
protected $casts = [
|
||||
'user_id' => 'integer',
|
||||
'oss_config_id' => 'integer',
|
||||
'folder_id' => 'integer',
|
||||
'type' => 'integer',
|
||||
'size' => 'integer',
|
||||
'width' => 'integer',
|
||||
'height' => 'integer',
|
||||
'ref_count' => 'integer',
|
||||
'last_scan_at' => 'integer',
|
||||
'source' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* 扩展名归类到 type
|
||||
*
|
||||
* 从 OSS 反向同步时手上只有对象键,没有上传时的 MIME,只能按扩展名判断
|
||||
*/
|
||||
public static function typeOfExt(string $ext): int
|
||||
{
|
||||
return match (strtolower(trim($ext, " \t\n\r\0\x0B."))) {
|
||||
'jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg', 'ico', 'avif', 'heic' => self::TYPE_IMAGE,
|
||||
'mp4', 'mov', 'avi', 'mkv', 'flv', 'wmv', 'webm', 'm3u8', 'ts' => self::TYPE_VIDEO,
|
||||
'mp3', 'wav', 'aac', 'flac', 'ogg', 'm4a', 'amr' => self::TYPE_AUDIO,
|
||||
'xls', 'xlsx', 'csv' => self::TYPE_EXCEL,
|
||||
'zip', 'rar', '7z', 'tar', 'gz', 'bz2' => self::TYPE_ARCHIVE,
|
||||
'pdf', 'doc', 'docx', 'ppt', 'pptx', 'txt', 'md' => self::TYPE_DOCUMENT,
|
||||
default => self::TYPE_OTHER,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
14
app/Models/RoleEndpointRelationModel.php
Normal file
14
app/Models/RoleEndpointRelationModel.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\BaseApp\BaseModel;
|
||||
|
||||
class RoleEndpointRelationModel extends BaseModel
|
||||
{
|
||||
protected $table = 'role_endpoint_relation';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public $timestamps = false;
|
||||
}
|
||||
20
app/Models/WxAppModel.php
Normal file
20
app/Models/WxAppModel.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\BaseApp\BaseModel;
|
||||
|
||||
/**
|
||||
* 小程序应用配置(nl_wx_app)
|
||||
*
|
||||
* app_secret / mch_key / mch_private_key 是密文列,读取必须走 WxAppService 解密,
|
||||
* 任何接口都不要直接把这三列返回给前端。
|
||||
*/
|
||||
class WxAppModel extends BaseModel
|
||||
{
|
||||
protected $table = 'wx_app';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected $hidden = ['app_secret', 'mch_key', 'mch_private_key'];
|
||||
}
|
||||
15
app/Models/business/CardClassModel.php
Normal file
15
app/Models/business/CardClassModel.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
|
||||
/**
|
||||
* 色卡分类(cc_card_class)
|
||||
*/
|
||||
class CardClassModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'card_class';
|
||||
|
||||
protected $guarded = [];
|
||||
}
|
||||
15
app/Models/business/CarouselModel.php
Normal file
15
app/Models/business/CarouselModel.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
|
||||
/**
|
||||
* 小程序轮播图(cc_carousel)
|
||||
*/
|
||||
class CarouselModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'carousel';
|
||||
|
||||
protected $guarded = [];
|
||||
}
|
||||
35
app/Models/business/CatalogueModel.php
Normal file
35
app/Models/business/CatalogueModel.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* 商品图册(cc_catalogue)
|
||||
*
|
||||
* 老项目关系名写成 cateGory,序列化出来是 cate_gory,前端还得记这个拼写。
|
||||
* 新后端统一叫 category,列表里另外拍平成 category_name。
|
||||
*/
|
||||
class CatalogueModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'catalogue';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CategoryModel::class, 'category_id', 'id');
|
||||
}
|
||||
|
||||
public function priceSheet(): HasMany
|
||||
{
|
||||
return $this->hasMany(PriceSheetModel::class, 'catalogue_id', 'id');
|
||||
}
|
||||
|
||||
public function images(): HasMany
|
||||
{
|
||||
return $this->hasMany(ImageModel::class, 'catalogue_id', 'id');
|
||||
}
|
||||
}
|
||||
26
app/Models/business/CategoryModel.php
Normal file
26
app/Models/business/CategoryModel.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* 商品分类(cc_category)
|
||||
*/
|
||||
class CategoryModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'category';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function children(): HasMany
|
||||
{
|
||||
return $this->hasMany(self::class, 'pid', 'id');
|
||||
}
|
||||
|
||||
public function catalogues(): HasMany
|
||||
{
|
||||
return $this->hasMany(CatalogueModel::class, 'category_id', 'id');
|
||||
}
|
||||
}
|
||||
28
app/Models/business/ColorcardModel.php
Normal file
28
app/Models/business/ColorcardModel.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* 色卡(cc_colorcard)
|
||||
*
|
||||
* 外键列名是 card_class / company(不带 _id),沿用老表不改。
|
||||
*/
|
||||
class ColorcardModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'colorcard';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function cardClassInfo(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CardClassModel::class, 'card_class', 'id');
|
||||
}
|
||||
|
||||
public function companyInfo(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CompanyModel::class, 'company', 'id');
|
||||
}
|
||||
}
|
||||
15
app/Models/business/CompanyModel.php
Normal file
15
app/Models/business/CompanyModel.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
|
||||
/**
|
||||
* 色卡所属公司(cc_company)
|
||||
*/
|
||||
class CompanyModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'company';
|
||||
|
||||
protected $guarded = [];
|
||||
}
|
||||
18
app/Models/business/DepartmentModel.php
Normal file
18
app/Models/business/DepartmentModel.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
|
||||
/**
|
||||
* 部门表模型
|
||||
*
|
||||
* 直接复用老系统已有的 cc_department 表(结构正好够用:id/name/desc/status/pid/color/时间戳),
|
||||
* 部门数据零迁移。账号侧通过 nl_admin.department_id 关联。
|
||||
*/
|
||||
class DepartmentModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'department';
|
||||
|
||||
protected $guarded = [];
|
||||
}
|
||||
23
app/Models/business/EnterpriseModel.php
Normal file
23
app/Models/business/EnterpriseModel.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* 企业(cc_enterprise)
|
||||
*
|
||||
* 老表只有 name / logo,企业管理模块会补齐联系人、税号、结算方式、默认价格倍率等列。
|
||||
*/
|
||||
class EnterpriseModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'enterprise';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(WxUserModel::class, 'enterprise_id', 'id');
|
||||
}
|
||||
}
|
||||
15
app/Models/business/FactoryClassificationModel.php
Normal file
15
app/Models/business/FactoryClassificationModel.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
|
||||
/**
|
||||
* 工厂分类(cc_factory_classification)
|
||||
*/
|
||||
class FactoryClassificationModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'factory_classification';
|
||||
|
||||
protected $guarded = [];
|
||||
}
|
||||
23
app/Models/business/FactoryImageModel.php
Normal file
23
app/Models/business/FactoryImageModel.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* 工厂产品图(cc_factory_image)
|
||||
*
|
||||
* 外键列名就叫 factory(不是 factory_id),沿用老表不改。
|
||||
*/
|
||||
class FactoryImageModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'factory_image';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function factoryInfo(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(FactoryInfoModel::class, 'factory', 'id');
|
||||
}
|
||||
}
|
||||
29
app/Models/business/FactoryInfoModel.php
Normal file
29
app/Models/business/FactoryInfoModel.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* 工厂管理(cc_factory_info)
|
||||
*
|
||||
* 外键列名就叫 classification(不是 classification_id),沿用老表不改。
|
||||
*/
|
||||
class FactoryInfoModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'factory_info';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function classificationInfo(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(FactoryClassificationModel::class, 'classification', 'id');
|
||||
}
|
||||
|
||||
public function images(): HasMany
|
||||
{
|
||||
return $this->hasMany(FactoryImageModel::class, 'factory', 'id');
|
||||
}
|
||||
}
|
||||
26
app/Models/business/ImageModel.php
Normal file
26
app/Models/business/ImageModel.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* 商品相册(cc_image)
|
||||
*
|
||||
* type 1 渲染图 / 2 实物图,小程序详情页分两个列表展示
|
||||
*/
|
||||
class ImageModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'image';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public const TYPE_RENDER = 1;
|
||||
public const TYPE_PHYSICAL = 2;
|
||||
|
||||
public function catalogue(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CatalogueModel::class, 'catalogue_id', 'id');
|
||||
}
|
||||
}
|
||||
34
app/Models/business/ListItemModel.php
Normal file
34
app/Models/business/ListItemModel.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* 清单明细(cc_list_item)
|
||||
*
|
||||
* catalogue_id 指向商品图册;price_sheet_id 指向具体规格行,
|
||||
* 老库没有这个字段,所以历史数据这里是 0,转订单时要提示用户补选规格。
|
||||
*/
|
||||
class ListItemModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'list_item';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function catalogue(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CatalogueModel::class, 'catalogue_id', 'id');
|
||||
}
|
||||
|
||||
public function priceSheet(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PriceSheetModel::class, 'price_sheet_id', 'id');
|
||||
}
|
||||
|
||||
public function list(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ListModel::class, 'list_id', 'id');
|
||||
}
|
||||
}
|
||||
34
app/Models/business/ListModel.php
Normal file
34
app/Models/business/ListModel.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* 清单(cc_list)
|
||||
*
|
||||
* 一个小程序用户可以有多份清单,登录时会自动建一份「默认清单」。
|
||||
*/
|
||||
class ListModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'list';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(ListItemModel::class, 'list_id', 'id');
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WxUserModel::class, 'user_id', 'id');
|
||||
}
|
||||
|
||||
public function enterprise(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(EnterpriseModel::class, 'enterprise_id', 'id');
|
||||
}
|
||||
}
|
||||
23
app/Models/business/OrderDeliveryModel.php
Normal file
23
app/Models/business/OrderDeliveryModel.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* 发货记录(cc_order_delivery)
|
||||
*
|
||||
* 一个订单可能分批发货,所以是一对多而不是订单表上的几个字段。
|
||||
*/
|
||||
class OrderDeliveryModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'order_delivery';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function order(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(OrderModel::class, 'order_id', 'id');
|
||||
}
|
||||
}
|
||||
24
app/Models/business/OrderItemModel.php
Normal file
24
app/Models/business/OrderItemModel.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* 订单明细(cc_order_item)
|
||||
*
|
||||
* 标题、封面、规格、单价全部是下单那一刻的快照。catalogue_id 只用于溯源,
|
||||
* 展示金额与规格时不要回查商品表,否则后台改价会改掉历史订单。
|
||||
*/
|
||||
class OrderItemModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'order_item';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function order(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(OrderModel::class, 'order_id', 'id');
|
||||
}
|
||||
}
|
||||
63
app/Models/business/OrderModel.php
Normal file
63
app/Models/business/OrderModel.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* 订单(cc_order)
|
||||
*
|
||||
* 金额字段一律是整数分。状态用显式状态机(见 OrderService::transition),
|
||||
* 不要在业务代码里散落 if-else 直接改 status。
|
||||
*/
|
||||
class OrderModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'order';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public const STATUS_UNPAID = 0;
|
||||
public const STATUS_PAID = 1;
|
||||
public const STATUS_SHIPPED = 2;
|
||||
public const STATUS_DONE = 3;
|
||||
public const STATUS_CANCELLED = 4;
|
||||
|
||||
public const PAY_TYPE_VOUCHER = 1;
|
||||
public const PAY_TYPE_WECHAT = 2;
|
||||
|
||||
public const PAY_STATUS_UNPAID = 0;
|
||||
public const PAY_STATUS_AUDITING = 1;
|
||||
public const PAY_STATUS_PAID = 2;
|
||||
public const PAY_STATUS_REJECTED = 3;
|
||||
|
||||
public const DELIVERY_EXPRESS = 1;
|
||||
public const DELIVERY_PICKUP = 2;
|
||||
public const DELIVERY_COMPANY = 3;
|
||||
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(OrderItemModel::class, 'order_id', 'id');
|
||||
}
|
||||
|
||||
public function payments(): HasMany
|
||||
{
|
||||
return $this->hasMany(OrderPaymentModel::class, 'order_id', 'id');
|
||||
}
|
||||
|
||||
public function deliveries(): HasMany
|
||||
{
|
||||
return $this->hasMany(OrderDeliveryModel::class, 'order_id', 'id');
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WxUserModel::class, 'user_id', 'id');
|
||||
}
|
||||
|
||||
public function enterprise(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(EnterpriseModel::class, 'enterprise_id', 'id');
|
||||
}
|
||||
}
|
||||
27
app/Models/business/OrderPaymentModel.php
Normal file
27
app/Models/business/OrderPaymentModel.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* 支付记录(cc_order_payment)
|
||||
*
|
||||
* out_trade_no 有唯一索引,微信重复推送回调时靠它保证幂等。
|
||||
*/
|
||||
class OrderPaymentModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'order_payment';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public const STATUS_AUDITING = 0;
|
||||
public const STATUS_CONFIRMED = 1;
|
||||
public const STATUS_REJECTED = 2;
|
||||
|
||||
public function order(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(OrderModel::class, 'order_id', 'id');
|
||||
}
|
||||
}
|
||||
38
app/Models/business/PriceSheetModel.php
Normal file
38
app/Models/business/PriceSheetModel.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* 报价单(cc_price_sheet)
|
||||
*
|
||||
* 表里除 routine 外还有 6 个材质列(岩板、科技绒…),老项目 create() 从不给它们赋值、
|
||||
* 前端表单列也全注释了,属于没启用的死 schema。新后端只读不写,展示时按非空过滤,
|
||||
* 真要做多材质报价请走 cc_price_sheet_item 那套设计,不要继续往这些列上加逻辑。
|
||||
*/
|
||||
class PriceSheetModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'price_sheet';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* 历史材质列,仅用于展示过滤
|
||||
*/
|
||||
public const MATERIAL_FIELDS = [
|
||||
'routine',
|
||||
'plank_of_rock',
|
||||
'science_and_technology_velvet',
|
||||
'imitation_leather',
|
||||
'genuine_leather',
|
||||
'science_and_technology_cloth',
|
||||
'microfiber_skin',
|
||||
];
|
||||
|
||||
public function catalogue(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CatalogueModel::class, 'catalogue_id', 'id');
|
||||
}
|
||||
}
|
||||
24
app/Models/business/WxTemplateModel.php
Normal file
24
app/Models/business/WxTemplateModel.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
|
||||
/**
|
||||
* 小程序装修模板(cc_wx_template)
|
||||
*
|
||||
* tokens 存设计令牌(配色/字号/圆角/阴影/间距/动效曲线与时长),
|
||||
* layout 存页面骨架(每个页面用哪种排布)。小程序不支持动态 <style>,
|
||||
* 所以令牌最终是注入到根节点的 CSS 变量,不能塞任意 CSS 文本进来。
|
||||
*/
|
||||
class WxTemplateModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'wx_template';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected $casts = [
|
||||
'tokens' => 'array',
|
||||
'layout' => 'array',
|
||||
];
|
||||
}
|
||||
41
app/Models/business/WxUserModel.php
Normal file
41
app/Models/business/WxUserModel.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\business;
|
||||
|
||||
use App\BaseApp\BaseBusinessModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* 小程序用户(cc_wx_user)
|
||||
*
|
||||
* is_p 代理商 / pid 上级代理商 / price_number 价格倍率 / show_price 价格是否可见 /
|
||||
* template_code 经销商专属装修模板(空=跟随品牌默认)。
|
||||
* session_key 是微信会话密钥,只能留在服务端,任何接口都不要把它输出出去。
|
||||
*/
|
||||
class WxUserModel extends BaseBusinessModel
|
||||
{
|
||||
protected $table = 'wx_user';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected $hidden = ['session_key'];
|
||||
|
||||
public function enterprise(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(EnterpriseModel::class, 'enterprise_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 该代理商名下的下级用户
|
||||
*/
|
||||
public function children(): HasMany
|
||||
{
|
||||
return $this->hasMany(self::class, 'pid', 'id');
|
||||
}
|
||||
|
||||
public function parent(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(self::class, 'pid', 'id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user