ArchivesApplyService.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace services\common;
  3. use common\enums\AuditStatusEnum;
  4. use common\enums\MemberTypeEnum;
  5. use common\enums\StatusEnum;
  6. use common\models\common\ArchivesApply;
  7. /**
  8. * Class ArchivesApplyService
  9. * @package services\common
  10. */
  11. class ArchivesApplyService
  12. {
  13. /**
  14. * @return array|\yii\db\ActiveRecord[]
  15. */
  16. public function getGroupStateCount($member_type = MemberTypeEnum::MERCHANT)
  17. {
  18. return ArchivesApply::find()
  19. ->select(['audit_status', 'count(id) as count'])
  20. ->where(['status' => StatusEnum::ENABLED])
  21. ->andWhere(['member_type' => $member_type])
  22. ->groupBy('audit_status')
  23. ->asArray()
  24. ->all();
  25. }
  26. /**
  27. * @return bool|int|string
  28. */
  29. public function getApplyCount($merchant_id = '', $member_type = MemberTypeEnum::MERCHANT)
  30. {
  31. return ArchivesApply::find()
  32. ->where(['status' => StatusEnum::ENABLED, 'audit_status' => AuditStatusEnum::DISABLED])
  33. ->andWhere(['member_type' => $member_type])
  34. ->andFilterWhere(['merchant_id' => $merchant_id])
  35. ->count() ?? 0;
  36. }
  37. /**
  38. * @return array|\yii\db\ActiveRecord|null
  39. */
  40. public function findById($id)
  41. {
  42. return ArchivesApply::find()
  43. ->where(['id' => $id])
  44. ->one();
  45. }
  46. /**
  47. * 商户最后一条认证信息
  48. *
  49. * @return array|\yii\db\ActiveRecord|null
  50. */
  51. public function findLastByMerchantId($merchant_id)
  52. {
  53. return ArchivesApply::find()
  54. ->where(['merchant_id' => $merchant_id])
  55. ->andWhere(['member_type' => MemberTypeEnum::MERCHANT])
  56. ->andWhere(['status' => StatusEnum::ENABLED])
  57. ->orderBy('id desc')
  58. ->one();
  59. }
  60. }
粤ICP备19079148号