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

Commit b10c44bf authored by 张国柄's avatar 张国柄

Merge remote-tracking branch 'origin/dev_goblin' into dev_goblin

parents a81c891a 876b0c46
......@@ -341,6 +341,8 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
* @date 2022/1/11 下午4:16
*/
public boolean addShoopCart(String spuId, String storeId,String skuId,Integer number,String userId){
boolean isGoods=false;
String cardId="";
//判断该用户 redis里是否有购物车
GoblinShoppingCartVoo goblinShoppingCartVoo= (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId));
if(null==goblinShoppingCartVoo){
......@@ -360,6 +362,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
goblinShoppingCartVoo1.setShopList(list);
goblinShoppingCartVoo1.setGoblinShoppingCartId(IDGenerator.nextSnowId());
saveRedisMongodbMysqlShop(goblinShoppingCartVoo1,userId);
insertShopCartMysql(goblinShoppingCartVoDetail.getCarId(),spuId,storeId,skuId,1,userId);
}else{
//查看是否有该商铺
List<GoblinShoppingCartVo> list=goblinShoppingCartVoo.getShopList();
......@@ -369,11 +372,12 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
//有这个商铺的 东西
List<GoblinShoppingCartVoDetail> list1=goblinShoppingCartVo.getSkuList();
//查看是否有这个商品
boolean isGoods=false;
for(GoblinShoppingCartVoDetail goblinShoppingCartVoDetail:list1){
if(skuId.equals(goblinShoppingCartVoDetail.getSkuId())){
isGoods=true;
goblinShoppingCartVoDetail.setNumber((goblinShoppingCartVoDetail.getNumber()+1));
cardId=goblinShoppingCartVoDetail.getCarId();
}
}
if(isGoods){
......@@ -382,6 +386,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
}else{
//创建商品放入到list
GoblinShoppingCartVoDetail goblinShoppingCartVoDetail=this.setValue(userId,storeId,spuId,skuId,1);
cardId=goblinShoppingCartVoDetail.getCarId();
list1.add(goblinShoppingCartVoDetail);
}
isShop=true;
......@@ -399,6 +404,11 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
list.add(goblinShoppingCartVo);
}
saveRedisMongodbMysqlShop(goblinShoppingCartVoo,userId);
if(isGoods){
updateShopCartMysql(cardId,number,userId);
}else{
insertShopCartMysql(cardId,spuId,storeId,skuId,1,userId);
}
}
return true;
}
......@@ -409,6 +419,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
*/
public boolean updateShopCart(String spuId, String storeId,String skuId,Integer number,String userId){
GoblinShoppingCartVoo goblinShoppingCartVoo= (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId));
String cardId="";
if(null!=goblinShoppingCartVoo){
List<GoblinShoppingCartVo> list=goblinShoppingCartVoo.getShopList();
//遍历商铺
......@@ -418,6 +429,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
List<GoblinShoppingCartVoDetail> list1=goblinShoppingCartVo.getSkuList();
for(GoblinShoppingCartVoDetail goblinShoppingCartVoDetail:list1){
if(skuId.equals(goblinShoppingCartVoDetail.getSkuId())){
cardId=goblinShoppingCartVoDetail.getCarId();
goblinShoppingCartVoDetail.setNumber(number);
}
}
......@@ -425,6 +437,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
}
//调用储存方法
saveRedisMongodbMysqlShop(goblinShoppingCartVoo,userId);
updateShopCartMysql(cardId,number,userId);
}
return true;
}
......@@ -472,6 +485,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
}
if(shopList.size()==0){
deleteRedisMongodbMysqlShop(goblinShoppingCartVoo,userId,skuIds);
deleteMysql(userId,skuIds);
}else{
saveRedisMongodbMysqlShop(goblinShoppingCartVoo,userId);
deleteMysql(userId,skuIds);
......@@ -566,10 +580,26 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
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, created_at,updated_at, `comment`)
carId,userId,storeId,spuId,skuId,1,"",0,
//car_id, user_id, store_id,spu_id, sku_id, `number`,marketing_id, del_tag, `comment`
carId,userId,storeId,spuId,skuId,1,"",0,""
});
String sqlDatas = SqlMapping.gets(sqls, sqlData);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_SHOP_CART.getKey(), sqlDatas);
log.info("发送购物车消息队列完毕");
}
public void updateShopCartMysql(String carId ,Integer number,String userId){
LinkedList<String> sqls = CollectionUtil.linkedListString();
sqls.add(SqlMapping.get("goblin_shop.cart.update"));
LinkedList<Object[]> sqlData = CollectionUtil.linkedListObjectArr();
sqlData.add(new Object[]{
//update goblin_shopping_cart set `number` = ? where car_id=? and user_id=?
number,carId,userId
});
String sqlDatas = SqlMapping.gets(sqls, sqlData);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_SHOP_CART.getKey(), sqlDatas);
log.info("发送购物车消息队列完毕");
}
//删除
public void deleteMysql(String userId,String[] skuIds){
//mysql 删除 按照 userid 、skuid
......@@ -578,10 +608,11 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
LinkedList<Object[]> sqlData = CollectionUtil.linkedListObjectArr();
for(String sku:skuIds){
sqlData.add(new Object[]{
userId,sku,0
1,userId,sku
});
}
String sqlDatas = SqlMapping.gets(sqls, sqlData);
log.info(sqlDatas);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_SHOP_CART.getKey(), sqlDatas);
log.info("发送购物车消息队列完毕");
}
......
......@@ -10,9 +10,9 @@ spring:
cloud:
config:
# uri: http://127.0.0.1:7002/support-config
# uri: http://39.107.71.112:7002/support-config
profile: ${liquidnet.cloudConfig.profile}
name: ${spring.application.name} #默认为spring.application.name
discovery:
enabled: true
service-id: liquidnet-support-config
\ No newline at end of file
uri: http://39.107.71.112:7002/support-config
# profile: ${liquidnet.cloudConfig.profile}
# name: ${spring.application.name} #默认为spring.application.name
# discovery:ß
# enabled: true
# service-id: liquidnet-support-config
\ No newline at end of file
......@@ -64,5 +64,6 @@ goblin_order.store.refundPrice=UPDATE goblin_store_order SET price_refund = ? ,s
goblin_order.store.refundSkuPrice=UPDATE goblin_order_sku SET price_refund = ? ,status = ? , updated_at = ? WHERE order_sku_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
goblin_order.store.refundBackOrder=UPDATE goblin_back_order SET status = ? , updated_at = ? WHERE back_order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
#---- 购物车操作
goblin_shop.cart.delete = UPDATE goblin_shopping_cart set user_id=? and sku_id=? and del_tag=?
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 (?,?,?,?,?,?,?,?,?)
\ No newline at end of file
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.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