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

Commit 12853a35 authored by 胡佳晨's avatar 胡佳晨

提交代码

parent f07beae8
......@@ -14,5 +14,6 @@ public class GoblinRedisConst {
public static final String REDIS_GOBLIN_ZHENGZAI_RELATION = PREFIX.concat("zhengzai:market:");
public static final String REDIS_GOBLIN_STORE_SELF_RELATION = PREFIX.concat("zhengzai:storeId:");
public static final String REDIS_GOBLIN_STORE_MARKET = PREFIX.concat("store:market:");
/* ----------------------------------------------------------------- */
}
......@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
@ApiModel(value = "GoblinStorePurchaseItemParam")
@Data
......@@ -16,19 +17,22 @@ public class GoblinStorePurchaseItemParam {
@ApiModelProperty(required = true, value = "商铺Id", example = "1")
@NotBlank(message = "商铺id不能为空")
private String storeId;
@ApiModelProperty(required = true, value = "spuId", example = "1")
@NotBlank(message = "spuId不能空")
private String spuId;
@ApiModelProperty(required = true, value = "skuId", example = "1")
@NotBlank(message = "skuId不能为空")
private String skuId;
@ApiModelProperty(required = true, value = "活动价格", example = "1.00")
@NotBlank(message = "活动价格不能为空")
private String priceMarketing;
private BigDecimal priceMarketing;
@ApiModelProperty(required = true, value = "活动库存", example = "1.00")
@NotBlank(message = "活动库存不能为空")
private String stockMarketing;
@ApiModelProperty(required = true, value = "用户限购[0-不限购|x-限购数量]", example = "1")
@NotBlank(message = "用户限购类型不能为空")
private String buyLimit;
private Integer buyLimit;
@ApiModelProperty(required = true, value = "购买条件[0-全部用户|1-仅支持会员|2-指定用户可买]", example = "1")
@NotBlank(message = "购买条件不能为空")
private String buyType;
private Integer buyType;
}
package com.liquidnet.service.goblin.dto.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
@ApiModel
@Data
public class GoblinStoreMarketVo implements Cloneable {
@ApiModelProperty(value = " 商铺营销表id")
private String storeMarketId;
@ApiModelProperty(value = " 营销名称")
private String name;
@ApiModelProperty(value = " 营销类型[1-满赠|2-限时秒杀]")
private Integer type;
@ApiModelProperty(value = " 活动状态[-1-全部|0-等待开始|1-活动中|2-活动结束|7-停用]")
private Integer status;
@ApiModelProperty(value = " 商铺id")
private String storeId;
@ApiModelProperty(value = " 营销描述")
private String desc;
@ApiModelProperty(value = " 营销开始时间")
private LocalDateTime startTime;
@ApiModelProperty(value = " 营销结束时间营销为定金预售的时候,该时间也是第二阶段付款的时间营销为全款预售的时候,该时间也是发货时间")
private LocalDateTime endTime;
@ApiModelProperty(value = "活动是否预热[0-否|1-是]")
private Integer isPre;
@ApiModelProperty(value = " 活动预热时间")
private LocalDateTime preTime;
@ApiModelProperty(value = " 创建时间")
private LocalDateTime createdAt;
private static final GoblinStoreMarketVo obj = new GoblinStoreMarketVo();
public static GoblinStoreMarketVo getNew() {
try {
return (GoblinStoreMarketVo) obj.clone();
} catch (CloneNotSupportedException e) {
return new GoblinStoreMarketVo();
}
}
}
package com.liquidnet.service.goblin.service.manage;
import com.github.pagehelper.PageInfo;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.manage.GoblinStorePurchaseItemParam;
import com.liquidnet.service.goblin.dto.vo.GoblinPurchasingVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreMarketVo;
import java.util.List;
......@@ -19,7 +20,7 @@ public interface IGoblinStorePurchasingService {
* @param ct 创建时间
* @return
*/
ResponseDto<List<GoblinPurchasingVo>> purchasingList(int page, String purchaseName, int status, String st, String et, String ct);
ResponseDto<PageInfo<GoblinStoreMarketVo>> purchasingList(int page, String purchaseName, int status, String st, String et, String ct);
/**
* 活动状态操作
......@@ -28,7 +29,7 @@ public interface IGoblinStorePurchasingService {
* @param status 状态
* @return
*/
ResponseDto<Boolean> purchasingStatus(String marketId, int status);
ResponseDto<Boolean> purchasingStatus(String marketId, String storeId, int status);
/**
* 添加 限时秒杀活动
......@@ -61,7 +62,7 @@ public interface IGoblinStorePurchasingService {
* @param marketId 活动秒杀id
* @return
*/
ResponseDto<GoblinPurchasingVo> purchasingDetails(String marketId);
ResponseDto<GoblinStoreMarketVo> purchasingDetails(String marketId, String storeId);
/**
* 获取活动内sku列表
......@@ -70,15 +71,23 @@ public interface IGoblinStorePurchasingService {
* @param page 页数
* @return
*/
ResponseDto<String> purchasingSkuList(String marketId, int page);//TODO 返回值
ResponseDto<String> purchasingSkuList(String marketId, String storeId, int page);//TODO 返回值
/**
* 配置活动相关sku
* 添加活动相关sku
*
* @param params
* @return
*/
ResponseDto<Boolean> purchasingSkuOperation(List<GoblinStorePurchaseItemParam> params);
ResponseDto<Boolean> purchasingSkuInsert(List<GoblinStorePurchaseItemParam> params);
/**
* 编辑活动相关sku
*
* @param params
* @return
*/
ResponseDto<Boolean> purchasingSkuUpdate(List<GoblinStorePurchaseItemParam> params);
/**
* 删除活动内sku
......@@ -87,5 +96,5 @@ public interface IGoblinStorePurchasingService {
* @param skuId skuId
* @return
*/
ResponseDto<Boolean> purchasingSkuDel(String marketId, String skuId);
ResponseDto<Boolean> purchasingSkuDel(String marketId, String storeId,String spuId, String skuId);
}
......@@ -18,7 +18,7 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class GoblinStoreMarketPurchasing implements Serializable {
public class GoblinStoreMarketPurchasing implements Serializable,Cloneable {
private static final long serialVersionUID = 1L;
......@@ -35,6 +35,11 @@ public class GoblinStoreMarketPurchasing implements Serializable {
*/
private String storeMarketId;
/**
* spu_id
*/
private String spuId;
/**
* sku_id
*/
......@@ -76,5 +81,12 @@ public class GoblinStoreMarketPurchasing implements Serializable {
private String comment;
private static final GoblinStoreMarketPurchasing obj = new GoblinStoreMarketPurchasing();
public static GoblinStoreMarketPurchasing getNew() {
try {
return (GoblinStoreMarketPurchasing) obj.clone();
} catch (CloneNotSupportedException e) {
return new GoblinStoreMarketPurchasing();
}
}
}
......@@ -19,7 +19,7 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class GoblinStoreMarketing implements Serializable {
public class GoblinStoreMarketing implements Serializable ,Cloneable{
private static final long serialVersionUID = 1L;
......@@ -87,5 +87,12 @@ public class GoblinStoreMarketing implements Serializable {
private String comment;
private static final GoblinStoreMarketing obj = new GoblinStoreMarketing();
public static GoblinStoreMarketing getNew() {
try {
return (GoblinStoreMarketing) obj.clone();
} catch (CloneNotSupportedException e) {
return new GoblinStoreMarketing();
}
}
}
......@@ -6,6 +6,7 @@ import com.liquidnet.service.goblin.dto.manage.GoblinStorePurchaseItemParam;
import com.liquidnet.service.goblin.dto.manage.GoblinStorePurchaseParam;
import com.liquidnet.service.goblin.dto.vo.GoblinPurchasingVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreInfoVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreMarketVo;
import com.liquidnet.service.goblin.service.manage.IGoblinStorePurchasingService;
import com.sun.org.apache.xpath.internal.operations.Bool;
import io.swagger.annotations.*;
......@@ -39,27 +40,27 @@ public class GoblinStorePurchasingController {
@ApiImplicitParam(type = "form", required = false, dataType = "String", name = "endTime", value = "活动结束时间", example = ""),
@ApiImplicitParam(type = "form", required = false, dataType = "String", name = "createdAt", value = "活动创建时间", example = ""),
})
public ResponseDto<PageInfo<GoblinPurchasingVo>> purchasingList(@RequestParam(value = "page", required = false) @Valid Integer page,
public ResponseDto<PageInfo<GoblinStoreMarketVo>> purchasingList(@RequestParam(value = "page", required = false) @Valid Integer page,
@RequestParam(value = "purchaseName", required = false) String purchaseName,
@RequestParam(value = "status", required = false) Integer status,
@RequestParam(value = "startTime", required = false) String st,
@RequestParam(value = "endTime", required = false) String et,
@RequestParam(value = "createdAt", required = false) String ct) {
PageInfo<GoblinPurchasingVo> data = new PageInfo<>();
data.setList(goblinStorePurchasingService.purchasingList(page, purchaseName, status, st, et, ct).getData());
return ResponseDto.success(data);
return goblinStorePurchasingService.purchasingList(page, purchaseName, status, st, et, ct);
}
@PutMapping("purchasing/status")
@ApiOperation("活动操作-限时秒杀")
@ApiResponse(code = 200, message = "接口返回对象参数")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "marketId", value = "活动id", example = "1"),
@ApiImplicitParam(type = "form", required = true, dataType = "Integer", name = "status", value = "活动状态[0-等待开始|7-停用]", example = ""),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "marketId", value = "活动id", example = ""),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeId", value = "商铺id", example = ""),
@ApiImplicitParam(type = "form", required = true, dataType = "Integer", name = "status", value = "活动状态[0-等待开始(启用)|7-停用|-1-删除]", example = ""),
})
public ResponseDto<Boolean> purchasingStatus(@RequestParam(value = "marketId") @Valid String marketId,
@RequestParam(value = "storeId") @Valid String storeId,
@RequestParam(value = "status") @Valid Integer status) {
return goblinStorePurchasingService.purchasingStatus(marketId, status);
return goblinStorePurchasingService.purchasingStatus(marketId, storeId,status);
}
@PostMapping("purchasing")
......@@ -84,9 +85,11 @@ public class GoblinStorePurchasingController {
@ApiResponse(code = 200, message = "接口返回对象参数")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "marketId", value = "活动id", example = "1"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeId", value = "商铺id", example = "1"),
})
public ResponseDto<GoblinPurchasingVo> purchasingDetails(@RequestParam("marketId") @Valid String marketId) {
return goblinStorePurchasingService.purchasingDetails(marketId);
public ResponseDto<GoblinStoreMarketVo> purchasingDetails(@RequestParam("marketId") @Valid String marketId,
@RequestParam("storeId") @Valid String storeId) {
return goblinStorePurchasingService.purchasingDetails(marketId, storeId);
}
@GetMapping("purchasing/sku")
......@@ -94,11 +97,13 @@ public class GoblinStorePurchasingController {
@ApiResponse(code = 200, message = "接口返回对象参数")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "marketId", value = "活动id", example = "1"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeId", value = "商铺id", example = "1"),
@ApiImplicitParam(type = "form", required = true, dataType = "Integer", name = "page", value = "页数", example = "1"),
})
public ResponseDto<String> purchasingSkuList(@RequestParam("marketId") @Valid String marketId,
@RequestParam("storeId") @Valid String storeId,
@RequestParam("page") @Valid Integer page) {
return goblinStorePurchasingService.purchasingSkuList(marketId, page);
return goblinStorePurchasingService.purchasingSkuList(marketId, storeId, page);
}
@PostMapping("purchasing/sku")
......@@ -114,11 +119,13 @@ public class GoblinStorePurchasingController {
@ApiResponse(code = 200, message = "接口返回对象参数")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "marketId", value = "活动id", example = "1"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeId", value = "商铺id", example = "1"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "skuId", value = "skuId", example = "1"),
})
public ResponseDto<Boolean> purchasingSkuDel(@RequestParam("marketId") @Valid String marketId,
@RequestParam("storeId") @Valid String storeId,
@RequestParam("skuId") @Valid String skuId) {
return goblinStorePurchasingService.purchasingSkuDel(marketId, skuId);
return goblinStorePurchasingService.purchasingSkuDel(marketId, storeId, skuId);
}
}
package com.liquidnet.service.goblin.service.impl.manage;
import com.github.pagehelper.PageInfo;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.manage.GoblinStorePurchaseItemParam;
import com.liquidnet.service.goblin.dto.vo.GoblinPurchasingVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreMarketVo;
import com.liquidnet.service.goblin.entity.GoblinStoreMarketPurchasing;
import com.liquidnet.service.goblin.entity.GoblinStoreMarketing;
import com.liquidnet.service.goblin.service.manage.IGoblinStorePurchasingService;
import com.liquidnet.service.goblin.util.GoblinMongoUtils;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS;
@Service
public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingService {
@Autowired
GoblinRedisUtils goblinRedisUtils;
@Autowired
GoblinMongoUtils goblinMongoUtils;
@Override
public ResponseDto<List<GoblinPurchasingVo>> purchasingList(int page, String purchaseName, int status, String st, String et, String ct) {
return null;
public ResponseDto<PageInfo<GoblinStoreMarketVo>> purchasingList(int page, String purchaseName, int status, String st, String et, String ct) {
PageInfo pageInfo = new PageInfo();
HashMap<String, Object> map = goblinMongoUtils.getStoreMarketList(page, purchaseName, status, st, et, ct);
pageInfo.setList((List) map.get("data"));
pageInfo.setTotal((Long) map.get("total"));
return ResponseDto.success(pageInfo);
}
@Override
public ResponseDto<Boolean> purchasingStatus(String marketId, int status) {
return null;
public ResponseDto<Boolean> purchasingStatus(String marketId, String storeId, int status) {
GoblinStoreMarketing bean = GoblinStoreMarketing.getNew();
LocalDateTime now = LocalDateTime.now();
bean.setUpdatedAt(now);
switch (status) {
case 0:
case 7:
bean.setStatus(status);
GoblinStoreMarketVo vo = GoblinStoreMarketVo.getNew();
vo.setStatus(status);
goblinMongoUtils.updateStoreMarket(marketId, storeId, vo);
vo = goblinRedisUtils.getGoblinStoreMarketVo(marketId, storeId);
vo.setStatus(status);
goblinRedisUtils.setGoblinStoreMarketVo(marketId, storeId, vo);
break;
case -1:
bean.setStatus(7);
bean.setDelFlag(1);
goblinMongoUtils.delStoreMarket(marketId, storeId);
goblinRedisUtils.delGoblinStoreMarketVo(marketId, storeId);
break;
}
//mysql todo
return ResponseDto.success();
}
@Override
public ResponseDto<Boolean> purchasingInsert(String purchaseName, String storeId, String st, String et, Integer isPre, String preTime) {
return null;
String storeMarketId = IDGenerator.nextTimeId2();
GoblinStoreMarketing bean = GoblinStoreMarketing.getNew();
bean.setStoreMarketId(storeMarketId);
bean.setName(purchaseName);
bean.setType(2);
bean.setStatus(0);
bean.setStoreId(storeId);
bean.setDesc("");
bean.setStartTime(LocalDateTime.parse(st, DTF_YMD_HMS));
bean.setEndTime(LocalDateTime.parse(et, DTF_YMD_HMS));
bean.setDelFlag(0);
bean.setIsPre(isPre);
if (isPre == 1) {
bean.setPreTime(LocalDateTime.parse(preTime, DTF_YMD_HMS));
}
bean.setCreatedAt(LocalDateTime.now());
GoblinStoreMarketVo vo = GoblinStoreMarketVo.getNew();
BeanUtils.copyProperties(bean, vo);
//mongo
goblinMongoUtils.insertStoreMarket(vo);
//redis
goblinRedisUtils.setGoblinStoreMarketVo(storeMarketId, storeId, vo);
//mysql todo
return ResponseDto.success();
}
@Override
public ResponseDto<Boolean> purchasingUpdate(String marketId, String purchaseName, String storeId, String st, String et, Integer isPre, String preTime) {
return null;
GoblinStoreMarketing bean = GoblinStoreMarketing.getNew();
bean.setName(purchaseName);
bean.setType(2);
bean.setStatus(0);
bean.setStoreId(storeId);
bean.setDesc("");
bean.setStartTime(LocalDateTime.parse(st, DTF_YMD_HMS));
bean.setEndTime(LocalDateTime.parse(et, DTF_YMD_HMS));
bean.setDelFlag(0);
bean.setIsPre(isPre);
if (isPre == 1) {
bean.setPreTime(LocalDateTime.parse(preTime, DTF_YMD_HMS));
}
bean.setCreatedAt(LocalDateTime.now());
GoblinStoreMarketVo vo = GoblinStoreMarketVo.getNew();
BeanUtils.copyProperties(bean, vo);
//mongo
goblinMongoUtils.updateStoreMarket(marketId, storeId, vo);
//redis
goblinRedisUtils.setGoblinStoreMarketVo(marketId, storeId, vo);
//mysql todo
return ResponseDto.success();
}
@Override
public ResponseDto<GoblinStoreMarketVo> purchasingDetails(String marketId, String storeId) {
return ResponseDto.success(goblinRedisUtils.getGoblinStoreMarketVo(marketId, storeId));
}
@Override
public ResponseDto<GoblinPurchasingVo> purchasingDetails(String marketId) {
public ResponseDto<String> purchasingSkuList(String marketId, String storeId, int page) {
return null;
}
@Override
public ResponseDto<String> purchasingSkuList(String marketId, int page) {
public ResponseDto<Boolean> purchasingSkuInsert(List<GoblinStorePurchaseItemParam> params) {
String purchaseId = IDGenerator.nextMilliId2();
LocalDateTime now = LocalDateTime.now();
for (GoblinStorePurchaseItemParam item : params) {
GoblinStoreMarketPurchasing bean = GoblinStoreMarketPurchasing.getNew();
bean.setPurchaseId(purchaseId);
bean.setStoreMarketId(item.getStoreMarketId());
bean.setStoreId(item.getStoreId());
bean.setSkuId(item.getSkuId());
bean.setSpuId(item.getSpuId());
bean.setPriceMarketing(item.getPriceMarketing());
bean.setStockMarketing(item.hashCode());
bean.setBuyLimit(item.getBuyLimit());
bean.setBuyType(item.getBuyType());
bean.setDelFlag(0);
bean.setCreatedAt(now);
//mongo
//redis
}
//mysql
return null;
}
@Override
public ResponseDto<Boolean> purchasingSkuOperation(List<GoblinStorePurchaseItemParam> params) {
public ResponseDto<Boolean> purchasingSkuUpdate(List<GoblinStorePurchaseItemParam> params) {
LocalDateTime now = LocalDateTime.now();
for (GoblinStorePurchaseItemParam item : params) {
GoblinStoreMarketPurchasing bean = GoblinStoreMarketPurchasing.getNew();
// bean.setStoreMarketId(item.getStoreMarketId());
// bean.setStoreId(item.getStoreId());
// bean.setSkuId(item.getSkuId());
// bean.setSpuId(item.getSpuId());
bean.setPriceMarketing(item.getPriceMarketing());
bean.setStockMarketing(item.hashCode());
bean.setBuyLimit(item.getBuyLimit());
bean.setBuyType(item.getBuyType());
bean.setDelFlag(0);
bean.setUpdatedAt(now);
//mongo
//redis
}
//mysql
return null;
}
@Override
public ResponseDto<Boolean> purchasingSkuDel(String marketId, String skuId) {
public ResponseDto<Boolean> purchasingSkuDel(String marketId, String storeId, String spuId, String skuId) {
LocalDateTime now = LocalDateTime.now();
GoblinStoreMarketPurchasing bean = GoblinStoreMarketPurchasing.getNew();
bean.setUpdatedAt(now);
bean.setDelFlag(1);
//mysql
//mongo
//redis
return null;
}
}
package com.liquidnet.service.goblin.util;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreMarketVo;
import com.mongodb.BasicDBObject;
import com.mongodb.client.result.DeleteResult;
import com.mongodb.client.result.UpdateResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.convert.MongoConverter;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
@Component
public class GoblinMongoUtils {
@Autowired
MongoTemplate mongoTemplate;
@Autowired
MongoConverter mongoConverter;
/**
* 添加 商铺活动 mongo
*
* @param data
* @return
*/
public GoblinStoreMarketVo insertStoreMarket(GoblinStoreMarketVo data) {
return mongoTemplate.insert(data, GoblinStoreMarketVo.class.getSimpleName());
}
/**
* 修改 商铺活动 mongo
*
* @param marketId
* @param data
* @return
*/
public UpdateResult updateStoreMarket(String marketId, String storeId,GoblinStoreMarketVo data) {
BasicDBObject object = ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(data));
return mongoTemplate.getCollection(GoblinStoreMarketVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("storeMarketId").is(marketId).and("storeId").is(storeId)).getQueryObject(),
object);
}
/**
* 获取 商铺活动 mongo
*
* @param marketId
* @param storeId
* @return
*/
public GoblinStoreMarketVo getStoreMarket(String marketId, String storeId) {
return mongoTemplate.findOne(Query.query(Criteria.where("storeMarketId").is(marketId).and("storeId").is(storeId)), GoblinStoreMarketVo.class, GoblinStoreMarketVo.class.getSimpleName());
}
/**
* 删除 商铺活动 mongo
*
* @param marketId
* @param storeId
* @return
*/
public DeleteResult delStoreMarket(String marketId, String storeId) {
return mongoTemplate.remove(Query.query(Criteria.where("storeMarketId").is(marketId).and("storeId").is(storeId)), GoblinStoreMarketVo.class.getSimpleName());
}
/**
* 获取 商铺活动列表
*
* @param page
* @param purchaseName
* @param status
* @param st
* @param et
* @param ct
* @return
*/
public HashMap<String, Object> getStoreMarketList(int page, String purchaseName, int status, String st, String et, String ct) {
String nowStr = DateUtil.getNowTime();
int size = 40;
HashMap<String, Object> info = CollectionUtil.mapStringObject();
// 排序 分页
Pageable pageable = PageRequest.of(page - 1, size, Sort.by(Sort.Direction.DESC, "createdAt"));
//条件
Criteria criteria = new Criteria();
if (purchaseName != null) {
criteria = criteria.and("name").regex(".*?\\" + purchaseName);
}
if (st != null && et != null) {
criteria = criteria.and("endTime").lte(et).and("startTime").gte(st);
}
if (ct != null) {
criteria = criteria.and("createdAt").regex(".*?\\" + ct);
}
switch (status) {
case 0:
criteria = criteria.and("startTime").gte(nowStr);
break;
case 1:
criteria = criteria.and("endTime").gte(nowStr).and("startTime").lte(nowStr);
break;
case 2:
criteria = criteria.and("endTime").lte(nowStr);
break;
case 7:
criteria = criteria.and("status").lte(7);
break;
}
Query query = Query.query(criteria);
// 查询总数
long count = mongoTemplate.count(query, GoblinStoreMarketVo.class, GoblinStoreMarketVo.class.getSimpleName());
query.with(pageable);
List<GoblinStoreMarketVo> voList = mongoTemplate.find(query, GoblinStoreMarketVo.class, GoblinStoreMarketVo.class.getSimpleName());
info.put("total", count);
info.put("data", voList);
return info;
}
}
package com.liquidnet.service.goblin.util;
import com.liquidnet.common.cache.redis.util.RedisDataSourceUtil;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.dto.vo.GoblinMarketingZhengzaiRelationVo;
import com.liquidnet.service.goblin.dto.vo.GoblinSelfMarketingVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreMarketVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component
public class GoblinRedisUtils {
@Autowired
RedisUtil redisUtil;
@Autowired
GoblinMongoUtils goblinMongoUtils;
/**
* 覆盖 商铺活动vo
*
* @param storeMarketId
* @param storeId
* @param vo
* @return
*/
public boolean setGoblinStoreMarketVo(String storeMarketId, String storeId, GoblinStoreMarketVo vo) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_STORE_MARKET.concat(storeMarketId).concat(":store_id:" + storeId);
return redisUtil.set(redisKey, vo);
}
/**
* 获取 商铺活动vo
*
* @param storeMarketId
* @param storeId
* @return
*/
public GoblinStoreMarketVo getGoblinStoreMarketVo(String storeMarketId, String storeId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_STORE_MARKET.concat(storeMarketId).concat(":store_id:" + storeId);
Object obj = redisUtil.get(redisKey);
if (obj == null) {
GoblinStoreMarketVo vo = goblinMongoUtils.getStoreMarket(storeMarketId, storeId);
setGoblinStoreMarketVo(storeMarketId, storeId, vo);
return vo;
} else {
return (GoblinStoreMarketVo) obj;
}
}
/**
* 删除 商铺活动vo
*
* @param storeMarketId
* @param storeId
* @return
*/
public void delGoblinStoreMarketVo(String storeMarketId, String storeId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_STORE_MARKET.concat(storeMarketId).concat(":store_id:" + storeId);
redisUtil.del(redisKey);
}
/**
* 获取 当前商铺能参与的官方活动id列表
......
......@@ -4,6 +4,7 @@ import com.liquidnet.service.base.PagedResult;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtGoodsListVo;
import com.liquidnet.service.goblin.dto.vo.GoblinSelfMarketingVo;
import com.liquidnet.service.goblin.entity.GoblinFrontBanner;
import com.mongodb.BasicDBObject;
import java.util.ArrayList;
......@@ -11,6 +12,11 @@ public class ObjectUtil {
private static final PagedResult<GoblinStoreMgtGoodsListVo> goblinStoreMgtGoodsVoPagedResult = new PagedResult<>();
private static final ArrayList<GoblinFrontBanner> goblinFrontBannerArrayList = new ArrayList<>();
private static final ArrayList<GoblinSelfMarketingVo> goblinSelfMarketingVoArrayList = new ArrayList<>();
private static final BasicDBObject basicDBObject = new BasicDBObject();
public static BasicDBObject cloneBasicDBObject() {
return (BasicDBObject) basicDBObject.clone();
}
public static PagedResult<GoblinStoreMgtGoodsListVo> getGoblinStoreMgtGoodsVoPagedResult() {
return goblinStoreMgtGoodsVoPagedResult.clone();
......
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