|
|
@@ -8,17 +8,16 @@ import java.util.Collections;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
-import com.fs.live.domain.Live;
|
|
|
-import com.fs.live.domain.LiveAutoTask;
|
|
|
-import com.fs.live.domain.LiveLotteryConf;
|
|
|
-import com.fs.live.domain.LiveRedConf;
|
|
|
+import com.fs.live.domain.*;
|
|
|
import com.fs.live.mapper.*;
|
|
|
import com.fs.live.param.LiveLotteryProduct;
|
|
|
import com.fs.live.service.ILiveAutoTaskService;
|
|
|
+import com.fs.live.service.ILiveCouponService;
|
|
|
import com.fs.live.service.ILiveGoodsService;
|
|
|
import com.fs.live.vo.LiveGoodsVo;
|
|
|
import com.fs.live.vo.LiveLotteryConfVo;
|
|
|
@@ -51,6 +50,10 @@ public class LiveAutoTaskServiceImpl implements ILiveAutoTaskService {
|
|
|
private LiveLotteryConfMapper liveLotteryConfMapper;
|
|
|
@Autowired
|
|
|
private LiveLotteryProductConfMapper lotteryProductConfMapper;
|
|
|
+ @Autowired
|
|
|
+ private LiveCouponMapper liveCouponMapper;
|
|
|
+ @Autowired
|
|
|
+ private LiveCouponIssueMapper liveCouponIssueMapper;
|
|
|
|
|
|
/**
|
|
|
* 查询直播间自动化任务配置
|
|
|
@@ -138,7 +141,18 @@ public class LiveAutoTaskServiceImpl implements ILiveAutoTaskService {
|
|
|
baseMapper.insertLiveAutoTask(liveAutoTask);
|
|
|
} else if(liveAutoTask.getTaskType() == 3L){
|
|
|
baseMapper.insertLiveAutoTask(liveAutoTask);
|
|
|
-
|
|
|
+ } else if (liveAutoTask.getTaskType() == 5L) {
|
|
|
+ // 自动优惠券
|
|
|
+ LiveCoupon liveCoupon = liveCouponMapper.selectLiveCouponById(Long.valueOf(liveAutoTask.getContent()));
|
|
|
+ if(liveCoupon == null) return R.error("优惠券不存在");
|
|
|
+ LiveCouponIssue liveCouponIssue = liveCouponIssueMapper.selectLiveCouponIssueByCouponId(liveCoupon.getCouponId());
|
|
|
+ if(liveCouponIssue == null)return R.error("优惠券未发布");
|
|
|
+ LiveCouponIssueRelation liveCouponIssueRelation = liveCouponMapper.selectCouponRelation(liveAutoTask.getLiveId(),liveCouponIssue.getId());
|
|
|
+ if(liveCouponIssueRelation == null) return R.error("优惠券尚未添加在直播间");
|
|
|
+ if(ObjectUtil.isEmpty(liveCouponIssueRelation.getGoodsId())) return R.error("未绑定商品,无法制定自动化任务!");
|
|
|
+ liveCoupon.setGoodsId(liveCouponIssueRelation.getGoodsId());
|
|
|
+ liveAutoTask.setContent(JSON.toJSONString(liveCoupon));
|
|
|
+ baseMapper.insertLiveAutoTask(liveAutoTask);
|
|
|
} else {
|
|
|
return R.error("任务类型错误");
|
|
|
}
|
|
|
@@ -240,6 +254,18 @@ public class LiveAutoTaskServiceImpl implements ILiveAutoTaskService {
|
|
|
return baseMapper.updateLiveAutoTask(liveAutoTask);
|
|
|
} else if(liveAutoTask.getTaskType() == 3L){
|
|
|
return baseMapper.updateLiveAutoTask(liveAutoTask);
|
|
|
+ }else if( liveAutoTask.getTaskType() == 5L){
|
|
|
+ // 自动优惠券
|
|
|
+ LiveCoupon liveCoupon = liveCouponMapper.selectLiveCouponById(Long.valueOf(liveAutoTask.getContent()));
|
|
|
+ if(liveCoupon == null) return -1;
|
|
|
+ LiveCouponIssue liveCouponIssue = liveCouponIssueMapper.selectLiveCouponIssueByCouponId(liveCoupon.getCouponId());
|
|
|
+ if(liveCouponIssue == null)return -1;
|
|
|
+ LiveCouponIssueRelation liveCouponIssueRelation = liveCouponMapper.selectCouponRelation(liveAutoTask.getLiveId(),liveCouponIssue.getId());
|
|
|
+ if(liveCouponIssueRelation == null) return -1;
|
|
|
+ if(ObjectUtil.isEmpty(liveCouponIssueRelation.getGoodsId())) return -1;
|
|
|
+ liveCoupon.setGoodsId(liveCouponIssueRelation.getGoodsId());
|
|
|
+ liveAutoTask.setContent(JSON.toJSONString(liveCoupon));
|
|
|
+ return baseMapper.updateLiveAutoTask(liveAutoTask);
|
|
|
} else {
|
|
|
return -1;
|
|
|
}
|