|
@@ -22,6 +22,7 @@ import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyMapper;
|
|
|
import com.fs.company.mapper.CompanyMoneyLogsMapper;
|
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
|
+import com.fs.company.service.ICompanyService;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
|
import com.fs.course.domain.*;
|
|
|
import com.fs.course.dto.CoursePackageDTO;
|
|
@@ -100,14 +101,16 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
{
|
|
|
@Value("${cloud_host.company_name}")
|
|
|
private String signProjectName;
|
|
|
-
|
|
|
+ @Value("${isNewWxMerchant}")
|
|
|
+ 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=";
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ ICompanyService companyService;
|
|
|
@Autowired
|
|
|
private CompanyMoneyLogsMapper moneyLogsMapper;
|
|
|
@Autowired
|
|
@@ -922,6 +925,13 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
// 积分奖励
|
|
|
case 2:
|
|
|
return sendIntegralReward(param,user, log, config);
|
|
|
+ // 红包+积分
|
|
|
+ case 3:
|
|
|
+ R sendRed = sendRedPacketReward(param, user, log, video, config);
|
|
|
+ if (!Objects.equals(sendRed.get("code"), 200)) {
|
|
|
+ return sendRed;
|
|
|
+ }
|
|
|
+ return sendIntegralReward(param,user, log, config);
|
|
|
default:
|
|
|
return R.error("参数错误!");
|
|
|
}
|
|
@@ -981,6 +991,13 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
// 积分奖励
|
|
|
case 2:
|
|
|
return sendIntegralReward(param,user, log, config);
|
|
|
+ // 红包+积分
|
|
|
+ case 3:
|
|
|
+ R sendRed = sendRedPacketReward(param, user, log, video, config);
|
|
|
+ if (!Objects.equals(sendRed.get("code"), 200)) {
|
|
|
+ return sendRed;
|
|
|
+ }
|
|
|
+ return sendIntegralReward(param,user, log, config);
|
|
|
default:
|
|
|
return R.error("参数错误!");
|
|
|
}
|
|
@@ -1191,21 +1208,25 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
// if (company.getCourseMiniAppId()==null){
|
|
|
// return R.error("销售公司参数错误,未绑定小程序");
|
|
|
// }
|
|
|
- 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参数错误");
|
|
|
- }
|
|
|
- packetParam.setOpenId(user.getCourseMaOpenId());
|
|
|
- try {
|
|
|
- handleFsUserWx(user,param.getAppId());
|
|
|
- }catch (Exception e){
|
|
|
- logger.error("zyp \n 【更新或插入用户与小程序的绑定关系失败】:{}", user.getUserId(),e);
|
|
|
- }
|
|
|
-
|
|
|
+ if (user.getMpOpenId()!=null&&!isNewWxMerchant){
|
|
|
+ packetParam.setOpenId(user.getMpOpenId());
|
|
|
}else {
|
|
|
- packetParam.setOpenId(fsUserWx.getOpenId());
|
|
|
+ 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参数错误");
|
|
|
+ }
|
|
|
+ packetParam.setOpenId(user.getCourseMaOpenId());
|
|
|
+ try {
|
|
|
+ handleFsUserWx(user,param.getAppId());
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.error("zyp \n 【更新或插入用户与小程序的绑定关系失败】:{}", user.getUserId(),e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ packetParam.setOpenId(fsUserWx.getOpenId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//判断服务号配置是否存在
|
|
@@ -1228,6 +1249,11 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
//2025.6.19 红包金额为0的时候
|
|
|
if (amount.compareTo(BigDecimal.ZERO)>0){
|
|
|
|
|
|
+ Company company = companyMapper.selectCompanyById(param.getCompanyId());
|
|
|
+ BigDecimal money = company.getMoney();
|
|
|
+ if (money.compareTo(BigDecimal.ZERO)<0) {
|
|
|
+ return R.error("服务商余额不足,请联系群主服务器充值!");
|
|
|
+ }
|
|
|
// 发送红包
|
|
|
R sendRedPacket = paymentService.sendRedPacket(packetParam);
|
|
|
if (sendRedPacket.get("code").equals(200)) {
|
|
@@ -1519,14 +1545,6 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
public ResponseResult<FsUser> isAddCompanyUser(FsUserCourseAddCompanyUserParam param) {
|
|
|
logger.info("\n 【进入个微-判断是否添加客服】,入参:{}",param);
|
|
|
|
|
|
- // 生成锁的key,使用用户ID和视频ID组合
|
|
|
- String lockKey = "submit:lock:" + param.getUserId() + ":" + param.getVideoId();
|
|
|
- // 尝试获取锁,3秒过期
|
|
|
- boolean locked = redisCache.setIfAbsent(lockKey, "1", 1, TimeUnit.SECONDS);
|
|
|
-
|
|
|
- if (!locked) {
|
|
|
- return ResponseResult.fail(504, "请勿重复提交,请等待3秒后重试");
|
|
|
- }
|
|
|
//查询用户
|
|
|
FsUser fsUser = fsUserMapper.selectFsUserById(param.getUserId());
|
|
|
if (fsUser == null){
|
|
@@ -1565,8 +1583,22 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
//2、如果只绑定了当前销售,需要添加看课记录(正常流程);
|
|
|
//3、以上都不是,则标识重粉,需要加入关系表,并打上重粉标签
|
|
|
FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(fsUser.getUserId(), param.getProjectId());
|
|
|
+
|
|
|
+ // 添加逻辑:如果存在fs_user表数据,但是又不存在fs_user_company_user表,则表示是以前企微看课的,需要手动绑定
|
|
|
+ if(Objects.isNull(userCompanyUser) && fsUser.getCompanyUserId() == null && fsUser.getIsAddQw() == 1){
|
|
|
+ userCompanyUserService.bindRelationship(fsUser.getUserId(), param.getProjectId(), param.getCompanyId(), param.getCompanyUserId(), 1);
|
|
|
+ }
|
|
|
+
|
|
|
if(Objects.isNull(userCompanyUser)) {
|
|
|
- return ResponseResult.fail(BizResponseEnum.DATA_NOT_EXIST, getCompanyUserQRCode(companyUser));
|
|
|
+ Company company = companyService.selectCompanyById(param.getCompanyId());
|
|
|
+ if((companyUser.getIsAllowedAllRegister() !=null && companyUser.getIsAllowedAllRegister() != 1)){
|
|
|
+ return ResponseResult.fail(504,"当前销售禁止绑定会员,请联系销售!");
|
|
|
+ }
|
|
|
+ if (companyUser.getIsNeedRegisterMember() == null || companyUser.getIsNeedRegisterMember() == 1){
|
|
|
+ return ResponseResult.fail(504,"请联系销售发送邀请链接成为会员!");
|
|
|
+ }
|
|
|
+ int defaultStatus = (company != null ? company.getFsUserIsDefaultBlack() : 0) == 1 ? 0 : 1;
|
|
|
+ userCompanyUser = userCompanyUserService.bindRelationship(param.getUserId(), param.getProjectId(), companyUser.getCompanyId(), companyUser.getUserId(), defaultStatus);
|
|
|
}
|
|
|
|
|
|
// 逻辑调整:如果会员已经绑定了销售,直接提示,不添加重粉数据了-2025年6月16日14点53分
|
|
@@ -1607,9 +1639,11 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
return ResponseResult.fail(504, "请观看最新的课程项目");
|
|
|
}
|
|
|
// 项目看课数限制
|
|
|
- Integer logCount = fsUserCourseMapper.selectTodayCourseWatchLogCountByUserIdAndProjectId(param.getUserId(), param.getProjectId());
|
|
|
- if (Objects.isNull(watchCourseVideo) && logCount > 0) {
|
|
|
- return ResponseResult.fail(504, "超过项目看课数量限制");
|
|
|
+ if(!"福本源".equals(signProjectName) && !"宽益堂".equals(signProjectName)) {
|
|
|
+ Integer logCount = fsUserCourseMapper.selectTodayCourseWatchLogCountByUserIdAndProjectId(param.getUserId(), param.getProjectId());
|
|
|
+ if (Objects.isNull(watchCourseVideo) && logCount > 0) {
|
|
|
+ return ResponseResult.fail(504, "超过项目看课数量限制");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//添加判断:该用户是否已经存在此课程的看课记录,并且看课记录的销售id不是传入的销售id
|