32], [['USER_ID'], 'unique'], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'ID' => 'ID', 'USER_ID' => '用户id', 'CASH' => '现金', 'UPDATED_AT' => '修改时间', 'CLEAR_BY_CLOSED_AT' => '清空关停会员钱包时间', ]; } /** * 操作日志记录条件 * @return array */ public function attrLabelsWithLogType(){ return [ 'USER_ID' => '用户id', 'CLEAR_BY_CLOSED_AT' => [ 'label' => '清空关停会员钱包时间', 'type' => ValueTypeConfig::DATE_TIME_TYPE, ], ]; } /** * 获取一名会员的余额 * @param $userId * @return array|null */ public static function getCashByUserId($userId){ $data = UserWallet::findOneAsArray('USER_ID=:USER_ID', [':USER_ID'=>$userId], 'USER_ID,CASH'); if(!$data){ $data = [ 'USER_ID' => $userId, 'CASH' => 0, ]; } return $data; } }