package com.cdm.module.promotion.convert.coupon;

import com.cdm.framework.common.pojo.PageResult;
import com.cdm.module.promotion.api.coupon.dto.CouponRespDTO;
import com.cdm.module.promotion.controller.admin.coupon.vo.coupon.CouponPageItemRespVO;
import com.cdm.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO;
import com.cdm.module.promotion.controller.app.coupon.vo.coupon.AppCouponMatchRespVO;
import com.cdm.module.promotion.controller.app.coupon.vo.coupon.AppCouponPageReqVO;
import com.cdm.module.promotion.controller.app.coupon.vo.coupon.AppCouponRespVO;
import com.cdm.module.promotion.dal.dataobject.coupon.CouponDO;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.annotation.processing.Generated;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2023-12-21T17:57:31+0800",
    comments = "version: 1.5.5.Final, compiler: javac, environment: Java 17.0.3 (JetBrains s.r.o.)"
)
public class CouponConvertImpl implements CouponConvert {

    @Override
    public PageResult<CouponPageItemRespVO> convertPage(PageResult<CouponDO> page) {
        if ( page == null ) {
            return null;
        }

        PageResult<CouponPageItemRespVO> pageResult = new PageResult<CouponPageItemRespVO>();

        pageResult.setList( couponDOListToCouponPageItemRespVOList( page.getList() ) );
        pageResult.setTotal( page.getTotal() );

        return pageResult;
    }

    @Override
    public CouponRespDTO convert(CouponDO bean) {
        if ( bean == null ) {
            return null;
        }

        CouponRespDTO couponRespDTO = new CouponRespDTO();

        couponRespDTO.setId( bean.getId() );
        if ( bean.getTemplateId() != null ) {
            couponRespDTO.setTemplateId( bean.getTemplateId().intValue() );
        }
        couponRespDTO.setName( bean.getName() );
        couponRespDTO.setStatus( bean.getStatus() );
        couponRespDTO.setUserId( bean.getUserId() );
        couponRespDTO.setTakeType( bean.getTakeType() );
        couponRespDTO.setUsePrice( bean.getUsePrice() );
        couponRespDTO.setValidStartTime( bean.getValidStartTime() );
        couponRespDTO.setValidEndTime( bean.getValidEndTime() );
        couponRespDTO.setProductScope( bean.getProductScope() );
        List<Long> list = bean.getProductScopeValues();
        if ( list != null ) {
            couponRespDTO.setProductScopeValues( new ArrayList<Long>( list ) );
        }
        couponRespDTO.setDiscountType( bean.getDiscountType() );
        couponRespDTO.setDiscountPercent( bean.getDiscountPercent() );
        couponRespDTO.setDiscountPrice( bean.getDiscountPrice() );
        couponRespDTO.setDiscountLimitPrice( bean.getDiscountLimitPrice() );
        couponRespDTO.setUseOrderId( bean.getUseOrderId() );
        couponRespDTO.setUseTime( bean.getUseTime() );

        return couponRespDTO;
    }

    @Override
    public CouponPageReqVO convert(AppCouponPageReqVO pageReqVO, Collection<Long> userIds) {
        if ( pageReqVO == null && userIds == null ) {
            return null;
        }

        CouponPageReqVO couponPageReqVO = new CouponPageReqVO();

        if ( pageReqVO != null ) {
            couponPageReqVO.setPageNo( pageReqVO.getPageNo() );
            couponPageReqVO.setPageSize( pageReqVO.getPageSize() );
            couponPageReqVO.setStatus( pageReqVO.getStatus() );
        }
        Collection<Long> collection = userIds;
        if ( collection != null ) {
            couponPageReqVO.setUserIds( new ArrayList<Long>( collection ) );
        }

        return couponPageReqVO;
    }

    @Override
    public PageResult<AppCouponRespVO> convertAppPage(PageResult<CouponDO> pageResult) {
        if ( pageResult == null ) {
            return null;
        }

        PageResult<AppCouponRespVO> pageResult1 = new PageResult<AppCouponRespVO>();

        pageResult1.setList( couponDOListToAppCouponRespVOList( pageResult.getList() ) );
        pageResult1.setTotal( pageResult.getTotal() );

        return pageResult1;
    }

    @Override
    public List<AppCouponMatchRespVO> convertList(List<CouponDO> list) {
        if ( list == null ) {
            return null;
        }

        List<AppCouponMatchRespVO> list1 = new ArrayList<AppCouponMatchRespVO>( list.size() );
        for ( CouponDO couponDO : list ) {
            list1.add( couponDOToAppCouponMatchRespVO( couponDO ) );
        }

        return list1;
    }

