package com.yc.ship.module.trade.dal.mysql.orderjz;

import com.yc.ship.framework.common.pojo.PageResult;
import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
import com.yc.ship.framework.tenant.core.aop.TenantIgnore;
import com.yc.ship.module.trade.controller.admin.orderjz.vo.OrderJzPageReqVO;
import com.yc.ship.module.trade.dal.dataobject.orderjz.OrderJzDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 订单接站 Mapper
 *
 * @author lsq
 */
@Mapper
public interface OrderJzMapper extends BaseMapperX<OrderJzDO> {

    default PageResult<OrderJzDO> selectPage(OrderJzPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrderJzDO>()
                .eqIfPresent(OrderJzDO::getOrderId, reqVO.getOrderId())
                .eqIfPresent(OrderJzDO::getIsJz, reqVO.getIsJz())
                .eqIfPresent(OrderJzDO::getJzAddress, reqVO.getJzAddress())
                .likeIfPresent(OrderJzDO::getJzLinkName, reqVO.getJzLinkName())
                .eqIfPresent(OrderJzDO::getJzLinkPhone, reqVO.getJzLinkPhone())
                .orderByDesc(OrderJzDO::getId));
    }


    @Update("UPDATE trade_order_jz SET deleted = #{deleted},update_time = now() WHERE order_id = #{orderId}")
    @TenantIgnore
    void updateDeleted(@Param("orderId") Long orderId, @Param("deleted")  int deleted);

}