255], [['goods_no'], 'string', 'max' => 60], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'order_id' => 'Order ID', 'goods_id' => 'Goods ID', 'num' => '购买商品数量', 'unit_price' => '商品单价', 'total_original_price' => '商品原总价(优惠前)', 'total_price' => '商品总价(优惠后)', 'member_discount_price' => '会员优惠金额(正数表示优惠,负数表示加价)', 'erase_price' => '抹零价格', 'goods_info' => '购买商品信息', 'is_delete' => 'Is Delete', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'deleted_at' => 'Deleted At', 'is_refund' => '是否退款', 'refund_status' => '售后状态 0--未售后 1--售后中 2--售后结束', 'back_price' => '后台优惠(正数表示优惠,负数表示加价)', 'sign' => '订单详情标识,用于区分插件', 'goods_no' => '商品货号', 'form_data' => '自定义表单提交的数据', 'form_id' => '自定义表单的id', 'goods_type' => '商品类型', ]; } /** * @param null $goodsInfo * @return string * @throws \Exception */ public function encodeGoodsInfo($goodsInfo = null) { if (!$goodsInfo) { $goodsInfo = $this->goods_info; } if (!$goodsInfo) { throw new \Exception('goodsInfo不能为空。'); } return Yii::$app->serializer->encode($goodsInfo); } /** * @param null $goodsInfo * @return \ArrayObject|mixed * @throws \Exception */ public function decodeGoodsInfo($goodsInfo = null) { if (!$goodsInfo) { $goodsInfo = $this->goods_info; } if (!$goodsInfo) { throw new \Exception('goodsInfo不能为空。'); } return Yii::$app->serializer->decode($goodsInfo); } public function getGoodsCard() { return $this->hasMany(GoodsCardRelation::className(), ['goods_id' => 'goods_id'])->where(['is_delete' => 0]); } public function getCard() { return $this->hasMany(GoodsCards::className(), ['id' => 'card_id']) ->via('goodsCard'); } public function getGoodsCoupon() { return $this->hasMany(GoodsCouponRelation::className(), ['goods_id' => 'goods_id'])->where(['is_delete' => 0]); } public function getCoupon() { return $this->hasMany(Coupon::className(), ['id' => 'coupon_id']) ->via('goodsCoupon'); } public function getGoods() { return $this->hasOne(Goods::className(), ['id' => 'goods_id']); } public function getOrder() { return $this->hasOne(Order::className(), ['id' => 'order_id']); } public function getRefund() { return $this->hasOne(OrderRefund::className(), ['order_detail_id' => 'id'])->andWhere(['is_delete' => 0])->orderBy('created_at DESC'); } public function getUserCards() { return $this->hasMany(UserCard::className(), ['order_detail_id' => 'id']); } public function getShare() { return $this->hasOne(ShareOrder::className(), ['order_detail_id' => 'id']); } public function getGoodsWarehouse() { return $this->hasOne(GoodsWarehouse::className(), ['id' => 'goods_warehouse_id']) ->via('goods'); } public function getExpressRelation() { return $this->hasOne(OrderDetailExpressRelation::className(), ['order_detail_id' => 'id'])->andWhere(['is_delete' => 0]); } public function getRefundStatusText() { if ($this->refund_status == 0) { $refundStatusText = '未售后'; } elseif ($this->refund_status == 1) { $refundStatusText = '售后申请中'; } elseif ($this->refund_status == 2) { $refundStatusText = '售后完成'; } else { $refundStatusText = '位置状态'; } return $refundStatusText; } public function getOrderRefund() { return $this->hasOne(OrderRefund::className(), ['order_detail_id' => 'id']); } public function changePluginData($pluginData) { if (version_compare(\Yii::$app->getAppVersion(), '4.2.88') == 1) { return $pluginData; } else { if (isset($pluginData['discount_list'])) { return $pluginData['discount_list']; } else { return []; } } } }