Browse Source

查询列表添加状态返回和状态处理

yinds 1 year ago
parent
commit
d9c43e97f2

+ 149 - 0
app/src/main/java/com/hw/nativeapp/config/enums/IntegerEnum.java

@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2022
+ * All rights reserved, Designed By 信通达智能科技有限公司
+ * Copyright authorization contact
+ */
+package com.hw.nativeapp.config.enums;
+
+
+import com.hw.nativeapp.R;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+public enum IntegerEnum {
+
+    //
+    YES("是",1,0),
+    NO("否",0,0),
+
+
+
+    //支付状态: 0-未支付 1-已支付 2-支付中 3-支付失败 4-支付退款
+    PAY_STA_NONE("未支付",0,0),
+    PAY_STA_PAYED("已支付",1,0),
+    PAY_STA_PAYING("支付中",2,0),
+    PAY_STA_PAYFAIL("支付失败",3,0),
+    PAY_STA_REFUND("支付退款",4,0),
+
+    //订单状态: 0待支付,2超时取消,3支付完成,待使用,4退款中,5己退款,6退款失败,7己使用,8己超期,9关闭
+    ORDER_STA_NONE("待支付",0,R.color.blue),
+    ORDER_STA_TIMEOUT("超时取消",2,R.color.red),
+    ORDER_STA_PAYCOMPLETE("待使用",3, R.color.green),
+    ORDER_STA_REFUNDING("退款中",4,R.color.red),
+    ORDER_STA_REFUND("己退款",5,R.color.red),
+    ORDER_STA_REFUNDFAIL("退款失败",6,R.color.red),
+    ORDER_STA_USED("己使用",7,R.color.gray),
+    ORDER_STA_EXPIRE("己超期",8,R.color.red),
+    ORDER_STA_CLOSE("关闭",9,R.color.red),
+
+
+    //订单来源 1小程序,2-美团 3-携程,4-公众号 5-团购  6-分销商 7-窗口 8-自助售取票机 9-支付宝 10-窗口美团 11-窗口携程 12-窗口赠送 13-窗口抖音 14-窗口猫眼 15-窗口去哪儿
+    ORDER_SOURCE_APPLET("小程序",1,0),
+    ORDER_SOURCE_MEITUAN("美团",2,0),
+    ORDER_SOURCE_XIECHENG("携程",3,0),
+    ORDER_SOURCE_H5("公众号",4,0),
+    ORDER_SOURCE_GROUP("团购",5,0),
+    ORDER_SOURCE_PERSON("分销商",6,0),
+    ORDER_SOURCE_WINDOWS("窗口",7,0),
+    ORDER_SOURCE_SELF("自助售取票机",8,0),
+    ORDER_SOURCE_ALIPAY("支付宝",9,0),
+    ORDER_SOURCE_WINMEITUAN("窗口美团",10,0),
+    ORDER_SOURCE_WINXIECHENG("窗口携程",11,0),
+    ORDER_SOURCE_WINGIVE("窗口赠票",12,0),
+    ORDER_SOURCE_WINDY("窗口抖音",13,0),
+    ORDER_SOURCE_WINMY("窗口猫眼",14,0),
+    ORDER_SOURCE_WINQNE("窗口去哪儿",15,0),
+
+
+
+    //出票来源: 1-自助端 2-窗口端 3-PDA端
+    TICKET_SOURCE_SELF("出票来源-自助端",1,0),
+    TICKET_SOURCE_WIN("出票来源-窗口端",2,0),
+    TICKET_SOURCE_PDA("出票来源-窗口端",3,0),
+
+    //删除状态:0-否 1是
+    DEL_NO("删除状态-否",0,0),
+    DEL_YES("删除状态-是",1,0);
+
+
+
+    String name;
+    Integer code;
+    Integer color;
+
+
+    IntegerEnum(String name, Integer code,Integer color) {
+        this.code = code;
+        this.name=name;
+        this.color=color;
+    }
+
+
+
+
+
+    public static String getPayStaName(Integer code){
+        List<IntegerEnum> list = Arrays.asList(PAY_STA_NONE,PAY_STA_PAYED,PAY_STA_PAYING,
+                PAY_STA_PAYFAIL,PAY_STA_REFUND);
+        for (IntegerEnum item : list){
+            if (code.equals(item.getCode())){
+                return item.getName();
+            }
+        }
+        return PAY_STA_NONE.getName();
+    }
+
+    public static String getOrderSourceName(Integer source){
+        List<IntegerEnum> list = Arrays.asList(ORDER_SOURCE_APPLET,ORDER_SOURCE_MEITUAN,
+                ORDER_SOURCE_XIECHENG,ORDER_SOURCE_H5,ORDER_SOURCE_GROUP,
+                ORDER_SOURCE_PERSON,ORDER_SOURCE_WINDOWS,ORDER_SOURCE_SELF,
+                ORDER_SOURCE_ALIPAY,ORDER_SOURCE_WINMEITUAN,ORDER_SOURCE_WINXIECHENG,
+                ORDER_SOURCE_WINGIVE,ORDER_SOURCE_WINDY,ORDER_SOURCE_WINMY,ORDER_SOURCE_WINQNE);
+        for (IntegerEnum item : list){
+            if (source.equals(item.getCode())){
+                return item.getName();
+            }
+        }
+        return ORDER_SOURCE_APPLET.getName();
+    }
+
+    public static IntegerEnum getOrderStatusName(Integer status){
+        List<IntegerEnum> list = Arrays.asList(ORDER_STA_NONE,ORDER_STA_TIMEOUT,ORDER_STA_PAYCOMPLETE,ORDER_STA_REFUNDING,ORDER_STA_REFUND
+        ,ORDER_STA_REFUNDFAIL,ORDER_STA_USED,ORDER_STA_EXPIRE,ORDER_STA_CLOSE);
+        for (IntegerEnum item : list){
+            if (status.equals(item.getCode())){
+                return item;
+            }
+        }
+        return ORDER_STA_NONE;
+    }
+
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+
+    public Integer getColor() {
+        return color;
+    }
+
+    public void setColor(Integer color) {
+        this.color = color;
+    }
+}

