init commit
This commit is contained in:
84
application/admin/model/wdsxh/points/Order.php
Normal file
84
application/admin/model/wdsxh/points/Order.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model\wdsxh\points;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Order extends Model
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 表名
|
||||
protected $name = 'wdsxh_points_order';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'state_text',
|
||||
'complete_time_text',
|
||||
'redemption_time_text',
|
||||
'goods_info',
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function getStateList()
|
||||
{
|
||||
return ['2' => __('State 2'), '3' => __('State 3'), '4' => __('State 4')];
|
||||
}
|
||||
|
||||
|
||||
public function getStateTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['state']) ? $data['state'] : '');
|
||||
$list = $this->getStateList();
|
||||
return isset($list[$value]) ? $list[$value] : '';
|
||||
}
|
||||
|
||||
|
||||
public function getCompleteTimeTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['complete_time']) ? $data['complete_time'] : '');
|
||||
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
||||
}
|
||||
|
||||
|
||||
public function getRedemptionTimeTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['redemption_time']) ? $data['redemption_time'] : '');
|
||||
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
||||
}
|
||||
|
||||
protected function setCompleteTimeAttr($value)
|
||||
{
|
||||
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
||||
}
|
||||
|
||||
protected function setRedemptionTimeAttr($value)
|
||||
{
|
||||
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
||||
}
|
||||
|
||||
public function getGoodsInfoAttr($value, $data)
|
||||
{
|
||||
$goods = (new Goods())
|
||||
->withTrashed()
|
||||
->where('id',$data['goods_id'])
|
||||
->field('name,image')
|
||||
->find();
|
||||
$goods->points = $data['points'];
|
||||
return $goods;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user