Pārlūkot izejas kodu

转发服务优化,APP相关优化

yjwang 6 dienas atpakaļ
vecāks
revīzija
1e5eddee33

+ 21 - 0
fs-company-app/src/main/java/com/fs/app/controller/FsUserCourseVideoController.java

@@ -10,7 +10,9 @@ import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.ResponseResult;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.StringUtils;
+import com.fs.company.domain.Company;
 import com.fs.company.domain.CompanyUser;
+import com.fs.company.service.ICompanyService;
 import com.fs.company.service.ICompanyUserService;
 import com.fs.course.config.CourseConfig;
 import com.fs.course.domain.FsUserCoursePeriod;
@@ -39,6 +41,7 @@ import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -57,6 +60,9 @@ public class FsUserCourseVideoController extends AppBaseController {
     @Autowired
     private IFsUserCourseVideoService fsUserCourseVideoService;
 
+    @Autowired
+    private ICompanyService iCompanyService;
+
     @Autowired
     private IFsUserCourseService fsUserCourseService;
 
@@ -276,6 +282,21 @@ public class FsUserCourseVideoController extends AppBaseController {
         return ResponseResult.ok(courseLinkService.getGotoWxAppLink(linkStr,appid));
     }
 
+    @GetMapping("/getGotoAppLink")
+    @ApiOperation("获取跳转微信小程序的链接地址")
+    public ResponseResult<String> getGotoWxAppLink(String linkStr, Long companyId) {
+        Company company = iCompanyService.selectCompanyById(companyId);
+        String appid = null;
+        if (CollectionUtils.isNotEmpty(company.getMiniAppMaster())){
+            appid = company.getMiniAppMaster().get(0);
+        }else if (CollectionUtils.isNotEmpty(company.getMiniAppServer())){
+            appid = company.getMiniAppServer().get(0);
+        }else {
+            return ResponseResult.fail(500,"请在后台配置主备小程序!");
+        }
+        return ResponseResult.ok(courseLinkService.getGotoWxAppLink(linkStr,appid));
+    }
+
     @ApiOperation("会员批量发送课程消息")
     @PostMapping("/batchSendCourse")
     public OpenImResponseDTO batchSendCourse(@RequestBody BatchSendCourseDTO batchSendCourseDTO) throws JsonProcessingException {

+ 206 - 0
fs-ipad-task/src/main/java/com/fs/app/task/SendAppMsg.java

@@ -0,0 +1,206 @@
+package com.fs.app.task;
+
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.fs.app.service.IpadSendServer;
+import com.fs.common.core.redis.RedisCacheT;
+import com.fs.common.utils.PubFun;
+import com.fs.qw.domain.QwIpadServer;
+import com.fs.qw.domain.QwUser;
+import com.fs.qw.mapper.QwIpadServerMapper;
+import com.fs.qw.mapper.QwPushCountMapper;
+import com.fs.qw.mapper.QwRestrictionPushRecordMapper;
+import com.fs.qw.mapper.QwUserMapper;
+import com.fs.qw.service.impl.AsyncSopTestService;
+import com.fs.qw.vo.QwSopCourseFinishTempSetting;
+import com.fs.qw.vo.QwSopTempSetting;
+import com.fs.sop.domain.QwSopLogs;
+import com.fs.sop.mapper.QwSopLogsMapper;
+import com.fs.sop.service.IQwSopLogsService;
+import com.fs.system.mapper.SysConfigMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+@Component
+@Slf4j
+public class SendAppMsg {
+
+    private final QwUserMapper qwUserMapper;
+    private final QwSopLogsMapper qwSopLogsMapper;
+    private final IpadSendServer sendServer;
+    private final SysConfigMapper sysConfigMapper;
+    private final IQwSopLogsService qwSopLogsService;
+    private final AsyncSopTestService asyncSopTestService;
+    private final QwIpadServerMapper qwIpadServerMapper;
+    private final RedisCacheT<Long> redisCache;
+    private final QwPushCountMapper qwPushCountMapper;
+    private final QwRestrictionPushRecordMapper qwRestrictionPushRecordMapper;
+    @Value("${group-no}")
+    private String groupNo;
+    private final List<QwUser> qwUserList = Collections.synchronizedList(new ArrayList<>());
+    private final Map<Long, Long> qwMap = new ConcurrentHashMap<>();
+
+    @Autowired
+    @Qualifier("customThreadPool")
+    private ThreadPoolTaskExecutor customThreadPool;
+
+
+    public SendAppMsg(QwUserMapper qwUserMapper, QwSopLogsMapper qwSopLogsMapper, IpadSendServer sendServer, SysConfigMapper sysConfigMapper, IQwSopLogsService qwSopLogsService, AsyncSopTestService asyncSopTestService, QwIpadServerMapper qwIpadServerMapper, RedisCacheT<Long> redisCache, QwPushCountMapper qwPushCountMapper, QwRestrictionPushRecordMapper qwRestrictionPushRecordMapper) {
+        this.qwUserMapper = qwUserMapper;
+        this.qwSopLogsMapper = qwSopLogsMapper;
+        this.sendServer = sendServer;
+        this.sysConfigMapper = sysConfigMapper;
+        this.qwSopLogsService = qwSopLogsService;
+        this.asyncSopTestService = asyncSopTestService;
+        this.qwIpadServerMapper = qwIpadServerMapper;
+        this.redisCache = redisCache;
+        this.qwPushCountMapper = qwPushCountMapper;
+        this.qwRestrictionPushRecordMapper = qwRestrictionPushRecordMapper;
+    }
+
+    private List<QwUser> getQwUserList() {
+        if (qwUserList.isEmpty()) {
+            List<QwIpadServer> serverList = qwIpadServerMapper.selectList(new QueryWrapper<QwIpadServer>().eq("group_no", groupNo));
+            if (serverList.isEmpty()) {
+                return new ArrayList<>();
+            }
+            List<Long> serverIds = PubFun.listToNewList(serverList, QwIpadServer::getId);
+            List<QwUser> qwUsers = qwUserMapper.selectList(new QueryWrapper<QwUser>().eq("send_msg_type", 1).eq("server_status", 1).eq("ipad_status", 0).in("server_id", serverIds));
+            qwUserList.addAll(qwUsers);
+        }
+        return qwUserList;
+    }
+
+
+    @Scheduled(fixedRate = 50000) // 每50秒执行一次
+    public void refulsQwUserList() {
+        qwUserList.clear();
+    }
+
+    @Scheduled(fixedDelay = 20000) // 每20秒执行一次
+    public void sendMsg2() {
+        if (StringUtils.isEmpty(groupNo)) {
+            log.error("corpId为空不执行");
+            return;
+        }
+
+        // 获取 pad 发送的企微
+        getQwUserList().forEach(e -> {
+            // 如果没有值就执行后面的方法 并且入值
+            qwMap.computeIfAbsent(e.getId(), k -> {
+                // 线程启动
+                CompletableFuture.runAsync(() -> {
+                    try {
+                        log.info("SendAppMsg-开始任务:{}", e.getQwUserName());
+                        // 开始任务
+                        processUser(e);
+                    } catch (Exception exception) {
+                        log.error("发送错误:", exception);
+                    } finally {
+                        log.info("SendAppMsg-删除任务:{}", e.getQwUserName());
+                        qwMap.remove(e.getId());
+                    }
+                }, customThreadPool);
+                return System.currentTimeMillis(); // 占位值
+            });
+        });
+    }
+
+    /**
+     * 发送任务执行
+     *
+     * @param qwUser 发送企微
+     * @param
+     * @param
+     * @param
+     */
+    private void processUser(QwUser qwUser) {
+        long start1 = System.currentTimeMillis();
+        // 获取当前企微待发送记录
+        List<QwSopLogs> qwSopLogList = qwSopLogsMapper.selectByQwUserId(qwUser.getId());
+        if (qwSopLogList.isEmpty()) {
+            return;
+        }
+        // 获取企微用户
+        QwUser user = qwUserMapper.selectById(qwUser.getId());
+        long end1 = System.currentTimeMillis();
+        log.info("SendAppMsg-销售:{}, 消息:{}, 耗时: {}, 时间:{}", user.getQwUserName(), qwSopLogList.size(), end1 - start1, qwMap.get(qwUser.getId()));
+        long start3 = System.currentTimeMillis();
+
+        // 循环代发送消息
+        for (QwSopLogs qwSopLogs : qwSopLogList) {
+            long start2 = System.currentTimeMillis();
+            QwSopCourseFinishTempSetting setting = JSON.parseObject(qwSopLogs.getContentJson(), QwSopCourseFinishTempSetting.class);
+            // 判断消息状态是否满足发送条件
+            if (!sendServer.isSendLogs(qwSopLogs, setting, user)) {
+                continue;
+            }
+            String key = "qw:logs:pad:send:id:" + qwSopLogs.getId();
+            Long time = redisCache.getCacheObject(key);
+            // 判断这个消息有没有进入过发送,如果进了就不要再发了,防止重复发送,,,,, TODO 千万不能动!!!!!
+            if (redisCache.getCacheObject(key) != null) {
+                log.error("{}已有发送:{}, :{}", qwUser.getQwUserName(), qwSopLogs.getId(), time);
+                continue;
+            }
+            List<QwSopTempSetting.Content.Setting> settings = JSON.parseArray(JSON.toJSONString(setting.getSetting()), QwSopTempSetting.Content.Setting.class);
+            List<String> typeList = Arrays.asList("9", "11", "12");
+            if (setting.getType() != 4 && !CollectionUtils.isEmpty(settings) && settings.stream().anyMatch(e -> typeList.contains(e.getContentType()))) {
+                redisCache.setCacheObject(key, System.currentTimeMillis(), 3, TimeUnit.HOURS);
+                // 推送 APP
+                if (!setting.getSetting().isEmpty()) {
+                    try {
+                        settings = JSON.parseArray(JSON.toJSONString(setting.getSetting()), QwSopTempSetting.Content.Setting.class).stream().filter(e -> "9".equals(e.getContentType())).collect(Collectors.toList());
+                        if (!settings.isEmpty()) {
+                            asyncSopTestService.asyncSendMsgBySopAppLinkNormalIM(settings, qwSopLogs.getCorpId(), user.getCompanyUserId(), qwSopLogs.getFsUserId());
+                        }
+                        //app文本消息
+                        log.info("开始发送app文本消息消息开始,消息{},用户{}", JSONObject.toJSONString(settings), user.getQwUserName());
+                        settings = JSON.parseArray(JSON.toJSONString(setting.getSetting()), QwSopTempSetting.Content.Setting.class).stream().filter(e -> "11".equals(e.getContentType())).collect(Collectors.toList());
+
+                        if (!settings.isEmpty()) {
+                            asyncSopTestService.asyncSendMsgBySopAppTxtNormalIM(settings, qwSopLogs.getCorpId(), qwUser.getCompanyUserId(), qwSopLogs.getFsUserId());
+                        }
+                        //app语音消息
+                        log.info("开始发送app语音消息消息开始,消息{},用户{}", JSONObject.toJSONString(settings), user.getQwUserName());
+                        settings = JSON.parseArray(JSON.toJSONString(setting.getSetting()), QwSopTempSetting.Content.Setting.class).stream().filter(e -> "12".equals(e.getContentType())).collect(Collectors.toList());
+                        if (!settings.isEmpty()) {
+                            asyncSopTestService.asyncSendMsgBySopAppMP3NormalIM(settings, qwSopLogs.getCorpId(), qwUser.getCompanyUserId(), qwSopLogs.getFsUserId());
+                        }
+                    } catch (Exception e) {
+                        log.error("推送APP失败", e);
+                    }
+                }
+                qwSopLogs.setSend(true);
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                QwSopLogs updateQwSop = new QwSopLogs();
+                updateQwSop.setId(qwSopLogs.getId());
+                updateQwSop.setReceivingStatus(1L);
+                updateQwSop.setSendStatus(1L);
+                updateQwSop.setRemark("APP发送成功");
+                updateQwSop.setRealSendTime(sdf.format(new Date()));
+                updateQwSop.setContentJson(JSON.toJSONString(setting));
+                long end2 = System.currentTimeMillis();
+                int i = qwSopLogsService.updateQwSopLogsSendType(updateQwSop);
+                log.info("SendAppMsg-销售:{}, 修改条数{}, 发送方消息完成:{}, 耗时: {}", user.getQwUserName(), i, qwSopLogs.getId(), end2 - start2);
+            }
+        }
+        long end3 = System.currentTimeMillis();
+        log.info("SendAppMsg-销售执行完成:{}, 耗时:{}", user.getQwUserName(), end3 - start3);
+    }
+}

+ 35 - 10
fs-ipad-task/src/main/java/com/fs/app/task/SendMsg.java

@@ -267,17 +267,42 @@ public class SendMsg {
                     }
                 }
             }
