1.代客下单 会员支付,台桌状态问题
This commit is contained in:
@@ -153,6 +153,8 @@ public class TbCashierCart implements Serializable {
|
|||||||
@Column(name = "`uuid`")
|
@Column(name = "`uuid`")
|
||||||
@ApiModelProperty(value = "uuid")
|
@ApiModelProperty(value = "uuid")
|
||||||
private String uuid;
|
private String uuid;
|
||||||
|
@Column(name = "`sku_name`")
|
||||||
|
private String skuName;
|
||||||
|
|
||||||
public void copy(TbCashierCart source){
|
public void copy(TbCashierCart source){
|
||||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
package cn.ysk.cashier.service;
|
package cn.ysk.cashier.service;
|
||||||
|
|
||||||
import cn.ysk.cashier.dto.ScanPayDTO;
|
import cn.ysk.cashier.dto.ScanPayDTO;
|
||||||
|
import cn.ysk.cashier.dto.shoptable.PayDTO;
|
||||||
|
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
public interface TbPayService {
|
public interface TbPayService {
|
||||||
void scanPay(ScanPayDTO scanPayDTO);
|
void scanPay(ScanPayDTO scanPayDTO);
|
||||||
|
|
||||||
void vipPay(@NotNull Integer shopId, @NotNull Integer orderId);
|
TbOrderInfo vipPay(@NotNull Integer shopId, @NotNull Integer orderId);
|
||||||
|
|
||||||
|
TbOrderInfo cashPay(PayDTO payDTO);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package cn.ysk.cashier.service.impl;
|
|||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.ysk.cashier.dto.ScanPayDTO;
|
import cn.ysk.cashier.dto.ScanPayDTO;
|
||||||
|
import cn.ysk.cashier.dto.shoptable.PayDTO;
|
||||||
|
import cn.ysk.cashier.enums.TableStateEnum;
|
||||||
import cn.ysk.cashier.exception.BadRequestException;
|
import cn.ysk.cashier.exception.BadRequestException;
|
||||||
import cn.ysk.cashier.mybatis.entity.TbShopUser;
|
import cn.ysk.cashier.mybatis.entity.TbShopUser;
|
||||||
import cn.ysk.cashier.mybatis.entity.TbOrderPayment;
|
import cn.ysk.cashier.mybatis.entity.TbOrderPayment;
|
||||||
@@ -14,6 +16,7 @@ import cn.ysk.cashier.pojo.order.TbCashierCart;
|
|||||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||||
import cn.ysk.cashier.pojo.shop.TbMerchantThirdApply;
|
import cn.ysk.cashier.pojo.shop.TbMerchantThirdApply;
|
||||||
|
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||||
import cn.ysk.cashier.repository.shop.TbMerchantThirdApplyRepository;
|
import cn.ysk.cashier.repository.shop.TbMerchantThirdApplyRepository;
|
||||||
import cn.ysk.cashier.service.TbPayService;
|
import cn.ysk.cashier.service.TbPayService;
|
||||||
import cn.ysk.cashier.utils.RabbitMsgUtils;
|
import cn.ysk.cashier.utils.RabbitMsgUtils;
|
||||||
@@ -50,9 +53,11 @@ public class TbPayServiceImpl implements TbPayService {
|
|||||||
private final TbOrderDetailMapper orderDetailMapper;
|
private final TbOrderDetailMapper orderDetailMapper;
|
||||||
private final RabbitTemplate rabbitTemplate;
|
private final RabbitTemplate rabbitTemplate;
|
||||||
private final RabbitMsgUtils rabbitMsgUtils;
|
private final RabbitMsgUtils rabbitMsgUtils;
|
||||||
|
private final MpShopTableMapper mpShopTableMapper;
|
||||||
|
|
||||||
|
|
||||||
public TbPayServiceImpl(TbOrderInfoMapper orderInfoMapper, TbCashierCartMapper cashierCartMapper, TbMerchantThirdApplyRepository merchantThirdApplyRepository, TbOrderPaymentService orderPaymentService, TbShopPayTypeMapper shopPayTypeMapper, TbOrderDetailMapper orderDetailMapper, RabbitTemplate rabbitTemplate, RabbitMsgUtils rabbitMsgUtils, TbMShopUserMapper shopUserMapper, TbShopUserFlowMapper shopUserFlowMapper) {
|
|
||||||
|
public TbPayServiceImpl(TbOrderInfoMapper orderInfoMapper, TbCashierCartMapper cashierCartMapper, TbMerchantThirdApplyRepository merchantThirdApplyRepository, TbOrderPaymentService orderPaymentService, TbShopPayTypeMapper shopPayTypeMapper, TbOrderDetailMapper orderDetailMapper, RabbitTemplate rabbitTemplate, RabbitMsgUtils rabbitMsgUtils, MpShopTableMapper mpShopTableMapper, TbMShopUserMapper shopUserMapper, TbShopUserFlowMapper shopUserFlowMapper) {
|
||||||
this.orderInfoMapper = orderInfoMapper;
|
this.orderInfoMapper = orderInfoMapper;
|
||||||
this.cashierCartMapper = cashierCartMapper;
|
this.cashierCartMapper = cashierCartMapper;
|
||||||
this.merchantThirdApplyRepository = merchantThirdApplyRepository;
|
this.merchantThirdApplyRepository = merchantThirdApplyRepository;
|
||||||
@@ -61,6 +66,7 @@ public class TbPayServiceImpl implements TbPayService {
|
|||||||
this.orderDetailMapper = orderDetailMapper;
|
this.orderDetailMapper = orderDetailMapper;
|
||||||
this.rabbitTemplate = rabbitTemplate;
|
this.rabbitTemplate = rabbitTemplate;
|
||||||
this.rabbitMsgUtils = rabbitMsgUtils;
|
this.rabbitMsgUtils = rabbitMsgUtils;
|
||||||
|
this.mpShopTableMapper = mpShopTableMapper;
|
||||||
this.shopUserMapper = shopUserMapper;
|
this.shopUserMapper = shopUserMapper;
|
||||||
this.shopUserFlowMapper = shopUserFlowMapper;
|
this.shopUserFlowMapper = shopUserFlowMapper;
|
||||||
}
|
}
|
||||||
@@ -291,7 +297,7 @@ public class TbPayServiceImpl implements TbPayService {
|
|||||||
private final TbShopUserFlowMapper shopUserFlowMapper;
|
private final TbShopUserFlowMapper shopUserFlowMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void vipPay(@NotNull Integer shopId, @NotNull Integer orderId) {
|
public TbOrderInfo vipPay(@NotNull Integer shopId, @NotNull Integer orderId) {
|
||||||
|
|
||||||
TbOrderInfo orderInfo = orderInfoMapper.selectById(orderId);
|
TbOrderInfo orderInfo = orderInfoMapper.selectById(orderId);
|
||||||
|
|
||||||
@@ -341,20 +347,49 @@ public class TbPayServiceImpl implements TbPayService {
|
|||||||
orderDetailMapper.update(null, new LambdaUpdateWrapper<TbOrderDetail>()
|
orderDetailMapper.update(null, new LambdaUpdateWrapper<TbOrderDetail>()
|
||||||
.eq(TbOrderDetail::getOrderId, orderId)
|
.eq(TbOrderDetail::getOrderId, orderId)
|
||||||
.set(TbOrderDetail::getStatus, "closed"));
|
.set(TbOrderDetail::getStatus, "closed"));
|
||||||
log.info("更新购物车:{}", cartCount);
|
return orderInfo;
|
||||||
|
}
|
||||||
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
@Override
|
||||||
jsonObject.put("token", null);
|
public TbOrderInfo cashPay(PayDTO payDTO) {
|
||||||
jsonObject.put("type", "create");
|
TbOrderInfo orderInfo = orderInfoMapper.selectOne(new LambdaUpdateWrapper<TbOrderInfo>()
|
||||||
jsonObject.put("orderId", orderId);
|
.eq(TbOrderInfo::getId, payDTO.getOrderId())
|
||||||
|
.eq(TbOrderInfo::getShopId, payDTO.getShopId()));
|
||||||
|
|
||||||
rabbitMsgUtils.sendOrderCollectMsg(jsonObject);
|
if (orderInfo == null) {
|
||||||
rabbitMsgUtils.printTicket(String.valueOf(orderId));
|
throw new BadRequestException("订单信息不存在");
|
||||||
|
}
|
||||||
|
|
||||||
// 发送库存记录mq消息
|
if (!"unpaid".equals(orderInfo.getStatus())) {
|
||||||
JSONObject mqData = new JSONObject();
|
throw new BadRequestException("此订单不处于未支付状态");
|
||||||
mqData.put("orderId", orderId);
|
}
|
||||||
mqData.put("type", "pc");
|
|
||||||
rabbitMsgUtils.sendStockMsg(mqData);
|
|
||||||
|
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||||
|
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
|
||||||
|
.set(TbShopTable::getStatus, TableStateEnum.PAYING.getState()));
|
||||||
|
// int count = shopInfoRepository.countSelectByShopIdAndPayType(orderInfo.getShopId(), "cash");
|
||||||
|
// if (count < 1) {
|
||||||
|
// return Result.fail(CodeEnum.PAYTYPENOEXIST);
|
||||||
|
// }
|
||||||
|
|
||||||
|
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||||
|
orderInfo.setPayType("cash");
|
||||||
|
orderInfo.setStatus("closed");
|
||||||
|
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
||||||
|
orderInfoMapper.updateById(orderInfo);
|
||||||
|
|
||||||
|
//更新购物车状态
|
||||||
|
TbCashierCart cashierCart = new TbCashierCart();
|
||||||
|
cashierCart.setStatus("final");
|
||||||
|
int cartCount = cashierCartMapper.update(cashierCart, new LambdaUpdateWrapper<TbCashierCart>()
|
||||||
|
.eq(TbCashierCart::getOrderId, payDTO.getOrderId()));
|
||||||
|
|
||||||
|
TbOrderDetail orderDetail = new TbOrderDetail();
|
||||||
|
orderDetail.setStatus("closed");
|
||||||
|
orderDetailMapper.update(orderDetail, new LambdaUpdateWrapper<TbOrderDetail>()
|
||||||
|
.eq(TbOrderDetail::getOrderId, payDTO.getOrderId()));
|
||||||
|
|
||||||
|
return orderInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -349,6 +349,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
tbCashierCart.setIsGift(String.valueOf(addCartDTO.isGift()));
|
tbCashierCart.setIsGift(String.valueOf(addCartDTO.isGift()));
|
||||||
tbCashierCart.setSalePrice(productSku.getSalePrice());
|
tbCashierCart.setSalePrice(productSku.getSalePrice());
|
||||||
tbCashierCart.setTotalAmount(new BigDecimal(addCartDTO.getNum()).multiply(productSku.getSalePrice()));
|
tbCashierCart.setTotalAmount(new BigDecimal(addCartDTO.getNum()).multiply(productSku.getSalePrice()));
|
||||||
|
tbCashierCart.setSkuName(productSku.getSpecSnap());
|
||||||
if (!addCartDTO.isPack()) {
|
if (!addCartDTO.isPack()) {
|
||||||
tbCashierCart.setPackFee(BigDecimal.ZERO);
|
tbCashierCart.setPackFee(BigDecimal.ZERO);
|
||||||
} else {
|
} else {
|
||||||
@@ -1022,60 +1023,26 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
@Override
|
@Override
|
||||||
public Object pay(PayDTO payDTO) {
|
public Object pay(PayDTO payDTO) {
|
||||||
|
|
||||||
|
TbOrderInfo orderInfo = null;
|
||||||
switch (payDTO.getPayType()) {
|
switch (payDTO.getPayType()) {
|
||||||
case "vipPay":
|
case "vipPay":
|
||||||
tbPayServiceImpl.vipPay(payDTO.getShopId(), payDTO.getOrderId());
|
orderInfo = tbPayServiceImpl.vipPay(payDTO.getShopId(), payDTO.getOrderId());
|
||||||
return null;
|
break;
|
||||||
|
case "cashPay":
|
||||||
|
orderInfo = tbPayServiceImpl.cashPay(payDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
TbOrderInfo orderInfo = orderInfoMapper.selectOne(new LambdaUpdateWrapper<TbOrderInfo>()
|
log.info("更新购物车");
|
||||||
.eq(TbOrderInfo::getId, payDTO.getOrderId())
|
|
||||||
.eq(TbOrderInfo::getShopId, payDTO.getShopId()));
|
|
||||||
|
|
||||||
if (orderInfo == null) {
|
|
||||||
throw new BadRequestException("订单信息不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!"unpaid".equals(orderInfo.getStatus())) {
|
|
||||||
return new BadRequestException("此订单不处于未支付状态");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
|
||||||
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
|
|
||||||
.set(TbShopTable::getStatus, TableStateEnum.PAYING.getState()));
|
|
||||||
// int count = shopInfoRepository.countSelectByShopIdAndPayType(orderInfo.getShopId(), "cash");
|
|
||||||
// if (count < 1) {
|
|
||||||
// return Result.fail(CodeEnum.PAYTYPENOEXIST);
|
|
||||||
// }
|
|
||||||
|
|
||||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
|
||||||
orderInfo.setPayType("cash");
|
|
||||||
orderInfo.setStatus("closed");
|
|
||||||
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
|
||||||
orderInfoMapper.updateById(orderInfo);
|
|
||||||
|
|
||||||
//更新购物车状态
|
|
||||||
TbCashierCart cashierCart = new TbCashierCart();
|
|
||||||
cashierCart.setStatus("final");
|
|
||||||
int cartCount = cashierCartMapper.update(cashierCart, new LambdaUpdateWrapper<TbCashierCart>()
|
|
||||||
.eq(TbCashierCart::getOrderId, payDTO.getOrderId()));
|
|
||||||
|
|
||||||
TbOrderDetail orderDetail = new TbOrderDetail();
|
|
||||||
orderDetail.setStatus("closed");
|
|
||||||
orderDetailMapper.update(orderDetail, new LambdaUpdateWrapper<TbOrderDetail>()
|
|
||||||
.eq(TbOrderDetail::getOrderId, payDTO.getOrderId()));
|
|
||||||
|
|
||||||
log.info("更新购物车:{}", cartCount);
|
|
||||||
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("token", null);
|
||||||
jsonObject.put("type", "create");
|
jsonObject.put("type", "create");
|
||||||
jsonObject.put("orderId", payDTO.getOrderId());
|
jsonObject.put("orderId", orderInfo.getId());
|
||||||
rabbitTemplate.convertAndSend(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, jsonObject.toJSONString(), new CorrelationData(UUID.randomUUID().toString()));
|
|
||||||
|
|
||||||
// 打印消息
|
// 打印消息
|
||||||
|
rabbitMsgUtils.sendOrderCollectMsg(jsonObject);
|
||||||
if (StrUtil.isBlank(orderInfo.getUseType()) || orderInfo.getUseType().equals("afterPay")) {
|
if (StrUtil.isBlank(orderInfo.getUseType()) || orderInfo.getUseType().equals("afterPay")) {
|
||||||
rabbitTemplate.convertAndSend(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, payDTO.getOrderId().toString(), new CorrelationData(UUID.randomUUID().toString()));
|
rabbitMsgUtils.printTicket(String.valueOf(orderInfo.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送库存记录mq消息
|
// 发送库存记录mq消息
|
||||||
|
|||||||
Reference in New Issue
Block a user