package com.ruoyi.ss.feeRule.service.impl;

import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.ss.feeRule.domain.FeeRule;
import com.ruoyi.ss.feeRule.domain.FeeRuleDTO;
import com.ruoyi.ss.feeRule.service.IFeeRuleConverter;
import org.springframework.stereotype.Service;

import static com.ruoyi.common.utils.SecurityUtils.getUserId;
import static com.ruoyi.common.utils.SecurityUtils.getUsername;

@Service
public class FeeRuleConverterImpl implements IFeeRuleConverter {

    @Override
    public FeeRule toOrderBO(FeeRuleDTO dto) {
        FeeRule rule = new FeeRule();
        rule.setCreateBy(getUsername());
        if(dto.getHours() == null){
            rule.setHours(1);
        }
        BeanUtils.copyProperties(dto, rule);
        rule.setMerchantId(getUserId());
        return rule;
    }
}
