| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace app\common\model;
- use Exception;
- use fast\Action;
- use fast\Asset;
- use fast\RechargeOrderType;
- use fast\RechargeStatus;
- use think\Db;
- use think\Model;
- class RwaExchangeRecordModel extends Model
- {
- protected $name = "rwa_exchange_record";
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'create_time';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'create_time_text',
- ];
- public function userInfo()
- {
- return $this->hasOne(UserModel::class, 'id', 'user_id');
- }
- //用户 user_id
- public function users()
- {
- return $this->hasOne('UserModel', 'id', 'user_id', [], 'LEFT')->setEagerlyType(0);
- }
- //产品
- public function products()
- {
- return $this->hasOne('ProductLists', 'id', 'product_id', [], 'LEFT')->setEagerlyType(0);
- }
-
-
- //兑换
- public function welfarereda()
- {
- return $this->hasOne('ProductWelfareRede', 'id', 'welfare_id', [], 'LEFT')->setEagerlyType(0);
- }
- public function getCreateTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- protected function setCreateTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- }
|