UserSignScoreDao.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\common\dao\user;
  3. use app\common\dao\BaseDao;
  4. use app\common\enum\user\UserSignScoreEnum;
  5. use app\common\model\user\UserSignScore;
  6. use app\entity\CommonEntity;
  7. use app\entity\data\user\UserSignScoreEntity;
  8. use think\db\exception\DataNotFoundException;
  9. use think\db\exception\DbException;
  10. use think\db\exception\ModelNotFoundException;
  11. class UserSignScoreDao extends BaseDao
  12. {
  13. protected function getModel(): string
  14. {
  15. return UserSignScore::class;
  16. }
  17. /**
  18. * @param array $idList
  19. * @return CommonEntity[]
  20. */
  21. public function getStoreSignScoreEntityListByIdList(array $idList): array
  22. {
  23. $entityList = [];
  24. try {
  25. /** @var UserSignScore $model */
  26. $model = $this->getModel();
  27. $dataRes = $model::getDB()
  28. ->whereIn('id', $idList)
  29. ->select()
  30. ->toArray();
  31. if (!empty($dataRes)) {
  32. $entityList = array_map(function ($data) {
  33. return UserSignScoreEntity::newInstance($data);
  34. }, $dataRes);
  35. }
  36. } catch (\Exception $e) {
  37. }
  38. return $entityList;
  39. }
  40. /**
  41. * @param string $orderType
  42. * @param array $orderIdList
  43. * @return UserSignScoreEntity[]
  44. */
  45. public function getUserBillEntityListByOrderIdListAndPending(string $orderType, array $orderIdList): array
  46. {
  47. $entityList = [];
  48. try {
  49. $dataList = UserSignScore::getDB()
  50. ->where('order_type', '=', $orderType)
  51. ->whereIn('order_id', $orderIdList)
  52. ->where('status', '=', UserSignScoreEnum::STATUS['Pending']['code'])
  53. ->select()
  54. ->toArray();
  55. if (!empty($dataList)) {
  56. $entityList = array_map(function ($data) {
  57. return UserSignScoreEntity::newInstance($data);
  58. }, $dataList);
  59. }
  60. } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
  61. }
  62. return $entityList;
  63. }
  64. }