diff --git a/app/src/main/java/com/el/yello/presentation/main/MainActivity.kt b/app/src/main/java/com/el/yello/presentation/main/MainActivity.kt index 295dceb52..1e23766d5 100644 --- a/app/src/main/java/com/el/yello/presentation/main/MainActivity.kt +++ b/app/src/main/java/com/el/yello/presentation/main/MainActivity.kt @@ -9,6 +9,7 @@ import androidx.activity.viewModels import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import androidx.fragment.app.commit +import androidx.fragment.app.commitNow import androidx.fragment.app.replace import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope @@ -21,9 +22,11 @@ import com.el.yello.presentation.main.profile.ProfileViewModel import com.el.yello.presentation.main.profile.info.ProfileFragment import com.el.yello.presentation.main.recommend.RecommendFragment import com.el.yello.presentation.main.yello.YelloFragment +import com.el.yello.presentation.pay.PayReSubsNoticeDialog import com.el.yello.presentation.util.dp import com.el.yello.util.amplitude.AmplitudeUtils import com.el.yello.util.context.yelloSnackbar +import com.example.domain.enum.SubscribeType import com.example.ui.base.BindingActivity import com.example.ui.context.toast import com.example.ui.intent.stringExtra @@ -31,6 +34,9 @@ import com.example.ui.view.UiState import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach +import java.text.SimpleDateFormat +import java.util.Calendar +import java.util.concurrent.TimeUnit @AndroidEntryPoint class MainActivity : BindingActivity(R.layout.activity_main) { @@ -55,7 +61,8 @@ class MainActivity : BindingActivity(R.layout.activity_main override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - + viewModel.getUserSubsInfoStateFromServer() + observeSubsNeededState() initBnvItemIconTintList() initBnvItemSelectedListener() initBnvItemReselectedListener() @@ -67,6 +74,48 @@ class MainActivity : BindingActivity(R.layout.activity_main this.onBackPressedDispatcher.addCallback(this, onBackPressedCallback) } + private fun observeSubsNeededState() { + viewModel.getUserSubsInfoState.flowWithLifecycle(lifecycle).onEach { state -> + when (state) { + is UiState.Success -> { + if (state.data?.subscribe == SubscribeType.CANCELED) { + val expiredDateString = state.data?.expiredDate.toString() + val expiredDate = + SimpleDateFormat(EXPIRED_DATE_FORMAT).parse(expiredDateString) + val currentDate = Calendar.getInstance().time + val daysDifference = TimeUnit.DAYS.convert( + expiredDate.time - currentDate.time, + TimeUnit.MILLISECONDS, + ) + if (daysDifference >= 1) { + val expiredDateString = state.data?.expiredDate.toString() + val payResubsNoticeFragment = + PayReSubsNoticeDialog.newInstance(expiredDateString) + supportFragmentManager.commitNow { + add( + payResubsNoticeFragment, + PAY_RESUBS_DIALOG, + ) + } + } + } + } + + is UiState.Failure -> { + yelloSnackbar(binding.root, getString(R.string.msg_error)) + } + + is UiState.Empty -> { + return@onEach + } + + is UiState.Loading -> { + return@onEach + } + } + }.launchIn(lifecycleScope) + } + private fun initBnvItemIconTintList() { binding.bnvMain.itemIconTintList = null binding.bnvMain.selectedItemId = R.id.menu_yello @@ -209,9 +258,9 @@ class MainActivity : BindingActivity(R.layout.activity_main const val NEW_FRIEND = "NEW_FRIEND" const val VOTE_AVAILABLE = "VOTE_AVAILABLE" const val RECOMMEND = "RECOMMEND" - const val BACK_PRESSED_INTERVAL = 2000 - + const val EXPIRED_DATE_FORMAT = "yyyy-MM-dd" + const val PAY_RESUBS_DIALOG = "PayResubsNoticeDialog" private const val EVENT_CLICK_RECOMMEND_NAVIGATION = "click_recommend_navigation" fun getIntent(context: Context, type: String? = null, path: String? = null) = diff --git a/app/src/main/java/com/el/yello/presentation/main/myyello/MyYelloAdapter.kt b/app/src/main/java/com/el/yello/presentation/main/myyello/MyYelloAdapter.kt index 539becf1b..dc9969418 100644 --- a/app/src/main/java/com/el/yello/presentation/main/myyello/MyYelloAdapter.kt +++ b/app/src/main/java/com/el/yello/presentation/main/myyello/MyYelloAdapter.kt @@ -10,7 +10,7 @@ import com.el.yello.R import com.el.yello.databinding.ItemMyYelloBinding import com.el.yello.util.Utils import com.example.domain.entity.Yello -import com.example.domain.enum.GenderEnum +import com.example.domain.enum.Gender import com.example.ui.view.setOnSingleClickListener class MyYelloAdapter(private val itemClick: (Yello, Int) -> (Unit)) : @@ -73,7 +73,7 @@ class MyYelloAdapter(private val itemClick: (Yello, Int) -> (Unit)) : ) ) binding.tvTime.setTextColor(ContextCompat.getColor(itemView.context, R.color.grayscales_600)) - if (item.gender == GenderEnum.M) { + if (item.gender == Gender.M) { if ((item.isHintUsed || item.nameHint != -1) && item.isRead) { binding.cardMyYello.setCardBackgroundColor( ContextCompat.getColor( diff --git a/app/src/main/java/com/el/yello/presentation/main/profile/ProfileViewModel.kt b/app/src/main/java/com/el/yello/presentation/main/profile/ProfileViewModel.kt index 0e84d6752..40d296a26 100644 --- a/app/src/main/java/com/el/yello/presentation/main/profile/ProfileViewModel.kt +++ b/app/src/main/java/com/el/yello/presentation/main/profile/ProfileViewModel.kt @@ -4,6 +4,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.el.yello.util.amplitude.AmplitudeUtils import com.example.domain.entity.PayInfoModel +import com.example.domain.entity.PayUserSubsInfoModel import com.example.domain.entity.ProfileFriendsListModel import com.example.domain.entity.ProfileUserModel import com.example.domain.entity.vote.VoteCount @@ -60,6 +61,10 @@ class ProfileViewModel @Inject constructor( private val _voteCount = MutableStateFlow>(UiState.Loading) val voteCount: StateFlow> = _voteCount + private val _getUserSubsInfoState = + MutableStateFlow>(UiState.Empty) + val getUserSubsInfoState: StateFlow> = _getUserSubsInfoState + var isItemBottomSheetRunning: Boolean = false var isFirstScroll: Boolean = true @@ -240,4 +245,19 @@ class ProfileViewModel @Inject constructor( }.onFailure(Timber::e) } } + fun getUserSubsInfoStateFromServer() { + viewModelScope.launch { + payRepository.getUserSubsInfo() + .onSuccess { userInfo -> + if (userInfo == null) { + _getUserSubsInfoState.value = UiState.Empty + } else { + _getUserSubsInfoState.value = UiState.Success(userInfo) + } + } + .onFailure { + _getUserSubsInfoState.value = UiState.Failure(it.message.toString()) + } + } + } } diff --git a/app/src/main/java/com/el/yello/presentation/onboarding/fragment/highschoolinfo/HighSchoolInfoFragment.kt b/app/src/main/java/com/el/yello/presentation/onboarding/fragment/highschoolinfo/HighSchoolInfoFragment.kt index 9bf9defe6..85df6dfb1 100644 --- a/app/src/main/java/com/el/yello/presentation/onboarding/fragment/highschoolinfo/HighSchoolInfoFragment.kt +++ b/app/src/main/java/com/el/yello/presentation/onboarding/fragment/highschoolinfo/HighSchoolInfoFragment.kt @@ -12,7 +12,7 @@ import com.el.yello.presentation.onboarding.fragment.highschoolinfo.group.GroupD import com.el.yello.presentation.onboarding.fragment.highschoolinfo.school.SearchDialogHighSchoolFragment import com.el.yello.util.amplitude.AmplitudeUtils import com.el.yello.util.context.yelloSnackbar -import com.example.domain.enum.GradeEnum +import com.example.domain.enum.Grade import com.example.ui.base.BindingFragment import com.example.ui.view.setOnSingleClickListener import org.json.JSONObject @@ -24,9 +24,9 @@ class HighSchoolInfoFragment : override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) binding.vm = viewModel - binding.first = GradeEnum.A.toInt() - binding.second = GradeEnum.B.toInt() - binding.third = GradeEnum.C.toInt() + binding.first = Grade.A.toInt() + binding.second = Grade.B.toInt() + binding.third = Grade.C.toInt() setupHighSchool() setupGrade() setupHighSchoolGroup() @@ -61,7 +61,7 @@ class HighSchoolInfoFragment : private fun setupGrade() { viewModel.studentIdText.observe(viewLifecycleOwner) { grade -> when (grade) { - GradeEnum.A.toInt() -> { + Grade.A.toInt() -> { binding.tvGradeFirst.setBackgroundResource(R.drawable.shape_grayscales900_fill_yello_main600_line_8_leftrect) binding.tvGradeFirst.setTextColor(resources.getColor(R.color.yello_main_600)) binding.tvGradeSecond.setBackgroundResource(R.drawable.shape_grayscales900_fill_grayscales700_line_8_square) @@ -70,7 +70,7 @@ class HighSchoolInfoFragment : binding.tvGradeThird.setTextColor(resources.getColor(R.color.grayscales_700)) } - GradeEnum.B.toInt() -> { + Grade.B.toInt() -> { binding.tvGradeFirst.setBackgroundResource(R.drawable.shape_grayscales900_fill_grayscales700_line_8_leftrect) binding.tvGradeFirst.setTextColor(resources.getColor(R.color.grayscales_700)) binding.tvGradeSecond.setBackgroundResource(R.drawable.shape_grayscales900_fill_yello_main600_line_8_square) @@ -79,7 +79,7 @@ class HighSchoolInfoFragment : binding.tvGradeThird.setTextColor(resources.getColor(R.color.grayscales_700)) } - GradeEnum.C.toInt() -> { + Grade.C.toInt() -> { binding.tvGradeFirst.setBackgroundResource(R.drawable.shape_grayscales900_fill_grayscales700_line_8_leftrect) binding.tvGradeFirst.setTextColor(resources.getColor(R.color.grayscales_700)) binding.tvGradeSecond.setBackgroundResource(R.drawable.shape_grayscales900_fill_grayscales700_line_8_square) diff --git a/app/src/main/java/com/el/yello/presentation/onboarding/fragment/studenttype/SelectStudentFragment.kt b/app/src/main/java/com/el/yello/presentation/onboarding/fragment/studenttype/SelectStudentFragment.kt index cf7b7e035..78ed2e662 100644 --- a/app/src/main/java/com/el/yello/presentation/onboarding/fragment/studenttype/SelectStudentFragment.kt +++ b/app/src/main/java/com/el/yello/presentation/onboarding/fragment/studenttype/SelectStudentFragment.kt @@ -9,7 +9,7 @@ import com.el.yello.databinding.FragmentSelectStudentTypeBinding import com.el.yello.presentation.onboarding.activity.OnBoardingActivity import com.el.yello.presentation.onboarding.activity.OnBoardingViewModel import com.el.yello.util.amplitude.AmplitudeUtils -import com.example.domain.enum.StudentTypeEnum +import com.example.domain.enum.StudentType import com.example.ui.base.BindingFragment import com.example.ui.view.setOnSingleClickListener import org.json.JSONObject @@ -21,8 +21,8 @@ class SelectStudentFragment : override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) binding.vm = viewModel - binding.highschool = StudentTypeEnum.H.toString() - binding.university = StudentTypeEnum.U.toString() + binding.highschool = StudentType.H.toString() + binding.university = StudentType.U.toString() setupStudentType() } @@ -33,7 +33,7 @@ class SelectStudentFragment : private fun setupStudentType() { viewModel.studentType.observe(viewLifecycleOwner) { studentType -> when (studentType) { - StudentTypeEnum.H.toString() -> { + StudentType.H.toString() -> { binding.btnSchoolHighschool.setBackgroundResource(R.drawable.shape_black_fill_yello_main_500_line_8_rect) binding.btnSchoolUniversity.setBackgroundResource(R.drawable.shape_black_fill_grayscales700_line_8_rect) binding.ivStudentHighschool.setImageResource(R.drawable.ic_student_highschool_face_select) @@ -48,7 +48,7 @@ class SelectStudentFragment : activity.progressBarPlus() } } - StudentTypeEnum.U.toString() -> { + StudentType.U.toString() -> { binding.btnSchoolUniversity.setBackgroundResource(R.drawable.shape_black_fill_yello_main_500_line_8_rect) binding.btnSchoolHighschool.setBackgroundResource(R.drawable.shape_black_fill_grayscales700_line_8_rect) binding.ivStudentUniversity.setImageResource(R.drawable.ic_student_university_face_select) diff --git a/app/src/main/java/com/el/yello/presentation/pay/PayReSubsNoticeDialog.kt b/app/src/main/java/com/el/yello/presentation/pay/PayReSubsNoticeDialog.kt new file mode 100644 index 000000000..233ea8786 --- /dev/null +++ b/app/src/main/java/com/el/yello/presentation/pay/PayReSubsNoticeDialog.kt @@ -0,0 +1,75 @@ +package com.el.yello.presentation.pay + +import android.content.Intent +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.os.Bundle +import android.view.View +import android.view.ViewGroup +import android.view.WindowManager +import com.el.yello.R +import com.el.yello.databinding.FragmentNoticeResubscribeBinding +import com.example.ui.base.BindingDialogFragment +import com.example.ui.view.setOnSingleClickListener + +class PayReSubsNoticeDialog : + BindingDialogFragment(R.layout.fragment_notice_resubscribe) { + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + setNoticeBtnClickListener() + getArgExpiredDate() + } + + override fun onStart() { + super.onStart() + showDialogFullScreen() + } + + private fun showDialogFullScreen() { + dialog?.window?.setLayout( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, + ) + dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + dialog?.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) + } + + private fun setNoticeBtnClickListener() { + binding.btnNoticeQuit.setOnSingleClickListener { + dismiss() + } + binding.btnYelloplusSubscribe.setOnSingleClickListener { + Intent(requireContext(), PayActivity::class.java).apply { + startActivity(this) + } + dismiss() + } + } + + private fun setExpiredDate(expiredDate: String) { + if (isAdded) { + binding.tvResubscribeExpiredDate.text = expiredDate + } + } + + private fun getArgExpiredDate() { + val expiredDate = arguments?.getString(ARG_EXPIRED_DATE) + expiredDate?.let { + setExpiredDate(it) + } + } + + companion object { + private const val ARG_EXPIRED_DATE = "arg_expired_date" + + @JvmStatic + fun newInstance(expiredDate: String): PayReSubsNoticeDialog { + return PayReSubsNoticeDialog().apply { + arguments = Bundle().apply { + putString(ARG_EXPIRED_DATE, expiredDate) + } + } + } + } +} diff --git a/app/src/main/java/com/el/yello/presentation/pay/PayViewModel.kt b/app/src/main/java/com/el/yello/presentation/pay/PayViewModel.kt index 024bdbe8f..94278dd5c 100644 --- a/app/src/main/java/com/el/yello/presentation/pay/PayViewModel.kt +++ b/app/src/main/java/com/el/yello/presentation/pay/PayViewModel.kt @@ -6,7 +6,6 @@ import com.example.domain.entity.PayInAppModel import com.example.domain.entity.PayInfoModel import com.example.domain.entity.PayRequestModel import com.example.domain.entity.PaySubsModel -import com.example.domain.entity.PaySubsNeededModel import com.example.domain.repository.PayRepository import com.example.ui.view.UiState import dagger.hilt.android.lifecycle.HiltViewModel @@ -17,7 +16,7 @@ import javax.inject.Inject @HiltViewModel class PayViewModel @Inject constructor( - private val payRepository: PayRepository + private val payRepository: PayRepository, ) : ViewModel() { var currentInAppItem = String() @@ -28,9 +27,6 @@ class PayViewModel @Inject constructor( private val _postInAppCheckState = MutableStateFlow>(UiState.Empty) val postInAppCheckState: StateFlow> = _postInAppCheckState - private val _getSubsNeededState = MutableStateFlow>(UiState.Empty) - val getSubsNeededState: StateFlow> = _getSubsNeededState - private val _getPurchaseInfoState = MutableStateFlow>(UiState.Empty) val getPurchaseInfoState: StateFlow> = _getPurchaseInfoState @@ -71,20 +67,6 @@ class PayViewModel @Inject constructor( } } - // 서버 통신 - (아직 사용 X) 구독 재촉 알림 필요 여부 확인 - fun getSubsNeededFromServer() { - viewModelScope.launch { - payRepository.getSubsNeeded() - .onSuccess { - it ?: return@launch - _getSubsNeededState.value = UiState.Success(it) - } - .onFailure { - _getSubsNeededState.value = UiState.Failure(it.message.toString()) - } - } - } - fun getPurchaseInfoFromServer() { viewModelScope.launch { payRepository.getPurchaseInfo() diff --git a/app/src/main/res/drawable/ic_notice_subscribe_one.xml b/app/src/main/res/drawable/ic_notice_subscribe_one.xml new file mode 100644 index 000000000..01dfe5cf4 --- /dev/null +++ b/app/src/main/res/drawable/ic_notice_subscribe_one.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_notice_subscribe_three.xml b/app/src/main/res/drawable/ic_notice_subscribe_three.xml new file mode 100644 index 000000000..a922d00c5 --- /dev/null +++ b/app/src/main/res/drawable/ic_notice_subscribe_three.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_notice_subscribe_two.xml b/app/src/main/res/drawable/ic_notice_subscribe_two.xml new file mode 100644 index 000000000..73e5e9ab5 --- /dev/null +++ b/app/src/main/res/drawable/ic_notice_subscribe_two.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/shape_grayscales900_fill_grayscales700_circle.xml b/app/src/main/res/drawable/shape_grayscales900_fill_grayscales700_circle.xml new file mode 100644 index 000000000..132244d0f --- /dev/null +++ b/app/src/main/res/drawable/shape_grayscales900_fill_grayscales700_circle.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_notice_resubscribe.xml b/app/src/main/res/layout/fragment_notice_resubscribe.xml new file mode 100644 index 000000000..76381510c --- /dev/null +++ b/app/src/main/res/layout/fragment_notice_resubscribe.xml @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8e7c7811c..41f700fe4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -341,4 +341,13 @@ 친구를 추가해주세요! 4명 이상의 친구를 가지면 선택지가 채워져요. + 곧 옐로플러스의 \n특별한 혜택을 잃게 돼요 + 에 만료 예정인 + 옐로 플러스의 구독을 해지했어요. + 이름 열람권 매주 3회 + 포인트 2배 지급 + 초성 힌트 무제한 제공 + 곧 위와 같은 혜택을 누릴 수 없게 돼요. \n\n옐로 플러스의 특별한 서비스를\n계속 이용하시려면, 버튼을 눌러\n구독을 계속해 보세요! + 계속 옐로플러스 구독하기 + diff --git a/data/src/main/java/com/example/data/datasource/PayDataSource.kt b/data/src/main/java/com/example/data/datasource/PayDataSource.kt index 13378adc7..ad5b27bfa 100644 --- a/data/src/main/java/com/example/data/datasource/PayDataSource.kt +++ b/data/src/main/java/com/example/data/datasource/PayDataSource.kt @@ -5,22 +5,19 @@ import com.example.data.model.response.BaseResponse import com.example.data.model.response.pay.ResponsePayInAppDto import com.example.data.model.response.pay.ResponsePaySubsDto import com.example.data.model.response.pay.ResponsePurchaseInfoDto -import com.example.data.model.response.pay.ResponseSubsNeededDto +import com.example.data.model.response.pay.ResponseUserSubsInfoDto interface PayDataSource { suspend fun postToCheckSubsData( - request: RequestPayDto + request: RequestPayDto, ): BaseResponse suspend fun postToCheckInAppData( - request: RequestPayDto + request: RequestPayDto, ): BaseResponse - suspend fun getSubsNeededData( - ): BaseResponse + suspend fun getPurchaseInfoData(): BaseResponse - suspend fun getPurchaseInfoData( - ): BaseResponse - -} \ No newline at end of file + suspend fun getUserSubsInfoData(): BaseResponse +} diff --git a/data/src/main/java/com/example/data/datasource/remote/PayDataSourceImpl.kt b/data/src/main/java/com/example/data/datasource/remote/PayDataSourceImpl.kt index c7db9375b..9f85e0706 100644 --- a/data/src/main/java/com/example/data/datasource/remote/PayDataSourceImpl.kt +++ b/data/src/main/java/com/example/data/datasource/remote/PayDataSourceImpl.kt @@ -3,37 +3,34 @@ package com.example.data.datasource.remote import com.example.data.datasource.PayDataSource import com.example.data.model.request.pay.RequestPayDto import com.example.data.model.response.BaseResponse -import com.example.data.model.response.pay.ResponseSubsNeededDto import com.example.data.model.response.pay.ResponsePayInAppDto import com.example.data.model.response.pay.ResponsePaySubsDto import com.example.data.model.response.pay.ResponsePurchaseInfoDto +import com.example.data.model.response.pay.ResponseUserSubsInfoDto import com.example.data.remote.service.PayService import javax.inject.Inject class PayDataSourceImpl @Inject constructor( - private val payService: PayService + private val payService: PayService, ) : PayDataSource { override suspend fun postToCheckSubsData( - request: RequestPayDto + request: RequestPayDto, ): BaseResponse { return payService.postToCheckSubs(request) } override suspend fun postToCheckInAppData( - request: RequestPayDto + request: RequestPayDto, ): BaseResponse { return payService.postToCheckInApp(request) } - override suspend fun getSubsNeededData( - ): BaseResponse { - return payService.getSubsNeeded() - } - - override suspend fun getPurchaseInfoData( - ): BaseResponse { + override suspend fun getPurchaseInfoData(): BaseResponse { return payService.getPurchaseInfo() } -} \ No newline at end of file + override suspend fun getUserSubsInfoData(): BaseResponse { + return payService.getUserSubsInfo() + } +} diff --git a/data/src/main/java/com/example/data/model/response/pay/ResponseSubsNeededDto.kt b/data/src/main/java/com/example/data/model/response/pay/ResponseSubsNeededDto.kt deleted file mode 100644 index 7bec4bb17..000000000 --- a/data/src/main/java/com/example/data/model/response/pay/ResponseSubsNeededDto.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.example.data.model.response.pay - -import com.example.domain.entity.PaySubsNeededModel -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -data class ResponseSubsNeededDto( - @SerialName("subscribe") - val subscribe: String, - @SerialName("isSubscribeNeeded") - val isSubscribeNeeded: Boolean -) { - fun toResponseSubsNeededModel(): PaySubsNeededModel { - return PaySubsNeededModel( - subscribe, isSubscribeNeeded - ) - } -} \ No newline at end of file diff --git a/data/src/main/java/com/example/data/model/response/pay/ResponseUserSubsInfoDto.kt b/data/src/main/java/com/example/data/model/response/pay/ResponseUserSubsInfoDto.kt new file mode 100644 index 000000000..a43ef931e --- /dev/null +++ b/data/src/main/java/com/example/data/model/response/pay/ResponseUserSubsInfoDto.kt @@ -0,0 +1,24 @@ +package com.example.data.model.response.pay + +import com.example.domain.entity.PayUserSubsInfoModel +import com.example.domain.enum.toSubscribeType +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ResponseUserSubsInfoDto( + @SerialName("id") + val id: Long, + @SerialName("subscribe") + val subscribe: String, + @SerialName("expiredDate") + val expiredDate: String, +) { + fun toResponseUserSubsInfoModel(): PayUserSubsInfoModel { + return PayUserSubsInfoModel( + id = id, + subscribe = subscribe.toSubscribeType(), + expiredDate = expiredDate, + ) + } +} diff --git a/data/src/main/java/com/example/data/model/response/yello/ResponseMyYello.kt b/data/src/main/java/com/example/data/model/response/yello/ResponseMyYello.kt index 5f9471c85..8330fed83 100644 --- a/data/src/main/java/com/example/data/model/response/yello/ResponseMyYello.kt +++ b/data/src/main/java/com/example/data/model/response/yello/ResponseMyYello.kt @@ -3,7 +3,7 @@ package com.example.data.model.response.yello import com.example.domain.entity.MyYello import com.example.domain.entity.Vote import com.example.domain.entity.Yello -import com.example.domain.enum.GenderEnum +import com.example.domain.enum.Gender import kotlinx.serialization.Serializable @Serializable @@ -40,7 +40,7 @@ data class YelloDto( val createdAt: String, ) { fun toYello(): Yello { - val genderEnum = if (senderGender.contains("FE")) GenderEnum.W else GenderEnum.M + val genderEnum = if (senderGender.contains("FE")) Gender.W else Gender.M return Yello( id, genderEnum, diff --git a/data/src/main/java/com/example/data/remote/service/PayService.kt b/data/src/main/java/com/example/data/remote/service/PayService.kt index c616b3c08..08c17b91d 100644 --- a/data/src/main/java/com/example/data/remote/service/PayService.kt +++ b/data/src/main/java/com/example/data/remote/service/PayService.kt @@ -2,10 +2,10 @@ package com.example.data.remote.service import com.example.data.model.request.pay.RequestPayDto import com.example.data.model.response.BaseResponse -import com.example.data.model.response.pay.ResponseSubsNeededDto import com.example.data.model.response.pay.ResponsePayInAppDto import com.example.data.model.response.pay.ResponsePaySubsDto import com.example.data.model.response.pay.ResponsePurchaseInfoDto +import com.example.data.model.response.pay.ResponseUserSubsInfoDto import retrofit2.http.Body import retrofit2.http.GET import retrofit2.http.POST @@ -14,20 +14,17 @@ interface PayService { @POST("/api/v1/purchase/google/verify/subscribe") suspend fun postToCheckSubs( - @Body request: RequestPayDto + @Body request: RequestPayDto, ): BaseResponse @POST("/api/v1/purchase/google/verify/ticket") suspend fun postToCheckInApp( - @Body request: RequestPayDto + @Body request: RequestPayDto, ): BaseResponse - @GET("/api/v1/purchase/subscribe") - suspend fun getSubsNeeded( - ): BaseResponse - @GET("/api/v1/purchase") - suspend fun getPurchaseInfo( - ): BaseResponse + suspend fun getPurchaseInfo(): BaseResponse -} \ No newline at end of file + @GET("/api/v1/user/subscribe") + suspend fun getUserSubsInfo(): BaseResponse +} diff --git a/data/src/main/java/com/example/data/repository/PayRepositoryImpl.kt b/data/src/main/java/com/example/data/repository/PayRepositoryImpl.kt index 54e56d295..b3198e89f 100644 --- a/data/src/main/java/com/example/data/repository/PayRepositoryImpl.kt +++ b/data/src/main/java/com/example/data/repository/PayRepositoryImpl.kt @@ -2,50 +2,47 @@ package com.example.data.repository import com.example.data.datasource.PayDataSource import com.example.data.model.request.pay.toRequestDto -import com.example.domain.entity.PayRequestModel import com.example.domain.entity.PayInAppModel -import com.example.domain.entity.PaySubsModel import com.example.domain.entity.PayInfoModel -import com.example.domain.entity.PaySubsNeededModel +import com.example.domain.entity.PayRequestModel +import com.example.domain.entity.PaySubsModel +import com.example.domain.entity.PayUserSubsInfoModel import com.example.domain.repository.PayRepository import javax.inject.Inject class PayRepositoryImpl @Inject constructor( - private val payDataSource: PayDataSource + private val payDataSource: PayDataSource, ) : PayRepository { override suspend fun postToCheckSubs( - request: PayRequestModel + request: PayRequestModel, ): Result { return runCatching { payDataSource.postToCheckSubsData( - request.toRequestDto() + request.toRequestDto(), ).data?.toResponsePaySubsModel() } } override suspend fun postToCheckInApp( - request: PayRequestModel + request: PayRequestModel, ): Result { return runCatching { payDataSource.postToCheckInAppData( - request.toRequestDto() + request.toRequestDto(), ).data?.toResponsePayInAppModel() } } - override suspend fun getSubsNeeded( - ): Result { + override suspend fun getPurchaseInfo(): Result { return runCatching { - payDataSource.getSubsNeededData().data?.toResponseSubsNeededModel() + payDataSource.getPurchaseInfoData().data?.toResponsePurchaseInfoModel() } } - override suspend fun getPurchaseInfo( - ): Result { + override suspend fun getUserSubsInfo(): Result { return runCatching { - payDataSource.getPurchaseInfoData().data?.toResponsePurchaseInfoModel() + payDataSource.getUserSubsInfoData().data?.toResponseUserSubsInfoModel() } } - -} \ No newline at end of file +} diff --git a/domain/src/main/java/com/example/domain/entity/MyYello.kt b/domain/src/main/java/com/example/domain/entity/MyYello.kt index c6d397cdc..67e4042e3 100644 --- a/domain/src/main/java/com/example/domain/entity/MyYello.kt +++ b/domain/src/main/java/com/example/domain/entity/MyYello.kt @@ -1,6 +1,6 @@ package com.example.domain.entity -import com.example.domain.enum.GenderEnum +import com.example.domain.enum.Gender data class MyYello( val totalCount: Int, @@ -14,7 +14,7 @@ data class MyYello( data class Yello( val id: Long, - val gender: GenderEnum, + val gender: Gender, var nameHint: Int, val senderName: String, val vote: Vote, diff --git a/domain/src/main/java/com/example/domain/entity/PaySubsNeededModel.kt b/domain/src/main/java/com/example/domain/entity/PaySubsNeededModel.kt deleted file mode 100644 index f00302023..000000000 --- a/domain/src/main/java/com/example/domain/entity/PaySubsNeededModel.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.example.domain.entity - -class PaySubsNeededModel ( - val subscribe: String, - val isSubscribeNeeded: Boolean -) \ No newline at end of file diff --git a/domain/src/main/java/com/example/domain/entity/PayUserSubsInfoModel.kt b/domain/src/main/java/com/example/domain/entity/PayUserSubsInfoModel.kt new file mode 100644 index 000000000..f283ac2cb --- /dev/null +++ b/domain/src/main/java/com/example/domain/entity/PayUserSubsInfoModel.kt @@ -0,0 +1,9 @@ +package com.example.domain.entity + +import com.example.domain.enum.SubscribeType + +class PayUserSubsInfoModel( + val id: Long, + val subscribe: SubscribeType, + val expiredDate: String, +) diff --git a/domain/src/main/java/com/example/domain/enum/GenderEnum.kt b/domain/src/main/java/com/example/domain/enum/Gender.kt similarity index 85% rename from domain/src/main/java/com/example/domain/enum/GenderEnum.kt rename to domain/src/main/java/com/example/domain/enum/Gender.kt index d02316a09..4ada0185e 100644 --- a/domain/src/main/java/com/example/domain/enum/GenderEnum.kt +++ b/domain/src/main/java/com/example/domain/enum/Gender.kt @@ -1,6 +1,6 @@ package com.example.domain.enum -enum class GenderEnum { +enum class Gender { M, W; override fun toString() = when (this) { diff --git a/domain/src/main/java/com/example/domain/enum/GradeEnum.kt b/domain/src/main/java/com/example/domain/enum/Grade.kt similarity index 85% rename from domain/src/main/java/com/example/domain/enum/GradeEnum.kt rename to domain/src/main/java/com/example/domain/enum/Grade.kt index e0e63b7b3..7d6b0a2c2 100644 --- a/domain/src/main/java/com/example/domain/enum/GradeEnum.kt +++ b/domain/src/main/java/com/example/domain/enum/Grade.kt @@ -1,6 +1,6 @@ package com.example.domain.enum -enum class GradeEnum { +enum class Grade { A, B, C; fun toInt() = when (this) { diff --git a/domain/src/main/java/com/example/domain/enum/StudentTypeEnum.kt b/domain/src/main/java/com/example/domain/enum/StudentType.kt similarity index 83% rename from domain/src/main/java/com/example/domain/enum/StudentTypeEnum.kt rename to domain/src/main/java/com/example/domain/enum/StudentType.kt index 381a145ff..7a66474fa 100644 --- a/domain/src/main/java/com/example/domain/enum/StudentTypeEnum.kt +++ b/domain/src/main/java/com/example/domain/enum/StudentType.kt @@ -1,6 +1,6 @@ package com.example.domain.enum -enum class StudentTypeEnum { +enum class StudentType { H, U; override fun toString() = when (this) { H -> "HIGHSCHOOL" diff --git a/domain/src/main/java/com/example/domain/enum/SubscribeType.kt b/domain/src/main/java/com/example/domain/enum/SubscribeType.kt new file mode 100644 index 000000000..4d980783d --- /dev/null +++ b/domain/src/main/java/com/example/domain/enum/SubscribeType.kt @@ -0,0 +1,25 @@ +package com.example.domain.enum + +enum class SubscribeType { + CANCELED, + NORMAL, + ACTIVE, + ERROR, + ; + + override fun toString() = when (this) { + CANCELED -> "canceled" + NORMAL -> "normal" + ACTIVE -> "active" + ERROR -> "error" + } +} + +fun String.toSubscribeType(): SubscribeType { + return when (this) { + "canceled" -> SubscribeType.CANCELED + "normal" -> SubscribeType.NORMAL + "active" -> SubscribeType.ACTIVE + else -> SubscribeType.ERROR + } +} diff --git a/domain/src/main/java/com/example/domain/repository/PayRepository.kt b/domain/src/main/java/com/example/domain/repository/PayRepository.kt index abdb691cb..46e8b3ce7 100644 --- a/domain/src/main/java/com/example/domain/repository/PayRepository.kt +++ b/domain/src/main/java/com/example/domain/repository/PayRepository.kt @@ -4,22 +4,19 @@ import com.example.domain.entity.PayInAppModel import com.example.domain.entity.PayInfoModel import com.example.domain.entity.PayRequestModel import com.example.domain.entity.PaySubsModel -import com.example.domain.entity.PaySubsNeededModel +import com.example.domain.entity.PayUserSubsInfoModel interface PayRepository { suspend fun postToCheckSubs( - request: PayRequestModel + request: PayRequestModel, ): Result suspend fun postToCheckInApp( - request: PayRequestModel + request: PayRequestModel, ): Result - suspend fun getSubsNeeded( - ): Result - - suspend fun getPurchaseInfo( - ): Result + suspend fun getPurchaseInfo(): Result + suspend fun getUserSubsInfo(): Result }