$orderIds])->with(['order_goods'])->select()->toArray(); foreach ($orderList as $order){ $updateData = []; if(OrderEnum::VIRTUAL_ORDER != $order['order_type']){ continue; } $orderGoods = array_shift($order['order_goods']); if(empty($orderGoods)){ continue; } $goodsSnap = $orderGoods['goods_snap']; //实物商品,不处理 if(GoodsEnum::GOODS_REALITY == $goodsSnap->type){ continue; } //自动发货 if(GoodsEnum::AFTER_PAY_AUTO == $goodsSnap->after_pay){ switch ($goodsSnap->delivery_type) { // 固定内容 case 0: $updateData['delivery_content'] = $goodsSnap->delivery_content ?? ''; $updateData['delivery_content_type'] = 0; break; // 发货模版 case 1: if (! isset($goodsSnap->delivery_template)) { break; } $updateData['delivery_content_type'] = $goodsSnap->delivery_template['type']; if ($goodsSnap->delivery_template['type'] === 0) { $updateData['delivery_content'] = $goodsSnap->delivery_template['content'] ?? ''; } if ($goodsSnap->delivery_template['type'] === 1) { $updateData['delivery_content1'] = $goodsSnap->delivery_template['content1'] ?? []; } break; default: $updateData['delivery_content'] = ''; break; } //更新数据 $updateData = array_merge($updateData,[ 'order_status' => OrderEnum::STATUS_WAIT_RECEIVE, 'express_status' => DeliveryEnum::NOT_SHIPPED, 'express_time' => time(), 'delivery_id' => 0, ]); //自动完成订单 if(GoodsEnum::AFTER_DELIVERY_AUTO == $goodsSnap->after_delivery){ $updateData['order_status'] = OrderEnum::STATUS_FINISH; $updateData['confirm_take_time'] = time(); $updateData['after_sale_deadline'] = OrderLogic::getAfterSaleDeadline(); //记录日志 (new OrderLog())->record([ 'type' => OrderLogEnum::TYPE_SYSTEM, 'channel' => OrderLogEnum::USER_CONFIRM_ORDER, 'order_id' => $order['id'] ]); } } //更新订单状态 $updateData && Order::update($updateData,['id'=>$order['id']]); } } }