package com.gic.haoban.manage.service.service.fee.impl;

import java.util.List;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gic.haoban.manage.service.dao.mapper.fee.TabHaobanQywxFeeOrderMapper;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeOrder;
import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeOrderService;

/**
 * 企业微信收费订单(TabHaobanQywxFeeOrder)表服务实现类
 *
 * @author mozhu
 * @since 2022-08-03 16:12:33
 */
@Service
public class HaobanQywxFeeOrderServiceImpl implements HaobanQywxFeeOrderService {
    
    
    private static Logger logger = LogManager.getLogger(HaobanQywxFeeOrderService.class);

    
    @Autowired
    private TabHaobanQywxFeeOrderMapper tabHaobanQywxFeeOrderMapper;

    /**
     * 新增数据
     *
     * @param tabHaobanQywxFeeOrder 实例对象
     * @return 实例对象
     */
    @Override
    public TabHaobanQywxFeeOrder insert(TabHaobanQywxFeeOrder tabHaobanQywxFeeOrder) {
        String wxEnterpriseId = tabHaobanQywxFeeOrder.getWxEnterpriseId() ;
        String orderId = tabHaobanQywxFeeOrder.getOrderId() ;
        TabHaobanQywxFeeOrder tab = this.tabHaobanQywxFeeOrderMapper.selectByOrderId(wxEnterpriseId, orderId) ;
        if(null != tab) {
            logger.info("订单记录已经存在,orderId={}",orderId);
            return tab ;
        }
        this.tabHaobanQywxFeeOrderMapper.insert(tabHaobanQywxFeeOrder);
        return tabHaobanQywxFeeOrder;
    }

    @Override
    public int countExternalContactCount(String wxEnterpriseId) {
        return tabHaobanQywxFeeOrderMapper.countExternalContactCount(wxEnterpriseId);
    }
    
    @Override
    public List<TabHaobanQywxFeeOrder> listOrder(String wxEnterpriseId) {
        return this.tabHaobanQywxFeeOrderMapper.listOrder(wxEnterpriseId);
    }
}
