Bläddra i källkod

新增中国银行收款短信识别

zhijiezhao 2 år sedan
förälder
incheckning
b35ccdeba8

+ 44 - 19
src/main/java/com/caimei365/order/service/impl/ReceiptServiceImpl.java

@@ -1741,7 +1741,7 @@ public class ReceiptServiceImpl implements ReceiptService {
                             String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
 
                             //推送信息中心-交易物流
-                            MessageCenter messageCenter=new MessageCenter();
+                            MessageCenter messageCenter = new MessageCenter();
                             messageCenter.setShopID(null);
                             messageCenter.setClubID(order.getClubId());
                             messageCenter.setUserType(1);
@@ -2069,6 +2069,7 @@ public class ReceiptServiceImpl implements ReceiptService {
      *                【中信银行】您尾号0897的中信卡于03月14日16:01,支付宝存入人民币5994.06元,当前余额为人民币1000000.00元。
      *                【中信银行】您尾号0897的中信卡于05月29日14:42,二代支付存入人民币10000.00元,当前余额为人民币13871.67元。
      *                您的账户2400于07月21日11:13收入人民币1000.79元,余额1000.79元。【华夏银行】
+     *                您公司账户9452,于08231217收入(网银网上支付)人民币1000.00当前余额1000.19,对方为广州市埃墨莉素生物科技有限公司(账号*0659)(我行吸收的本外币存款依照《存款保险条例》受到保护)【中国银行】
      */
     private ResponseJson<ReceiptVo> identifyMessage(String message) throws Exception {
         if (message.contains("银行")) {
@@ -2095,7 +2096,7 @@ public class ReceiptServiceImpl implements ReceiptService {
                 if (message.contains("支付宝")) {
                     receivableDesc += "-支付宝";
                 }
-            } else if (receivableDesc.contains("广发银行") || receivableDesc.contains("建设银行") || receivableDesc.contains("华夏银行")) {
+            } else if (receivableDesc.contains("广发银行") || receivableDesc.contains("建设银行") || receivableDesc.contains("华夏银行") || receivableDesc.contains("中国银行")) {
                 // 匹配的第一组数字为银行卡尾号
                 Matcher matcherBank = PATTERN_NUMBER.matcher(message);
                 if (matcherBank.find()) {
@@ -2139,13 +2140,21 @@ public class ReceiptServiceImpl implements ReceiptService {
                 } else if (difference < 0) {
                     time = DateUtils.format(DateUtils.addMonth(DateUtils.parseDate(time), -1), "yyyy-MM-dd HH:mm:ss");
                 }
-            } else if(Arrays.asList(22).contains(typeId)){
+            } else if (Arrays.asList(22).contains(typeId)) {
                 time = year + "-" + contentTime.get(1) + "-" + contentTime.get(2) + " " + contentTime.get(3);
                 int difference = DateUtils.differentDays(time);
                 if (difference < 0) {
                     time = Integer.parseInt(year) - 1 + "-" + contentTime.get(1) + "-" + contentTime.get(2) + " " + contentTime.get(3);
                 }
-            }else {
+            } else if (Arrays.asList(23).contains(typeId)) {
+                String s = contentTime.get(1);
+                String s1 = s.substring(0, 2) + "-" + s.substring(2, 4) + " " + s.substring(4, 6) + ":" + s.substring(6, 8) + ":" + "00";
+                time = year + "-" + s1;
+                int difference = DateUtils.differentDays(time);
+                if (difference < 0) {
+                    time = Integer.parseInt(year) + "-" + s1;
+                }
+            } else {
                 time = year + "-" + contentTime.get(1) + "-" + contentTime.get(2) + " " + contentTime.get(3) + ":" + "00";
                 int difference = DateUtils.differentDays(time);
                 if (difference < 0) {
@@ -2166,6 +2175,14 @@ public class ReceiptServiceImpl implements ReceiptService {
                     int index2 = message.indexOf("元", index);
                     money = Double.parseDouble(message.substring(index + 4, index2));
                 }
+            } else if (23 == typeId) {
+                if (message.contains("人民币")) {
+                    index = message.indexOf("人民币");
+                    int index2 = message.indexOf("当前余额", index);
+                    money = Double.parseDouble(message.substring(index + 3, index2));
+                } else {
+                    throw new Exception("短信识别错误!");
+                }
             } else {
                 if (message.contains("入人民币")) {
                     index = message.indexOf("入人民币");
@@ -2211,26 +2228,34 @@ public class ReceiptServiceImpl implements ReceiptService {
     }
 
     /**
-     *    隐藏短信余额
-     *
-     *  贵公司尾号7297的账户5月23日15时30分往来款收入人民币1800.00元,余额7055.50元。对方户名:哈尔滨爱丽达医疗美容管理有限公司爱建医疗美容诊所。[建设银行]
-     *  【广发银行】尊敬的客户,贵司账号后四位0115 的账户于08日13:55 收入一笔方芳尾数为8067的账户转账1850.00元,手续费0.00元。账户余额:1000000.00元。
-     *  【广发银行】您末四位为0115的企业账户于12日16:09收入人民币5000.00元(深圳同城)。账户余额:8907.21元。
-     *  【中信银行】贵公司尾号7172的中信账号于03月15日17:25,二代支付存入人民币3132.30元,当前余额为人民币4373.07元。
-     *  【中信银行】您尾号0897的中信卡于03月06日11:44,存入人民币2358.00元,当前余额为人民币1000000.00元。
-     *  【中信银行】您尾号0897的中信卡于03月19日13:37,财付通快捷支付存入人民币11348.45元,当前余额为人民币1000000.00元。
-     *  【中信银行】您尾号0897的中信卡于03月14日16:01,支付宝存入人民币5994.06元,当前余额为人民币1000000.00元。
-     *  【中信银行】您尾号0897的中信卡于05月29日14:42,二代支付存入人民币10000.00元,当前余额为人民币13871.67元。
-     *  您的账户2400于07月21日11:13收入人民币1000.79元,余额1000.79元。【华夏银行】
+     * 隐藏短信余额
+     * <p>
+     * 贵公司尾号7297的账户5月23日15时30分往来款收入人民币1800.00元,余额7055.50元。对方户名:哈尔滨爱丽达医疗美容管理有限公司爱建医疗美容诊所。[建设银行]
+     * 【广发银行】尊敬的客户,贵司账号后四位0115 的账户于08日13:55 收入一笔方芳尾数为8067的账户转账1850.00元,手续费0.00元。账户余额:1000000.00元。
+     * 【广发银行】您末四位为0115的企业账户于12日16:09收入人民币5000.00元(深圳同城)。账户余额:8907.21元。
+     * 【中信银行】贵公司尾号7172的中信账号于03月15日17:25,二代支付存入人民币3132.30元,当前余额为人民币4373.07元。
+     * 【中信银行】您尾号0897的中信卡于03月06日11:44,存入人民币2358.00元,当前余额为人民币1000000.00元。
+     * 【中信银行】您尾号0897的中信卡于03月19日13:37,财付通快捷支付存入人民币11348.45元,当前余额为人民币1000000.00元。
+     * 【中信银行】您尾号0897的中信卡于03月14日16:01,支付宝存入人民币5994.06元,当前余额为人民币1000000.00元。
+     * 【中信银行】您尾号0897的中信卡于05月29日14:42,二代支付存入人民币10000.00元,当前余额为人民币13871.67元。
+     * 您的账户2400于07月21日11:13收入人民币1000.79元,余额1000.79元。【华夏银行】
+     * 您公司账户9452,于08231217收入(网银网上支付)人民币1000.00当前余额1000.19,对方为广州市埃墨莉素生物科技有限公司(账号*0659)(我行吸收的本外币存款依照《存款保险条例》受到保护)【中国银行】
      */
     private String hiddenBalance(String message) {
         message = message.replace(":", ":").trim();
         int index = message.indexOf("余额");
         if (index != -1) {
-            int index2 = message.indexOf("元", index);
-            String text1 = message.substring(0, index + 2);
-            String text2 = message.substring(index2);
-            message = text1 + "***" + text2;
+            if (message.contains("中国银行")) {
+                int index2 = message.lastIndexOf(",");
+                String text1 = message.substring(0, index + 2);
+                String text2 = message.substring(index2);
+                message = text1 + "***" + text2;
+            } else {
+                int index2 = message.indexOf("元", index);
+                String text1 = message.substring(0, index + 2);
+                String text2 = message.substring(index2);
+                message = text1 + "***" + text2;
+            }
         }
         return message;
     }

+ 30 - 1
src/test/java/com/caimei365/order/OrderApplicationTests.java

@@ -13,6 +13,8 @@
 //import java.io.InputStream;
 //import java.lang.reflect.Type;
 //import java.util.*;
+//import java.util.regex.Matcher;
+//import java.util.regex.Pattern;
 //import java.util.stream.Collectors;
 //
 ///**
@@ -26,6 +28,9 @@
 ////    @Resource
 ////    private SubmitMapper submitMapper;
 //
+//    private static final List<Integer> TIP_FEE_TYPE = Arrays.asList(4, 5, 6, 11);
+//    private static final Pattern PATTERN_NUMBER = Pattern.compile("[\\*0-9\\.:]+");
+//    private static final Pattern PATTERN_ORDER = Pattern.compile("#(.*?)#");
 //
 //    @Test
 //    void contextLoads() throws IOException {
@@ -38,6 +43,30 @@
 ////        System.out.println(System.currentTimeMillis());
 ////        System.out.println(System.currentTimeMillis()/1000);
 ////        System.out.println(Math.floor(MathUtil.div(100, 1.7).doubleValue()));
-//
+//        String message = "您公司账户9452,于08231217收入(网银网上支付)人民币1000.00当前余额***,对方为广州市埃墨莉素生物科技有限公司(账号*0659)(我行吸收的本外币存款依照《存款保险条例》受到保护)【中国银行】";
+////        Matcher matcherBank = PATTERN_NUMBER.matcher(message);
+////        ArrayList<String> strings = new ArrayList<>();
+////        while (matcherBank.find()){
+////            strings.add(matcherBank.group());
+////        }
+////        System.out.println("数组-------------》"+strings.toString());
+////        String substring = strings.get(1).substring(0, 2);
+////        System.out.println("leng"substring.length());
+////        String substring1 = strings.get(1).substring(2, 4);
+////            String substring2 = strings.get(1).substring(4, 6);
+////            String substring3 = strings.get(1).substring(6, 8);
+////            System.out.println(substring+"-"+substring1+"-"+substring2+"-"+substring3);
+////        int index = message.indexOf("余额");
+////        int index2 = message.lastIndexOf(",");
+////        String text1 = message.substring(0, index+2);
+////        String text2 = message.substring(index2);
+////        message = text1 + "***" + text2;
+////        System.out.println(message);
+//        int index = message.indexOf("人民币");
+//        int index2 = message.indexOf("当前余额", index);
+//        String substring = message.substring(index + 3, index2);
+//        System.out.println("substring----------------------->"+substring);
+//        Double money = Double.parseDouble(substring);
+//        System.out.println("money----------------------->"+money);
 //    }
 //}