fix
Helius
2021-09-15 7ab7943de217a9e5d4a489c22c7ae27a29692d55
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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;
    }
 
}