MexOrder.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace App\Module\Mex\Models;
  3. use App\Module\Mex\Enums\OrderStatus;
  4. use App\Module\Mex\Enums\OrderType;
  5. use App\Module\Fund\Enums\FUND_CURRENCY_TYPE;
  6. use App\Module\GameItems\Models\Item;
  7. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  8. use UCore\ModelCore;
  9. /**
  10. * 农贸市场订单模型
  11. * field start
  12. * @property int $id 订单ID,主键
  13. * @property int $user_id 用户ID
  14. * @property int $item_id 商品ID,关联物品表
  15. * @property \App\Module\Fund\Enums\FUND_CURRENCY_TYPE $currency_type 币种类型,关联FUND_CURRENCY_TYPE枚举,默认2为钻石
  16. * @property \App\Module\Mex\Enums\OrderType $order_type 订单类型:BUY买入,SELL卖出
  17. * @property int $quantity 订单数量
  18. * @property float $price 订单价格,支持5位小数
  19. * @property float $total_amount 订单总金额
  20. * @property \App\Module\Mex\Enums\OrderStatus $status 订单状态:PENDING等待,COMPLETED完成,CANCELLED取消,FAILED失败
  21. * @property float $frozen_amount 冻结金额(买单使用)
  22. * @property int $completed_quantity 已成交数量
  23. * @property float $completed_amount 已成交金额
  24. * @property \Carbon\Carbon $created_at 创建时间
  25. * @property \Carbon\Carbon $updated_at 更新时间
  26. * @property \Carbon\Carbon $completed_at 完成时间
  27. * @property string $failed_reason 失败原因
  28. * field end
  29. */
  30. class MexOrder extends ModelCore
  31. {
  32. protected $table = 'mex_orders';
  33. // attrlist start
  34. protected $fillable = [
  35. 'id',
  36. 'user_id',
  37. 'item_id',
  38. 'currency_type',
  39. 'order_type',
  40. 'quantity',
  41. 'price',
  42. 'total_amount',
  43. 'status',
  44. 'frozen_amount',
  45. 'completed_quantity',
  46. 'completed_amount',
  47. 'completed_at',
  48. 'failed_reason',
  49. ];
  50. // attrlist end
  51. protected $casts = [
  52. 'user_id' => 'integer',
  53. 'item_id' => 'integer',
  54. 'currency_type' => FUND_CURRENCY_TYPE::class,
  55. 'order_type' => OrderType::class,
  56. 'quantity' => 'integer',
  57. 'price' => 'decimal:5',
  58. 'total_amount' => 'decimal:5',
  59. 'status' => OrderStatus::class,
  60. 'frozen_amount' => 'decimal:5',
  61. 'completed_quantity' => 'integer',
  62. 'completed_amount' => 'decimal:5',
  63. 'completed_at' => 'datetime',
  64. ];
  65. /**
  66. * 获取关联的商品信息
  67. *
  68. * @return BelongsTo
  69. */
  70. public function item(): BelongsTo
  71. {
  72. return $this->belongsTo(Item::class, 'item_id');
  73. }
  74. }