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

import java.util.List;

import com.iamberry.wechat.core.entity.order.Order;
import com.iamberry.wechat.face.ism.IntegralLogService;
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;
import org.springframework.transaction.annotation.Transactional;

/**
 * 会员信息 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
	 */
	@Override
	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);
	}
	@Override
	public Integer updateUserIntegral(Member member) {
		// TODO Auto-generated method stub
		return memberMapper.updateUserIntegral(member);
	}

	/**
	 * 根据 userid 修改会员信息
	 * 2016年4月21日
	 * @author 穆再兴
	 * @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
	 */
	@Override
	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日
	 * @return
	 */
	@Override
	public List<Integer> selectDownCountByUserId(Integer userId){
		return memberMapper.selectDownCountByUserId(userId);
	}

	/**
	 * 查詢訂單表
	 * @return
	 */
	@Override
	public List<Order> selectAiberleShopOrderList(){
		return memberMapper.selectAiberleShopOrderList();
	}

	/**
	 * 更新訂單表
	 */
	@Override
	public void updateAiberleShopOrder(Order order){
		memberMapper.updateAiberleShopOrder(order);
	}

	@Override
	public Integer nowUpdateUserByOpenId(Member member){
		return memberMapper.nowUpdateUserByOpenId(member);
	}

	@Override
	public Integer becomeVipByOpenId(Member member) {
		return memberMapper.nowUpdateUserByOpenId(member);
	}

	@Override
	public List<Member> getNowBirthDate() {
		return memberMapper.getNowBirthDate();
	}

	@Override
	public List<Member> getNoRegister(Member member) {
		return memberMapper.getNoRegister(member);
	}

}
