更新
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
package com.ckkj.griddle.refund;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.ckkj.griddle.R;
|
||||
|
||||
/** 撤销售后确认弹窗,保持设计稿圆角、按钮及遮罩,不创建额外 Activity。 */
|
||||
final class RefundCancelDialog implements View.OnClickListener {
|
||||
private final Activity activity;
|
||||
private final Dialog dialog;
|
||||
private final Runnable onConfirm;
|
||||
|
||||
RefundCancelDialog(Activity activity, Runnable onConfirm) {
|
||||
this.activity = activity;
|
||||
this.onConfirm = onConfirm;
|
||||
dialog = new Dialog(activity);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(R.layout.dialog_refund_cancel);
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
dialog.findViewById(R.id.tv_refund_dialog_cancel).setOnClickListener(this);
|
||||
dialog.findViewById(R.id.tv_refund_dialog_confirm).setOnClickListener(this);
|
||||
}
|
||||
|
||||
void show() {
|
||||
dialog.show();
|
||||
Window window = dialog.getWindow();
|
||||
if (window == null) return;
|
||||
float density = activity.getResources().getDisplayMetrics().density;
|
||||
int available = Math.round(activity.getResources().getConfiguration().screenWidthDp * density);
|
||||
int width = Math.max(1, Math.min(Math.round(321 * density), available - Math.round(48 * density)));
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
||||
window.setDimAmount(0.6f);
|
||||
window.setGravity(Gravity.CENTER);
|
||||
window.setLayout(width, WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
|
||||
boolean isShowing() {
|
||||
return dialog.isShowing();
|
||||
}
|
||||
|
||||
void dismiss() {
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// 确认与取消均先关闭弹窗,只有确认才转交当前申请编号进行撤销。
|
||||
dismiss();
|
||||
if (v.getId() == R.id.tv_refund_dialog_confirm && onConfirm != null) onConfirm.run();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package com.ckkj.griddle.refund;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.ckkj.griddle.R;
|
||||
import com.ckkj.griddle.base.BaseActivity;
|
||||
import com.ckkj.griddle.databinding.ItemMyOrderGoodsBinding;
|
||||
import com.ckkj.griddle.databinding.RefundDetailLayoutBinding;
|
||||
import com.ckkj.griddle.mine.order.entity.MyOrderEntity;
|
||||
import com.ckkj.griddle.network.BaseBean;
|
||||
import com.ckkj.griddle.refund.entity.RefundDetailEntity;
|
||||
import com.ckkj.griddle.refund.entity.RefundEntity;
|
||||
import com.ckkj.griddle.refund.mvp.RefundContract;
|
||||
import com.ckkj.griddle.refund.mvp.RefundImpl;
|
||||
import com.ckkj.griddle.refund.mvp.RefundPresenter;
|
||||
import com.ckkj.griddle.utils.show.ToastUtil;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.OnClick;
|
||||
|
||||
/** 售后详情:审核中、已通过和已拒绝共用布局,依据真实申请状态展示。 */
|
||||
public class RefundDetailActivity extends BaseActivity<RefundDetailLayoutBinding, RefundPresenter>
|
||||
implements RefundContract.RefundDetailView {
|
||||
public static final String EXTRA_REFUND_ID = "refund_detail_id";
|
||||
public static final String EXTRA_CANCELLED_IDS = "refund_detail_cancelled_ids";
|
||||
public static final String RESULT_CANCELLED_ID = "refund_detail_cancelled_id";
|
||||
private static final String STATE_CANCELLED_HERE = "refund_detail_cancelled_here";
|
||||
|
||||
private final ArrayList<String> cancelledIds = new ArrayList<>();
|
||||
private String refundId;
|
||||
private boolean cancelledHere;
|
||||
private RefundDetailEntity detail;
|
||||
private RefundCancelDialog cancelDialog;
|
||||
|
||||
@Override
|
||||
public RefundPresenter createPresenter() {
|
||||
return new RefundPresenter(new RefundImpl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutResId(Bundle savedInstanceState) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData(Bundle savedInstanceState) {
|
||||
super.initData(savedInstanceState);
|
||||
ImmersionBar.with(this).statusBarColor(R.color.white).statusBarDarkFont(true).init();
|
||||
refundId = getIntent().getStringExtra(EXTRA_REFUND_ID);
|
||||
Bundle state = savedInstanceState == null ? getIntent().getExtras() : savedInstanceState;
|
||||
if (state != null) {
|
||||
ArrayList<String> savedIds = state.getStringArrayList(EXTRA_CANCELLED_IDS);
|
||||
if (savedIds != null) cancelledIds.addAll(savedIds);
|
||||
cancelledHere = state.getBoolean(STATE_CANCELLED_HERE, false);
|
||||
}
|
||||
mPresenter.restoreCancelledIds(cancelledIds);
|
||||
// 旋转、折叠等重建后,仍需把本页取消结果带回列表。
|
||||
if (cancelledHere) publishCancelledResult();
|
||||
mPresenter.getRefundDetail(refundId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showRefundDetail(RefundDetailEntity data) {
|
||||
if (data == null || data.refund == null || data.refund.goods == null) {
|
||||
showError(null);
|
||||
return;
|
||||
}
|
||||
detail = data;
|
||||
RefundEntity refund = data.refund;
|
||||
viewBinding.tvRefundDetailNumber.setText(refund.id);
|
||||
viewBinding.tvRefundDetailStatus.setText(refund.status.labelRes);
|
||||
viewBinding.tvRefundDetailStatus.setTextColor(Color.parseColor(
|
||||
refund.status == RefundEntity.Status.REJECTED ? "#E5484D" : "#222222"));
|
||||
viewBinding.tvRefundDetailAppliedTime.setText(data.appliedTime);
|
||||
viewBinding.llRefundDetailReview.setVisibility(data.isReviewed() ? View.VISIBLE : View.GONE);
|
||||
viewBinding.tvRefundDetailReviewedTime.setText(data.reviewedTime);
|
||||
viewBinding.tvRefundDetailReviewRemark.setText(data.reviewRemark);
|
||||
bindGoods(refund.goods);
|
||||
viewBinding.tvRefundDetailType.setText(refund.typeRes);
|
||||
viewBinding.tvRefundDetailReason.setText(data.reason);
|
||||
viewBinding.tvRefundDetailDescription.setText(data.description);
|
||||
bindEvidence(data);
|
||||
viewBinding.tvRefundDetailError.setVisibility(View.GONE);
|
||||
viewBinding.scrollRefundDetail.setVisibility(View.VISIBLE);
|
||||
viewBinding.llRefundDetailActions.setVisibility(refund.canCancel() ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
private void bindGoods(MyOrderEntity.Goods goods) {
|
||||
ItemMyOrderGoodsBinding binding = viewBinding.includeRefundDetailGoods;
|
||||
binding.tvMyOrderGoodsName.setText(goods.nameRes);
|
||||
binding.tvMyOrderGoodsSpec.setText(getString(R.string.my_order_specification,
|
||||
goods.specification, goods.quantity));
|
||||
binding.tvMyOrderGoodsPrice.setText(getString(R.string.my_order_price,
|
||||
BigDecimal.valueOf(goods.priceCents, 2).toPlainString()));
|
||||
Glide.with(this).load(goods.coverRes)
|
||||
.transform(new CenterCrop(), new RoundedCorners(dp(10)))
|
||||
.into(binding.ivMyOrderGoodsCover);
|
||||
}
|
||||
|
||||
private void bindEvidence(RefundDetailEntity data) {
|
||||
viewBinding.flowRefundDetailEvidence.removeAllViews();
|
||||
int count = 0;
|
||||
// 凭证为只读展示,数量由详情数据决定,不添加上传或删除入口。
|
||||
for (String uri : data.evidenceUris) {
|
||||
if (TextUtils.isEmpty(uri)) continue;
|
||||
ImageView image = new ImageView(this);
|
||||
image.setLayoutParams(new ViewGroup.LayoutParams(dp(60), dp(60)));
|
||||
image.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
image.setContentDescription(getString(R.string.refund_detail_evidence_description, ++count));
|
||||
viewBinding.flowRefundDetailEvidence.addView(image);
|
||||
Glide.with(this).load(uri).placeholder(R.drawable.review_image_bg)
|
||||
.error(R.drawable.review_image_bg)
|
||||
.transform(new CenterCrop(), new RoundedCorners(dp(6))).into(image);
|
||||
}
|
||||
viewBinding.flowRefundDetailEvidence.setVisibility(count > 0 ? View.VISIBLE : View.GONE);
|
||||
viewBinding.tvRefundDetailNoEvidence.setVisibility(count == 0 ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@OnClick({R.id.iv_refund_detail_back, R.id.tv_refund_detail_cancel})
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.iv_refund_detail_back:
|
||||
finish();
|
||||
break;
|
||||
case R.id.tv_refund_detail_cancel:
|
||||
showCancelDialog();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void showCancelDialog() {
|
||||
if (detail == null || !detail.refund.canCancel()
|
||||
|| (cancelDialog != null && cancelDialog.isShowing())) return;
|
||||
cancelDialog = new RefundCancelDialog(this, () -> mPresenter.cancelRefund(refundId));
|
||||
cancelDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefundCancelled(RefundEntity refund) {
|
||||
if (refund == null || !TextUtils.equals(refundId, refund.id)) return;
|
||||
if (!cancelledIds.contains(refund.id)) cancelledIds.add(refund.id);
|
||||
cancelledHere = true;
|
||||
publishCancelledResult();
|
||||
mPresenter.getRefundDetail(refundId);
|
||||
ToastUtil.showShort(mContext, getString(R.string.refund_cancel_preview));
|
||||
}
|
||||
|
||||
private void publishCancelledResult() {
|
||||
Intent result = new Intent();
|
||||
result.putExtra(RESULT_CANCELLED_ID, refundId);
|
||||
setResult(RESULT_OK, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(String message) {
|
||||
String error = TextUtils.isEmpty(message) ? getString(R.string.refund_detail_load_failed) : message;
|
||||
if (detail == null) {
|
||||
viewBinding.tvRefundDetailError.setText(error);
|
||||
viewBinding.tvRefundDetailError.setVisibility(View.VISIBLE);
|
||||
viewBinding.scrollRefundDetail.setVisibility(View.GONE);
|
||||
viewBinding.llRefundDetailActions.setVisibility(View.GONE);
|
||||
}
|
||||
ToastUtil.showShort(mContext, error);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logOut(BaseBean bean) {
|
||||
// 登录失效沿用父类统一处理。
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
outState.putStringArrayList(EXTRA_CANCELLED_IDS, new ArrayList<>(cancelledIds));
|
||||
outState.putBoolean(STATE_CANCELLED_HERE, cancelledHere);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (cancelDialog != null) cancelDialog.dismiss();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private int dp(int value) {
|
||||
return Math.round(value * getResources().getDisplayMetrics().density);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.ckkj.griddle.refund.adapter;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.ckkj.griddle.R;
|
||||
import com.ckkj.griddle.refund.entity.RefundEntity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/** 退款条目完整绑定状态及取消按钮,防止列表复用后按钮串显。 */
|
||||
public class RefundAdapter extends BaseQuickAdapter<RefundEntity, BaseViewHolder> {
|
||||
public RefundAdapter() {
|
||||
super(R.layout.item_refund);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, RefundEntity refund) {
|
||||
helper.setText(R.id.tv_refund_number, mContext.getString(R.string.refund_number, refund.id))
|
||||
.setText(R.id.tv_refund_status, mContext.getString(refund.status.labelRes))
|
||||
.setText(R.id.tv_refund_type, mContext.getString(R.string.refund_type,
|
||||
mContext.getString(refund.typeRes)))
|
||||
.setText(R.id.tv_my_order_goods_name, mContext.getString(refund.goods.nameRes))
|
||||
.setText(R.id.tv_my_order_goods_spec, mContext.getString(R.string.my_order_specification,
|
||||
refund.goods.specification, refund.goods.quantity))
|
||||
.setText(R.id.tv_my_order_goods_price, mContext.getString(R.string.my_order_price,
|
||||
BigDecimal.valueOf(refund.goods.priceCents, 2).toPlainString()))
|
||||
.addOnClickListener(R.id.tv_refund_cancel_request);
|
||||
helper.setTextColor(R.id.tv_refund_status, refund.status == RefundEntity.Status.REJECTED
|
||||
? Color.parseColor("#E5484D") : Color.parseColor("#222222"));
|
||||
helper.getView(R.id.tv_refund_cancel_request).setVisibility(
|
||||
refund.canCancel() ? View.VISIBLE : View.GONE);
|
||||
// 两侧文案在窄屏和长英文下均允许换行,不挤掉售后类型。
|
||||
float density = mContext.getResources().getDisplayMetrics().density;
|
||||
int width = Math.min(720, mContext.getResources().getConfiguration().screenWidthDp);
|
||||
((TextView) helper.getView(R.id.tv_refund_status)).setMaxWidth(Math.round((width - 44) * density / 2));
|
||||
((TextView) helper.getView(R.id.tv_refund_cancel_request)).setMaxWidth(Math.round((width - 42) * density / 2));
|
||||
helper.setTextColor(R.id.tv_my_order_goods_price, Color.parseColor("#E5484D"));
|
||||
ImageView image = helper.getView(R.id.iv_my_order_goods_cover);
|
||||
Glide.with(image).load(refund.goods.coverRes)
|
||||
.transform(new CenterCrop(), new RoundedCorners(Math.round(10 * density))).into(image);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.ckkj.griddle.refund.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/** 售后申请详情快照,审核信息和凭证独立于列表摘要。 */
|
||||
public class RefundDetailEntity {
|
||||
public final RefundEntity refund;
|
||||
public final String appliedTime;
|
||||
public final String reviewedTime;
|
||||
public final String reviewRemark;
|
||||
public final String reason;
|
||||
public final String description;
|
||||
public final List<String> evidenceUris;
|
||||
|
||||
public RefundDetailEntity(RefundEntity refund, String appliedTime, String reviewedTime,
|
||||
String reviewRemark, String reason, String description,
|
||||
List<String> evidenceUris) {
|
||||
this.refund = refund;
|
||||
this.appliedTime = appliedTime;
|
||||
this.reviewedTime = reviewedTime;
|
||||
this.reviewRemark = reviewRemark;
|
||||
this.reason = reason;
|
||||
this.description = description;
|
||||
this.evidenceUris = evidenceUris == null ? Collections.emptyList()
|
||||
: Collections.unmodifiableList(new ArrayList<>(evidenceUris));
|
||||
}
|
||||
|
||||
public boolean isReviewed() {
|
||||
return refund.status == RefundEntity.Status.APPROVED
|
||||
|| refund.status == RefundEntity.Status.REJECTED;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.ckkj.griddle.refund.entity;
|
||||
|
||||
import com.ckkj.griddle.R;
|
||||
import com.ckkj.griddle.mine.order.entity.MyOrderEntity;
|
||||
|
||||
/** 退款记录,业务状态独立于筛选条件,已取消记录保留在全部列表中。 */
|
||||
public class RefundEntity {
|
||||
public enum Status {
|
||||
ALL(R.string.refund_all), PENDING(R.string.refund_pending),
|
||||
APPROVED(R.string.refund_approved), REJECTED(R.string.refund_rejected),
|
||||
CANCELLED(R.string.refund_cancelled);
|
||||
|
||||
public final int labelRes;
|
||||
|
||||
Status(int labelRes) {
|
||||
this.labelRes = labelRes;
|
||||
}
|
||||
}
|
||||
|
||||
public final String id;
|
||||
public final Status status;
|
||||
public final int typeRes;
|
||||
public final MyOrderEntity.Goods goods;
|
||||
|
||||
public RefundEntity(String id, Status status, int typeRes, MyOrderEntity.Goods goods) {
|
||||
this.id = id;
|
||||
this.status = status;
|
||||
this.typeRes = typeRes;
|
||||
this.goods = goods;
|
||||
}
|
||||
|
||||
public boolean canCancel() {
|
||||
return status == Status.PENDING;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.ckkj.griddle.refund.mvp;
|
||||
|
||||
import com.ckkj.griddle.base.IView;
|
||||
import com.ckkj.griddle.refund.entity.RefundEntity;
|
||||
import com.ckkj.griddle.refund.entity.RefundDetailEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** 退款列表、状态筛选及撤销申请的基础协议。 */
|
||||
public class RefundContract {
|
||||
public interface CallBack<T> {
|
||||
void success(T data);
|
||||
void fail(String message);
|
||||
}
|
||||
|
||||
public interface DataModel {
|
||||
void getRefunds(RefundEntity.Status filter, CallBack<List<RefundEntity>> callback);
|
||||
void getRefundDetail(String refundId, CallBack<RefundDetailEntity> callback);
|
||||
void cancelRefund(String refundId, CallBack<RefundEntity> callback);
|
||||
void restoreCancelledIds(List<String> ids);
|
||||
}
|
||||
|
||||
public interface RefundView extends IView {
|
||||
void showRefunds(List<RefundEntity> refunds);
|
||||
void onRefundCancelled(RefundEntity refund);
|
||||
}
|
||||
|
||||
/** 详情和列表复用退款协调层,详情不承担列表渲染。 */
|
||||
public interface RefundDetailView extends RefundView {
|
||||
void showRefundDetail(RefundDetailEntity detail);
|
||||
|
||||
@Override
|
||||
default void showRefunds(List<RefundEntity> refunds) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.ckkj.griddle.refund.mvp;
|
||||
|
||||
import com.ckkj.griddle.MyApplication;
|
||||
import com.ckkj.griddle.R;
|
||||
import com.ckkj.griddle.mine.order.entity.MyOrderEntity;
|
||||
import com.ckkj.griddle.refund.entity.RefundEntity;
|
||||
import com.ckkj.griddle.refund.entity.RefundDetailEntity;
|
||||
import com.ckkj.griddle.refund.entity.RefundEntity.Status;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/** 当前提供本地预览数据,查询与取消接口均集中在此,页面不直接改动数据源。 */
|
||||
public class RefundImpl implements RefundContract.DataModel {
|
||||
private final Set<String> cancelledIds = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public void getRefunds(Status filter, RefundContract.CallBack<List<RefundEntity>> callback) {
|
||||
List<RefundEntity> result = new ArrayList<>();
|
||||
for (RefundEntity refund : createPreview()) {
|
||||
if (filter == Status.ALL || filter == refund.status) result.add(refund);
|
||||
}
|
||||
callback.success(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRefundDetail(String refundId, RefundContract.CallBack<RefundDetailEntity> callback) {
|
||||
for (RefundEntity refund : createPreview()) {
|
||||
if (!refund.id.equals(refundId)) continue;
|
||||
boolean reviewed = refund.status == Status.APPROVED || refund.status == Status.REJECTED;
|
||||
String remark = reviewed ? MyApplication.getContext().getString(
|
||||
refund.status == Status.APPROVED ? R.string.refund_detail_preview_approved
|
||||
: R.string.refund_detail_preview_rejected) : "";
|
||||
// 暂用项目现有商品图展示凭证位置,接入接口后替换为该申请的真实附件地址。
|
||||
String evidence = "android.resource://" + MyApplication.getContext().getPackageName()
|
||||
+ "/" + R.mipmap.icon_cart_goods_preview;
|
||||
callback.success(new RefundDetailEntity(refund, "2026-11-10 10:20",
|
||||
reviewed ? "2026-11-10 11:20" : "", remark,
|
||||
MyApplication.getContext().getString(R.string.refund_detail_preview_reason),
|
||||
MyApplication.getContext().getString(R.string.refund_detail_preview_description),
|
||||
Arrays.asList(evidence, evidence, evidence, evidence)));
|
||||
return;
|
||||
}
|
||||
callback.fail(MyApplication.getContext().getString(R.string.refund_detail_load_failed));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelRefund(String refundId, RefundContract.CallBack<RefundEntity> callback) {
|
||||
for (RefundEntity refund : createPreview()) {
|
||||
if (!refund.id.equals(refundId)) continue;
|
||||
if (!refund.canCancel()) break;
|
||||
// 仅更新本地预览;接入服务端后应在撤销接口成功回调中返回新状态。
|
||||
cancelledIds.add(refundId);
|
||||
callback.success(new RefundEntity(refund.id, Status.CANCELLED, refund.typeRes, refund.goods));
|
||||
return;
|
||||
}
|
||||
callback.fail(MyApplication.getContext().getString(R.string.refund_cancel_unavailable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreCancelledIds(List<String> ids) {
|
||||
cancelledIds.clear();
|
||||
if (ids != null) cancelledIds.addAll(ids);
|
||||
}
|
||||
|
||||
private List<RefundEntity> createPreview() {
|
||||
MyOrderEntity.Goods goods = new MyOrderEntity.Goods(R.string.my_order_goods_preview,
|
||||
R.mipmap.icon_cart_goods_preview, "0.5kg", 1, 20800);
|
||||
return Arrays.asList(
|
||||
new RefundEntity("SL20261020001", cancelledIds.contains("SL20261020001")
|
||||
? Status.CANCELLED : Status.PENDING, R.string.after_sales_refund_only, goods),
|
||||
new RefundEntity("SL20261020002", Status.REJECTED, R.string.after_sales_refund_only, goods),
|
||||
new RefundEntity("SL20261020003", Status.APPROVED, R.string.after_sales_refund_only, goods));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.ckkj.griddle.refund.mvp;
|
||||
|
||||
import com.ckkj.griddle.base.BasePresenter;
|
||||
import com.ckkj.griddle.refund.entity.RefundEntity;
|
||||
import com.ckkj.griddle.refund.entity.RefundDetailEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** 退款协调层:转交筛选、取消申请及结果回调。 */
|
||||
public class RefundPresenter extends BasePresenter<RefundContract.RefundView> {
|
||||
private final RefundContract.DataModel impl;
|
||||
|
||||
public RefundPresenter(RefundContract.DataModel impl) {
|
||||
this.impl = impl;
|
||||
}
|
||||
|
||||
public void getRefunds(RefundEntity.Status filter) {
|
||||
impl.getRefunds(filter, new RefundContract.CallBack<List<RefundEntity>>() {
|
||||
@Override
|
||||
public void success(List<RefundEntity> refunds) {
|
||||
if (getView() != null) getView().showRefunds(refunds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail(String message) {
|
||||
if (getView() != null) getView().showError(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void cancelRefund(String refundId) {
|
||||
impl.cancelRefund(refundId, new RefundContract.CallBack<RefundEntity>() {
|
||||
@Override
|
||||
public void success(RefundEntity refund) {
|
||||
if (getView() != null) getView().onRefundCancelled(refund);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail(String message) {
|
||||
if (getView() != null) getView().showError(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getRefundDetail(String refundId) {
|
||||
impl.getRefundDetail(refundId, new RefundContract.CallBack<RefundDetailEntity>() {
|
||||
@Override
|
||||
public void success(RefundDetailEntity detail) {
|
||||
if (getView() instanceof RefundContract.RefundDetailView) {
|
||||
((RefundContract.RefundDetailView) getView()).showRefundDetail(detail);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail(String message) {
|
||||
if (getView() != null) getView().showError(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void restoreCancelledIds(List<String> ids) {
|
||||
impl.restoreCancelledIds(ids);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user