|
@@ -1,21 +1,45 @@
|
|
|
package com.cooleshow.teacher.ui.course;
|
|
|
|
|
|
+import android.os.Bundle;
|
|
|
+import android.text.Editable;
|
|
|
+import android.text.SpannableString;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.text.TextWatcher;
|
|
|
import android.view.View;
|
|
|
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
|
|
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
|
import com.chad.library.adapter.base.listener.OnItemClickListener;
|
|
|
+import com.cooleshow.base.constanst.Constants;
|
|
|
import com.cooleshow.base.iml.ICommonFilterData;
|
|
|
import com.cooleshow.base.router.RouterPath;
|
|
|
import com.cooleshow.base.ui.activity.BaseMVPActivity;
|
|
|
+import com.cooleshow.base.utils.GsonUtils;
|
|
|
+import com.cooleshow.base.utils.NumberUtils;
|
|
|
+import com.cooleshow.base.utils.ToastUtil;
|
|
|
+import com.cooleshow.base.utils.UiUtils;
|
|
|
+import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
|
|
|
import com.cooleshow.base.widgets.EmptyViewLayout;
|
|
|
+import com.cooleshow.base.widgets.dialog.CourseTipDialog;
|
|
|
import com.cooleshow.teacher.R;
|
|
|
import com.cooleshow.teacher.adapter.HomePageVipCourseAdapter;
|
|
|
import com.cooleshow.teacher.adapter.VIPCourseSettingSelectAdapter;
|
|
|
+import com.cooleshow.teacher.bean.CourseSettingTimeAndPriceSectionBean;
|
|
|
+import com.cooleshow.teacher.bean.QuerySubjectBean;
|
|
|
+import com.cooleshow.teacher.bean.SysParamConfigBean;
|
|
|
+import com.cooleshow.teacher.bean.request.SubmitVIPCourseSettingEntry;
|
|
|
+import com.cooleshow.teacher.constants.CourseConstants;
|
|
|
+import com.cooleshow.teacher.contract.VIPCourseSettingContract;
|
|
|
import com.cooleshow.teacher.databinding.AcVipCourseSettingLayoutBinding;
|
|
|
import com.cooleshow.teacher.presenter.course.VIPCourseSettingPresenter;
|
|
|
+import com.google.gson.reflect.TypeToken;
|
|
|
+
|
|
|
+import java.lang.reflect.Type;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
+import androidx.annotation.Nullable;
|
|
|
import androidx.recyclerview.widget.GridLayoutManager;
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
@@ -24,15 +48,42 @@ import androidx.recyclerview.widget.RecyclerView;
|
|
|
* Author by pq, Date on 2024/11/15.
|
|
|
*/
|
|
|
@Route(path = RouterPath.CourseCenter.VIP_COURSE_SETTING)
|
|
|
-public class VIPCourseSettingActivity extends BaseMVPActivity<AcVipCourseSettingLayoutBinding, VIPCourseSettingPresenter> implements View.OnClickListener {
|
|
|
-
|
|
|
-
|
|
|
+public class VIPCourseSettingActivity extends BaseMVPActivity<AcVipCourseSettingLayoutBinding, VIPCourseSettingPresenter> implements View.OnClickListener, VIPCourseSettingContract.View {
|
|
|
+ private String days = "0";//课程结束后多少天到账
|
|
|
+ private double singleCoursePriceRate = 0;//单课时价格费率
|
|
|
private VIPCourseSettingSelectAdapter subjectAdapter;
|
|
|
private VIPCourseSettingSelectAdapter timeSelectAdapter;
|
|
|
+ private int minPrice = 100;
|
|
|
+ private int maxPrice = 1000;
|
|
|
+ private List<ICommonFilterData> subjectDatas = new ArrayList<>();
|
|
|
+ private ArrayList<ICommonFilterData> timesData = new ArrayList<>();
|
|
|
+ private TextWatcher mTextWatcher = new TextWatcher() {
|
|
|
+ @Override
|
|
|
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable s) {
|
|
|
+ refreshPriceUI();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ private CourseTipDialog mCourseTipDialog;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ QMUIStatusBarHelper.setStatusBarLightMode(this);
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
protected void initView() {
|
|
|
- initMidTitleToolBar(viewBinding.toolbarInclude.toolbar,"VIP定制课设置");
|
|
|
+ initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "VIP定制课设置");
|
|
|
viewBinding.toolbarInclude.tvRight.setVisibility(View.VISIBLE);
|
|
|
viewBinding.toolbarInclude.tvRight.setImageResource(R.drawable.icon_question_mark);
|
|
|
viewBinding.toolbarInclude.tvRight.setOnClickListener(this);
|
|
@@ -41,12 +92,12 @@ public class VIPCourseSettingActivity extends BaseMVPActivity<AcVipCourseSetting
|
|
|
@Override
|
|
|
public void initData() {
|
|
|
super.initData();
|
|
|
- GridLayoutManager gridLayoutManager =new GridLayoutManager(this,3);
|
|
|
+ GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);
|
|
|
subjectAdapter = new VIPCourseSettingSelectAdapter();
|
|
|
viewBinding.recyclerViewSubject.setLayoutManager(gridLayoutManager);
|
|
|
viewBinding.recyclerViewSubject.setAdapter(subjectAdapter);
|
|
|
|
|
|
- GridLayoutManager gridLayoutManager2 =new GridLayoutManager(this,3);
|
|
|
+ GridLayoutManager gridLayoutManager2 = new GridLayoutManager(this, 3);
|
|
|
timeSelectAdapter = new VIPCourseSettingSelectAdapter();
|
|
|
viewBinding.recyclerViewTime.setLayoutManager(gridLayoutManager2);
|
|
|
viewBinding.recyclerViewTime.setAdapter(timeSelectAdapter);
|
|
@@ -55,6 +106,8 @@ public class VIPCourseSettingActivity extends BaseMVPActivity<AcVipCourseSetting
|
|
|
}
|
|
|
|
|
|
private void initListener() {
|
|
|
+ viewBinding.tvConfirm.setOnClickListener(this);
|
|
|
+ viewBinding.editPrice.addTextChangedListener(mTextWatcher);
|
|
|
subjectAdapter.setOnItemClickListener(new OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
|
|
@@ -74,6 +127,7 @@ public class VIPCourseSettingActivity extends BaseMVPActivity<AcVipCourseSetting
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -84,7 +138,8 @@ public class VIPCourseSettingActivity extends BaseMVPActivity<AcVipCourseSetting
|
|
|
@Override
|
|
|
protected void onResume() {
|
|
|
super.onResume();
|
|
|
-
|
|
|
+ presenter.queryCourseConfig();
|
|
|
+ presenter.querySubjectItem();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -95,8 +150,163 @@ public class VIPCourseSettingActivity extends BaseMVPActivity<AcVipCourseSetting
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
int id = v.getId();
|
|
|
- if(id == R.id.tv_confirm){
|
|
|
+ if (id == R.id.tv_confirm) {
|
|
|
+ SubmitVIPCourseSettingEntry vipCourseSettingEntry = checkCondition();
|
|
|
+ if (vipCourseSettingEntry != null) {
|
|
|
+ presenter.submit(vipCourseSettingEntry);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (id == com.cooleshow.base.R.id.tv_right) {
|
|
|
+ showTipDialog();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private SubmitVIPCourseSettingEntry checkCondition() {
|
|
|
+ ArrayList<String> selectList = subjectAdapter.getSelectList();
|
|
|
+ if (selectList == null || selectList.size() == 0) {
|
|
|
+ ToastUtil.getInstance().showShort("请选择声部");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ ArrayList<String> timeSelectList = timeSelectAdapter.getSelectList();
|
|
|
+ if (timeSelectList == null || timeSelectList.size() == 0) {
|
|
|
+ ToastUtil.getInstance().showShort("请选择单课时时长");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ int coursePrice = 0;
|
|
|
+ Editable editable = viewBinding.editPrice.getText();
|
|
|
+ if (editable != null) {
|
|
|
+ String s = editable.toString();
|
|
|
+ if (TextUtils.isEmpty(s)) {
|
|
|
+ ToastUtil.getInstance().showShort("请输入课时单价");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ coursePrice = Integer.parseInt(s);
|
|
|
+ if (coursePrice < minPrice || coursePrice > maxPrice) {
|
|
|
+ ToastUtil.getInstance().showShort(String.format("课时单价应在%d到%d元之间", minPrice, maxPrice));
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ToastUtil.getInstance().showShort("请输入课时单价");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ SubmitVIPCourseSettingEntry vipCourseSettingEntry = new SubmitVIPCourseSettingEntry();
|
|
|
+ try {
|
|
|
+ vipCourseSettingEntry.courseMinutes = Integer.parseInt(timeSelectList.get(0));
|
|
|
+ vipCourseSettingEntry.subjectId = selectList.get(0);
|
|
|
+ vipCourseSettingEntry.courseType = Constants.VIP_COURSE_TAG;
|
|
|
+ vipCourseSettingEntry.subjectPrice = coursePrice;
|
|
|
+ return vipCourseSettingEntry;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void queryConfigSuccess(ArrayList<SysParamConfigBean> data) {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
return;
|
|
|
}
|
|
|
+ if (data != null && data.size() > 0) {
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
+ SysParamConfigBean sysParamConfigBean = data.get(i);
|
|
|
+ if (TextUtils.equals(sysParamConfigBean.getParamName(), CourseConstants.VIP_COURSE_ACCOUNT_PERIOD)) {
|
|
|
+ days = sysParamConfigBean.getParamValue();
|
|
|
+ }
|
|
|
+ if (TextUtils.equals(sysParamConfigBean.getParamName(), CourseConstants.VIP_COURSE_SERVICE_FEE)) {
|
|
|
+ singleCoursePriceRate = CourseConstants.countVIPCourseRate(sysParamConfigBean.getParamValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (TextUtils.equals(sysParamConfigBean.getParamName(), CourseConstants.VIP_COURSE_TIMES_SETTING)) {
|
|
|
+ createTimeAndPriceSectionData(sysParamConfigBean.getParamValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ refreshUI();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void querySubjectItemSuccess(List<QuerySubjectBean> data) {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (subjectAdapter != null) {
|
|
|
+ subjectDatas.clear();
|
|
|
+ subjectDatas.addAll(data);
|
|
|
+ subjectAdapter.setNewInstance(subjectDatas);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void submitSuccess(Object data) {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ToastUtil.getInstance().showShort("设置成功");
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void refreshUI() {
|
|
|
+ //汇款天数
|
|
|
+ SpannableString string = UiUtils.diffColorStringAndBold(getString(R.string.vip_setting_str3), " " + days + " ", getString(R.string.vip_setting_str4), getResources().getColor(com.cooleshow.base.R.color.color_999999), getResources().getColor(com.cooleshow.base.R.color.color_ff4e19));
|
|
|
+ viewBinding.tvTip2.setText(string);
|
|
|
+ timeSelectAdapter.setNewInstance(timesData);
|
|
|
+ viewBinding.editPrice.setHint(minPrice + "~" + maxPrice);
|
|
|
+ refreshPriceUI();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void refreshPriceUI() {
|
|
|
+ double twoDecimalValue = 0.00;
|
|
|
+ try {
|
|
|
+ String prePrice = viewBinding.editPrice.getText().toString().trim();
|
|
|
+ int i = Integer.parseInt(prePrice);
|
|
|
+ twoDecimalValue = NumberUtils.getTwoDecimalValue(i * singleCoursePriceRate);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ SpannableString string = UiUtils.diffColorStringAndBold(getString(R.string.vip_setting_str1), " " + twoDecimalValue + " ", getString(R.string.vip_setting_str2), getResources().getColor(com.cooleshow.base.R.color.color_999999), getResources().getColor(com.cooleshow.base.R.color.color_ff4e19));
|
|
|
+ viewBinding.tvTip1.setText(string);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void createTimeAndPriceSectionData(String paramValue) {
|
|
|
+ try {
|
|
|
+ Type itemType = new TypeToken<List<CourseSettingTimeAndPriceSectionBean>>() {
|
|
|
+ }.getType();
|
|
|
+ List<CourseSettingTimeAndPriceSectionBean> result = GsonUtils.fromJson(paramValue, itemType);
|
|
|
+ if (result != null) {
|
|
|
+ timesData.clear();
|
|
|
+ timesData.addAll(result);
|
|
|
+ CourseSettingTimeAndPriceSectionBean courseSettingTimeAndPriceSectionBean = result.get(0);
|
|
|
+ minPrice = Integer.parseInt(courseSettingTimeAndPriceSectionBean.getLowestPrice());
|
|
|
+ maxPrice = Integer.parseInt(courseSettingTimeAndPriceSectionBean.getHighestPrice());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showTipDialog() {
|
|
|
+ if (mCourseTipDialog == null) {
|
|
|
+ mCourseTipDialog = new CourseTipDialog(this);
|
|
|
+ }
|
|
|
+ if (!mCourseTipDialog.isShowing()) {
|
|
|
+ mCourseTipDialog.show();
|
|
|
+ }
|
|
|
+ //仅显示VIP定制课
|
|
|
+ mCourseTipDialog.onlyShowPos(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroy() {
|
|
|
+ if (viewBinding != null) {
|
|
|
+ viewBinding.editPrice.removeTextChangedListener(mTextWatcher);
|
|
|
+ }
|
|
|
+ super.onDestroy();
|
|
|
}
|
|
|
}
|