12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace App\Models;
- use App\Traits\ModelHelpers;
- use Illuminate\Database\Eloquent\Model;
- /*次model专门为多态关联使用*/
- class RentOrder extends Model
- {
- //
- use ModelHelpers;
- protected $table = "rent_orders";
- const ORDER_TYPE = 1;
- protected $guarded = [];
- // 待支付租金
- const STATUS_WAIT_PAY_RENT_MONEY = 0;
- // 租车中
- const STATUS_RENT_BIKE = 1;
- // 租车结束,待支付
- const STATUS_CLOSE_RENT_BIKE = 2;
- // 已完成
- const STATUS_COMPLETE_ORDER = 3;
- // 订单关闭
- const STATUS_CLOSE_ORDER = 4;
- public static $statusMaps = [
- self::STATUS_WAIT_PAY_RENT_MONEY => '待支付租金',
- self::STATUS_RENT_BIKE => '租车中',
- self::STATUS_CLOSE_RENT_BIKE => '租车结束,待支付',
- self::STATUS_COMPLETE_ORDER => '已完成',
- self::STATUS_CLOSE_ORDER => '订单关闭'
- ];
- const PAY_STATUS_OK = 1;
- const PAY_STATUS_NO = 0;
- public static $payStatusMaps = [
- self::PAY_STATUS_NO => '已支付',
- self::PAY_STATUS_OK => '未支付'
- ];
- const ADMIN_SETTLE_ORDER_AUTO_CLOSE = 2;
- const ADMIN_SETTLE_ORDER_ADMIN = 1;
- const ADMIN_SETTLE_ORDER_USER = 0;
- public static $adminSettleOrderMaps = [
- self::ADMIN_SETTLE_ORDER_USER => '正常结算',
- self::ADMIN_SETTLE_ORDER_ADMIN => '管理员结算',
- self::ADMIN_SETTLE_ORDER_AUTO_CLOSE => '系统自动结算',
- ];
- const PAY_TYPE_NO = 0;
- const PAY_TYPE_WECHAT = 1;
- const PAY_TYPE_ACCOUNT = 2;
- public static $payTypeMaps = [
- self::PAY_TYPE_NO => '待支付',
- self::PAY_TYPE_WECHAT => '微信支付',
- self::PAY_TYPE_ACCOUNT => '余额支付'
- ];
- const REFUND_MONEY_OK = 1;
- const REFUND_MONEY_NO = 0;
- public static $refundMoneyMaps = [
- self::REFUND_MONEY_NO => '未返还',
- self::REFUND_MONEY_OK => '已返还'
- ];
- public function getOrderTypeAttribute(){
- return self::ORDER_TYPE;
- }
- public function users()
- {
- return $this->belongsTo(User::class, 'user_id', 'id');
- }
- public function bikes()
- {
- return $this->belongsTo(Bike::class, 'bike_id', 'id');
- }
- public function order_bike_operates()
- {
- return $this->hasMany(OrderRentBikeOperate::class, 'order_id', 'id');
- }
- public function area()
- {
- return $this->belongsTo(Area::class, 'area_id', 'id');
- }
- public function walletLogs()
- {
- return $this->morphMany(WalletLog::class, 'log');
- }
- }
|