package com.iamberry.wechat.service.member.dao.imp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.iamberry.wechat.core.entity.Page;
import com.iamberry.wechat.core.entity.member.Member;
import com.iamberry.wechat.service.mapper.MemberMapper;
import com.iamberry.wechat.service.member.dao.MemberDao;

/**
 * 会员信息 DAO 实现
 * 2016年4月21日
 * @author Administrator
 *
 */
@Repository
public class MemberDaoImpl  implements MemberDao {
	@Autowired
	private MemberMapper memberMapper;

	/**
	 * 根据userid得到会员信息
	 * @param userId
	 * @return
	 */
	@Override
	public Member getMemberByUserId(Integer userId) {
		// TODO Auto-generated method stub
		return memberMapper.getMemberByUserId(userId);
	}
	
	/**
	 * 根据 openid 查询一个member
	 * 2016年4月28日
	 * @author 穆再兴
	 * @return
	 */
	public Member getMemberByUserOpenId(String openid){
		return memberMapper.getMemberByUserOpenId(openid);
	}
	@Override
	public Integer getCount() {
		// TODO Auto-generated method stub
		return memberMapper.getCount();
	}

	@Override
	public List<Member> getMemberByPage(Page page) {
		// TODO Auto-generated method stub
		return memberMapper.getMemberByPage(page);
	}

	/**
	 * 根据 userid 修改会员信息
	 * 2016年4月21日
	 * @author 穆再兴
	 * @param userId
	 * @return
	 */
	@Override
	public Integer updateMemberByUserId(Member member){
		return memberMapper.updateMemberByUserId(member);
	}
	@Override
	public Integer updateUserUseIntegral(Member member) {
		// TODO Auto-generated method stub
		return memberMapper.updateUserUseIntegral(member);
	}
	@Override
	public List<Member> selectUserIntegralByWechatProxyId(Page page) {
		// TODO Auto-generated method stub
		return memberMapper.selectUserIntegralByWechatProxyId(page);
	}
	@Override
	public Member selectUserIdentityAndQrcodeByOpenId(String openid) {
		// TODO Auto-generated method stub
		return memberMapper.selectUserIdentityAndQrcodeByOpenId(openid);
	}

	@Override
	public Member selectUserResAndIdSByOpenId(String openid) {
		// TODO Auto-generated method stub
		return memberMapper.selectUserResAndIdSByOpenId(openid);
	}
	
	/**
	 * 根据 openid 修改用户可用金额
	 * 2016年5月4日
	 * @param member
	 * @return
	 */
	public Integer updateUserIncomeByOpenId(Member member){
		return memberMapper.updateUserIncomeByOpenId(member);
	}

	@Override
	public Integer updateUserFlagByOpenId(String openId) {
		// TODO Auto-generated method stub
		return memberMapper.updateUserFlagByOpenId(openId);
	}
	
	/**
	 * 根据userid获取当前用户的“下线人数”和“已购买人数”
	 * 2016年5月11日
	 * @param openId
	 * @return
	 */
	public List<Integer> selectDownCountByUserId(Integer userId){
		return memberMapper.selectDownCountByUserId(userId);
	}

	@Override
	public Integer updateIsBaughtByOpenid(Member member) {
		// TODO Auto-generated method stub
		return memberMapper.updateIsBaughtByOpenid(member);
	}

	/**
	 *个人分销员
	 *根据placeInfo查询个人用户的个数
	 *@paramplaceInfo
	 *@return
	 */
	public Integer getOrdinaryNumber(Member member){
		int flag = memberMapper.getOrdinaryNumber(member);
		return flag;
	}

	/**
	 *后台-Drp分销管理主界面-->获取个人分销员的下线列表
	 */
	public List<Member>  getOrdinary(Member member){
		return memberMapper.getOrdinary(member);
	}
}
