记得上下班打卡 | git大法好,push需谨慎

Commit 1ceb84bf authored by zhengfuxin's avatar zhengfuxin

修改精选商品

parent 4ba25734
......@@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
/**
* <p>
......@@ -64,7 +65,7 @@ public class GoblinFrontSelectGoodsParam implements Serializable {
private int orderType;
@ApiModelProperty(value = "spu信息")
private GoblinGoods goblinGoods;
private List<GoblinGoods> goblinGoodsList;
}
......@@ -11,7 +11,9 @@ import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.entity.GoblinFrontSelectGoods;
import com.liquidnet.service.goblin.entity.GoblinGoods;
import com.liquidnet.service.goblin.mapper.GoblinFrontSelectGoodsMapper;
import com.liquidnet.service.goblin.mapper.GoblinGoodsMapper;
import com.liquidnet.service.goblin.param.GoblinFrontSelectGoodsParam;
import com.mongodb.BasicDBObject;
import org.springframework.beans.BeanUtils;
......@@ -22,6 +24,7 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -43,6 +46,8 @@ public class GoblinFrontSelectGoodsServiceImpl extends ServiceImpl<GoblinFrontSe
private RedisGoblinUtil redisGoblinUtil;
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
GoblinGoodsMapper goblinGoodsMapper;
public boolean create(GoblinFrontSelectGoods goblinFrontSelectGoods){
List list= this.getList();
......@@ -70,8 +75,12 @@ public class GoblinFrontSelectGoodsServiceImpl extends ServiceImpl<GoblinFrontSe
}
public boolean update(GoblinFrontSelectGoods goblinFrontSelectGoods){
goblinFrontSelectGoods.setUpdateTime(LocalDateTime.now());
goblinFrontSelectGoodsMapper.updateById(goblinFrontSelectGoods);
if(goblinFrontSelectGoods.getMid()>0){
goblinFrontSelectGoods.setUpdateTime(LocalDateTime.now());
goblinFrontSelectGoodsMapper.updateById(goblinFrontSelectGoods);
}else{
this.create(goblinFrontSelectGoods);
}
return true;
}
......@@ -79,19 +88,30 @@ public class GoblinFrontSelectGoodsServiceImpl extends ServiceImpl<GoblinFrontSe
LambdaQueryWrapper<GoblinFrontSelectGoods> queryWrapper = Wrappers.lambdaQuery(GoblinFrontSelectGoods.class);
queryWrapper.eq(GoblinFrontSelectGoods::getDelTag,0);
List<GoblinFrontSelectGoods> list= goblinFrontSelectGoodsMapper.selectList(queryWrapper);
List<GoblinGoods> goblinGoodsList =new ArrayList<>();
List<GoblinFrontSelectGoodsParam> goodsP =new ArrayList<>();
for(GoblinFrontSelectGoods goblinFrontSelectGoods:list){
String spuids=goblinFrontSelectGoods.getSpuId();
if(StringUtil.isNotBlank(spuids)){
String[] spuIds=spuids.split(",");
for(String id:spuIds){
LambdaQueryWrapper<GoblinGoods> queryWrappers = Wrappers.lambdaQuery(GoblinGoods.class);
queryWrappers.ne(GoblinGoods::getDelFlg,"1");
queryWrappers.eq(GoblinGoods::getSpuId,id);
List<GoblinGoods> goodsList= goblinGoodsMapper.selectList(queryWrappers);
if(goodsList.size()>0){
goblinGoodsList.add(goodsList.get(0));
}
}
}
GoblinFrontSelectGoodsParam goblinFrontSelectGoodsParam=new GoblinFrontSelectGoodsParam();
BeanUtils.copyProperties(goblinFrontSelectGoods,goblinFrontSelectGoodsParam);
goblinFrontSelectGoodsParam.setGoblinGoodsList(goblinGoodsList);
goodsP.add(goblinFrontSelectGoodsParam);
}
return goblinFrontSelectGoodsMapper.selectList(queryWrapper);
return goodsP;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment