| | |
| | | package com.yeshi.fanli.service.impl.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.money.TeamEincomeRecordMapper;
|
| | | import com.yeshi.fanli.entity.money.TeamEincomeRecord;
|
| | | import com.yeshi.fanli.exception.ParamsException;
|
| | | import com.yeshi.fanli.exception.money.TeamEincomeRecordException;
|
| | | import com.yeshi.fanli.service.inter.money.TeamEincomeRecordService;
|
| | |
|
| | | @Service
|
| | | public class TeamEincomeRecordServiceImpl implements TeamEincomeRecordService {
|
| | |
|
| | | @Resource
|
| | | private TeamEincomeRecordMapper teamEincomeRecordMapper;
|
| | |
|
| | | @Override
|
| | | public void addTeamEincomeRecord(TeamEincomeRecord record) throws TeamEincomeRecordException, ParamsException {
|
| | | if (record.getUid() == null || record.getMoney() == null || record.getType() == null
|
| | | || record.getPreRecieveTime() == null)
|
| | | throw new ParamsException(1, "参数不完整");
|
| | |
|
| | | TeamEincomeRecord oldRecord = teamEincomeRecordMapper.selectByUidAndPreRecieveTimeAndTypeAndSourceType(record.getUid(),
|
| | | record.getPreRecieveTime(), record.getType(),record.getSourceType());
|
| | | if (oldRecord != null)
|
| | | throw new TeamEincomeRecordException(1, "已存在");
|
| | | if (record.getCreateTime() == null)
|
| | | record.setCreateTime(new Date());
|
| | | teamEincomeRecordMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<TeamEincomeRecord> listCanRecieveRecord(Date preRecieveTime, Long uid, List<Integer> typeList) {
|
| | |
|
| | | return teamEincomeRecordMapper.listByUidAndPreRecieveTimeAndState(uid, preRecieveTime, typeList,
|
| | | TeamEincomeRecord.STATE_NOT_RECIEVE);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TeamEincomeRecord selectByPrimaryKeyForUpdate(Long id) {
|
| | | return teamEincomeRecordMapper.selectByPrimaryKeyForUpdate(id);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void setRecieved(Long id) {
|
| | | TeamEincomeRecord record = teamEincomeRecordMapper.selectByPrimaryKeyForUpdate(id);
|
| | | if (record != null) {
|
| | | TeamEincomeRecord update = new TeamEincomeRecord();
|
| | | update.setId(id);
|
| | | update.setRecieveTime(new Date());
|
| | | update.setState(TeamEincomeRecord.STATE_RECIEVED);
|
| | | update.setUpdateTime(new Date());
|
| | | teamEincomeRecordMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getEstimateDividents(Date preGetTime, Long uid) {
|
| | | List<Integer> typeList = new ArrayList<Integer>();
|
| | | List<TeamEincomeRecord> list = listCanRecieveRecord(preGetTime, uid, typeList);
|
| | | BigDecimal money = new BigDecimal(0);
|
| | | if (list != null)
|
| | | for (TeamEincomeRecord record : list) {
|
| | | money = money.add(record.getMoney());
|
| | | }
|
| | | return money;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Long> listCanRecieveUid(Date preRecieveTime, List<Integer> typeList, int page, int pageSize) {
|
| | | return teamEincomeRecordMapper.listCanRecieveUid(preRecieveTime, typeList, (page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countCanRecieveUid(Date preRecieveTime, List<Integer> typeList) {
|
| | | return teamEincomeRecordMapper.countCanRecieveUid(preRecieveTime, typeList);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public BigDecimal sumRecieveByType(Long uid, int type) {
|
| | | BigDecimal money = teamEincomeRecordMapper.sumRecieveByType(uid, type);
|
| | | if (money == null) {
|
| | | money = new BigDecimal(0);
|
| | | }
|
| | | return money;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.money; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.yeshi.fanli.dao.mybatis.money.TeamEincomeRecordMapper; |
| | | import com.yeshi.fanli.entity.money.TeamEincomeRecord; |
| | | import com.yeshi.fanli.exception.ParamsException; |
| | | import com.yeshi.fanli.exception.money.TeamEincomeRecordException; |
| | | import com.yeshi.fanli.service.inter.money.TeamEincomeRecordService; |
| | | |
| | | @Service |
| | | public class TeamEincomeRecordServiceImpl implements TeamEincomeRecordService { |
| | | |
| | | @Resource |
| | | private TeamEincomeRecordMapper teamEincomeRecordMapper; |
| | | |
| | | @Override |
| | | public void addTeamEincomeRecord(TeamEincomeRecord record) throws TeamEincomeRecordException, ParamsException { |
| | | if (record.getUid() == null || record.getMoney() == null || record.getType() == null |
| | | || record.getPreRecieveTime() == null) |
| | | throw new ParamsException(1, "参数不完整"); |
| | | |
| | | TeamEincomeRecord oldRecord = teamEincomeRecordMapper.selectByUidAndPreRecieveTimeAndTypeAndSourceType(record.getUid(), |
| | | record.getPreRecieveTime(), record.getType(),record.getSourceType()); |
| | | if (oldRecord != null) |
| | | throw new TeamEincomeRecordException(1, "已存在"); |
| | | if (record.getCreateTime() == null) |
| | | record.setCreateTime(new Date()); |
| | | teamEincomeRecordMapper.insertSelective(record); |
| | | } |
| | | |
| | | @Override |
| | | public List<TeamEincomeRecord> listCanRecieveRecord(Date preRecieveTime, Long uid, List<Integer> typeList) { |
| | | |
| | | return teamEincomeRecordMapper.listByUidAndPreRecieveTimeAndState(uid, preRecieveTime, typeList, |
| | | TeamEincomeRecord.STATE_NOT_RECIEVE); |
| | | } |
| | | |
| | | @Override |
| | | public TeamEincomeRecord selectByPrimaryKeyForUpdate(Long id) { |
| | | return teamEincomeRecordMapper.selectByPrimaryKeyForUpdate(id); |
| | | } |
| | | |
| | | @Transactional |
| | | @Override |
| | | public void setRecieved(Long id) { |
| | | TeamEincomeRecord record = teamEincomeRecordMapper.selectByPrimaryKeyForUpdate(id); |
| | | if (record != null) { |
| | | TeamEincomeRecord update = new TeamEincomeRecord(); |
| | | update.setId(id); |
| | | update.setRecieveTime(new Date()); |
| | | update.setState(TeamEincomeRecord.STATE_RECIEVED); |
| | | update.setUpdateTime(new Date()); |
| | | teamEincomeRecordMapper.updateByPrimaryKeySelective(update); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public BigDecimal getEstimateDividents(Date preGetTime, Long uid) { |
| | | List<Integer> typeList = new ArrayList<Integer>(); |
| | | List<TeamEincomeRecord> list = listCanRecieveRecord(preGetTime, uid, typeList); |
| | | BigDecimal money = new BigDecimal(0); |
| | | if (list != null) |
| | | for (TeamEincomeRecord record : list) { |
| | | money = money.add(record.getMoney()); |
| | | } |
| | | return money; |
| | | } |
| | | |
| | | @Override |
| | | public List<Long> listCanRecieveUid(Date preRecieveTime, List<Integer> typeList, int page, int pageSize) { |
| | | return teamEincomeRecordMapper.listCanRecieveUid(preRecieveTime, typeList, (page - 1) * pageSize, pageSize); |
| | | } |
| | | |
| | | @Override |
| | | public long countCanRecieveUid(Date preRecieveTime, List<Integer> typeList) { |
| | | return teamEincomeRecordMapper.countCanRecieveUid(preRecieveTime, typeList); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public BigDecimal sumRecieveByType(Long uid, int type) { |
| | | BigDecimal money = teamEincomeRecordMapper.sumRecieveByType(uid, type); |
| | | if (money == null) { |
| | | money = new BigDecimal(0); |
| | | } |
| | | return money; |
| | | } |
| | | |
| | | |
| | | |
| | | } |