OrderBikeOperate.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class OrderBikeOperate extends Model
  5. {
  6. //
  7. protected $table = "order_bike_operates";
  8. protected $guarded = [];
  9. const STATUS_OK = 1;
  10. const STATUS_PAUSE = 0;
  11. public static $statusMaps = [
  12. self::STATUS_OK => '正常',
  13. self::STATUS_PAUSE => '暂停'
  14. ];
  15. const TYPE_NULL = 0;
  16. const TYPE_BILL_BIKE = 1;
  17. const TYPE_OPEN_BIKE = 2;
  18. const TYPE_CLONE_BIKE = 3;
  19. const TYPE_PAUSE_OPEN_BIKE = 4;
  20. const TYPE_PAUSE_CLONE_BIKE = 5;
  21. const TYPE_ADMIN_SETTLRMENT = 6;
  22. const TYPE_ADMIN_ORDER_BACK = 7;
  23. const TYPE_ADMIN_ORDER_BACK_LOW_POWER = 10;
  24. const TYPE_ADMIN_ORDER_HUI_DIAN = 8;
  25. const TYPE_ADMIN_ORDER_OPEN_LOCK = 9;
  26. const TYPE_ADMIN_ORDER_REFUND = 11;
  27. public static $typeMaps = [
  28. self::TYPE_NULL => '未知',
  29. self::TYPE_BILL_BIKE => '寻车',
  30. self::TYPE_OPEN_BIKE => '开锁',
  31. self::TYPE_CLONE_BIKE => '关锁',
  32. self::TYPE_PAUSE_OPEN_BIKE => '开锁(临时停车)',
  33. self::TYPE_PAUSE_CLONE_BIKE => '关锁(临时停车)',
  34. self::TYPE_ADMIN_SETTLRMENT => '后台管理员结算订单',
  35. self::TYPE_ADMIN_ORDER_BACK => '后台管理员订单回溯',
  36. self::TYPE_ADMIN_ORDER_BACK_LOW_POWER => '后台管理员电量过低订单回溯',
  37. self::TYPE_ADMIN_ORDER_HUI_DIAN => '后台管理员恢复电能',
  38. self::TYPE_ADMIN_ORDER_OPEN_LOCK => '后台管理员开电车锁',
  39. self::TYPE_ADMIN_ORDER_REFUND => '后台管理员订单返还',
  40. ];
  41. const IS_ADMIN_NO = 'F';
  42. const IS_ADMIN_YES = 'T';
  43. public static $isAdminMaps = [
  44. self::IS_ADMIN_NO => '用户操作',
  45. self::IS_ADMIN_YES => '管理员操作'
  46. ];
  47. public function order(){
  48. return $this->belongsTo(Order::class,'order_id','id');
  49. }
  50. public function users(){
  51. return $this->belongsTo(User::class,'user_id','id');
  52. }
  53. public function adminUsers(){
  54. return $this->belongsTo(AdminUser::class,'user_id','id');
  55. }
  56. public static function logs($name,$type,$bike_id,$order_id,$user_id,$is_admin,$admin_id=0){
  57. $data = [
  58. 'name' => $name,
  59. 'type' => $type,
  60. 'bike_id' => $bike_id,
  61. 'order_id' => $order_id,
  62. 'user_id' => $user_id,
  63. 'is_admin' => $is_admin,
  64. 'admin_id' => $admin_id
  65. ];
  66. $res = self::create($data);
  67. return $res;
  68. }
  69. }