Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

yfh 1 день назад
Родитель
Сommit
fca617aafd

+ 25 - 4
fs-admin/src/main/java/com/fs/his/controller/FsStorePaymentController.java

@@ -5,10 +5,10 @@ import java.util.List;
 
 import com.fs.common.core.domain.R;
 import com.fs.common.utils.SecurityUtils;
-import com.fs.his.domain.FsExportTask;
+import com.fs.his.domain.*;
 import com.fs.his.mapper.FsPrescribeMapper;
 import com.fs.his.param.FsStorePaymentParam;
-import com.fs.his.service.IFsExportTaskService;
+import com.fs.his.service.*;
 import com.fs.his.vo.FsStorePaymentExcelVO;
 import com.fs.his.vo.FsStorePaymentVO;
 import lombok.extern.slf4j.Slf4j;
@@ -26,8 +26,6 @@ import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.enums.BusinessType;
-import com.fs.his.domain.FsStorePayment;
-import com.fs.his.service.IFsStorePaymentService;
 import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.common.core.page.TableDataInfo;
 
@@ -44,11 +42,17 @@ public class FsStorePaymentController extends BaseController
 {
     @Autowired
     private IFsStorePaymentService fsStorePaymentService;
+
+    @Autowired
+    private IFsStorePaymentErrorService fsStorePaymentErrorService;
     @Autowired
     FsPrescribeMapper fsPrescribeMapper;
 
     @Autowired
     private IFsExportTaskService exportTaskService;
+    @Autowired
+    private IFsPackageOrderService fsPackageOrderService;
+
     /**
      * 查询支付明细列表
      */
@@ -169,4 +173,21 @@ public class FsStorePaymentController extends BaseController
     {
         return toAjax(fsStorePaymentService.deleteFsStorePaymentByPaymentIds(paymentIds));
     }
+
+    /**
+     * 查询支付错误明细
+     */
+    @GetMapping("/error/list")
+    public TableDataInfo list(FsStorePaymentError fsStorePaymentError)
+    {
+        startPage();
+        List<FsStorePaymentError> list = fsStorePaymentErrorService.selectFsStorePaymentErrorList(fsStorePaymentError);
+        for (FsStorePaymentError vo : list){
+            if (vo.getBusinessType() != null && vo.getBusinessType()==3 &&  vo.getOrderId() != null) {
+                FsPackageOrder fsPackageOrder = fsPackageOrderService.selectFsPackageOrderByOrderId(vo.getOrderId());
+                vo.setOrderNo(fsPackageOrder.getOrderSn());
+            }
+        }
+        return getDataTable(list);
+    }
 }

+ 5 - 3
fs-live-app/src/main/java/com/fs/live/task/Task.java

