|
@@ -0,0 +1,114 @@
|
|
|
+package com.ruoyi.demo.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.lang.Dict;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+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.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.service.PlanService;
|
|
|
+import com.ruoyi.demo.utils.SignUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class PlanServiceImpl implements PlanService {
|
|
|
+ @Autowired
|
|
|
+ PlanMapper planMapper;
|
|
|
+ @Autowired
|
|
|
+ PlanItemMapper planItemMapper;
|
|
|
+ @Autowired
|
|
|
+ AppMapper appMapper;
|
|
|
+ @Autowired
|
|
|
+ CommercialMapper commercialMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int addPlan(PlanAddBo bo) {
|
|
|
+ QueryWrapper<App> appQueryWrapper = new QueryWrapper<>();
|
|
|
+ appQueryWrapper.eq("appkey",bo.getAppkey());
|
|
|
+ App app = appMapper.selectOne(appQueryWrapper);
|
|
|
+ if (app == null)
|
|
|
+ return -1;
|
|
|
+ QueryWrapper<Commercial> commercialQueryWrapper = new QueryWrapper<>();
|
|
|
+ commercialQueryWrapper.eq("commercial_id",bo.getCommercialId());
|
|
|
+ Commercial commercial = commercialMapper.selectOne(commercialQueryWrapper);
|
|
|
+ if (commercial == null)
|
|
|
+ return -2;
|
|
|
+ Map<String,Object> params = Dict.create()
|
|
|
+ .set("appkey",bo.getAppkey())
|
|
|
+ .set("commercialId",bo.getCommercialId())
|
|
|
+ .set("goodsId",bo.getGoodsId())
|
|
|
+ .set("goodsImg",bo.getGoodsImg())
|
|
|
+ .set("goodsName",bo.getGoodsName())
|
|
|
+ .set("goodsLogo",bo.getGoodsLogo())
|
|
|
+ .set("goodsIntroduce",bo.getGoodsIntroduce())
|
|
|
+ .set("goodsPrice",bo.getGoodsPrice())
|
|
|
+ .set("goodsClassify",bo.getGoodsClassify())
|
|
|
+ .set("planCreateTime",bo.getPlanCreateTime())
|
|
|
+ .set("planStartTime",bo.getPlanStartTime())
|
|
|
+ .set("planEndTime",bo.getPlanEndTime())
|
|
|
+ .set("items",bo.getItems())
|
|
|
+ .set("sign",bo.getSign());
|
|
|
+ if (!SignUtil.verify(params,app.getAppSecret()))
|
|
|
+ return -3;
|
|
|
+ // 插入广告计划
|
|
|
+ Plan plan = new Plan();
|
|
|
+ plan.setCommercialId(commercial.getCommercialId());
|
|
|
+ plan.setCommercialName(commercial.getCommercialName());
|
|
|
+ plan.setAppkey(app.getAppkey());
|
|
|
+ plan.setAppName(app.getAppName());
|
|
|
+ plan.setGoodsId(bo.getGoodsId());
|
|
|
+ plan.setGoodsImg(bo.getGoodsImg());
|
|
|
+ plan.setGoodsName(bo.getGoodsName());
|
|
|
+ plan.setGoodsLogo(bo.getGoodsLogo());
|
|
|
+ plan.setGoodsIntroduce(bo.getGoodsIntroduce());
|
|
|
+ plan.setGoodsClassify(bo.getGoodsClassify());
|
|
|
+ plan.setPlanCreateTime(bo.getPlanCreateTime());
|
|
|
+ plan.setPlanStartTime(bo.getPlanStartTime());
|
|
|
+ plan.setPlanEndTime(bo.getPlanEndTime());
|
|
|
+ plan.setState(0);
|
|
|
+ planMapper.insert(plan);
|
|
|
+ // 插入广告计划明细
|
|
|
+ for (PlanItem item : bo.getItems()) {
|
|
|
+ item.setPlanId(plan.getPlanId());
|
|
|
+ planItemMapper.insert(item);
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int deletePlan(List<String> ids) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int checkPlan(String planId, Integer state) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PlanListVo> getPlanList(PlanBo bo) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PlanDetailVo getPlanDetail(String planId) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PlanPushVo getPlanPush() {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|