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

Commit db8a1120 authored by zhengfuxin's avatar zhengfuxin

修改购物车

parent 7c6b08a0
......@@ -43,9 +43,9 @@ public class GoblinFrontLoginController {
@GetMapping("getShopCartCount")
@ApiOperation("获取购物车数量")
public ResponseDto getShopCartCount() {
public ResponseDto getShopCartCount(@RequestParam(name = "type", required = false)Integer type) {
String userId=CurrentUtil.getCurrentUid();
return ResponseDto.success(goblinFrontService.getShopCartCount(userId));
return ResponseDto.success(goblinFrontService.getShopCartCount(userId,type));
}
@PostMapping("deleteShopCart")
@ApiOperation("删除购物车")
......@@ -69,9 +69,9 @@ public class GoblinFrontLoginController {
@GetMapping("getShopCart")
@ApiOperation("获得购物车列表")
public ResponseDto<GoblinShoppingCartVoo> getShopCart() {
public ResponseDto<GoblinShoppingCartVoo> getShopCart(@RequestParam(name = "type", required = false)Integer type) {
String userId=CurrentUtil.getCurrentUid();
return ResponseDto.success(goblinFrontService.getShoppCart(userId));
return ResponseDto.success(goblinFrontService.getShoppCart(userId,type));
}
......
......@@ -714,10 +714,10 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
return true;
}
public int getShopCartCount(String userId){
public int getShopCartCount(String userId,Integer type){
log.info("获取商品数量{}",userId);
int count=0;
GoblinShoppingCartVoo goblinShoppingCartVoo= (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId));
GoblinShoppingCartVoo goblinShoppingCartVoo= (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId).concat(type.toString()));
if(null!=goblinShoppingCartVoo){
List<GoblinShoppingCartVo> shopList=goblinShoppingCartVoo.getShopList();
for(GoblinShoppingCartVo goblinShoppingCartVo:shopList){
......@@ -772,7 +772,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
}
}
if(shopList.size()==0){
deleteRedisMongodbMysqlShop(goblinShoppingCartVoo,userId,skuIds);
deleteRedisMongodbMysqlShop(goblinShoppingCartVoo,userId,skuIds,type);
deleteMysql(userId,skuIds);
}else{
saveRedisMongodbMysqlShop(goblinShoppingCartVoo,userId,type);
......@@ -794,9 +794,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
* @Description: 获得购物车列表
* @date 2022/1/12 下午2:36
*/
public GoblinShoppingCartVoo getShoppCart(String userId){
public GoblinShoppingCartVoo getShoppCart(String userId,Integer type){
//判断该用户 redis里是否有购物车
GoblinShoppingCartVoo goblinShoppingCartVoo= (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId));
GoblinShoppingCartVoo goblinShoppingCartVoo= (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId).concat(type.toString()));
if(null==goblinShoppingCartVoo){
return null;
}
......@@ -811,7 +811,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
goblinShoppingCartVoDetail.setGoblinGoodsSkuInfoVo(goblinGoodsSkuInfoVo);
}
}
goblinShoppingCartVoo.setShoopingCount(this.getShopCartCount(userId));
goblinShoppingCartVoo.setShoopingCount(this.getShopCartCount(userId,type));
return goblinShoppingCartVoo;
}
public GoblinShoppingCartVoDetail setValue(String userId,String storeId,String spuId,String skuId,Integer number){
......@@ -846,9 +846,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
//mysql 消息队列
}
//删除redis 删除mongodb
public void deleteRedisMongodbMysqlShop(GoblinShoppingCartVoo goblinShoppingCartVoo,String userId,String[] skuIds){
public void deleteRedisMongodbMysqlShop(GoblinShoppingCartVoo goblinShoppingCartVoo,String userId,String[] skuIds,Integer type){
//redis存储
redisUtil.del(GoblinRedisConst.FRONT_SHOPCART.concat(userId));
redisUtil.del(GoblinRedisConst.FRONT_SHOPCART.concat(userId).concat(type.toString()));
//mongodb 删除
mongoTemplate.remove(Query.query(Criteria.where("goblinShoppingCartId").is(goblinShoppingCartVoo.getGoblinShoppingCartId())), GoblinShoppingCartVoo.class, GoblinShoppingCartVoo.class.getSimpleName());
//mysql 删除 按照 userid 、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