Bladeren bron

快跑者将备注的换行符转成空格

liu 2 weken geleden
bovenliggende
commit
1819a33560

+ 22 - 9
src/main/java/com/sqx/modules/callBack/controller/CallBackController.java

@@ -172,6 +172,7 @@ public class CallBackController {
 
     @GetMapping("/open/test")
     public Result test(String orderNumber){
+        log.info("订单号:{}",orderNumber);
         TbOrder order = appOrderService.getOne(new QueryWrapper<TbOrder>().eq("order_number", orderNumber));
 
         log.info("第一次创建快跑者订单");
@@ -209,11 +210,23 @@ public class CallBackController {
     }
 
     public static void main(String[] args) {
-        StringBuilder append = new StringBuilder().append("爆料鸡排\t(藤椒风味酱-香辣花生撒粉)约120克介意慎拍");
-        String s1= append.toString().replaceAll("\\t", " ");
-        String s="爆料鸡排\t(藤椒风味酱-香辣花生撒粉)约120克介意慎拍".replaceAll("\\t", " ");
-        System.out.println("s = " + s);
-        System.out.println("append = " + s1);
+//        StringBuilder append = new StringBuilder().append("爆料鸡排\t(藤椒风味酱-香辣花生撒粉)约120克介意慎拍");
+//        String s1= append.toString().replaceAll("\\t", " ");
+//        String s="爆料鸡排\t(藤椒风味酱-香辣花生撒粉)约120克介意慎拍".replaceAll("\\t", " ");
+//        System.out.println("s = " + s);
+//        System.out.println("append = " + s1);
+        String remark="素:土豆,方便面,金针菇,荤:肉\t\n" +
+                "饼,鸡排,荷包蛋,波波肠";
+        System.out.println("remark = " + remark);
+        remark=remark.replaceAll("\\r\\n|\\n|\\r", " ");
+        remark=remark.replaceAll("\\\\", " ");
+        System.out.println("remark = " + remark);
+        try {
+            remark = URLEncoder.encode(remark, "UTF-8");
+            System.out.println("remark = " + remark);
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e);
+        }
     }
 
     public String creatSpeedRunnerOrder(TbOrder tbOrder){
@@ -313,7 +326,7 @@ public class CallBackController {
         String remark = tbOrder.getRemark();
         if (ObjectUtils.isNotEmpty(remark)) {
             try {
-                remark=remark.replaceAll("\\r\\n|\\n|\\r", " ");
+                remark=remark.replaceAll("\\r\\n|\\n|\\r|\\t", " ");
                 remark=remark.replaceAll("\\\\", " ");
                 remark = URLEncoder.encode(remark, "UTF-8");
             } catch (UnsupportedEncodingException e) {
@@ -351,7 +364,7 @@ public class CallBackController {
         String userName = address.getUserName();
         if (ObjectUtils.isNotEmpty(userName)) {
             try {
-                userName=userName.replaceAll("\\r\\n|\\n|\\r", " ");
+                userName=userName.replaceAll("\\r\\n|\\n|\\r|\\t", " ");
                 userName = URLEncoder.encode(userName, "UTF-8");
             } catch (UnsupportedEncodingException e) {
                 throw new RuntimeException(e);
@@ -464,7 +477,7 @@ public class CallBackController {
 
         String remark2 = tbOrder.getRemark();
         if (ObjectUtils.isNotEmpty(remark2)) {
-            remark2=remark2.replaceAll("\\r\\n|\\n|\\r", " ");
+            remark2=remark2.replaceAll("\\r\\n|\\n|\\r|\\t", " ");
             remark2=remark2.replaceAll("\\\\", " ");
             // 方法2:使用Java 8+的\\R正则表达式;
         }
@@ -485,7 +498,7 @@ public class CallBackController {
 //        String userName = address.getUserName();
         String userName1 = address.getUserName();
         if (ObjectUtils.isNotEmpty(userName1)) {
-            userName1=userName1.replaceAll("\\r\\n|\\n|\\r", " ");
+            userName1=userName1.replaceAll("\\r\\n|\\n|\\r|\\t", " ");
         }
         body2.put("customer_name", userName1);
 

+ 4 - 4
src/main/java/com/sqx/modules/errand/service/impl/TbIndentServiceImpl.java

@@ -487,7 +487,7 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
         String remark = tbOrder.getRemark();
         if (ObjectUtils.isNotEmpty(remark)) {
             try {
-                remark=remark.replaceAll("\\r\\n|\\n|\\r", " ");
+                remark=remark.replaceAll("\\r\\n|\\n|\\r|\\t", " ");
                 remark=remark.replaceAll("\\\\", " ");
                 remark = URLEncoder.encode(remark, "UTF-8");
             } catch (UnsupportedEncodingException e) {
@@ -525,7 +525,7 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
         String userName = address.getUserName();
         if (ObjectUtils.isNotEmpty(userName)) {
             try {
-                userName=userName.replaceAll("\\r\\n|\\n|\\r", " ");
+                userName=userName.replaceAll("\\r\\n|\\n|\\r|\\t", " ");
                 userName = URLEncoder.encode(userName, "UTF-8");
             } catch (UnsupportedEncodingException e) {
                 throw new RuntimeException(e);
@@ -640,7 +640,7 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
 
         String remark2 = tbOrder.getRemark();
         if (ObjectUtils.isNotEmpty(remark2)) {
-            remark2=remark2.replaceAll("\\r\\n|\\n|\\r", " ");
+            remark2=remark2.replaceAll("\\r\\n|\\n|\\r|\\t", " ");
             remark2=remark2.replaceAll("\\\\", " ");
             // 方法2:使用Java 8+的\\R正则表达式;
         }
@@ -661,7 +661,7 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
 //        String userName = address.getUserName();
         String userName1 = address.getUserName();
         if (ObjectUtils.isNotEmpty(userName1)) {
-            userName1=userName1.replaceAll("\\r\\n|\\n|\\r", " ");
+            userName1=userName1.replaceAll("\\r\\n|\\n|\\r|\\t", " ");
         }
         body2.put("customer_name", userName1);
 

+ 1 - 1
src/test/java/OrderTest.java

@@ -325,7 +325,7 @@ public class OrderTest {
         RhtQrcodePayApi qrcodePay = new RhtQrcodePayApi(wechatMchConfig.getMchId(), wechatMchConfig.getMchKey(), "https://api.ekbuyclub.com");
 
         String orderNumberStr =
-                "118702260527006274593720"
+                "118702260608006383131158"
                 ;
         for (String orderNumber : orderNumberStr.split(",")) {
             QrcodeQueryRequestBean qqrb = new QrcodeQueryRequestBean();