|
@@ -5,10 +5,7 @@ import cn.hutool.core.lang.Dict;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
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.bo.*;
|
|
|
import com.ruoyi.demo.entity.vo.*;
|
|
|
import com.ruoyi.demo.mapper.*;
|
|
|
import com.ruoyi.demo.service.PlanService;
|
|
@@ -55,14 +52,14 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
|
@Override
|
|
|
public String getSign(PlanAddBo bo) {
|
|
|
- QueryWrapper<App> appQueryWrapper = new QueryWrapper<>();
|
|
|
- appQueryWrapper.eq("appkey", bo.getAppkey());
|
|
|
- appQueryWrapper.eq("state", 1);
|
|
|
- appQueryWrapper.eq("deleted", "0");
|
|
|
- App app = appMapper.selectOne(appQueryWrapper);
|
|
|
+ App app = appMapper.selectOne(new QueryWrapper<App>()
|
|
|
+ .eq("appkey", bo.getAppkey())
|
|
|
+ .eq("state", 1)
|
|
|
+ .eq("deleted", "0"));
|
|
|
if (app == null)
|
|
|
return "error";
|
|
|
Map<String, Object> params = Dict.create()
|
|
|
+ .set("planOtherId", bo.getPlanOtherId())
|
|
|
.set("appkey", bo.getAppkey())
|
|
|
.set("goodsId", bo.getGoodsId())
|
|
|
.set("goodsImg", bo.getGoodsImg())
|
|
@@ -81,17 +78,17 @@ public class PlanServiceImpl implements PlanService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int addPlan(PlanAddBo bo) {
|
|
|
+ public String addPlan(PlanAddBo bo) {
|
|
|
// app是否可用
|
|
|
- QueryWrapper<App> appQueryWrapper = new QueryWrapper<>();
|
|
|
- appQueryWrapper.eq("appkey", bo.getAppkey());
|
|
|
- appQueryWrapper.eq("state", 1);
|
|
|
- appQueryWrapper.eq("deleted", "0");
|
|
|
- App app = appMapper.selectOne(appQueryWrapper);
|
|
|
+ App app = appMapper.selectOne(new QueryWrapper<App>()
|
|
|
+ .eq("appkey", bo.getAppkey())
|
|
|
+ .eq("state", 1)
|
|
|
+ .eq("deleted", "0"));
|
|
|
if (app == null)
|
|
|
- return -1;
|
|
|
+ return "-1";
|
|
|
// 校验
|
|
|
Map<String, Object> params = Dict.create()
|
|
|
+ .set("planOtherId", bo.getPlanOtherId())
|
|
|
.set("appkey", bo.getAppkey())
|
|
|
.set("goodsId", bo.getGoodsId())
|
|
|
.set("goodsImg", bo.getGoodsImg())
|
|
@@ -107,45 +104,41 @@ public class PlanServiceImpl implements PlanService {
|
|
|
.set("vendorId", bo.getVendorId())
|
|
|
.set("vendorName", bo.getVendorName());
|
|
|
if (!SignUtil.verify(params, app.getAppSecret()))
|
|
|
- return -3;
|
|
|
+ return "-3";
|
|
|
// 插入广告计划
|
|
|
Plan plan = new Plan(app, bo);
|
|
|
- planMapper.insert(plan);
|
|
|
+ int i = planMapper.insert(plan);
|
|
|
+ if (i == 0)
|
|
|
+ return "0";
|
|
|
// 插入广告计划明细
|
|
|
for (PlanItemAddBo itemAddBo : bo.getItems()) {
|
|
|
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());
|
|
|
- goodsQueryWrapper.eq("vendor_id", bo.getVendorId());
|
|
|
- Goods query = goodsMapper.selectOne(goodsQueryWrapper);
|
|
|
- if (query == null) {
|
|
|
- Goods goods = new Goods(plan);
|
|
|
- goodsMapper.insert(goods);
|
|
|
- }
|
|
|
- return 1;
|
|
|
+ Goods query = goodsMapper.selectOne(new QueryWrapper<Goods>()
|
|
|
+ .eq("appkey", bo.getAppkey())
|
|
|
+ .eq("goods_id", bo.getGoodsId())
|
|
|
+ .eq("vendor_id", bo.getVendorId()));
|
|
|
+ if (query == null)
|
|
|
+ goodsMapper.insert(new Goods(plan));
|
|
|
+ return plan.getPlanId();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int deletePlan(String id) {
|
|
|
- QueryWrapper<PlanItem> itemQueryWrapper = new QueryWrapper<>();
|
|
|
- itemQueryWrapper.eq("plan_id", id);
|
|
|
- planItemMapper.delete(itemQueryWrapper);
|
|
|
- QueryWrapper<Plan> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("plan_id", id);
|
|
|
- return planMapper.delete(queryWrapper);
|
|
|
+ planItemMapper.delete(new QueryWrapper<PlanItem>()
|
|
|
+ .eq("plan_id", id));
|
|
|
+ return planMapper.delete(new QueryWrapper<Plan>()
|
|
|
+ .eq("plan_id", id));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int deletePlans(List<String> ids) {
|
|
|
int i = 0;
|
|
|
for (String id : ids) {
|
|
|
- QueryWrapper<Plan> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("plan_id", id);
|
|
|
- i += planMapper.delete(queryWrapper);
|
|
|
+ i += planMapper.delete(new QueryWrapper<Plan>()
|
|
|
+ .eq("plan_id", id));
|
|
|
}
|
|
|
return i;
|
|
|
}
|
|
@@ -153,18 +146,16 @@ public class PlanServiceImpl implements PlanService {
|
|
|
@Override
|
|
|
public int checkPlan(PlanBo bo, Long userId, String userName) {
|
|
|
// 是否有该计划
|
|
|
- QueryWrapper<Plan> planQueryWrapper = new QueryWrapper<>();
|
|
|
- planQueryWrapper.eq("plan_id", bo.getPlanId())
|
|
|
- .eq("deleted", "0");
|
|
|
- Plan plan = planMapper.selectOne(planQueryWrapper);
|
|
|
+ Plan plan = planMapper.selectOne(new QueryWrapper<Plan>()
|
|
|
+ .eq("plan_id", bo.getPlanId())
|
|
|
+ .eq("deleted", "0"));
|
|
|
if (plan == null)
|
|
|
return -1;
|
|
|
// 没有该app或者该app已经被禁用,则不允许审核
|
|
|
- QueryWrapper<App> appQueryWrapper = new QueryWrapper<>();
|
|
|
- appQueryWrapper.eq("appkey", plan.getAppkey())
|
|
|
+ App app = appMapper.selectOne(new QueryWrapper<App>()
|
|
|
+ .eq("appkey", plan.getAppkey())
|
|
|
.eq("state", 1)
|
|
|
- .eq("deleted", "0");
|
|
|
- App app = appMapper.selectOne(appQueryWrapper);
|
|
|
+ .eq("deleted", "0"));
|
|
|
if (app == null)
|
|
|
return -1;
|
|
|
// 确定审核状态并更新广告计划
|
|
@@ -225,15 +216,13 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
|
@Override
|
|
|
public PlanDetailVo getPlanDetail(String planId) {
|
|
|
- QueryWrapper<Plan> planQueryWrapper = new QueryWrapper<>();
|
|
|
- planQueryWrapper.eq("plan_id", planId);
|
|
|
- planQueryWrapper.eq("deleted", "0");
|
|
|
- Plan plan = planMapper.selectOne(planQueryWrapper);
|
|
|
+ Plan plan = planMapper.selectOne(new QueryWrapper<Plan>()
|
|
|
+ .eq("plan_id", planId)
|
|
|
+ .eq("deleted", "0"));
|
|
|
if (plan == null)
|
|
|
return null;
|
|
|
- QueryWrapper<PlanItem> itemQueryWrapper = new QueryWrapper<>();
|
|
|
- itemQueryWrapper.eq("plan_id", planId);
|
|
|
- List<PlanItem> items = planItemMapper.selectList(itemQueryWrapper);
|
|
|
+ List<PlanItem> items = planItemMapper.selectList(new QueryWrapper<PlanItem>()
|
|
|
+ .eq("plan_id", planId));
|
|
|
List<PlanItemVo> itemVos = new ArrayList<>();
|
|
|
if (items != null)
|
|
|
for (PlanItem item : items) {
|
|
@@ -248,21 +237,17 @@ public class PlanServiceImpl implements PlanService {
|
|
|
// 根据设备id查询可投放的广告计划
|
|
|
// 再根据每个广告计划id,查询其商品信息
|
|
|
List<PlanPushVo> pushVos = new ArrayList<>();
|
|
|
- QueryWrapper<PlanItem> itemQueryWrapper = new QueryWrapper<>();
|
|
|
- itemQueryWrapper.eq("equipment_id", equipmentId);
|
|
|
- itemQueryWrapper.eq("deleted", "0");
|
|
|
- List<PlanItem> items = planItemMapper.selectList(itemQueryWrapper);
|
|
|
+ List<PlanItem> items = planItemMapper.selectList(new QueryWrapper<PlanItem>()
|
|
|
+ .eq("equipment_id", equipmentId)
|
|
|
+ .eq("deleted", "0"));
|
|
|
for (PlanItem item : items) {
|
|
|
- QueryWrapper<Plan> planQueryWrapper = new QueryWrapper<>();
|
|
|
-
|
|
|
- // 广告计划开始时间 <= 当前时间 < 广告计划结束时间
|
|
|
- planQueryWrapper.apply("plan_start_time <= STR_TO_DATE({0},'%Y-%m-%d %H:%i:%s')", DateUtil.date());
|
|
|
- planQueryWrapper.apply("plan_end_time > STR_TO_DATE({0},'%Y-%m-%d %H:%i:%s')", DateUtil.date());
|
|
|
-
|
|
|
- planQueryWrapper.eq("plan_id", item.getPlanId());
|
|
|
- planQueryWrapper.eq("state", StateUtil.APPROVED);
|
|
|
- planQueryWrapper.eq("deleted", "0");
|
|
|
- Plan plan = planMapper.selectOne(planQueryWrapper);
|
|
|
+ Plan plan = planMapper.selectOne(new QueryWrapper<Plan>()
|
|
|
+ // 广告计划开始时间 <= 当前时间 < 广告计划结束时间
|
|
|
+ .apply("plan_start_time <= STR_TO_DATE({0},'%Y-%m-%d %H:%i:%s')", DateUtil.date())
|
|
|
+ .apply("plan_end_time > STR_TO_DATE({0},'%Y-%m-%d %H:%i:%s')", DateUtil.date())
|
|
|
+ .eq("plan_id", item.getPlanId())
|
|
|
+ .eq("state", StateUtil.APPROVED)
|
|
|
+ .eq("deleted", "0"));
|
|
|
if (plan != null)
|
|
|
pushVos.add(new PlanPushVo(item, plan));
|
|
|
}
|
|
@@ -273,24 +258,20 @@ public class PlanServiceImpl implements PlanService {
|
|
|
public List<PlanPushVo> getPlanPushByCode(String equipmentCode) {
|
|
|
List<PlanPushVo> pushVos = new ArrayList<>();
|
|
|
// 根据设备编号查询设备下的广告计划子项
|
|
|
- QueryWrapper<PlanItem> itemQueryWrapper = new QueryWrapper<>();
|
|
|
- itemQueryWrapper.eq("equipment_code", equipmentCode);
|
|
|
- itemQueryWrapper.eq("deleted", "0");
|
|
|
- List<PlanItem> items = planItemMapper.selectList(itemQueryWrapper);
|
|
|
+ List<PlanItem> items = planItemMapper.selectList(new QueryWrapper<PlanItem>()
|
|
|
+ .eq("equipment_code", equipmentCode)
|
|
|
+ .eq("deleted", "0"));
|
|
|
// 排序
|
|
|
items.sort(Comparator.comparing(PlanItem::getSort).reversed());
|
|
|
for (PlanItem item : items) { // 根据计划子项查询计划,并补齐返回信息
|
|
|
- QueryWrapper<Plan> planQueryWrapper = new QueryWrapper<>();
|
|
|
- planQueryWrapper.eq("plan_id", item.getPlanId());
|
|
|
-
|
|
|
- // 广告计划开始时间 <= 当前时间 < 广告计划结束时间
|
|
|
- planQueryWrapper.apply("plan_start_time <= STR_TO_DATE({0},'%Y-%m-%d %H:%i:%s')", DateUtil.date());
|
|
|
- planQueryWrapper.apply("plan_end_time > STR_TO_DATE({0},'%Y-%m-%d %H:%i:%s')", DateUtil.date());
|
|
|
-
|
|
|
- planQueryWrapper.eq("state", StateUtil.APPROVED);
|
|
|
- planQueryWrapper.eq("on_state", OnStateUtil.UP);
|
|
|
- planQueryWrapper.eq("deleted", "0");
|
|
|
- Plan plan = planMapper.selectOne(planQueryWrapper);
|
|
|
+ Plan plan = planMapper.selectOne(new QueryWrapper<Plan>()
|
|
|
+ .eq("plan_id", item.getPlanId())
|
|
|
+ // 广告计划开始时间 <= 当前时间 < 广告计划结束时间
|
|
|
+ .apply("plan_start_time <= STR_TO_DATE({0},'%Y-%m-%d %H:%i:%s')", DateUtil.date())
|
|
|
+ .apply("plan_end_time > STR_TO_DATE({0},'%Y-%m-%d %H:%i:%s')", DateUtil.date())
|
|
|
+ .eq("state", StateUtil.APPROVED)
|
|
|
+ .eq("on_state", OnStateUtil.UP)
|
|
|
+ .eq("deleted", "0"));
|
|
|
if (plan != null)
|
|
|
pushVos.add(new PlanPushVo(item, plan));
|
|
|
}
|
|
@@ -300,10 +281,9 @@ public class PlanServiceImpl implements PlanService {
|
|
|
@Override
|
|
|
public int planUpDown(String planId) {
|
|
|
// 是否存在该广告计划
|
|
|
- QueryWrapper<Plan> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("plan_id", planId);
|
|
|
- queryWrapper.eq("deleted", "0");
|
|
|
- Plan plan = planMapper.selectOne(queryWrapper);
|
|
|
+ Plan plan = planMapper.selectOne(new QueryWrapper<Plan>()
|
|
|
+ .eq("plan_id", planId)
|
|
|
+ .eq("deleted", "0"));
|
|
|
if (plan == null)
|
|
|
return -1;
|
|
|
// 改变状态,1:上架;0:下架
|
|
@@ -326,6 +306,63 @@ public class PlanServiceImpl implements PlanService {
|
|
|
return planMapper.updateById(plan);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public int planPushUpDown(UpDownBo bo) {
|
|
|
+ // app是否可用
|
|
|
+ App app = appMapper.selectOne(new QueryWrapper<App>()
|
|
|
+ .eq("appkey", bo.getAppkey())
|
|
|
+ .eq("state", 1)
|
|
|
+ .eq("deleted", "0"));
|
|
|
+ if (app == null)
|
|
|
+ return -1;
|
|
|
+ // 校验
|
|
|
+ Map<String, Object> params = Dict.create()
|
|
|
+ .set("appkey", bo.getAppkey())
|
|
|
+ .set("planIds", bo.getPlanIds())
|
|
|
+ .set("sign", bo.getSign());
|
|
|
+ if (!SignUtil.verify(params, app.getAppSecret()))
|
|
|
+ return -3;
|
|
|
+ for (String planId : bo.getPlanIds()){
|
|
|
+ Plan plan = planMapper.selectOne(new QueryWrapper<Plan>()
|
|
|
+ .eq("plan_id", planId)
|
|
|
+ .eq("deleted", "0"));
|
|
|
+ if (plan == null)
|
|
|
+ continue;
|
|
|
+ // 改变状态,1:上架;0:下架
|
|
|
+ plan.setOnState(plan.getOnState() + 1);
|
|
|
+ if (plan.getOnState() >= 2) {
|
|
|
+ plan.setOnState(0);
|
|
|
+ // 发送下架信息
|
|
|
+ try {
|
|
|
+ Map<String, Object> map = Dict.create()
|
|
|
+ .set("msg", "您的广告\"" + plan.getPlanName() + "\"已下架")
|
|
|
+ .set("time", DateUtil.date());
|
|
|
+ SendCallBackUtil.sendCallBack(app.getCallBack(), map);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ planMapper.updateById(plan);
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String pushGetSign(UpDownBo bo) {
|
|
|
+ // app是否可用
|
|
|
+ App app = appMapper.selectOne(new QueryWrapper<App>()
|
|
|
+ .eq("appkey", bo.getAppkey())
|
|
|
+ .eq("state", 1)
|
|
|
+ .eq("deleted", "0"));
|
|
|
+ if (app == null)
|
|
|
+ return "error";
|
|
|
+ // 校验
|
|
|
+ Map<String, Object> params = Dict.create()
|
|
|
+ .set("appkey", bo.getAppkey())
|
|
|
+ .set("planIds", bo.getPlanIds())
|
|
|
+ .set("sign", bo.getSign());
|
|
|
+ return SignUtil.sign(params, app.getAppSecret());
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public MyPage<PlanManageListVo> getPlanManageList(PlanBo bo) {
|
|
|
QueryWrapper<Plan> planQueryWrapper = new QueryWrapper<>();
|
|
@@ -361,16 +398,14 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
|
@Override
|
|
|
public PlanManageDetailVo getPlanManageDetail(String planId) {
|
|
|
- QueryWrapper<Plan> planQueryWrapper = new QueryWrapper<>();
|
|
|
- planQueryWrapper.eq("plan_id", planId)
|
|
|
- .eq("deleted", "0");
|
|
|
- Plan plan = planMapper.selectOne(planQueryWrapper);
|
|
|
+ Plan plan = planMapper.selectOne(new QueryWrapper<Plan>()
|
|
|
+ .eq("plan_id", planId)
|
|
|
+ .eq("deleted", "0"));
|
|
|
if (plan == null)
|
|
|
return null;
|
|
|
- QueryWrapper<PlanItem> itemQueryWrapper = new QueryWrapper<>();
|
|
|
- itemQueryWrapper.eq("plan_id", planId)
|
|
|
- .eq("deleted", "0");
|
|
|
- List<PlanItem> items = planItemMapper.selectList(itemQueryWrapper);
|
|
|
+ List<PlanItem> items = planItemMapper.selectList(new QueryWrapper<PlanItem>()
|
|
|
+ .eq("plan_id", planId)
|
|
|
+ .eq("deleted", "0"));
|
|
|
List<PlanManageItemVo> itemVos = new ArrayList<>();
|
|
|
for (PlanItem item : items) { // 补齐店铺信息
|
|
|
PlanManageItemVo itemVo = new PlanManageItemVo(item);
|
|
@@ -489,9 +524,8 @@ public class PlanServiceImpl implements PlanService {
|
|
|
@Override
|
|
|
public List<AddrCategory> getAddrCategoryLevel(String code, String level) {
|
|
|
if ("province".equals(level)) {
|
|
|
- QueryWrapper<AddrCategory> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("city", "");
|
|
|
- return addrCategoryMapper.selectList(queryWrapper);
|
|
|
+ return addrCategoryMapper.selectList(new QueryWrapper<AddrCategory>()
|
|
|
+ .eq("city", ""));
|
|
|
} else if ("city".equals(level)) {
|
|
|
QueryWrapper<AddrCategory> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.likeRight("addr_code", code.substring(0, 2));
|