TimestampBehavior::class, 'attributes' => [ ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'], ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'] ] ] ]; } /** * {@inheritdoc} */ public function rules() { return [ [['store_id', 'user_id', 'money', 'before_money'], 'required'], [['id','store_id', 'user_id', 'saas_id', 'source_id', 'created_at', 'updated_at'], 'integer'], [['money', 'before_money'], 'number'], [['type'], 'string', 'max' => 32], [['currency_code','source_table'], 'string', 'max' => 64], [['desc'], 'string', 'max' => 255], [['extra'],'string'] ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'store_id' => '商城ID', 'user_id' => '用户ID', 'saas_id' => '联盟ID', 'currency_code' => '货币代码', 'money' => '资金变动(支持负数)', 'before_money' => '变动前金额', 'type' => '类型', 'source_table' => '关联表', 'source_id' => '关联表id', 'desc' => '描述', 'extra' => '额外信息', 'created_at' => '创建时间', 'updated_at' => '更新时间', ]; } public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id']); } }