package com.sv.service.oms;

import com.github.pagehelper.PageHelper;
import com.sv.entity.MemberEnterVenueLog;
import com.sv.mapper.MemberEnterVenueLogMapper;
import com.ydd.framework.core.common.Pagination;
import com.ydd.framework.core.service.impl.BaseServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * Service - 篮球进场订单
 *
 * @author yechanglin
 * @since 2018-08-03
 */
@Service("MemberEnterVenueLogServiceOms")
@Transactional(readOnly = true)
public class MemberEnterVenueLogService extends BaseServiceImpl {

	private final Logger logger = LoggerFactory.getLogger(MemberEnterVenueLogService.class);

	@Resource
	private MemberEnterVenueLogMapper memberEnterVenueLogMapper;

	/**
	 * 创建篮球进场订单
	 *
	 * @param memberEnterVenueLog 篮球进场订单
	 */

	@Transactional
    public void save(MemberEnterVenueLog memberEnterVenueLog) {
		if (memberEnterVenueLog.getId() != null && memberEnterVenueLog.getId() > 0) {
			// 更新
			memberEnterVenueLogMapper.update(memberEnterVenueLog);
		} else {
			// 新建
			memberEnterVenueLogMapper.insert(memberEnterVenueLog);
		}
	}

	/**
	 * 更新篮球进场订单
 	 *
	 * @param memberEnterVenueLog 篮球进场订单
	 */

	@Transactional
    public void update(MemberEnterVenueLog memberEnterVenueLog) {
		memberEnterVenueLogMapper.update(memberEnterVenueLog);
	}

	/**
	 * 删除篮球进场订单
	 *
	 * @param id 编号
   	 * @return 删除数量
	 */

	@Transactional
    public Integer delete(Integer id) {
		if (id == null || id <= 0) {
			return 0;
		}
		return memberEnterVenueLogMapper.delete(id);
	}

	/**
	 * 删除篮球进场订单
	 *
	 * @param ids 编号数组
	 * @return 删除数量
	 */

	@Transactional
    public Integer deleteByIds(Integer[] ids) {
		if (ids == null || ids.length == 0) {
			return 0;
		}
		return memberEnterVenueLogMapper.deleteByIds(ids);
	}

	/**
	 * 查询篮球进场订单
	 *
	 * @param id 编号
	 * @return 篮球进场订单
	 */
	public MemberEnterVenueLog findById(Integer id) {
		return memberEnterVenueLogMapper.findById(id);
	}

	/**
	 * 查询篮球进场订单
	 *
	 * @param pagination 分页信息
	 * @return 分页结果
	 */

	public Pagination findPage(Pagination pagination, Integer payStatus, Integer memberId, String starTime,
							   String endTime, String orderSn, Integer payType,Integer venueId) {
		PageHelper.startPage(pagination.getPage(), pagination.getPageSize());
		PageHelper.orderBy("id desc");
		pagination.setQueryResult(memberEnterVenueLogMapper.findAlls(payStatus, memberId, starTime, endTime, orderSn, payType,venueId));
		return pagination;
	}

}

