餐位费校验修改
This commit is contained in:
@@ -601,6 +601,8 @@ public class CartService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createOrder(JSONObject jsonObject) {
|
||||
try {
|
||||
JSONObject responseData = new JSONObject();
|
||||
|
||||
String shopId = jsonObject.getString("shopId");
|
||||
String tableId = jsonObject.getString("tableId");
|
||||
String userId = jsonObject.getString("userId");
|
||||
@@ -641,8 +643,6 @@ public class CartService {
|
||||
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
||||
.eq(TbCashierCart::getStatus, "create");
|
||||
|
||||
|
||||
|
||||
TbShopTable shopTable = null;
|
||||
// 外带模式
|
||||
if (shopEatTypeInfoDTO.isTakeout()) {
|
||||
@@ -664,16 +664,39 @@ public class CartService {
|
||||
List<TbCashierCart> cashierCartList = mpCashierCartMapper.selectList(queryWrapper);
|
||||
// 就餐人数
|
||||
ArrayList<Integer> cashierIds = new ArrayList<>();
|
||||
cashierCartList.forEach(cashierCart -> {
|
||||
cashierIds.add(cashierCart.getId());
|
||||
});
|
||||
|
||||
Integer seatNum = 0;
|
||||
BigDecimal seatCost = BigDecimal.ZERO;
|
||||
for (TbCashierCart tbCashierCart : cashierCartList) {
|
||||
cashierIds.add(tbCashierCart.getId());
|
||||
if (tbCashierCart.getId() == -999) {
|
||||
seatNum = tbCashierCart.getNumber();
|
||||
seatCost = tbCashierCart.getTotalAmount();
|
||||
}
|
||||
}
|
||||
|
||||
// 校验是否选择人数
|
||||
// 设置餐位费
|
||||
TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId);
|
||||
if (!shopEatTypeInfoDTO.isTakeout() && shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 0
|
||||
&& seatNum < 1) {
|
||||
log.info("消息推送");
|
||||
responseData.put("msg", "请选择就餐人数");
|
||||
if (shopTable.getMaxCapacity() < seatNum) {
|
||||
responseData.put("msg", "当前台桌最大人数为: " + shopTable.getMaxCapacity());
|
||||
}
|
||||
responseData.put("status", "fail");
|
||||
responseData.put("type", jsonObject.getString("type"));
|
||||
responseData.put("data", "");
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cashierIds.isEmpty()) {
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "购物车为空");
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, jsonObject.getString("userId"), true);
|
||||
responseData.put("status", "fail");
|
||||
responseData.put("msg", "购物车为空");
|
||||
responseData.put("data", new ArrayList<>());
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -689,8 +712,7 @@ public class CartService {
|
||||
|
||||
|
||||
boolean hasNewInfo = false;
|
||||
Integer seatNum = 0;
|
||||
BigDecimal seatCost = BigDecimal.ZERO;
|
||||
|
||||
//校验 库存 耗材
|
||||
for (TbCashierCart cart : cashierCartList) {
|
||||
// 设置用餐类型
|
||||
@@ -770,8 +792,7 @@ public class CartService {
|
||||
}else {
|
||||
tbProduct = null;
|
||||
saleAmount = saleAmount.add(shopEatTypeInfoDTO.getShopInfo().getTableFee());
|
||||
seatNum = cart.getNumber();
|
||||
seatCost = cart.getTotalAmount();
|
||||
|
||||
}
|
||||
|
||||
totalAmount = totalAmount.add(cart.getTotalAmount());
|
||||
@@ -839,23 +860,21 @@ public class CartService {
|
||||
TbSystemCoupons systemCoupons = systemCouponsMapper.selectByPrimaryKey(couponsId);
|
||||
if (Objects.isNull(systemCoupons) || !systemCoupons.getStatus().equals("0")) {
|
||||
log.info("开始处理订单");
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "优惠券已售空");
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", "");
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, jsonObject.getString("userId"), true);
|
||||
responseData.put("status", "fail");
|
||||
responseData.put("msg", "优惠券已售空");
|
||||
responseData.put("type", jsonObject.getString("type"));
|
||||
responseData.put("data", "");
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true);
|
||||
log.info("消息推送");
|
||||
return;
|
||||
}
|
||||
if (N.gt(systemCoupons.getCouponsAmount(), totalAmount)) {
|
||||
log.info("开始处理订单");
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "订单金额小于优惠价金额");
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", "");
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, jsonObject.getString("userId"), true);
|
||||
responseData.put("status", "fail");
|
||||
responseData.put("msg", "订单金额小于优惠价金额");
|
||||
responseData.put("type", jsonObject.getString("type"));
|
||||
responseData.put("data", "");
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true);
|
||||
log.info("消息推送");
|
||||
return;
|
||||
}
|
||||
@@ -887,33 +906,17 @@ public class CartService {
|
||||
|
||||
}
|
||||
|
||||
// 设置餐位费
|
||||
TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId);
|
||||
if (!shopEatTypeInfoDTO.isTakeout() && shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 0
|
||||
&& seatNum < 1) {
|
||||
log.info("消息推送");
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("msg", "请选择就餐人数");
|
||||
if (shopTable.getMaxCapacity() < seatNum) {
|
||||
jsonObject1.put("msg", "当前台桌最大人数为: " + shopTable.getMaxCapacity());
|
||||
}
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", "");
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, jsonObject.getString("userId"), true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (orderInfo != null) {
|
||||
log.info("订单状态:" + orderInfo.getStatus());
|
||||
if (!"unpaid".equals(orderInfo.getStatus())) {
|
||||
log.info("开始处理订单");
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "订单正在支付中,请稍后再试");
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", "");
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, jsonObject.getString("userId"), true);
|
||||
responseData.put("status", "fail");
|
||||
responseData.put("msg", "订单正在支付中,请稍后再试");
|
||||
responseData.put("type", jsonObject.getString("type"));
|
||||
responseData.put("data", "");
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true);
|
||||
log.info("消息推送");
|
||||
return;
|
||||
}
|
||||
@@ -1027,23 +1030,21 @@ public class CartService {
|
||||
|
||||
redisUtil.saveMessage(tableCartKey, array.toJSONString());
|
||||
orderInfo.setDetailList(orderDetails);
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "success");
|
||||
jsonObject1.put("msg", "成功");
|
||||
jsonObject1.put("type", jsonObject.getString("type"));
|
||||
jsonObject1.put("data", orderInfo);
|
||||
|
||||
responseData.put("status", "success");
|
||||
responseData.put("msg", "成功");
|
||||
responseData.put("type", jsonObject.getString("type"));
|
||||
responseData.put("data", orderInfo);
|
||||
redisUtil.deleteByKey(tableCartKey);
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, jsonObject.getString("userId"), true);
|
||||
JSONObject jsonObject12 = new JSONObject();
|
||||
jsonObject12.put("status", "success");
|
||||
jsonObject12.put("msg", "成功");
|
||||
jsonObject12.put("type", "order");
|
||||
jsonObject12.put("amount", BigDecimal.ZERO);
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true);
|
||||
|
||||
jsonObject12.put("data", new JSONArray());
|
||||
|
||||
responseData.put("status", "success");
|
||||
responseData.put("msg", "成功");
|
||||
responseData.put("type", "order");
|
||||
responseData.put("amount", BigDecimal.ZERO);
|
||||
responseData.put("data", new JSONArray());
|
||||
// PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject12.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false);
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject12.toString(), tableCartKey, jsonObject.getString("userId"));
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"));
|
||||
|
||||
|
||||
redisUtil.saveMessage(RedisCst.ORDER_EXPIRED.concat(orderId.toString()), orderId.toString(), 60 * 16L);
|
||||
|
||||
Reference in New Issue
Block a user