OrderAftersales.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. /**
  5. * 模型
  6. */
  7. class OrderAftersales extends Model
  8. {
  9. // 表名
  10. protected $name = 'shop_order_aftersales';
  11. // 开启自动写入时间戳字段
  12. protected $autoWriteTimestamp = 'int';
  13. // 定义时间戳字段名
  14. protected $createTime = 'createtime';
  15. protected $updateTime = 'updatetime';
  16. // 追加属性
  17. protected $append = [
  18. 'status_text',
  19. 'type_text'
  20. ];
  21. public function getStatusList()
  22. {
  23. return ['1' => '等待审核', '2' => '审核通过', '3' => '审核拒绝'];
  24. }
  25. public function getStatusTextAttr($value, $data)
  26. {
  27. $value = $value ?: ($data['status'] ?? '');
  28. $list = $this->getStatusList();
  29. return $list[$value] ?? '';
  30. }
  31. public function getTypeList()
  32. {
  33. return ['1' => '仅退款', '2' => '退货退款'];
  34. }
  35. public function getTypeTextAttr($value, $data)
  36. {
  37. $value = $value ?: ($data['type'] ?? '');
  38. $list = $this->getTypeList();
  39. return $list[$value] ?? '';
  40. }
  41. public function getImagesAttr($value, $data)
  42. {
  43. $value = $value ?: ($data['images'] ?? '');
  44. if (empty($value)) {
  45. return [];
  46. }
  47. $value = explode(',', $value);
  48. foreach ($value as &$img) {
  49. $img = cdnurl($img, true);
  50. }
  51. return $value;
  52. }
  53. public function OrderGoods()
  54. {
  55. return $this->hasOne('OrderGoods', 'id', 'order_goods_id', [], 'LEFT');
  56. }
  57. }