|
@@ -5,14 +5,15 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.ruoyi.demo.entity.*;
|
|
|
+import com.ruoyi.demo.entity.bo.CallBackBean;
|
|
|
import com.ruoyi.demo.entity.bo.PlanAddBo;
|
|
|
import com.ruoyi.demo.entity.bo.PlanBo;
|
|
|
import com.ruoyi.demo.entity.bo.PlanItemAddBo;
|
|
|
import com.ruoyi.demo.entity.vo.*;
|
|
|
import com.ruoyi.demo.mapper.*;
|
|
|
import com.ruoyi.demo.service.PlanService;
|
|
|
+import com.ruoyi.demo.utils.SendCallBackUtil;
|
|
|
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;
|
|
@@ -46,6 +47,10 @@ public class PlanServiceImpl implements PlanService {
|
|
|
AddrCategoryMapper addrCategoryMapper;
|
|
|
@Autowired
|
|
|
EquipmentMapper equipmentMapper;
|
|
|
+ @Autowired
|
|
|
+ GoodsMapper goodsMapper;
|
|
|
+// @Autowired
|
|
|
+// SysUserMapper sysUserMapper;
|
|
|
|
|
|
@Override
|
|
|
public int addPlan(PlanAddBo bo) {
|
|
@@ -78,6 +83,15 @@ public class PlanServiceImpl implements PlanService {
|
|
|
PlanItem item = new PlanItem(plan.getPlanId(), itemAddBo);
|
|
|
planItemMapper.insert(item);
|
|
|
}
|
|
|
+ // 插入商品信息
|
|
|
+ QueryWrapper<Goods> goodsQueryWrapper = new QueryWrapper<>();
|
|
|
+ goodsQueryWrapper.eq("appkey",bo.getAppkey());
|
|
|
+ goodsQueryWrapper.eq("goods_id",bo.getGoodsId());
|
|
|
+ Goods query = goodsMapper.selectOne(goodsQueryWrapper);
|
|
|
+ if (query == null){
|
|
|
+ Goods goods = new Goods(plan);
|
|
|
+ goodsMapper.insert(goods);
|
|
|
+ }
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -103,20 +117,31 @@ public class PlanServiceImpl implements PlanService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int checkPlan(PlanBo bo,String userId) {
|
|
|
+ public int checkPlan(PlanBo bo,Long userId,String userName) {
|
|
|
QueryWrapper<Plan> planQueryWrapper = new QueryWrapper<>();
|
|
|
planQueryWrapper.eq("plan_id",bo.getPlanId());
|
|
|
planQueryWrapper.eq("deleted","0");
|
|
|
Plan plan = planMapper.selectOne(planQueryWrapper);
|
|
|
if (plan == null)
|
|
|
return -1;
|
|
|
+ QueryWrapper<App> appQueryWrapper = new QueryWrapper<>();
|
|
|
+ appQueryWrapper.eq("appkey",plan.getAppkey());
|
|
|
+ App app = appMapper.selectOne(appQueryWrapper);
|
|
|
plan.setState(bo.getState());
|
|
|
int i = planMapper.updateById(plan);
|
|
|
if (i == 0)
|
|
|
return 0;
|
|
|
- PlanAudit audit = new PlanAudit(bo,userId);
|
|
|
- planAuditMapper.insert(audit);
|
|
|
- return 1;
|
|
|
+// SysUser sysUser = sysUserMapper.selectById(userId);
|
|
|
+ PlanAudit audit = new PlanAudit(bo,userId.toString(),userName);
|
|
|
+ int insert = planAuditMapper.insert(audit);
|
|
|
+ if (insert == 1){
|
|
|
+ CallBackBean callBackBean = new CallBackBean();
|
|
|
+ callBackBean.setAuditPerson(userName);
|
|
|
+ callBackBean.setAuditComment(bo.getAuditComment());
|
|
|
+ callBackBean.setAuditTime(LocalDateTime.now(ZoneId.of("Asia/Shanghai")));
|
|
|
+ SendCallBackUtil.sendCallBack(app.getCallBack(),callBackBean);
|
|
|
+ }
|
|
|
+ return insert;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -158,24 +183,24 @@ public class PlanServiceImpl implements PlanService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- 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(ZoneId.of("Asia/Shanghai")));
|
|
|
- planQueryWrapper.apply("DATE_FORMAT(plan_end_time,'%Y-%m-%d %H:%i:%s') > DATE_FORMAT({0},'%Y-%m-%d %H:%i:%s')",LocalDateTime.now(ZoneId.of("Asia/Shanghai")));
|
|
|
- planQueryWrapper.eq("state",1);
|
|
|
- planQueryWrapper.eq("deleted","0");
|
|
|
+ public List<PlanPushVo> getPlanPush(String equipmentId) {
|
|
|
+// 根据设备id查询可投放的广告计划
|
|
|
+// 再根据每个广告计划id,查询其商品信息
|
|
|
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));
|
|
|
- }
|
|
|
+ QueryWrapper<PlanItem> itemQueryWrapper = new QueryWrapper<>();
|
|
|
+ itemQueryWrapper.eq("equipment_id",equipmentId);
|
|
|
+ itemQueryWrapper.eq("deleted","0");
|
|
|
+ List<PlanItem> items = planItemMapper.selectList(itemQueryWrapper);
|
|
|
+ for (PlanItem item : items){
|
|
|
+ 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(ZoneId.of("Asia/Shanghai")));
|
|
|
+ planQueryWrapper.apply("DATE_FORMAT(plan_end_time,'%Y-%m-%d %H:%i:%s') > DATE_FORMAT({0},'%Y-%m-%d %H:%i:%s')",LocalDateTime.now(ZoneId.of("Asia/Shanghai")));
|
|
|
+ planQueryWrapper.eq("plan_id",item.getPlanId());
|
|
|
+ planQueryWrapper.eq("state",1);
|
|
|
+ planQueryWrapper.eq("deleted","0");
|
|
|
+ Plan plan = planMapper.selectOne(planQueryWrapper);
|
|
|
+ if (plan != null)
|
|
|
+ pushVos.add(new PlanPushVo(item,plan));
|
|
|
}
|
|
|
return pushVos;
|
|
|
}
|