MexMatchLog.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace App\Module\Mex\Models;
  3. use App\Module\Mex\Enums\MatchType;
  4. use App\Module\GameItems\Models\Item;
  5. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  6. use UCore\ModelCore;
  7. /**
  8. * 农贸市场撮合日志模型
  9. *
  10. * field start
  11. * @property int $id 撮合日志ID,主键
  12. * @property \App\Module\Mex\Enums\MatchType $match_type 撮合类型:USER_BUY用户买入撮合,USER_SELL用户卖出撮合
  13. * @property int $item_id 商品ID,关联物品表
  14. * @property int $batch_size 批处理大小
  15. * @property int $matched_orders 成功撮合的订单数
  16. * @property float $total_amount 撮合总金额
  17. * @property bool $success 撮合是否成功:0失败,1成功
  18. * @property string $message 撮合结果消息
  19. * @property int $execution_time_ms 执行时间(毫秒)
  20. * @property string $error_message 错误消息(失败时记录)
  21. * @property \Carbon\Carbon $created_at 撮合时间
  22. * field end
  23. */
  24. class MexMatchLog extends ModelCore
  25. {
  26. protected $table = 'mex_match_logs';
  27. // 禁用updated_at字段的自动管理,因为表中只有created_at字段
  28. public const UPDATED_AT = null;
  29. // attrlist start
  30. protected $fillable = [
  31. 'id',
  32. 'match_type',
  33. 'item_id',
  34. 'batch_size',
  35. 'matched_orders',
  36. 'total_amount',
  37. 'success',
  38. 'message',
  39. 'execution_time_ms',
  40. 'error_message',
  41. ];
  42. // attrlist end
  43. protected $casts = [
  44. 'match_type' => MatchType::class,
  45. 'item_id' => 'integer',
  46. 'batch_size' => 'integer',
  47. 'matched_orders' => 'integer',
  48. 'total_amount' => 'decimal:5',
  49. 'success' => 'boolean',
  50. 'execution_time_ms' => 'integer',
  51. ];
  52. /**
  53. * 获取关联的商品信息
  54. *
  55. * @return BelongsTo
  56. */
  57. public function item(): BelongsTo
  58. {
  59. return $this->belongsTo(Item::class, 'item_id');
  60. }
  61. }