    protected CouponPageItemRespVO couponDOToCouponPageItemRespVO(CouponDO couponDO) {
        if ( couponDO == null ) {
            return null;
        }

        CouponPageItemRespVO couponPageItemRespVO = new CouponPageItemRespVO();

        couponPageItemRespVO.setTemplateId( couponDO.getTemplateId() );
        couponPageItemRespVO.setName( couponDO.getName() );
        couponPageItemRespVO.setStatus( couponDO.getStatus() );
        couponPageItemRespVO.setUserId( couponDO.getUserId() );
        couponPageItemRespVO.setTakeType( couponDO.getTakeType() );
        couponPageItemRespVO.setUsePrice( couponDO.getUsePrice() );
        couponPageItemRespVO.setValidStartTime( couponDO.getValidStartTime() );
        couponPageItemRespVO.setValidEndTime( couponDO.getValidEndTime() );
        couponPageItemRespVO.setProductScope( couponDO.getProductScope() );
        List<Long> list = couponDO.getProductScopeValues();
        if ( list != null ) {
            couponPageItemRespVO.setProductScopeValues( new ArrayList<Long>( list ) );
        }
        couponPageItemRespVO.setDiscountType( couponDO.getDiscountType() );
        couponPageItemRespVO.setDiscountPercent( couponDO.getDiscountPercent() );
        couponPageItemRespVO.setDiscountPrice( couponDO.getDiscountPrice() );
        couponPageItemRespVO.setDiscountLimitPrice( couponDO.getDiscountLimitPrice() );
        couponPageItemRespVO.setUseOrderId( couponDO.getUseOrderId() );
        couponPageItemRespVO.setUseTime( couponDO.getUseTime() );
        couponPageItemRespVO.setId( couponDO.getId() );
        couponPageItemRespVO.setCreateTime( couponDO.getCreateTime() );

        return couponPageItemRespVO;
    }

    protected List<CouponPageItemRespVO> couponDOListToCouponPageItemRespVOList(List<CouponDO> list) {
        if ( list == null ) {
            return null;
        }

        List<CouponPageItemRespVO> list1 = new ArrayList<CouponPageItemRespVO>( list.size() );
        for ( CouponDO couponDO : list ) {
            list1.add( couponDOToCouponPageItemRespVO( couponDO ) );
        }

        return list1;
    }

    protected AppCouponRespVO couponDOToAppCouponRespVO(CouponDO couponDO) {
        if ( couponDO == null ) {
            return null;
        }

        AppCouponRespVO appCouponRespVO = new AppCouponRespVO();

        appCouponRespVO.setId( couponDO.getId() );
        appCouponRespVO.setName( couponDO.getName() );
        appCouponRespVO.setStatus( couponDO.getStatus() );
        appCouponRespVO.setUsePrice( couponDO.getUsePrice() );
        appCouponRespVO.setValidStartTime( couponDO.getValidStartTime() );
        appCouponRespVO.setValidEndTime( couponDO.getValidEndTime() );
        appCouponRespVO.setDiscountType( couponDO.getDiscountType() );
        appCouponRespVO.setDiscountPercent( couponDO.getDiscountPercent() );
        appCouponRespVO.setDiscountPrice( couponDO.getDiscountPrice() );
        appCouponRespVO.setDiscountLimitPrice( couponDO.getDiscountLimitPrice() );

        return appCouponRespVO;
    }

    protected List<AppCouponRespVO> couponDOListToAppCouponRespVOList(List<CouponDO> list) {
        if ( list == null ) {
            return null;
        }

        List<AppCouponRespVO> list1 = new ArrayList<AppCouponRespVO>( list.size() );
        for ( CouponDO couponDO : list ) {
            list1.add( couponDOToAppCouponRespVO( couponDO ) );
        }

        return list1;
    }

    protected AppCouponMatchRespVO couponDOToAppCouponMatchRespVO(CouponDO couponDO) {
        if ( couponDO == null ) {
            return null;
        }

        AppCouponMatchRespVO appCouponMatchRespVO = new AppCouponMatchRespVO();

        appCouponMatchRespVO.setId( couponDO.getId() );
        appCouponMatchRespVO.setName( couponDO.getName() );
        appCouponMatchRespVO.setStatus( couponDO.getStatus() );
        appCouponMatchRespVO.setUsePrice( couponDO.getUsePrice() );
        appCouponMatchRespVO.setValidStartTime( couponDO.getValidStartTime() );
        appCouponMatchRespVO.setValidEndTime( couponDO.getValidEndTime() );
        appCouponMatchRespVO.setDiscountType( couponDO.getDiscountType() );
        appCouponMatchRespVO.setDiscountPercent( couponDO.getDiscountPercent() );
        appCouponMatchRespVO.setDiscountPrice( couponDO.getDiscountPrice() );
        appCouponMatchRespVO.setDiscountLimitPrice( couponDO.getDiscountLimitPrice() );

        return appCouponMatchRespVO;
    }
}
