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

# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java
This commit is contained in:
Tankaikai
2024-09-26 17:28:46 +08:00
7 changed files with 33 additions and 20 deletions

View File

@@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.controller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.entity.dto.ChoseCountDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.ChoseEatModelDTO;
@@ -41,9 +42,13 @@ public class ProductController {
@RequestHeader("id") String userId,
@RequestParam(required = false) String lat,
@RequestParam(required = false) String lng,
@RequestParam("code") String code
@RequestParam(required = false) String code,
@RequestParam(required = false) Integer shopId
) {
return productService.queryShopIdByTableCode(userId, openId, code,lat,lng);
if (shopId == null && StrUtil.isBlank(code)) {
return Result.fail("参数缺失");
}
return productService.queryShopIdByTableCode(userId, openId, code,lat,lng, shopId);
}
/**

View File

@@ -44,6 +44,7 @@ public class TbOrderDetail implements Serializable {
private Integer cartId;
private Integer placeNum;
private String useType;
private String note;
private static final long serialVersionUID = 1L;
}

View File

@@ -232,6 +232,7 @@ public class PushToAppChannelHandlerAdapter extends NettyChannelHandlerAdapter {
@Async
public void AppSendInfo(String message, String redisKey,String userId, boolean userFlag) {
log.info("netty连接 发送消息 tableId:{} userId:{} userFlag:{} message:{}",redisKey,userId,userFlag, JSONUtil.toJSONString(message));
log.info("当前已连接队列信息: {}", webSocketMap);
if (userFlag) {
if (webSocketMap.containsKey(redisKey)) {
ConcurrentHashMap<String, ChannelHandlerContext> webSockets = webSocketMap.get(redisKey);

View File

@@ -354,7 +354,7 @@ public class CartService {
}
}
redisUtil.saveMessage(tableCartKey, jsonArray.toJSONString());
redisUtil.saveMessage(tableCartKey, JSONObject.toJSONString(cashierCartArrayList));
// 餐位费
TbCashierCart seatCost = cashierCartArrayList.stream().findFirst().filter(info -> "-999".equals(info.getProductId())).orElse(null);
HashMap<String, Object> data = new HashMap<>();

View File

@@ -451,7 +451,6 @@ public class OrderService {
public Object orderDetail(Integer orderId) {
TbOrderInfo orderInfo = mpOrderInfoMapper.selectOne(new LambdaQueryWrapper<TbOrderInfo>()
.eq(TbOrderInfo::getId, orderId));

View File

@@ -207,7 +207,6 @@ public class PayService {
return Result.fail("没有对应的商户");
}
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, null);
if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) {
return Result.fail("购物车信息不存在");
@@ -218,17 +217,16 @@ public class PayService {
body.append(cashierCart.getName());
}
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId()));
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
return Result.fail("支付通道不存在");
}
if ("aliPay".equals(payType) && StrUtil.isBlank(thirdApply.getAlipaySmallAppid())) {
return Result.fail("店铺未配置支付宝小程序appId");
}
String userId = String.valueOf(TokenUtil.getUserId());
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderId);
if (ObjectUtil.isEmpty(payment) || payment == null) {
payment = new TbOrderPayment();
@@ -287,7 +285,7 @@ public class PayService {
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
orderInfo.setStatus("paying");
orderInfo.setPayOrderNo(payment.getTradeNumber());
orderInfo.setUserId(userId);
tbOrderInfoMapper.updateByPrimaryKey(orderInfo);
//清除缓存购物车数据
@@ -342,7 +340,7 @@ public class PayService {
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
orderInfo.setStatus("paying");
orderInfo.setPayOrderNo(payment.getTradeNumber());
orderInfo.setUserId(userId);
tbOrderInfoMapper.updateByPrimaryKey(orderInfo);
//清除缓存购物车数据
@@ -446,6 +444,7 @@ public class PayService {
orderInfo.setPayType("deposit");
orderInfo.setStatus("closed");
orderInfo.setPayOrderNo("deposit".concat(SnowFlakeUtil.generateOrderNo()));
orderInfo.setUserId(String.valueOf(TokenUtil.getUserId()));
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
//更新购物车状态
int cartCount = tbCashierCartMapper.updateStatusByOrderId(orderId, "final");
@@ -762,6 +761,7 @@ public class PayService {
orderInfo.setPayType("wx_lite");
orderInfo.setPayOrderNo(payment.getTradeNumber());
orderInfo.setPayAmount(orderInfo.getOrderAmount());
orderInfo.setUserId(String.valueOf(TokenUtil.getUserId()));
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
@@ -814,6 +814,7 @@ public class PayService {
orderInfo.setPayType("wx_lite");
orderInfo.setPayOrderNo(payment.getTradeNumber());
orderInfo.setPayAmount(orderInfo.getOrderAmount());
orderInfo.setUserId(String.valueOf(TokenUtil.getUserId()));
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);

View File

@@ -118,17 +118,20 @@ public class ProductService {
return orderInfoList.isEmpty() ? null : orderInfoList.get(0);
}
public Result queryShopIdByTableCode(String userId, String openId, String code, String lat, String lng) {
if (StringUtils.isBlank(code)) return Result.fail("桌码信息为空");
public Result queryShopIdByTableCode(String userId, String openId, String code, String lat, String lng, Integer shopId) {
if (StringUtils.isBlank(lat) || lat.equals("undefined")) {
lat = "34.343207";
lng = "108.939645";
}
TbShopTable tbShopTable = tbShopTableMapper.selectQRcode(code);
if (tbShopTable == null) {
return Result.fail("台桌信息不存在");
TbShopTable tbShopTable = null;
if (StrUtil.isNotBlank(code)) {
tbShopTable = tbShopTableMapper.selectQRcode(code);
if (tbShopTable == null) {
return Result.fail("台桌信息不存在");
}
}
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(tbShopTable.getShopId());
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(shopId != null ? shopId : tbShopTable.getShopId());
String distance = LocationUtils.getDistanceString(
Double.parseDouble(lng), Double.parseDouble(lat),
Double.parseDouble(shopInfo.getLng()), Double.parseDouble(shopInfo.getLat()));
@@ -137,12 +140,15 @@ public class ProductService {
// 获取当前台桌最新订单id
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(code, shopInfo.getId());
TbOrderInfo order = getCurrentOrder(shopEatTypeInfoDTO, code, shopInfo.getId());
tbShopTable.setOrderId(order == null ? null : order.getId());
tbShopTable.setChoseCount(order != null && (order.getSeatCount() != null));
concurrentMap.put("shopTableInfo", tbShopTable);
if (tbShopTable != null) {
tbShopTable.setOrderId(order == null ? null : order.getId());
tbShopTable.setChoseCount(order != null && (order.getSeatCount() != null));
}
concurrentMap.put("shopTableInfo", tbShopTable == null ? "" : tbShopTable);
concurrentMap.put("storeInfo", shopInfo);
concurrentMap.put("distance", distance);
TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, tbShopTable.getShopId().toString());
TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId != null ? shopId.toString() : tbShopTable.getShopId().toString());
try {
if (ObjectUtil.isEmpty(shopUser)) {
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
@@ -163,7 +169,7 @@ public class ProductService {
shopUser.setConsumeNumber(0);
shopUser.setLevelConsume(BigDecimal.ZERO);
shopUser.setStatus(Byte.parseByte("1"));
shopUser.setShopId(tbShopTable.getShopId().toString());
shopUser.setShopId(shopId != null ? shopId.toString() : tbShopTable.getShopId().toString());
shopUser.setUserId(userId);
shopUser.setMiniOpenId(openId);
shopUser.setCreatedAt(System.currentTimeMillis());