UserIntegral.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class UserIntegral extends Model
  5. {
  6. // 设置字段信息
  7. protected $schema = [
  8. 'id' => 'int',
  9. 'userid' => 'int',
  10. 'title' => 'string',
  11. 'intvalue' => 'int',
  12. 'intmoney' => 'float',
  13. 'onlycontent' => 'string',
  14. 'remark' => 'string',
  15. 'itype' => 'tinyint',
  16. 'status' => 'tinyint',
  17. 'createtime' => 'int',
  18. 'yeartime' => 'int',
  19. 'monthtime' => 'int'
  20. ];
  21. // 设置字段自动转换类型
  22. protected $type = [
  23. 'createtime' => 'timestamp:Y-m-d H:i:s'
  24. ];
  25. public function getItypeTextAttr($value,$data)
  26. {
  27. $itype = [1=>'推荐奖励', 2=>'积分充值', 3=>'积分兑现', 4=>'招聘相关', 5=>'订单相关', 6=>'供人相关', 7=>'兑购消费', 8=>'其他'];
  28. return $itype[$data['itype']];
  29. }
  30. public function getStatusTextAttr($value,$data)
  31. {
  32. $status = [1=>'待处理', 2=>'已处理'];
  33. return $status[$data['status']];
  34. }
  35. // 关联User
  36. public function user()
  37. {
  38. return $this->hasOne(User::class, "id", "userid");
  39. }
  40. }