|
@@ -6,37 +6,43 @@ import com.ruoyi.demo.entity.*;
|
|
|
import com.ruoyi.demo.entity.bo.PlanAddBo;
|
|
|
import com.ruoyi.demo.entity.bo.PlanBo;
|
|
|
import com.ruoyi.demo.entity.vo.PlanDetailVo;
|
|
|
+import com.ruoyi.demo.entity.vo.PlanItemVo;
|
|
|
import com.ruoyi.demo.entity.vo.PlanListVo;
|
|
|
import com.ruoyi.demo.entity.vo.PlanPushVo;
|
|
|
-import com.ruoyi.demo.mapper.AppMapper;
|
|
|
-import com.ruoyi.demo.mapper.CommercialMapper;
|
|
|
-import com.ruoyi.demo.mapper.PlanItemMapper;
|
|
|
-import com.ruoyi.demo.mapper.PlanMapper;
|
|
|
+import com.ruoyi.demo.mapper.*;
|
|
|
import com.ruoyi.demo.service.PlanService;
|
|
|
import com.ruoyi.demo.utils.SignUtil;
|
|
|
+import com.ruoyi.demo.utils.StateUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
+@Transactional
|
|
|
public class PlanServiceImpl implements PlanService {
|
|
|
@Autowired
|
|
|
PlanMapper planMapper;
|
|
|
@Autowired
|
|
|
PlanItemMapper planItemMapper;
|
|
|
@Autowired
|
|
|
+ PlanAuditMapper planAuditMapper;
|
|
|
+ @Autowired
|
|
|
AppMapper appMapper;
|
|
|
@Autowired
|
|
|
CommercialMapper commercialMapper;
|
|
|
+ @Autowired
|
|
|
+ SystemSetterMapper systemSetterMapper;
|
|
|
|
|
|
@Override
|
|
|
public int addPlan(PlanAddBo bo) {
|
|
|
QueryWrapper<App> appQueryWrapper = new QueryWrapper<>();
|
|
|
appQueryWrapper.eq("appkey",bo.getAppkey());
|
|
|
+ appQueryWrapper.eq("show_delete",0);
|
|
|
App app = appMapper.selectOne(appQueryWrapper);
|
|
|
if (app == null)
|
|
|
return -1;
|
|
@@ -77,7 +83,7 @@ public class PlanServiceImpl implements PlanService {
|
|
|
plan.setPlanCreateTime(bo.getPlanCreateTime());
|
|
|
plan.setPlanStartTime(bo.getPlanStartTime());
|
|
|
plan.setPlanEndTime(bo.getPlanEndTime());
|
|
|
- plan.setState(0);
|
|
|
+ plan.setState(StateUtil.NOT_AUDITED);
|
|
|
planMapper.insert(plan);
|
|
|
// 插入广告计划明细
|
|
|
for (PlanItem item : bo.getItems()) {
|
|
@@ -99,22 +105,89 @@ public class PlanServiceImpl implements PlanService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int checkPlan(String planId, Integer state) {
|
|
|
- return 0;
|
|
|
+ public int checkPlan(String planId, Integer state, String auditComment,String userId) {
|
|
|
+ QueryWrapper<Plan> planQueryWrapper = new QueryWrapper<>();
|
|
|
+ planQueryWrapper.eq("plan_id",planId);
|
|
|
+ planQueryWrapper.eq("show_delete",0);
|
|
|
+ Plan plan = planMapper.selectOne(planQueryWrapper);
|
|
|
+ if (plan == null)
|
|
|
+ return -1;
|
|
|
+ plan.setState(state);
|
|
|
+ int i = planMapper.updateById(plan);
|
|
|
+ if (i == 0)
|
|
|
+ return 0;
|
|
|
+ PlanAudit audit = new PlanAudit();
|
|
|
+ audit.setPlanId(planId);
|
|
|
+ audit.setUserId(userId);
|
|
|
+ audit.setState(state);
|
|
|
+ audit.setAuditComment(auditComment);
|
|
|
+ audit.setAuditTime(LocalDateTime.now());
|
|
|
+ planAuditMapper.insert(audit);
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<PlanListVo> getPlanList(PlanBo bo) {
|
|
|
- return null;
|
|
|
+ QueryWrapper<Plan> planQueryWrapper = new QueryWrapper<>();
|
|
|
+ if (bo.getState() != null)
|
|
|
+ planQueryWrapper.eq("state",bo.getState());
|
|
|
+ if (bo.getAppkey() != null)
|
|
|
+ planQueryWrapper.like("appkey",bo.getAppkey());
|
|
|
+ if (bo.getAppName() != null)
|
|
|
+ planQueryWrapper.like("app_name",bo.getAppName());
|
|
|
+ if (bo.getGoods() != null){
|
|
|
+ planQueryWrapper.like("goods_name",bo.getGoods())
|
|
|
+ .or()
|
|
|
+ .like("goods_introduce",bo.getGoods());
|
|
|
+ }
|
|
|
+ planQueryWrapper.eq("show_delete",0);
|
|
|
+ List<Plan> plans = planMapper.selectList(planQueryWrapper);
|
|
|
+ List<PlanListVo> vos = new ArrayList<>();
|
|
|
+ for (Plan plan : plans){
|
|
|
+ vos.add(new PlanListVo(plan));
|
|
|
+ }
|
|
|
+ return vos;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public PlanDetailVo getPlanDetail(String planId) {
|
|
|
- return null;
|
|
|
+ QueryWrapper<Plan> planQueryWrapper = new QueryWrapper<>();
|
|
|
+ planQueryWrapper.eq("plan_id",planId);
|
|
|
+ planQueryWrapper.eq("show_delete",0);
|
|
|
+ Plan plan = planMapper.selectOne(planQueryWrapper);
|
|
|
+ if (plan == null)
|
|
|
+ return null;
|
|
|
+ QueryWrapper<PlanItem> itemQueryWrapper = new QueryWrapper<>();
|
|
|
+ itemQueryWrapper.eq("plan_id",planId);
|
|
|
+ List<PlanItem> items = planItemMapper.selectList(itemQueryWrapper);
|
|
|
+ List<PlanItemVo> itemVos = new ArrayList<>();
|
|
|
+ if (items != null)
|
|
|
+ for (PlanItem item : items){
|
|
|
+ itemVos.add(new PlanItemVo(item));
|
|
|
+ }
|
|
|
+ PlanDetailVo vo = new PlanDetailVo(plan, itemVos);
|
|
|
+ return vo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PlanPushVo getPlanPush() {
|
|
|
- return null;
|
|
|
+ public List<PlanPushVo> getPlanPush() {
|
|
|
+// 查询可投放的广告计划
|
|
|
+// 再根据每个广告计划,查询其明细
|
|
|
+// 返回结果
|
|
|
+ QueryWrapper<SystemSetter> systemSetterQueryWrapper = new QueryWrapper<>();
|
|
|
+ SystemSetter setter = systemSetterMapper.selectOne(systemSetterQueryWrapper);
|
|
|
+ QueryWrapper<Plan> planQueryWrapper = new QueryWrapper<>();
|
|
|
+ planQueryWrapper.apply("DATE_FORMAT(plan_start_time,'%Y-%m-%d %H:%i:%s') <= DATE_FORMAT({0},'%Y-%m-%d %H:%i:%s')",LocalDateTime.now());
|
|
|
+ planQueryWrapper.apply("DATE_FORMAT(plan_end_time,'%Y-%m-%d %H:%i:%s') > DATE_FORMAT({0},'%Y-%m-%d %H:%i:%s')",LocalDateTime.now());
|
|
|
+ planQueryWrapper.eq("state",1);
|
|
|
+ List<PlanPushVo> pushVos = new ArrayList<>();
|
|
|
+ for (Plan plan : planMapper.selectList(planQueryWrapper)) {
|
|
|
+ QueryWrapper<PlanItem> itemQueryWrapper = new QueryWrapper<>();
|
|
|
+ itemQueryWrapper.eq("plan_id",plan.getPlanId());
|
|
|
+ for (PlanItem item : planItemMapper.selectList(itemQueryWrapper)) {
|
|
|
+ pushVos.add(new PlanPushVo(item,plan,setter));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return pushVos;
|
|
|
}
|
|
|
}
|