package com.kmall.admin.service.impl;

import com.kmall.admin.service.OrderRefundService;
import com.kmall.common.entity.SysUserEntity;
import com.kmall.common.utils.ShiroUtils;
import com.kmall.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.kmall.admin.dao.OrderRefundDao;
import com.kmall.admin.entity.OrderRefundEntity;

/**
 * 订单退款记录表Service实现类
 *
 * @author emato
 * @email admin@qhdswl.com
 * @date 2018-11-01 10:16:41
 */
@Service("orderRefundService")
public class OrderRefundServiceImpl implements OrderRefundService {
    @Autowired
    private OrderRefundDao orderRefundDao;

    @Override
    public OrderRefundEntity queryObject(Integer id) {
        return orderRefundDao.queryObject(id);
    }

    @Override
    public List<OrderRefundEntity> queryList(Map<String, Object> map) {
        return orderRefundDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return orderRefundDao.queryTotal(map);
    }

    @Override
    public int save(OrderRefundEntity orderRefund) {
        return orderRefundDao.save(orderRefund);
    }

    @Override
    public int update(OrderRefundEntity orderRefund) {
        if (StringUtils.isNotEmpty(orderRefund.getApprovalRemark())) {
            orderRefund.setApprovalTime(new Date());
            SysUserEntity user = ShiroUtils.getUserEntity();
            orderRefund.setApprover(user.getUserId().toString());
            orderRefund.setRefundStatus(3);
        }
        return orderRefundDao.update(orderRefund);
    }

    @Override
    public int delete(Integer id) {
        return orderRefundDao.delete(id);
    }

    @Override
    public int deleteBatch(Integer[]ids) {
        return orderRefundDao.deleteBatch(ids);
    }

    @Override
    public OrderRefundEntity queryObjectByOrderId(Long orderId) {
        return orderRefundDao.queryObjectByOrderId(orderId);
    }
}
