getModel(); $dataRes = $model::getDB() ->whereIn('id', $idList) ->select() ->toArray(); if (!empty($dataRes)) { $entityList = array_map(function ($data) { return UserSignScoreEntity::newInstance($data); }, $dataRes); } } catch (\Exception $e) { } return $entityList; } /** * @param string $orderType * @param array $orderIdList * @return UserSignScoreEntity[] */ public function getUserSignScoreEntityListByOrderIdListAndPending(string $orderType, array $orderIdList): array { $entityList = []; try { $dataList = UserSignScore::getDB() ->where('order_type', '=', $orderType) ->whereIn('order_id', $orderIdList) ->where('status', '=', UserSignScoreEnum::STATUS['Pending']['code']) ->select() ->toArray(); if (!empty($dataList)) { $entityList = array_map(function ($data) { return UserSignScoreEntity::newInstance($data); }, $dataList); } } catch (DataNotFoundException|ModelNotFoundException|DbException $e) { } return $entityList; } /** * 批量更新 * @param $dataList * @return array */ public function saveAll($dataList): array { try { return $this->getModel()::getInstance()->allowField(array_keys(reset($dataList)))->saveAll($dataList)->toArray(); } catch (\Exception $e) { return []; } } }