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

Commit 057a7eb6 authored by GaoHu's avatar GaoHu

exit

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