You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

77 lines
2.5 KiB

<?php
namespace app\admin\model\ykjp\sell;
use think\Model;
use traits\model\SoftDelete;
class Sellaudit extends Model {
use SoftDelete;
// 表名
protected $name = 'ykjp_sell';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
// 追加属性
protected $append = [
'delivery_time_text',
'type_text',
'billing_time_text',
'status_list_text'
];
public function getTypeList() {
return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3')];
}
public function getStatusListList() {
return ['1' => __('Status_list 1'), '2' => __('Status_list 2'), '3' => __('Status_list 3'), '4' => __('Status_list 4'), '5' => __('Status_list 5'), '6' => __('Status_list 6')];
}
public function getDeliveryTimeTextAttr($value, $data) {
$value = $value ? $value : (isset($data['delivery_time']) ? $data['delivery_time'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
public function getTypeTextAttr($value, $data) {
$value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
$list = $this->getTypeList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getBillingTimeTextAttr($value, $data) {
$value = $value ? $value : (isset($data['billing_time']) ? $data['billing_time'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
public function getStatusListTextAttr($value, $data) {
$value = $value ? $value : (isset($data['status_list']) ? $data['status_list'] : '');
$list = $this->getStatusListList();
return isset($list[$value]) ? $list[$value] : '';
}
protected function setDeliveryTimeAttr($value) {
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
protected function setBillingTimeAttr($value) {
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
public function object_array($array) {
if (is_object($array)) {
$array = (array) $array;
} if (is_array($array)) {
foreach ($array as $key => $value) {
$array[$key] = $this->object_array($value);
}
}
return $array;
}
}