package com.sckw.payment.service;

import com.sckw.core.common.enums.NumberConstant;
import com.sckw.core.model.constant.Global;
import com.sckw.core.utils.IdWorker;
import com.sckw.core.web.context.LoginUserHolder;
import com.sckw.payment.dao.KwpWalletRefundSubMapper;
import com.sckw.payment.model.KwpWalletRefundSub;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 *
 * @author xucaiqin
 * @date 2023-09-19 10:26:44
 */
@Service
@RequiredArgsConstructor
public class KwpWalletRefundSubService {
    private final KwpWalletRefundSubMapper kwpWalletRefundSubMapper;

    /**
     * 保存关联的操作记录
     * @param refundId
     * @param remark
     * @param status
     */
    public void saveRecord(Long refundId, String remark, int status) {
        KwpWalletRefundSub kwpWalletRefundSub = new KwpWalletRefundSub();
        kwpWalletRefundSub.setId(new IdWorker(NumberConstant.ONE).nextId());
        kwpWalletRefundSub.setRefundId(refundId);
        kwpWalletRefundSub.setRemark(remark);
        kwpWalletRefundSub.setCreateBy(LoginUserHolder.getUserId());
        kwpWalletRefundSub.setCreateTime(LocalDateTime.now());
        kwpWalletRefundSub.setUpdateBy(LoginUserHolder.getUserId());
        kwpWalletRefundSub.setUpdateTime(LocalDateTime.now());
        kwpWalletRefundSub.setDelFlag(Global.UN_DELETED);
        kwpWalletRefundSub.setStatus(status);
        kwpWalletRefundSubMapper.insert(kwpWalletRefundSub);
    }
}