+ 3 - 1
app/src/main/java/com/hw/nativeapp/httpnet/entity/handleBean.java

@@ -14,10 +14,12 @@ public class handleBean {
     public String performStart;
     public String performEnd;
 
+
     public String seatName;
     public String seatTypeId;
     public String seatTypeName;
 
     public boolean checkedStatus;
-
+    /** 状态(0待支付,2超时取消,3支付完成,待使用,4退款中,5己退款,6退款失败,7己使用,8己超期) */
+    public Integer status;
 }

+ 16 - 4
app/src/main/java/com/hw/nativeapp/ui/activity/PurchaseInfoActivity.java

@@ -21,6 +21,7 @@ import com.hjq.bar.OnTitleBarListener;
 import com.hjq.bar.TitleBar;
 import com.hw.nativeapp.MApplication;
 import com.hw.nativeapp.R;
+import com.hw.nativeapp.config.enums.IntegerEnum;
 import com.hw.nativeapp.httpnet.ErrorConsumer;
 import com.hw.nativeapp.httpnet.ResponseConsumer;
 import com.hw.nativeapp.httpnet.entity.PageAsk;
@@ -29,11 +30,13 @@ import com.hw.nativeapp.ui.activity.adapters.PurchaseInfoAdapter;
 import com.hw.nativeapp.utils.ActivityUtils;
 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.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -213,6 +216,7 @@ public class PurchaseInfoActivity extends BaseActivity  {
         if(idcard != null && !idcard.isEmpty()){
             options.put("idcard", idcard);
         }
+        options.put("orderStatusIn","0,3,4,5,6,7,8,9");
         MApplication.getApiService().getValidList( options, System.currentTimeMillis() / 1000)
                 .compose(RxUtil.applyObservableAsync())
                 .subscribe(new ResponseConsumer<JSONObject>() {
@@ -275,18 +279,26 @@ public class PurchaseInfoActivity extends BaseActivity  {
                 listObj.add(dataList.getJSONObject(i));
             }
         }
-        if(listObj == null || listObj.size() == 0) {
+        if(listObj.size() == 0) {
             Toast msg = Toast.makeText(this, "请勾选需要核销的数据!", Toast.LENGTH_SHORT);
 //            msg.setGravity(Gravity.CENTER, 0, 0);
             msg.show();
             return;
         }
-        String [] list = new String[listObj.size()];
+        List<String> list = new ArrayList<>();
         for (int i = 0; i < listObj.size(); i++) {
-            if(listObj.getJSONObject(i).getBooleanValue("checkedStatus")){
-                list[i] = listObj.getJSONObject(i).getString("id");
+            JSONObject itemJson = listObj.getJSONObject(i);
+            boolean checkedStatus = itemJson.getBooleanValue("checkedStatus");
+            int status = itemJson.getIntValue("status");
+            if(checkedStatus && status == IntegerEnum.ORDER_STA_PAYCOMPLETE.getCode()){
+                list.add(listObj.getJSONObject(i).getString("id")) ;
             }
         }
+        if (list.isEmpty()){
+            Toast msg = Toast.makeText(this, "可核销数据为空!", Toast.LENGTH_SHORT);
+            msg.show();
+            return;
+        }
         options.put("viewerIds", list);
         progressDialog = MaskUtil.showProgressDialog( "正在提交...", PurchaseInfoActivity.this);
         new Handler().postDelayed(() -> {

+ 30 - 10
app/src/main/java/com/hw/nativeapp/ui/activity/adapters/PurchaseInfoAdapter.java

@@ -10,12 +10,15 @@ import androidx.annotation.NonNull;
 import androidx.recyclerview.widget.RecyclerView;
 
 import com.hw.nativeapp.R;
+import com.hw.nativeapp.config.enums.IntegerEnum;
 import com.hw.nativeapp.httpnet.entity.handleBean;
 import com.hw.nativeapp.ui.activity.holders.PurchaseInfoHolder;
 import com.hw.nativeapp.ui.activity.holders.TicketPurchaseHolder;
+import com.hw.nativeapp.utils.DateUtils;
 import com.hw.nativeapp.utils.StringUtils;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 public class PurchaseInfoAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
@@ -61,18 +64,35 @@ public class PurchaseInfoAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
             return;
         }
         normalHolder.tx_name.setText(detailBean.name);
-        normalHolder.tx_status.setText("待核销");
-        normalHolder.tx_date.setText(detailBean.performDate);
-        String startTime = detailBean.performStart.indexOf(" ") > -1 ? detailBean.performStart.split(" ")[1] : "";
-        String endTime = detailBean.performEnd.indexOf(" ") > -1 ? detailBean.performEnd.split(" ")[1] : "";
-        normalHolder.tx_time.setText(startTime +  "--" + endTime);
+        normalHolder.tx_status.setText(IntegerEnum.getOrderStatusName(detailBean.status).getName());
+        normalHolder.tx_status.setTextColor(mContext.getResources().getColor(IntegerEnum.getOrderStatusName(detailBean.status).getColor()));
+
+
+        //日期
+        Date pStart = DateUtils.parse(detailBean.performStart,DateUtils.DATE_TIME_PATTERN);
+        Date pEnd = DateUtils.parse(detailBean.performStart,DateUtils.DATE_TIME_PATTERN);;
+        String shwoTime = DateUtils.getDateString(pStart,"MM月dd日 HH:mm") + "-" +
+                DateUtils.getDateString(pEnd,"HH:mm");
+
+        normalHolder.tx_date.setText(shwoTime);
+        normalHolder.tx_performName.setText(detailBean.performName);
+//        String startTime = detailBean.performStart.indexOf(" ") > -1 ? detailBean.performStart.split(" ")[1] : "";
+//        String endTime = detailBean.performEnd.indexOf(" ") > -1 ? detailBean.performEnd.split(" ")[1] : "";
+//        normalHolder.tx_time.setText(startTime +  "--" + endTime);
         normalHolder.tx_seat_name.setText(detailBean.seatName);
         normalHolder.tx_seat_type.setText(detailBean.seatTypeName);
-        normalHolder.cb_check.setChecked(detailBean.checkedStatus);
-        normalHolder.cb_check.setOnClickListener(v -> {
-            detailBean.checkedStatus =  normalHolder.cb_check.isChecked();
-            mOnOutBtnClickListerer.onClick(detailBean, position);
-        });
+        if (detailBean.status.equals(IntegerEnum.ORDER_STA_PAYCOMPLETE.getCode())){
+            normalHolder.cb_check.setVisibility(View.VISIBLE);
+            normalHolder.cb_check.setChecked(detailBean.checkedStatus);
+            normalHolder.ll_item.setOnClickListener(v -> {
+                detailBean.checkedStatus =  !normalHolder.cb_check.isChecked();
+                normalHolder.cb_check.setChecked(detailBean.checkedStatus);
+                mOnOutBtnClickListerer.onClick(detailBean, position);
+            });
+        }else {
+            normalHolder.cb_check.setVisibility(View.INVISIBLE);
+        }
+
     }
 
     @Override

+ 5 - 2
app/src/main/java/com/hw/nativeapp/ui/activity/holders/PurchaseInfoHolder.java

@@ -2,6 +2,7 @@ package com.hw.nativeapp.ui.activity.holders;
 
 import android.view.View;
 import android.widget.CheckBox;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import androidx.annotation.NonNull;
@@ -14,10 +15,11 @@ public class PurchaseInfoHolder extends RecyclerView.ViewHolder{
     public TextView tx_name;
     public TextView tx_status;
     public TextView tx_date;
-    public TextView tx_time;
+    public TextView tx_performName;
     public TextView tx_seat_name;
     public TextView tx_seat_type;
     public CheckBox cb_check;
+    public LinearLayout ll_item;
 
     public PurchaseInfoHolder(@NonNull View itemView) {
         super(itemView);
@@ -25,9 +27,10 @@ public class PurchaseInfoHolder extends RecyclerView.ViewHolder{
         tx_name = (TextView) itemView.findViewById(R.id.tx_name);
         tx_status = (TextView) itemView.findViewById(R.id.tx_status);
         tx_date = (TextView) itemView.findViewById(R.id.tx_date);
-        tx_time = (TextView) itemView.findViewById(R.id.tx_time);
+        tx_performName = (TextView) itemView.findViewById(R.id.tx_performName);
         tx_seat_name = (TextView) itemView.findViewById(R.id.tx_seat_name);
         tx_seat_type = (TextView) itemView.findViewById(R.id.tx_seat_type);
+        ll_item = itemView.findViewById(R.id.ll_item);
 
         cb_check = (CheckBox) itemView.findViewById(R.id.cb_check);
     }

+ 27 - 9
app/src/main/res/layout/item_purchase_info.xml

@@ -7,6 +7,7 @@
 
 
     <LinearLayout
+        android:id="@+id/ll_item"
         android:layout_margin="10sp"
         android:layout_width="match_parent"
         android:orientation="vertical"
@@ -28,7 +29,7 @@
                     android:layout_height="match_parent" />
             </LinearLayout>
             <LinearLayout
-                android:layout_width="wrap_content"
+                android:layout_width="match_parent"
                 android:orientation="vertical"
                 android:layout_height="wrap_content">
                 <LinearLayout
@@ -44,7 +45,7 @@
                         android:text="张三"
                         android:textColor="@color/black"
                         android:textFontWeight="800"
-                        android:textSize="14sp" />
+                        android:textSize="26sp" />
                     <TextView
                         android:id="@+id/tx_status"
                         android:layout_weight="3"
@@ -56,32 +57,49 @@
                         android:textFontWeight="800"
                         android:textSize="14sp" />
                 </LinearLayout>
+
                 <LinearLayout
-                    android:layout_marginTop="10sp"
+                    android:layout_marginTop="6sp"
                     android:orientation="horizontal"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content">
                     <TextView
-                        android:id="@+id/tx_date"
+                        android:layout_weight="1"
+                        android:id="@+id/tx_performName"
                         android:layout_width="wrap_content"
                         android:layout_height="match_parent"
                         android:gravity="left"
-                        android:text="2024-01-01"
+                        tools:text="伟大转折剧目"
                         android:textColor="@color/black"
                         android:textFontWeight="800"
                         android:textSize="14sp" />
+                </LinearLayout>
+                <LinearLayout
+                    android:layout_marginTop="6sp"
+                    android:orientation="horizontal"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content">
                     <TextView
-                        android:id="@+id/tx_time"
+                        android:id="@+id/tx_date"
                         android:layout_width="wrap_content"
                         android:layout_height="match_parent"
-                        android:layout_marginLeft="10dp"
-                        android:text="19:00"
+                        android:gravity="left"
+                        android:text="01月17日 14:00-16:00"
                         android:textColor="@color/black"
                         android:textFontWeight="800"
                         android:textSize="14sp" />
+<!--                    <TextView-->
+<!--                        android:id="@+id/tx_time"-->
+<!--                        android:layout_width="wrap_content"-->
+<!--                        android:layout_height="match_parent"-->
+<!--                        android:layout_marginLeft="10dp"-->
+<!--                        android:text="19:00"-->
+<!--                        android:textColor="@color/black"-->
+<!--                        android:textFontWeight="800"-->
+<!--                        android:textSize="14sp" />-->
                 </LinearLayout>
                 <LinearLayout
-                    android:layout_marginTop="10sp"
+                    android:layout_marginTop="6sp"
                     android:orientation="horizontal"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content">