package com.xzx.gc.system.service;
|
|
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.util.NumberUtil;
|
import com.xzx.gc.common.constant.Constants;
|
import com.xzx.gc.entity.AccountLog;
|
import com.xzx.gc.system.mapper.AccountLogMapper;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.List;
|
|
@Service
|
@Transactional
|
public class AccountLogService {
|
|
@Autowired
|
private AccountLogMapper accountLogMapper;
|
|
|
/**
|
* 根据类型查询
|
* @param channelType
|
* @return
|
*/
|
public List<AccountLog> findByChannelType(Short channelType){
|
List<AccountLog> accountLogs = accountLogMapper.findByChannelType(channelType);
|
for (AccountLog accountLog : accountLogs) {
|
accountLog.setMoney(Convert.toStr(NumberUtil.sub(Convert.toBigDecimal(accountLog.getOldMoney(),Constants.MONEY_INIT),Convert.toBigDecimal(accountLog.getNewMoney(),Constants.MONEY_INIT))));
|
}
|
return accountLogs;
|
}
|
|
/**
|
* 根据类型查询昨天的数据
|
* @param channelType
|
* @return
|
*/
|
public List<AccountLog> findByChannelTypeAndTime(Short channelType){
|
List<AccountLog> accountLogs = accountLogMapper.findByChannelTypeAndTime(channelType);
|
for (AccountLog accountLog : accountLogs) {
|
accountLog.setMoney(Convert.toStr(NumberUtil.sub(Convert.toBigDecimal(accountLog.getOldMoney(),Constants.MONEY_INIT),Convert.toBigDecimal(accountLog.getNewMoney(),Constants.MONEY_INIT))));
|
}
|
return accountLogs;
|
}
|
|
}
|