package com.ruoyi.bst.order.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.bst.order.domain.dto.OrderRidePaySuccessDTO;
import com.ruoyi.bst.order.domain.enums.OrderPayType;
import com.ruoyi.bst.order.service.OrderService;
import com.ruoyi.bst.pay.domain.PayVO;
import com.ruoyi.bst.pay.interfaces.PayHandler;

@Service
public class OrderRidePayHandlerImpl implements PayHandler {

    @Autowired
    private OrderService orderService;

    @Override
    public boolean onPaySuccess(PayVO pay) {

        // 处理骑行费支付成功
        OrderRidePaySuccessDTO dto = new OrderRidePaySuccessDTO();
        dto.setOrderId(pay.getBstId());
        dto.setPayType(OrderPayType.USER_PAY);
        dto.setPayAmount(pay.getAmount());
        dto.setPayId(pay.getId());
        dto.setPayTime(pay.getPayTime());
        int rows = orderService.handleRidePaySuccess(dto);

        return rows == 1;
    }
}
