package com.iamberry.wechat.service.drp;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

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

import com.iamberry.app.tool.log.RatFWLogger;
import com.iamberry.wechat.core.entity.PageBean;
import com.iamberry.wechat.core.entity.drp.PlaceLogs;
import com.iamberry.wechat.face.drp.PlaceLogsService;
import com.iamberry.wechat.service.mapper.PlaceLogsMapper;
import com.iamberry.wechat.tools.StaticInfo;

/**
 * @description 商户现金收支记录处理逻辑
 * @author 欧阳明
 * @date 2016-4-19
 */
@Service("placeLogsServiceImpl")
@SuppressWarnings(value="unchecked")
public class PlaceLogsServiceImpl implements PlaceLogsService {
	@Autowired
	private PlaceLogsMapper  placeLogsMapper;
	
	@Autowired
	private RatFWLogger logger;
	
	public Map SearchPlaceLogsPage(PageBean page) {
		Map hm = new HashMap();
		PageBean pageIndex=new PageBean();
		PlaceLogs placeLogs=(PlaceLogs)page.getCondition();
		
		String str = placeLogs.getEndDate();
		if(str!=null && !"".equals(str)){
			placeLogs.setEndDate(str+StaticInfo.endDateC);
		}
		
		pageIndex.setPageNumber(page.getPageNumber());
		pageIndex.setPageSize(page.getPageSize());
		
		if(page.getPageCount()>0){
			pageIndex.setCount(page.getPageCount());
		}else{
			pageIndex.setCount(placeLogsMapper.getAllCount(placeLogs));
		}
		
		pageIndex.initRecordBegin();
		placeLogs.setPage(pageIndex);
		List<PlaceLogs> lists = placeLogsMapper.selectAll(placeLogs);
		
        hm.put("data",lists);
		hm.put("page",pageIndex);
		return hm;
	}

}
