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

Commit 5c1335d1 authored by GaoHu's avatar GaoHu

exit

parent a861ee81
...@@ -45,6 +45,6 @@ public interface IGoblinGoodsAnticipateService { ...@@ -45,6 +45,6 @@ public interface IGoblinGoodsAnticipateService {
/** /**
* 用户预约 * 用户预约
*/ */
ResponseDto<Object> userAbout(String skuId, String uid, String phone, Integer state,String url); ResponseDto<Object> userAbout(String skuId, String uid, String phone,String url);
} }
...@@ -34,7 +34,7 @@ public class GoblinGoodsAnticipateController { ...@@ -34,7 +34,7 @@ public class GoblinGoodsAnticipateController {
@Autowired @Autowired
IGoblinGoodsAnticipateService goblinGoodsAnticipateService; IGoblinGoodsAnticipateService goblinGoodsAnticipateService;
@ApiOperation("用户预约(state预约标识:0为预约,1为取消预约)") @ApiOperation("用户预约 (只能预约不能取消)")
@PostMapping("/userAbout") @PostMapping("/userAbout")
public ResponseDto<Object> userAbout(HttpServletRequest request, public ResponseDto<Object> userAbout(HttpServletRequest request,
@RequestParam(name = "skuId", required = true) String skuId, @RequestParam(name = "skuId", required = true) String skuId,
...@@ -42,7 +42,7 @@ public class GoblinGoodsAnticipateController { ...@@ -42,7 +42,7 @@ public class GoblinGoodsAnticipateController {
@RequestParam(name = "phone", required = true) String phone) { @RequestParam(name = "phone", required = true) String phone) {
String url = "url"; String url = "url";
return goblinGoodsAnticipateService.userAbout(skuId, uid, phone, 0,url); return goblinGoodsAnticipateService.userAbout(skuId, uid, phone,url);
} }
} }
...@@ -140,30 +140,34 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS ...@@ -140,30 +140,34 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
//实际预约人数 //实际预约人数
anticipateValueVo.setActualPeople(autIdPeople); anticipateValueVo.setActualPeople(autIdPeople);
//设置预约状态 //设置预约状态
//预约开始时间 setState(anticipateValueVo);
LocalDateTime aboutStartDate = anticipateValueVo.getAboutStartDate();
//预约结束时间
LocalDateTime aboutEndDate = anticipateValueVo.getAboutEndDate();
LocalDateTime now = LocalDateTime.now();
if (aboutStartDate.isAfter(now)) {
//未开始 0
anticipateValueVo.setState(0);
}
if (aboutStartDate.isBefore(now) && aboutEndDate.isAfter(now)) {
//预约中 1
anticipateValueVo.setState(1);
}
if (aboutEndDate.isBefore(now)) {
//已结束 2
anticipateValueVo.setState(2);
}
} }
pageInfo.setList(data); pageInfo.setList(data);
pageInfo.setTotal((Long) map.get("total")); pageInfo.setTotal((Long) map.get("total"));
return ResponseDto.success(pageInfo); return ResponseDto.success(pageInfo);
} }
private void setState(GoblinGoodsAnticipateValueVo anticipateValueVo) {
//预约开始时间
LocalDateTime aboutStartDate = anticipateValueVo.getAboutStartDate();
//预约结束时间
LocalDateTime aboutEndDate = anticipateValueVo.getAboutEndDate();
LocalDateTime now = LocalDateTime.now();
if (aboutStartDate.isAfter(now)) {
//未开始 0
anticipateValueVo.setState(0);
}
if (aboutStartDate.isBefore(now) && aboutEndDate.isAfter(now)) {
//预约中 1
anticipateValueVo.setState(1);
}
if (aboutEndDate.isBefore(now)) {
//已结束 2
anticipateValueVo.setState(2);
}
}
@Override @Override
public ResponseDto<Object> updatePeople(String skuId, BigInteger people) { public ResponseDto<Object> updatePeople(String skuId, BigInteger people) {
//修改Mongodb //修改Mongodb
...@@ -182,23 +186,24 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS ...@@ -182,23 +186,24 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
public ResponseDto<Object> delete(String skuId) { public ResponseDto<Object> delete(String skuId) {
//更具skuId查询 //更具skuId查询
GoblinGoodsAnticipateValueVo goodsAnticipateValueVo = goblinMongoUtils.getAnticipateValueVo(skuId); GoblinGoodsAnticipateValueVo goodsAnticipateValueVo = goblinMongoUtils.getAnticipateValueVo(skuId);
if (goodsAnticipateValueVo!=null){
//没有开启则可以删除预约 setState(goodsAnticipateValueVo);
LocalDateTime aboutStartDate = goodsAnticipateValueVo.getAboutStartDate(); //没有开启则可以删除预约
LocalDateTime now = LocalDateTime.now(); if (!goodsAnticipateValueVo.getState().equals(0)){
if (aboutStartDate.isAfter(now)){ return ResponseDto.failure("预约状态为已开启或已结束,不可删除!");
return ResponseDto.failure("预约开启,不可以删除"); }
//mysql删除
LinkedList<Object[]> sqlValue = CollectionUtil.linkedListObjectArr();
sqlValue.add(new Object[]{
skuId
});
//预约库删除
sendRedis("goblin_goods_anticipate_value_delete", sqlValue);
//删除mongodb
goblinMongoUtils.delGoodsAnticipateValueVo(skuId);
return ResponseDto.success();
} }
//mysql删除 return ResponseDto.failure("该预约不存在");
LinkedList<Object[]> sqlValue = CollectionUtil.linkedListObjectArr();
sqlValue.add(new Object[]{
skuId
});
//预约库删除
sendRedis("goblin_goods_anticipate_value_delete", sqlValue);
//删除mongodb
goblinMongoUtils.delGoodsAnticipateValueVo(skuId);
return ResponseDto.success();
} }
private void delUserBySkuId(String skuId) { private void delUserBySkuId(String skuId) {
...@@ -213,43 +218,41 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS ...@@ -213,43 +218,41 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
} }
@Override @Override
public ResponseDto<Object> userAbout(String skuId, String uid, String phone, Integer state,String url) { public ResponseDto<Object> userAbout(String skuId, String uid, String phone,String url) {
//查询该用户是否预 //查询该skuId是否能被预约
GoblinGoodAnticipateUserVo userVo = goblinRedisUtils.getUserAboutAut(skuId, uid); GoblinGoodsAnticipateValueVo anticipateValueVo = goblinMongoUtils.getAnticipateValueVo(skuId);
LinkedList<Object[]> sqlValue = CollectionUtil.linkedListObjectArr(); if (anticipateValueVo!=null) {
if (state.equals(GoblinGoodAnticipateUserVo.STATE_VALID) && userVo == null) { setState(anticipateValueVo);
GoblinGoodAnticipateUserVo user = new GoblinGoodAnticipateUserVo(); if (!anticipateValueVo.getState().equals(1)) {
user.setUid(uid); return ResponseDto.failure("预约尚未开始或已结束!");
user.setSkuId(skuId); }
user.setPhone(phone); //查询该用户是否预
user.setState(state); GoblinGoodAnticipateUserVo userVo = goblinRedisUtils.getUserAboutAut(skuId, uid);
//mongodb记录 LinkedList<Object[]> sqlValue = CollectionUtil.linkedListObjectArr();
goblinRedisUtils.setUserAboutSku(user); if (userVo == null) {
//用户没有预约过 GoblinGoodAnticipateUserVo user = new GoblinGoodAnticipateUserVo();
//发送redis消息修改mysql记录用户预约 user.setUid(uid);
sqlValue.add(new Object[]{ user.setSkuId(skuId);
uid, user.setPhone(phone);
skuId, user.setState(0);
phone, //mongodb记录
state goblinRedisUtils.setUserAboutSku(user);
}); //用户没有预约过
sendRedis("goblin_goods_anticipate_user", sqlValue); //发送redis消息修改mysql记录用户预约
goblinRedisUtils.setSkuIdPeople(skuId, state); sqlValue.add(new Object[]{
//储存用户头像 uid,
userAvatar(skuId,url); skuId,
phone,
0
});
sendRedis("goblin_goods_anticipate_user", sqlValue);
goblinRedisUtils.setSkuIdPeople(skuId, 0);
//储存用户头像
userAvatar(skuId, url);
}
return ResponseDto.success();
} }
/* if (state.equals(GoblinGoodAnticipateUserVo.STATE_INVALID)&&userVo != null) { return ResponseDto.failure("该预约不存在!");
//mysql删除用户记录
sqlValue.add(new Object[]{
uid,
skuId
});
sendRedis("goblin_goods_anticipate_user_update", sqlValue);
//删除缓存 redis和mongodb
goblinRedisUtils.delUserAboutSku(skuId, uid);
goblinRedisUtils.setSkuIdPeople(skuId, state);
}*/
return ResponseDto.success();
} }
private void userAvatar(String skuId,String url) { private void userAvatar(String skuId,String url) {
......
...@@ -92,14 +92,9 @@ public class GoblinRedisUtils { ...@@ -92,14 +92,9 @@ public class GoblinRedisUtils {
public void setSkuIdPeople(String skuId,Integer state) { public void setSkuIdPeople(String skuId,Integer state) {
BigInteger num = (BigInteger) redisUtil.get(GoblinRedisConst.ANTICIPATE_PEOPLE.concat(skuId)); BigInteger num = (BigInteger) redisUtil.get(GoblinRedisConst.ANTICIPATE_PEOPLE.concat(skuId));
num = num!=null?num: BigInteger.valueOf(0); num = num!=null?num: BigInteger.valueOf(0);
if (GoblinGoodAnticipateUserVo.STATE_VALID.equals(state)){ //新预约 +1
//新预约 +1 redisUtil.set(GoblinRedisConst.ANTICIPATE_PEOPLE.concat(skuId),num.add(BigInteger.valueOf(1)));
redisUtil.set(GoblinRedisConst.ANTICIPATE_PEOPLE.concat(skuId),num.add(BigInteger.valueOf(1)));
}
if (state.equals(GoblinGoodAnticipateUserVo.STATE_INVALID)){
//取消预约 -1
redisUtil.set(GoblinRedisConst.ANTICIPATE_PEOPLE.concat(skuId),num.subtract(BigInteger.valueOf(1)));
}
} }
/** /**
......
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