|
@@ -1,5 +1,7 @@
|
|
|
package com.pan_american.android.ui.group_management.entry_and_exit_fee_detail
|
|
|
|
|
|
+import android.content.Intent
|
|
|
+import android.net.Uri
|
|
|
import android.os.Bundle
|
|
|
import android.view.LayoutInflater
|
|
|
import android.view.View
|
|
@@ -7,6 +9,10 @@ import android.view.ViewGroup
|
|
|
import com.pan_american.android.OASystem
|
|
|
import com.pan_american.android.R
|
|
|
import com.pan_american.android.base.BaseFragment
|
|
|
+import com.pan_american.android.base.BaseResponse
|
|
|
+import com.pan_american.android.base.CustomAlertDialog
|
|
|
+import com.pan_american.android.data.model.group_management.entry_and_exit_fee_detail.network.DownloadCustomerListRequest
|
|
|
+import com.pan_american.android.data.model.group_management.entry_and_exit_fee_detail.network.DownloadCustomerListResponse
|
|
|
import com.pan_american.android.data.model.group_management.entry_and_exit_fee_detail.network.EntryAndExitDetailResponse
|
|
|
import com.pan_american.android.data.network.APIService
|
|
|
import com.pan_american.android.data.network.ServiceCreator
|
|
@@ -14,6 +20,9 @@ import com.pan_american.android.databinding.FragmentEntryAndExitFeeTotalBinding
|
|
|
import org.greenrobot.eventbus.EventBus
|
|
|
import org.greenrobot.eventbus.Subscribe
|
|
|
import org.greenrobot.eventbus.ThreadMode
|
|
|
+import retrofit2.Call
|
|
|
+import retrofit2.Callback
|
|
|
+import retrofit2.Response
|
|
|
|
|
|
class EntryAndExitFeeTotalFragment : BaseFragment<FragmentEntryAndExitFeeTotalBinding>() {
|
|
|
|
|
@@ -52,49 +61,82 @@ class EntryAndExitFeeTotalFragment : BaseFragment<FragmentEntryAndExitFeeTotalBi
|
|
|
override fun initViews() {
|
|
|
OASystem.entryAndExitDetailResponse.apply {
|
|
|
binding.checkInBoard.isChecked = choiceOne == 1
|
|
|
- binding.inBoardTotal.text = String.format(resources.getString(R.string.total_per_fee_format), choiceOneTotalCost)
|
|
|
+ binding.inBoardTotal.text = String.format(
|
|
|
+ resources.getString(R.string.total_per_fee_format),
|
|
|
+ choiceOneTotalCost
|
|
|
+ )
|
|
|
|
|
|
binding.checkEconomyClass.isChecked = choiceTwoJJ == 1
|
|
|
binding.checkBusinessClass.isChecked = choiceTwoGW == 1
|
|
|
binding.checkFirstClass.isChecked = choiceTwoTD == 1
|
|
|
|
|
|
binding.checkAccommodationFee.isChecked = choiceThree == 1
|
|
|
- binding.accommodationTotal.text = String.format(resources.getString(R.string.total_per_fee_format), choiceThreeTotalCost)
|
|
|
+ binding.accommodationTotal.text = String.format(
|
|
|
+ resources.getString(R.string.total_per_fee_format),
|
|
|
+ choiceThreeTotalCost
|
|
|
+ )
|
|
|
|
|
|
binding.checkMealFee.isChecked = choiceFour == 1
|
|
|
- binding.mealTotal.text = String.format(resources.getString(R.string.total_per_fee_format), choiceFourTotalCost)
|
|
|
+ binding.mealTotal.text = String.format(
|
|
|
+ resources.getString(R.string.total_per_fee_format),
|
|
|
+ choiceFourTotalCost
|
|
|
+ )
|
|
|
|
|
|
binding.checkPublicAndMiscellaneous.isChecked = choiceFive == 1
|
|
|
- binding.publicAndMiscellaneousTotal.text = String.format(resources.getString(R.string.total_per_fee_format), choiceFiveTotalCost)
|
|
|
+ binding.publicAndMiscellaneousTotal.text = String.format(
|
|
|
+ resources.getString(R.string.total_per_fee_format),
|
|
|
+ choiceFiveTotalCost
|
|
|
+ )
|
|
|
|
|
|
binding.checkTraining.isChecked = choiceSix == 1
|
|
|
- binding.trainingTotal.text = String.format(resources.getString(R.string.total_per_fee_format), choiceSixTotalCost)
|
|
|
+ binding.trainingTotal.text = String.format(
|
|
|
+ resources.getString(R.string.total_per_fee_format),
|
|
|
+ choiceSixTotalCost
|
|
|
+ )
|
|
|
|
|
|
binding.checkOther.isChecked = otherExpenses_Checked == 1
|
|
|
- binding.otherTotal.text = String.format(resources.getString(R.string.total_per_fee_format), otherExpensesTotalCost)
|
|
|
-
|
|
|
- binding.economyClass.text = String.format(resources.getString(R.string.economy_class_price), outsideJJPay)
|
|
|
- binding.businessClass.text = String.format(resources.getString(R.string.business_class_price), outsideGWPay)
|
|
|
- binding.firstClass.text = String.format(resources.getString(R.string.first_class_price), outsideTDPay)
|
|
|
+ binding.otherTotal.text = String.format(
|
|
|
+ resources.getString(R.string.total_per_fee_format),
|
|
|
+ otherExpensesTotalCost
|
|
|
+ )
|
|
|
+
|
|
|
+ binding.economyClass.text =
|
|
|
+ String.format(resources.getString(R.string.economy_class_price), outsideJJPay)
|
|
|
+ binding.businessClass.text =
|
|
|
+ String.format(resources.getString(R.string.business_class_price), outsideGWPay)
|
|
|
+ binding.firstClass.text =
|
|
|
+ String.format(resources.getString(R.string.first_class_price), outsideTDPay)
|
|
|
|
|
|
OASystem.entryAndExitDetailResponse.apply {
|
|
|
- economyTotalPayment = choiceOneTotalCost + outsideJJPay + choiceThreeTotalCost + choiceFourTotalCost + choiceFiveTotalCost
|
|
|
- bussinessTotalPayment = choiceOneTotalCost + outsideGWPay + choiceThreeTotalCost + choiceFourTotalCost + choiceFiveTotalCost
|
|
|
- firstClassTotalPayment = choiceOneTotalCost + outsideTDPay + choiceThreeTotalCost + choiceFourTotalCost + choiceFiveTotalCost
|
|
|
+ economyTotalPayment =
|
|
|
+ choiceOneTotalCost + outsideJJPay + choiceThreeTotalCost + choiceFourTotalCost + choiceFiveTotalCost
|
|
|
+ bussinessTotalPayment =
|
|
|
+ choiceOneTotalCost + outsideGWPay + choiceThreeTotalCost + choiceFourTotalCost + choiceFiveTotalCost
|
|
|
+ firstClassTotalPayment =
|
|
|
+ choiceOneTotalCost + outsideTDPay + choiceThreeTotalCost + choiceFourTotalCost + choiceFiveTotalCost
|
|
|
}
|
|
|
|
|
|
binding.economyClassTotal.text = if (choiceTwoJJ == 1) {
|
|
|
- String.format(resources.getString(R.string.economy_class_price), economyTotalPayment)
|
|
|
+ String.format(
|
|
|
+ resources.getString(R.string.economy_class_price),
|
|
|
+ economyTotalPayment
|
|
|
+ )
|
|
|
} else {
|
|
|
String.format(resources.getString(R.string.economy_class_price), 0.0)
|
|
|
}
|
|
|
binding.businessClassTotal.text = if (choiceTwoGW == 1) {
|
|
|
- String.format(resources.getString(R.string.business_class_price), bussinessTotalPayment)
|
|
|
+ String.format(
|
|
|
+ resources.getString(R.string.business_class_price),
|
|
|
+ bussinessTotalPayment
|
|
|
+ )
|
|
|
} else {
|
|
|
String.format(resources.getString(R.string.business_class_price), 0.0)
|
|
|
}
|
|
|
binding.firstClassTotal.text = if (choiceTwoTD == 1) {
|
|
|
- String.format(resources.getString(R.string.first_class_price), firstClassTotalPayment)
|
|
|
+ String.format(
|
|
|
+ resources.getString(R.string.first_class_price),
|
|
|
+ firstClassTotalPayment
|
|
|
+ )
|
|
|
} else {
|
|
|
String.format(resources.getString(R.string.first_class_price), 0.0)
|
|
|
}
|
|
@@ -235,11 +277,23 @@ class EntryAndExitFeeTotalFragment : BaseFragment<FragmentEntryAndExitFeeTotalBi
|
|
|
}
|
|
|
|
|
|
binding.exportToCollectionBill.setOnClickListener {
|
|
|
-
|
|
|
+ CustomAlertDialog.Builder(OASystem.context).apply {
|
|
|
+ setTitle(resources.getString(R.string.hint))
|
|
|
+ setMessage(resources.getString(R.string.export_to_collection_bil_confirm))
|
|
|
+ setNegativeButtonAndListener(resources.getString(R.string.cancel)) { dialog, _ ->
|
|
|
+ dialog.dismiss()
|
|
|
+ }
|
|
|
+ setPositiveButtonAndListener(resources.getString(R.string.confirm)) { dialog, _ ->
|
|
|
+
|
|
|
+ exportPaymentToCollectionBill()
|
|
|
+
|
|
|
+ dialog.dismiss()
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
binding.downloadGroupMembersList.setOnClickListener {
|
|
|
-
|
|
|
+ downloadCustomerList()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -247,4 +301,62 @@ class EntryAndExitFeeTotalFragment : BaseFragment<FragmentEntryAndExitFeeTotalBi
|
|
|
fun updateView(response: EntryAndExitDetailResponse) {
|
|
|
initViews()
|
|
|
}
|
|
|
+
|
|
|
+ private fun exportPaymentToCollectionBill() {
|
|
|
+ apiService.exportPaymentToCollectionBill(groupId = OASystem.entryAndExitDetailResponse.diId)
|
|
|
+ .enqueue(object :
|
|
|
+ Callback<BaseResponse> {
|
|
|
+ override fun onResponse(call: Call<BaseResponse>, response: Response<BaseResponse>) {
|
|
|
+ val addResponse = response.body()
|
|
|
+
|
|
|
+ if (addResponse != null) {
|
|
|
+ if (addResponse.code == 200) {
|
|
|
+ showMessage(resources.getString(R.string.operate_success))
|
|
|
+ } else {
|
|
|
+ showMessage(addResponse.msg)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onFailure(p0: Call<BaseResponse>, p1: Throwable) {
|
|
|
+ showErrorInfo(R.string.interface_request_error)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun downloadCustomerList() {
|
|
|
+ apiService.downloadCustomerList(DownloadCustomerListRequest(diId = OASystem.entryAndExitDetailResponse.diId)).enqueue(object : Callback<DownloadCustomerListResponse> {
|
|
|
+ override fun onResponse(
|
|
|
+ call: Call<DownloadCustomerListResponse>,
|
|
|
+ response: Response<DownloadCustomerListResponse>
|
|
|
+ ) {
|
|
|
+ val dataResponse = response.body()
|
|
|
+ if (dataResponse != null) {
|
|
|
+ if (dataResponse.code == 200) {
|
|
|
+
|
|
|
+ CustomAlertDialog.Builder(OASystem.context).apply {
|
|
|
+ setTitle(resources.getString(R.string.hint))
|
|
|
+ setMessage(resources.getString(R.string.group_members_list_generated))
|
|
|
+ setNegativeButtonAndListener(resources.getString(R.string.cancel)) { dialog, _ ->
|
|
|
+ dialog.dismiss()
|
|
|
+ }
|
|
|
+ setPositiveButtonAndListener(resources.getString(R.string.confirm)) { dialog, _ ->
|
|
|
+ val uri = Uri.parse(dataResponse.data)
|
|
|
+ startActivity(Intent(Intent.ACTION_VIEW, uri))
|
|
|
+
|
|
|
+ dialog.dismiss()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ showMessage(dataResponse.msg)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onFailure(p0: Call<DownloadCustomerListResponse>, p1: Throwable) {
|
|
|
+ showErrorInfo(R.string.interface_request_error)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|