-            // 推送 APP
-            if (!setting.getSetting().isEmpty()) {
-                new Thread(() -> {
-                    try {
-                        List<QwSopTempSetting.Content.Setting> settings = JSON.parseArray(JSON.toJSONString(setting.getSetting()), QwSopTempSetting.Content.Setting.class).stream().filter(e -> "9".equals(e.getContentType())).collect(Collectors.toList());
-                        asyncSopTestService.asyncSendMsgBySopAppLinkNormalIM(settings, qwSopLogs.getCorpId(), user.getCompanyUserId(), qwSopLogs.getFsUserId());
-                    } catch (Exception e) {
-                        log.error("推送APP失败", e);
-                    }
-                }).start();
+            if (setting.getType() != 4) {
+                // 推送 APP
+                if (!setting.getSetting().isEmpty()) {
+                    new Thread(() -> {
+                        try {
+                            log.info("ipad发送APP------------------>:{}, {}", user.getQwUserName(), qwSopLogs.getId());
+                            List<QwSopTempSetting.Content.Setting> settings = JSON.parseArray(JSON.toJSONString(setting.getSetting()), QwSopTempSetting.Content.Setting.class).stream().filter(e -> "9".equals(e.getContentType())).collect(Collectors.toList());
+                            asyncSopTestService.asyncSendMsgBySopAppLinkNormalIM(settings, qwSopLogs.getCorpId(), user.getCompanyUserId(), qwSopLogs.getFsUserId());
+                            //app文本消息
+                            settings = JSON.parseArray(JSON.toJSONString(setting.getSetting()), QwSopTempSetting.Content.Setting.class).stream().filter(e -> "11".equals(e.getContentType())).collect(Collectors.toList());
+
+                            if (!settings.isEmpty()) {
+                                asyncSopTestService.asyncSendMsgBySopAppTxtNormalIM(settings, qwSopLogs.getCorpId(), qwUser.getCompanyUserId(), qwSopLogs.getFsUserId());
+                            }
+                            //app语音消息
+                            settings = JSON.parseArray(JSON.toJSONString(setting.getSetting()), QwSopTempSetting.Content.Setting.class).stream().filter(e -> "12".equals(e.getContentType())).collect(Collectors.toList());
+                            if (!settings.isEmpty()) {
+                                asyncSopTestService.asyncSendMsgBySopAppMP3NormalIM(settings, qwSopLogs.getCorpId(), qwUser.getCompanyUserId(), qwSopLogs.getFsUserId());
+                            }
+                        } catch (Exception e) {
+                            log.error("推送APP失败", e);
+                        }
+                    }).start();
+                }
             }
+//            // 推送 APP
+//            if (!setting.getSetting().isEmpty()) {
+//                new Thread(() -> {
+//                    try {
+//                        List<QwSopTempSetting.Content.Setting> settings = JSON.parseArray(JSON.toJSONString(setting.getSetting()), QwSopTempSetting.Content.Setting.class).stream().filter(e -> "9".equals(e.getContentType())).collect(Collectors.toList());
+//                        asyncSopTestService.asyncSendMsgBySopAppLinkNormalIM(settings, qwSopLogs.getCorpId(), user.getCompanyUserId(), qwSopLogs.getFsUserId());
+//                    } catch (Exception e) {
+//                        log.error("推送APP失败", e);
+//                    }
+//                }).start();
+//            }
             qwSopLogs.setSend(true);
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             QwSopLogs updateQwSop = new QwSopLogs();

+ 1 - 1
fs-ipad-task/src/main/resources/application.yml

@@ -4,7 +4,7 @@ server:
 # Spring配置
 spring:
   profiles:
-    active: dev
+    active: dev-yjb
 #    active: druid-hdt
 #    active: druid-yzt
 #    active: druid-sxjz

+ 6 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseServiceImpl.java

@@ -15,6 +15,7 @@ import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
+import com.fs.common.utils.CloudHostUtils;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.company.domain.CompanyTag;
@@ -755,6 +756,11 @@ public class FsUserCourseServiceImpl implements IFsUserCourseService
         link.setUpdateTime(calendar.getTime());
         int i = fsCourseLinkMapper.insertFsCourseLink(link);
         if (i > 0){
+            if (CloudHostUtils.hasCloudHostName("中康") || CloudHostUtils.hasCloudHostName("医健宝")){
+                String domainName = getDomainName(param.getCompanyUserId(), config);
+                String sortLink = domainName + link.getRealLink().replace("/#","");
+                return R.ok().put("url", sortLink).put("link", random);
+            }
             String domainName = getDomainName(param.getCompanyUserId(), config);
             String sortLink = domainName + appShortLink + link.getLink();
             return R.ok().put("url", sortLink).put("link", random);

+ 1 - 1
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreCartScrmMapper.java

@@ -96,7 +96,7 @@ public interface FsStoreCartScrmMapper
            "<foreach collection='array' item='id' open='(' separator=',' close=')'>#{id}</foreach>"+
             "</script>"})
     int delCart(Long[] ids);
