|
|
@@ -13,11 +13,11 @@ import com.fs.common.core.domain.entity.SysDictData;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.enums.BizResponseEnum;
|
|
|
import com.fs.common.exception.CustomException;
|
|
|
+import com.fs.common.utils.CloudHostUtils;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.date.DateUtil;
|
|
|
import com.fs.company.domain.Company;
|
|
|
-import com.fs.company.domain.CompanyMoneyLogs;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyMapper;
|
|
|
import com.fs.company.mapper.CompanyMoneyLogsMapper;
|
|
|
@@ -47,6 +47,7 @@ import com.fs.his.param.WxSendRedPacketParam;
|
|
|
import com.fs.his.service.IFsStorePaymentService;
|
|
|
import com.fs.his.service.IFsUserService;
|
|
|
import com.fs.his.service.IFsUserWxService;
|
|
|
+import com.fs.his.utils.ConfigUtil;
|
|
|
import com.fs.his.vo.OptionsVO;
|
|
|
import com.fs.qw.domain.QwCompany;
|
|
|
import com.fs.qw.domain.QwExternalContact;
|
|
|
@@ -61,29 +62,37 @@ import com.fs.qwApi.service.QwApiService;
|
|
|
import com.fs.sop.mapper.QwSopLogsMapper;
|
|
|
import com.fs.sop.mapper.SopUserLogsInfoMapper;
|
|
|
import com.fs.sop.service.ISopUserLogsInfoService;
|
|
|
+import com.fs.system.domain.SysConfig;
|
|
|
import com.fs.system.mapper.SysDictDataMapper;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.voice.utils.StringUtil;
|
|
|
import com.github.binarywang.wxpay.bean.transfer.TransferBillsResult;
|
|
|
+import com.google.common.collect.Sets;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.lang.exception.ExceptionUtils;
|
|
|
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
+import org.redisson.api.RLock;
|
|
|
+import org.redisson.api.RedissonClient;
|
|
|
+import org.redisson.client.RedisClient;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.BeansException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
-import java.time.Instant;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.ZoneId;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.*;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -106,7 +115,6 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
private Boolean isNewWxMerchant;
|
|
|
private static final Logger logger = LoggerFactory.getLogger(FsUserCourseVideoServiceImpl.class);
|
|
|
|
|
|
-
|
|
|
private static final String miniappRealLink = "/pages_course/video.html?course=";
|
|
|
private static final String REAL_LINK_PREFIX = "/courseH5/pages/course/learning?course=";
|
|
|
private static final String SHORT_LINK_PREFIX = "/courseH5/pages/course/learning?s=";
|
|
|
@@ -141,6 +149,8 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
private AsyncIsAddKfXfkService xfkService;
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedissonClient redissonClient;
|
|
|
@Autowired
|
|
|
private QwExternalContactMapper qwExternalContactMapper;
|
|
|
@Autowired
|
|
|
@@ -218,6 +228,10 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
@Autowired
|
|
|
private CloudHostProper cloudHostProper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ConfigUtil configUtil;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 查询课堂视频
|
|
|
@@ -414,7 +428,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
|
|
|
@Override
|
|
|
public R isAddKf(FsUserCourseVideoAddKfUParam param) {
|
|
|
- logger.info("zyp \n【判断添加客服】:{}",param);
|
|
|
+ logger.info("【判断添加客服】:{}",param);
|
|
|
//查询用户
|
|
|
FsUser fsUser = fsUserMapper.selectFsUserByUserId(param.getUserId());
|
|
|
//用户不存在唤起重新授权
|
|
|
@@ -454,6 +468,8 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
// logger.error("看课重粉提交mq失败", e);
|
|
|
// }
|
|
|
|
|
|
+ String json = configService.selectConfigByKey("course.config");
|
|
|
+ CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
Integer isRoom = param.getIsRoom();
|
|
|
|
|
|
// 处理逻辑
|
|
|
@@ -585,7 +601,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
log.setQwUserId(Long.valueOf(param.getQwUserId()));
|
|
|
log.setCreateTime(new Date());
|
|
|
log.setLogType(3);
|
|
|
- logger.info("zyp \n【群聊生成看课记录】:{}",param);
|
|
|
+ logger.info("【群聊生成看课记录】:{}",param);
|
|
|
courseWatchLogMapper.insertFsCourseWatchLog(log);
|
|
|
}
|
|
|
|
|
|
@@ -780,7 +796,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
public R getInternetTraffic(FsUserCourseVideoFinishUParam param) {
|
|
|
try {
|
|
|
if (param.getBufferRate()==null){
|
|
|
- logger.error("zyp \n【缓冲值空】参数: {}",param);
|
|
|
+ logger.error("【缓冲值空】参数: {}",param);
|
|
|
return R.error("缓冲值空");
|
|
|
}
|
|
|
FsCourseTrafficLog trafficLog = new FsCourseTrafficLog();
|
|
|
@@ -792,6 +808,10 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
if (video == null) {
|
|
|
return R.error("视频不存在");
|
|
|
}
|
|
|
+ Company company = companyMapper.selectCompanyById(param.getCompanyId());
|
|
|
+ if (company==null){
|
|
|
+ return R.error("公司不存在");
|
|
|
+ }
|
|
|
|
|
|
// 计算流量
|
|
|
BigDecimal result = param.getBufferRate().divide(new BigDecimal("100"), 4, RoundingMode.HALF_UP);
|
|
|
@@ -891,23 +911,31 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
// if (StringUtils.isEmpty(user.getMpOpenId())){
|
|
|
// return R.error("未识别到领取信息");
|
|
|
// }
|
|
|
+ log.info("查询会员信息:{}", user);
|
|
|
if (user.getStatus()==0){
|
|
|
return R.error("会员被停用,无权限,请联系客服!");
|
|
|
}
|
|
|
- FsCourseWatchLog log = new FsCourseWatchLog();
|
|
|
+ FsCourseWatchLog watchLog = new FsCourseWatchLog();
|
|
|
|
|
|
// 根据链接类型判断是否已发放奖励
|
|
|
- log = courseWatchLogMapper.getWatchCourseVideo(param.getUserId(), param.getVideoId(), param.getQwUserId(), param.getQwExternalId());
|
|
|
- if (log == null) {
|
|
|
+ watchLog = courseWatchLogMapper.getWatchCourseVideo(param.getUserId(), param.getVideoId(), param.getQwUserId(), param.getQwExternalId());
|
|
|
+ log.info("看课记录:{}", watchLog);
|
|
|
+ if (watchLog == null) {
|
|
|
return R.error("无记录");
|
|
|
}
|
|
|
- if (log.getRewardType() != null) {
|
|
|
+ if (watchLog.getLogType() != 2) {
|
|
|
+ return R.error("未完课");
|
|
|
+ }
|
|
|
+ if (watchLog.getRewardType() != null) {
|
|
|
FsCourseRedPacketLog packetLog = redPacketLogMapper.selectFsCourseRedPacketLogByTemporary(param.getVideoId(), param.getUserId());
|
|
|
+ log.info("课程红包:{}", packetLog);
|
|
|
if(packetLog != null && packetLog.getStatus() == 1) {
|
|
|
return R.error("已领取该课程奖励,不可重复领取!");
|
|
|
}
|
|
|
if(packetLog != null && packetLog.getStatus() == 0) {
|
|
|
+ log.info("判断领取记录");
|
|
|
if(StringUtils.isNotEmpty(packetLog.getResult())){
|
|
|
+ log.info("是否有结果");
|
|
|
R r = JSON.parseObject(packetLog.getResult(), R.class);
|
|
|
return r;
|
|
|
} else {
|
|
|
@@ -925,22 +953,22 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
// 获取配置信息
|
|
|
String json = configService.selectConfigByKey("course.config");
|
|
|
CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
-
|
|
|
+ log.info("奖励类型:{}", config.getRewardType());
|
|
|
// 根据奖励类型发放不同奖励
|
|
|
switch (config.getRewardType()) {
|
|
|
// 红包奖励
|
|
|
case 1:
|
|
|
- return sendRedPacketReward(param, user, log, video, config);
|
|
|
+ return sendRedPacketReward(param, user, watchLog, video, config);
|
|
|
// 积分奖励
|
|
|
case 2:
|
|
|
- return sendIntegralReward(param,user, log, config);
|
|
|
+ return sendIntegralReward(param,user, watchLog, config);
|
|
|
// 红包+积分
|
|
|
case 3:
|
|
|
- R sendRed = sendRedPacketReward(param, user, log, video, config);
|
|
|
+ R sendRed = sendRedPacketReward(param, user, watchLog, video, config);
|
|
|
if (!Objects.equals(sendRed.get("code"), 200)) {
|
|
|
return sendRed;
|
|
|
}
|
|
|
- return sendIntegralReward(param,user, log, config);
|
|
|
+ return sendIntegralReward(param,user, watchLog, config);
|
|
|
default:
|
|
|
return R.error("参数错误!");
|
|
|
}
|
|
|
@@ -948,6 +976,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
|
|
|
@Override
|
|
|
public R sendRewardByFsUser(FsCourseSendRewardUParam param) {
|
|
|
+ log.info("进入用户判断");
|
|
|
FsUser user = fsUserMapper.selectFsUserByUserId(param.getUserId());
|
|
|
if (user == null){
|
|
|
return R.error("未识别到用户信息");
|
|
|
@@ -992,12 +1021,6 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
String json = configService.selectConfigByKey("course.config");
|
|
|
CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
|
|
|
- // 判断来源是否是app,如是app,则发放积分奖励
|
|
|
- int sourceApp = 3;
|
|
|
- if(sourceApp == param.getSource()){
|
|
|
- return sendIntegralReward(param, user, log, config);
|
|
|
- }
|
|
|
-
|
|
|
// 根据奖励类型发放不同奖励
|
|
|
switch (config.getRewardType()) {
|
|
|
// 红包奖励
|
|
|
@@ -1029,7 +1052,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
* @return 处理结果
|
|
|
*/
|
|
|
private R sendRedPacketReward(FsCourseSendRewardUParam param, FsUser user, FsCourseWatchLog log, FsUserCourseVideo video, CourseConfig config) {
|
|
|
-
|
|
|
+ logger.info("进入发放红包");
|
|
|
// 确定红包金额
|
|
|
BigDecimal amount = BigDecimal.ZERO;
|
|
|
FsUserCourseVideoRedPackage redPackage = fsUserCourseVideoRedPackageMapper.selectRedPacketByCompanyId(param.getVideoId(), param.getCompanyId(), param.getPeriodId());
|
|
|
@@ -1042,127 +1065,128 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
|
|
|
// 准备发送红包参数
|
|
|
WxSendRedPacketParam packetParam = new WxSendRedPacketParam();
|
|
|
- packetParam.setOpenId(user.getMpOpenId());
|
|
|
- // 来源是小程序切换openId
|
|
|
- if (param.getSource() == 2) {
|
|
|
- //处理多小程序问题
|
|
|
+
|
|
|
+ if (user.getMpOpenId()!=null&&!isNewWxMerchant){
|
|
|
+ packetParam.setOpenId(user.getMpOpenId());
|
|
|
+ }else {
|
|
|
+ //修复数据
|
|
|
FsUserWx fsUserWx = fsUserWxService.selectByAppIdAndUserId(param.getAppId(),user.getUserId(),1);
|
|
|
if (fsUserWx ==null){
|
|
|
+ if (user.getCourseMaOpenId()==null){
|
|
|
+ logger.error(" 【转账openId参数错误】:{}", user.getUserId());
|
|
|
+ return R.error("openId参数错误,请清理缓存后重新授权!");
|
|
|
+ }
|
|
|
+ packetParam.setOpenId(user.getCourseMaOpenId());
|
|
|
try {
|
|
|
handleFsUserWx(user,param.getAppId());
|
|
|
}catch (Exception e){
|
|
|
- logger.error("zyp \n 【更新或插入用户与小程序的绑定关系失败】:{}", user.getUserId());
|
|
|
+ logger.error(" 【更新或插入用户与小程序的绑定关系失败】:{}", user.getUserId(),e);
|
|
|
}
|
|
|
+
|
|
|
}else {
|
|
|
packetParam.setOpenId(fsUserWx.getOpenId());
|
|
|
}
|
|
|
- //查出公司绑定openid并赋值
|
|
|
+ }
|
|
|
|
|
|
+// packetParam.setOpenId(user.getMpOpenId());
|
|
|
+// // 来源是小程序切换openId
|
|
|
+// if (param.getSource() == 2) {
|
|
|
+// //处理多小程序问题
|
|
|
+// FsUserWx fsUserWx = fsUserWxService.selectByAppIdAndUserId(param.getAppId(),user.getUserId(),1);
|
|
|
+// if (fsUserWx ==null){
|
|
|
+// try {
|
|
|
+// handleFsUserWx(user,param.getAppId());
|
|
|
+// }catch (Exception e){
|
|
|
+// logger.error("【更新或插入用户与小程序的绑定关系失败】:{}", user.getUserId());
|
|
|
+// }
|
|
|
+// }else {
|
|
|
+// packetParam.setOpenId(fsUserWx.getOpenId());
|
|
|
+// }
|
|
|
+// //查出公司绑定openid并赋值
|
|
|
+// }
|
|
|
+
|
|
|
+ //判断服务号配置是否存在
|
|
|
+ if (StringUtils.isNotEmpty(config.getMpAppId())){
|
|
|
+ packetParam.setMpAppId(config.getMpAppId());
|
|
|
}
|
|
|
packetParam.setAmount(amount);
|
|
|
packetParam.setSource(param.getSource());
|
|
|
packetParam.setRedPacketMode(config.getRedPacketMode());
|
|
|
packetParam.setCompanyId(param.getCompanyId());
|
|
|
packetParam.setAppId(param.getAppId());
|
|
|
+ packetParam.setUser(user);
|
|
|
|
|
|
- System.out.println("红包金额"+amount);
|
|
|
- System.out.println("红包商户号"+packetParam);
|
|
|
+ logger.info("红包金额 {},红包商户号 {}",amount,packetParam);
|
|
|
//2025.6.19 红包金额为0的时候
|
|
|
if (amount.compareTo(BigDecimal.ZERO)>0){
|
|
|
-
|
|
|
-// Company company = companyMapper.selectCompanyByIdForUpdate(param.getCompanyId());
|
|
|
- // BigDecimal money = company.getMoney();
|
|
|
- // BigDecimal subtract = money.subtract(amount);
|
|
|
-// if (subtract.compareTo(BigDecimal.ZERO)<0){
|
|
|
-// FsCourseRedPacketLog redPacketLog = new FsCourseRedPacketLog();
|
|
|
-// redPacketLog.setCourseId(param.getCourseId());
|
|
|
-// redPacketLog.setCompanyId(param.getCompanyId());
|
|
|
-// redPacketLog.setUserId(param.getUserId());
|
|
|
-// redPacketLog.setVideoId(param.getVideoId());
|
|
|
-// redPacketLog.setStatus(2);
|
|
|
-// redPacketLog.setQwUserId(param.getQwUserId() != null ? param.getQwUserId() : null);
|
|
|
-// redPacketLog.setCompanyUserId(param.getCompanyUserId());
|
|
|
-// redPacketLog.setCreateTime(new Date());
|
|
|
-// redPacketLog.setAmount(amount);
|
|
|
-// redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
|
|
|
-// redPacketLog.setPeriodId(param.getPeriodId());
|
|
|
-// redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
-// return R.error("余额不足请稍等");
|
|
|
-// }
|
|
|
// 发送红包
|
|
|
- R sendRedPacket = paymentService.sendRedPacket(packetParam);
|
|
|
- if (sendRedPacket.get("code").equals(200)) {
|
|
|
- FsCourseRedPacketLog redPacketLog = new FsCourseRedPacketLog();
|
|
|
- TransferBillsResult transferBillsResult;
|
|
|
- if (sendRedPacket.get("isNew").equals(1)){
|
|
|
- transferBillsResult = (TransferBillsResult)sendRedPacket.get("data");
|
|
|
- redPacketLog.setResult(JSON.toJSONString(sendRedPacket));
|
|
|
- redPacketLog.setOutBatchNo(transferBillsResult.getOutBillNo());
|
|
|
- }else {
|
|
|
- redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
|
|
|
- }
|
|
|
- // 添加红包记录
|
|
|
- redPacketLog.setCourseId(param.getCourseId());
|
|
|
-// redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
|
|
|
- redPacketLog.setCompanyId(param.getCompanyId());
|
|
|
- redPacketLog.setUserId(param.getUserId());
|
|
|
- redPacketLog.setVideoId(param.getVideoId());
|
|
|
- redPacketLog.setStatus(0);
|
|
|
- redPacketLog.setQwUserId(param.getQwUserId() != null ? param.getQwUserId() : null);
|
|
|
- redPacketLog.setCompanyUserId(param.getCompanyUserId());
|
|
|
- redPacketLog.setCreateTime(new Date());
|
|
|
- redPacketLog.setAmount(amount);
|
|
|
- redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
|
|
|
- redPacketLog.setPeriodId(param.getPeriodId());
|
|
|
- redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
-
|
|
|
- // 更新观看记录的奖励类型
|
|
|
- log.setRewardType(config.getRewardType());
|
|
|
- courseWatchLogMapper.updateFsCourseWatchLog(log);
|
|
|
-//
|
|
|
-// company.setMoney(subtract);
|
|
|
-// companyMapper.updateCompany(company);
|
|
|
-//
|
|
|
-// CompanyMoneyLogs logs=new CompanyMoneyLogs();
|
|
|
-// logs.setCompanyId(company.getCompanyId());
|
|
|
-// logs.setRemark("扣除红包金额");
|
|
|
-// logs.setMoney(amount.multiply(new BigDecimal(-1)));
|
|
|
-// logs.setLogsType(15);
|
|
|
-// logs.setBalance(company.getMoney());
|
|
|
-// logs.setCreateTime(new Date());
|
|
|
-// moneyLogsMapper.insertCompanyMoneyLogs(logs);
|
|
|
-
|
|
|
- return sendRedPacket;
|
|
|
- } else {
|
|
|
- return R.error("奖励发送失败,请联系客服");
|
|
|
- }
|
|
|
+ return sendRedPacketRewardToUser(param, log, config, packetParam, amount);
|
|
|
} else {
|
|
|
FsCourseRedPacketLog redPacketLog = new FsCourseRedPacketLog();
|
|
|
// 添加红包记录
|
|
|
redPacketLog.setCourseId(param.getCourseId());
|
|
|
-// redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
|
|
|
+
|
|
|
redPacketLog.setCompanyId(param.getCompanyId());
|
|
|
redPacketLog.setUserId(param.getUserId());
|
|
|
redPacketLog.setVideoId(param.getVideoId());
|
|
|
redPacketLog.setStatus(0);
|
|
|
- redPacketLog.setQwUserId(param.getQwUserId() != null ? param.getQwUserId() : null);
|
|
|
+ redPacketLog.setQwUserId(param.getQwUserId());
|
|
|
redPacketLog.setCompanyUserId(param.getCompanyUserId());
|
|
|
redPacketLog.setCreateTime(new Date());
|
|
|
redPacketLog.setAmount(BigDecimal.ZERO);
|
|
|
- redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
|
|
|
+ redPacketLog.setWatchLogId(log.getLogId());
|
|
|
redPacketLog.setPeriodId(param.getPeriodId());
|
|
|
redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
|
|
|
// 更新观看记录的奖励类型
|
|
|
-// if (param.getLinkType() == null || param.getLinkType() == 0) {
|
|
|
log.setRewardType(config.getRewardType());
|
|
|
courseWatchLogMapper.updateFsCourseWatchLog(log);
|
|
|
-// }
|
|
|
return R.ok("红包发送成功");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private R sendRedPacketRewardToUser(FsCourseSendRewardUParam param, FsCourseWatchLog log, CourseConfig config, WxSendRedPacketParam packetParam, BigDecimal amount) {
|
|
|
+
|
|
|
+
|
|
|
+ // 发送红包
|
|
|
+ R sendRedPacket = paymentService.sendRedPacket(packetParam);
|
|
|
+ if (sendRedPacket.get("code").equals(200)) {
|
|
|
+ FsCourseRedPacketLog redPacketLog = new FsCourseRedPacketLog();
|
|
|
+ TransferBillsResult transferBillsResult;
|
|
|
+ if (sendRedPacket.get("isNew").equals(1)){
|
|
|
+ transferBillsResult = (TransferBillsResult)sendRedPacket.get("data");
|
|
|
+ redPacketLog.setResult(JSON.toJSONString(sendRedPacket));
|
|
|
+ redPacketLog.setOutBatchNo(transferBillsResult.getOutBillNo());
|
|
|
+ }else {
|
|
|
+ redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
|
|
|
+ }
|
|
|
+ // 添加红包记录
|
|
|
+ redPacketLog.setCourseId(param.getCourseId());
|
|
|
+ redPacketLog.setCompanyId(param.getCompanyId());
|
|
|
+ redPacketLog.setUserId(param.getUserId());
|
|
|
+ redPacketLog.setVideoId(param.getVideoId());
|
|
|
+ redPacketLog.setStatus(0);
|
|
|
+ redPacketLog.setQwUserId(param.getQwUserId() != null ? param.getQwUserId() : null);
|
|
|
+ redPacketLog.setCompanyUserId(param.getCompanyUserId());
|
|
|
+ redPacketLog.setCreateTime(new Date());
|
|
|
+ redPacketLog.setAmount(amount);
|
|
|
+ redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
|
|
|
+ redPacketLog.setPeriodId(param.getPeriodId());
|
|
|
+
|
|
|
+ redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
+ // 更新观看记录的奖励类型
|
|
|
+ log.setRewardType(config.getRewardType());
|
|
|
+ courseWatchLogMapper.updateFsCourseWatchLog(log);
|
|
|
+
|
|
|
+ return sendRedPacket;
|
|
|
+ } else {
|
|
|
+ return R.error("奖励发送失败,请联系客服");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
private void handleFsUserWx(FsUser user, String appId) {
|
|
|
FsUserWx fsUserWx = new FsUserWx();
|
|
|
@@ -1175,7 +1199,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
fsUserWx.setUpdateTime(new Date());
|
|
|
fsUserWxService.saveOrUpdateByUniqueKey(fsUserWx);
|
|
|
|
|
|
- logger.info("zyp \n 【更新或插入用户与小程序{}的绑定关系】:{}", appId, user.getUserId());
|
|
|
+ logger.info("【更新或插入用户与小程序{}的绑定关系】:{}", appId, user.getUserId());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1226,17 +1250,18 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
if (user.getMpOpenId()!=null&&!isNewWxMerchant){
|
|
|
packetParam.setOpenId(user.getMpOpenId());
|
|
|
}else {
|
|
|
+ //修复数据
|
|
|
FsUserWx fsUserWx = fsUserWxService.selectByAppIdAndUserId(param.getAppId(),user.getUserId(),1);
|
|
|
if (fsUserWx ==null){
|
|
|
if (user.getCourseMaOpenId()==null){
|
|
|
- logger.error("zyp \n 【转账openId参数错误】:{}", user.getUserId());
|
|
|
- return R.error("openId参数错误");
|
|
|
+ logger.error(" 【转账openId参数错误】:{}", user.getUserId());
|
|
|
+ return R.error("openId参数错误,请清理缓存后重新授权!");
|
|
|
}
|
|
|
packetParam.setOpenId(user.getCourseMaOpenId());
|
|
|
try {
|
|
|
handleFsUserWx(user,param.getAppId());
|
|
|
}catch (Exception e){
|
|
|
- logger.error("zyp \n 【更新或插入用户与小程序的绑定关系失败】:{}", user.getUserId(),e);
|
|
|
+ logger.error(" 【更新或插入用户与小程序的绑定关系失败】:{}", user.getUserId(),e);
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
@@ -1256,11 +1281,8 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
packetParam.setAppId(param.getAppId());
|
|
|
packetParam.setUser(user);
|
|
|
|
|
|
- System.out.println("红包金额"+amount);
|
|
|
- System.out.println("红包商户号"+packetParam);
|
|
|
-// if (ObjectUtils.isNotEmpty(config.getIsNegative())&&config.getIsNegative() == 1) {
|
|
|
-// return processRedPacket(config, packetParam, param, amount, log);
|
|
|
-// }
|
|
|
+ logger.info("红包金额 {},红包商户号 {}",amount,packetParam);
|
|
|
+
|
|
|
//2025.6.19 红包金额为0的时候
|
|
|
if (amount.compareTo(BigDecimal.ZERO)>0){
|
|
|
|
|
|
@@ -1269,6 +1291,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
if (money.compareTo(BigDecimal.ZERO)<0) {
|
|
|
return R.error("服务商余额不足,请联系群主服务器充值!");
|
|
|
}
|
|
|
+
|
|
|
// 发送红包
|
|
|
R sendRedPacket = paymentService.sendRedPacket(packetParam);
|
|
|
if (sendRedPacket.get("code").equals(200)) {
|
|
|
@@ -1295,6 +1318,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
|
|
|
redPacketLog.setPeriodId(param.getPeriodId());
|
|
|
redPacketLog.setAppId(param.getAppId());
|
|
|
+
|
|
|
redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
|
|
|
// 更新观看记录的奖励类型
|
|
|
@@ -1462,6 +1486,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
redPacketLog.setAmount(BigDecimal.valueOf(config.getAnswerIntegral()).divide(BigDecimal.valueOf(1000)));
|
|
|
redPacketLog.setRemark("点播答题领取积分转");
|
|
|
redPacketLog.setWatchLogId(log.getLogId() !=null ? log.getLogId() : null);
|
|
|
+ redPacketLog.setPeriodId(param.getPeriodId());
|
|
|
redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
return R.ok("奖励发放成功").put("rewardType",config.getRewardType());
|
|
|
}
|
|
|
@@ -1601,7 +1626,6 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
return ResponseResult.fail(504, "课程配置错误,项目归属为空,课程ID: " + param.getCourseId());
|
|
|
}
|
|
|
|
|
|
- // 查询【用户-项目】关系
|
|
|
FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(fsUser.getUserId(), courseProject);
|
|
|
|
|
|
// 添加逻辑:如果存在fs_user表数据,但是又不存在fs_user_company_user表,则表示是以前企微看课的,需要手动绑定
|
|
|
@@ -1648,12 +1672,13 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
return ResponseResult.fail(504, "请观看最新的课程项目");
|
|
|
}
|
|
|
// 项目看课数限制
|
|
|
- if(!"福本源".equals(signProjectName) && !"宽益堂".equals(signProjectName)) {
|
|
|
+ if(!"福本源".equals(signProjectName) && !"宽益堂".equals(signProjectName) && !CloudHostUtils.hasCloudHostName("弘德堂")) {
|
|
|
Integer logCount = fsUserCourseMapper.selectTodayCourseWatchLogCountByUserIdAndProjectId(param.getUserId(), courseProject);
|
|
|
if (Objects.isNull(watchCourseVideo) && logCount > 0) {
|
|
|
return ResponseResult.fail(504, "超过项目看课数量限制");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//添加判断:该用户是否已经存在此课程的看课记录,并且看课记录的销售id不是传入的销售id
|
|
|
if(watchCourseVideo != null){
|
|
|
if(!watchCourseVideo.getCompanyUserId().equals(param.getCompanyUserId())) {
|
|
|
@@ -1723,6 +1748,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
LocalDateTime effectiveEndTime = companyUserEndDateTime != null ?
|
|
|
companyUserEndDateTime : periodDays.getEndDateTime();
|
|
|
// 检查时间范围和状态
|
|
|
+ log.error("传入参数:开始时间:{},结束时间:{},periodDays={}",effectiveStartTime,effectiveEndTime,periodDays);
|
|
|
return DateUtil.isWithinRangeSafe(LocalDateTime.now(), effectiveStartTime, effectiveEndTime)&& periodDays.getStatus() == 1;
|
|
|
}
|
|
|
|
|
|
@@ -2159,6 +2185,8 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
}
|
|
|
link.setProjectCode(cloudHostProper.getProjectCode());
|
|
|
|
|
|
+ link.setProjectCode(cloudHostProper.getProjectCode());
|
|
|
+
|
|
|
String randomString = generateRandomStringWithLock();
|
|
|
if (StringUtil.strIsNullOrEmpty(randomString)){
|
|
|
link.setLink(UUID.randomUUID().toString().replace("-", ""));
|
|
|
@@ -2167,6 +2195,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
}
|
|
|
|
|
|
link.setCreateTime(sendTime);
|
|
|
+ link.setProjectCode(cloudHostProper.getProjectCode());
|
|
|
|
|
|
FsCourseRealLink courseMap = new FsCourseRealLink();
|
|
|
BeanUtils.copyProperties(link,courseMap);
|
|
|
@@ -2522,15 +2551,16 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public FsUserCourseVideoQVO selectFsUserCourseVideoByVideoIdVO(Long videoId, Long userId) {
|
|
|
+ public FsUserCourseVideoQVO selectFsUserCourseVideoByVideoIdVO(Long videoId,Long userId) {
|
|
|
FsUserCourseVideoQVO fsUserCourseVideoQVO = new FsUserCourseVideoQVO();
|
|
|
- FsUserCourseVideo courseVideo = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoIdAndUserId(videoId, userId);
|
|
|
+ FsUserCourseVideo courseVideo = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoIdAndUserId(videoId,userId);
|
|
|
|
|
|
- if (courseVideo != null) {
|
|
|
- org.springframework.beans.BeanUtils.copyProperties(courseVideo, fsUserCourseVideoQVO);
|
|
|
+ BeanCopyUtils.copy(courseVideo,fsUserCourseVideoQVO);
|
|
|
+ if(courseVideo != null && courseVideo.getRedPacketMoney() != null){
|
|
|
+ fsUserCourseVideoQVO.setRedPacketMoney(courseVideo.getRedPacketMoney().toString());
|
|
|
}
|
|
|
|
|
|
- if (courseVideo != null && StringUtils.isNotEmpty(courseVideo.getQuestionBankId())) {
|
|
|
+ if (StringUtils.isNotEmpty(courseVideo.getQuestionBankId())){
|
|
|
List<FsCourseQuestionBank> fsCourseQuestionBanks = courseQuestionBankMapper.selectFsCourseQuestionBankByIdVO(courseVideo.getQuestionBankId().split(","));
|
|
|
fsUserCourseVideoQVO.setQuestionBankList(fsCourseQuestionBanks);
|
|
|
}
|
|
|
@@ -2603,7 +2633,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
public R getInternetTrafficIsOpen(FsUserCourseVideoFinishUParam param) {
|
|
|
try {
|
|
|
if (param.getBufferRate()==null){
|
|
|
- logger.error("zyp \n【缓冲值空】参数: {}",param);
|
|
|
+ logger.error("【缓冲值空】参数: {}",param);
|
|
|
return R.error("缓冲值空");
|
|
|
}
|
|
|
FsCourseTrafficLog trafficLog = new FsCourseTrafficLog();
|
|
|
@@ -2623,14 +2653,13 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
|
|
|
// 处理 UUID 为空的情况
|
|
|
if (StringUtils.isNotEmpty(trafficLog.getUuId())) {
|
|
|
- // 直接插入或更新
|
|
|
-// logger.error("zyp \n【插入或更新流量】:{}",trafficLog);
|
|
|
+ // 插入或更新
|
|
|
fsCourseTrafficLogMapper.insertOrUpdateTrafficLog(trafficLog);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
// 打印参数param和异常信息
|
|
|
- logger.error("zyp \n【插入或更新流量失败】参数: {}, 错误信息:{}", param, e.getMessage(), e);
|
|
|
+ logger.error("【插入或更新流量失败】参数: {}, 错误信息:{}", param, e.getMessage(), e);
|
|
|
return R.error();
|
|
|
}
|
|
|
return R.ok();
|
|
|
@@ -2646,7 +2675,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
log.setDuration(0L);
|
|
|
log.setCreateTime(new Date());
|
|
|
log.setLogType(3);
|
|
|
- logger.info("zyp \n【群聊生成看课记录】:{}",param);
|
|
|
+ logger.info("【群聊生成看课记录】:{}",param);
|
|
|
courseWatchLogMapper.insertFsCourseWatchLog(log);
|
|
|
} catch (BeansException e) {
|
|
|
return R.error("群聊生成看课记录失败!");
|
|
|
@@ -2655,3 +2684,4 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|