yujian
2019-08-16 e97b71caed03d1f1aa3ae21b1ea0deac4dd9ffe0
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
49
package com.yeshi.fanli.service.impl.integral;
 
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Service;
 
import com.yeshi.fanli.dao.mybatis.integral.IntegralExchangeRecordMapper;
import com.yeshi.fanli.entity.integral.IntegralExchange;
import com.yeshi.fanli.service.inter.integral.IntegralExchangeRecordService;
import com.yeshi.fanli.service.inter.integral.IntegralExchangeService;
import com.yeshi.fanli.util.StringUtil;
 
@Service
public class IntegralExchangeRecordServiceImpl implements IntegralExchangeRecordService {
 
    @Resource
    private IntegralExchangeRecordMapper integralExchangeRecordMapper;
 
    @Resource
    private IntegralExchangeService integralExchangeService;
    
    @Override
    public List<IntegralExchange> listExchange(long start, int count, Long uid){
        List<IntegralExchange> listValid = integralExchangeService.listValidCache(start, count);
        if (listValid == null || listValid.size() == 0) {
            return listValid;
        }
        
        for(IntegralExchange integralExchange: listValid) {
            String progress = integralExchange.getProgress();
            if (StringUtil.isNullOrEmpty(progress))
                continue;
            
            // 今日兑换情况
            long exchange = integralExchangeRecordMapper.countRecordByUid(integralExchange.getId(), uid);
            
            progress = progress.replace("{已兑换}", exchange + "").replace("{上限数}", integralExchange.getUpperLimit() + "");
            integralExchange.setProgress(progress);
        }
        return listValid;
    }
    
    @Override
    public long countRecordByUid(long exchangeid, Long uid){
        return integralExchangeRecordMapper.countRecordByUid(exchangeid, uid);
    }
}