-    @Select("select c.*,p.cate_id,p.product_name,p.image as product_image,p.temp_id,p.product_type,v.price,v.sku as product_attr_name,v.image as product_attr_image,v.stock,v.cost,v.integral,v.weight,v.volume,v.bar_code,v.group_bar_code,v.brokerage,v.brokerage_two,v.brokerage_three from fs_store_cart_scrm c left join fs_store_product_scrm p on p.product_id=c.product_id left join fs_store_product_attr_value_scrm v on v.id=c.product_attr_value_id where find_in_set(c.id,#{ids})")
+    @Select("select c.*,p.cate_id,p.product_name,p.image as product_image,p.temp_id,p.product_type,v.price,v.sku as product_attr_name,v.image as product_attr_image,v.stock,v.cost,v.integral,v.weight,v.volume,v.bar_code,v.group_bar_code,v.brokerage,v.brokerage_two,v.brokerage_three,ss.store_id,ss.store_name from fs_store_cart_scrm c left join fs_store_product_scrm p on p.product_id=c.product_id left join fs_store_product_attr_value_scrm v on v.id=c.product_attr_value_id LEFT JOIN fs_store_scrm ss ON p.store_id = ss.store_id where find_in_set(c.id,#{ids})")
     List<FsStoreCartQueryVO> selectFsStoreCartListByIds(String ids);
     @Update("update  fs_store_cart_scrm set is_pay=1 where find_in_set(id,#{cartIds})")
     void updateIsPay(String cartIds);

