package com.tejia.lijin.app.ui.mine;
|
|
import android.app.Dialog;
|
import android.content.Context;
|
import android.content.Intent;
|
import android.content.SharedPreferences;
|
import android.os.Bundle;
|
import android.view.View;
|
import android.widget.FrameLayout;
|
import android.widget.ImageView;
|
import android.widget.LinearLayout;
|
import android.widget.TextView;
|
|
import com.google.gson.Gson;
|
import com.tejia.lijin.app.ShoppingApplication;
|
import com.tejia.lijin.app.util.user.UserUtil;
|
import com.wpc.library.util.common.StringUtils;
|
import com.tejia.lijin.app.BasicTextHttpResponseHandler;
|
import com.tejia.lijin.app.R;
|
import com.tejia.lijin.app.ShoppingApi;
|
import com.tejia.lijin.app.entity.user.money.statistic.MoneyStatisticVO;
|
import com.tejia.lijin.app.ui.BaseActivity;
|
import com.tejia.lijin.app.ui.invite.ShareBrowserActivity;
|
import com.tejia.lijin.app.util.ToolUtil;
|
import com.tejia.lijin.app.util.TopStatusSettings;
|
import com.tejia.lijin.app.util.umengCustomEvent.UserCustomEvent;
|
|
import org.apache.http.Header;
|
import org.json.JSONException;
|
import org.json.JSONObject;
|
|
/**
|
* Created by weikou2015 on 2018/1/18.
|
* 资金
|
*/
|
|
public class CapitalActivity extends BaseActivity implements View.OnClickListener {
|
TextView tv_left, tv_middle, tv_available_rebate,
|
tv_mine_drawcash;
|
private String TYPE = "money";
|
private TextView tv_notice_content;
|
private LinearLayout ll_notice;
|
private ImageView iv_close;
|
private TextView tv_available_withdrawal;//提款中 显示余额
|
|
|
//账户明细,提现记录
|
private FrameLayout fl_account_detail, fl_withdraw_history;
|
|
//统计数据
|
private FrameLayout fl_withdraw, fl_total_money, fl_daozhang;
|
private TextView tv_money_desc, tv_shouhuo_desc;
|
|
private void initStatisticView() {
|
fl_withdraw = findViewById(R.id.fl_withdraw);
|
fl_total_money = findViewById(R.id.fl_total_money);
|
fl_daozhang = findViewById(R.id.fl_daozhang);
|
|
tv_money_desc = findViewById(R.id.tv_money_desc);
|
tv_shouhuo_desc = findViewById(R.id.tv_shouhuo_desc);
|
|
((TextView) fl_withdraw.findViewById(R.id.tv_name_1)).setText("本月提现");
|
((TextView) fl_withdraw.findViewById(R.id.tv_name_2)).setText("上月提现");
|
((TextView) fl_withdraw.findViewById(R.id.tv_name_3)).setText("累计提现");
|
|
((TextView) fl_total_money.findViewById(R.id.tv_name_1)).setText("累计分享佣金");
|
|
((TextView) fl_daozhang.findViewById(R.id.tv_name_1)).setText("待确认收货");
|
((TextView) fl_daozhang.findViewById(R.id.tv_name_2)).setText("本月未到账");
|
((TextView) fl_daozhang.findViewById(R.id.tv_name_3)).setText("全部未到账");
|
}
|
|
|
@Override
|
protected void onCreate(Bundle savedInstanceState) {
|
super.onCreate(savedInstanceState);
|
setContentView(R.layout.activity_rebate);
|
TopStatusSettings.setStatusViewAndDeepColor(this);
|
initStatisticView();
|
tv_left = findViewById(R.id.tv_top_bar_left);
|
tv_middle = findViewById(R.id.tv_top_bar_middle);
|
tv_available_rebate = findViewById(R.id.tv_available_rebate);
|
tv_mine_drawcash = findViewById(R.id.tv_mine_drawcash);
|
tv_available_withdrawal = findViewById(R.id.tv_available_withdrawal);
|
|
|
fl_account_detail = findViewById(R.id.fl_account_detail);
|
fl_withdraw_history = findViewById(R.id.fl_withdraw_history);
|
|
fl_account_detail.setOnClickListener(this);
|
fl_withdraw_history.setOnClickListener(this);
|
|
|
tv_middle.setText("资金");
|
|
|
SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE);
|
tv_notice_content = findViewById(R.id.tv_notice_content);
|
ll_notice = findViewById(R.id.ll_notice);
|
iv_close = findViewById(R.id.iv_close);
|
getAppPageNotification();
|
|
tv_left.setOnClickListener(this);
|
tv_mine_drawcash.setOnClickListener(this);
|
mUserMoneyStatistic = getIntent().getStringExtra("UserMoneyStatistic");
|
}
|
|
private String mUserMoneyStatistic = null;
|
|
@Override
|
protected void onResume() {
|
super.onResume();
|
if (mUserMoneyStatistic != null && !StringUtils.isEmpty(mUserMoneyStatistic)) {//传入有数据
|
JSONObject jsTaskList = null;
|
try {
|
jsTaskList = new JSONObject(mUserMoneyStatistic);
|
} catch (JSONException e) {
|
e.printStackTrace();
|
}
|
setUserMoneyInfo(jsTaskList);//设置UserMoneyStatistic
|
mUserMoneyStatistic = null;
|
} else {//传入没有数据 请求网络
|
getUserMoney();
|
}
|
getUserMoneyStatistic();
|
SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE);
|
}
|
|
private void getAppPageNotification() {
|
ShoppingApi.getAppPageNotification(this, TYPE, new BasicTextHttpResponseHandler() {
|
@Override
|
public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
|
if (jsonObject.optInt("code") == 0) {
|
boolean isClose = jsonObject.optJSONObject("data").optBoolean("canClose");
|
String content = jsonObject.optJSONObject("data").optString("content");
|
final String contentUrl = jsonObject.optJSONObject("data").optString("contentUrl");
|
final String md5 = jsonObject.optJSONObject("data").optString("md5");
|
|
tv_notice_content.setText(content);
|
final SharedPreferences sp = getSharedPreferences("notice", Context.MODE_PRIVATE);
|
if (!sp.getBoolean(md5, false)) {//false 展示,true不展示
|
ll_notice.setVisibility(View.VISIBLE);
|
} else {
|
ll_notice.setVisibility(View.GONE);
|
}
|
|
if (isClose) {
|
iv_close.setImageDrawable(getResources().getDrawable(R.drawable.ic_notice_close));
|
iv_close.setOnClickListener(new View.OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
ll_notice.setVisibility(View.GONE);
|
SharedPreferences.Editor editor = sp.edit();
|
editor.putBoolean(md5, true);
|
editor.commit();
|
}
|
});
|
} else {
|
iv_close.setImageDrawable(getResources().getDrawable(R.drawable.ic_notice_input));
|
}
|
ll_notice.setOnClickListener(new View.OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
if (StringUtils.isEmpty(contentUrl))
|
return;
|
Intent intent = new Intent(CapitalActivity.this, ShareBrowserActivity.class);
|
intent.putExtra("url", contentUrl);
|
startActivity(intent);
|
}
|
});
|
}
|
}
|
});
|
}
|
|
/**
|
* 用户资金统计
|
*/
|
private void getUserMoneyStatistic() {
|
ShoppingApi.getMoneyStatistic(this, UserUtil.getUid(ShoppingApplication.application), new BasicTextHttpResponseHandler() {
|
@Override
|
public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
|
super.onSuccessPerfect(statusCode, headers, jsonObject);
|
setUserMoneyStatistic(jsonObject);
|
}
|
|
@Override
|
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
|
super.onFailure(statusCode, headers, responseString, throwable);
|
ToolUtil.showToast(tv_available_rebate.getContext(), "网络连接异常,请检测网络设置");
|
}
|
});
|
}
|
|
private void getUserMoney() {
|
ShoppingApi.getUserMoneyInfo(this, UserUtil.getUid(ShoppingApplication.application), new BasicTextHttpResponseHandler() {
|
@Override
|
public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
|
super.onSuccessPerfect(statusCode, headers, jsonObject);
|
setUserMoneyInfo(jsonObject);
|
}
|
|
@Override
|
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
|
super.onFailure(statusCode, headers, responseString, throwable);
|
ToolUtil.showToast(tv_available_rebate.getContext(), "网络连接异常,请检测网络设置");
|
}
|
});
|
}
|
|
String helpLink = null;
|
|
/**
|
* 设置UserMoneyStatistic
|
*
|
* @param jsonObject
|
*/
|
private void setUserMoneyStatistic(JSONObject jsonObject) {
|
if (jsonObject.optInt("code") == 0) {
|
JSONObject data = jsonObject.optJSONObject("data");
|
helpLink = data.optString("link");
|
String balance = data.optString("balanceMoney");
|
tv_available_rebate.setText(balance);
|
tv_available_withdrawal.setText(jsonObject.optJSONObject("data").optString("extractingMoneyInfo"));//提现中
|
|
MoneyStatisticVO vo = new Gson().fromJson(data.toString(), MoneyStatisticVO.class);
|
|
tv_money_desc.setText(vo.getExtractDesc());
|
tv_shouhuo_desc.setText(vo.getMoneyArrivalDesc());
|
|
((TextView) fl_withdraw.findViewById(R.id.tv_value_1)).setText("¥ " + vo.getMonthExtractMoney());
|
((TextView) fl_withdraw.findViewById(R.id.tv_value_2)).setText("¥ " + vo.getLastMonthExtractMoney());
|
((TextView) fl_withdraw.findViewById(R.id.tv_value_3)).setText("¥ " + vo.getTotalExtractMoney());
|
|
((TextView) fl_total_money.findViewById(R.id.tv_value_1)).setText("¥ " + vo.getTotalShareMoney());
|
|
((TextView) fl_daozhang.findViewById(R.id.tv_value_1)).setText("¥ " + vo.getNotSettleMoney());
|
((TextView) fl_daozhang.findViewById(R.id.tv_value_2)).setText("¥ " + vo.getMonthUnRecievedMoney());
|
((TextView) fl_daozhang.findViewById(R.id.tv_value_3)).setText("¥ " + vo.getTotalUnRecievedMoney());
|
}
|
}
|
|
|
private void setUserMoneyInfo(JSONObject jsonObject) {
|
if (jsonObject.optInt("code") == 0) {
|
JSONObject data = jsonObject.optJSONObject("data");
|
|
helpLink = data.optString("link");
|
String balance = data.optString("balanceMoney");
|
tv_available_rebate.setText(balance);
|
tv_available_withdrawal.setText(jsonObject.optJSONObject("data").optString("extractingMoneyInfo"));//提现中
|
}
|
}
|
|
|
@Override
|
public void onClick(View view) {
|
switch (view.getId()) {
|
case R.id.tv_top_bar_left:
|
finish();
|
break;
|
// case R.id.tv_mine_descrip://账目明细
|
//// UserCustomEvent.userMoneyDetail(CapitalActivity.this);
|
//// startActivity(new Intent(CapitalActivity.this, AccountDescActivity33.class));
|
//// break;
|
case R.id.tv_top_bar_right://账目明细
|
|
break;
|
case R.id.tv_mine_drawcash://提现
|
UserCustomEvent.userMoneyExtract(CapitalActivity.this);
|
Intent intent = new Intent(CapitalActivity.this, WithdrawCashActivity.class);
|
intent.putExtra("maxWithDraw", "100");
|
startActivity(intent);
|
break;
|
case R.id.iv_top_bar_right1:
|
startActivity(new Intent(CapitalActivity.this, ShareBrowserActivity.class).putExtra("url", helpLink));
|
break;
|
case R.id.fl_account_detail://账户明细
|
UserCustomEvent.userMoneyDetail(CapitalActivity.this);
|
startActivity(new Intent(CapitalActivity.this, AccountDescActivity33.class));
|
break;
|
case R.id.fl_withdraw_history://提现记录
|
startActivity(new Intent(CapitalActivity.this, WithdrawRecordActivity.class));
|
break;
|
}
|
}
|
|
// boolean withdrawpop = false;//点击自动提现重复请求
|
// boolean withdrawpop2 = false;//点击取消自动提现重复请求
|
private String closeAutoExtractMsg = "";////关闭自动提现提示语
|
private String openAutoExtractMsg = "";//开启自动提现提示语
|
private Dialog dialog;
|
|
@Override
|
protected void onPause() {
|
super.onPause();
|
if (dialog != null && dialog.isShowing()) {
|
dialog.dismiss();
|
}
|
}
|
|
@Override
|
protected void onDestroy() {
|
super.onDestroy();
|
if (dialog != null && dialog.isShowing()) {
|
dialog.dismiss();
|
}
|
}
|
}
|