| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace app\common\dao\user;
- use app\common\dao\BaseDao;
- use app\common\enum\user\UserSignFugouEnum;
- use app\common\model\BaseModel;
- use app\common\model\user\UserSignFugou;
- use app\entity\CommonEntity;
- use app\entity\data\user\UserSignFugouEntity;
- use think\db\exception\DataNotFoundException;
- use think\db\exception\DbException;
- use think\db\exception\ModelNotFoundException;
- class UserSignFugouDao extends BaseDao
- {
- /**
- * @return BaseModel
- */
- protected function getModel(): string
- {
- return UserSignFugou::class;
- }
- /**
- * @param array $idList
- * @return CommonEntity[]
- */
- public function getUserSignFugouEntityListByIdList(array $idList): array
- {
- $entityList = [];
- try {
- /** @var UserSignFugou $model */
- $model = $this->getModel();
- $dataRes = $model::getDB()
- ->whereIn('id', $idList)
- ->select()
- ->toArray();
- if (!empty($dataRes)) {
- $entityList = array_map(function ($data) {
- return UserSignFugouEntity::newInstance($data);
- }, $dataRes);
- }
- } catch (\Exception $e) {
- }
- return $entityList;
- }
- /**
- * @param string $orderType
- * @param array $orderIdList
- * @return UserSignFugouEntity[]
- */
- public function getUserSignFugouEntityListByOrderIdListAndPending(string $orderType, array $orderIdList): array
- {
- $entityList = [];
- try {
- /** @var UserSignFugou $model */
- $model = $this->getModel();
- $dataList = $model::getDB()
- ->where('order_type', '=', $orderType)
- ->whereIn('order_id', $orderIdList)
- ->where('status', '=', UserSignFugouEnum::STATUS['Pending']['code'])
- ->select()
- ->toArray();
- if (!empty($dataList)) {
- $entityList = array_map(function ($data) {
- return UserSignFugouEntity::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 [];
- }
- }
- }
|