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

Commit 9921fd14 authored by zhengfuxin's avatar zhengfuxin

修改购物车

parent 8d61cd38
...@@ -24,7 +24,7 @@ public class GoblinShoppingCartVoo implements Serializable { ...@@ -24,7 +24,7 @@ public class GoblinShoppingCartVoo implements Serializable {
private String goblinShoppingCartId; private String goblinShoppingCartId;
//mongodb userid //mongodb userid
private String userId; private String userId;
private Integer type; private String type;
private int shoopingCount; private int shoopingCount;
......
...@@ -29,13 +29,13 @@ public class GoblinFrontLoginController { ...@@ -29,13 +29,13 @@ public class GoblinFrontLoginController {
@GetMapping("addShopCart") @GetMapping("addShopCart")
@ApiOperation("加入购物车") @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,@RequestParam(name = "type", required = true) Integer type) { 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 = true) String type) {
String userId=CurrentUtil.getCurrentUid(); String userId=CurrentUtil.getCurrentUid();
return ResponseDto.success( goblinFrontService.addShoopCart(spuId,storeId,skuId,number,userId,type)); return ResponseDto.success( goblinFrontService.addShoopCart(spuId,storeId,skuId,number,userId,type));
} }
@GetMapping("updateShopCart") @GetMapping("updateShopCart")
@ApiOperation("修改购物车") @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,@RequestParam(name = "type", required = true) Integer type) { 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 = true) String type) {
String userId=CurrentUtil.getCurrentUid(); String userId=CurrentUtil.getCurrentUid();
return ResponseDto.success( goblinFrontService.updateShopCart(spuId,storeId,skuId,number,userId,type)); return ResponseDto.success( goblinFrontService.updateShopCart(spuId,storeId,skuId,number,userId,type));
} }
...@@ -43,25 +43,25 @@ public class GoblinFrontLoginController { ...@@ -43,25 +43,25 @@ public class GoblinFrontLoginController {
@GetMapping("getShopCartCount") @GetMapping("getShopCartCount")
@ApiOperation("获取购物车数量") @ApiOperation("获取购物车数量")
public ResponseDto getShopCartCount(@RequestParam(name = "type", required = true)Integer type) { public ResponseDto getShopCartCount(@RequestParam(name = "type", required = true)String type) {
String userId=CurrentUtil.getCurrentUid(); String userId=CurrentUtil.getCurrentUid();
return ResponseDto.success(goblinFrontService.getShopCartCount(userId,type)); return ResponseDto.success(goblinFrontService.getShopCartCount(userId,type));
} }
@PostMapping("deleteShopCart") @PostMapping("deleteShopCart")
@ApiOperation("删除购物车") @ApiOperation("删除购物车")
public ResponseDto deleteShopCart(@RequestParam(name = "skuIds", required = false) String skuIds,@RequestParam(name = "type", required = true) Integer type) { public ResponseDto deleteShopCart(@RequestParam(name = "skuIds", required = false) String skuIds,@RequestParam(name = "type", required = true) String type) {
String userId=CurrentUtil.getCurrentUid(); String userId=CurrentUtil.getCurrentUid();
return ResponseDto.success(goblinFrontService.delteShoppingCart(skuIds.split(","),userId,type)); return ResponseDto.success(goblinFrontService.delteShoppingCart(skuIds.split(","),userId,type));
} }
@PostMapping("saveData") @PostMapping("saveData")
@ApiOperation("保存数据购物车过度") @ApiOperation("保存数据购物车过度")
public ResponseDto saveData(@RequestParam(name = "data", required = false)String data,@RequestParam(name = "type", required = true)Integer type) { public ResponseDto saveData(@RequestParam(name = "data", required = false)String data,@RequestParam(name = "type", required = true)String type) {
String userId=CurrentUtil.getCurrentUid(); String userId=CurrentUtil.getCurrentUid();
return ResponseDto.success(goblinFrontService.saveDate(data,userId,type)); return ResponseDto.success(goblinFrontService.saveDate(data,userId,type));
} }
@PostMapping("getData") @PostMapping("getData")
@ApiOperation("获得购物车过度") @ApiOperation("获得购物车过度")
public ResponseDto getData(@RequestParam(name = "type", required = true)Integer type) { public ResponseDto getData(@RequestParam(name = "type", required = true)String type) {
String userId=CurrentUtil.getCurrentUid(); String userId=CurrentUtil.getCurrentUid();
return ResponseDto.success(goblinFrontService.getDate(userId,type)); return ResponseDto.success(goblinFrontService.getDate(userId,type));
} }
...@@ -69,7 +69,7 @@ public class GoblinFrontLoginController { ...@@ -69,7 +69,7 @@ public class GoblinFrontLoginController {
@GetMapping("getShopCart") @GetMapping("getShopCart")
@ApiOperation("获得购物车列表") @ApiOperation("获得购物车列表")
public ResponseDto<GoblinShoppingCartVoo> getShopCart(@RequestParam(name = "type", required = true)Integer type) { public ResponseDto<GoblinShoppingCartVoo> getShopCart(@RequestParam(name = "type", required = true)String type) {
String userId=CurrentUtil.getCurrentUid(); String userId=CurrentUtil.getCurrentUid();
return ResponseDto.success(goblinFrontService.getShoppCart(userId,type)); return ResponseDto.success(goblinFrontService.getShoppCart(userId,type));
} }
......
...@@ -794,7 +794,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -794,7 +794,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
* @Description:添加购物车 * @Description:添加购物车
* @date 2022/1/11 下午4:16 * @date 2022/1/11 下午4:16
*/ */
public boolean addShoopCart(String spuId, String storeId,String skuId,Integer number,String userId,Integer type){ public boolean addShoopCart(String spuId, String storeId,String skuId,Integer number,String userId,String type){
if(null==number||number<=0){ if(null==number||number<=0){
return false; return false;
} }
...@@ -874,7 +874,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -874,7 +874,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
* @Description: 修改 购物车里 数量 * @Description: 修改 购物车里 数量
* @date 2022/1/11 下午6:24 * @date 2022/1/11 下午6:24
*/ */
public boolean updateShopCart(String spuId, String storeId,String skuId,Integer number,String userId,Integer type){ public boolean updateShopCart(String spuId, String storeId,String skuId,Integer number,String userId,String type){
if(null==number||number<=0){ if(null==number||number<=0){
return false; return false;
} }
...@@ -902,7 +902,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -902,7 +902,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
return true; return true;
} }
public int getShopCartCount(String userId,Integer type){ public int getShopCartCount(String userId,String type){
log.info("获取商品数量{}",userId); log.info("获取商品数量{}",userId);
int count=0; int count=0;
GoblinShoppingCartVoo goblinShoppingCartVoo= (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId).concat(type.toString())); GoblinShoppingCartVoo goblinShoppingCartVoo= (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId).concat(type.toString()));
...@@ -922,11 +922,11 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -922,11 +922,11 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
* @Description:存储信息 * @Description:存储信息
* @date 2022/1/17 下午4:55 * @date 2022/1/17 下午4:55
*/ */
public boolean saveDate(String data,String userId,Integer type) { public boolean saveDate(String data,String userId,String type) {
redisUtil.set(GoblinRedisConst.FRONT_SHOPCART_TWO.concat(userId).concat(type.toString()),data,60*60*24); redisUtil.set(GoblinRedisConst.FRONT_SHOPCART_TWO.concat(userId).concat(type.toString()),data,60*60*24);
return true; return true;
} }
public String getDate(String userId,Integer type) { public String getDate(String userId,String type) {
if(redisUtil.get(GoblinRedisConst.FRONT_SHOPCART_TWO.concat(userId).concat(type.toString()))==null){ if(redisUtil.get(GoblinRedisConst.FRONT_SHOPCART_TWO.concat(userId).concat(type.toString()))==null){
return ""; return "";
} }
...@@ -935,7 +935,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -935,7 +935,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
/** /**
* 删除购物车里面的商品 * 删除购物车里面的商品
*/ */
public boolean delteShoppingCart(String[] skuIds,String userId,Integer type) { public boolean delteShoppingCart(String[] skuIds,String userId,String type) {
boolean isDeleteAll = false; boolean isDeleteAll = false;
GoblinShoppingCartVoo goblinShoppingCartVoo = (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId)); GoblinShoppingCartVoo goblinShoppingCartVoo = (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId));
if (null != goblinShoppingCartVoo) { if (null != goblinShoppingCartVoo) {
...@@ -981,7 +981,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -981,7 +981,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
* @Description: 获得购物车列表 * @Description: 获得购物车列表
* @date 2022/1/12 下午2:36 * @date 2022/1/12 下午2:36
*/ */
public GoblinShoppingCartVoo getShoppCart(String userId,Integer type){ public GoblinShoppingCartVoo getShoppCart(String userId,String type){
//判断该用户 redis里是否有购物车 //判断该用户 redis里是否有购物车
GoblinShoppingCartVoo goblinShoppingCartVoo= (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId).concat(type.toString())); GoblinShoppingCartVoo goblinShoppingCartVoo= (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId).concat(type.toString()));
if(null==goblinShoppingCartVoo){ if(null==goblinShoppingCartVoo){
...@@ -1014,7 +1014,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -1014,7 +1014,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
goblinShoppingCartVoDetail.setUpdatedAt(LocalDateTime.now()); goblinShoppingCartVoDetail.setUpdatedAt(LocalDateTime.now());
return goblinShoppingCartVoDetail; return goblinShoppingCartVoDetail;
} }
public void saveRedisMongodbMysqlShop(GoblinShoppingCartVoo goblinShoppingCartVoo,String userId,Integer type){ public void saveRedisMongodbMysqlShop(GoblinShoppingCartVoo goblinShoppingCartVoo,String userId,String type){
goblinShoppingCartVoo.setUserId(userId); goblinShoppingCartVoo.setUserId(userId);
//redis存储 //redis存储
redisUtil.set(GoblinRedisConst.FRONT_SHOPCART.concat(userId).concat(type.toString()),goblinShoppingCartVoo); redisUtil.set(GoblinRedisConst.FRONT_SHOPCART.concat(userId).concat(type.toString()),goblinShoppingCartVoo);
...@@ -1033,7 +1033,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -1033,7 +1033,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
//mysql 消息队列 //mysql 消息队列
} }
//删除redis 删除mongodb //删除redis 删除mongodb
public void deleteRedisMongodbMysqlShop(GoblinShoppingCartVoo goblinShoppingCartVoo,String userId,String[] skuIds,Integer type){ public void deleteRedisMongodbMysqlShop(GoblinShoppingCartVoo goblinShoppingCartVoo,String userId,String[] skuIds,String type){
//redis存储 //redis存储
redisUtil.del(GoblinRedisConst.FRONT_SHOPCART.concat(userId).concat(type.toString())); redisUtil.del(GoblinRedisConst.FRONT_SHOPCART.concat(userId).concat(type.toString()));
//mongodb 删除 //mongodb 删除
...@@ -1051,7 +1051,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -1051,7 +1051,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
log.debug("sql信息{}",sqlDatas); log.debug("sql信息{}",sqlDatas);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_SHOP_CART.getKey(), sqlDatas); queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_SHOP_CART.getKey(), sqlDatas);
} }
public void insertShopCartMysql(String carId ,String spuId, String storeId,String skuId,Integer number,String userId,Integer type){ public void insertShopCartMysql(String carId ,String spuId, String storeId,String skuId,Integer number,String userId,String type){
LinkedList<String> sqls = CollectionUtil.linkedListString(); LinkedList<String> sqls = CollectionUtil.linkedListString();
sqls.add(SqlMapping.get("goblin_shop.cart.insert")); sqls.add(SqlMapping.get("goblin_shop.cart.insert"));
LinkedList<Object[]> sqlData = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> sqlData = CollectionUtil.linkedListObjectArr();
......
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