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

Commit 057a7eb6 authored by GaoHu's avatar GaoHu

exit

parent 4ea9f164
......@@ -15,7 +15,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.LinkedList;
/**
......@@ -42,7 +41,7 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
//查询该skuId是否能被预约
GoblinGoodsAnticipateValueVo anticipateValueVo = goblinRedisUtils.getValueBySkuId(skuId);
if (anticipateValueVo != null) {
anticipateValueVo.setState(setState(anticipateValueVo.getAboutStartDate(), anticipateValueVo.getAboutEndDate()));
anticipateValueVo.setState(GoblinAnticipateUtils.setState(anticipateValueVo.getAboutStartDate(), anticipateValueVo.getAboutEndDate()));
if (!anticipateValueVo.getState().equals(1)) {
return ResponseDto.failure("该商品预约尚未开始或已经结束,不可预约!");
}
......@@ -90,25 +89,6 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
return ResponseDto.success(goblinRedisUtils.getUserAboutAut(skuId,userInfo.getUid()) != null) ;
}
private Integer setState(LocalDateTime startDate, LocalDateTime endDate) {
LocalDateTime now = LocalDateTime.now();
if (startDate.isAfter(now)) {
//未开始 0
return 0;
}
if (startDate.isBefore(now) && endDate.isAfter(now)) {
//预约中 1
return 1;
}
if (endDate.isBefore(now)) {
//已结束 2
return 2;
}
//其他
return null;
}
public void sendRedis(String sqlKey, LinkedList<Object[]> sqlData) {
LinkedList<String> sql = CollectionUtil.linkedListString();
sql.add(SqlMapping.get(sqlKey));
......
......@@ -13,6 +13,7 @@ import com.liquidnet.service.goblin.dto.manage.vo.AnticipateValueVo;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinGoodsAnticipateValueVo;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsAnticipateVo;
import com.liquidnet.service.goblin.service.manage.IGoblinGoodsAnticipateMgService;
import com.liquidnet.service.goblin.util.GoblinAnticipateUtils;
import com.liquidnet.service.goblin.util.GoblinMongoUtils;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import com.liquidnet.service.goblin.util.QueueUtils;
......@@ -142,7 +143,7 @@ public class GoblinGoodsAnticipateMgServiceImpl implements IGoblinGoodsAnticipat
//实际预约人数
anticipateValueVo.setActualPeople(autIdPeople);
//设置预约状态
anticipateValueVo.setState(setState(anticipateValueVo.getAboutStartDate(), anticipateValueVo.getAboutEndDate()));
anticipateValueVo.setState(GoblinAnticipateUtils.setState(anticipateValueVo.getAboutStartDate(), anticipateValueVo.getAboutEndDate()));
}
pageInfo.setPageNum(goodsAnticipateValueParam.getPageNum());
......@@ -152,25 +153,6 @@ public class GoblinGoodsAnticipateMgServiceImpl implements IGoblinGoodsAnticipat
return ResponseDto.success(pageInfo);
}
private Integer setState(LocalDateTime startDate, LocalDateTime endDate) {
LocalDateTime now = LocalDateTime.now();
if (startDate.isAfter(now)) {
//未开始 0
return 0;
}
if (startDate.isBefore(now) && endDate.isAfter(now)) {
//预约中 1
return 1;
}
if (endDate.isBefore(now)) {
//已结束 2
return 2;
}
//其他
return null;
}
@Override
public ResponseDto<Object> updatePeople(String skuId, BigInteger people) {
//修改Mongodb
......@@ -191,7 +173,7 @@ public class GoblinGoodsAnticipateMgServiceImpl implements IGoblinGoodsAnticipat
GoblinGoodsAnticipateValueVo goodsAnticipateValueVo = goblinRedisUtils.getValueBySkuId(skuId);
if (goodsAnticipateValueVo != null) {
goodsAnticipateValueVo.setState(setState(goodsAnticipateValueVo.getAboutStartDate(), goodsAnticipateValueVo.getAboutEndDate()));
goodsAnticipateValueVo.setState(GoblinAnticipateUtils.setState(goodsAnticipateValueVo.getAboutStartDate(), goodsAnticipateValueVo.getAboutEndDate()));
//没有开启则可以删除预约
if (!goodsAnticipateValueVo.getState().equals(0)) {
return ResponseDto.failure("预约状态为已开启或已结束,不可删除!");
......@@ -210,24 +192,13 @@ public class GoblinGoodsAnticipateMgServiceImpl implements IGoblinGoodsAnticipat
return ResponseDto.failure("该预约不存在");
}
private void delUserBySkuId(String skuId) {
//删除redis 和mongodb
goblinMongoUtils.delUserBySkuId(skuId);
//数据库修改 用户预约过该skuId的表字段全部修改未 1
LinkedList<Object[]> sqlValue = CollectionUtil.linkedListObjectArr();
sqlValue.add(new Object[]{
skuId
});
sendRedis("goblin_goods_anticipate_user_update_sku", sqlValue);
}
@Override
public AnticipateValueVo getAnticipateValueBySkuId(String skuId, int hasHead) {
GoblinGoodsAnticipateValueVo anticipateValueVo = goblinRedisUtils.getValueBySkuId(skuId);
AnticipateValueVo valueVo = AnticipateValueVo.getNew();
if (anticipateValueVo != null) {
valueVo = valueVo.copy(anticipateValueVo);
valueVo.setState(setState(valueVo.getAboutStartDate(), valueVo.getAboutEndDate()));
valueVo.setState(GoblinAnticipateUtils.setState(valueVo.getAboutStartDate(), valueVo.getAboutEndDate()));
} else {
valueVo.setState(null);
valueVo.setAboutEndDate(null);
......
......@@ -13,6 +13,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
import java.time.LocalDateTime;
/**
* @author TT
*/
......@@ -23,8 +25,6 @@ public class GoblinAnticipateUtils {
@Value("${liquidnet.service.adam.url}")
private String adamUrl;
private final String avatar = "";
public AdamUserInfoVo getUserInfo() {
try {
MultiValueMap<String, String> header = CollectionUtil.linkedMultiValueMapStringString();
......@@ -45,4 +45,23 @@ public class GoblinAnticipateUtils {
return null;
}
}
public static Integer setState(LocalDateTime startDate, LocalDateTime endDate) {
LocalDateTime now = LocalDateTime.now();
if (startDate.isAfter(now)) {
//未开始 0
return 0;
}
if (startDate.isBefore(now) && endDate.isAfter(now)) {
//预约中 1
return 1;
}
if (endDate.isBefore(now)) {
//已结束 2
return 2;
}
//其他
return null;
}
}
......@@ -89,14 +89,6 @@ public class GoblinRedisUtils {
redisUtil.set(GoblinRedisConst.USER_ANTICIPATE_STATE.concat(user.getSkuId()).concat(user.getUid()),user,60*60*24*30);
}
/**
* 删除用户预约
*/
public void delUserAboutSku(String skuId, String uid) {
goblinMongoUtils.delGoodsAnticipateUserVo(uid, skuId);
redisUtil.del(GoblinRedisConst.USER_ANTICIPATE_STATE.concat(skuId).concat(uid));
}
/**
* 实际预约人数修改
*/
......@@ -114,19 +106,12 @@ public class GoblinRedisUtils {
return (BigInteger) redisUtil.get(GoblinRedisConst.ANTICIPATE_PEOPLE.concat(skuId));
}
/**
* 删除预约
*/
public void delGoodsSkuId(String skuId) {
redisUtil.del(GoblinRedisConst.ANTICIPATE_SKUID.concat(skuId));
}
/**
* 保存用户头像
*/
public void setUserAvatar(String skuId,String avatar) {
List<String> list = (List) redisUtil.get(GoblinRedisConst.ANTICIPATE_SKUID_AVATAR.concat(skuId));
List<String> urlList = list != null ? list : new ArrayList<String>();
Object list = redisUtil.get(GoblinRedisConst.ANTICIPATE_SKUID_AVATAR.concat(skuId));
List<String> urlList = list != null ? (List<String>)list : CollectionUtil.arrayListString();
if (urlList.size()<=2){
urlList.add(avatar);
redisUtil.set(GoblinRedisConst.ANTICIPATE_SKUID_AVATAR.concat(skuId),urlList);
......@@ -135,8 +120,6 @@ public class GoblinRedisUtils {
/**
* 获取用户预约头像
* @param skuId
* @return
*/
public List<String> getUserAvatar(String skuId){
String rdk = GoblinRedisConst.ANTICIPATE_SKUID_AVATAR.concat(skuId);
......
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