RentOrder.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace App\Models;
  3. use App\Traits\ModelHelpers;
  4. use Illuminate\Database\Eloquent\Model;
  5. /*次model专门为多态关联使用*/
  6. class RentOrder extends Model
  7. {
  8. //
  9. use ModelHelpers;
  10. protected $table = "rent_orders";
  11. const ORDER_TYPE = 1;
  12. protected $guarded = [];
  13. // 待支付租金
  14. const STATUS_WAIT_PAY_RENT_MONEY = 0;
  15. // 租车中
  16. const STATUS_RENT_BIKE = 1;
  17. // 租车结束,待支付
  18. const STATUS_CLOSE_RENT_BIKE = 2;
  19. // 已完成
  20. const STATUS_COMPLETE_ORDER = 3;
  21. // 订单关闭
  22. const STATUS_CLOSE_ORDER = 4;
  23. public static $statusMaps = [
  24. self::STATUS_WAIT_PAY_RENT_MONEY => '待支付租金',
  25. self::STATUS_RENT_BIKE => '租车中',
  26. self::STATUS_CLOSE_RENT_BIKE => '租车结束,待支付',
  27. self::STATUS_COMPLETE_ORDER => '已完成',
  28. self::STATUS_CLOSE_ORDER => '订单关闭'
  29. ];
  30. const PAY_STATUS_OK = 1;
  31. const PAY_STATUS_NO = 0;
  32. public static $payStatusMaps = [
  33. self::PAY_STATUS_NO => '已支付',
  34. self::PAY_STATUS_OK => '未支付'
  35. ];
  36. const ADMIN_SETTLE_ORDER_AUTO_CLOSE = 2;
  37. const ADMIN_SETTLE_ORDER_ADMIN = 1;
  38. const ADMIN_SETTLE_ORDER_USER = 0;
  39. public static $adminSettleOrderMaps = [
  40. self::ADMIN_SETTLE_ORDER_USER => '正常结算',
  41. self::ADMIN_SETTLE_ORDER_ADMIN => '管理员结算',
  42. self::ADMIN_SETTLE_ORDER_AUTO_CLOSE => '系统自动结算',
  43. ];
  44. const PAY_TYPE_NO = 0;
  45. const PAY_TYPE_WECHAT = 1;
  46. const PAY_TYPE_ACCOUNT = 2;
  47. public static $payTypeMaps = [
  48. self::PAY_TYPE_NO => '待支付',
  49. self::PAY_TYPE_WECHAT => '微信支付',
  50. self::PAY_TYPE_ACCOUNT => '余额支付'
  51. ];
  52. const REFUND_MONEY_OK = 1;
  53. const REFUND_MONEY_NO = 0;
  54. public static $refundMoneyMaps = [
  55. self::REFUND_MONEY_NO => '未返还',
  56. self::REFUND_MONEY_OK => '已返还'
  57. ];
  58. public function getOrderTypeAttribute(){
  59. return self::ORDER_TYPE;
  60. }
  61. public function users()
  62. {
  63. return $this->belongsTo(User::class, 'user_id', 'id');
  64. }
  65. public function bikes()
  66. {
  67. return $this->belongsTo(Bike::class, 'bike_id', 'id');
  68. }
  69. public function order_bike_operates()
  70. {
  71. return $this->hasMany(OrderRentBikeOperate::class, 'order_id', 'id');
  72. }
  73. public function area()
  74. {
  75. return $this->belongsTo(Area::class, 'area_id', 'id');
  76. }
  77. public function walletLogs()
  78. {
  79. return $this->morphMany(WalletLog::class, 'log');
  80. }
  81. }