MexOrder.php 2.0 KB

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