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

Commit 5c05aca6 authored by 胡佳晨's avatar 胡佳晨

提交 app 正在下单 活动、店铺列表

parent 2ca63d68
......@@ -43,6 +43,8 @@ public class GoblinRedisConst {
public static final String REDIS_GOBLIN_STORE_SELF_RELATION = PREFIX.concat("zhengzai:storeId:");//活动-当前商铺能参与的官方活动id列表
public static final String REDIS_GOBLIN_STORE_MARKET = PREFIX.concat("store:market:");//商铺活动
public static final String REDIS_GOBLIN_ZHENGZAI_LIST = PREFIX.concat("zhengzai:list");//全部正在下单内容
public static final String REDIS_GOBLIN_STORE_MARKET_ISCONFIG = PREFIX.concat("store:is_config:");//商铺活动-该活动配置了款式的商品
/* ----------------------------------------------------------------- */
/**
......
......@@ -84,6 +84,7 @@ public class GoblinZhengzaiMarketServiceImpl implements IGoblinZhengzaiMarketSer
goblinMongoUtils.delSelfMarket(marketId);
//redis
goblinRedisUtils.delSelfMarket(marketId);
goblinRedisUtils.delZhengzaiList(marketId);
} else {
selfMarketing.setStatus(status);
selfMarketing.setUpdatedAt(LocalDateTime.now());
......@@ -92,9 +93,10 @@ public class GoblinZhengzaiMarketServiceImpl implements IGoblinZhengzaiMarketSer
//mongo
GoblinSelfMarketingVo vo = GoblinSelfMarketingVo.getNew();
BeanUtils.copyProperties(selfMarketing, vo);
goblinMongoUtils.updateSelfMarket(marketId, vo);
GoblinSelfMarketingVo changeVo = goblinMongoUtils.updateSelfMarket(marketId, vo);
//redis
goblinRedisUtils.setSelfMarket(marketId, vo);
goblinRedisUtils.setSelfMarket(marketId, changeVo);
goblinRedisUtils.changeZhengzaiList(changeVo);
}
return ResponseDto.success();
}
......@@ -120,6 +122,7 @@ public class GoblinZhengzaiMarketServiceImpl implements IGoblinZhengzaiMarketSer
goblinMongoUtils.insertSelfMarket(vo);
//redis
goblinRedisUtils.setSelfMarket(SelfMarketId, vo);
goblinRedisUtils.addZhengzaiList(vo);
return ResponseDto.success();
}
......@@ -139,9 +142,10 @@ public class GoblinZhengzaiMarketServiceImpl implements IGoblinZhengzaiMarketSer
vo.setName(purchaseName);
vo.setStartTime(st);
vo.setEndTime(et);
goblinMongoUtils.updateSelfMarket(marketId, vo);
GoblinSelfMarketingVo changeVo = goblinMongoUtils.updateSelfMarket(marketId, vo);
//redis
goblinRedisUtils.setSelfMarket(marketId, vo);
goblinRedisUtils.changeZhengzaiList(changeVo);
return ResponseDto.success();
}
......@@ -186,7 +190,7 @@ public class GoblinZhengzaiMarketServiceImpl implements IGoblinZhengzaiMarketSer
goblinMongoUtils.insertZhengzaiRelation(vo);
//redis
goblinRedisUtils.setZhengzaiRelation(marketId, vo);
goblinRedisUtils.addStoreSelfRelation(marketId,storeId);
goblinRedisUtils.addStoreSelfRelation(marketId, storeId);
return ResponseDto.success();
}
......@@ -205,7 +209,7 @@ public class GoblinZhengzaiMarketServiceImpl implements IGoblinZhengzaiMarketSer
goblinMongoUtils.updateZhengzaiRelation(marketId, storeId, vo);
//redis
goblinRedisUtils.setZhengzaiRelation(marketId, vo);
goblinRedisUtils.addStoreSelfRelation(marketId,storeId);
goblinRedisUtils.addStoreSelfRelation(marketId, storeId);
} else if (delTag == 1) {
GoblinMarketingZhengzaiRelation entity = GoblinMarketingZhengzaiRelation.getNew();
entity.setDelTag(1);
......@@ -216,7 +220,7 @@ public class GoblinZhengzaiMarketServiceImpl implements IGoblinZhengzaiMarketSer
goblinMongoUtils.delZhengzaiRelation(marketId, storeId);
//redis
goblinRedisUtils.delZhengzaiRelation(marketId, storeId);
goblinRedisUtils.delStoreSelfRelation(marketId,storeId);
goblinRedisUtils.delStoreSelfRelation(marketId, storeId);
}
return ResponseDto.success();
}
......
package com.liquidnet.client.admin.zhengzai.goblin.utils;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.goblin.dto.vo.GoblinMarketingZhengzaiRelationVo;
import com.liquidnet.service.goblin.dto.vo.GoblinSelfMarketingVo;
import com.liquidnet.service.goblin.entity.GoblinMarketingZhengzaiRelation;
import com.liquidnet.service.goblin.entity.GoblinSelfMarketing;
import com.liquidnet.service.kylin.dto.vo.partner.KylinTicketTimesPartnerVo;
import com.mongodb.BasicDBObject;
import com.mongodb.client.model.FindOneAndUpdateOptions;
import com.mongodb.client.model.ReturnDocument;
import com.mongodb.client.result.DeleteResult;
import com.mongodb.client.result.UpdateResult;
import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.convert.MongoConverter;
......@@ -26,11 +31,13 @@ public class GoblinMongoUtils {
return mongoTemplate.insert(data, GoblinSelfMarketingVo.class.getSimpleName());
}
public UpdateResult updateSelfMarket(String selfMarketId, GoblinSelfMarketingVo data) {
public GoblinSelfMarketingVo updateSelfMarket(String selfMarketId, GoblinSelfMarketingVo data) {
BasicDBObject object = GoblinObjectUtils.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(data));
return mongoTemplate.getCollection(GoblinSelfMarketing.class.getSimpleName()).updateOne(
Document doc = mongoTemplate.getCollection(GoblinSelfMarketing.class.getSimpleName()).findOneAndUpdate(
Query.query(Criteria.where("selfMarketId").is(selfMarketId)).getQueryObject(),
object);
object,
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER));
return JsonUtils.fromJson(doc.toJson(), GoblinSelfMarketingVo.class);
}
public DeleteResult delSelfMarket(String selfMarketId) {
......
......@@ -55,6 +55,7 @@ public class GoblinRedisUtils {
/**
* 获取 当前商铺能参与的官方活动id列表
*
* @param storeId
* @return
*/
......@@ -68,6 +69,7 @@ public class GoblinRedisUtils {
}
}
//添加 当前商铺能参与的活动id列表
public void addStoreSelfRelation(String selfMarketId, String storeId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_STORE_SELF_RELATION.concat(storeId);
List<String> list = getZhengzaiRelation(storeId);
......@@ -75,6 +77,7 @@ public class GoblinRedisUtils {
redisDataSourceUtil.getRedisGoblinUtil().set(redisKey, list);
}
//删除 当前商铺能参与的活动id列表
public void delStoreSelfRelation(String selfMarketId, String storeId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_STORE_SELF_RELATION.concat(storeId);
List<String> list = getZhengzaiRelation(storeId);
......@@ -82,4 +85,50 @@ public class GoblinRedisUtils {
redisDataSourceUtil.getRedisGoblinUtil().set(redisKey, list);
}
//获取 正在下单 活动列表
public List<GoblinSelfMarketingVo> getZhengzaiList() {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ZHENGZAI_LIST;
Object obj = redisDataSourceUtil.getRedisGoblinUtil().get(redisKey);
if (obj == null) {
return new ArrayList();
} else {
return (List<GoblinSelfMarketingVo>) obj;
}
}
//添加 正在下单 活动列表
public void addZhengzaiList(GoblinSelfMarketingVo vo) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ZHENGZAI_LIST;
List<GoblinSelfMarketingVo> list = getZhengzaiList();
list.add(vo);
redisDataSourceUtil.getRedisGoblinUtil().set(redisKey, list);
}
//删除 正在下单 活动列表
public void delZhengzaiList(String selfMarketId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ZHENGZAI_LIST;
List<GoblinSelfMarketingVo> list = getZhengzaiList();
for (GoblinSelfMarketingVo item : list) {
if (item.getSelfMarketId().equals(selfMarketId)) {
list.remove(item);
break;
}
}
redisDataSourceUtil.getRedisGoblinUtil().set(redisKey, list);
}
//修改 正在下单 活动列表
public void changeZhengzaiList(GoblinSelfMarketingVo vo) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ZHENGZAI_LIST;
List<GoblinSelfMarketingVo> list = getZhengzaiList();
for (int i = 0; i < list.size(); i++) {
GoblinSelfMarketingVo item = list.get(i);
if (item.getSelfMarketId().equals(vo.getSelfMarketId())) {
list.set(i, item);
break;
}
}
redisDataSourceUtil.getRedisGoblinUtil().set(redisKey, list);
}
}
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