Bill.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\admin\model\profit;
  3. use think\Model;
  4. class Bill extends Model
  5. {
  6. // 表名
  7. protected $name = 'profit_bill';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'integer';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = false;
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'identity_type_text',
  17. 'change_type_text'
  18. ];
  19. public function getIdentityTypeList()
  20. {
  21. return [
  22. 'platform' => __('Platform'),
  23. 'agency' => __('Agency'),
  24. 'store' => __('Store'),
  25. 'massager' => __('Massager'),
  26. 'user' => "用户"
  27. ];
  28. }
  29. public function getChangeTypeList()
  30. {
  31. return [
  32. 'profit' => __('Profit'),
  33. 'drawings' => __('Drawings'),
  34. "closing_expend" => "业绩结算支出",
  35. "closing_income" => "结算收入",
  36. "channel_expend" => "渠道支出",
  37. "channel_income" => "渠道收入"
  38. ];
  39. }
  40. public function getIdentityTypeTextAttr($value, $data)
  41. {
  42. $value = $value ? $value : (isset($data['identity_type']) ? $data['identity_type'] : '');
  43. $list = $this->getIdentityTypeList();
  44. return isset($list[$value]) ? $list[$value] : '';
  45. }
  46. public function getChangeTypeTextAttr($value, $data)
  47. {
  48. $value = $value ? $value : (isset($data['change_type']) ? $data['change_type'] : '');
  49. $list = $this->getChangeTypeList();
  50. return isset($list[$value]) ? $list[$value] : '';
  51. }
  52. }