package com.bonus.canteen.core.pay.common.constants;

import cn.hutool.core.collection.CollUtil;
import com.bonus.canteen.core.common.converter.LeExcelFieldConvertor;
import com.bonus.canteen.core.common.converter.LeExcelFieldEnum;

import java.util.*;
import java.util.stream.Collectors;

public enum PayTypeEnum implements LeExcelFieldEnum<PayTypeEnum> {
   MEAL_CARD(1, "账户支付"),
   CASH(2, "现金支付"),
   COUPON(3, "餐券支付"),
   CASH_MACHINE(4, "设备现金支付"),
   SUB_GRANT(5, "补贴"),
   RED_GRANT(6, "红包"),
   WX_RCB_NATIVE(7, "无锡农商行原生"),
   ALI_QRCODE(10, "支付宝扫码"),
   ALI_FACE(11, "支付宝人脸"),
   ALI_NATIVE(12, "支付宝原生"),
   OFFLINE_ALI_QRCODE(13, "支付宝线下扫码"),
   ALI_APP_PAY(14, "支付宝app"),
   ALI_DING_ACC_PAY(15, "钉工牌账户支付"),
   ALI_DING_PAY(16, "钉工牌支付宝支付"),
   ALI_PAY_WITHHOLD(17, "支付宝代扣"),
   ALI_H5_PAY(18, "支付宝移动网页支付"),
   WECHAT_QRCODE(20, "微信扫码"),
   WECHAT_FACE(21, "微信k12人脸"),
   WECHAT_NATIVE(22, "微信原生"),
   WECHAT_WITHHOLD(23, "微信代扣"),
   OFFLINE_WECHAT_QRCODE(24, "微信线下扫码"),
   WECHAT_H5(25, "微信移动网页支付"),
   UNION_PAY_QRCODE(30, "银联付款码"),
   CLOUD_UNION_PAY(31, "云闪付"),
   JINGDONG_PAY(40, "京东支付"),
   CCB_PAY(41, "建行龙支付"),
   BUSINESS_UNIFY_PAY(50, "商家统一支付"),
   OTHER_QRCODE(60, "小程序二维码支付"),
   OTHER_PAY(61, "其他支付"),
   MIXTURE_PAY_ALI_QRCODE(70, "支付宝扫码（混合支付）"),
   MIXTURE_PAY_WECHAT_QRCODE(71, "微信扫码（混合支付）"),
   MIXTURE_PAY_ALI_NATIVE(72, "支付宝原生（混合支付）"),
   MIXTURE_PAY_WECHAT_NATIVE(73, "微信原生（混合支付）"),
   SHOU_QIAN_BA_PAY(80, "收钱吧支付"),
   SHOU_QIAN_BA_MOBILE_H5(81, "收钱吧移动端h5支付"),
   THIRD_DEVICE(98, "第三方设备支付"),
   THIRD_ACC(99, "第三方账户支付"),
   ABC_PAY_CODE(100, "农行付款码支付"),
   ABC_ID_CODE(101, "农行身份码支付"),
   ABC_ACCOUNT_PAY(102, "农行账户支付"),
   ABC_QR_CODE_PAY(103, "农行扫码支付"),
   ABC_CREDIT_PAY(104, "农行信用卡支付"),
   ABC_AGENT_PAY(105, "农行授权免密支付"),
   ICBC_PAY_CODE(110, "工行付款码支付"),
   CMB_PAY_CODE(120, "招行扫码支付"),
   CIB_PAY_CODE(121, "兴业银行扫码支付"),
   ABC_DCEP_CODE_PAY(122, "数字人民币扫码支付"),
   ECITIC_H5_PAY(123, "中信H5支付"),
   ECITIC_PAY_CODE(124, "中信付款码支付"),
   BOC_ACCOUNT_PAY(125, "中国银行账户支付"),
   CHINA_PAY_CODE(126, "银联线上支付"),
   BOC_AREA_CODE_ACCOUNT_PAY(127, "中国银行园区码-小牛账户支付"),
   BOC_LENIU_CODE_ACCOUNT_PAY(128, "中国银行-小牛二维码账户支付"),
   BOC_LENIU_CARD_ACCOUNT_PAY(129, "中国银行-小牛刷卡账户支付"),
   BOC_LENIU_FACE_ACCOUNT_PAY(130, "中国银行-小牛刷脸账户支付"),
   CIB_DCEP_CONTRACT(131, "数字人民币协议免密支付"),
   TCRCB_PAY_H5(133, "太仓农商行支付"),
   FUIOU_PAY_H5(132, "富友支付"),
   ACC_BNJ_PAY(134, "南京银行免密支付"),
   WECHAT_CARD_QR_CODE(135, "腾讯微卡电子码"),
   WECHAT_CARD_H5(136, "腾讯微卡在线支付"),
   CCB_PAY_H5(137, "建设银行H5支付"),
   KSRCB_PAY_CODE(138, "昆山农商行付款码支付"),
   CIB_DCEP_AUTH(139, "兴业银行数币密码支付"),
   SZRCB_PAY_H5(140, "苏州农商行支付"),
   BNJ_WECHAT_MINI(141, "微信小程序南京银行免密支付"),
   NBCB_SETTLEMENT_PAY(142, "宁波银行结算支付"),
   ABC_NATIVE(143, "农行页面下单"),
   ABC_POS_MACHINE_PAY(144, "农行POS机刷卡支付"),
   BNJ_H5_PAY(145, "南京银行H5支付"),
   ABC_PAY_H5(146, "农行H5支付"),
   ALI_ENTERPRISE_FACE(147, "支付宝企业刷脸"),
   ALI_ENTERPRISE_QRCODE(148, "支付宝企业扫码"),
   ALI_ENTERPRISE_WITHHOLD(149, "支付宝企业免密支付"),
   ACC_SCAN(150, "收款码（账户）"),
   ALI_SCAN(151, "收款码（支付宝）"),
   WECHAT_SCAN(152, "收款码（微信）"),
   ECITIC_H5_WECHAT_PAY(153, "微信支付(中信)"),
   ECITIC_H5_UNCONSCIOUS_PAY(154, "中信无感支付"),
   ABC_PAY_H5_WECHAT(155, "农行H5微信支付"),
   ABC_PAY_H5_ALI(156, "农行H5支付宝支付"),
   DIANDI_PAY_H5(157, "点滴支付H5支付"),
   HMS_CAMPUS_CODE(158, "银联园区二维码支付"),
   CIB_NATIVE(159, "兴业银行客户端支付"),
   UMS_ENTRUST_PAY(160, "云闪付授权支付"),
   HUAGENG_WECHAT_PAY(161, "华耕微信收款"),
   HUAGENG_ALI_PAY(162, "华耕支付宝收款"),
   HUAGENG_SUBSIDY_PAY(163, "华耕补贴消费"),
   HUAGENG_POLYMERIZE_PAY(164, "华耕聚合收款"),
   HUAGENG_CASH_PAY(165, "华耕手填现金"),
   HUAGENG_SIGNING_PAY(166, "华耕手填签单"),
   HUAGENG_COUPON_PAY(167, "华耕手填餐券"),
   SODEXO_QRCODE(168, "索迪斯二维码支付"),
   TC_SSC_CARD_PAY(169, "太仓社保卡支付"),
   CMB_H5_CARD_PAY(170, "招行一网通支付"),
   ZY_WECHAT_PAY(171, "正元微信支付"),
   ZY_ALI_PAY(172, "正元支付宝支付"),
   ZY_ACC_PAY(173, "正元账户支付"),
   ZY_CCB_PAY(174, "正元建行支付"),
   ICBC_JFT_H5(175, "工行聚富通支付"),
   ABC_WECHAT_BRIDGE(176, "微信支付(农行)");

