ElectronicsOrder.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. namespace app\admin\model\shop;
  3. use think\Model;
  4. class ElectronicsOrder extends Model
  5. {
  6. // 表名
  7. protected $name = 'shop_electronics_order';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'paytype_text',
  17. 'is_notice_text',
  18. 'is_return_temp_text',
  19. 'is_send_message_text',
  20. 'is_return_sign_bill_text',
  21. 'exp_type_text'
  22. ];
  23. public function getPaytypeList()
  24. {
  25. return ['1' => __('Paytype 1'), '2' => __('Paytype 2'), '3' => __('Paytype 3'), '4' => __('Paytype 4')];
  26. }
  27. public function getIsNoticeList()
  28. {
  29. return ['0' => __('Is_notice 0'), '1' => __('Is_notice 1')];
  30. }
  31. public function getIsReturnTempList()
  32. {
  33. return ['0' => __('Is_return_temp 0'), '1' => __('Is_return_temp 1')];
  34. }
  35. public function getIsSendMessageList()
  36. {
  37. return ['0' => __('Is_send_message 0'), '1' => __('Is_send_message 1')];
  38. }
  39. public function getIsReturnSignBillList()
  40. {
  41. return ['0' => __('Is_return_sign_bill 0'), '1' => __('Is_return_sign_bill 1')];
  42. }
  43. public function getExpTypeList()
  44. {
  45. return ['1' => __('Exp_type 1')];
  46. }
  47. public function getPaytypeTextAttr($value, $data)
  48. {
  49. $value = $value ?: ($data['paytype'] ?? '');
  50. $list = $this->getPaytypeList();
  51. return $list[$value] ?? '';
  52. }
  53. public function getIsNoticeTextAttr($value, $data)
  54. {
  55. $value = $value ?: ($data['is_notice'] ?? '');
  56. $list = $this->getIsNoticeList();
  57. return $list[$value] ?? '';
  58. }
  59. public function getIsReturnTempTextAttr($value, $data)
  60. {
  61. $value = $value ?: ($data['is_return_temp'] ?? '');
  62. $list = $this->getIsReturnTempList();
  63. return $list[$value] ?? '';
  64. }
  65. public function getIsSendMessageTextAttr($value, $data)
  66. {
  67. $value = $value ?: ($data['is_send_message'] ?? '');
  68. $list = $this->getIsSendMessageList();
  69. return $list[$value] ?? '';
  70. }
  71. public function getIsReturnSignBillTextAttr($value, $data)
  72. {
  73. $value = $value ?: ($data['is_return_sign_bill'] ?? '');
  74. $list = $this->getIsReturnSignBillList();
  75. return $list[$value] ?? '';
  76. }
  77. public function getExpTypeTextAttr($value, $data)
  78. {
  79. $value = $value ?: ($data['exp_type'] ?? '');
  80. $list = $this->getExpTypeList();
  81. return $list[$value] ?? '';
  82. }
  83. public function Shipper()
  84. {
  85. return $this->hasOne('Shipper', 'id', 'shipper_id', [], 'LEFT');
  86. }
  87. }