package com.hfkj.service.order.impl;

import com.hfkj.dao.BsOrderSettleLedgerMapper;
import com.hfkj.dao.BsOrderSettleMapper;
import com.hfkj.entity.BsOrderSettle;
import com.hfkj.entity.BsOrderSettleLedger;
import com.hfkj.entity.BsOrderSettleLedgerExample;
import com.hfkj.service.order.BsOrderSettleLedgerService;
import com.hfkj.service.order.BsOrderSettleService;
import org.springframework.stereotype.Service;

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

/**
 * @className: BsOrderSettleLedgerServiceImpl
 * @author: HuRui
 * @date: 2024/6/25
 **/
@Service("orderSettleLedgerService")
public class BsOrderSettleLedgerServiceImpl implements BsOrderSettleLedgerService {
    @Resource
    private BsOrderSettleLedgerMapper orderSettleLedgerMapper;

    @Override
    public void editData(BsOrderSettleLedger data) {
        if (data.getId() == null) {
            data.setCreateTime(new Date());
            orderSettleLedgerMapper.insert(data);
        } else {
            orderSettleLedgerMapper.updateByPrimaryKey(data);
        }
    }

    @Override
    public List<BsOrderSettleLedger> getListBySettleId(Long orderSettleId) {
        BsOrderSettleLedgerExample example = new BsOrderSettleLedgerExample();
        example.createCriteria().andOrderSettleIdEqualTo(orderSettleId);
        return orderSettleLedgerMapper.selectByExample(example);
    }

}