   private final Integer key;
   private final String desc;
   private static final Map<Integer, String> keyMap = (Map)Arrays.stream(values()).collect(Collectors.toMap(PayTypeEnum::getKey, PayTypeEnum::getDesc, (k1, k2) -> {
      return k2;
   }));

   private PayTypeEnum(Integer key, String desc) {
      this.key = key;
      this.desc = desc;
   }

   public static String getDesc(Integer key) {
      return (String)keyMap.getOrDefault(key, "");
   }

   public static PayTypeEnum getEnum(Integer key) {
      PayTypeEnum[] var1 = values();
      int var2 = var1.length;

      for(int var3 = 0; var3 < var2; ++var3) {
         PayTypeEnum temp = var1[var3];
         if (temp.getKey().equals(key)) {
            return temp;
         }
      }

      return null;
   }

   public static List<Map<String, Object>> getAllEnumsList() {
      PayTypeEnum[] payTypeEnums = values();
      List<Map<String, Object>> payTypeList = new ArrayList();
      PayTypeEnum[] var2 = payTypeEnums;
      int var3 = payTypeEnums.length;

      for(int var4 = 0; var4 < var3; ++var4) {
         PayTypeEnum payTypeEnum = var2[var4];
         Map<String, Object> payTypeMap = new HashMap();
         payTypeMap.put("key", payTypeEnum.getKey());
         payTypeMap.put("value", payTypeEnum.getDesc());
         payTypeList.add(payTypeMap);
      }

      return payTypeList;
   }

   public static boolean isAlipayChannel(Integer payType) {
      return CollUtil.toList(new Integer[]{ALI_QRCODE.getKey(), ALI_FACE.getKey(), ALI_NATIVE.getKey(), ALI_APP_PAY.getKey(), ALI_DING_PAY.getKey(), ALI_PAY_WITHHOLD.getKey(), MIXTURE_PAY_ALI_QRCODE.getKey(), MIXTURE_PAY_ALI_NATIVE.getKey(), ALI_ENTERPRISE_FACE.getKey(), ALI_ENTERPRISE_QRCODE.getKey(), ALI_ENTERPRISE_WITHHOLD.getKey(), ALI_SCAN.getKey()}).contains(payType);
   }

   public static boolean isWechatChannel(Integer payType) {
      return CollUtil.toList(new Integer[]{WECHAT_QRCODE.getKey(), WECHAT_FACE.getKey(), WECHAT_NATIVE.getKey(), WECHAT_WITHHOLD.getKey(), MIXTURE_PAY_WECHAT_QRCODE.getKey(), MIXTURE_PAY_WECHAT_NATIVE.getKey(), WECHAT_CARD_QR_CODE.getKey()}).contains(payType);
   }

   public static boolean isOtherChannel(Integer payType) {
      return CASH.getKey().equals(payType) || OFFLINE_ALI_QRCODE.getKey().equals(payType) || OFFLINE_WECHAT_QRCODE.getKey().equals(payType) || OTHER_PAY.getKey().equals(payType) || THIRD_DEVICE.getKey().equals(payType);
   }

   @Override
   public Integer getKey() {
      return this.key;
   }

   @Override
   public String getDesc() {
      return this.desc;
   }

   public static class ExcelConvertor extends LeExcelFieldConvertor<PayTypeEnum> {
      public ExcelConvertor() {
         super(PayTypeEnum.class);
      }
   }
}
