新版数智员工

This commit is contained in:
wong
2026-03-24 10:39:16 +08:00
parent 1853934d85
commit 7fb61b77a4
123 changed files with 38491 additions and 1018 deletions

View File

@@ -5,12 +5,12 @@ namespace app\store\model;
use think\Model;
/**
* 套餐模型
* 供应商套餐模型
*/
class VendorPackageModel extends Model
{
// 设置表名
protected $table = 'ck_vendor_package';
protected $name = 'vendor_package';
// 主键
protected $pk = 'id';
@@ -20,8 +20,10 @@ class VendorPackageModel extends Model
protected $createTime = 'createTime';
protected $updateTime = 'updateTime';
// 隐藏字段
protected $hidden = ['isDel'];
// 类型转换
protected $type = [
'tags' => 'array',
];
/**
* 与项目的关联
@@ -37,7 +39,13 @@ class VendorPackageModel extends Model
*/
public function getTagsAttr($value)
{
return $value ? explode(',', $value) : [];
if (empty($value)) {
return [];
}
if (is_array($value)) {
return $value;
}
return array_filter(explode(',', $value));
}
/**
@@ -47,4 +55,18 @@ class VendorPackageModel extends Model
{
return is_array($value) ? implode(',', $value) : $value;
}
}
/**
* 折扣获取器
*/
public function getDiscountAttr($value, $data)
{
if (empty($data['originalPrice']) || $data['originalPrice'] <= 0) {
return '原价';
}
$discount = round((floatval($data['price']) / floatval($data['originalPrice'])) * 10, 1);
return $discount . '折';
}
}