xiaoyong931011
2021-11-26 985b96889f292288405f0fc5241b78abbe9c67d1
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package com.xcong.excoin.modules.fish.service.impl;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xcong.excoin.common.entity.FebsResponse;
import com.xcong.excoin.common.entity.QueryRequest;
import com.xcong.excoin.modules.fish.entity.CannonAccountMoneyChange;
import com.xcong.excoin.modules.fish.entity.CannonExchangeRatio;
import com.xcong.excoin.modules.fish.entity.CannonSetting;
import com.xcong.excoin.modules.fish.mapper.CannonExchangeRatioMapper;
import com.xcong.excoin.modules.fish.mapper.CannonSettingMapper;
import com.xcong.excoin.modules.fish.service.FishService;
import com.xcong.excoin.modules.fish.vo.CannonAccountMoneyChangeVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
 
@Slf4j
@Service
@RequiredArgsConstructor
public class FishServiceImpl extends ServiceImpl<CannonExchangeRatioMapper, CannonExchangeRatio> implements FishService {
 
    private final CannonExchangeRatioMapper cannonExchangeRatioMapper;
    private final CannonSettingMapper cannonSettingMapper;
 
    @Override
    public IPage<CannonExchangeRatio> exchangeRatio(CannonExchangeRatio cannonExchangeRatio, QueryRequest request) {
        Page<CannonExchangeRatio> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<CannonExchangeRatio> cannonExchangeRatioIPage = cannonExchangeRatioMapper.findExchangeRatioInPage(page, cannonExchangeRatio);
        return cannonExchangeRatioIPage;
    }
 
    @Override
    public CannonExchangeRatio getExchangeRatioInfoById(long id) {
        CannonExchangeRatio cannonExchangeRatio = cannonExchangeRatioMapper.selectById(id);
        return cannonExchangeRatio;
    }
 
    @Override
    public IPage<CannonSetting> cannonList(CannonSetting cannonSetting, QueryRequest request) {
        Page<CannonSetting> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<CannonSetting> cannonSettingIPage = cannonExchangeRatioMapper.findCannonSettingInPage(page, cannonSetting);
        return cannonSettingIPage;
    }
 
    @Override
    public void cannonAdd(CannonSetting cannonSetting) {
        CannonSetting cannonSettingNew = new CannonSetting();
        cannonSettingNew.setName(cannonSetting.getName());
        cannonSettingNew.setCode(cannonSetting.getCode());
        cannonSettingNew.setExchangePrice(cannonSetting.getExchangePrice());
        cannonSettingNew.setGoldConsume(cannonSetting.getGoldConsume());
        cannonSettingNew.setCannonImg(cannonSetting.getCannonImg());
        cannonSettingNew.setBulletImg(cannonSettingNew.getBulletImg());
        cannonSettingMapper.insert(cannonSettingNew);
    }
 
    @Override
    public CannonSetting getCannonInfoById(long id) {
        return cannonSettingMapper.selectById(id);
    }
 
    @Override
    public FebsResponse cannonUpdate(CannonSetting cannonSetting) {
        cannonSettingMapper.updateById(cannonSetting);
        return new FebsResponse().success();
    }
 
    @Override
    public FebsResponse exchangeRatioUpdate(CannonExchangeRatio cannonExchangeRatio) {
        Long id = cannonExchangeRatio.getId();
        CannonExchangeRatio cannonExchangeRatioOld = cannonExchangeRatioMapper.selectById(id);
        cannonExchangeRatioOld.setCoinRatio(cannonExchangeRatio.getCoinRatio());
        cannonExchangeRatioMapper.updateById(cannonExchangeRatioOld);
        return new FebsResponse().success();
    }
 
    @Override
    public IPage<CannonAccountMoneyChangeVo> accountList(CannonAccountMoneyChange cannonAccountMoneyChange, QueryRequest request) {
 
        Page<CannonAccountMoneyChangeVo> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<CannonAccountMoneyChangeVo> cannonAccountMoneyChangeVoIPage =
                cannonExchangeRatioMapper.findCannonAccountMoneyChangeInPage(page, cannonAccountMoneyChange);
        return cannonAccountMoneyChangeVoIPage;
    }
 
}