Record.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. namespace app\admin\model\deposit;
  3. use app\admin\model\User;
  4. use think\Model;
  5. class Record extends Model
  6. {
  7. // 表名
  8. protected $name = 'deposit_record';
  9. // 自动写入时间戳字段
  10. protected $autoWriteTimestamp = 'integer';
  11. // 定义时间戳字段名
  12. protected $createTime = 'createtime';
  13. protected $updateTime = 'updatetime';
  14. protected $deleteTime = false;
  15. // 追加属性
  16. protected $append = [
  17. 'platform_text',
  18. 'identity_type_text',
  19. 'apply_status_text',
  20. 'deposit_status_text'
  21. ];
  22. public function getPlatformList()
  23. {
  24. return ['ali' => __('Ali'), 'wechat' => __('Wechat')];
  25. }
  26. public function getIdentityTypeList()
  27. {
  28. return ['agency' => __('Agency'), 'store' => __('Store'), 'massager' => __('Massager'), 'user' => __('User')];
  29. }
  30. public function getApplyStatusList()
  31. {
  32. return ['default' => __('Default'), 'reject' => __('Reject'), 'pass' => __('Pass')];
  33. }
  34. public function getDepositStatusList()
  35. {
  36. return ['default' => __('Default'), 'success' => __('Success'), 'fail' => __('Fail')];
  37. }
  38. public function getPlatformTextAttr($value, $data)
  39. {
  40. $value = $value ? $value : (isset($data['platform']) ? $data['platform'] : '');
  41. $list = $this->getPlatformList();
  42. return isset($list[$value]) ? $list[$value] : '';
  43. }
  44. public function getIdentityTypeTextAttr($value, $data)
  45. {
  46. $value = $value ? $value : (isset($data['identity_type']) ? $data['identity_type'] : '');
  47. $list = $this->getIdentityTypeList();
  48. return isset($list[$value]) ? $list[$value] : '';
  49. }
  50. public function getApplyStatusTextAttr($value, $data)
  51. {
  52. $value = $value ? $value : (isset($data['apply_status']) ? $data['apply_status'] : '');
  53. $list = $this->getApplyStatusList();
  54. return isset($list[$value]) ? $list[$value] : '';
  55. }
  56. public function getDepositStatusTextAttr($value, $data)
  57. {
  58. $value = $value ? $value : (isset($data['deposit_status']) ? $data['deposit_status'] : '');
  59. $list = $this->getDepositStatusList();
  60. return isset($list[$value]) ? $list[$value] : '';
  61. }
  62. public function store()
  63. {
  64. return $this->belongsTo('app\admin\model\Store', 'store_id', 'id', [], 'LEFT')->setEagerlyType(0);
  65. }
  66. public function massager()
  67. {
  68. return $this->belongsTo('app\admin\model\Massager', 'massager_id', 'id', [], 'LEFT')->setEagerlyType(0);
  69. }
  70. public function admin()
  71. {
  72. return $this->belongsTo('app\admin\model\Admin', 'agency_id', 'id', [], 'LEFT')->setEagerlyType(0);
  73. }
  74. public function user()
  75. {
  76. return $this->belongsTo(User::class, 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  77. }
  78. }