package com.fzm.mall.server.front.order.mapper;

import com.fzm.mall.server.front.order.model.OrderDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fzm.mall.server.front.order.model.vo.ReturnMoneyDetail;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 用户购物订单详情表 Mapper 接口
 * </p>
 *
 * @author fzm
 * @since 2021-03-03
 */
public interface OrderDetailMapper extends BaseMapper<OrderDetail> {
    @Update("update order_detail a left join order_info b on a.oid = b.oid set a.buyer_state = 1 where b.uid = #{uid} and a.sku_id = #{skuId} and a.buyer_state = 0 and a.oid = #{oid}")
    int updateCommend(@Param("uid") String uid, @Param("oid") String oid, @Param("skuId") String skuId);

    @Update("update order_detail a left join goods_comment b on a.oid = b.oid and a.sku_id = b.sku_id set a.buyer_state = 2 where b.comment_id = #{commentId} and a.buyer_state = 1")
    int updateCommendAppend(@Param("commentId") String commentId);

    @Select("select b.*,a.merchant_id merchantId from order_info a left join order_detail b on a.oid = b.oid where a.uid = #{uid} and b.buyer_state = 0 limit 10")
    List<OrderDetail> getWaitsByUid(String uid);

    @Select("select b.* from order_info a left join order_detail b on a.oid = b.oid where a.uid =#{uid} and b.sku_id = #{skuId}")
    List<OrderDetail> getByUidAndSkuId(@Param("uid") String uid, @Param("skuId") String skuId);
}
