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

Commit df44b39f authored by zhengfuxin's avatar zhengfuxin

修改购物车

parent 4576f147
......@@ -24,6 +24,7 @@ public class GoblinShoppingCartVoo implements Serializable {
private String goblinShoppingCartId;
//mongodb userid
private String userId;
private Integer type;
private int shoopingCount;
......
......@@ -29,15 +29,15 @@ public class GoblinFrontLoginController {
@GetMapping("addShopCart")
@ApiOperation("加入购物车")
public ResponseDto addShopCart(@RequestParam(name = "spuId", required = true) String spuId,@RequestParam(name = "storeId", required = true) String storeId,@RequestParam(name = "skuId", required = true) String skuId,@RequestParam(name = "number", required = false) Integer number) {
public ResponseDto addShopCart(@RequestParam(name = "spuId", required = true) String spuId,@RequestParam(name = "storeId", required = true) String storeId,@RequestParam(name = "skuId", required = true) String skuId,@RequestParam(name = "number", required = false) Integer number,@RequestParam(name = "type", required = false) Integer type) {
String userId=CurrentUtil.getCurrentUid();
return ResponseDto.success( goblinFrontService.addShoopCart(spuId,storeId,skuId,number,userId));
return ResponseDto.success( goblinFrontService.addShoopCart(spuId,storeId,skuId,number,userId,type));
}
@GetMapping("updateShopCart")
@ApiOperation("修改购物车")
public ResponseDto updateShopCart(@RequestParam(name = "spuId", required = true) String spuId,@RequestParam(name = "storeId", required = true) String storeId,@RequestParam(name = "skuId", required = true) String skuId,@RequestParam(name = "number", required = false) Integer number) {
public ResponseDto updateShopCart(@RequestParam(name = "spuId", required = true) String spuId,@RequestParam(name = "storeId", required = true) String storeId,@RequestParam(name = "skuId", required = true) String skuId,@RequestParam(name = "number", required = false) Integer number,@RequestParam(name = "type", required = false) Integer type) {
String userId=CurrentUtil.getCurrentUid();
return ResponseDto.success( goblinFrontService.updateShopCart(spuId,storeId,skuId,number,userId));
return ResponseDto.success( goblinFrontService.updateShopCart(spuId,storeId,skuId,number,userId,type));
}
......@@ -49,21 +49,21 @@ public class GoblinFrontLoginController {
}
@PostMapping("deleteShopCart")
@ApiOperation("删除购物车")
public ResponseDto deleteShopCart(String skuIds) {
public ResponseDto deleteShopCart(@RequestParam(name = "skuIds", required = false) String skuIds,@RequestParam(name = "type", required = false) Integer type) {
String userId=CurrentUtil.getCurrentUid();
return ResponseDto.success(goblinFrontService.delteShoppingCart(skuIds.split(","),userId));
return ResponseDto.success(goblinFrontService.delteShoppingCart(skuIds.split(","),userId,type));
}
@PostMapping("saveData")
@ApiOperation("保存数据购物车过度")
public ResponseDto saveData(String data) {
public ResponseDto saveData(@RequestParam(name = "data", required = false)String data,@RequestParam(name = "type", required = false)Integer type) {
String userId=CurrentUtil.getCurrentUid();
return ResponseDto.success(goblinFrontService.saveDate(data,userId));
return ResponseDto.success(goblinFrontService.saveDate(data,userId,type));
}
@PostMapping("getData")
@ApiOperation("获得购物车过度")
public ResponseDto getData() {
public ResponseDto getData(@RequestParam(name = "type", required = false)Integer type) {
String userId=CurrentUtil.getCurrentUid();
return ResponseDto.success(goblinFrontService.getDate(userId));
return ResponseDto.success(goblinFrontService.getDate(userId,type));
}
......
......@@ -606,7 +606,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
* @Description:添加购物车
* @date 2022/1/11 下午4:16
*/
public boolean addShoopCart(String spuId, String storeId,String skuId,Integer number,String userId){
public boolean addShoopCart(String spuId, String storeId,String skuId,Integer number,String userId,Integer type){
if(null==number||number<=0){
return false;
}
......@@ -630,8 +630,8 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
list.add(goblinShoppingCartVo);
goblinShoppingCartVoo1.setShopList(list);
goblinShoppingCartVoo1.setGoblinShoppingCartId(IDGenerator.nextSnowId());
saveRedisMongodbMysqlShop(goblinShoppingCartVoo1,userId);
insertShopCartMysql(goblinShoppingCartVoDetail.getCarId(),spuId,storeId,skuId,1,userId);
saveRedisMongodbMysqlShop(goblinShoppingCartVoo1,userId,type);
insertShopCartMysql(goblinShoppingCartVoDetail.getCarId(),spuId,storeId,skuId,1,userId,type);
}else{
//查看是否有该商铺
List<GoblinShoppingCartVo> list=goblinShoppingCartVoo.getShopList();
......@@ -672,11 +672,11 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
goblinShoppingCartVo.setSkuList(list1);
list.add(goblinShoppingCartVo);
}
saveRedisMongodbMysqlShop(goblinShoppingCartVoo,userId);
saveRedisMongodbMysqlShop(goblinShoppingCartVoo,userId,type);
if(isGoods){
updateShopCartMysql(cardId,number,userId);
}else{
insertShopCartMysql(cardId,spuId,storeId,skuId,number,userId);
insertShopCartMysql(cardId,spuId,storeId,skuId,number,userId,type);
}
}
return true;
......@@ -686,7 +686,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
* @Description: 修改 购物车里 数量
* @date 2022/1/11 下午6:24
*/
public boolean updateShopCart(String spuId, String storeId,String skuId,Integer number,String userId){
public boolean updateShopCart(String spuId, String storeId,String skuId,Integer number,String userId,Integer type){
if(null==number||number<=0){
return false;
}
......@@ -708,7 +708,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
}
}
//调用储存方法
saveRedisMongodbMysqlShop(goblinShoppingCartVoo,userId);
saveRedisMongodbMysqlShop(goblinShoppingCartVoo,userId,type);
updateShopCartMysql(cardId,number,userId);
}
return true;
......@@ -734,20 +734,20 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
* @Description:存储信息
* @date 2022/1/17 下午4:55
*/
public boolean saveDate(String data,String userId) {
redisUtil.set(GoblinRedisConst.FRONT_SHOPCART_TWO.concat(userId),data,60*60*24);
public boolean saveDate(String data,String userId,Integer type) {
redisUtil.set(GoblinRedisConst.FRONT_SHOPCART_TWO.concat(userId).concat(type.toString()),data,60*60*24);
return true;
}
public String getDate(String userId) {
if(redisUtil.get(GoblinRedisConst.FRONT_SHOPCART_TWO.concat(userId))==null){
public String getDate(String userId,Integer type) {
if(redisUtil.get(GoblinRedisConst.FRONT_SHOPCART_TWO.concat(userId).concat(type.toString()))==null){
return "";
}
return (String) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART_TWO.concat(userId));
return (String) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART_TWO.concat(userId).concat(type.toString()));
}
/**
* 删除购物车里面的商品
*/
public boolean delteShoppingCart(String[] skuIds,String userId) {
public boolean delteShoppingCart(String[] skuIds,String userId,Integer type) {
boolean isDeleteAll = false;
GoblinShoppingCartVoo goblinShoppingCartVoo = (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId));
if (null != goblinShoppingCartVoo) {
......@@ -775,7 +775,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
deleteRedisMongodbMysqlShop(goblinShoppingCartVoo,userId,skuIds);
deleteMysql(userId,skuIds);
}else{
saveRedisMongodbMysqlShop(goblinShoppingCartVoo,userId);
saveRedisMongodbMysqlShop(goblinShoppingCartVoo,userId,type);
deleteMysql(userId,skuIds);
}
}
......@@ -827,12 +827,13 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
goblinShoppingCartVoDetail.setUpdatedAt(LocalDateTime.now());
return goblinShoppingCartVoDetail;
}
public void saveRedisMongodbMysqlShop(GoblinShoppingCartVoo goblinShoppingCartVoo,String userId){
public void saveRedisMongodbMysqlShop(GoblinShoppingCartVoo goblinShoppingCartVoo,String userId,Integer type){
goblinShoppingCartVoo.setUserId(userId);
//redis存储
redisUtil.set(GoblinRedisConst.FRONT_SHOPCART.concat(userId),goblinShoppingCartVoo);
redisUtil.set(GoblinRedisConst.FRONT_SHOPCART.concat(userId).concat(type.toString()),goblinShoppingCartVoo);
//mongodb存储
boolean exists2 =mongoTemplate.exists(Query.query(Criteria.where("goblinShoppingCartId").is(goblinShoppingCartVoo.getGoblinShoppingCartId())),GoblinShoppingCartVoo.class, GoblinShoppingCartVoo.class.getSimpleName());
goblinShoppingCartVoo.setType(type);
if(exists2){
BasicDBObject orderObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(goblinShoppingCartVoo)));
mongoTemplate.getCollection(GoblinShoppingCartVoo.class.getSimpleName()).updateOne(
......@@ -864,13 +865,13 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_SHOP_CART.getKey(), sqlDatas);
log.info("发送购物车消息队列完毕");
}
public void insertShopCartMysql(String carId ,String spuId, String storeId,String skuId,Integer number,String userId){
public void insertShopCartMysql(String carId ,String spuId, String storeId,String skuId,Integer number,String userId,Integer type){
LinkedList<String> sqls = CollectionUtil.linkedListString();
sqls.add(SqlMapping.get("goblin_shop.cart.insert"));
LinkedList<Object[]> sqlData = CollectionUtil.linkedListObjectArr();
sqlData.add(new Object[]{
//car_id, user_id, store_id,spu_id, sku_id, `number`,marketing_id, del_tag, `comment`
carId,userId,storeId,spuId,skuId,1,"",0,""
carId,userId,storeId,spuId,skuId,1,"",0,"",type
});
String sqlDatas = SqlMapping.gets(sqls, sqlData);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_SHOP_CART.getKey(), sqlDatas);
......
......@@ -89,5 +89,5 @@ goblin_order.store.applyRefund=UPDATE goblin_back_order SET status = ? ,reason=?
goblin_order.user.applyRefund=INSERT INTO goblin_back_order (`back_order_id`,`back_code`,`order_id`,`order_code`,`store_id`,`user_id`,`sku_id_nums`,`type`,`reason`,`describes`,`real_back_price`,`back_price_express`,`status`,`created_at`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)
#---- 购物车操作
goblin_shop.cart.delete = UPDATE goblin_shopping_cart set del_tag=? where user_id=? and sku_id=?
goblin_shop.cart.insert = insert into goblin_shopping_cart (car_id, user_id, store_id,spu_id, sku_id, `number`,marketing_id, del_tag, `comment`) values (?,?,?,?,?,?,?,?,?)
goblin_shop.cart.insert = insert into goblin_shopping_cart (car_id, user_id, store_id,spu_id, sku_id, `number`,marketing_id, del_tag, `comment`,`type`) values (?,?,?,?,?,?,?,?,?,?)
goblin_shop.cart.update = update goblin_shopping_cart set `number` = ? where car_id=? and user_id=? and del_tag=0
\ No newline at end of file
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