admin_id,$this->type,'同步互医队列start'); $t = \Yii::$app->db->beginTransaction(); try { $DrugStoreDrug = DrugStoreDrug::find()->select(['drug_id', 'price', 'stock', 'status'])->all(); if (!$DrugStoreDrug) throw new Exception('暂无数据'); foreach ($DrugStoreDrug as $value) { $item= [ 'platform_store_id' => 0, 'id' => $value['drug_id'], 'price' => $value['price'], 'stock' => $value['stock'], 'is_sale' => $value['status'] == 1 ? 0 : 1, ]; $response = (new PlatformService())->syncDrug($item); if($response){ $success[]='药品ID:'.$value['drug_id'].'同步成功'; }else{ $error[] = '错误:药品ID:'.$value['drug_id'].'同步失败'; } } $t->commit(); Log::saveLog($this->admin_id,$this->type,'同步互医队列end'); }catch (\Exception $e){ $t->rollBack(); Log::saveLog($this->admin_id,$this->type,'同步互医队列异常:'.$e->getMessage()); return ; } } }