| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace App\Module\Mex\Models;
- use App\Module\Mex\Enums\OrderStatus;
- use App\Module\Mex\Enums\OrderType;
- use App\Module\Fund\Enums\FUND_CURRENCY_TYPE;
- use App\Module\GameItems\Models\Item;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use UCore\ModelCore;
- /**
- * 农贸市场订单模型
- * field start
- * @property int $id 订单ID,主键
- * @property int $user_id 用户ID
- * @property int $item_id 商品ID,关联物品表
- * @property \App\Module\Fund\Enums\FUND_CURRENCY_TYPE $currency_type 币种类型,关联FUND_CURRENCY_TYPE枚举,默认2为钻石
- * @property \App\Module\Mex\Enums\OrderType $order_type 订单类型:BUY买入,SELL卖出
- * @property int $quantity 订单数量
- * @property float $price 订单价格,支持5位小数
- * @property float $total_amount 订单总金额
- * @property \App\Module\Mex\Enums\OrderStatus $status 订单状态:PENDING等待,COMPLETED完成,CANCELLED取消,FAILED失败
- * @property float $frozen_amount 冻结金额(买单使用)
- * @property int $completed_quantity 已成交数量
- * @property float $completed_amount 已成交金额
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * @property \Carbon\Carbon $completed_at 完成时间
- * @property string $failed_reason 失败原因
- * field end
- */
- class MexOrder extends ModelCore
- {
- protected $table = 'mex_orders';
- // attrlist start
- protected $fillable = [
- 'id',
- 'user_id',
- 'item_id',
- 'currency_type',
- 'order_type',
- 'quantity',
- 'price',
- 'total_amount',
- 'status',
- 'frozen_amount',
- 'completed_quantity',
- 'completed_amount',
- 'completed_at',
- 'failed_reason',
- ];
- // attrlist end
- protected $casts = [
- 'user_id' => 'integer',
- 'item_id' => 'integer',
- 'currency_type' => FUND_CURRENCY_TYPE::class,
- 'order_type' => OrderType::class,
- 'quantity' => 'integer',
- 'price' => 'decimal:5',
- 'total_amount' => 'decimal:5',
- 'status' => OrderStatus::class,
- 'frozen_amount' => 'decimal:5',
- 'completed_quantity' => 'integer',
- 'completed_amount' => 'decimal:5',
- 'completed_at' => 'datetime',
- ];
- /**
- * 获取关联的商品信息
- *
- * @return BelongsTo
- */
- public function item(): BelongsTo
- {
- return $this->belongsTo(Item::class, 'item_id');
- }
- }
|