From a88f865b6ff515dccdc58b5cb52aca4a41e82906 Mon Sep 17 00:00:00 2001 From: wangshuai Date: Tue, 23 Jul 2024 16:16:38 +0800 Subject: [PATCH] =?UTF-8?q?1=EF=BC=9B=E7=9F=AD=E4=BF=A1=E5=85=AC=E7=94=A8?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=8A=A0=E9=BB=98=E8=AE=A4=E8=AF=9D=E6=9C=AF?= =?UTF-8?q?=EF=BC=88=E5=AD=97=E5=85=B8=E4=B8=AD=E9=85=8D=E7=BD=AE=EF=BC=89?= =?UTF-8?q?=202=EF=BC=9B=E9=A5=BF=E4=BA=86=E4=B9=88=E6=8E=A8=E9=80=81URL?= =?UTF-8?q?=E5=9B=9E=E8=B0=83URL=203=EF=BC=9B=E5=BA=97=E9=93=BA=E5=80=92?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/controller/ElemeController.java | 24 ++++++ .../framework/config/SecurityConfig.java | 1 + .../business/service/impl/AiServiceImpl.java | 76 ++++++++++++------- .../mapper/business/BusStoreInfoMapper.xml | 1 + 4 files changed, 76 insertions(+), 26 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/business/controller/ElemeController.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/business/controller/ElemeController.java b/ruoyi-admin/src/main/java/com/ruoyi/business/controller/ElemeController.java new file mode 100644 index 0000000..5b746bb --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/business/controller/ElemeController.java @@ -0,0 +1,24 @@ +package com.ruoyi.business.controller; + +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/eleme") +public class ElemeController { + + + @GetMapping("/message_receive") + public String msg() { + return "{\"message\":\"ok\"}"; + } + + + @GetMapping("/accredit") + public String accredit() { + return "{\"message\":\"ok\"}"; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index d2991ce..50bd6ab 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -136,6 +136,7 @@ public class SecurityConfig .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() .antMatchers(HttpMethod.POST,"/mt/cookies").permitAll() .antMatchers("/test/**").permitAll() + .antMatchers("/eleme/message_receive").permitAll() // .antMatchers("/mt/**").permitAll() // 除上面外的所有请求全部需要鉴权认证 diff --git a/ruoyi-system/src/main/java/com/ruoyi/business/service/impl/AiServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/business/service/impl/AiServiceImpl.java index 3bb8b2f..b1fbbbc 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/business/service/impl/AiServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/business/service/impl/AiServiceImpl.java @@ -8,6 +8,7 @@ import com.ruoyi.business.mapper.BusReturnVisitInfoMapper; import com.ruoyi.business.service.*; import com.ruoyi.common.config.BusTencentProperties; import com.ruoyi.common.utils.HttpClientUtilT; +import com.ruoyi.system.mapper.SysDictDataMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; @@ -52,6 +53,9 @@ public class AiServiceImpl implements IAiService { @Autowired private BusTencentProperties busTencentProperties; + @Autowired + private SysDictDataMapper sysDictDataMapper; + private String userSn = "SYSUSER|8398f13f3feccef770ee4d465fe22fbf"; private String aiUserSn = "SYSUSER|2665bcca63a2b5c724095fa01dce0470"; @@ -314,30 +318,34 @@ public class AiServiceImpl implements IAiService { } // 话术判断 08:00 10:00 11:30 13:30 18:00 20:00 String content = ""; - LocalTime time1 = LocalTime.of(6, 00, 00); - LocalTime time2 = LocalTime.of(10, 00, 00); - LocalTime time3 = LocalTime.of(14, 00, 00); - LocalTime time4 = LocalTime.of(17, 00, 00); - if (time1.isBefore(orderTime) && orderTime.isBefore(time2)) { - if(busStoreConfigInfo.getContent1()==null){ - continue; + if("AI".equals(busStoreInfo.getMarketingChannels())){ + LocalTime time1 = LocalTime.of(6, 00, 00); + LocalTime time2 = LocalTime.of(10, 00, 00); + LocalTime time3 = LocalTime.of(14, 00, 00); + LocalTime time4 = LocalTime.of(17, 00, 00); + if (time1.isBefore(orderTime) && orderTime.isBefore(time2)) { + if(busStoreConfigInfo.getContent1()==null){ + continue; + } + content = busStoreConfigInfo.getContent1(); + } else if (time2.isBefore(orderTime) && orderTime.isBefore(time3)) { + if(busStoreConfigInfo.getContent2()==null){ + continue; + } + content = busStoreConfigInfo.getContent2(); + } else if (time3.isBefore(orderTime) && orderTime.isBefore(time4)) { + if(busStoreConfigInfo.getContent3()==null){ + continue; + } + content = busStoreConfigInfo.getContent3(); + } else { + if(busStoreConfigInfo.getContent4()==null){ + continue; + } + content = busStoreConfigInfo.getContent4(); } - content = busStoreConfigInfo.getContent1(); - } else if (time2.isBefore(orderTime) && orderTime.isBefore(time3)) { - if(busStoreConfigInfo.getContent2()==null){ - continue; - } - content = busStoreConfigInfo.getContent2(); - } else if (time3.isBefore(orderTime) && orderTime.isBefore(time4)) { - if(busStoreConfigInfo.getContent3()==null){ - continue; - } - content = busStoreConfigInfo.getContent3(); - } else { - if(busStoreConfigInfo.getContent4()==null){ - continue; - } - content = busStoreConfigInfo.getContent4(); + }else if("sms".equals(busStoreInfo.getMarketingChannels())){ + content = sysDictDataMapper.selectDictLabel("bus_default_sms_script","default_script"); } if(busReturnVisitInfoMapper.returnVisitInfoList(busOrderInfo.getPrivcyPhone()).size()>0){ continue; @@ -366,7 +374,7 @@ public class AiServiceImpl implements IAiService { if("AI".equals(busStoreInfo.getMarketingChannels())){ sendAiTask(content,busOrderInfo); }else if("sms".equals(busStoreInfo.getMarketingChannels())){ - sendSmsTask(busOrderInfo); + sendSmsTask(content,busOrderInfo); }else{ sendAiTask(content,busOrderInfo); } @@ -397,8 +405,24 @@ public class AiServiceImpl implements IAiService { } } - private void sendSmsTask(BusOrderInfo busOrderInfo) { - + private synchronized void sendSmsTask(String content, BusOrderInfo busOrderInfo) { + try { + String phoneNo = busOrderInfo.getPrivcyPhone().split(",")[0];//#分机号# + content = content.replaceAll("#分机号#",busOrderInfo.getPrivcyPhone().split(",")[1]); +// String ss = "{\"taskId\":\"202203170025799000001\",\"message\":\"success\",\"timestamp\":1647481716818,\"status\":\"00\",\"tag\":\"\"}"; +// com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSON.parseObject(ss); + com.alibaba.fastjson.JSONObject jsonObject = busTencentProperties.smsCredential(phoneNo,content); + System.out.println(jsonObject); + if("00".equals(jsonObject.getString("status"))){ + //定时任务15天之前的删除记录 todo + BusFifteenInfo fifteenInfo = new BusFifteenInfo(); + fifteenInfo.setCustomId(busOrderInfo.getCustomId()); + fifteenInfo.setLastVisitTime(LocalDateTime.now().toString()); + fifteenInfoService.insertBusFifteenInfo(fifteenInfo); + } + } catch (Exception e) { + System.out.println("建立sendSmsTask错误: " + e.getMessage()); + } } private void addAiTaskTest(String apiKey, String content, BusOrderInfo busOrderInfo) { diff --git a/ruoyi-system/src/main/resources/mapper/business/BusStoreInfoMapper.xml b/ruoyi-system/src/main/resources/mapper/business/BusStoreInfoMapper.xml index aae64f3..d41d6b8 100644 --- a/ruoyi-system/src/main/resources/mapper/business/BusStoreInfoMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/business/BusStoreInfoMapper.xml @@ -95,6 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and sale_bind_time = #{saleBindTime} and bind_time between #{beginTime} and #{endTime} + ORDER BY bind_time desc