<?php namespace app\model; use support\Model; /** * @property int $id 奖励记录的唯一标识符 * @property int $user_id 用户ID * @property int $order_id 关联订单ID * @property string $username 用户名(如手机号码) * @property float $money 奖励积分 * @property float $before 操作前的积分余额 * @property float $after 操作后的积分余额 * @property string $memo 奖励类型或备注信息 * @property int $status 操作类型 1提现扣款 2人工调整 3提现返还 4注册赠送 5加粉赏金 6任务佣金 8是中奖 9是抽奖 * @property string $uu_id 用户唯一标识符 这里好像是对应的用户邀请码 * @property string|null $admin_name 管理员名称(如果管理员操作) * @property string $createtime2 创建时间的格式化日期(YYYY-MM-DD HH:MM:SS) */ class UserReward extends Model { /** * The table associated with the model. * * @var string */ protected $table = 'user_rewards'; /** * The primary key associated with the table. * * @var string */ protected $primaryKey = 'id'; /** * 数据创建时间,自动转化为格式化的日期 * * @return string */ // public function getCreatetime2Attribute() // { // return date('Y-m-d H:i:s', $this->createtime); // } /** * 记录新增奖励 * * @param array $data 奖励数据 * @return UserReward */ public static function createReward(array $data) { return self::create($data); } /** * 更新奖励记录 * * @param int $id 奖励记录的ID * @param array $data 更新的数据 * @return bool */ public static function updateReward(int $id, array $data) { $reward = self::find($id); if ($reward) { return $reward->update($data); } return false; } /** * 根据用户ID查询所有奖励记录 * * @param int $userId 用户ID * @param int $status 1提现扣款 2人工调整 3提现返还 4注册赠送 5加粉赏金 6任务佣金 * @return \support\Collection */ public static function getByUserId(int $userId,$status) { return self::where('user_id', $userId)->where('status', $status)->get(); } /** * 根据记录ID查询奖励记录 * * @param int $id 奖励记录ID * @return UserReward|null */ public static function getById(int $id) { return self::find($id); } /** * 根据记录的状态查询奖励记录 * * @param int $status 奖励记录的状态 * @return \support\Collection */ public static function getByStatus(int $status) { return self::where('status', $status)->get(); } }