OrderRefund.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. namespace app\common\model;
  3. /**
  4. * 售后单模型
  5. * Class OrderRefund
  6. * @package app\common\model\wxapp
  7. */
  8. class OrderRefund extends BaseModel
  9. {
  10. protected $name = 'order_refund';
  11. /**
  12. * 关联用户表
  13. * @return \think\model\relation\BelongsTo
  14. */
  15. public function user()
  16. {
  17. return $this->belongsTo('User');
  18. }
  19. /**
  20. * 关联订单主表
  21. * @return \think\model\relation\BelongsTo
  22. */
  23. public function orderMaster()
  24. {
  25. return $this->belongsTo('Order');
  26. }
  27. /**
  28. * 关联订单商品表
  29. * @return \think\model\relation\BelongsTo
  30. */
  31. public function orderGoods()
  32. {
  33. return $this->belongsTo('OrderGoods');
  34. }
  35. /**
  36. * 关联图片记录表
  37. * @return \think\model\relation\HasMany
  38. */
  39. public function image()
  40. {
  41. return $this->hasMany('OrderRefundImage');
  42. }
  43. /**
  44. * 关联物流公司表
  45. * @return \think\model\relation\BelongsTo
  46. */
  47. public function express()
  48. {
  49. return $this->belongsTo('Express');
  50. }
  51. /**
  52. * 关联用户表
  53. * @return \think\model\relation\HasOne
  54. */
  55. public function address()
  56. {
  57. return $this->hasOne('OrderRefundAddress');
  58. }
  59. /**
  60. * 售后类型
  61. * @param $value
  62. * @return array
  63. */
  64. public function getTypeAttr($value)
  65. {
  66. $status = [10 => '退货退款', 20 => '换货'];
  67. return ['text' => $status[$value], 'value' => $value];
  68. }
  69. /**
  70. * 商家是否同意售后
  71. * @param $value
  72. * @return array
  73. */
  74. public function getIsAgreeAttr($value)
  75. {
  76. $status = [0 => '待审核', 10 => '已同意', 20 => '已拒绝'];
  77. return ['text' => $status[$value], 'value' => $value];
  78. }
  79. /**
  80. * 售后单状态
  81. * @param $value
  82. * @return array
  83. */
  84. public function getStatusAttr($value)
  85. {
  86. $status = [0 => '进行中', 10 => '已拒绝', 20 => '已完成', 30 => '已取消'];
  87. return ['text' => $status[$value], 'value' => $value];
  88. }
  89. /**
  90. * 售后单详情
  91. * @param $where
  92. * @return static|null
  93. * @throws \think\exception\DbException
  94. */
  95. public static function detail($where)
  96. {
  97. return static::get($where, ['order_master', 'image.file', 'order_goods.image', 'express', 'address']);
  98. }
  99. }