admin
2021-05-28 98cc34dbca6d6218ec5e72baffda2d3a1dd72a55
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
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();
        }
    }
}