order = $order; //会员数据整理 $this->member = $order->belongsToMember; //单个会员的Fans(公众号) $this->fans = $order->belongsToMember->hasOneFans; //单个会员的Fans(小程序) $this->miniFans = $order->belongsToMember->hasOneMiniApp; //地址数据整理 $this->address = $order->address; //时间数据整理 $this->timeData = [ 'create_time' => $order->create_time->toDateTimeString(), 'pay_time' => $order->pay_time->toDateTimeString(), 'finish_time' => $order->finish_time->toDateTimeString(), 'cancel_time' => $order->cancel_time->toDateTimeString(), 'send_time' => $order->send_time->toDateTimeString() ]; //订单商品数据整理 $orderGoods = $order->hasManyOrderGoods()->get(); $orderGoods = empty($orderGoods) ? [] : $orderGoods->toArray(); if (count($orderGoods)>0) { $this->orderGoods = $orderGoods; foreach ($orderGoods as $kk=>$vv) { $this->goodsId[] = $vv['goods_id']; $this->goodsTitle .= $vv['title']; if ($vv['goods_option_title']) { $this->goodsTitle .= '[' . $vv['goods_option_title'] . ']'; } $this->goodsTitle .= '*' . $vv['total'] . ','; $this->goodsNum += $vv['total']; } $this->goodsTitle = rtrim($this->goodsTitle,','); } //订单包裹商品数据整理 if($this->order['expressmany']->count()){ $packageList=$this->order['expressmany']->last()['hasManyOrderPackage']; $this->timeData['package_send_time']=$this->order['expressmany']->last()['created_at']->toDateTimeString(); if($packageList->count()>0){ foreach($packageList as $key=>$val){ $this->packageGoodsTitle .= ($val['orderGoods']->title); if ($val['orderGoods']->goods_option_title) { $this->packageGoodsTitle .= '[' . $val['orderGoods']->goods_option_title . ']'; } $this->packageGoodsTitle .= '*' . $val['total'] . ','; } } $this->packageGoodsTitle=rtrim($this->packageGoodsTitle,','); } } }