package com.hfkj.service.pay.impl;

import com.hfkj.dao.BsPayMerMapper;
import com.hfkj.entity.BsPayMer;
import com.hfkj.entity.BsPayMerExample;
import com.hfkj.service.pay.BsPayMerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @className: BsPayMerServiceImpl
 * @author: HuRui
 * @date: 2025/5/22
 **/
@Service("payMerService")
public class BsPayMerServiceImpl implements BsPayMerService {
    @Resource
    private BsPayMerMapper payMerMapper;

    @Override
    public void edit(BsPayMer data) {
        data.setUpdateTime(new Date());
        if (data.getId() == null) {
            data.setCreateTime(new Date());
            data.setStatus(1);
            payMerMapper.insert(data);
        } else {
            payMerMapper.updateByPrimaryKey(data);
        }
    }

    @Override
    public BsPayMer getDetail(Long id) {
        return payMerMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<BsPayMer> getList(Map<String, Object> param) {
        BsPayMerExample example = new BsPayMerExample();
        example.createCriteria().andStatusNotEqualTo(0);

        example.setOrderByClause("create_time desc");
        return payMerMapper.selectByExample(example);
    }
}
