yujian
2019-08-14 2e5c6b46697f7b96460ad0c356740df52bf056d2
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
50
51
52
package com.yeshi.fanli.service.impl.integral;
 
import java.util.ArrayList;
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;
        }
        
        List<Long> listId = new ArrayList<Long>();
        for(IntegralExchange integralExchange: listValid) {
            listId.add(integralExchange.getId());
        }
        
        List<Long> listRecord = integralExchangeRecordMapper.listRecordByExchangeIds(listId);
        for(IntegralExchange integralExchange: listValid) {
            String progress = integralExchange.getProgress();
            if (StringUtil.isNullOrEmpty(progress))
                continue;
            
            int exchange = 0;
            if (listRecord != null && listRecord.size() >0 && listRecord.contains(integralExchange.getId()))
                exchange = 1;
            
            progress = progress.replace("{已兑换}", exchange + "").replace("{上限数}", integralExchange.getUpperLimit() + "");
            integralExchange.setProgress(progress);
        }
        return listValid;
    }
}