@@ -415,7 +415,7 @@ public class Task {
         for (Live openRewardLive : openRewardLives) {
             String configJson = openRewardLive.getConfigJson();
             LiveWatchConfig config = JSON.parseObject(configJson, LiveWatchConfig.class);
-            if (config.getEnabled()) {
+            if (config.getEnabled() && 1 == config.getParticipateCondition()) {
                 List<LiveWatchUser> liveWatchUsers = liveWatchUserService.checkOnlineNoRewardUser(openRewardLive.getLiveId(), now);
                 if (liveWatchUsers == null || liveWatchUsers.isEmpty()) {
                     continue;
@@ -633,7 +633,7 @@ public class Task {
     }
 
     /**
-     * 定时扫描开启的直播间,检查是否到了打标签的时间
+     * 定时扫描开启的直播间,检查是否到了打标签的时间,然后把正在看直播的用户拆分为 直播用户和回放用户
      * 每10秒执行一次
      */
     @Scheduled(cron = "0/10 * * * * ?")
@@ -896,6 +896,9 @@ public class Task {
                             List<LiveWatchLog> batch = updateLog.subList(i, end);
                             liveWatchLogService.batchUpdateLiveWatchLog(batch);
                         }
+                        for (LiveWatchLog liveWatchLog : updateLog) {
+                            redisCache.setCacheObject("live:watch:log:cache:" + liveWatchLog.getLogId(), liveWatchLog, 1, TimeUnit.HOURS);
+                        }
                     }
                     
                 } catch (Exception e) {
@@ -923,7 +926,6 @@ public class Task {
             // 查询 LiveWatchLog
             LiveWatchLog queryLog = new LiveWatchLog();
             queryLog.setLiveId(liveId);
-            queryLog.setUserId(userId);
             queryLog.setQwUserId(String.valueOf(qwUserId));
             queryLog.setExternalContactId(exId);
 

+ 7 - 3
fs-live-app/src/main/java/com/fs/live/websocket/service/WebSocketServer.java

@@ -137,8 +137,14 @@ public class WebSocketServer {
             room.put(userId, session);
             
             // 存储用户进入直播间的时间到 Redis(用于计算在线时长)
+            // 如果已经存在进入时间,说明是重连,不应该覆盖,保持原来的进入时间
             String entryTimeKey = String.format(USER_ENTRY_TIME_KEY, liveId, userId);
-            redisCache.setCacheObject(entryTimeKey, System.currentTimeMillis(), 24, TimeUnit.HOURS);
+            Long existingEntryTime = redisCache.getCacheObject(entryTimeKey);
+            if (existingEntryTime == null) {
+                // 首次连接,记录进入时间
+                redisCache.setCacheObject(entryTimeKey, System.currentTimeMillis(), 24, TimeUnit.HOURS);
+            }
+            // 如果是重连,不覆盖进入时间,保持原来的进入时间以便正确计算总时长
             
             // 直播间浏览量 +1
             redisCache.incr(PAGE_VIEWS_KEY + liveId, 1);
@@ -1178,7 +1184,6 @@ public class WebSocketServer {
         try {
             LiveWatchLog queryLog = new LiveWatchLog();
             queryLog.setLiveId(liveId);
-            queryLog.setUserId(userId);
             queryLog.setQwUserId(String.valueOf(qwUserId));
             queryLog.setExternalContactId(externalContactId);
             
@@ -1302,7 +1307,6 @@ public class WebSocketServer {
             // 查询 LiveWatchLog
             LiveWatchLog queryLog = new LiveWatchLog();
             queryLog.setLiveId(liveId);
-            queryLog.setUserId(userId);
             queryLog.setCompanyId(companyId);
             queryLog.setCompanyUserId(companyUserId);
             

+ 5 - 0
fs-service/src/main/java/com/fs/his/domain/FsStorePaymentError.java

@@ -35,4 +35,9 @@ public class FsStorePaymentError extends BaseEntity
     @Excel(name = "0未处理 1已处理")
     private Integer status;
 
+
+    private Long orderId;
+
+    private Integer businessType;
+
 }

+ 9 - 0
fs-service/src/main/java/com/fs/his/service/IFsStorePaymentErrorService.java

@@ -0,0 +1,9 @@
+package com.fs.his.service;
+
+import com.fs.his.domain.FsStorePaymentError;
+
+import java.util.List;
+
+public interface IFsStorePaymentErrorService {
+    List<FsStorePaymentError> selectFsStorePaymentErrorList(FsStorePaymentError fsStorePaymentError);
+}

+ 21 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsStorePaymentErrorServiceImpl.java

@@ -0,0 +1,21 @@
+package com.fs.his.service.impl;
+
+import com.fs.his.domain.FsStorePaymentError;
+import com.fs.his.mapper.FsStorePaymentErrorMapper;
+import com.fs.his.service.IFsStorePaymentErrorService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class FsStorePaymentErrorServiceImpl implements IFsStorePaymentErrorService {
+    @Autowired
+    private FsStorePaymentErrorMapper fsStorePaymentErrorMapper;
+
+    public List<FsStorePaymentError> selectFsStorePaymentErrorList(FsStorePaymentError fsStorePaymentError){
+        return fsStorePaymentErrorMapper.selectFsStorePaymentErrorList(fsStorePaymentError);
+    }
+
+
+}

+ 44 - 5
fs-service/src/main/java/com/fs/his/service/impl/FsStorePaymentServiceImpl.java

@@ -48,9 +48,7 @@ import com.fs.his.domain.*;
 import com.fs.his.dto.PayConfigDTO;
 import com.fs.his.enums.PaymentMethodEnum;
 import com.fs.his.mapper.*;
-import com.fs.his.param.FsStorePaymentParam;
-import com.fs.his.param.PayOrderParam;
-import com.fs.his.param.WxSendRedPacketParam;
+import com.fs.his.param.*;
 import com.fs.his.service.IFsInquiryOrderService;
 
 import com.fs.his.param.WxSendRedPacketParam;
@@ -217,6 +215,9 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
     @Value("${cloud_host.company_name}")
     private String signProjectName;
 
+    @Autowired
+    private FsStorePaymentErrorMapper fsStorePaymentErrorMapper;
+
     /**
      * 红包账户锁
      */
@@ -1648,18 +1649,56 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
         return "SUCCESS";
     }
 
+    long TWENTY_DAYS_IN_MILLIS = 1728000000L;// 使用毫秒判断,20天 = 20 * 24 * 60 * 60 * 1000 毫秒
     @Override
     public void synchronizePayStatus() {
         FsStorePayment queryParam = new FsStorePayment();
         queryParam.setStatus(0);//未支付
-        queryParam.setBeginTime(DateUtils.addDateDays(-1));
+//        queryParam.setBeginTime(DateUtils.addDateDays(-1));
         queryParam.setEndTime(DateUtils.getDate());
         List<FsStorePayment> list = selectFsStorePaymentList(queryParam);
         if (list != null && !list.isEmpty()) {
             List<CompletableFuture<Void>> futures = new ArrayList<>();
             for (FsStorePayment fsStorePayment : list) {
                 CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
-                    updateFsStorePaymentByDecryptForm(fsStorePayment.getPaymentId());
+                    try {
+                        updateFsStorePaymentByDecryptForm(fsStorePayment.getPaymentId());
+                        //查询是否改为已支付
+                        FsStorePayment finalPayment = fsStorePaymentMapper.selectFsStorePaymentByPaymentId(fsStorePayment.getPaymentId());
+                        try {
+                            Date createTime = finalPayment.getCreateTime();
+                            Date now = new Date();
+                            long value = now.getTime() - createTime.getTime();
+                            if(finalPayment.getStatus() == 0
+                                    && finalPayment.getBusinessType() == 3
+                                    && (value > TWENTY_DAYS_IN_MILLIS)
+                                    && finalPayment.getBusinessId() != null){
+                                //套餐包超过20天取消订单
+                                FsPackageOrderCancelParam param = new FsPackageOrderCancelParam();
+                                param.setOrderId(Long.valueOf(finalPayment.getBusinessId()));
+                                packageOrderService.cancel(param);
+                            }
+                        } catch (NumberFormatException e) {
+                            logger.info("定时任务:同步支付状态超时取消订单失败,payment_id:{}",fsStorePayment.getPaymentId());
+                        }
+                    } catch (Exception e) {
+                        //添加失败记录
+                        FsStorePaymentError fsStorePaymentError = new FsStorePaymentError();
+                        fsStorePaymentError.setOrderFlowNo(fsStorePayment.getTradeNo());
+                        String businessId = fsStorePayment.getBusinessId();
+                        fsStorePaymentError.setBusinessType(fsStorePayment.getBusinessType());
+                        fsStorePaymentError.setMsg(e.getMessage());
+                        fsStorePaymentError.setStatus(0);
+                        fsStorePaymentError.setCreateTime(new Date());
+                        if (businessId != null && fsStorePayment.getBusinessType() == 3) {
+                            fsStorePaymentError.setOrderId(Long.valueOf(businessId));
+                            FsPackageOrder fsPackageOrder = packageOrderService.selectFsPackageOrderByOrderId(Long.valueOf(businessId));
+                            if (fsPackageOrder != null) {
+                                fsStorePaymentError.setOrderNo(fsPackageOrder.getOrderSn());
+                            }
+                        }
+                        fsStorePaymentErrorMapper.insertFsStorePaymentError(fsStorePaymentError);
+                    }
                     logger.info("定时任务:同步支付状态,payment_id:{}",fsStorePayment.getPaymentId());
                 });
                 futures.add(future);

+ 1 - 1
fs-service/src/main/java/com/fs/live/domain/LiveOrder.java

@@ -96,7 +96,7 @@ public class LiveOrder extends BaseEntity {
     private String payType;
 
     /** 订单状态(-1 : 申请退款 -2 : 退货成功 0:已取消 1:待支付 2:待发货;3:待收货;4:待评价;5:已完成) */
-    @Excel(name = "订单状态", readConverterExp = "-=1,:=,申=请退款,-=2,:=,退=货成功,1=:待支付,2=:待发货;3:待收货;4:待评价;5:已完成")
+    @Excel(name = "订单状态", readConverterExp = "-=1,:=,申=请退款,-=2,:=,退=货成功,1=:待支付,2=:待发货;3:待收货;4:待评价;5:已完成;6:被拆分")
     private Integer status;
 
     /** 0 未退款 1 申请中 2 已退款 */

+ 14 - 12
fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -783,21 +783,23 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
             Map<String, Integer> liveFlagWithCache = liveWatchUserService.getLiveFlagWithCache(order.getLiveId());
             if (liveFlagWithCache != null && liveFlagWithCache.containsKey("liveFlag") && 1 == liveFlagWithCache.get("liveFlag")) {
                 try {
-                    LiveWatchLog queryLog = new LiveWatchLog();
-                    queryLog.setLiveId(order.getLiveId());
-                    queryLog.setUserId(Long.valueOf(order.getUserId()));
-                    queryLog.setCompanyId(order.getCompanyId());
-                    queryLog.setCompanyUserId(order.getCompanyUserId());
-
-                    List<LiveWatchLog> logs = liveWatchLogService.selectLiveWatchLogList(queryLog);
-                    if (logs != null && !logs.isEmpty()) {
-                        for (LiveWatchLog log : logs) {
-                            if (log.getLogType() == null || log.getLogType() != 2) {
-                                log.setLiveBuy(1);
-                                liveWatchLogService.updateLiveWatchLog(log);
+                    LiveUserFirstEntry liveUserFirstEntry = liveUserFirstEntryService.selectEntityByLiveIdUserId(order.getLiveId(), Long.parseLong(order.getUserId()));
+                    if (liveUserFirstEntry != null && liveUserFirstEntry.getExternalContactId()!=null && liveUserFirstEntry.getExternalContactId() > 0 &&  liveUserFirstEntry.getQwUserId()!=null && liveUserFirstEntry.getQwUserId() > 0) {
+                        LiveWatchLog queryLog = new LiveWatchLog();
+                        queryLog.setLiveId(order.getLiveId());
+                        queryLog.setQwUserId(String.valueOf(liveUserFirstEntry.getQwUserId()));
+                        queryLog.setExternalContactId(liveUserFirstEntry.getExternalContactId());
+                        List<LiveWatchLog> logs = liveWatchLogService.selectLiveWatchLogList(queryLog);
+                        if (logs != null && !logs.isEmpty()) {
+                            for (LiveWatchLog log : logs) {
+                                if (log.getLogType() == null || log.getLogType() != 2) {
+                                    log.setLiveBuy(1);
+                                    liveWatchLogService.updateLiveWatchLog(log);
+                                }
                             }
                         }
                     }
+
                 } catch (Exception e) {
                     log.error("更新 updateLiveWatchLog LiveWatchLog logType 异常(连接时):liveId={}, userId={}, error={}",
                             order.getLiveId(), order.getUserId(), e.getMessage(), e);

+ 11 - 0
fs-service/src/main/java/com/fs/qw/domain/QwCompany.java

@@ -85,4 +85,15 @@ public class QwCompany extends BaseEntity
     private Long createUserId;
     // 创建部门
     private Long createDeptId;
+
+    /**
+     * 御君方云医小程序原始id
+     */
+    private String yjfyyAppId;
+    /**
+     * 御君方云医应用id
+     */
+    private String yjfyyAgentId;
+
+    private String yjfyySchema;
 }

+ 11 - 1
fs-service/src/main/resources/mapper/his/FsStorePaymentErrorMapper.xml

@@ -11,10 +11,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="msg"    column="msg"    />
         <result property="status"    column="status"    />
         <result property="createTime"    column="create_time"    />
+        <result property="orderId"    column="order_id"    />
+        <result property="businessType"    column="business_type"    />
     </resultMap>
 
     <sql id="selectFsStorePaymentErrorVo">
-        select id, order_flow_no, order_no, msg, status, create_time from fs_store_payment_error
+        select id, order_flow_no, order_no, msg, status, create_time,order_id,business_type from fs_store_payment_error
     </sql>
 
     <select id="selectFsStorePaymentErrorList" parameterType="FsStorePaymentError" resultMap="FsStorePaymentErrorResult">
@@ -23,6 +25,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="orderFlowNo != null  and orderFlowNo != ''"> and order_flow_no = #{orderFlowNo}</if>
             <if test="orderNo != null  and orderNo != ''"> and order_no = #{orderNo}</if>
             <if test="msg != null  and msg != ''"> and msg = #{msg}</if>
+            <if test="orderId != null "> and order_id = #{orderId}</if>
+            <if test="businessType != null "> and business_type = #{businessType}</if>
             <if test="status != null "> and status = #{status}</if>
         </where>
     </select>
@@ -41,6 +45,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="msg != null">msg,</if>
             <if test="status != null">status,</if>
             <if test="createTime != null">create_time,</if>
+            <if test="orderId != null">order_id,</if>
+            <if test="businessType != null">business_type,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
@@ -49,6 +55,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="msg != null">#{msg},</if>
             <if test="status != null">#{status},</if>
             <if test="createTime != null">#{createTime},</if>
+            <if test="orderId != null">#{orderId},</if>
+            <if test="businessType != null">#{businessType},</if>
          </trim>
     </insert>
 
@@ -60,6 +68,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="msg != null">msg = #{msg},</if>
             <if test="status != null">status = #{status},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="orderId != null">order_id = #{orderId},</if>
+            <if test="businessType != null">business_type = #{businessType},</if>
         </trim>
         where id = #{id}
     </update>

+ 16 - 1
fs-service/src/main/resources/mapper/qw/QwCompanyMapper.xml

@@ -30,10 +30,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="msgPrivateKey"    column="msg_private_key"    />
         <result property="miniAppId"    column="mini_app_id"    />
         <result property="companyServerNum"    column="company_server_num"    />
+        <result property="yjfyyAppId"    column="yjfyy_app_id"    />
+        <result property="yjfyyAgentId"    column="yjfyy_agent_id"    />
+        <result property="yjfyySchema"    column="yjfyy_schema"    />
     </resultMap>
 
     <sql id="selectQwCompanyVo">
-        select id, corp_id, corp_name, open_secret, open_corp_id, server_agent_id, server_book_corp_id, server_book_secret, token, encoding_aes_key, provider_secret, realm_name_url, notify_url, chat_toolbar, chat_toolbar_oauth, company_ids, status, create_time, update_time, create_by,is_buy,mini_app_id,company_server_num from qw_company
+        select id, corp_id, corp_name, open_secret, open_corp_id, server_agent_id, server_book_corp_id, server_book_secret, token, encoding_aes_key, provider_secret, realm_name_url, notify_url, chat_toolbar, chat_toolbar_oauth, company_ids, status, create_time, update_time, create_by,is_buy,mini_app_id,company_server_num,yjfyy_app_id,yjfyy_agent_id,yjfyy_schema from qw_company
     </sql>
 
     <select id="selectQwCompanyList" parameterType="QwCompany" resultMap="QwCompanyResult">
@@ -58,6 +61,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isBuy != null "> and isBuy = #{isBuy}</if>
             <if test="createDeptId != null "> and create_dept_id = #{createDeptId}</if>
             <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
+            <if test="yjfyyAppId != null  and yjfyyAppId != ''"> and yjfyy_app_id = #{yjfyyAppId}</if>
+            <if test="yjfyyAgentId != null  and yjfyyAgentId != ''"> and yjfyy_agent_id = #{yjfyyAgentId}</if>
+            <if test="yjfyySchema != null  and yjfyySchema != ''"> and yjfyy_schema = #{yjfyySchema}</if>
         </where>
     </select>
 
@@ -99,6 +105,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyServerNum != null">company_server_num,</if>
             <if test="createUserId != null != null">create_user_id,</if>
             <if test="createDeptId != null">create_dept_id,</if>
+            <if test="yjfyyAppId != null">yjfyy_app_id,</if>
+            <if test="yjfyyAgentId != null">yjfyy_agent_id,</if>
+            <if test="yjfyySchema != null">yjfyy_schema,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="corpId != null">#{corpId},</if>
@@ -125,6 +134,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyServerNum != null">#{companyServerNum},</if>
             <if test="createUserId != null">#{createUserId},</if>
             <if test="createDeptId != null">#{createDeptId},</if>
+            <if test="yjfyyAppId != null">#{yjfyyAppId},</if>
+            <if test="yjfyyAgentId != null">#{yjfyyAgentId},</if>
+            <if test="yjfyySchema != null">#{yjfyySchema},</if>
          </trim>
     </insert>
 
@@ -153,6 +165,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isBuy != null">is_buy = #{isBuy},</if>
             <if test="miniAppId != null">mini_app_id = #{miniAppId},</if>
             <if test="companyServerNum != null">company_server_num = #{companyServerNum},</if>
+            <if test="yjfyyAppId != null">yjfyy_app_id = #{yjfyyAppId},</if>
+            <if test="yjfyyAgentId != null">yjfyy_agent_id = #{yjfyyAgentId},</if>
+            <if test="yjfyySchema != null">yjfyy_schema = #{yjfyySchema},</if>
         </trim>
         where id = #{id}
     </update>