package cn.newfeifan.mall.module.distri.dal.mysql.ordercalc;


import cn.newfeifan.mall.framework.common.pojo.PageResult;
import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
import cn.newfeifan.mall.module.distri.dal.dataobject.ordercalc.OrderCalcDO;
import org.apache.ibatis.annotations.Mapper;
import cn.newfeifan.mall.module.distri.controller.admin.ordercalc.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 订单产生数据计算 Mapper
 *
 * @author 非繁人
 */
@Mapper
public interface OrderCalcMapper extends BaseMapperX<OrderCalcDO> {

    default PageResult<OrderCalcDO> selectPage(OrderCalcPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrderCalcDO>()
                .eqIfPresent(OrderCalcDO::getOrderNo, reqVO.getOrderNo())
                .eqIfPresent(OrderCalcDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(OrderCalcDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(OrderCalcDO::getPrice, reqVO.getPrice())
                .eqIfPresent(OrderCalcDO::getCost, reqVO.getCost())
                .eqIfPresent(OrderCalcDO::getProductCount, reqVO.getProductCount())
                .eqIfPresent(OrderCalcDO::getGrossProfit, reqVO.getGrossProfit())
                .eqIfPresent(OrderCalcDO::getGrossProfitUserQuota, reqVO.getGrossProfitUserQuota())
                .eqIfPresent(OrderCalcDO::getGrossProfitAncestorQuota, reqVO.getGrossProfitAncestorQuota())
                .eqIfPresent(OrderCalcDO::getGrossProfitBonusQuota, reqVO.getGrossProfitBonusQuota())
                .eqIfPresent(OrderCalcDO::getGrossProfitPlatformQuota, reqVO.getGrossProfitPlatformQuota())
                .eqIfPresent(OrderCalcDO::getPercentTemplate, reqVO.getPercentTemplate())
                .eqIfPresent(OrderCalcDO::getOrderId, reqVO.getOrderId())
                .likeIfPresent(OrderCalcDO::getName, reqVO.getName())
                .likeIfPresent(OrderCalcDO::getNickName, reqVO.getNickName())
                .orderByDesc(OrderCalcDO::getId));
    }

    void updateOrderItemById(@Param("orderItemId")Long orderItemId);

    void updateOrderItemTransitionTime(@Param("orderItemId") Long orderItemId);
}