|
|
@@ -8,9 +8,14 @@ import java.util.Objects;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
+import com.fs.course.param.CourseCouponVerifyParam;
|
|
|
+import com.fs.his.domain.FsCourseCoupon;
|
|
|
+import com.fs.his.mapper.FsCourseCouponMapper;
|
|
|
import com.fs.his.vo.CourseCouponUserListUVO;
|
|
|
import com.fs.his.vo.FsCourseCouponUserRecordVO;
|
|
|
import com.fs.his.vo.FsCourseCouponUserVO;
|
|
|
+import com.fs.live.domain.LiveCouponUser;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.fs.his.mapper.FsCourseCouponUserMapper;
|
|
|
@@ -26,6 +31,10 @@ import com.fs.his.service.IFsCourseCouponUserService;
|
|
|
@Service
|
|
|
public class FsCourseCouponUserServiceImpl extends ServiceImpl<FsCourseCouponUserMapper, FsCourseCouponUser> implements IFsCourseCouponUserService {
|
|
|
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsCourseCouponMapper couponMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询用户看课优惠券
|
|
|
*
|
|
|
@@ -141,4 +150,79 @@ public class FsCourseCouponUserServiceImpl extends ServiceImpl<FsCourseCouponUse
|
|
|
public List<FsCourseCouponUserRecordVO> selectCourseCouponUserRecordList(FsCourseCouponUser courseCouponUser) {
|
|
|
return baseMapper.selectCourseCouponUserRecordList(courseCouponUser);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<FsCourseCouponUserVO> getUseCouponByCompanyUserId(Long companyUserId) {
|
|
|
+ return baseMapper.getUseCouponByCompanyUserId(companyUserId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R verifyCoupon(CourseCouponVerifyParam param) {
|
|
|
+
|
|
|
+ // 1. 参数校验
|
|
|
+ if (param.getCompanyUserId() == null) {
|
|
|
+ return R.error("销售未登录");
|
|
|
+ }
|
|
|
+ if (param.getCouponId() == null) {
|
|
|
+ return R.error("核销码不能为空");
|
|
|
+ }
|
|
|
+ if (param.getCouponUserId() == null) {
|
|
|
+ return R.error("用户领取记录ID不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ FsCourseCoupon fsCourseCoupon = couponMapper.selectFsCourseCouponById(param.getCouponId());
|
|
|
+ Date nowDate = DateUtils.getNowDate();
|
|
|
+ FsCourseCouponUser couponUser = baseMapper.selectFsCourseCouponUserById(param.getCouponUserId());
|
|
|
+
|
|
|
+ if (fsCourseCoupon == null) {
|
|
|
+ return R.error("无此核销卷");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(fsCourseCoupon.getStatus()==0){
|
|
|
+ couponUser.setStatus(3);
|
|
|
+ couponUser.setUpdateTime(nowDate);
|
|
|
+ baseMapper.updateFsCourseCouponUser(couponUser);
|
|
|
+ return R.error("核销卷已停用");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (fsCourseCoupon.getLimitTime() != null && fsCourseCoupon.getLimitTime().before(nowDate)) {
|
|
|
+
|
|
|
+ couponUser.setStatus(2);
|
|
|
+ couponUser.setUpdateTime(nowDate);
|
|
|
+ baseMapper.updateFsCourseCouponUser(couponUser);
|
|
|
+ return R.error("核销券已过期");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (couponUser == null) {
|
|
|
+ return R.error("无核销卷领取记录");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (couponUser.getStatus() != null && couponUser.getStatus()==1) {
|
|
|
+ return R.error("核销卷已核销");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (couponUser.getStatus() != null && couponUser.getStatus()==2) {
|
|
|
+ return R.error("核销卷已过期");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (couponUser.getLimitTime() != null && couponUser.getLimitTime().before(nowDate)) {
|
|
|
+
|
|
|
+ couponUser.setStatus(2);
|
|
|
+ couponUser.setUpdateTime(nowDate);
|
|
|
+ baseMapper.updateFsCourseCouponUser(couponUser);
|
|
|
+ return R.error("核销卷已过期");
|
|
|
+ }
|
|
|
+
|
|
|
+ couponUser.setStatus(1);
|
|
|
+ couponUser.setVerifyTime(nowDate);
|
|
|
+ couponUser.setUpdateTime(nowDate);
|
|
|
+ couponUser.setVerifyUserId(param.getCompanyUserId());
|
|
|
+
|
|
|
+ baseMapper.updateFsCourseCouponUser(couponUser);
|
|
|
+
|
|
|
+ return R.ok("核销成功");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|