package com.iformall.service.impl;

import java.util.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.PosPayOrder;
import com.iformall.mapper.PosPayOrderMapper;
import com.iformall.service.PosPayOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iformall.common.IdWorker;

@Service
public class PosPayOrderServiceImpl implements PosPayOrderService {
	
	@Autowired
    PosPayOrderMapper posPayOrderMapper;


    @Override
    public PageInfo<PosPayOrder> listAsPage(PosPayOrder record, Integer pageIndex, Integer pageSize) {
        return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> posPayOrderMapper.findList(record));
    }

    @Override
    public List<PosPayOrder> getList(PosPayOrder record) {
        return posPayOrderMapper.findList(record);
    }

    @Override
    public PosPayOrder getById(Long id) {
        return posPayOrderMapper.selectById(id);
    }

    @Override
    public void saveOrUpdate(PosPayOrder record) {
        if (record.getId() == null) {
            //record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
            final IdWorker idWorker = IdWorker.get();
        	record.setId(idWorker.nextId());
        	record.setPayOrderNo(String.valueOf(record.getId()));
            posPayOrderMapper.insert(record);
        } else {
            posPayOrderMapper.updateById(record);
        }
    }

    @Override
    public void deleteById(Long id) {
        posPayOrderMapper.deleteById(id);
    }
    
    
    
    
    
    
    
    
}