+ 1 - 1
fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderCreateParam.java

@@ -45,7 +45,7 @@ public class FsStoreOrderCreateParam implements Serializable
 
     private String createOrderKey;
 
-    //订单创建类型 1普通订单 2套餐订单 3
+    //订单创建类型 1普通订单 2套餐订单 3单
     private Integer orderCreateType;
 
     private Long customerId;

+ 23 - 3
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -2627,12 +2627,12 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
     @Transactional
     public R addUserCart(long userId, String createOrderKey) {
         String key = redisCache.getCacheObject("createOrderKey:" + createOrderKey);
-        List<FsStoreCartQueryVO> carts = redisCache.getCacheObject("orderCarts:" + createOrderKey);
+        List<FsStoreCartQueryVO> cartsList = redisCache.getCacheObject("orderCarts:" + createOrderKey);
         if (StringUtils.isEmpty(key)) {
             throw new CustomException("订单已过期", 501);
         }
         List<Long> ids = new ArrayList<>();
-        for (FsStoreCartQueryVO vo : carts) {
+        for (FsStoreCartQueryVO vo : cartsList) {
             FsStoreCartScrm storeCart = FsStoreCartScrm.builder()
                     .cartNum(vo.getCartNum())
                     .productAttrValueId(vo.getProductAttrValueId())
@@ -2647,11 +2647,31 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             cartMapper.insertFsStoreCart(storeCart);
             ids.add(storeCart.getId());
         }
+
+        //按店铺分组
+        List<FsStoreCartGroupStoreVO> carts = cartsList.stream()
+                .filter(vo -> vo.getStoreId() != null)
+                .collect(Collectors.groupingBy(
+                        FsStoreCartQueryVO::getStoreId,
+                        LinkedHashMap::new,
+                        Collectors.toList()
+                ))
+                .entrySet().stream()
+                .map(entry -> {
+                    FsStoreCartGroupStoreVO group = new FsStoreCartGroupStoreVO();
+                    FsStoreCartQueryVO firstItem = entry.getValue().get(0);
+                    group.setStoreId(firstItem.getStoreId());
+                    group.setStoreName(firstItem.getStoreName());
+                    group.setCartQueryList(entry.getValue());
+                    return group;
+                })
+                .collect(Collectors.toList());
+
         //删除REDIS
 //        redisCache.deleteObject("createOrderKey:"+createOrderKey);
 //        redisCache.deleteObject("orderCarts:" + createOrderKey);
         String[] idArr = key.split("-");
-        return R.ok().put("cartIds", ids).put("companyId", idArr[0]).put("companyUserId", idArr[1]);
+        return R.ok().put("cartIds", ids).put("companyId", idArr[0]).put("companyUserId", idArr[1]).put("carts", carts);
 
     }
 

+ 2 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreCartGroupStoreVO.java

@@ -7,6 +7,8 @@ import java.util.List;
 
 @Data
 public class FsStoreCartGroupStoreVO {
+    private Long storeId;
     private String storeName;
     private List<FsStoreCartScrmVO> list;
+    private List<FsStoreCartQueryVO> cartQueryList;
 }

+ 5 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreCartQueryVO.java

@@ -65,5 +65,10 @@ import java.math.BigDecimal;
 
     private BigDecimal changePrice;
 
+    //店铺Id
+    private Long storeId;
+
+    //店铺名称
+    private String storeName;
 
 }

