|
@@ -10,6 +10,7 @@ import android.util.Log;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.View;
|
|
|
import android.view.WindowManager;
|
|
|
+import android.widget.EditText;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
@@ -20,7 +21,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.blankj.utilcode.util.ToastUtils;
|
|
|
import com.hjq.bar.OnTitleBarListener;
|
|
|
import com.hjq.bar.TitleBar;
|
|
|
import com.hw.nativeapp.MApplication;
|
|
@@ -28,16 +28,21 @@ import com.hw.nativeapp.R;
|
|
|
import com.hw.nativeapp.httpnet.ErrorConsumer;
|
|
|
import com.hw.nativeapp.httpnet.ResponseConsumer;
|
|
|
import com.hw.nativeapp.httpnet.entity.PageAsk;
|
|
|
+import com.hw.nativeapp.httpnet.entity.TouristEntity;
|
|
|
import com.hw.nativeapp.httpnet.entity.handleBean;
|
|
|
import com.hw.nativeapp.ui.activity.adapters.PurchaseInfoAdapter;
|
|
|
import com.hw.nativeapp.ui.activity.adapters.TicketCollectionAdapter;
|
|
|
import com.hw.nativeapp.utils.ActivityUtils;
|
|
|
+import com.hw.nativeapp.utils.IdNumberUtils;
|
|
|
import com.hw.nativeapp.utils.MaskUtil;
|
|
|
import com.hw.nativeapp.utils.RxUtil;
|
|
|
+import com.hw.nativeapp.utils.StringUtils;
|
|
|
+import com.hw.nativeapp.utils.ToastUtils;
|
|
|
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
|
|
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
|
|
|
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -58,8 +63,16 @@ public class PurchaseInfoActivity extends BaseActivity {
|
|
|
TextView tx_num;
|
|
|
@BindView(R.id.tx_total)
|
|
|
TextView tx_total;
|
|
|
-
|
|
|
- public static final Integer COUNTDOWN_TIME = 120000;
|
|
|
+ @BindView(R.id.et_tourist_name)
|
|
|
+ EditText touristName;
|
|
|
+ @BindView(R.id.et_tourist_idcard)
|
|
|
+ EditText touristIdcard;
|
|
|
+ @BindView(R.id.tx_player)
|
|
|
+ TextView tx_player;
|
|
|
+ @BindView(R.id.tx_personnelNum)
|
|
|
+ TextView tx_personnelNum;
|
|
|
+
|
|
|
+ public static final Integer COUNTDOWN_TIME = 240000;
|
|
|
private CountDownTimer timer;
|
|
|
private TitleBar titleBar;
|
|
|
|
|
@@ -74,6 +87,8 @@ public class PurchaseInfoActivity extends BaseActivity {
|
|
|
private String auditoriumId = "";
|
|
|
private String date = "";
|
|
|
private String goodsId = "";
|
|
|
+ private Integer personnelNum = 1;
|
|
|
+ private Integer goodsSaleNum = 1;
|
|
|
private String salePeice = "";
|
|
|
private String performTimeId = "";
|
|
|
private String seatTypeId = "";
|
|
@@ -82,9 +97,9 @@ public class PurchaseInfoActivity extends BaseActivity {
|
|
|
private String total = "";
|
|
|
private String totalPeice = "";
|
|
|
private String idcard = "";
|
|
|
- private JSONArray viewerList = new JSONArray();
|
|
|
|
|
|
- private JSONArray dataList = new JSONArray();
|
|
|
+ private List<TouristEntity> touristList = new ArrayList<>();
|
|
|
+
|
|
|
@Override
|
|
|
void initView() {
|
|
|
titleBar = findViewById(R.id.tb_main_bar);
|
|
@@ -109,7 +124,7 @@ public class PurchaseInfoActivity extends BaseActivity {
|
|
|
getPageTransmitParams();
|
|
|
initListView();
|
|
|
getDataList(true);;
|
|
|
- startCountDownTimer();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -117,12 +132,14 @@ public class PurchaseInfoActivity extends BaseActivity {
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_purchase_info);
|
|
|
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
|
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
|
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void onStart() {
|
|
|
super.onStart();
|
|
|
+ startCountDownTimer();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -130,19 +147,50 @@ public class PurchaseInfoActivity extends BaseActivity {
|
|
|
super.onDestroy();
|
|
|
}
|
|
|
|
|
|
- @OnClick({R.id.determine_btn, R.id.continue_btn})
|
|
|
+ @OnClick({R.id.determine_btn, R.id.ll_add_tourist})
|
|
|
public void onClick(View v){
|
|
|
switch (v.getId()){
|
|
|
case R.id.determine_btn:
|
|
|
orderSubmit();
|
|
|
break;
|
|
|
- case R.id.continue_btn:
|
|
|
- jumpPage();
|
|
|
+ case R.id.ll_add_tourist:
|
|
|
+ addTourist();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void addTourist(){
|
|
|
+ String name = touristName.getText().toString();
|
|
|
+ String idcard = touristIdcard.getText().toString();
|
|
|
+ if (StringUtils.isEmpty(name)){
|
|
|
+ ToastUtils.showShortToast(this, "用户姓名为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(idcard)){
|
|
|
+ ToastUtils.showShortToast(this, "身份证信息为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!IdNumberUtils.isValidatedAllIdcard(idcard)){
|
|
|
+ ToastUtils.showShortToast(this, "身份证格式错误");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ TouristEntity touristEntity = new TouristEntity();
|
|
|
+ touristEntity.name = name;
|
|
|
+ touristEntity.idcard = idcard;
|
|
|
+ touristList.add(touristEntity);
|
|
|
+
|
|
|
+ initLoadData();
|
|
|
+ touristName.setText("");
|
|
|
+ touristIdcard.setText("");
|
|
|
+ }
|
|
|
+
|
|
|
// 订单提交
|
|
|
+ @SuppressLint("CheckResult")
|
|
|
private void orderSubmit(){
|
|
|
+ if (touristList.isEmpty()){
|
|
|
+ ToastUtils.showLongToast(this, "提交观影人信息为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
JSONObject options = new JSONObject();
|
|
|
options.put("performId", performId);
|
|
|
options.put("auditoriumId", auditoriumId);
|
|
@@ -150,50 +198,42 @@ public class PurchaseInfoActivity extends BaseActivity {
|
|
|
options.put("seatTypeId", seatTypeId);
|
|
|
options.put("source", "8");
|
|
|
options.put("channelType", "self");
|
|
|
- options.put("totalPrice", Double.valueOf(salePeice) * viewerList.size());
|
|
|
-
|
|
|
|
|
|
//观影人信息
|
|
|
List<JSONObject> tourists = new ArrayList<>();
|
|
|
- for (Object obj : viewerList){
|
|
|
- JSONObject objJson = (JSONObject) obj;
|
|
|
+ for (TouristEntity obj : touristList){
|
|
|
JSONObject touristItem = new JSONObject();
|
|
|
touristItem.put("realType", 1);
|
|
|
- touristItem.put("name", objJson.getString("name"));
|
|
|
+ touristItem.put("name", obj.name);
|
|
|
touristItem.put("mobile", mMobile);
|
|
|
- touristItem.put("idcard", objJson.getString("idcard"));
|
|
|
+ touristItem.put("idcard", obj.idcard);
|
|
|
tourists.add(touristItem);
|
|
|
}
|
|
|
|
|
|
+ //观影人数量
|
|
|
+ int touristNum = touristList.size();
|
|
|
+ //需要的观影人数量
|
|
|
+ int needTouristNum = goodsSaleNum * personnelNum;
|
|
|
+ if (touristNum < needTouristNum){
|
|
|
+ ToastUtils.showLongToast(this, "订单需要观影人数与提交不符");
|
|
|
+ return;
|
|
|
+ }
|
|
|
// 商品列表
|
|
|
JSONArray goodsList = new JSONArray();
|
|
|
JSONObject goods = new JSONObject();
|
|
|
goods.put("goodsId", goodsId);
|
|
|
- goods.put("saleNum", tourists.size());
|
|
|
+ goods.put("saleNum", goodsSaleNum);
|
|
|
goods.put("tourists", tourists);
|
|
|
goodsList.add(goods);
|
|
|
options.put("goodsList", goodsList);
|
|
|
|
|
|
// 购票人信息
|
|
|
JSONObject purchaser = new JSONObject();
|
|
|
- purchaser.put("name", name);
|
|
|
- purchaser.put("idcard", idcard);
|
|
|
+ purchaser.put("name", touristList.get(0).name);
|
|
|
+ purchaser.put("idcard", touristList.get(0).idcard);
|
|
|
purchaser.put("mobile", mMobile);
|
|
|
options.put("purchaser", purchaser);
|
|
|
|
|
|
- // 观影人列表
|
|
|
-// JSONArray viewerList1 = new JSONArray();
|
|
|
-// if(viewerList != null && viewerList.size() > 0){
|
|
|
-// for (int i = 0; i < viewerList.size(); i++) {
|
|
|
-// JSONObject viewer = new JSONObject();
|
|
|
-// viewer.put("name", viewerList.getJSONObject(i).getString("name"));
|
|
|
-// viewer.put("idcard", viewerList.getJSONObject(i).getString("idcard"));
|
|
|
-// viewer.put("salePrice", salePeice);
|
|
|
-// viewer.put("realPrice", salePeice);
|
|
|
-// viewerList1.add(viewer);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// options.put("viewerList", viewerList1);
|
|
|
progressDialog = MaskUtil.showProgressDialog( "正在提交...", PurchaseInfoActivity.this);
|
|
|
new Handler().postDelayed(() -> {
|
|
|
if(progressDialog != null){
|
|
@@ -231,25 +271,25 @@ public class PurchaseInfoActivity extends BaseActivity {
|
|
|
bundle.putString("idcard", idcard);
|
|
|
bundle.putString("total", total);
|
|
|
bundle.putString("totalPeice", totalPeice);
|
|
|
- bundle.putString("viewerList", JSONArray.toJSONString(viewerList));
|
|
|
+ bundle.putString("viewerList", JSONArray.toJSONString(touristList));
|
|
|
ActivityUtils.launchActivity(this,PaymentMethodActivity.class, bundle);
|
|
|
}
|
|
|
// 继续添加观影人
|
|
|
- private void jumpPage () {
|
|
|
- Bundle bundle = new Bundle();
|
|
|
- bundle.putString("performId", performId);
|
|
|
- bundle.putString("auditoriumId", auditoriumId);
|
|
|
- bundle.putString("performTimeId", performTimeId);
|
|
|
- bundle.putString("seatTypeId", seatTypeId);
|
|
|
- bundle.putString("goodsId", goodsId);
|
|
|
- bundle.putString("mobile", mMobile);
|
|
|
- bundle.putString("salePeice", salePeice);
|
|
|
- bundle.putString("type", "2");
|
|
|
- bundle.putString("name", name);
|
|
|
- bundle.putString("idcard", idcard);
|
|
|
- bundle.putString("viewerList", JSONArray.toJSONString(viewerList));
|
|
|
- ActivityUtils.launchActivity(this,InfoInputActivity.class, bundle);
|
|
|
- }
|
|
|
+// private void jumpPage () {
|
|
|
+// Bundle bundle = new Bundle();
|
|
|
+// bundle.putString("performId", performId);
|
|
|
+// bundle.putString("auditoriumId", auditoriumId);
|
|
|
+// bundle.putString("performTimeId", performTimeId);
|
|
|
+// bundle.putString("seatTypeId", seatTypeId);
|
|
|
+// bundle.putString("goodsId", goodsId);
|
|
|
+// bundle.putString("mobile", mMobile);
|
|
|
+// bundle.putString("salePeice", salePeice);
|
|
|
+// bundle.putString("type", "2");
|
|
|
+// bundle.putString("name", name);
|
|
|
+// bundle.putString("idcard", idcard);
|
|
|
+// bundle.putString("viewerList", JSONArray.toJSONString(touristList));
|
|
|
+// ActivityUtils.launchActivity(this,InfoInputActivity.class, bundle);
|
|
|
+// }
|
|
|
//获取页面传递参数
|
|
|
private void getPageTransmitParams(){
|
|
|
Intent transmitIntent = getIntent();
|
|
@@ -257,13 +297,15 @@ public class PurchaseInfoActivity extends BaseActivity {
|
|
|
mMobile = transmitIntent.getStringExtra("mobile");
|
|
|
auditoriumId = transmitIntent.getStringExtra("auditoriumId");
|
|
|
goodsId = transmitIntent.getStringExtra("goodsId");
|
|
|
+ personnelNum = transmitIntent.getIntExtra("personnelNum",1);
|
|
|
salePeice = transmitIntent.getStringExtra("salePeice");
|
|
|
performTimeId = transmitIntent.getStringExtra("performTimeId");
|
|
|
seatTypeId = transmitIntent.getStringExtra("seatTypeId");
|
|
|
type = transmitIntent.getStringExtra("type");
|
|
|
- name = transmitIntent.getStringExtra("name");
|
|
|
- idcard = transmitIntent.getStringExtra("idcard");
|
|
|
- viewerList = JSONArray.parseArray(transmitIntent.getStringExtra("viewerList"));
|
|
|
+ if (!StringUtils.isEmpty(mMobile)){
|
|
|
+ tx_player.setText(mMobile);
|
|
|
+ }
|
|
|
+ tx_personnelNum.setText(String.valueOf(personnelNum));
|
|
|
}
|
|
|
|
|
|
private void reflashFinish(){
|
|
@@ -282,16 +324,11 @@ public class PurchaseInfoActivity extends BaseActivity {
|
|
|
adapter = new PurchaseInfoAdapter(this);
|
|
|
|
|
|
adapter.setOnOutBtnClickListerer((bean, position) -> {
|
|
|
- if(viewerList.size() > 1) {
|
|
|
- viewerList.remove(position);
|
|
|
+ if(touristList.size() > 1) {
|
|
|
+ touristList.remove(position);
|
|
|
initLoadData();
|
|
|
} else {
|
|
|
-// Toast.makeText(this, "至少保留一个观影人", Toast.LENGTH_SHORT).show();
|
|
|
- ToastUtils Toast = new ToastUtils();
|
|
|
- Toast.setGravity(Gravity.TOP, 0, 200);
|
|
|
- Toast.setTextSize(32);
|
|
|
- Toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
|
|
|
- Toast.show("至少保留一个观影人");
|
|
|
+ ToastUtils.showShortToast(this, "至少保留一个观影人");
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -317,21 +354,36 @@ public class PurchaseInfoActivity extends BaseActivity {
|
|
|
|
|
|
private void getDataList(boolean cleaned){
|
|
|
JSONArray rows = new JSONArray();
|
|
|
- if(viewerList != null && viewerList.size() > 0) {
|
|
|
- for (int i = 0; i < viewerList.size(); i++) {
|
|
|
+ if(!touristList.isEmpty()) {
|
|
|
+ int index = 1;
|
|
|
+ for (TouristEntity t : touristList){
|
|
|
JSONObject obj1 = new JSONObject();
|
|
|
- obj1.put("id", i+1);
|
|
|
- obj1.put("name", viewerList.getJSONObject(i).getString("name"));
|
|
|
- obj1.put("idcard", viewerList.getJSONObject(i).getString("idcard"));
|
|
|
+ obj1.put("id", index);
|
|
|
+ obj1.put("name", t.name);
|
|
|
+ obj1.put("idcard", t.idcard);
|
|
|
rows.add(obj1);
|
|
|
+ index++;
|
|
|
}
|
|
|
}
|
|
|
- dataList = rows;
|
|
|
- tx_num.setText("共" + rows.size() + "张, 合计");
|
|
|
- tx_total.setText("¥" + (rows.size() * Double.valueOf(salePeice)));
|
|
|
- total = String.valueOf(rows.size());
|
|
|
- totalPeice = String.valueOf(rows.size() * Double.valueOf(salePeice));
|
|
|
- if (rows != null && !rows.isEmpty()){
|
|
|
+ int touristNum = touristList.size();
|
|
|
+ //除数
|
|
|
+ int divisorNum = touristNum/personnelNum;
|
|
|
+ //余数
|
|
|
+ int remainderNum = touristNum%personnelNum;
|
|
|
+ //购买商品数量
|
|
|
+ goodsSaleNum = divisorNum;
|
|
|
+ if (personnelNum > 1 && remainderNum > 0){
|
|
|
+ goodsSaleNum += 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal saleAmount = new BigDecimal(salePeice);
|
|
|
+ BigDecimal totalAmount = saleAmount.multiply(BigDecimal.valueOf(goodsSaleNum));
|
|
|
+ tx_num.setText("共" + touristNum + "人, 累计");
|
|
|
+ tx_total.setText("¥" + totalAmount);
|
|
|
+
|
|
|
+ total = String.valueOf(touristNum);
|
|
|
+ totalPeice = String.valueOf(totalAmount);
|
|
|
+ if (!rows.isEmpty()){
|
|
|
List<handleBean> rowbeans = JSONArray.parseArray(JSON.toJSONString(rows), handleBean.class);
|
|
|
reflashLoadData(rowbeans, cleaned);
|
|
|
emptyShow(false);
|
|
@@ -353,13 +405,6 @@ public class PurchaseInfoActivity extends BaseActivity {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void pageHandle(int total, int page, int pageCount){
|
|
|
- if (pageAsk.pageNum <= pageCount){
|
|
|
- pageAsk.pageNum++;
|
|
|
- }
|
|
|
- pageAsk.pageCount = pageCount;
|
|
|
- pageAsk.total = total;
|
|
|
- }
|
|
|
private void reflashLoadData(List<handleBean> rows, boolean cleared){
|
|
|
if (adapter == null){
|
|
|
return;
|
|
@@ -378,22 +423,25 @@ public class PurchaseInfoActivity extends BaseActivity {
|
|
|
private void stopCountDownTimer(){
|
|
|
if (timer != null){
|
|
|
timer.cancel();
|
|
|
+ timer = null;
|
|
|
}
|
|
|
}
|
|
|
private void startCountDownTimer(){
|
|
|
- timer = new CountDownTimer(COUNTDOWN_TIME, 1000) {
|
|
|
- @SuppressLint("SetTextI18n")
|
|
|
- @Override
|
|
|
- public void onTick(long millisUntilFinished) {
|
|
|
- titleBar.setRightTitle(millisUntilFinished / 1000 + "s");
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFinish() {
|
|
|
- jumpToLogin();
|
|
|
- }
|
|
|
- };
|
|
|
- timer.start();
|
|
|
+ if (timer == null){
|
|
|
+ timer = new CountDownTimer(COUNTDOWN_TIME, 1000) {
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
+ @Override
|
|
|
+ public void onTick(long millisUntilFinished) {
|
|
|
+ titleBar.setRightTitle(millisUntilFinished / 1000 + "s");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFinish() {
|
|
|
+ jumpToLogin();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ timer.start();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|