就餐模式获取修改
This commit is contained in:
@@ -3,11 +3,13 @@ package com.chaozhanggui.system.cashierservice.netty;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
|
||||||
import com.chaozhanggui.system.cashierservice.netty.config.NettyChannelHandlerAdapter;
|
import com.chaozhanggui.system.cashierservice.netty.config.NettyChannelHandlerAdapter;
|
||||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
||||||
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||||
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
|
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
|
||||||
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
|
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.ShopUtils;
|
||||||
import com.chaozhanggui.system.cashierservice.util.SpringUtils;
|
import com.chaozhanggui.system.cashierservice.util.SpringUtils;
|
||||||
import io.netty.channel.ChannelFutureListener;
|
import io.netty.channel.ChannelFutureListener;
|
||||||
import io.netty.channel.ChannelHandler.Sharable;
|
import io.netty.channel.ChannelHandler.Sharable;
|
||||||
@@ -17,6 +19,7 @@ import io.netty.handler.timeout.IdleState;
|
|||||||
import io.netty.handler.timeout.IdleStateEvent;
|
import io.netty.handler.timeout.IdleStateEvent;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -51,6 +54,9 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
|
|||||||
private RabbitProducer a;
|
private RabbitProducer a;
|
||||||
//注入为空
|
//注入为空
|
||||||
public static RabbitProducer rabbitProducer;
|
public static RabbitProducer rabbitProducer;
|
||||||
|
@Autowired
|
||||||
|
private ShopUtils shopUtils;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void b() {
|
public void b() {
|
||||||
rabbitProducer = this.a;
|
rabbitProducer = this.a;
|
||||||
@@ -135,6 +141,8 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ShopEatTypeInfoDTO eatModel = shopUtils.getEatModel(tableId, shopId);
|
||||||
|
tableId = !eatModel.isOpenTakeout() ? null : tableId;
|
||||||
String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, Integer.valueOf(userId));
|
String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, Integer.valueOf(userId));
|
||||||
log.info("netty连接 接收到数据 建立连接参数 param:{}",jsonObject);
|
log.info("netty连接 接收到数据 建立连接参数 param:{}",jsonObject);
|
||||||
this.tableId=tableId;
|
this.tableId=tableId;
|
||||||
|
|||||||
@@ -178,20 +178,20 @@ public class CartService {
|
|||||||
}
|
}
|
||||||
String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, userId);
|
String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, userId);
|
||||||
TbCashierCart seatCartInfo = null;
|
TbCashierCart seatCartInfo = null;
|
||||||
// if (redisUtil.exists(tableCartKey)) {
|
if (redisUtil.exists(tableCartKey)) {
|
||||||
// array = JSON.parseArray(redisUtil.getMessage(tableCartKey));
|
array = JSON.parseArray(redisUtil.getMessage(tableCartKey));
|
||||||
// for (int i = 0; i < array.size(); i++) {
|
for (int i = 0; i < array.size(); i++) {
|
||||||
// JSONObject object = array.getJSONObject(i);
|
JSONObject object = array.getJSONObject(i);
|
||||||
// TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
|
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
|
||||||
// if (cashierCart.getNumber() > 0) {
|
if (cashierCart.getNumber() > 0) {
|
||||||
// amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if ("-999".equals(cashierCart.getProductId())) {
|
if ("-999".equals(cashierCart.getProductId())) {
|
||||||
// seatCartInfo = cashierCart;
|
seatCartInfo = cashierCart;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
// 查询购物车所有信息
|
// 查询购物车所有信息
|
||||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||||
.eq(TbCashierCart::getShopId, shopId)
|
.eq(TbCashierCart::getShopId, shopId)
|
||||||
@@ -217,7 +217,7 @@ public class CartService {
|
|||||||
}
|
}
|
||||||
redisUtil.saveMessage(tableCartKey, array.toString(), 60 * 60 * 12L);
|
redisUtil.saveMessage(tableCartKey, array.toString(), 60 * 60 * 12L);
|
||||||
}
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
redisUtil.saveMessage(RedisCst.getCurrentTableSeatCount(shopEatTypeInfoDTO.getShopInfo().getId(), tableId), JSONObject.toJSONString(seatCartInfo), 60 * 60 * 12L);
|
redisUtil.saveMessage(RedisCst.getCurrentTableSeatCount(shopEatTypeInfoDTO.getShopInfo().getId(), tableId), JSONObject.toJSONString(seatCartInfo), 60 * 60 * 12L);
|
||||||
|
|
||||||
@@ -485,7 +485,7 @@ public class CartService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
redisUtil.saveMessage(tableCartKey, jsonArray.toJSONString());
|
redisUtil.saveMessage(tableCartKey, jsonArray.toJSONString(), 60 * 60 * 12L);
|
||||||
// 餐位费
|
// 餐位费
|
||||||
// Object seatCost = jsonArray.stream().findFirst().filter(info -> "-999".equals(((TbCashierCart) info).getProductId())).orElse(null);
|
// Object seatCost = jsonArray.stream().findFirst().filter(info -> "-999".equals(((TbCashierCart) info).getProductId())).orElse(null);
|
||||||
TbCashierCart seatCost = cashierCartArrayList.stream().findFirst().filter(info -> "-999".equals(info.getProductId())).orElse(null);
|
TbCashierCart seatCost = cashierCartArrayList.stream().findFirst().filter(info -> "-999".equals(info.getProductId())).orElse(null);
|
||||||
|
|||||||
Reference in New Issue
Block a user