255], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'order_id' => 'Order ID', 'goods_id' => 'Goods ID', 'goods_name' => '商品名称', 'num' => '商品数量', 'total_price' => '此商品的总价', 'created_at' => '创建时间', 'is_delete' => '是否删除', 'attr' => '商品规格', 'pic' => '商品规格图片', 'goods_info' => '商品快照', 'is_virtual' => '是否为虚拟订单详情', ]; } /** * 生成虚拟订单详情 */ public static function generateVirtualOrderDetail($order) { $detail = new self(); $detail->order_id = $order->id; $detail->goods_id = $order->goods_id; $detail->goods_name = $order->goods_name ?: '虚拟商品'; $detail->num = 1; $detail->total_price = $order->pay_price; $detail->created_at = $order->created_at; $detail->is_delete = 0; $detail->attr = json_encode(['规格' => '默认规格']); $detail->pic = '/images/default-goods.jpg'; $detail->goods_info = json_encode(['商品快照信息']); $detail->is_virtual = 1; return $detail->save(); } /** * 获取订单的详情 */ public static function getOrderDetails($orderId) { return self::find() ->where(['order_id' => $orderId, 'is_delete' => 0]) ->all(); } }