package com.iamberry.wechat.service.cart.dao;

import java.util.List;

import com.iamberry.wechat.core.entity.PaperBean;
import com.iamberry.wechat.core.entity.cart.CartDto;
import com.iamberry.wechat.core.entity.cart.ShopOrderAndItemDto;
import com.iamberry.wechat.core.entity.cart.ShopOrderItemDto;
import com.iamberry.wechat.core.entity.cart.ShopSalesOrderDto;
import com.iamberry.wechat.core.entity.coupon.CouponItem;
import com.iamberry.wechat.core.entity.coupon.CouponType;
import com.iamberry.wechat.core.entity.order.Order;
import com.iamberry.wechat.core.entity.order.OrderItem;

public interface CartDao {
	
	//根据用户id查询购物车
	public List<CartDto> selectCartByOpenId(String openId);
	
	//根据用户id查询购物车数量
	public Integer getCartNumByCartOpenId(String openId);
	
	//修改购物车数量
	public Integer updateCartByOpenId(CartDto cartDto);
	
	//根据商品id和openid查询购物车数量
	public Integer getCartNumByOpenId(CartDto cartDto);
	
	//根据商品id和用户openid查询购物车是否有该商品
	public CartDto getCartByCartProductId(CartDto cartDto);
	
	//添加商品到购物车
	public Integer addProductToCart(CartDto cartDto);
	
	//根据cartid删除购物车信息
	public Integer deleteCartByCartId(CartDto cartDto);
	
	//分页查询订单信息
	public List<ShopOrderAndItemDto> selectShopOrder(PaperBean paperBean);
	
	//根据openid查询订单数量
	public Integer getOrderNumByOpenId(PaperBean paperBean);
	
	//根据订单id查询订单项
	public List<ShopOrderItemDto> selectShopOrderItem(String itemSalesOrderid);
	
	//根据订单号查询订单信息
	public ShopSalesOrderDto getShopOrderByOrderId(String salesOrderId, String salesOpenId);

	/**
	 * 根据购物车ID，获取购物项
	 * @param carts
	 * @return
	 */
	public List<CartDto> selectCartItemByListId(Integer[] carts);

	/**
	 * 添加订单信息
	 * @param order
	 * @return
	 */
	public Integer insertOrderInfo(Order order);

	/**
	 * 添加订单项信息
	 * @param items
	 * @return
	 */
	public Integer insertOrderItemList(List<OrderItem> items);

	/**
	 * 修改订单信息
	 * @param order
	 * @return
	 */
	public Integer updateOrderStatus(Order order);

	/**
	 * 根据订单号，获取订单的状态
	 * @param orderId
	 * @return
	 */
	public Integer selectOrderStatusByOrderId(String orderId);
	
	
	//根据orderid查询用户openid和订单状态
	public ShopSalesOrderDto getOpenIdAndStatus(String salesOrderid);
	
	//修改订单状态和添加备注
	public Integer updateOrderByOrderId(Order order);

	/**
	 * 根据ID，批量删除购物车ID
	 */
	public Integer deleteBatchCartListById(List<Integer> cartIds);

	/**
	 * 根据订单号、用户openid，获取订单信息
	 * @param order
	 * @return
	 */
	public Order selectOrderInfoById(Order order);
	
	/**
	 * 根据单号查询该订单的产品总数 
	 * 2016年5月18日
	 * @param orderid
	 * @return
	 */
	public Integer getItemNumByOrderId(String orderid);
	
	/**
	 *  根据优惠券id获取优惠券优惠价格
	 * @param couponId
	 * @return
	 * @author liuzhiwei
	 */
	public CouponType getCouponReduceByItemId(CouponItem couponItem);
	
	/**
	 * 根据openid查看订单列表，不分页
	 * @param shopSalesOrderDto
	 * @return
	 */
	public List<ShopSalesOrderDto> getOrderList(ShopSalesOrderDto shopSalesOrderDto);

	/**
	 * 获取历史订单记录的最近的发货地址
	 * @param openid
	 * @return
	 */
	public Order getRecentOrderAddress(String openid);
	
	/**
	 * 根据openid和订单状态查询订单个数
	 * @param shopSalesOrderDto
	 * @return
	 */
	public Integer selectOrderCount(ShopSalesOrderDto shopSalesOrderDto);
}
