OrderRefund.php 2.4 KB

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