+ 8 - 1
fs-service/src/main/java/com/fs/im/dto/OpenImMsgDTO.java

@@ -12,7 +12,7 @@ public class OpenImMsgDTO {
     private String senderNickname;
     private String senderFaceURL;
     private int senderPlatformID;
-    private Content content;
+    private Object content;
     private int contentType;
     private int sessionType;
     private boolean isOnlineOnly;
@@ -28,6 +28,13 @@ public class OpenImMsgDTO {
         private String data;
         private String description;
         private String extension;
+        private String notificationName;
+        private int notificationType;
+        private String text;
+        private int mixType;
+        private String ex;
+        private String sourceUrl;
+        private Integer duration;
     }
     @Data
     public static class ImData{

+ 64 - 0
fs-service/src/main/java/com/fs/qw/service/impl/AsyncSopTestService.java

@@ -1,5 +1,6 @@
 package com.fs.qw.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fs.common.utils.PubFun;
@@ -7,6 +8,8 @@ import com.fs.course.domain.FsCourseSopAppLink;
 import com.fs.course.mapper.FsCourseSopAppLinkMapper;
 import com.fs.gtPush.service.uniPush2Service;
 import com.fs.his.mapper.FsUserMapper;
+import com.fs.im.dto.OpenImMsgDTO;
+import com.fs.im.service.OpenIMService;
 import com.fs.qw.domain.QwSopUpdateStatus;
 import com.fs.qw.domain.QwUser;
 import com.fs.qw.mapper.QwExternalContactMapper;
@@ -28,6 +31,7 @@ import com.fs.wxUser.param.CompanyWxUserSopParam;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
@@ -57,6 +61,8 @@ public class AsyncSopTestService {
     private final SopUserLogsMapper sopUserLogsMapper;
     private final FsCourseSopAppLinkMapper fsCourseSopAppLinkMapper;
     private final uniPush2Service push2Service;
+    @Autowired
+    private OpenIMService openIMService;
 
     /**
      * 立即执行SOP任务
@@ -530,4 +536,62 @@ public class AsyncSopTestService {
 
     }
 
+    @Async("scheduledExecutorService")
+    public void  asyncSendMsgBySopAppTxtNormalIM(List<QwSopTempSetting.Content.Setting> setting,String cropId,Long companyUserId,Long fsUserId){
+
+        setting.forEach(item->{
+            try {
+                log.info("执行发送app文本消息:{}",item);
+                OpenImMsgDTO openImMsgDTO = new OpenImMsgDTO();
+                openImMsgDTO.setSendID("C"+companyUserId);
+                openImMsgDTO.setRecvID("U"+fsUserId);
+                openImMsgDTO.setContentType(101);
+                openImMsgDTO.setSessionType(1);
+                OpenImMsgDTO.Content imContent = new OpenImMsgDTO.Content();
+                imContent.setContent(item.getValue());
+                openImMsgDTO.setContent(imContent);
+                openIMService.openIMSendMsg(openImMsgDTO);
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        });
+
+    }
+
+    @Async("scheduledExecutorService")
+    public void  asyncSendMsgBySopAppMP3NormalIM(List<QwSopTempSetting.Content.Setting> setting,String cropId,Long companyUserId,Long fsUserId){
+
+        setting.forEach(item->{
+            try {
+                if(StrUtil.isEmpty(item.getVoiceUrl())){
+                    log.info("执行发送app文本消息:{}",item);
+                    OpenImMsgDTO openImMsgDTO = new OpenImMsgDTO();
+                    openImMsgDTO.setSendID("C"+companyUserId);
+                    openImMsgDTO.setRecvID("U"+fsUserId);
+                    openImMsgDTO.setContentType(101);
+                    openImMsgDTO.setSessionType(1);
+                    OpenImMsgDTO.Content imContent = new OpenImMsgDTO.Content();
+                    imContent.setContent(item.getValue());
+                    openImMsgDTO.setContent(imContent);
+                    openIMService.openIMSendMsg(openImMsgDTO);
+                }else {
+                    log.info("执行发送app语音消息:{}",item);
+                    OpenImMsgDTO openImMsgDTO = new OpenImMsgDTO();
+                    openImMsgDTO.setSendID("C"+companyUserId);
+                    openImMsgDTO.setRecvID("U"+fsUserId);
+                    openImMsgDTO.setContentType(103);
+                    openImMsgDTO.setSessionType(1);
+                    OpenImMsgDTO.Content imContent = new OpenImMsgDTO.Content();
+                    imContent.setSourceUrl(item.getVoiceUrl());
+                    imContent.setDuration(Integer.parseInt(item.getVoiceDuration()));
+                    openImMsgDTO.setContent(imContent);
+                    openIMService.openIMSendMsg(openImMsgDTO);
+                }
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        });
+
+    }
+
 }

+ 1 - 4
fs-service/src/main/resources/application-config-dev-yjb.yml

@@ -124,7 +124,4 @@ jst:
   app_key: 871348458a964548a72bf8124cf917a4 #聚水潭2025-10-15
   app_secret: 5b7d9369dbcd414db45089bc047ebe1a #聚水潭2025-10-15
   authorization_code: 666666
-  shop_code: "18849902"
-
-openIM:
-  url: xx
+  shop_code: "18849902"

+ 26 - 26
fs-service/src/main/resources/application-dev-yjb.yml

@@ -33,9 +33,16 @@ spring:
             druid:
                 # 主库数据源
                 master:
-                  url: jdbc:mysql://nj-cdb-6306xy90.sql.tencentcdb.com:27077/fs_his?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
-                  username: root
-                  password: Ylrz147..
+                    url: jdbc:mysql://nj-cdb-6306xy90.sql.tencentcdb.com:27077/fs_his?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: yjb
+                    password: Ylrz_1q2w3e4r5t6y
+                # 从库数据源
+                slave:
+                    # 从数据源开关/默认关闭
+                    enabled: true
+                    url: jdbc:mysql://nj-cdb-6306xy90.sql.tencentcdb.com:27077/fs_his?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: yjb
+                    password: Ylrz_1q2w3e4r5t6y
                 # 初始连接数
                 initialSize: 5
                 # 最小连接池数量
@@ -81,9 +88,15 @@ spring:
             druid:
                 # 主库数据源
                 master:
-                  url: jdbc:mysql://nj-cdb-6306xy90.sql.tencentcdb.com:27077/fs_his_sop?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
-                  username: root
-                  password: Ylrz147..
+                    url: jdbc:mysql://nj-cdb-6306xy90.sql.tencentcdb.com:27077/fs_his_sop?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: yjb
+                    password: Ylrz_1q2w3e4r5t6y
+                read:
+                    # 从数据源开关/默认关闭
+                    enabled: true
+                    url: jdbc:mysql://nj-cdb-6306xy90.sql.tencentcdb.com:27077/fs_his_sop?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: yjb
+                    password: Ylrz_1q2w3e4r5t6y
                 # 初始连接数
                 initialSize: 5
                 # 最小连接池数量
@@ -123,9 +136,6 @@ spring:
                     wall:
                         config:
                             multi-statement-allow: true
-
-spring.jackson.mapper.accept-case-insensitive-properties:  true
-
 rocketmq:
     name-server: rmq-1243b25nj.rocketmq.gz.public.tencenttdmq.com:8080 # RocketMQ NameServer 地址
     producer:
@@ -136,30 +146,20 @@ rocketmq:
         group: test-group
         access-key: ak1243b25nj17d4b2dc1a03 # 替换为实际的 accessKey
         secret-key: sk08a7ea1f9f4b0237 # 替换为实际的 secretKey
-custom:
-    token: "1o62d3YxvdHd4LEUiltnu7sK"
-    encoding-aes-key: "UJfTQ5qKTKlegjkXtp1YuzJzxeHlUKvq5GyFbERN1iU"
-    corp-id: "ww51717e2b71d5e2d3"
-    secret: "6ODAmw-8W4t6h9mdzHh2Z4Apwj8mnsyRnjEDZOHdA7k"
-    private-key-path: "privatekey.pem"
-    webhook-url: "https://your-server.com/wecom/archive"
 # token配置
 token:
     # 令牌自定义标识
     header: Authorization
     # 令牌密钥
-    secret: abcdefghijklmnopqrstuvwxyz
+    secret: feeb79c778c1274dd0e4a709cd948718
     # 令牌有效期(默认30分钟)
     expireTime: 180
+#是否为新商户,新商户不走mpOpenId
+isNewWxMerchant: false
 openIM:
     secret: openIM123
     userID: imAdmin
-#是否为新商户,新商户不走mpOpenId
-isNewWxMerchant: true
-
-hospital580:
-    url: https://ehospital-openapi.sq580.com
-    clientId: yjbz_4537_prod
-    secretKey: F5oXOThiYOLkZK4zBsp8R4ecs7c25umw
-    storeId: 188804
-    callbackUrl: https://storeuserapp.bjyjbao.com/hospital580/sync/medicine
+    url: https://webim.bjyjbao.com/api
+#是否使用新im
+im:
+    type: OPENIM

+ 2 - 2
fs-service/src/main/resources/application-druid-yjb.yml

@@ -157,7 +157,7 @@ isNewWxMerchant: false
 openIM:
     secret: openIM123
     userID: imAdmin
-    url: https://web.im.fbylive.com/api
+    url: https://webim.bjyjbao.com/api
 #是否使用新im
 im:
-    type: NONE
+    type: OPENIM

+ 3 - 2
fs-user-app/src/main/java/com/fs/app/controller/store/StoreOrderScrmController.java

@@ -797,7 +797,7 @@ public class StoreOrderScrmController extends AppBaseController {
 
                     order.setPayType("2");
                     BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
-                    payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
+                    payMoney = payMoney.setScale(2, BigDecimal.ROUND_HALF_UP);
                     order.setPayDelivery(order.getPayPrice().subtract(payMoney));
                     order.setPayMoney(payMoney);
                 }
@@ -1369,7 +1369,8 @@ public class StoreOrderScrmController extends AppBaseController {
 
                         orders.get(i).setPayType("2");
                         BigDecimal payMoney = orders.get(i).getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
-                        payMoney = new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
+//                        payMoney = new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
+                        payMoney = payMoney.setScale(2, BigDecimal.ROUND_HALF_UP);
                         orders.get(i).setPayDelivery(orders.get(i).getPayPrice().subtract(payMoney));
                         orders.get(i).setPayMoney(payMoney);
                     } else if (param.getPayType().equals(3)) {