update order and order item db model

This commit is contained in:
2026-01-29 15:53:41 +08:00
parent 4e21ebfe5f
commit adc6ca4488
2 changed files with 25 additions and 13 deletions
+11 -5
View File
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace App\Model;
use Hyperf\DbConnection\Model\Model;
use App\Model\OrderItem;
/**
* @property int $id 主键
@@ -58,13 +58,19 @@ class Order extends Model
*/
protected array $casts = ['id' => 'integer', 'company_id' => 'integer', 'platform_id' => 'integer', 'store_id' => 'integer', 'order_status_id' => 'integer', 'payment_method_id' => 'integer', 'presale' => 'boolean', 'order_type_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
/**
* Get the order items for the order.
* 获取订单子项(基于 hypertable 分区键查询)
*
* @return \Hyperf\Database\Model\Collection
*/
public function items()
public function getOrderItems()
{
return $this->hasMany(OrderItem::class, 'order_id', 'id');
return OrderItem::query()
->where('platform_id', $this->platform_id)
->where('store_id', $this->store_id)
->where('platform_order_id', $this->platform_order_id)
->where('created_date', $this->created_date)
->get();
}
}