MexTransaction.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace App\Module\Mex\Models;
  3. use App\Module\Mex\Enums\TransactionType;
  4. use App\Module\Fund\Enums\FUND_CURRENCY_TYPE;
  5. use UCore\ModelCore;
  6. /**
  7. * 农贸市场成交记录模型
  8. *
  9. * field start
  10. * @property int $id 成交记录ID,主键
  11. * @property int $buy_order_id 买单ID,关联mex_orders表
  12. * @property int $sell_order_id 卖单ID,关联mex_orders表
  13. * @property int $buyer_id 买方用户ID
  14. * @property int $seller_id 卖方用户ID
  15. * @property int $item_id 商品ID,关联物品表
  16. * @property \App\Module\Fund\Enums\FUND_CURRENCY_TYPE $currency_type 币种类型,关联FUND_CURRENCY_TYPE枚举,默认2为钻石
  17. * @property int $quantity 成交数量
  18. * @property float $price 成交价格
  19. * @property float $total_amount 成交总金额
  20. * @property \App\Module\Mex\Enums\TransactionType $transaction_type 交易类型:USER_SELL用户卖出,USER_BUY用户买入,ADMIN_INJECT管理员注入,ADMIN_RECYCLE管理员回收
  21. * @property bool $is_admin_operation 是否管理员操作:0否,1是
  22. * @property int $admin_user_id 管理员用户ID(管理员操作时使用)
  23. * @property \Carbon\Carbon $created_at 成交时间
  24. * field end
  25. */
  26. class MexTransaction extends ModelCore
  27. {
  28. protected $table = 'mex_transactions';
  29. // 禁用updated_at字段的自动管理,因为表中只有created_at字段
  30. public const UPDATED_AT = null;
  31. // attrlist start
  32. protected $fillable = [
  33. 'id',
  34. 'buy_order_id',
  35. 'sell_order_id',
  36. 'buyer_id',
  37. 'seller_id',
  38. 'item_id',
  39. 'currency_type',
  40. 'quantity',
  41. 'price',
  42. 'total_amount',
  43. 'transaction_type',
  44. 'is_admin_operation',
  45. 'admin_user_id',
  46. ];
  47. // attrlist end
  48. protected $casts = [
  49. 'buy_order_id' => 'integer',
  50. 'sell_order_id' => 'integer',
  51. 'buyer_id' => 'integer',
  52. 'seller_id' => 'integer',
  53. 'item_id' => 'integer',
  54. 'currency_type' => FUND_CURRENCY_TYPE::class,
  55. 'quantity' => 'integer',
  56. 'price' => 'decimal:5',
  57. 'total_amount' => 'decimal:5',
  58. 'transaction_type' => TransactionType::class,
  59. 'is_admin_operation' => 'boolean',
  60. 'admin_user_id' => 'integer',
  61. ];
  62. }