|
|
@@ -10,8 +10,10 @@ import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
|
+import com.fs.course.domain.FsCourseWatchLog;
|
|
|
import com.fs.course.domain.FsUserCourseVideo;
|
|
|
import com.fs.course.domain.FsUserCourseVideoRedPackage;
|
|
|
+import com.fs.course.mapper.FsCourseWatchLogMapper;
|
|
|
import com.fs.course.mapper.FsUserCourseVideoMapper;
|
|
|
import com.fs.course.mapper.FsUserCourseVideoRedPackageMapper;
|
|
|
import com.fs.his.domain.FsCourseCouponUser;
|
|
|
@@ -45,6 +47,9 @@ public class FsCourseCouponServiceImpl extends ServiceImpl<FsCourseCouponMapper,
|
|
|
|
|
|
@Autowired
|
|
|
private FsUserCourseVideoRedPackageMapper fsUserCourseVideoRedPackageMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsCourseWatchLogMapper courseWatchLogMapper;
|
|
|
/**
|
|
|
* 查询课程优惠券
|
|
|
*
|
|
|
@@ -128,9 +133,9 @@ public class FsCourseCouponServiceImpl extends ServiceImpl<FsCourseCouponMapper,
|
|
|
//自动
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public R sendAutoCourseCoupon(Long videoId, Long userId,Long companyId) {
|
|
|
+ public R sendAutoCourseCoupon(Long videoId, Long userId,Long companyId,Long qwUserId,Long qwExternalId) {
|
|
|
CourseFinishRewardVO rewardVO = new CourseFinishRewardVO();
|
|
|
-
|
|
|
+ rewardVO.setTag(0);
|
|
|
Integer integral = null;
|
|
|
BigDecimal amount = null;
|
|
|
String couponName = null;
|
|
|
@@ -142,6 +147,14 @@ public class FsCourseCouponServiceImpl extends ServiceImpl<FsCourseCouponMapper,
|
|
|
return R.error("课程小节不存在");
|
|
|
}
|
|
|
|
|
|
+ FsCourseWatchLog log = courseWatchLogMapper.getWatchCourseVideo(userId, videoId, qwUserId.toString(), qwExternalId);
|
|
|
+ if (log == null){
|
|
|
+ return R.error("请先观看课程");
|
|
|
+ }
|
|
|
+ FsCourseCouponUser selectByLogId = courseCouponUserMapper.selectByLogId(log.getLogId());
|
|
|
+ if (selectByLogId != null) {
|
|
|
+ return R.ok().put("data", rewardVO);
|
|
|
+ }
|
|
|
//优惠券
|
|
|
FsCourseCoupon fsCourseCoupon = baseMapper.selectFsCourseCouponById(courseVideo.getCourseCouponId());
|
|
|
if (fsCourseCoupon != null) {
|
|
|
@@ -168,6 +181,7 @@ public class FsCourseCouponServiceImpl extends ServiceImpl<FsCourseCouponMapper,
|
|
|
couponUser.setStartTime(new Date());
|
|
|
couponUser.setLimitTime(fsCourseCoupon.getLimitTime());
|
|
|
couponUser.setCreateTime(new Date());
|
|
|
+ couponUser.setLogId(log.getLogId());
|
|
|
int i = courseCouponUserMapper.insertFsCourseCouponUser(couponUser);
|
|
|
|
|
|
//返回的优惠券名称
|
|
|
@@ -198,15 +212,16 @@ public class FsCourseCouponServiceImpl extends ServiceImpl<FsCourseCouponMapper,
|
|
|
rewardVO.setCouponName(couponName);
|
|
|
rewardVO.setIntegral(integral);
|
|
|
rewardVO.setRedPacketMoney(amount);
|
|
|
+ rewardVO.setTag(1);
|
|
|
return R.ok().put("data",rewardVO);
|
|
|
}
|
|
|
|
|
|
//手动
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public R sendCourseCoupon(Long videoId, Long userId,Long companyId,Long periodId) {
|
|
|
+ public R sendCourseCoupon(Long videoId, Long userId,Long companyId,Long periodId,Long companyUserId) {
|
|
|
CourseFinishRewardVO rewardVO = new CourseFinishRewardVO();
|
|
|
-
|
|
|
+ rewardVO.setTag(0);
|
|
|
Integer integral = null;
|
|
|
BigDecimal amount = null;
|
|
|
String couponName = null;
|
|
|
@@ -218,6 +233,15 @@ public class FsCourseCouponServiceImpl extends ServiceImpl<FsCourseCouponMapper,
|
|
|
return R.error("课程小节不存在");
|
|
|
}
|
|
|
|
|
|
+ FsCourseWatchLog log = courseWatchLogMapper.getWatchLogByFsUserAndPeriodId(videoId, userId, companyUserId, periodId);
|
|
|
+ if (log == null) {
|
|
|
+ return R.error("请先观看课程");
|
|
|
+ }
|
|
|
+ FsCourseCouponUser selectByLogId = courseCouponUserMapper.selectByLogId(log.getLogId());
|
|
|
+ if (selectByLogId != null) {
|
|
|
+ return R.ok().put("data", rewardVO);
|
|
|
+ }
|
|
|
+
|
|
|
//优惠券
|
|
|
FsCourseCoupon fsCourseCoupon = baseMapper.selectFsCourseCouponById(courseVideo.getCourseCouponId());
|
|
|
if (fsCourseCoupon != null) {
|
|
|
@@ -244,6 +268,7 @@ public class FsCourseCouponServiceImpl extends ServiceImpl<FsCourseCouponMapper,
|
|
|
couponUser.setStartTime(new Date());
|
|
|
couponUser.setLimitTime(fsCourseCoupon.getLimitTime());
|
|
|
couponUser.setCreateTime(new Date());
|
|
|
+ couponUser.setLogId(log.getLogId());
|
|
|
int i = courseCouponUserMapper.insertFsCourseCouponUser(couponUser);
|
|
|
|
|
|
//返回的优惠券名称
|
|
|
@@ -274,6 +299,7 @@ public class FsCourseCouponServiceImpl extends ServiceImpl<FsCourseCouponMapper,
|
|
|
rewardVO.setCouponName(couponName);
|
|
|
rewardVO.setIntegral(integral);
|
|
|
rewardVO.setRedPacketMoney(amount);
|
|
|
+ rewardVO.setTag(1);
|
|
|
return R.ok().put("data",rewardVO);
|
|
|
}
|
|
|
}
|