package com.greenorange.promotion.service.refund.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.greenorange.promotion.constant.CommonConstant;
import com.greenorange.promotion.model.dto.refundRecord.RefundRecordQueryRequest;
import com.greenorange.promotion.model.entity.RefundRecord;
import com.greenorange.promotion.service.refund.RefundRecordService;
import com.greenorange.promotion.mapper.RefundRecordMapper;
import com.greenorange.promotion.utils.SqlUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
* @author 35880
* @description 针对表【refund_record(退款记录表)】的数据库操作Service实现
* @createDate 2025-07-01 08:18:44
*/
@Service
public class RefundRecordServiceImpl extends ServiceImpl<RefundRecordMapper, RefundRecord>
    implements RefundRecordService{

    /**
     * 获取查询条件
     */
    @Override
    public QueryWrapper<RefundRecord> getQueryWrapper(RefundRecordQueryRequest refundRecordQueryRequest) {
        String outRefundNo = refundRecordQueryRequest.getOutRefundNo();
        String sortField = refundRecordQueryRequest.getSortField();
        String sortOrder = refundRecordQueryRequest.getSortOrder();
        QueryWrapper<RefundRecord> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(StringUtils.isNotBlank(outRefundNo), "outRefundNo", outRefundNo);
        queryWrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_DESC), sortField);
        return queryWrapper;
    }
}




