package com.iamberry.wechat.face.cart;

import java.util.List;

import com.iamberry.wechat.core.entity.PaperBean;
import com.iamberry.wechat.core.entity.admin.ShopSystemRule;
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.mq.MQMessage;
import com.iamberry.wechat.core.entity.order.Order;
import com.iamberry.wechat.core.entity.order.OrderItem;

public interface CartService {
	
	//根据用户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
	 * @param items
	 * @return
	 */
	public boolean addOrderAndSaveOrderItem(Order order, List<OrderItem> items, List<Integer> cartIds)  throws Exception;

	/**
	 * 修改订单信息
	 * @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);

	/**
	 * 根据订单号、用户openid，获取订单信息
	 * @param order
	 * @return
	 */
	public Order selectOrderInfoById(Order order);
	
	//根据rId查询规则表数据
	public ShopSystemRule getReluByRid(Integer rId);
	
	/**
	 * 根据单号查询该订单的产品总数 
	 * 2016年5月18日
	 * @param orderid
	 * @return
	 */
	public Integer getItemNumByOrderId(String orderid);
	
	/**
	 * 修改支付完之后，订单的状态，及插入订单状态
	 * 2016年7月7日
	 * @param QMessage
	 * @return
	 */
	public Boolean supdateStateByOrderId(MQMessage QMessage);
	
	/**
	 *  根据优惠券id获取优惠券优惠价格
	 * @param couponId
	 * @return
	 * @author liuzhiwei
	 */
	public CouponType getCouponReduceByItemId(CouponItem couponItem);
	
	/**
	 * 根据openid查看订单列表，不分页
	 * @param shopSalesOrderDto
	 * @return
	 */
	public List<ShopSalesOrderDto> getOrderList(ShopSalesOrderDto shopSalesOrderDto);
	/**
	 * 通过openid 获取历史订货记录的最近收货地址
	 * @param openid
	 * @return
	 */
	public Order getOrderRecentAddress(String openid);
	
	/**
	 * 根据openid和订单状态查询订单个数
	 * @param shopSalesOrderDto
	 * @return
	 */
	public Integer selectOrderCount(ShopSalesOrderDto shopSalesOrderDto);
}
