56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Model;
|
|
|
|
use Hyperf\DbConnection\Model\Model;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property int $order_id
|
|
* @property int $cycle_id
|
|
* @property int $sku_id
|
|
* @property int $spu_id
|
|
* @property int $user_id
|
|
* @property int $quantity
|
|
* @property string $unit_price
|
|
* @property int $is_comment
|
|
* @property int $copies
|
|
* @property int $type
|
|
* @property string $create_time
|
|
* @property string $update_time
|
|
*/
|
|
class OrderGood extends Model
|
|
{
|
|
/**
|
|
* The table associated with the model.
|
|
*/
|
|
protected ?string $table = 'order_goods';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected array $fillable = [];
|
|
protected array $guarded = [];
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
*/
|
|
protected array $casts = ['id' => 'integer', 'order_id' => 'integer', 'cycle_id' => 'integer', 'sku_id' => 'integer', 'spu_id' => 'integer', 'user_id' => 'integer', 'quantity' => 'integer', 'is_comment' => 'integer', 'copies' => 'integer', 'type' => 'integer'];
|
|
|
|
const string CREATED_AT = 'create_time';
|
|
|
|
const string UPDATED_AT = 'update_time';
|
|
|
|
/**
|
|
* 根据订单获取商品id
|
|
* @param int $orderId
|
|
* @return array
|
|
*/
|
|
public function getGoodIdsByOrderId(int $orderId): array
|
|
{
|
|
return $this->where('order_id', $orderId)->select('sku_id','SUM(`quantity`) as `quantity`')->get()->toArray();
|
|
}
|
|
}
|