Order.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace app\model;
  3. use DateTimeInterface;
  4. use support\Model;
  5. class Order extends Model
  6. {
  7. protected $table = 'order';
  8. protected $primaryKey = 'order_id';
  9. protected $keyType = 'string';
  10. protected $dateFormat = 'U';
  11. const CREATED_AT = 'order_addtimes';
  12. const UPDATED_AT = null;
  13. const AUTOMATIC_RECEIPT_PREFIX = 'ORDER:AUTOMATIC:RECEIPT:';
  14. const AUTOMATIC_COMPLETE_PREFIX = 'ORDER:AUTOMATIC:COMPLETE:';
  15. public function serializeDate(DateTimeInterface $date)
  16. {
  17. return $date->format('Y-m-d H:i:s');
  18. }
  19. public function sheet()
  20. {
  21. return $this->hasOne(OrderSheet::class, 'join_sheet_order_id', 'order_id');
  22. }
  23. public function sheets()
  24. {
  25. return $this->hasMany(OrderSheet::class, 'join_sheet_order_id', 'order_id');
  26. }
  27. public function member()
  28. {
  29. return $this->hasOne(Member::class, 'member_id', 'join_order_member_id');
  30. }
  31. public function cert()
  32. {
  33. return $this->hasOne(MemberCert::class, 'join_cert_member_id', 'join_order_member_id');
  34. }
  35. public function return()
  36. {
  37. return $this->hasOne(OrderReturn::class, 'join_return_order_id', 'order_id');
  38. }
  39. public function express()
  40. {
  41. return $this->hasOne(OrderExpress::class, 'join_express_order_id', 'order_id');
  42. }
  43. public function benefit()
  44. {
  45. return $this->hasMany(MemberBenefit::class, 'join_benefit_order_id', 'order_id');
  46. }
  47. public function payDetail()
  48. {
  49. return $this->hasMany(PayDetail::class, 'join_pay_order_id', 'order_groupby');
  50. }
  51. }