package com.ruoyi.frequency.rechargerecord.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.code.PublicCommon;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.frequency.rechargerecord.entity.RechargeRecord;
import com.ruoyi.frequency.rechargerecord.mapper.RechargeRecordMapper;
import com.ruoyi.frequency.rechargerecord.service.RechargeRecordService;
import com.ruoyi.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 充值记录Service业务层处理
 *
 * @author liwenlong
 * @date 2023-10-25
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class RechargeRecordServiceImpl extends ServiceImpl<RechargeRecordMapper, RechargeRecord>  implements RechargeRecordService
{
    @Autowired
    private RechargeRecordMapper rechargeRecordMapper;

    /**
     * 查询充值记录
     *
     * @param id 充值记录主键
     * @return 充值记录
     */
    @Override
    public RechargeRecord selectRechargeRecordById(Long id)
    {
        return rechargeRecordMapper.selectRechargeRecordById(id);
    }

    /**
     * 查询充值记录列表
     *
     * @param rechargeRecord 充值记录
     * @return 充值记录
     */
    @Override
    public List<RechargeRecord> selectRechargeRecordList(RechargeRecord rechargeRecord)
    {
        return rechargeRecordMapper.selectRechargeRecordList(rechargeRecord);
    }

    /**
     * 新增充值记录
     *
     * @param rechargeRecord 充值记录
     * @return 结果
     */
    @Override
    public int insertRechargeRecord(RechargeRecord rechargeRecord)
    {
        rechargeRecord.setCreateTime(DateUtils.getNowDate());
        return rechargeRecordMapper.insertRechargeRecord(rechargeRecord);
    }

    /**
     * 修改充值记录
     *
     * @param rechargeRecord 充值记录
     * @return 结果
     */
    @Override
    public int updateRechargeRecord(RechargeRecord rechargeRecord)
    {
        rechargeRecord.setUpdateTime(DateUtils.getNowDate());
        return rechargeRecordMapper.updateRechargeRecord(rechargeRecord);
    }

    /**
     * 批量删除充值记录
     *
     * @param ids 需要删除的充值记录主键
     * @return 结果
     */
    @Override
    public int deleteRechargeRecordByIds(Long[] ids)
    {
        this.lambdaUpdate().set(RechargeRecord::getDelFlag,PublicCommon.删除).in(RechargeRecord::getId,ids).update();
        return ids.length;
    }

    /**
     * 删除充值记录信息
     *
     * @param id 充值记录主键
     * @return 结果
     */
    @Override
    public int deleteRechargeRecordById(Long id)
    {
        this.lambdaUpdate().set(RechargeRecord::getDelFlag,PublicCommon.删除).eq(RechargeRecord::getId,id).update();
        return 1;
    }

    @Override
    public ResponseData rechargeAliNotify(HttpServletRequest request, HttpServletResponse response) {
        return null;
    }

    @Override
    public ResponseData rechargeWxNotify(HttpServletRequest request, HttpServletResponse response) {
        return null;
    }
}
