Merge branch 'refs/heads/1.0.1' into dev

This commit is contained in:
GYJ 2024-06-26 09:33:29 +08:00
commit b431937e49
5 changed files with 67 additions and 2 deletions

View File

@ -55,8 +55,7 @@ public class LoginFilter implements Filter {
"cashierService/product/productInfo",
"cashierService/notify/**",//登录部分接口不校验
"notify/**",
"cashierService/table/**",//回调部分接口不校验
"cashierService/pay/**"
"cashierService/table/**" //回调部分接口不校验
);
@Autowired

View File

@ -96,4 +96,22 @@ public class RabbitConfig {
public Binding bindingPrint_Register() {
return BindingBuilder.bind(queuePrint_Register()).to(printExchange_Register()).with(RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT);
}
@Bean
public DirectExchange consExchange_Register() {
return new DirectExchange(RabbitConstants.CONS_COLLECT_PUT);
}
@Bean
public Queue queuecons_Register() {
return new Queue(RabbitConstants.CONS_COLLECT_QUEUE_PUT, true); //队列持久
}
@Bean
public Binding bindingcons_Register() {
return BindingBuilder.bind(queuePrint_Register()).to(printExchange_Register()).with(RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT);
}
}

View File

@ -38,4 +38,15 @@ public interface RabbitConstants {
public static final String INTEGRAL_ROUTINGKEY_PUT = "integral_routingkey_put1";
public static final String CONS_COLLECT_PUT="cons_collect_put";
public static final String CONS_COLLECT_QUEUE_PUT = "cons_collect_queue_put";
public static final String CONS_COLLECT_ROUTINGKEY_PUT = "cons_collect_routingkey_put";
}

View File

@ -42,6 +42,17 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend(RabbitConstants.INTEGRAL_PUT, RabbitConstants.INTEGRAL_ROUTINGKEY_PUT, content, correlationId);
}
public void cons(String content){
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT, content, correlationId);
}
@Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
logger.info(" 回调id:" + correlationData);

View File

@ -7,6 +7,7 @@ import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.netty.PushToAppChannelHandlerAdapter;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
@ -54,6 +55,9 @@ public class CartService {
@Autowired
private TbSystemCouponsMapper systemCouponsMapper;
@Autowired
private RabbitProducer producer;
public void initCart(JSONObject jsonObject) {
String tableId = jsonObject.getString("tableId");
String shopId = jsonObject.getString("shopId");
@ -295,6 +299,15 @@ public class CartService {
cashierCart.setRefundNumber(0);
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(productSku.getSalePrice().add(cashierCart.getPackFee())));
cashierCartMapper.insert(cashierCart);
//修改耗材数据
JSONObject jsonObject=new JSONObject();
jsonObject.put("cartId",cashierCart.getId());
jsonObject.put("type","create");
producer.cons(jsonObject.toString());
return cashierCart;
} catch (Exception e) {
log.error("长链接错误 addCart{}", e.getMessage());
@ -583,6 +596,8 @@ public class CartService {
public void clearCart(JSONObject jsonObject) {
try {
String shopId = jsonObject.getString("shopId");
List<String> skuIds=new ArrayList<>();
if (redisUtil.exists(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId)))) {
JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
if (Objects.isNull(array) || array.isEmpty() || array.size() < 1) {
@ -590,6 +605,7 @@ public class CartService {
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(array.get(i).toString(), TbCashierCart.class);
redisUtil.secAdd(RedisCst.PRODUCT + shopId + ":" + jsonObject.getString("skuId"), cashierCart.getNumber().toString());
productSkuMapper.updateAddStockById(jsonObject.getString("skuId"), cashierCart.getNumber());
skuIds.add(cashierCart.getSkuId());
}
}
@ -602,6 +618,16 @@ public class CartService {
jsonObject1.put("type", "clearCart");
jsonObject1.put("amount", BigDecimal.ZERO);
jsonObject1.put("data", new ArrayList<>());
//修改耗材数据
JSONObject jsonObject2=new JSONObject();
jsonObject2.put("type","delete");
jsonObject2.put("skuIds",skuIds);
jsonObject2.put("shopId",shopId);
producer.cons(jsonObject2.toString());
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false);
} catch (Exception e) {
log.info("长链接错误 clearCart{}", e.getMessage());