Order.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 member()
  24. {
  25. return $this->hasOne(Member::class, 'member_id', 'join_order_member_id');
  26. }
  27. public function cert()
  28. {
  29. return $this->hasOne(MemberCert::class, 'join_cert_member_id', 'join_order_member_id');
  30. }
  31. public function return()
  32. {
  33. return $this->hasOne(OrderReturn::class, 'join_return_order_id', 'order_id');
  34. }
  35. public function express(){
  36. return $this->hasOne(OrderExpress::class, 'join_express_order_id','order_id');
  37. }
  38. }