OrderRent.php 2.5 KB

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