package cn.sikey.hmd.service.payments;


import cn.sikey.hmd.api.hmd.vo.payments.PaymentsReqVO;
import cn.sikey.hmd.api.hmd.vo.payments.PaymentsRespVO;
import cn.sikey.hmd.convert.PaymentsConvert;
import cn.sikey.hmd.dal.dataobject.PaymentsDO;
import cn.sikey.hmd.dal.mysql.PaymentsMapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @Author: qin
 * @Date: 2025/3/31
 * @Description: 支付记录
 */
@Service
@Slf4j
public class PaymentServiceImpl implements PaymentService {

    @Resource
    private PaymentsMapper paymentsMapper;

    @Override
    public void savePayments(PaymentsReqVO paymentsReqVO) {
        PaymentsDO paymentsDO = PaymentsConvert.INSTANCE.convertPaymentsReqVO(paymentsReqVO);
        paymentsDO.setCreator(paymentsReqVO.getDeviceId());
        paymentsDO.setUpdater(paymentsReqVO.getDeviceId());
        paymentsMapper.insert(paymentsDO);
    }

    @Override
    public void updatePayments(PaymentsReqVO paymentsReqVO) {
        paymentsMapper.updatePayments(paymentsReqVO);
    }

    @Override
    public PaymentsRespVO queryPayments(Long orderId) {
        PaymentsDO paymentsDO = paymentsMapper.queryPayments(orderId);
        return PaymentsConvert.INSTANCE.convertPaymentsRespVO(paymentsDO);
    }
}
