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

Commit 9899176c authored by 胡佳晨's avatar 胡佳晨

提交 结束时间未填写分段购 sku详情逻辑

增加 上个时间段 库存未售罄的库存
增加 getCollectByNowNext 根据时间获取当前分段购vo 如果当前没有返回下一个
增加 getListCanBuy 获取是否可分段购买
修改 skuVo详情 如果当前时间段未到分段购则返回下一个分段购的标签
parent 9945fb2f
...@@ -244,9 +244,10 @@ public class GoblinRedisConst { ...@@ -244,9 +244,10 @@ public class GoblinRedisConst {
public static final String NFT_PAY_TYPE = PREFIX.concat("nft:payType"); public static final String NFT_PAY_TYPE = PREFIX.concat("nft:payType");
public static final String LIST_DETAILS = PREFIX.concat("list:");//名单列表详情 $key:$listId public static final String LIST_DETAILS = PREFIX.concat("list:");//名单列表详情 $key:$listId
public static final String REDIS_BLACK = PREFIX.concat("black:");//黑名单 key:$skuId:$mobile public static final String REDIS_BLACK = PREFIX.concat("black:");//黑名单 key:$listId:$skuId:$mobile
public static final String REDIS_WHITE = PREFIX.concat("white:");//白名单 key:$skuId:$mobile public static final String REDIS_WHITE = PREFIX.concat("white:");//白名单 key:$listId:$skuId:$mobile
public static final String LIST_COLLECT = PREFIX.concat("list:collect");//名单列表详情 $key:$skuId public static final String LIST_COLLECT = PREFIX.concat("list:collect");//名单列表详情 $key:$skuId
public static final String ADAM_IS_MEMBER = "kylin:member:uid:";//是否会员 $key:$uid
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
......
...@@ -23,6 +23,8 @@ public class GoblinListCollectVo implements Serializable, Cloneable{ ...@@ -23,6 +23,8 @@ public class GoblinListCollectVo implements Serializable, Cloneable{
private BigDecimal priceV; private BigDecimal priceV;
@ApiModelProperty(value = "苹果价格id") @ApiModelProperty(value = "苹果价格id")
private String productId; private String productId;
@ApiModelProperty(value = "优先购类型[0-会员|1-指定用户]")
private Integer whiteType;
@ApiModelProperty(value = "开始时间") @ApiModelProperty(value = "开始时间")
private LocalDateTime timeStart; private LocalDateTime timeStart;
@ApiModelProperty(value = "结束时间") @ApiModelProperty(value = "结束时间")
......
...@@ -171,11 +171,11 @@ public abstract class AbstractOrderCloseReceiver implements StreamListener<Strin ...@@ -171,11 +171,11 @@ public abstract class AbstractOrderCloseReceiver implements StreamListener<Strin
goblinNftUtils.decrSkuCountByUid(nftOrder.getUserId(), nftOrder.getSkuId(), nftOrder.getNum()); goblinNftUtils.decrSkuCountByUid(nftOrder.getUserId(), nftOrder.getSkuId(), nftOrder.getNum());
LocalDateTime nowTime = LocalDateTime.now(); LocalDateTime nowTime = LocalDateTime.now();
if (StringUtils.isEmpty(nftOrder.getBoxSkuId())) {// 购买藏品 if (StringUtils.isEmpty(nftOrder.getBoxSkuId())) {// 购买藏品
GoblinListCollectVo goblinListCollectVo = goblinNftUtils.getCollectByNow(nowTime, nftOrder.getSkuId()); GoblinListCollectVo goblinListCollectVo = goblinNftUtils.getCollectByNowNext(nowTime, nftOrder.getSkuId());
String listId = (null == goblinListCollectVo) ? null : goblinListCollectVo.getListId(); String listId = (null == goblinListCollectVo) ? null : goblinListCollectVo.getListId();
goblinNftUtils.incrSkuStock(listId, nftOrder.getSkuId(), nftOrder.getNum()); goblinNftUtils.incrSkuStock(listId, nftOrder.getSkuId(), nftOrder.getNum());
} else {// 购买盲盒 } else {// 购买盲盒
GoblinListCollectVo goblinListCollectVo = goblinNftUtils.getCollectByNow(nowTime, nftOrder.getBoxSkuId()); GoblinListCollectVo goblinListCollectVo = goblinNftUtils.getCollectByNowNext(nowTime, nftOrder.getBoxSkuId());
String listId = (null == goblinListCollectVo) ? null : goblinListCollectVo.getListId(); String listId = (null == goblinListCollectVo) ? null : goblinListCollectVo.getListId();
goblinNftUtils.incrSkuStock(listId, nftOrder.getBoxSkuId(), nftOrder.getNum()); goblinNftUtils.incrSkuStock(listId, nftOrder.getBoxSkuId(), nftOrder.getNum());
} }
......
...@@ -64,6 +64,12 @@ public abstract class AbstractXlsRedisReceiver implements StreamListener<String, ...@@ -64,6 +64,12 @@ public abstract class AbstractXlsRedisReceiver implements StreamListener<String,
oXlsPath = path[1]; oXlsPath = path[1];
} }
String finalSkuId = (skuId = message.get("skuId")); String finalSkuId = (skuId = message.get("skuId"));
String listId;
// try {
listId = message.getOrDefault("listId", "");
// }catch (Exception e){
// listId = "";
// }
Integer finalType = (type = Integer.parseInt(message.get("type"))); Integer finalType = (type = Integer.parseInt(message.get("type")));
if (finalType.equals(1) || finalType.equals(2)) { if (finalType.equals(1) || finalType.equals(2)) {
EasyExcel.read(new URL(xlsPath).openStream(), PhoneDto.class, new PageReadListener<PhoneDto>(dataList -> { EasyExcel.read(new URL(xlsPath).openStream(), PhoneDto.class, new PageReadListener<PhoneDto>(dataList -> {
...@@ -95,9 +101,9 @@ public abstract class AbstractXlsRedisReceiver implements StreamListener<String, ...@@ -95,9 +101,9 @@ public abstract class AbstractXlsRedisReceiver implements StreamListener<String,
continue; continue;
} }
if (finalType.equals(3)) { if (finalType.equals(3)) {
redisUtil.set(GoblinRedisConst.REDIS_WHITE.concat(finalSkuId + ":").concat(data.get(0)), 1); redisUtil.set(GoblinRedisConst.REDIS_WHITE.concat(listId+":").concat(finalSkuId + ":").concat(data.get(0)), 1);
} else { } else {
redisUtil.set(GoblinRedisConst.REDIS_BLACK.concat(finalSkuId + ":").concat(data.get(0)), 1); redisUtil.set(GoblinRedisConst.REDIS_BLACK.concat(listId+":").concat(finalSkuId + ":").concat(data.get(0)), 1);
} }
} }
})).sheet().doRead(); })).sheet().doRead();
...@@ -109,9 +115,9 @@ public abstract class AbstractXlsRedisReceiver implements StreamListener<String, ...@@ -109,9 +115,9 @@ public abstract class AbstractXlsRedisReceiver implements StreamListener<String,
continue; continue;
} }
if (finalType.equals(3)) { if (finalType.equals(3)) {
redisUtil.del(GoblinRedisConst.REDIS_WHITE.concat(finalSkuId + ":").concat(data.get(0))); redisUtil.del(GoblinRedisConst.REDIS_WHITE.concat(listId+":").concat(finalSkuId + ":").concat(data.get(0)));
} else { } else {
redisUtil.del(GoblinRedisConst.REDIS_BLACK.concat(finalSkuId + ":").concat(data.get(0))); redisUtil.del(GoblinRedisConst.REDIS_BLACK.concat(listId+":").concat(finalSkuId + ":").concat(data.get(0)));
} }
} }
})).sheet().doRead(); })).sheet().doRead();
......
...@@ -7,6 +7,7 @@ import com.liquidnet.service.goblin.constant.GoblinStatusConst; ...@@ -7,6 +7,7 @@ import com.liquidnet.service.goblin.constant.GoblinStatusConst;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo; import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo;
import com.liquidnet.service.goblin.dto.vo.GoblinListCollectVo; import com.liquidnet.service.goblin.dto.vo.GoblinListCollectVo;
import com.liquidnet.service.goblin.dto.vo.GoblinNftOrderVo; import com.liquidnet.service.goblin.dto.vo.GoblinNftOrderVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreNoticeVo;
import com.mongodb.BasicDBObject; import com.mongodb.BasicDBObject;
import com.mongodb.client.result.UpdateResult; import com.mongodb.client.result.UpdateResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -18,8 +19,10 @@ import org.springframework.stereotype.Component; ...@@ -18,8 +19,10 @@ import org.springframework.stereotype.Component;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Component @Component
public class GoblinNftUtils { public class GoblinNftUtils {
...@@ -90,28 +93,38 @@ public class GoblinNftUtils { ...@@ -90,28 +93,38 @@ public class GoblinNftUtils {
* @param skuId * @param skuId
* @return * @return
*/ */
public GoblinListCollectVo getCollectByNow(LocalDateTime now, String skuId) { public GoblinListCollectVo getCollectByNowNext(LocalDateTime now, String skuId) {
GoblinListCollectVo collectVo = null; GoblinListCollectVo collectVo = null;
GoblinListCollectVo collectTemp = null; GoblinListCollectVo collectTemp = null;
GoblinListCollectVo collectNext = null;
List<GoblinListCollectVo> collectVos = getGoblinListCollect(skuId); List<GoblinListCollectVo> collectVos = getGoblinListCollect(skuId);
for (GoblinListCollectVo collectVoItem : collectVos) { for (int i = 0; i < collectVos.size(); i++) {
GoblinListCollectVo collectVoItem = collectVos.get(i);
if (now.isAfter(collectVoItem.getTimeStart()) && collectVoItem.getTimeEnd() == null) { if (now.isAfter(collectVoItem.getTimeStart()) && collectVoItem.getTimeEnd() == null) {
if (collectTemp == null || collectTemp.getTimeStart().isBefore(collectVoItem.getTimeStart())) { if (collectTemp == null || collectTemp.getTimeStart().isBefore(collectVoItem.getTimeStart())) {
collectTemp = collectVoItem; collectTemp = collectVoItem;
} }
} else if (now.isAfter(collectVoItem.getTimeStart()) && now.isBefore(collectVoItem.getTimeEnd())) { } else if (now.isAfter(collectVoItem.getTimeStart()) && now.isBefore(collectVoItem.getTimeEnd())) {
collectVo = collectVoItem; collectVo = collectVoItem;
break; } else if (now.isBefore(collectVoItem.getTimeStart())) {
if (collectNext == null || collectNext.getTimeStart().isAfter(collectNext.getTimeStart())) {
collectNext = collectVoItem;
}
} }
} }
if (collectVo == null) { if (collectVo == null && collectTemp != null) {
collectVo = collectTemp; collectVo = collectTemp;
} else if (collectVo == null) {
collectVo = collectNext;
} }
// lastStockToLastStock(1,collectVos, collectVo, skuId); // lastStockToLastStock(1,collectVos, collectVo, skuId);
return collectVo; return collectVo;
} }
/** /**
* 分段购获取 * 分段购获取
*
* @param skuId * @param skuId
* @return * @return
*/ */
...@@ -120,7 +133,9 @@ public class GoblinNftUtils { ...@@ -120,7 +133,9 @@ public class GoblinNftUtils {
if (obj == null) { if (obj == null) {
return new ArrayList<>(); return new ArrayList<>();
} else { } else {
return (List<GoblinListCollectVo>) obj; List<GoblinListCollectVo> list = (List<GoblinListCollectVo>) obj;
list = list.stream().sorted(Comparator.comparing(GoblinListCollectVo::getTimeStart)).collect(Collectors.toList());
return list;
} }
} }
......
...@@ -194,6 +194,7 @@ public class GoblinListServiceImpl implements IGoblinListService { ...@@ -194,6 +194,7 @@ public class GoblinListServiceImpl implements IGoblinListService {
collectVo.setPrice(itemVo.getPrice()); collectVo.setPrice(itemVo.getPrice());
collectVo.setPriceV(itemVo.getPriceV()); collectVo.setPriceV(itemVo.getPriceV());
collectVo.setProductId(itemVo.getProductId()); collectVo.setProductId(itemVo.getProductId());
collectVo.setWhiteType(vo.getWhiteType());
collectVo.setTimeStart(st); collectVo.setTimeStart(st);
collectVo.setTimeEnd(et); collectVo.setTimeEnd(et);
collectVo.setTagType(vo.getTagType()); collectVo.setTagType(vo.getTagType());
...@@ -201,9 +202,9 @@ public class GoblinListServiceImpl implements IGoblinListService { ...@@ -201,9 +202,9 @@ public class GoblinListServiceImpl implements IGoblinListService {
collectVos.add(collectVo); collectVos.add(collectVo);
redisUtils.setGoblinListCollect(itemVo.getSkuId(), collectVos); redisUtils.setGoblinListCollect(itemVo.getSkuId(), collectVos);
// 白名单 // 白名单
queueUtils.sendMsgByRedisXls(vo.getWhiteUrl(), "", "3", item.getSkuId()); queueUtils.sendMsgByRedisXls(vo.getListId(), vo.getWhiteUrl(), "", "3", item.getSkuId());
// 黑名单 // 黑名单
queueUtils.sendMsgByRedisXls(vo.getBlackUrl(), "", "4", item.getSkuId()); queueUtils.sendMsgByRedisXls(vo.getListId(), vo.getBlackUrl(), "", "4", item.getSkuId());
goblinListDetails.add(new Object[]{ goblinListDetails.add(new Object[]{
vo.getListId(), itemVo.getSpuId(), itemVo.getSkuId(), now, itemVo.getSkuStock(), itemVo.getPriceV(), itemVo.getProductId(), itemVo.getPrice() vo.getListId(), itemVo.getSpuId(), itemVo.getSkuId(), now, itemVo.getSkuStock(), itemVo.getPriceV(), itemVo.getProductId(), itemVo.getPrice()
}); });
...@@ -245,9 +246,9 @@ public class GoblinListServiceImpl implements IGoblinListService { ...@@ -245,9 +246,9 @@ public class GoblinListServiceImpl implements IGoblinListService {
vo.setBlackName(param.getBlackName() == null ? "" : param.getBlackName()); vo.setBlackName(param.getBlackName() == null ? "" : param.getBlackName());
for (GoblinListDetailsItemVo item : vo.getItemVo()) { for (GoblinListDetailsItemVo item : vo.getItemVo()) {
// 白名单 // 白名单
queueUtils.sendMsgByRedisXls(param.getWhiteUrl(), whiteUrl, "3", item.getSkuId()); queueUtils.sendMsgByRedisXls(vo.getListId(), param.getWhiteUrl(), whiteUrl, "3", item.getSkuId());
// 黑名单 // 黑名单
queueUtils.sendMsgByRedisXls(param.getBlackUrl(), blackUrl, "4", item.getSkuId()); queueUtils.sendMsgByRedisXls(vo.getListId(), param.getBlackUrl(), blackUrl, "4", item.getSkuId());
} }
redisUtils.setGoblinListDetailsVo(vo); redisUtils.setGoblinListDetailsVo(vo);
mongoUtils.changeGoblinListDetailsVo(vo); mongoUtils.changeGoblinListDetailsVo(vo);
...@@ -266,9 +267,9 @@ public class GoblinListServiceImpl implements IGoblinListService { ...@@ -266,9 +267,9 @@ public class GoblinListServiceImpl implements IGoblinListService {
} }
for (GoblinListDetailsItemVo item : vo.getItemVo()) { for (GoblinListDetailsItemVo item : vo.getItemVo()) {
// 白名单 // 白名单
queueUtils.sendMsgByRedisXls("", vo.getWhiteUrl(), "3", item.getSkuId()); queueUtils.sendMsgByRedisXls(vo.getListId(), "", vo.getWhiteUrl(), "3", item.getSkuId());
// 黑名单 // 黑名单
queueUtils.sendMsgByRedisXls("", vo.getBlackUrl(), "4", item.getSkuId()); queueUtils.sendMsgByRedisXls(vo.getListId(), "", vo.getBlackUrl(), "4", item.getSkuId());
} }
redisUtils.delGoblinListDetailsVo(listId); redisUtils.delGoblinListDetailsVo(listId);
mongoUtils.removeGoblinListDetailsVo(listId); mongoUtils.removeGoblinListDetailsVo(listId);
......
...@@ -25,10 +25,7 @@ import org.springframework.util.StringUtils; ...@@ -25,10 +25,7 @@ import org.springframework.util.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.liquidnet.service.goblin.constant.GoblinRedisConst.REDIS_GOBLIN_TEMP_COUPON_MARKET; import static com.liquidnet.service.goblin.constant.GoblinRedisConst.REDIS_GOBLIN_TEMP_COUPON_MARKET;
...@@ -715,13 +712,15 @@ public class GoblinRedisUtils { ...@@ -715,13 +712,15 @@ public class GoblinRedisUtils {
GoblinGoodsSkuInfoVo vo = getGoodsSkuInfoVo(skuId); GoblinGoodsSkuInfoVo vo = getGoodsSkuInfoVo(skuId);
HashMap<String, Object> map = CollectionUtil.mapStringObject(); HashMap<String, Object> map = CollectionUtil.mapStringObject();
if (now.isAfter(vo.getSaleStartTime())) {//普通商品已开售 if (now.isAfter(vo.getSaleStartTime())) {//普通商品已开售
lastStockToLastStock(0,getGoblinListCollect(skuId), null, skuId); lastStockToLastStock(0, getGoblinListCollect(skuId), null, skuId);
map.put("vo", vo); map.put("vo", vo);
map.put("tagType", null); map.put("tagType", null);
map.put("listId", null); map.put("listId", null);
map.put("whiteType", null);
} else {//未开售 } else {//未开售
GoblinListCollectVo collectVo = getCollectByNow(now, skuId); GoblinListCollectVo collectVo = getCollectByNow(now, skuId);
Integer tagType = null; Integer tagType = null;
Integer whiteType = null;
String listId = null; String listId = null;
if (collectVo != null) { if (collectVo != null) {
vo.setPrice(collectVo.getPrice()); vo.setPrice(collectVo.getPrice());
...@@ -729,12 +728,17 @@ public class GoblinRedisUtils { ...@@ -729,12 +728,17 @@ public class GoblinRedisUtils {
vo.setProductId(collectVo.getProductId()); vo.setProductId(collectVo.getProductId());
vo.setSaleStartTime(collectVo.getTimeStart()); vo.setSaleStartTime(collectVo.getTimeStart());
vo.setSaleStopTime(collectVo.getTimeEnd()); vo.setSaleStopTime(collectVo.getTimeEnd());
tagType = collectVo.getTagType();
listId = collectVo.getListId(); listId = collectVo.getListId();
whiteType = collectVo.getWhiteType();
}
GoblinListCollectVo collectNext = getCollectByNowNext(now, skuId);
if (collectNext != null) {
tagType = collectNext.getTagType();
} }
map.put("vo", vo); map.put("vo", vo);
map.put("tagType", tagType); map.put("tagType", tagType);
map.put("listId", listId); map.put("listId", listId);
map.put("whiteType", whiteType);
} }
return map; return map;
} }
...@@ -750,7 +754,8 @@ public class GoblinRedisUtils { ...@@ -750,7 +754,8 @@ public class GoblinRedisUtils {
GoblinListCollectVo collectVo = null; GoblinListCollectVo collectVo = null;
GoblinListCollectVo collectTemp = null; GoblinListCollectVo collectTemp = null;
List<GoblinListCollectVo> collectVos = getGoblinListCollect(skuId); List<GoblinListCollectVo> collectVos = getGoblinListCollect(skuId);
for (GoblinListCollectVo collectVoItem : collectVos) { for (int i = 0; i < collectVos.size(); i++) {
GoblinListCollectVo collectVoItem = collectVos.get(i);
if (now.isAfter(collectVoItem.getTimeStart()) && collectVoItem.getTimeEnd() == null) { if (now.isAfter(collectVoItem.getTimeStart()) && collectVoItem.getTimeEnd() == null) {
if (collectTemp == null || collectTemp.getTimeStart().isBefore(collectVoItem.getTimeStart())) { if (collectTemp == null || collectTemp.getTimeStart().isBefore(collectVoItem.getTimeStart())) {
collectTemp = collectVoItem; collectTemp = collectVoItem;
...@@ -763,7 +768,41 @@ public class GoblinRedisUtils { ...@@ -763,7 +768,41 @@ public class GoblinRedisUtils {
if (collectVo == null) { if (collectVo == null) {
collectVo = collectTemp; collectVo = collectTemp;
} }
lastStockToLastStock(1,collectVos, collectVo, skuId); lastStockToLastStock(1, collectVos, collectVo, skuId);
return collectVo;
}
/**
* 根据时间获取当前分段购vo 如果当前没有返回下一个
*
* @param now
* @param skuId
* @return
*/
public GoblinListCollectVo getCollectByNowNext(LocalDateTime now, String skuId) {
GoblinListCollectVo collectVo = null;
GoblinListCollectVo collectTemp = null;
GoblinListCollectVo collectNext = null;
List<GoblinListCollectVo> collectVos = getGoblinListCollect(skuId);
for (int i = 0; i < collectVos.size(); i++) {
GoblinListCollectVo collectVoItem = collectVos.get(i);
if (now.isAfter(collectVoItem.getTimeStart()) && collectVoItem.getTimeEnd() == null) {
if (collectTemp == null || collectTemp.getTimeStart().isBefore(collectVoItem.getTimeStart())) {
collectTemp = collectVoItem;
}
} else if (now.isAfter(collectVoItem.getTimeStart()) && now.isBefore(collectVoItem.getTimeEnd())) {
collectVo = collectVoItem;
} else if (now.isBefore(collectVoItem.getTimeStart())) {
if (collectNext == null || collectNext.getTimeStart().isAfter(collectNext.getTimeStart())) {
collectNext = collectVoItem;
}
}
}
if (collectVo == null && collectTemp != null) {
collectVo = collectTemp;
} else if (collectVo == null) {
collectVo = collectNext;
}
return collectVo; return collectVo;
} }
...@@ -817,6 +856,44 @@ public class GoblinRedisUtils { ...@@ -817,6 +856,44 @@ public class GoblinRedisUtils {
} }
} }
/**
* 分批购是否可购买
*
* @param listId
* @param skuId
* @param mobile
* @param uid
* @param whiteType
* @return
*/
public Boolean getListCanBuy(String listId, String skuId, String mobile, String uid, Integer whiteType) {
String rdkB = GoblinRedisConst.REDIS_BLACK.concat(listId + ":").concat(skuId + "").concat(mobile);
String rdkW = GoblinRedisConst.REDIS_WHITE.concat(listId + ":").concat(skuId + "").concat(mobile);
boolean bResult = redisUtil.hasKey(rdkB);//是否黑名单
boolean wResult = redisUtil.hasKey(rdkW);//是否白名单
Integer memberStage = getMember(uid);
if (bResult) {
return false;
}
if (whiteType == 0) {//会员
return memberStage != null;
} else {//白名单
return wResult;
}
}
// 1普通会员 2老会员
public Integer getMember(String uid) {
String redisKey = GoblinRedisConst.ADAM_IS_MEMBER
.concat(uid);
Object obj = redisUtil.get(redisKey);
if (obj == null) {
return null;
} else {
return (Integer) obj;
}
}
public GoblinGoodsSkuInfoVo getGoodsSkuInfoVoByUnShelves(String skuId) { public GoblinGoodsSkuInfoVo getGoodsSkuInfoVoByUnShelves(String skuId) {
String pre = GoblinStatusConst.MarketPreStatus.getPre(skuId); String pre = GoblinStatusConst.MarketPreStatus.getPre(skuId);
if (pre != null && pre.equals(GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue())) { if (pre != null && pre.equals(GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue())) {
...@@ -1866,7 +1943,9 @@ public class GoblinRedisUtils { ...@@ -1866,7 +1943,9 @@ public class GoblinRedisUtils {
if (obj == null) { if (obj == null) {
return ObjectUtil.getGoblinListCollectVo(); return ObjectUtil.getGoblinListCollectVo();
} else { } else {
return (List<GoblinListCollectVo>) obj; List<GoblinListCollectVo> list = (List<GoblinListCollectVo>) obj;
list = list.stream().sorted(Comparator.comparing(GoblinListCollectVo::getTimeStart)).collect(Collectors.toList());
return list;
} }
} }
......
...@@ -68,9 +68,10 @@ public class QueueUtils { ...@@ -68,9 +68,10 @@ public class QueueUtils {
* @param type [1-添加|2-删除|3-白名单|4-白名单] * @param type [1-添加|2-删除|3-白名单|4-白名单]
* @param skuId skuId * @param skuId skuId
*/ */
public void sendMsgByRedisXls(String nXlsPath, String oXlsPath, String type, String skuId) { public void sendMsgByRedisXls(String listId,String nXlsPath, String oXlsPath, String type, String skuId) {
HashMap<String, String> map = CollectionUtil.mapStringString(); HashMap<String, String> map = CollectionUtil.mapStringString();
map.put(MQConst.QUEUE_MESSAGE_KEY, nXlsPath.concat(",").concat(oXlsPath)); map.put(MQConst.QUEUE_MESSAGE_KEY, nXlsPath.concat(",").concat(oXlsPath));
map.put("listId", listId);
map.put("type", type); map.put("type", type);
map.put("skuId", skuId); map.put("skuId", skuId);
stringRedisTemplate.opsForStream().add(StreamRecords.mapBacked(map).withStreamKey(MQConst.GoblinQueue.GOBLIN_XLS_OPERA.getKey())); stringRedisTemplate.opsForStream().add(StreamRecords.mapBacked(map).withStreamKey(MQConst.GoblinQueue.GOBLIN_XLS_OPERA.getKey()));
......
...@@ -14,8 +14,10 @@ import org.springframework.util.CollectionUtils; ...@@ -14,8 +14,10 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Component @Component
public class GoblinRedisUtils { public class GoblinRedisUtils {
...@@ -177,13 +179,15 @@ public class GoblinRedisUtils { ...@@ -177,13 +179,15 @@ public class GoblinRedisUtils {
GoblinGoodsSkuInfoVo vo = getGoodsSkuInfoVo(skuId); GoblinGoodsSkuInfoVo vo = getGoodsSkuInfoVo(skuId);
HashMap<String, Object> map = CollectionUtil.mapStringObject(); HashMap<String, Object> map = CollectionUtil.mapStringObject();
if (now.isAfter(vo.getSaleStartTime())) {//普通商品已开售 if (now.isAfter(vo.getSaleStartTime())) {//普通商品已开售
lastStockToLastStock(0,getGoblinListCollect(skuId), null, skuId); lastStockToLastStock(0, getGoblinListCollect(skuId), null, skuId);
map.put("vo", vo); map.put("vo", vo);
map.put("tagType", null); map.put("tagType", null);
map.put("listId", null); map.put("listId", null);
map.put("whiteType", null);
} else {//未开售 } else {//未开售
GoblinListCollectVo collectVo = getCollectByNow(now, skuId); GoblinListCollectVo collectVo = getCollectByNow(now, skuId);
Integer tagType = null; Integer tagType = null;
Integer whiteType = null;
String listId = null; String listId = null;
if (collectVo != null) { if (collectVo != null) {
vo.setPrice(collectVo.getPrice()); vo.setPrice(collectVo.getPrice());
...@@ -193,10 +197,16 @@ public class GoblinRedisUtils { ...@@ -193,10 +197,16 @@ public class GoblinRedisUtils {
vo.setSaleStopTime(collectVo.getTimeEnd()); vo.setSaleStopTime(collectVo.getTimeEnd());
tagType = collectVo.getTagType(); tagType = collectVo.getTagType();
listId = collectVo.getListId(); listId = collectVo.getListId();
whiteType = collectVo.getWhiteType();
}
GoblinListCollectVo collectNext = getCollectByNowNext(now, skuId);
if (collectNext != null) {
tagType = collectNext.getTagType();
} }
map.put("vo", vo); map.put("vo", vo);
map.put("tagType", tagType); map.put("tagType", tagType);
map.put("listId", listId); map.put("listId", listId);
map.put("whiteType", whiteType);
} }
return map; return map;
} }
...@@ -212,7 +222,8 @@ public class GoblinRedisUtils { ...@@ -212,7 +222,8 @@ public class GoblinRedisUtils {
GoblinListCollectVo collectVo = null; GoblinListCollectVo collectVo = null;
GoblinListCollectVo collectTemp = null; GoblinListCollectVo collectTemp = null;
List<GoblinListCollectVo> collectVos = getGoblinListCollect(skuId); List<GoblinListCollectVo> collectVos = getGoblinListCollect(skuId);
for (GoblinListCollectVo collectVoItem : collectVos) { for (int i = 0; i < collectVos.size(); i++) {
GoblinListCollectVo collectVoItem = collectVos.get(i);
if (now.isAfter(collectVoItem.getTimeStart()) && collectVoItem.getTimeEnd() == null) { if (now.isAfter(collectVoItem.getTimeStart()) && collectVoItem.getTimeEnd() == null) {
if (collectTemp == null || collectTemp.getTimeStart().isBefore(collectVoItem.getTimeStart())) { if (collectTemp == null || collectTemp.getTimeStart().isBefore(collectVoItem.getTimeStart())) {
collectTemp = collectVoItem; collectTemp = collectVoItem;
...@@ -225,7 +236,41 @@ public class GoblinRedisUtils { ...@@ -225,7 +236,41 @@ public class GoblinRedisUtils {
if (collectVo == null) { if (collectVo == null) {
collectVo = collectTemp; collectVo = collectTemp;
} }
lastStockToLastStock(1,collectVos, collectVo, skuId); lastStockToLastStock(1, collectVos, collectVo, skuId);
return collectVo;
}
/**
* 根据时间获取当前分段购vo 如果当前没有返回下一个
*
* @param now
* @param skuId
* @return
*/
public GoblinListCollectVo getCollectByNowNext(LocalDateTime now, String skuId) {
GoblinListCollectVo collectVo = null;
GoblinListCollectVo collectTemp = null;
GoblinListCollectVo collectNext = null;
List<GoblinListCollectVo> collectVos = getGoblinListCollect(skuId);
for (int i = 0; i < collectVos.size(); i++) {
GoblinListCollectVo collectVoItem = collectVos.get(i);
if (now.isAfter(collectVoItem.getTimeStart()) && collectVoItem.getTimeEnd() == null) {
if (collectTemp == null || collectTemp.getTimeStart().isBefore(collectVoItem.getTimeStart())) {
collectTemp = collectVoItem;
}
} else if (now.isAfter(collectVoItem.getTimeStart()) && now.isBefore(collectVoItem.getTimeEnd())) {
collectVo = collectVoItem;
} else if (now.isBefore(collectVoItem.getTimeStart())) {
if (collectNext == null || collectNext.getTimeStart().isAfter(collectNext.getTimeStart())) {
collectNext = collectVoItem;
}
}
}
if (collectVo == null && collectTemp != null) {
collectVo = collectTemp;
} else if (collectVo == null) {
collectVo = collectNext;
}
return collectVo; return collectVo;
} }
...@@ -281,6 +326,7 @@ public class GoblinRedisUtils { ...@@ -281,6 +326,7 @@ public class GoblinRedisUtils {
/** /**
* 分段购获取 * 分段购获取
*
* @param skuId * @param skuId
* @return * @return
*/ */
...@@ -289,7 +335,35 @@ public class GoblinRedisUtils { ...@@ -289,7 +335,35 @@ public class GoblinRedisUtils {
if (obj == null) { if (obj == null) {
return ObjectUtil.getGoblinListCollectVo(); return ObjectUtil.getGoblinListCollectVo();
} else { } else {
return (List<GoblinListCollectVo>) obj; List<GoblinListCollectVo> list = (List<GoblinListCollectVo>) obj;
list = list.stream().sorted(Comparator.comparing(GoblinListCollectVo::getTimeStart)).collect(Collectors.toList());
return list;
}
}
/**
* 分批购是否可购买
*
* @param listId
* @param skuId
* @param mobile
* @param uid
* @param whiteType
* @return
*/
public Boolean getListCanBuy(String listId, String skuId, String mobile, String uid, Integer whiteType) {
String rdkB = GoblinRedisConst.REDIS_BLACK.concat(listId + ":").concat(skuId + "").concat(mobile);
String rdkW = GoblinRedisConst.REDIS_WHITE.concat(listId + ":").concat(skuId + "").concat(mobile);
boolean bResult = redisUtil.hasKey(rdkB);//是否黑名单
boolean wResult = redisUtil.hasKey(rdkW);//是否白名单
Integer memberStage = getMember(uid);
if (bResult) {
return false;
}
if (whiteType == 0) {//会员
return memberStage != null;
} else {//白名单
return wResult;
} }
} }
...@@ -500,9 +574,9 @@ public class GoblinRedisUtils { ...@@ -500,9 +574,9 @@ public class GoblinRedisUtils {
String redisKey = KylinRedisConst.ADAM_IS_MEMBER String redisKey = KylinRedisConst.ADAM_IS_MEMBER
.concat(uid); .concat(uid);
Object obj = redisUtil.get(redisKey); Object obj = redisUtil.get(redisKey);
if(obj==null){ if (obj == null) {
return null; return null;
}else{ } else {
return (Integer) obj; return (Integer) obj;
} }
} }
......
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