2],null,'id,ptStyle,shopName',null,true); if(empty($shopList)){ return false; } foreach($shopList as $shop){ $mainId = $shop->mainId; $shopName = $shop->shopName??''; $sjName = $shop->merchantName??''; $name = $sjName.' '.$shopName; $cacheKey = 'live_order_' . $mainId; $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]); if(empty($has)){ continue; } echo $cacheKey.' '; $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $list = LiveOrderClass::getAllByCondition(['mainId' => $mainId,'switchOrder'=>0], null, '*'); if(empty($list)){ continue; } $customInfo = CustomClass::getAllByCondition(['ownMainId'=>$mainId],null,'*','id'); $total = []; $format = []; foreach ($list as $key => $live) { $addTime = $live['addTime']; $orderSn = $live['orderSn']; $itemId = $live['itemId']; $ptItemId = $live['ptItemId']; $date = date("Y-m-d", strtotime($addTime)); $customList = LiveOrderCustomClass::getAllByCondition(['orderSn'=>$orderSn],null,'*'); if(empty($customList)){ continue; } $total[$date] = 1; foreach($customList as $k => $v){ $customId = $v['customId']??0; $num = $v['num']??0; $unitPrice = $v['unitPrice']??0; $currentCustom = $customInfo[$customId]??[]; if(empty($currentCustom)){ throw new \Exception("出现不存在的客户 customId:{$customId}"); } $format[$customId][] =[ 'productId'=>$itemId, 'bigNum'=>$num, 'itemId'=>$ptItemId, 'smallNum'=>0, 'price'=>$unitPrice, ]; } } if (count($total) > 1) { noticeUtil::push($name." mainId:{$mainId} live order 有记录不是同一天的", '15280215347'); continue; } print_r($format);die; $hasPay = 2; $customId = 0; $custom = CustomClass::getCustom($customId); $post = []; $post['shopId'] =0; OrderService::createFinishOrder($post, $custom, $hasPay); //转换完了之后要清货位号!!!!!!!!! $transaction->commit(); Yii::$app->redis->executeCommand('DEL', [$cacheKey]); } catch (\Exception $e) { $transaction->rollBack(); $msg = $e->getMessage(); noticeUtil::push($name." mainId:{$mainId} live order 报错了:".$msg, '15280215347'); } } } }