代码优化提交
This commit is contained in:
34
Server/application/store/model/VendorModel.php
Normal file
34
Server/application/store/model/VendorModel.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace app\store\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 供应商模型
|
||||
*/
|
||||
class VendorModel extends Model
|
||||
{
|
||||
// 设置表名
|
||||
protected $table = 's2_vendor';
|
||||
|
||||
// 主键
|
||||
protected $pk = 'id';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
// 隐藏字段
|
||||
protected $hidden = ['isDel'];
|
||||
|
||||
/**
|
||||
* 与套餐的关联
|
||||
*/
|
||||
public function packages()
|
||||
{
|
||||
return $this->hasMany('VendorPackageModel', 'vendorId', 'id')
|
||||
->where('isDel', 0);
|
||||
}
|
||||
}
|
||||
45
Server/application/store/model/VendorOrderModel.php
Normal file
45
Server/application/store/model/VendorOrderModel.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace app\store\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 订单模型
|
||||
*/
|
||||
class VendorOrderModel extends Model
|
||||
{
|
||||
// 设置表名
|
||||
protected $table = 'ck_vendor_order';
|
||||
|
||||
// 主键
|
||||
protected $pk = 'id';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
// 状态常量
|
||||
const STATUS_UNPAID = 0; // 待支付
|
||||
const STATUS_PAID = 1; // 已支付
|
||||
const STATUS_COMPLETED = 2; // 已完成
|
||||
const STATUS_CANCELED = 3; // 已取消
|
||||
|
||||
/**
|
||||
* 与套餐的关联
|
||||
*/
|
||||
public function package()
|
||||
{
|
||||
return $this->belongsTo('VendorPackageModel', 'packageId', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成唯一订单号
|
||||
* @return string
|
||||
*/
|
||||
public static function generateOrderNo()
|
||||
{
|
||||
return date('YmdHis') . rand(1000, 9999);
|
||||
}
|
||||
}
|
||||
50
Server/application/store/model/VendorPackageModel.php
Normal file
50
Server/application/store/model/VendorPackageModel.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace app\store\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 套餐模型
|
||||
*/
|
||||
class VendorPackageModel extends Model
|
||||
{
|
||||
// 设置表名
|
||||
protected $table = 'ck_vendor_package';
|
||||
|
||||
// 主键
|
||||
protected $pk = 'id';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
// 隐藏字段
|
||||
protected $hidden = ['isDel'];
|
||||
|
||||
/**
|
||||
* 与项目的关联
|
||||
*/
|
||||
public function projects()
|
||||
{
|
||||
return $this->hasMany('VendorProjectModel', 'packageId', 'id')
|
||||
->where('isDel', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 标签获取器
|
||||
*/
|
||||
public function getTagsAttr($value)
|
||||
{
|
||||
return $value ? explode(',', $value) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 标签修改器
|
||||
*/
|
||||
public function setTagsAttr($value)
|
||||
{
|
||||
return is_array($value) ? implode(',', $value) : $value;
|
||||
}
|
||||
}
|
||||
33
Server/application/store/model/VendorProjectModel.php
Normal file
33
Server/application/store/model/VendorProjectModel.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace app\store\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 套餐项目模型
|
||||
*/
|
||||
class VendorProjectModel extends Model
|
||||
{
|
||||
// 设置表名
|
||||
protected $table = 'ck_vendor_project';
|
||||
|
||||
// 主键
|
||||
protected $pk = 'id';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
// 隐藏字段
|
||||
protected $hidden = ['isDel'];
|
||||
|
||||
/**
|
||||
* 与套餐的关联
|
||||
*/
|
||||
public function package()
|
||||
{
|
||||
return $this->belongsTo('VendorPackageModel', 'packageId', 'id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user