getModel(); $dataRes = $model::getDB() ->whereIn('id', $idList) ->select() ->toArray(); if (!empty($dataRes)) { $entityList = array_map(function ($data) { return UserSignGongxianEntity::newInstance($data); }, $dataRes); } } catch (\Exception $e) { } return $entityList; } /** * @param string $orderType * @param array $orderIdList * @return UserSignGongxianEntity[] */ public function getUserSignGongxianEntityListByOrderIdListAndPending(string $orderType, array $orderIdList): array { $entityList = []; try { $dataList = UserSignGongxian::getDB() ->where('order_type', '=', $orderType) ->whereIn('order_id', $orderIdList) ->where('status', '=', UserSignGongxianEnum::STATUS['PendingConfirmation']['code']) ->select() ->toArray(); if (!empty($dataList)) { $entityList = array_map(function ($data) { return UserSignGongxianEntity::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 []; } } /** * 根据order_id与uid查找贡献值(status=1, type=1) */ public function getGongxianFromUidOrderId($orderId, $uid) { try { return $this::getModel()::getDB() ->where('order_id', '=', $orderId) ->where('status', '=', 1) ->where('type', '=', 1) ->where('uid', '=', $uid) ->value('number'); } catch (\Exception $e) { return []; } } }