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