OrderSheet.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. namespace app\model;
  3. use DateTimeInterface;
  4. use support\Model;
  5. class OrderSheet extends Model
  6. {
  7. protected $table = 'order_sheet';
  8. protected $primaryKey = 'order_sheet_id';
  9. protected $dateFormat = 'U';
  10. const CREATED_AT = 'order_sheet_addtimes';
  11. const UPDATED_AT = null;
  12. public function serializeDate(DateTimeInterface $date)
  13. {
  14. return $date->format('Y-m-d H:i:s');
  15. }
  16. /**
  17. * @Desc 关联Member
  18. * @Author Gorden
  19. * @Date 2024/3/29 9:18
  20. *
  21. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  22. */
  23. public function member()
  24. {
  25. return $this->hasOne(Member::class, 'member_id', 'join_sheet_member_id');
  26. }
  27. public function memberInfo()
  28. {
  29. return $this->hasOne(MemberInfo::class, 'join_info_member_id', 'join_sheet_member_id')
  30. ->select('join_info_member_id', 'member_info_nickname', 'member_info_headimg');
  31. }
  32. public function cert()
  33. {
  34. return $this->hasOne(MemberCert::class, 'join_cert_member_id', 'join_sheet_member_id')
  35. ->select('join_cert_member_id', 'member_cert_name');
  36. }
  37. /**
  38. * @Desc 关联Goods
  39. * @Author Gorden
  40. * @Date 2024/3/29 9:19
  41. *
  42. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  43. */
  44. public function goods()
  45. {
  46. return $this->hasOne(Goods::class, 'goods_id', 'join_sheet_goods_id');
  47. }
  48. /**
  49. * @Desc 关联订单
  50. * @Author Gorden
  51. * @Date 2024/3/29 9:19
  52. *
  53. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  54. */
  55. public function order()
  56. {
  57. return $this->hasOne(Order::class, 'order_id', 'join_sheet_order_id');
  58. }
  59. /**
  60. * @Desc 发货信息
  61. * @Author Gorden
  62. * @Date 2024/4/23 15:02
  63. *
  64. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  65. */
  66. public function express()
  67. {
  68. return $this->hasOne(OrderExpress::class, 'join_express_order_id', 'join_sheet_order_id');
  69. }
  70. /**
  71. * @Desc 退货退款
  72. * @Author Gorden
  73. * @Date 2024/4/26 10:16
  74. *
  75. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  76. */
  77. public function refund()
  78. {
  79. return $this->hasOne(OrderReturn::class, 'join_return_order_id', 'join_sheet_order_id');
  80. }
  81. public function running()
  82. {
  83. return $this->hasOne(GoodsRunning::class, 'join_running_goods_id', 'join_sheet_goods_id')
  84. ->select('join_running_goods_id', 'goods_running_storage', 'goods_running_sale');
  85. }
  86. public function skus()
  87. {
  88. return $this->hasMany(GoodsSku::class, 'join_sku_goods_id', 'join_sheet_goods_id');
  89. }
  90. public function sku()
  91. {
  92. return $this->hasOne(GoodsSku::class, 'goods_sku_id', 'join_sheet_goods_sku_id');
  93. }
  94. public function benefit()
  95. {
  96. return $this->hasMany(MemberBenefit::class, 'join_benefit_order_id', 'join_sheet_order_id');
  97. }
  98. }