Переглянути джерело

Merge remote-tracking branch 'origin/master'

yfh 2 днів тому
батько
коміт
f88faae0b1

+ 9 - 0
fs-admin/src/main/java/com/fs/live/controller/LiveController.java

@@ -221,4 +221,13 @@ public class LiveController extends BaseController {
         return getDataTable(list);
     }
 
+    /**
+     * 清除直播间缓存
+     */
+    @Log(title = "直播", businessType = BusinessType.UPDATE)
+    @PostMapping("/clearCache/{liveId}")
+    public R clearCache(@PathVariable("liveId") Long liveId) {
+        return liveService.clearLiveCache(liveId);
+    }
+
 }

+ 1 - 8
fs-live-app/src/main/java/com/fs/live/task/LiveCompletionPointsTask.java

@@ -53,8 +53,6 @@ public class LiveCompletionPointsTask {
                 log.debug("当前没有开启完课积分的直播间");
                 return;
             }
-            
-            log.info("开始检查完课状态, 开启完课积分的直播间数量: {}", activeLives.size());
 
             for (Live live : activeLives) {
                 try {
@@ -65,14 +63,9 @@ public class LiveCompletionPointsTask {
                     Map<Object, Object> userDurations = redisCache.hashEntries(hashKey);
                     
                     if (userDurations == null || userDurations.isEmpty()) {
-                        log.warn("直播间没有观看时长数据, liveId={}, liveName={}, Redis Key: {}, userDurations={}", 
-                                liveId, live.getLiveName(), hashKey, userDurations);
+
                         continue;
                     }
-                    
-                    log.info("直播间有观看数据, liveId={}, liveName={}, 用户数: {}", 
-                            liveId, live.getLiveName(), userDurations.size());
-                    
                     // 3. 逐个用户处理
                     for (Map.Entry<Object, Object> entry : userDurations.entrySet()) {
                         try {

+ 6 - 1
fs-live-app/src/main/java/com/fs/live/task/Task.java

@@ -169,6 +169,7 @@ public class Task {
                         redisCache.expire(key+live.getLiveId(), 1, TimeUnit.DAYS);
                     });
                 }
+                // 清理小程序缓存 和 直播标签缓存
                 String cacheKey = String.format(LiveKeysConstant.LIVE_DATA_CACHE, live.getLiveId());
                 redisCache.setCacheObject(cacheKey,live,1,TimeUnit.HOURS);
                 liveWatchUserService.clearLiveFlagCache(live.getLiveId());
@@ -415,8 +416,12 @@ public class Task {
             String configJson = openRewardLive.getConfigJson();
             LiveWatchConfig config = JSON.parseObject(configJson, LiveWatchConfig.class);
             if (config.getEnabled()) {
+                List<LiveWatchUser> liveWatchUsers = liveWatchUserService.checkOnlineNoRewardUser(openRewardLive.getLiveId(), now);
+                if (liveWatchUsers == null || liveWatchUsers.isEmpty()) {
+                    continue;
+                }
                 // 3.检查当前直播间的在线用户(可以传入一个时间,然后查出来当天没领取奖励的用户)
-                List<LiveWatchUser> onlineUser = liveWatchUserService.checkOnlineNoRewardUser(openRewardLive.getLiveId(), now)
+                List<LiveWatchUser> onlineUser = liveWatchUsers
                         .stream().filter(user -> (now.getTime() - user.getUpdateTime().getTime() + ( user.getOnlineSeconds() == null ? 0L : user.getOnlineSeconds())) > config.getWatchDuration() * 60 * 1000)
                         .collect(Collectors.toList());
                 if(onlineUser.isEmpty()) continue;

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

@@ -84,7 +84,7 @@ public interface ILiveAfterSalesService {
 
     R refundMoney(LiveAfterSalesRefundParam param);
 
-    R cancel(LiveAfterSalesCancelParam param);
+    R cancel(LiveAfterSalesCancelParam param)  throws ParseException;
 
     R applyForAfterSales(String userId, LiveAfterSalesParam param);
 

+ 7 - 0
fs-service/src/main/java/com/fs/live/service/ILiveService.java

@@ -187,6 +187,13 @@ public interface ILiveService
      */
     LiveConfigVo asyncToCacheLiveConfig(Long liveId);
 
+    /**
+     * 清除直播间数据缓存
+     * @param liveId 直播间ID
+     * @return 结果
+     */
+    R clearLiveCache(Long liveId);
+
     List<Live> liveCompanyList(Long companyId);
 
     R subNotifyLive(LiveNotifyParam liveNotifyParam);

+ 9 - 15
fs-service/src/main/java/com/fs/live/service/impl/LiveAfterSalesServiceImpl.java

@@ -280,8 +280,8 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
-    public R cancel(LiveAfterSalesCancelParam param) {
+    @Transactional
+    public R cancel(LiveAfterSalesCancelParam param)  throws ParseException{
         LiveAfterSales storeAfterSales = baseMapper.selectLiveAfterSalesById(param.getSalesId());
         if (storeAfterSales == null) {
             throw new CustomException("未查询到售后订单信息");
@@ -322,13 +322,8 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
                     orderMap.setStatus(order.getStatus());
                     liveOrderService.updateLiveOrder(orderMap);
                     liveOrderItemMapper.updateFsStoreOrderCode(order.getOrderId(),orderSn);
-                    try {
-                        //生成新的订单
-                        liveOrderService.createOmsOrder(order.getOrderId());
-                    } catch (Exception e) {
-                        log.error("撤销售后,生成oms订单异常",e);
-                    }
-
+                    //生成新的订单
+                    liveOrderService.createOmsOrder(order.getOrderId());
                 }
             }
         }
@@ -431,7 +426,6 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
         storeAfterSales.setIsDel(0);
         storeAfterSales.setOrderStatus(orderStatus);
         storeAfterSales.setUserId(Long.valueOf(userId));
-        storeAfterSales.setOrderStatus(orderStatus);
         storeAfterSales.setCompanyId(order.getCompanyId());
         storeAfterSales.setCompanyUserId(order.getCompanyUserId());
         liveAfterSalesService.insertLiveAfterSales(storeAfterSales);
@@ -557,6 +551,9 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
         if(ObjectUtil.isNull(liveAfterSales)) {
             throw new IllegalArgumentException("售后单不存在!");
         }
+        if (!liveAfterSales.getStatus().equals(AfterStatusEnum.STATUS_3.getValue())) {
+            throw new CustomException("非法操作");
+        }
         return liveOrderService.refundOrderMoney(liveAfterSales.getOrderId(),liveAfterSales);
     }
 
@@ -638,6 +635,7 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
         if (!liveAfterSales.getStatus().equals(AfterStatusEnum.STATUS_0.getValue())) {
             throw new CustomException("非法操作");
         }
+        //仅退款
         if(liveAfterSales.getRefundType().equals(0)){
             //仅退款未发货处理
             if(liveAfterSales.getOrderStatus().equals(OrderInfoEnum.STATUS_1.getValue())){
@@ -645,14 +643,11 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
                 liveAfterSales.setStatus(3);
                 baseMapper.updateLiveAfterSales(liveAfterSales);
             }
-            //待收货直接退款
+            //仅退款待收货处理
             else if(liveAfterSales.getOrderStatus().equals(OrderInfoEnum.STATUS_2.getValue())){
                 liveAfterSales.setStatus(2);
                 baseMapper.updateLiveAfterSales(liveAfterSales);
             //已完成 退货退款
-            } else if(liveAfterSales.getOrderStatus().equals(4)) {
-                liveAfterSales.setStatus(1);
-                baseMapper.updateLiveAfterSales(liveAfterSales);
             }
             LiveAfterSalesLogs salesLogs = new LiveAfterSalesLogs();
             salesLogs.setStoreAfterSalesId(liveAfterSales.getId());
@@ -897,7 +892,6 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
         LiveOrder order = liveOrderService.selectLiveOrderByOrderId(String.valueOf(storeAfterSales.getOrderId()));
         order.setStatus(storeAfterSales.getOrderStatus());
         order.setRefundStatus(OrderInfoEnum.REFUND_STATUS_0.getValue().toString());
-        order.setIsAfterSales(0);
         liveOrderService.updateLiveOrder(order);
         //操作记录
         LiveAfterSalesLogs logs = new LiveAfterSalesLogs();

+ 10 - 15
fs-service/src/main/java/com/fs/live/service/impl/LiveCompletionPointsRecordServiceImpl.java

@@ -62,7 +62,7 @@ public class LiveCompletionPointsRecordServiceImpl implements ILiveCompletionPoi
             // 1. 获取直播信息和配置
             Live live = liveService.selectLiveByLiveId(liveId);
             if (live == null) {
-                log.warn("直播间不存在, liveId={}", liveId);
+
                 return;
             }
 
@@ -71,7 +71,7 @@ public class LiveCompletionPointsRecordServiceImpl implements ILiveCompletionPoi
             
             // 检查是否开启完课积分功能
             if (!config.isEnabled()) {
-                log.debug("直播间未开启完课积分功能, liveId={}", liveId);
+
                 return;
             }
             
@@ -80,8 +80,7 @@ public class LiveCompletionPointsRecordServiceImpl implements ILiveCompletionPoi
             int[] pointsConfig = config.getPointsConfig();
             
             if (completionRate == null || pointsConfig == null || pointsConfig.length == 0) {
-                log.warn("完课积分配置不完整, liveId={}, completionRate={}, pointsConfig={}", 
-                        liveId, completionRate, pointsConfig);
+
                 return;
             }
 
@@ -90,19 +89,18 @@ public class LiveCompletionPointsRecordServiceImpl implements ILiveCompletionPoi
             if (actualWatchDuration == null) {
                 // 自动累加直播和回放的观看时长
                 actualWatchDuration = liveWatchUserService.getTotalWatchDuration(liveId, userId);
-                log.debug("自动累计观看时长: liveId={}, userId={}, totalDuration={}",
-                        liveId, userId, actualWatchDuration);
+
             }
 
             if (actualWatchDuration == null || actualWatchDuration <= 0) {
-                log.debug("观看时长为0, liveId={}, userId={}", liveId, userId);
+
                 return;
             }
 
             // 4. 获取视频总时长(秒)
             Long videoDuration = live.getDuration();
             if (videoDuration == null || videoDuration <= 0) {
-                log.warn("直播间视频时长无效, liveId={}, duration={}", liveId, videoDuration);
+
                 return;
             }
 
@@ -118,8 +116,7 @@ public class LiveCompletionPointsRecordServiceImpl implements ILiveCompletionPoi
 
             // 6. 判断是否达到完课标准
             if (watchRate.compareTo(BigDecimal.valueOf(completionRate)) < 0) {
-                log.debug("观看时长未达到完课标准, liveId={}, userId={}, watchDuration={}, videoDuration={}, watchRate={}%, required={}%",
-                        liveId, userId, actualWatchDuration, videoDuration, watchRate, completionRate);
+
                 return;
             }
 
@@ -129,7 +126,7 @@ public class LiveCompletionPointsRecordServiceImpl implements ILiveCompletionPoi
 
             LiveCompletionPointsRecord todayRecord = recordMapper.selectByUserAndDate(liveId, userId, currentDate);
             if (todayRecord != null) {
-                log.debug("今天已有完课记录, liveId={}, userId={}", liveId, userId);
+
                 return;
             }
 
@@ -145,8 +142,7 @@ public class LiveCompletionPointsRecordServiceImpl implements ILiveCompletionPoi
 
                 if (daysBetween == 0) {
                     continuousDays = latestRecord.getContinuousDays();
-                    log.debug("今天已有其他直播间完课记录,继承连续天数, liveId={}, userId={}, continuousDays={}", 
-                            liveId, userId, continuousDays);
+
                 } else if (daysBetween == 1) {
                     // 昨天完课了,连续天数+1
                     continuousDays = latestRecord.getContinuousDays() + 1;
@@ -177,8 +173,7 @@ public class LiveCompletionPointsRecordServiceImpl implements ILiveCompletionPoi
 
             recordMapper.insertRecord(record);
 
-            log.info("创建完课记录成功, liveId={}, userId={}, watchDuration={}, videoDuration={}, watchRate={}%, continuousDays={}, points={}",
-                    liveId, userId, actualWatchDuration, videoDuration, watchRate, continuousDays, points);
+
 
         } catch (Exception e) {
             log.error("检查并创建完课记录失败, liveId={}, userId={}", liveId, userId, e);

+ 85 - 63
fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -3,6 +3,7 @@ package com.fs.live.service.impl;
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.sql.Timestamp;
+import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
@@ -689,7 +690,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
     }
 
     @Override
-    @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
+    @Transactional
     public String payConfirm(Integer type,Long orderId,String payCode,String tradeNo,String bankTransactionId,String bankSerialNo) {
         Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
         try {
@@ -709,7 +710,12 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                         liveOrderPaymentMapper.updateLiveOrderPayment(paymentMap);
                         order = baseMapper.selectFsUserVipOrderByOrderCode(storePayment.getBusinessCode());
                         if(order==null || !order.getStatus().equals(OrderInfoEnum.STATUS_0.getValue())){
-                            throw new CustomException("当前订单未找到或者订单状态不为待支付! paycode:"+payCode);
+                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                            return "";
+                        }
+                        if (order != null && !order.getIsPay().equals(0)) {
+                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                            return "";
                         }
                     }
                 }
@@ -1389,6 +1395,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
     @Override
     @Transactional(rollbackFor = Exception.class)
     public R refundOrderMoney(Long orderId, LiveAfterSales liveAfterSales) {
+        BigDecimal refundAmount = liveAfterSales.getRefundAmount();
         IErpOrderService erpOrderService = getErpService();
         FsErpConfig erpConfig = configUtil.generateStructConfigByKey("his.config", FsErpConfig.class);
         LiveOrder order = baseMapper.selectLiveOrderByOrderId(String.valueOf(orderId));
@@ -1407,43 +1414,49 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 && !CloudHostUtils.hasCloudHostName("康年堂")) {
             return R.error("暂未推送至erp,请稍后再试!");
         }
-        liveAfterSales.setRefundAmount(order.getPayPrice());
+        if (Objects.isNull(refundAmount)) {
+            throw new CustomException("退款金额不能为空");
+        }
+        if (order.getPayMoney().compareTo(refundAmount) < 0) {
+            throw new CustomException("退款金额不能大于支付金额");
+        }
+        liveAfterSales.setRefundAmount(liveAfterSales.getRefundAmount());
         liveAfterSales.setStatus(4);
         liveAfterSales.setSalesStatus(3);
         liveAfterSalesService.updateLiveAfterSales(liveAfterSales);
-        if (StringUtils.isNotEmpty(order.getExtendOrderId())) {
-            ErpRefundUpdateRequest request = new ErpRefundUpdateRequest();
-            request.setTid(order.getOrderCode());
-            request.setOid(order.getOrderCode());
-            request.setRefund_state(1);
-            request.setOrderStatus(order.getStatus());
-            if (ObjectUtils.equals(order.getStatus(), 2)) {
-                LiveAfterSalesParam param = new LiveAfterSalesParam();
-                param.setOrderCode(order.getOrderCode());
-                param.setRefundAmount(order.getPayMoney());
-                param.setServiceType(1);
-                param.setReasons("后台手动退款流程");
-                param.setExplainImg(null);
-                List<FsStoreAfterSalesProductParam> productParams = new ArrayList<>();
-                List <LiveOrderItem> items = liveOrderItemMapper.selectLiveOrderItemByOrderId(order.getOrderId());
-                for (LiveOrderItem item : items){
-                    FsStoreAfterSalesProductParam param1 = new FsStoreAfterSalesProductParam();
-                    param1.setProductId(item.getProductId());
-                    param1.setNum(Math.toIntExact(item.getNum()));
-                    productParams.add(param1);
-                }
-                return liveAfterSalesService.applyForAfterSales(order.getUserId(), param);
-            } else {
-                ErpOrderQueryRequert queryRequest = new ErpOrderQueryRequert();
-                queryRequest.setCode(order.getExtendOrderId());
-                ErpOrderQueryResponse response = erpOrderService.getLiveOrder(queryRequest);
-                if (response.getOrders() != null && response.getOrders().size() > 0) {
-                    if (response.getOrders().get(0).getCancle() != null && !response.getOrders().get(0).getCancle()) {
-                        jSTOrderService.refundUpdateLive(request);
-                    }
-                }
-            }
-        }
+//        if (StringUtils.isNotEmpty(order.getExtendOrderId())) {
+//            ErpRefundUpdateRequest request = new ErpRefundUpdateRequest();
+//            request.setTid(order.getOrderCode());
+//            request.setOid(order.getOrderCode());
+//            request.setRefund_state(1);
+//            request.setOrderStatus(order.getStatus());
+//            if (ObjectUtils.equals(order.getStatus(), 2)) {
+//                LiveAfterSalesParam param = new LiveAfterSalesParam();
+//                param.setOrderCode(order.getOrderCode());
+//                param.setRefundAmount(order.getPayMoney());
+//                param.setServiceType(1);
+//                param.setReasons("后台手动退款流程");
+//                param.setExplainImg(null);
+//                List<FsStoreAfterSalesProductParam> productParams = new ArrayList<>();
+//                List <LiveOrderItem> items = liveOrderItemMapper.selectLiveOrderItemByOrderId(order.getOrderId());
+//                for (LiveOrderItem item : items){
+//                    FsStoreAfterSalesProductParam param1 = new FsStoreAfterSalesProductParam();
+//                    param1.setProductId(item.getProductId());
+//                    param1.setNum(Math.toIntExact(item.getNum()));
+//                    productParams.add(param1);
+//                }
+//                return liveAfterSalesService.applyForAfterSales(order.getUserId(), param);
+//            } else {
+//                ErpOrderQueryRequert queryRequest = new ErpOrderQueryRequert();
+//                queryRequest.setCode(order.getExtendOrderId());
+//                ErpOrderQueryResponse response = erpOrderService.getLiveOrder(queryRequest);
+//                if (response.getOrders() != null && response.getOrders().size() > 0) {
+//                    if (response.getOrders().get(0).getCancle() != null && !response.getOrders().get(0).getCancle()) {
+//                        jSTOrderService.refundUpdateLive(request);
+//                    }
+//                }
+//            }
+//        }
         order.setStatus(OrderInfoEnum.STATUS_NE2.getValue());
         order.setRefundMoney(order.getPayMoney());
         order.setRefundStatus(String.valueOf(OrderInfoEnum.REFUND_STATUS_2.getValue()));
@@ -1494,7 +1507,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                         refundRequest.setOutTradeNo("live-" + payment.getPayCode());
                         refundRequest.setOutRefundNo("live-" + payment.getPayCode());
                         refundRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(payment.getPayMoney().toString()));
-                        refundRequest.setRefundFee(WxPayUnifiedOrderRequest.yuanToFen(payment.getPayMoney().toString()));
+                        refundRequest.setRefundFee(WxPayUnifiedOrderRequest.yuanToFen(refundAmount.toString()));
                         try {
                             WxPayRefundResult refundResult = wxPayService.refund(refundRequest);
                             WxPayRefundQueryResult refundQueryResult = wxPayService.refundQuery("", refundResult.getOutTradeNo(), refundResult.getOutRefundNo(), refundResult.getRefundId());
@@ -1503,14 +1516,12 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                                 paymentMap.setPaymentId(payment.getPaymentId());
                                 paymentMap.setStatus(-1);
                                 paymentMap.setRefundTime(DateUtils.getNowDate());
-                                paymentMap.setRefundMoney(payment.getPayMoney());
+                                paymentMap.setRefundMoney(refundAmount);
                                 liveOrderPaymentMapper.updateLiveOrderPayment(paymentMap);
                             } else {
-                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                 return R.error("退款请求失败" + (refundQueryResult != null ? refundQueryResult.getErrCodeDes() : ""));
                             }
                         } catch (WxPayException e) {
-                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return R.error("退款请求失败" + e.getErrCodeDes());
                         }
                     } else if (payment.getPayMode() != null && "hf".equals(payment.getPayMode())) {
@@ -1518,25 +1529,26 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                         FsHfpayConfigMapper fsHfpayConfigMapper = SpringUtils.getBean(FsHfpayConfigMapper.class);
                         if (payment.getAppId() != null) {
                             FsHfpayConfig fsHfpayConfig = fsHfpayConfigMapper.selectByAppId(payment.getAppId());
-                            if (fsHfpayConfig != null) {
+                            if (fsHfpayConfig == null){
+                                huifuId = fsPayConfig.getHuifuId();
+                            }else {
                                 huifuId = fsHfpayConfig.getHuifuId();
                             }
                         } else {
                             CloudHostProper cloudHostProper = SpringUtils.getBean(CloudHostProper.class);
                             if ("益善缘".equals(cloudHostProper.getCompanyName())) {
                                 FsHfpayConfig fsPayConfig2 = fsHfpayConfigMapper.selectByAppId("wx0d1a3dd485268521");
-                                if (fsPayConfig2 != null) {
-                                    huifuId = fsPayConfig2.getHuifuId();
-                                }
+                                huifuId = fsPayConfig2.getHuifuId();
                             } else {
                                 huifuId = fsPayConfig.getHuifuId();
                             }
                         }
 
                         V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
+                        DecimalFormat df = new DecimalFormat("0.00");
                         request.setOrgHfSeqId(payment.getTradeNo());
                         request.setHuifuId(huifuId);
-                        request.setOrdAmt(payment.getPayMoney().toString());
+                        request.setOrdAmt(df.format(refundAmount));
                         request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
                         request.setReqSeqId("refund-" + payment.getPayCode());
                         Map<String, Object> extendInfoMap = new HashMap<>();
@@ -3118,6 +3130,17 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                     if (amount != null){
                         payMoney=amount;
                     }
+                    //运费
+                    BigDecimal payPostage = order.getPayPostage();
+                    if (payPostage == null || payPostage.compareTo(BigDecimal.ZERO) <= 0){
+                        payPostage = storeConfig.getPayPostage();
+                        if (payPostage == null){
+                            payPostage = BigDecimal.ZERO;
+                        }
+                        order.setPayPrice(order.getPayPrice().add(payPostage));
+                    }
+                    order.setPayPostage(payPostage);
+                    payMoney = payMoney.add(payPostage);
                     order.setPayMoney(payMoney);
                     order.setPayDelivery(order.getPayPrice().subtract(payMoney) );
 //                    order.setPayMoney(BigDecimal.ZERO);
@@ -3131,8 +3154,8 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
             String payCode = OrderCodeUtils.getOrderSn();
 //            order.setOrderCode(orderCode);
 //            if(order.getPayType().equals("1")||order.getPayType().equals("2")){
-            if((order.getPayType().equals("1")||order.getPayType().equals("2")||order.getPayType().equals("3")) && order.getPayMoney().compareTo(new BigDecimal(0))>0){
-                LiveOrderPayment storePayment=new LiveOrderPayment();
+            if ((order.getPayType().equals("1") || order.getPayType().equals("2") || order.getPayType().equals("3")) && order.getPayMoney().compareTo(new BigDecimal(0)) > 0) {
+                LiveOrderPayment storePayment = new LiveOrderPayment();
                 storePayment.setCompanyId(order.getCompanyId());
                 storePayment.setCompanyUserId(order.getCompanyUserId());
                 storePayment.setPayMode(fsPayConfig.getType());
@@ -3149,35 +3172,35 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 storePayment.setAppId(param.getAppId());
                 liveOrderPaymentMapper.insertLiveOrderPayment(storePayment);
 
-                if (fsPayConfig.getType().equals("hf")){
+                if (fsPayConfig.getType().equals("hf")) {
                     HuiFuCreateOrder o = new HuiFuCreateOrder();
                     o.setTradeType("T_MINIAPP");
                     o.setOpenid(storePayment.getOpenId());
-                    o.setReqSeqId("live-"+storePayment.getPayCode());
+                    o.setReqSeqId("live-" + storePayment.getPayCode());
                     o.setTransAmt(storePayment.getPayMoney().toString());
                     o.setGoodsDesc("直播订单支付");
                     if (StringUtils.isNotBlank(param.getAppId())) {
                         o.setAppId(param.getAppId());
                     }
                     HuifuCreateOrderResult result = huiFuService.createOrder(o);
-                    if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
-                        LiveOrderPayment mt=new LiveOrderPayment();
+                    if (result.getResp_code() != null && (result.getResp_code().equals("00000000") || result.getResp_code().equals("00000100"))) {
+                        LiveOrderPayment mt = new LiveOrderPayment();
                         mt.setPaymentId(storePayment.getPaymentId());
                         mt.setTradeNo(result.getHf_seq_id());
                         mt.setAppId(param.getAppId());
                         mt.setBusinessCode(order.getOrderCode());
                         liveOrderPaymentMapper.updateLiveOrderPayment(mt);
-                        redisCache.setCacheObject("isPaying:"+order.getOrderId(),order.getOrderId().toString(),1, TimeUnit.MINUTES);
+                        redisCache.setCacheObject("isPaying:" + order.getOrderId(), order.getOrderId().toString(), 1, TimeUnit.MINUTES);
                         log.info("汇付支付");
-                        Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
+                        Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {
+                        });
                         String s = (String) resultMap.get("package");
-                        resultMap.put("packageValue",s);
-                        return R.ok().put("payType",param.getPayType()).put("result",resultMap);
-                    }
-                    else{
+                        resultMap.put("packageValue", s);
+                        return R.ok().put("payType", param.getPayType()).put("result", resultMap);
+                    } else {
                         return R.error(result.getResp_desc());
                     }
-                }else  if (fsPayConfig.getType().equals("wx")){
+                } else if (fsPayConfig.getType().equals("wx")) {
                     WxPayConfig payConfig = new WxPayConfig();
                     payConfig.setAppId(fsPayConfig.getAppId());
                     payConfig.setMchId(fsPayConfig.getWxMchId());
@@ -3198,7 +3221,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                     //调用统一下单接口,获取"预支付交易会话标识"
                     try {
                         WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
-                        return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0).put("payType",param.getPayType());
+                        return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0).put("payType", param.getPayType());
                     } catch (WxPayException e) {
                         e.printStackTrace();
                         throw new CustomException("支付失败" + e.getMessage());
@@ -3206,10 +3229,10 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 }
             }
 //            else if(order.getPayType().equals("3")){
-            else if(order.getPayType().equals("3") && order.getPayMoney().compareTo(new BigDecimal(0))<=0){
+            else if (order.getPayType().equals("3") && order.getPayMoney().compareTo(new BigDecimal(0)) <= 0) {
                 //货到付款
-                this.payConfirm(2,order.getOrderId(),null,null,null,null);
-                return R.ok().put("payType",param.getPayType());
+                this.payConfirm(2, order.getOrderId(), null, null, null, null);
+                return R.ok().put("payType", param.getPayType());
             }
             return R.error();
         }
@@ -3661,7 +3684,6 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         liveOrder.setStatus(OrderInfoEnum.STATUS_0.getValue());
         liveOrder.setPayType("1");
         liveOrder.setTotalPrice(payPrice);
-        liveOrder.setPayMoney(BigDecimal.ZERO);
         liveOrder.setPayPrice(payPrice.subtract(liveOrder.getDiscountMoney()));
         try {
             if (baseMapper.insertLiveOrder(liveOrder) > 0) {

+ 13 - 3
fs-service/src/main/java/com/fs/live/service/impl/LiveServiceImpl.java

@@ -1348,15 +1348,25 @@ public class LiveServiceImpl implements ILiveService
         return jsonObject.getLong(key);
     }
 
+
     /**
-     * 清除直播间数据缓存
+     * 清除直播间数据缓存(公开方法)
      * @param liveId 直播间ID
+     * @return 结果
      */
-    private void clearLiveCache(Long liveId) {
-        if (liveId != null) {
+    @Override
+    public R clearLiveCache(Long liveId) {
+        if (liveId == null) {
+            return R.error("直播间ID不能为空");
+        }
+        try {
             String cacheKey = String.format(LiveKeysConstant.LIVE_DATA_CACHE, liveId);
             redisCache.deleteObject(cacheKey);
             log.debug("清除直播间缓存: liveId={}", liveId);
+            return R.ok("缓存清理成功");
+        } catch (Exception e) {
+            log.error("清除直播间缓存失败: liveId={}", liveId, e);
+            return R.error("缓存清理失败: " + e.getMessage());
         }
     }
 

+ 0 - 246
fs-user-app/src/main/java/com/fs/app/controller/live/LiveController.java

@@ -91,252 +91,6 @@ public class LiveController extends AppBaseController {
     @Autowired
     private com.fs.live.mapper.LiveOrderMapper liveOrderMapper;
 
-
-	@GetMapping("/test/{liveId}")
-	public void test(@PathVariable("liveId") Long liveId) {
-		Live live = liveService.selectLiveDbByLiveId(liveId);
-		List<LiveVideo> liveVideos = liveVideoMapper.selectByIdAndType(liveId, 1);
-		Long duration = liveVideos.get(0).getDuration();
-		List<LiveWatchUser> liveWatchUsers = liveWatchUserService.selectLiveWatchUserListByLiveId(live.getLiveId());
-		List<LiveWatchUser> online = liveWatchUsers.stream().filter(liveWatchUser -> 1 == liveWatchUser.getLiveFlag()).collect(Collectors.toList());
-		List<LiveWatchUser> offline = liveWatchUsers.stream().filter(liveWatchUser -> 1 == liveWatchUser.getReplayFlag()).collect(Collectors.toList());
-		this.adjustWatchDuration(liveId,liveWatchUsers,online,offline,liveWatchUsers.size(),duration);
-	}
-
-	/**
-	 * 调整观看时长以满足统计要求
-	 * 按照每个分公司学员人数,随机50%的人,添加看课时长
-	 * 40%的人看课是30min-40min随机,其中一定包含购买商品用户
-	 * 10%的人看课是20min-29min随机,其中一定包含购买商品用户
-	 * 剩余50%看课是0-19min随机
-	 * 回放规则同上
-	 */
-	private void adjustWatchDuration(Long liveId, List<LiveWatchUser> allUsers,
-									 List<LiveWatchUser> liveUsers, List<LiveWatchUser> replayUsers,
-									 long totalViewers, Long videoDuration) {
-
-		// 查询购买商品的用户(is_pay = '1')
-		com.fs.live.domain.LiveOrder orderQuery = new com.fs.live.domain.LiveOrder();
-		orderQuery.setLiveId(liveId);
-		List<com.fs.live.domain.LiveOrder> orders = liveOrderMapper.selectLiveOrderList(orderQuery);
-		Set<Long> paidUserIds = orders.stream()
-				.filter(o -> "1".equals(o.getIsPay()) && o.getUserId() != null && !o.getUserId().isEmpty())
-				.map(o -> {
-					try {
-						return Long.parseLong(o.getUserId());
-					} catch (NumberFormatException e) {
-						return null;
-					}
-				})
-				.filter(java.util.Objects::nonNull)
-				.collect(Collectors.toSet());
-
-		// 查询每个分公司的学员(通过 live_user_first_entry 表)
-		com.fs.live.domain.LiveUserFirstEntry firstEntryQuery = new com.fs.live.domain.LiveUserFirstEntry();
-		firstEntryQuery.setLiveId(liveId);
-		List<com.fs.live.domain.LiveUserFirstEntry> firstEntries = liveUserFirstEntryMapper.selectLiveUserFirstEntryList(firstEntryQuery);
-		
-		// 按分公司分组用户
-		Map<Long, List<Long>> companyUserMap = new HashMap<>();
-		Map<Long, Long> userCompanyMap = new HashMap<>(); // 用户ID -> 分公司ID
-		Set<Long> usersWithCompany = new HashSet<>(); // 有分公司的用户
-		
-		for (com.fs.live.domain.LiveUserFirstEntry entry : firstEntries) {
-			if (entry.getCompanyId() != null && entry.getUserId() != null) {
-				companyUserMap.computeIfAbsent(entry.getCompanyId(), k -> new ArrayList<>()).add(entry.getUserId());
-				userCompanyMap.put(entry.getUserId(), entry.getCompanyId());
-				usersWithCompany.add(entry.getUserId());
-			}
-		}
-		
-		// 处理没有分公司的用户(归到一个虚拟分公司,companyId = null 或 0)
-		Long noCompanyId = 0L;
-		for (LiveWatchUser user : allUsers) {
-			Long userId = user.getUserId();
-			if (userId != null && !usersWithCompany.contains(userId)) {
-				companyUserMap.computeIfAbsent(noCompanyId, k -> new ArrayList<>()).add(userId);
-				userCompanyMap.put(userId, noCompanyId);
-			}
-		}
-
-		// 按用户ID分组,合并同一用户的观看时长(把观看时间平分到各个用户身上)
-		Map<Long, List<LiveWatchUser>> allUserMap = new HashMap<>();
-		Map<Long, LiveWatchUser> liveUserMap = new HashMap<>();
-		Map<Long, LiveWatchUser> replayUserMap = new HashMap<>();
-
-		for (LiveWatchUser user : allUsers) {
-			Long userId = user.getUserId();
-			if (userId == null) continue;
-
-			allUserMap.computeIfAbsent(userId, k -> new ArrayList<>()).add(user);
-
-			if (user.getLiveFlag() != null && user.getLiveFlag() == 1 && (user.getReplayFlag() == null || user.getReplayFlag() == 0)) {
-				LiveWatchUser existing = liveUserMap.get(userId);
-				if (existing == null) {
-					liveUserMap.put(userId, user);
-				} else {
-					// 合并观看时长:把观看时间平分到各个用户身上
-					long totalSeconds = (existing.getOnlineSeconds() != null ? existing.getOnlineSeconds() : 0L) +
-							(user.getOnlineSeconds() != null ? user.getOnlineSeconds() : 0L);
-					existing.setOnlineSeconds(totalSeconds);
-				}
-			} else if (user.getReplayFlag() != null && user.getReplayFlag() == 1 && (user.getLiveFlag() == null || user.getLiveFlag() == 0)) {
-				LiveWatchUser existing = replayUserMap.get(userId);
-				if (existing == null) {
-					replayUserMap.put(userId, user);
-				} else {
-					// 合并观看时长:把观看时间平分到各个用户身上
-					long totalSeconds = (existing.getOnlineSeconds() != null ? existing.getOnlineSeconds() : 0L) +
-							(user.getOnlineSeconds() != null ? user.getOnlineSeconds() : 0L);
-					existing.setOnlineSeconds(totalSeconds);
-				}
-			}
-		}
-
-		// 按分公司处理直播用户观看时长
-		adjustWatchDurationByCompany(liveUserMap, companyUserMap, userCompanyMap, paidUserIds, true);
-		
-		// 按分公司处理回放用户观看时长(规则同上)
-		adjustWatchDurationByCompany(replayUserMap, companyUserMap, userCompanyMap, paidUserIds, false);
-
-		// 更新数据库
-		Date now = new Date();
-		int batchSize = 500;
-		for (int i = 0; i < allUsers.size(); i += batchSize) {
-			int end = Math.min(i + batchSize, allUsers.size());
-			List<LiveWatchUser> batch = allUsers.subList(i, end);
-			for (LiveWatchUser user : batch) {
-				user.setUpdateTime(now);
-			}
-			liveWatchUserService.batchUpdateLiveWatchUser(batch);
-		}
-
-		log.info("直播间 {} 观看时长调整完成:总观看人数={}, 视频时长={}秒",
-				liveId, totalViewers, videoDuration);
-	}
-
-	/**
-	 * 按分公司调整观看时长
-	 * @param userMap 用户观看记录Map(userId -> LiveWatchUser)
-	 * @param companyUserMap 分公司用户Map(companyId -> List<userId>)
-	 * @param userCompanyMap 用户分公司Map(userId -> companyId)
-	 * @param paidUserIds 购买商品的用户ID集合
-	 * @param isLive 是否为直播(true=直播,false=回放)
-	 */
-	private void adjustWatchDurationByCompany(Map<Long, LiveWatchUser> userMap,
-											   Map<Long, List<Long>> companyUserMap,
-											   Map<Long, Long> userCompanyMap,
-											   Set<Long> paidUserIds,
-											   boolean isLive) {
-		
-		// 遍历每个分公司
-		for (Map.Entry<Long, List<Long>> companyEntry : companyUserMap.entrySet()) {
-			Long companyId = companyEntry.getKey();
-			List<Long> companyUserIds = companyEntry.getValue();
-			
-			// 筛选出该分公司有观看记录的用户
-			List<Long> companyWatchUserIds = companyUserIds.stream()
-					.filter(userId -> userMap.containsKey(userId))
-					.collect(Collectors.toList());
-			
-			if (companyWatchUserIds.isEmpty()) {
-				continue;
-			}
-			
-			// 随机选择50%的人添加看课时长
-			Collections.shuffle(companyWatchUserIds);
-			int selectedCount = (int) Math.round(companyWatchUserIds.size() * 0.5);
-			List<Long> selectedUserIds = companyWatchUserIds.subList(0, Math.min(selectedCount, companyWatchUserIds.size()));
-			
-			// 分离购买商品的用户和未购买商品的用户
-			List<Long> paidUsers = selectedUserIds.stream()
-					.filter(paidUserIds::contains)
-					.collect(Collectors.toList());
-			List<Long> unpaidUsers = selectedUserIds.stream()
-					.filter(userId -> !paidUserIds.contains(userId))
-					.collect(Collectors.toList());
-			
-			// 计算各区间人数
-			// 40%的人(即总人数的20%)看课30-40分钟,必须包含购买商品用户
-			// 10%的人(即总人数的5%)看课20-29分钟,必须包含购买商品用户
-			// 剩余50%的人(即总人数的25%)看课0-19分钟
-			int count30to40 = (int) Math.round(selectedUserIds.size() * 0.4);
-			int count20to29 = (int) Math.round(selectedUserIds.size() * 0.1);
-			int count0to19 = selectedUserIds.size() - count30to40 - count20to29;
-			
-			// 确保购买商品的用户被包含在30-40分钟或20-29分钟组中
-			List<Long> users30to40 = new ArrayList<>();
-			List<Long> users20to29 = new ArrayList<>();
-			List<Long> users0to19 = new ArrayList<>();
-			
-			// 优先将购买商品的用户分配到30-40分钟组
-			int paidIndex = 0;
-			for (int i = 0; i < count30to40 && paidIndex < paidUsers.size(); i++) {
-				users30to40.add(paidUsers.get(paidIndex++));
-			}
-			
-			// 如果30-40分钟组还有空位,从购买商品用户中继续分配
-			for (int i = users30to40.size(); i < count30to40 && paidIndex < paidUsers.size(); i++) {
-				users30to40.add(paidUsers.get(paidIndex++));
-			}
-			
-			// 如果还有购买商品的用户,分配到20-29分钟组
-			for (int i = 0; i < count20to29 && paidIndex < paidUsers.size(); i++) {
-				users20to29.add(paidUsers.get(paidIndex++));
-			}
-			
-			// 剩余的购买商品用户分配到0-19分钟组
-			while (paidIndex < paidUsers.size()) {
-				users0to19.add(paidUsers.get(paidIndex++));
-			}
-			
-			// 填充30-40分钟组(从未购买用户中随机选择)
-			Collections.shuffle(unpaidUsers);
-			int unpaidIndex = 0;
-			for (int i = users30to40.size(); i < count30to40 && unpaidIndex < unpaidUsers.size(); i++) {
-				users30to40.add(unpaidUsers.get(unpaidIndex++));
-			}
-			
-			// 填充20-29分钟组(从未购买用户中随机选择)
-			for (int i = users20to29.size(); i < count20to29 && unpaidIndex < unpaidUsers.size(); i++) {
-				users20to29.add(unpaidUsers.get(unpaidIndex++));
-			}
-			
-			// 剩余用户分配到0-19分钟组
-			while (unpaidIndex < unpaidUsers.size()) {
-				users0to19.add(unpaidUsers.get(unpaidIndex++));
-			}
-			
-			// 设置30-40分钟的用户观看时长(1800-2400秒)
-			for (Long userId : users30to40) {
-				LiveWatchUser user = userMap.get(userId);
-				if (user != null) {
-					user.setOnlineSeconds(1800L + (long)(Math.random() * 600)); // 30-40分钟
-				}
-			}
-			
-			// 设置20-29分钟的用户观看时长(1200-1740秒)
-			for (Long userId : users20to29) {
-				LiveWatchUser user = userMap.get(userId);
-				if (user != null) {
-					user.setOnlineSeconds(1200L + (long)(Math.random() * 540)); // 20-29分钟
-				}
-			}
-			
-			// 设置0-19分钟的用户观看时长(0-1140秒)
-			for (Long userId : users0to19) {
-				LiveWatchUser user = userMap.get(userId);
-				if (user != null) {
-					user.setOnlineSeconds((long)(Math.random() * 1140)); // 0-19分钟
-				}
-			}
-			
-			log.debug("分公司 {} {}用户观看时长调整:总人数={}, 选中人数={}, 30-40分钟={}, 20-29分钟={}, 0-19分钟={}, 购买用户数={}",
-					companyId, isLive ? "直播" : "回放", companyWatchUserIds.size(), selectedUserIds.size(),
-					users30to40.size(), users20to29.size(), users0to19.size(), paidUsers.size());
-		}
-	}
-
 	/**
 	 * 查询未结束直播间(销售专用)
 	 */

+ 0 - 322
fs-user-app/src/main/java/com/fs/app/controller/live/LiveOrderController.java

@@ -323,328 +323,6 @@ public class LiveOrderController extends AppBaseController
         return orderService.createLiveOrder(param);
     }
 
-//    @Login
-//    @ApiOperation("支付")
-//    @PostMapping("/pay")
-//    @Transactional
-//    //@Synchronized
-//    public R pay(HttpServletRequest request, @Validated @RequestBody LiveOrderPayParam param)
-//    {
-//        LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
-//        if(order==null){
-//            return R.error("订单不存在");
-//        }
-//        if(order.getStatus()!= OrderInfoEnum.STATUS_0.getValue()){
-//            return R.error("订单状态不正确");
-//        }
-//        String orderId=redisCache.getCacheObject("isPaying:"+order.getOrderId());
-//        if(StringUtils.isNotEmpty(orderId)&&orderId.equals(order.getOrderId().toString())){
-//            return R.error("正在支付中...");
-//        }
-//
-//        FsUserScrm user=userService.selectFsUserById(Long.valueOf(order.getUserId()));
-//        if(user!=null&& StringUtils.isNotEmpty(user.getMaOpenId())){
-//            //已改价处理
-//            if(order.getIsEditMoney()!=null&&order.getIsEditMoney()==1){
-//                //改过价不做处理
-//
-//            }
-//            else{
-//                String config=configService.selectConfigByKey("his.store");
-//                StoreConfig storeConfig= JSONUtil.toBean(config,StoreConfig.class);
-//                if(param.getPayType().equals(1)){
-//                    order.setPayType("1");
-//                    order.setPayMoney(order.getPayPrice());
-//                    order.setPayDelivery(BigDecimal.ZERO);
-//                }
-//                else if(param.getPayType().equals(2)){
-//                    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());
-//                    order.setPayDelivery(order.getPayPrice().subtract(payMoney));
-//                    order.setPayMoney(payMoney);
-//                }
-//                else if(param.getPayType().equals(3)){
-//                    //货到付款
-//                    order.setPayType("3");
-//                    BigDecimal amount=redisCache.getCacheObject("orderAmount:"+order.getOrderId());
-//                    BigDecimal payMoney = BigDecimal.ZERO;
-//                    if (amount != null){
-//                        payMoney=amount;
-//                    }
-//                    order.setPayMoney(payMoney);
-//                    order.setPayDelivery(order.getPayPrice().subtract(payMoney) );
-////                    order.setPayMoney(BigDecimal.ZERO);
-//                }
-//                orderService.updateLiveOrder(order);
-//            }
-//            String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
-////            order.setOrderCode(orderCode);
-////            if(order.getPayType().equals("1")||order.getPayType().equals("2")){
-//            if((order.getPayType().equals("1")||order.getPayType().equals("2")||order.getPayType().equals("3")) && order.getPayMoney().compareTo(new BigDecimal(0))>0){
-//                String json = configService.selectConfigByKey("his.pay");
-//                FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
-//                LiveOrderPayment storePayment=new LiveOrderPayment();
-//                storePayment.setCompanyId(order.getCompanyId());
-//                storePayment.setCompanyUserId(order.getCompanyUserId());
-//                storePayment.setPayMode(fsPayConfig.getType());
-//                storePayment.setStatus(0);
-//                storePayment.setPayCode(payCode);
-//                storePayment.setPayMoney(order.getPayMoney());
-//                storePayment.setCreateTime(new Date());
-//                storePayment.setPayTypeCode("weixin");
-//                storePayment.setBusinessType(2);
-//                storePayment.setRemark("直播订单支付");
-//                storePayment.setOpenId(user.getRealName());
-//                storePayment.setUserId(user.getUserId());
-//                storePayment.setBusinessId(String.valueOf(order.getOrderId()));
-//                liveOrderPaymentMapper.insertLiveOrderPayment(storePayment);
-//
-//                if (fsPayConfig.getType().equals("hf")){
-//                    HuiFuCreateOrder o = new HuiFuCreateOrder();
-//                    o.setTradeType("T_MINIAPP");
-//                    o.setOpenid(user.getMaOpenId());
-//                    o.setReqSeqId("live-"+storePayment.getPayCode());
-//                    o.setTransAmt(storePayment.getPayMoney().toString());
-//                    o.setGoodsDesc("直播订单支付");
-//                    if (param != null && StringUtils.isNotBlank(param.getAppId())) {
-//                        o.setAppId(param.getAppId());
-//                    }
-//                    HuifuCreateOrderResult result = huiFuService.createOrder(o);
-//                    if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
-//                        LiveOrderPayment mt=new LiveOrderPayment();
-//                        mt.setPaymentId(storePayment.getPaymentId());
-//                        mt.setTradeNo(result.getHf_seq_id());
-//                        liveOrderPaymentMapper.updateLiveOrderPayment(mt);
-//                        redisCache.setCacheObject("isPaying:"+order.getOrderId(),order.getOrderId().toString(),1, TimeUnit.MINUTES);
-//                        Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
-//                        String s = (String) resultMap.get("package");
-//                        resultMap.put("packageValue",s);
-//                        return R.ok().put("payType",param.getPayType()).put("result",resultMap);
-//                    }
-//                    else{
-//                        return R.error(result.getResp_desc());
-//                    }
-//                }else  if (fsPayConfig.getType().equals("wx")){
-//                    WxPayConfig payConfig = new WxPayConfig();
-//                    payConfig.setAppId(fsPayConfig.getAppId());
-//                    payConfig.setMchId(fsPayConfig.getWxMchId());
-//                    payConfig.setMchKey(fsPayConfig.getWxMchKey());
-//                    payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
-//                    payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
-//                    payConfig.setKeyPath(fsPayConfig.getKeyPath());
-//                    payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
-//                    wxPayService.setConfig(payConfig);
-//                    WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
-//                    orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
-//                    orderRequest.setBody("直播订单支付");
-//                    orderRequest.setOutTradeNo("live-" + storePayment.getPayCode());
-//                    orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
-//                    //orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(money));//测试
-//                    orderRequest.setTradeType("JSAPI");
-//                    orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
-//                    //调用统一下单接口,获取"预支付交易会话标识"
-//                    try {
-//                        WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
-//                        return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0).put("payType",param.getPayType());
-//                    } catch (WxPayException e) {
-//                        e.printStackTrace();
-//                        throw new CustomException("支付失败" + e.getMessage());
-//                    }
-//                }
-//            }
-////            else if(order.getPayType().equals("3")){
-//            else if(order.getPayType().equals("3") && order.getPayMoney().compareTo(new BigDecimal(0))<=0){
-//                //货到付款
-//                orderService.payConfirm(2,order.getOrderId(),null,null,null,null);
-//                return R.ok().put("payType",param.getPayType());
-//            }
-//            return R.error();
-//        }
-//        else{
-//            return R.error("用户OPENID不存在");
-//        }
-//
-//    }
-
-    /*
-    @Login
-    @ApiOperation("支付")
-    @PostMapping("/pay")
-    @Transactional
-    //@Synchronized
-    public R pay(HttpServletRequest request, @Validated @RequestBody LiveOrderPayParam param)
-    {
-        Long orderId = param.getOrderId();
-        logger.info("开始处理支付请求, 订单号: {}, 支付类型: {}", orderId, param.getPayType());
-
-        RLock lock = redissonClient.getLock(String.format(LOCK_KEY_PAY,orderId));
-        R result = null;
-
-        try {
-            boolean locked = lock.tryLock(100, 30000, TimeUnit.MILLISECONDS);
-
-            if (!locked) {
-                logger.warn("订单正在处理中,获取锁失败, 订单号: {}", orderId);
-                return R.error("订单正在处理中,请勿重复提交");
-            }
-
-            result = orderService.pay(param);
-
-        } catch (InterruptedException e) {
-            logger.error("获取支付锁的过程被中断, 订单号: {}", orderId, e);
-            Thread.currentThread().interrupt();
-            return R.error("支付处理被中断,请稍后重试");
-        } catch (Throwable e) {
-            logger.error("支付过程中发生异常, 订单号: {}", orderId, e);
-            throw e;
-        } finally {
-            if (lock.isHeldByCurrentThread()) {
-                lock.unlock();
-                logger.debug("支付锁已释放, 订单号: {}", orderId);
-            }
-        }
-
-        return result;
-        LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
-        if(order==null){
-            return R.error("订单不存在");
-        }
-        if(order.getStatus()!= OrderInfoEnum.STATUS_0.getValue()){
-            return R.error("订单状态不正确");
-        }
-        String orderId=redisCache.getCacheObject("isPaying:"+order.getOrderId());
-        if(StringUtils.isNotEmpty(orderId)&&orderId.equals(order.getOrderId().toString())){
-            return R.error("正在支付中...");
-        }
-
-        FsUserScrm user=userService.selectFsUserById(Long.valueOf(order.getUserId()));
-        if(user!=null&& StringUtils.isNotEmpty(user.getMaOpenId())){
-            //已改价处理
-            if(order.getIsEditMoney()!=null&&order.getIsEditMoney()==1){
-                //改过价不做处理
-
-            }
-            else{
-                String config=configService.selectConfigByKey("his.store");
-                StoreConfig storeConfig= JSONUtil.toBean(config,StoreConfig.class);
-                if(param.getPayType().equals(1)){
-                    order.setPayType("1");
-                    order.setPayMoney(order.getPayPrice());
-                    order.setPayDelivery(BigDecimal.ZERO);
-                }
-                else if(param.getPayType().equals(2)){
-                    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());
-                    order.setPayDelivery(order.getPayPrice().subtract(payMoney));
-                    order.setPayMoney(payMoney);
-                }
-                else if(param.getPayType().equals(3)){
-                    //货到付款
-                    order.setPayType("3");
-                    BigDecimal amount=redisCache.getCacheObject("orderAmount:"+order.getOrderId());
-                    BigDecimal payMoney = BigDecimal.ZERO;
-                    if (amount != null){
-                        payMoney=amount;
-                    }
-                    order.setPayMoney(payMoney);
-                    order.setPayDelivery(order.getPayPrice().subtract(payMoney) );
-//                    order.setPayMoney(BigDecimal.ZERO);
-                }
-                orderService.updateLiveOrder(order);
-            }
-            String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
-//            order.setOrderCode(orderCode);
-//            if(order.getPayType().equals("1")||order.getPayType().equals("2")){
-            if((order.getPayType().equals("1")||order.getPayType().equals("2")||order.getPayType().equals("3")) && order.getPayMoney().compareTo(new BigDecimal(0))>0){
-                String json = configService.selectConfigByKey("his.pay");
-                FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
-                LiveOrderPayment storePayment=new LiveOrderPayment();
-                storePayment.setCompanyId(order.getCompanyId());
-                storePayment.setCompanyUserId(order.getCompanyUserId());
-                storePayment.setPayMode(fsPayConfig.getType());
-                storePayment.setStatus(0);
-                storePayment.setPayCode(payCode);
-                storePayment.setPayMoney(order.getPayMoney());
-                storePayment.setCreateTime(new Date());
-                storePayment.setPayTypeCode("weixin");
-                storePayment.setBusinessType(2);
-                storePayment.setRemark("直播订单支付");
-                storePayment.setOpenId(user.getRealName());
-                storePayment.setUserId(user.getUserId());
-                storePayment.setBusinessId(String.valueOf(order.getOrderId()));
-                liveOrderPaymentMapper.insertLiveOrderPayment(storePayment);
-
-                if (fsPayConfig.getType().equals("hf")){
-                    HuiFuCreateOrder o = new HuiFuCreateOrder();
-                    o.setTradeType("T_MINIAPP");
-                    o.setOpenid(user.getMaOpenId());
-                    o.setReqSeqId("live-"+storePayment.getPayCode());
-                    o.setTransAmt(storePayment.getPayMoney().toString());
-                    o.setGoodsDesc("直播订单支付");
-                    if (param != null && StringUtils.isNotBlank(param.getAppId())) {
-                        o.setAppId(param.getAppId());
-                    }
-                    HuifuCreateOrderResult result = huiFuService.createOrder(o);
-                    if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
-                        LiveOrderPayment mt=new LiveOrderPayment();
-                        mt.setPaymentId(storePayment.getPaymentId());
-                        mt.setTradeNo(result.getHf_seq_id());
-                        liveOrderPaymentMapper.updateLiveOrderPayment(mt);
-                        redisCache.setCacheObject("isPaying:"+order.getOrderId(),order.getOrderId().toString(),1, TimeUnit.MINUTES);
-                        Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
-                        String s = (String) resultMap.get("package");
-                        resultMap.put("packageValue",s);
-                        return R.ok().put("payType",param.getPayType()).put("result",resultMap);
-                    }
-                    else{
-                        return R.error(result.getResp_desc());
-                    }
-                }else  if (fsPayConfig.getType().equals("wx")){
-                    WxPayConfig payConfig = new WxPayConfig();
-                    payConfig.setAppId(fsPayConfig.getAppId());
-                    payConfig.setMchId(fsPayConfig.getWxMchId());
-                    payConfig.setMchKey(fsPayConfig.getWxMchKey());
-                    payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
-                    payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
-                    payConfig.setKeyPath(fsPayConfig.getKeyPath());
-                    payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
-                    wxPayService.setConfig(payConfig);
-                    WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
-                    orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
-                    orderRequest.setBody("直播订单支付");
-                    orderRequest.setOutTradeNo("live-" + storePayment.getPayCode());
-                    orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
-                    //orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(money));//测试
-                    orderRequest.setTradeType("JSAPI");
-                    orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
-                    //调用统一下单接口,获取"预支付交易会话标识"
-                    try {
-                        WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
-                        return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0).put("payType",param.getPayType());
-                    } catch (WxPayException e) {
-                        e.printStackTrace();
-                        throw new CustomException("支付失败" + e.getMessage());
-                    }
-                }
-            }
-//            else if(order.getPayType().equals("3")){
-            else if(order.getPayType().equals("3") && order.getPayMoney().compareTo(new BigDecimal(0))<=0){
-                //货到付款
-                orderService.payConfirm(2,order.getOrderId(),null,null,null,null);
-                return R.ok().put("payType",param.getPayType());
-            }
-            return R.error();
-        }
-        else{
-            return R.error("用户OPENID不存在");
-        }
-
-    }
-        /**
-     * 获取订单详细信息
-     */
     @Login
     @GetMapping(value = "/info/{orderId}")
     public AjaxResult getInfo(@PathVariable("orderId") String orderId)