Log.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace app\admin\model\shopro\commission;
  3. use think\Model;
  4. class Log extends Model
  5. {
  6. // 表名
  7. protected $name = 'shopro_commission_log';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = false;
  13. // 追加属性
  14. protected $append = [
  15. 'event_text',
  16. 'oper_type_text'
  17. ];
  18. public function getEventList()
  19. {
  20. return [
  21. 'agent' => '分销商',
  22. 'level' => '等级变动',
  23. 'order' => '分销业绩',
  24. 'team' => '团队',
  25. 'reward' => '佣金',
  26. 'share' => '绑定关系',
  27. ];
  28. }
  29. public function getOperTypeList()
  30. {
  31. return [
  32. 'user' => '用户',
  33. 'admin' => '管理员',
  34. 'system' => '系统',
  35. ];
  36. }
  37. public function getEventTextAttr($value, $data) {
  38. $value = $value ? $value : (isset($data['event']) ? $data['event'] : '');
  39. $list = $this->getEventList();
  40. return isset($list[$value]) ? $list[$value] : '';
  41. }
  42. public function getOperTypeTextAttr($value, $data) {
  43. $value = $value ? $value : (isset($data['oper_type']) ? $data['oper_type'] : '');
  44. $list = $this->getOperTypeList();
  45. return isset($list[$value]) ? $list[$value] : '';
  46. }
  47. public function oper()
  48. {
  49. return $this->belongsTo(\app\admin\model\User::class, 'oper_id')->field('id,nickname,avatar,prevtime,logintime,jointime');
  50. }
  51. public function agent()
  52. {
  53. return $this->belongsTo(\app\admin\model\User::class, 'agent_id')->field('id,nickname,avatar,prevtime,logintime,jointime');
  54. }
  55. }