All Downloads are FREE. Search and download functionalities are using the official Maven repository.

k.e.book.ddh.service.CcItemMarketService Maven / Gradle / Ivy


package k.e.book.ddh.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import k.e.book.common.enums.ItemMarketStatus;
import k.e.book.ddh.entity.CcItemMarketDO;
import k.e.book.ddh.entity.CcItemMarketQueryDTO;
import k.e.book.ddh.mapper.CcItemMarketMapper;
import org.springframework.stereotype.Service;

/**
 * @author kk
 * @date 2023-05-21 11:04
 */
@Service
public class CcItemMarketService extends ServiceImpl {

    public boolean updateAutoById(Long id) {
        CcItemMarketDO dd = new CcItemMarketDO();
        dd.setStatus(ItemMarketStatus.OnSale.getName());
        LambdaQueryWrapper qr = new LambdaQueryWrapper<>();
        qr.eq(CcItemMarketDO::getStatus, ItemMarketStatus.LOCKING.getName())
                .eq(CcItemMarketDO::getId, id);
        return this.update(dd, qr);
    }

    /**
     * 3 => 1 & item_id
     *
     * @param itemId item id
     * @return d
     */
    public boolean updateAuto(Long itemId) {
        CcItemMarketDO dd = new CcItemMarketDO();
        dd.setStatus(ItemMarketStatus.OnSale.getName());
        LambdaQueryWrapper qr = new LambdaQueryWrapper<>();
        qr.eq(CcItemMarketDO::getStatus, ItemMarketStatus.LOCKING.getName()).eq(CcItemMarketDO::getItemId, itemId);
        return this.update(dd, qr);
    }

    /**
     * @param marketId d
     * @param status   状态:0=隐藏,1=挂售中,2=已卖出,3=锁定中,4=取消挂售,5=系统取消,6=后台取消
     * @return
     */
    public CcItemMarketDO getByOtherSell(Long marketId, String status) {
        LambdaQueryWrapper qr = new LambdaQueryWrapper<>();
        qr.eq(CcItemMarketDO::getId, marketId).eq(CcItemMarketDO::getStatus, status)
                .last("limit 1")
        ;
        return this.getOne(qr);
    }

    public IPage selectProductPage(CcItemMarketQueryDTO dto) {
        LambdaQueryWrapper qr = new LambdaQueryWrapper<>();

        if (dto.getId() != null) {
            qr.eq(CcItemMarketDO::getId, dto.getId());
        }
        if (dto.getParentId() != null) {
            qr.eq(CcItemMarketDO::getParentId, dto.getParentId());
        }
        if (dto.getProductId() != null) {
            qr.eq(CcItemMarketDO::getProductId, dto.getProductId());
        }
        if (dto.getItemId() != null) {
            qr.eq(CcItemMarketDO::getItemId, dto.getItemId());
        }
        if (dto.getUserCollectId() != null) {
            qr.eq(CcItemMarketDO::getUserCollectId, dto.getUserCollectId());
        }
        if (dto.getUserId() != null) {
            qr.eq(CcItemMarketDO::getUserId, dto.getUserId());
        }
        if (dto.getOrderid() != null) {
            qr.eq(CcItemMarketDO::getOrderid, dto.getOrderid());
        }
        if (dto.getLevel() != null) {
            qr.eq(CcItemMarketDO::getLevel, dto.getLevel());
        }
        if (dto.getAmount() != null) {
            qr.eq(CcItemMarketDO::getAmount, dto.getAmount());
        }
        if (dto.getPriceunit() != null) {
            qr.eq(CcItemMarketDO::getPriceunit, dto.getPriceunit());
        }
        if (dto.getLikes() != null) {
            qr.eq(CcItemMarketDO::getLikes, dto.getLikes());
        }
        if (dto.getCreatetime() != null) {
            qr.eq(CcItemMarketDO::getCreatetime, dto.getCreatetime());
        }
        if (dto.getUpdatetime() != null) {
            qr.eq(CcItemMarketDO::getUpdatetime, dto.getUpdatetime());
        }
        if (dto.getServiceFee() != null) {
            qr.eq(CcItemMarketDO::getServiceFee, dto.getServiceFee());
        }
        if (dto.getCopyrightFee() != null) {
            qr.eq(CcItemMarketDO::getCopyrightFee, dto.getCopyrightFee());
        }
        if (dto.getPaymentFee() != null) {
            qr.eq(CcItemMarketDO::getPaymentFee, dto.getPaymentFee());
        }
        if (dto.getWithdrawFee() != null) {
            qr.eq(CcItemMarketDO::getWithdrawFee, dto.getWithdrawFee());
        }
        if (dto.getPaidAmount() != null) {
            qr.eq(CcItemMarketDO::getPaidAmount, dto.getPaidAmount());
        }
        if (dto.getPaidStatus() != null) {
            qr.eq(CcItemMarketDO::getPaidStatus, dto.getPaidStatus());
        }
        if (dto.getStatus() != null) {
            qr.eq(CcItemMarketDO::getStatus, dto.getStatus());
        }
        if (dto.getSettleAccount() != null) {
            qr.eq(CcItemMarketDO::getSettleAccount, dto.getSettleAccount());
        }
        if (dto.getCreatedAt() != null) {
            qr.eq(CcItemMarketDO::getCreatedAt, dto.getCreatedAt());
        }
        if (dto.getUpdatedAt() != null) {
            qr.eq(CcItemMarketDO::getUpdatedAt, dto.getUpdatedAt());
        }
        if (dto.getDeletedAt() != null) {
            qr.eq(CcItemMarketDO::getDeletedAt, dto.getDeletedAt());
        }

        qr.orderByDesc(CcItemMarketDO::getId);
        IPage page = new Page<>();
        page.setCurrent(dto.getPage());
        page.setSize(dto.getLimit());
        return baseMapper.selectPage(page, qr);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy