|
@@ -7,7 +7,6 @@ import androidx.lifecycle.LiveData;
|
|
|
import androidx.lifecycle.MutableLiveData;
|
|
import androidx.lifecycle.MutableLiveData;
|
|
|
|
|
|
|
|
import com.atmob.app.lib.base.BaseViewModel;
|
|
import com.atmob.app.lib.base.BaseViewModel;
|
|
|
-import com.atmob.app.lib.handler.RxHttpHandler;
|
|
|
|
|
import com.atmob.app.lib.livedata.SingleLiveEvent;
|
|
import com.atmob.app.lib.livedata.SingleLiveEvent;
|
|
|
import com.atmob.common.runtime.ActivityUtil;
|
|
import com.atmob.common.runtime.ActivityUtil;
|
|
|
import com.atmob.common.runtime.ContextUtil;
|
|
import com.atmob.common.runtime.ContextUtil;
|
|
@@ -17,13 +16,16 @@ import com.datarecovery.master.data.api.bean.PayOptionsBean;
|
|
|
import com.datarecovery.master.data.api.bean.WechatPaymentSignBean;
|
|
import com.datarecovery.master.data.api.bean.WechatPaymentSignBean;
|
|
|
import com.datarecovery.master.data.api.response.MemberDetailResponse;
|
|
import com.datarecovery.master.data.api.response.MemberDetailResponse;
|
|
|
import com.datarecovery.master.data.api.response.MemberPayResponse;
|
|
import com.datarecovery.master.data.api.response.MemberPayResponse;
|
|
|
|
|
+import com.datarecovery.master.data.consts.Constants;
|
|
|
import com.datarecovery.master.data.repositories.AccountRepository;
|
|
import com.datarecovery.master.data.repositories.AccountRepository;
|
|
|
import com.datarecovery.master.data.repositories.MemberRepository;
|
|
import com.datarecovery.master.data.repositories.MemberRepository;
|
|
|
|
|
+import com.datarecovery.master.handler.EventHelper;
|
|
|
import com.datarecovery.master.module.login.LoginActivity;
|
|
import com.datarecovery.master.module.login.LoginActivity;
|
|
|
import com.datarecovery.master.module.member.bean.EvaluateBean;
|
|
import com.datarecovery.master.module.member.bean.EvaluateBean;
|
|
|
import com.datarecovery.master.module.member.bean.SuperScenesBean;
|
|
import com.datarecovery.master.module.member.bean.SuperScenesBean;
|
|
|
-import com.datarecovery.master.module.wxrecover.WeChatRecoverActivity;
|
|
|
|
|
import com.datarecovery.master.utils.BoxingUtil;
|
|
import com.datarecovery.master.utils.BoxingUtil;
|
|
|
|
|
+import com.datarecovery.master.utils.OrderReportHelper;
|
|
|
|
|
+import com.datarecovery.master.utils.RxHttpHandler;
|
|
|
import com.datarecovery.master.utils.ToastUtil;
|
|
import com.datarecovery.master.utils.ToastUtil;
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
|
|
|
|
@@ -70,6 +72,8 @@ public class MemberViewModel extends BaseViewModel {
|
|
|
|
|
|
|
|
private final SingleLiveEvent<Pair<String, String>> showWxQRPaymentEvent = new SingleLiveEvent<>();
|
|
private final SingleLiveEvent<Pair<String, String>> showWxQRPaymentEvent = new SingleLiveEvent<>();
|
|
|
private final SingleLiveEvent<Pair<String, String>> showAliQRPaymentEvent = new SingleLiveEvent<>();
|
|
private final SingleLiveEvent<Pair<String, String>> showAliQRPaymentEvent = new SingleLiveEvent<>();
|
|
|
|
|
+
|
|
|
|
|
+ private final HashMap<String, MemberGoodsBean> orderIdItemMap = new HashMap<>();
|
|
|
@MemberType
|
|
@MemberType
|
|
|
private String memberType;
|
|
private String memberType;
|
|
|
|
|
|
|
@@ -291,6 +295,7 @@ public class MemberViewModel extends BaseViewModel {
|
|
|
@Override
|
|
@Override
|
|
|
public void onSuccess(@NonNull MemberPayResponse memberPayResponse) {
|
|
public void onSuccess(@NonNull MemberPayResponse memberPayResponse) {
|
|
|
showLoadingEvent.setValue(false);
|
|
showLoadingEvent.setValue(false);
|
|
|
|
|
+ orderIdItemMap.put(memberPayResponse.getOutTradeNo(), bean);
|
|
|
if (payPlatform == 1 && payMethod == 2) {
|
|
if (payPlatform == 1 && payMethod == 2) {
|
|
|
onWeChatPay(memberPayResponse.getWechatPayPrepayJson(), memberPayResponse.getOutTradeNo());
|
|
onWeChatPay(memberPayResponse.getWechatPayPrepayJson(), memberPayResponse.getOutTradeNo());
|
|
|
} else if (payPlatform == 4 && payMethod == 2) {
|
|
} else if (payPlatform == 4 && payMethod == 2) {
|
|
@@ -308,7 +313,12 @@ public class MemberViewModel extends BaseViewModel {
|
|
|
showLoadingEvent.setValue(false);
|
|
showLoadingEvent.setValue(false);
|
|
|
if (throwable instanceof RxHttpHandler.ServerErrorException) {
|
|
if (throwable instanceof RxHttpHandler.ServerErrorException) {
|
|
|
RxHttpHandler.ServerErrorException serverErrorException = (RxHttpHandler.ServerErrorException) throwable;
|
|
RxHttpHandler.ServerErrorException serverErrorException = (RxHttpHandler.ServerErrorException) throwable;
|
|
|
- ToastUtil.show(serverErrorException.getMsg(), ToastUtil.LENGTH_SHORT);
|
|
|
|
|
|
|
+ if (serverErrorException.getCode() == Constants.ERROR_CODE_NO_LOGIN_ERROR) {
|
|
|
|
|
+ ToastUtil.show(R.string.no_login, ToastUtil.LENGTH_SHORT);
|
|
|
|
|
+ LoginActivity.start(ActivityUtil.getTopActivity(), getReportId());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ToastUtil.show(serverErrorException.getMsg(), ToastUtil.LENGTH_SHORT);
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
ToastUtil.show(R.string.member_payment_failed, ToastUtil.LENGTH_SHORT);
|
|
ToastUtil.show(R.string.member_payment_failed, ToastUtil.LENGTH_SHORT);
|
|
|
}
|
|
}
|
|
@@ -316,6 +326,25 @@ public class MemberViewModel extends BaseViewModel {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public String getReportId() {
|
|
|
|
|
+ if (Objects.equals(memberType, MemberType.APP_WX_MESSAGE_RECOVER)) {
|
|
|
|
|
+ return "hf11011";
|
|
|
|
|
+ } else if (Objects.equals(memberType, MemberType.APP_WX_FRIEND_RECOVER)) {
|
|
|
|
|
+ return "hf11009";
|
|
|
|
|
+ } else if (Objects.equals(memberType, MemberType.APP_IMAGE_RECOVER)) {
|
|
|
|
|
+ return "hf11001";
|
|
|
|
|
+ } else if (Objects.equals(memberType, MemberType.APP_FILE_RECOVER)) {
|
|
|
|
|
+ return "hf11003";
|
|
|
|
|
+ } else if (Objects.equals(memberType, MemberType.APP_VIDEO_RECOVER)) {
|
|
|
|
|
+ return "hf11005";
|
|
|
|
|
+ } else if (Objects.equals(memberType, MemberType.APP_AUDIO_RECOVER)) {
|
|
|
|
|
+ return "hf11007";
|
|
|
|
|
+ } else if (Objects.equals(memberType, MemberType.APP_IMAGE_CLEAN)) {
|
|
|
|
|
+ return "hf11013";
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void onAliPayScan(String s, String orderId) {
|
|
private void onAliPayScan(String s, String orderId) {
|
|
|
showAliQRPaymentEvent.setValue(new Pair<>(s, orderId));
|
|
showAliQRPaymentEvent.setValue(new Pair<>(s, orderId));
|
|
|
}
|
|
}
|
|
@@ -323,7 +352,7 @@ public class MemberViewModel extends BaseViewModel {
|
|
|
private void onAliPay(String s, String orderId) {
|
|
private void onAliPay(String s, String orderId) {
|
|
|
AlipayInfo alipayInfo = new AlipayInfo();
|
|
AlipayInfo alipayInfo = new AlipayInfo();
|
|
|
alipayInfo.setContent(s);
|
|
alipayInfo.setContent(s);
|
|
|
- requestSdkPay(alipayInfo, orderId);
|
|
|
|
|
|
|
+ requestSdkPay(alipayInfo, orderId, Constants.PAYMENT_WAY_ALIPAY);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void onWeChatScanPay(String s, String orderId) {
|
|
private void onWeChatScanPay(String s, String orderId) {
|
|
@@ -341,13 +370,13 @@ public class MemberViewModel extends BaseViewModel {
|
|
|
wXpayInfo.setNoncestr(wechatPaymentSignBean.getRandomStr());
|
|
wXpayInfo.setNoncestr(wechatPaymentSignBean.getRandomStr());
|
|
|
wXpayInfo.setTimestamp(wechatPaymentSignBean.getTimeStamp());
|
|
wXpayInfo.setTimestamp(wechatPaymentSignBean.getTimeStamp());
|
|
|
wXpayInfo.setSign(wechatPaymentSignBean.getSign());
|
|
wXpayInfo.setSign(wechatPaymentSignBean.getSign());
|
|
|
- requestSdkPay(wXpayInfo, orderId);
|
|
|
|
|
|
|
+ requestSdkPay(wXpayInfo, orderId, Constants.PAYMENT_WAY_WECHAT);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void requestSdkPay(Object payInfo, String orderId) {
|
|
|
|
|
|
|
+ private void requestSdkPay(Object payInfo, String orderId, int payWay) {
|
|
|
AgilePay.pay(payInfo, ActivityUtil.getTopActivity(), new AgilePayState() {
|
|
AgilePay.pay(payInfo, ActivityUtil.getTopActivity(), new AgilePayState() {
|
|
|
@Override
|
|
@Override
|
|
|
public void error(int errno, String error) {
|
|
public void error(int errno, String error) {
|
|
@@ -369,7 +398,11 @@ public class MemberViewModel extends BaseViewModel {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void paySuccess(String result) {
|
|
public void paySuccess(String result) {
|
|
|
- queryOrderStatus(orderId, true);
|
|
|
|
|
|
|
+ MemberGoodsBean bean = orderIdItemMap.get(orderId);
|
|
|
|
|
+ if (bean != null) {
|
|
|
|
|
+ EventHelper.reportPay(bean.getAmount(), orderId, payWay, bean.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ queryOrderStatus(orderId, payWay, true, false);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -379,7 +412,11 @@ public class MemberViewModel extends BaseViewModel {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public @NonNull Disposable queryOrderStatus(String orderId, boolean showLoading) {
|
|
|
|
|
|
|
+ public @NonNull Disposable queryOrderStatus(String orderId, int payWay, boolean showLoading, boolean isReportPay) {
|
|
|
|
|
+ MemberGoodsBean memberBean = orderIdItemMap.get(orderId);
|
|
|
|
|
+ if (memberBean != null && isReportPay) {
|
|
|
|
|
+ OrderReportHelper.recordOrderId(memberBean.getAmount(), orderId, payWay, memberBean.getName());
|
|
|
|
|
+ }
|
|
|
return memberRepository.getPayStatus(orderId)
|
|
return memberRepository.getPayStatus(orderId)
|
|
|
.doOnSubscribe(disposable -> {
|
|
.doOnSubscribe(disposable -> {
|
|
|
if (showLoading) {
|
|
if (showLoading) {
|
|
@@ -387,6 +424,13 @@ public class MemberViewModel extends BaseViewModel {
|
|
|
addDisposable(RxJavaUtil.timer(10, TimeUnit.SECONDS, () -> showLoadingEvent.setValue(false)));
|
|
addDisposable(RxJavaUtil.timer(10, TimeUnit.SECONDS, () -> showLoadingEvent.setValue(false)));
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
+ .doOnSuccess(success -> {
|
|
|
|
|
+ if (isReportPay) {
|
|
|
|
|
+ if (BoxingUtil.boxing(success) && memberBean != null) {
|
|
|
|
|
+ EventHelper.reportPay(memberBean.getAmount(), orderId, payWay, memberBean.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
.subscribe(aBoolean -> {
|
|
.subscribe(aBoolean -> {
|
|
|
showLoadingEvent.setValue(false);
|
|
showLoadingEvent.setValue(false);
|
|
|
if (BoxingUtil.boxing(aBoolean)) {
|
|
if (BoxingUtil.boxing(aBoolean)) {
|