xiaoyong931011
2021-12-07 37518c255d676f17e661dfdfd6152de3405f7dcd
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
package com.xcong.excoin.modules.fish.service.impl;
 
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
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.LoginUserUtils;
import com.xcong.excoin.common.enumerates.CoinTypeEnum;
import com.xcong.excoin.common.response.Result;
import com.xcong.excoin.modules.coin.service.CoinService;
import com.xcong.excoin.modules.fish.dao.*;
import com.xcong.excoin.modules.fish.dto.*;
import com.xcong.excoin.modules.fish.entity.*;
import com.xcong.excoin.modules.fish.service.MemberCannonService;
import com.xcong.excoin.modules.fish.vo.*;
import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
import com.xcong.excoin.utils.RedisUtils;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
 
@Service
public class MemberCannonServiceImpl extends ServiceImpl<CannonOwnRecordDao, CannonOwnRecord> implements MemberCannonService {
 
    @Resource
    MemberAccountGoldDao memberAccountGoldDao;
    @Resource
    MemberWalletCoinDao memberWalletCoinDao;
    @Resource
    private MemberCannonService memberCannonService;
    @Resource
    CannonAccountMoneyChangeDao cannonAccountMoneyChangeDao;
    @Resource
    CannonOwnRecordDao cannonOwnRecordDao;
    @Resource
    CannonSettingDao cannonSettingDao;
    @Resource
    CannonGameRecordDao cannonGameRecordDao;
    @Resource
    CannonWinRecordDao cannonWinRecordDao;
    @Resource
    RedisUtils redisUtils;
    @Resource
    private CoinService coinService;
 
    @Override
    public Result coinGoldExchange(CoinGoldExchangeDto coinGoldExchangeDto) {
        BigDecimal balance = coinGoldExchangeDto.getBalance();
        if (balance.compareTo(BigDecimal.ZERO) <= 0) {
            return Result.fail("兑换金额不能小于或等于0");
        }
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        //获取兑换比例
        List<CannonExchangeRatio> cannonExchangeRatios = cannonSettingDao.selectCannonExchangeRatio();
        if(CollUtil.isEmpty(cannonExchangeRatios)){
            return Result.fail("系统繁忙请稍候重试");
        }
        CannonExchangeRatio cannonExchangeRatio = cannonExchangeRatios.get(0);
        Integer type = coinGoldExchangeDto.getType();
        //1:金币兑换1代币 2:1代币兑换金币
        if(type == 1){
            MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId);
            MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCC.name());
            if(balance.compareTo(memberAccountGold.getAvailableBalance()) > 0){
                return Result.fail("金币不足");
            }
            BigDecimal coinRatio = cannonExchangeRatio.getCoinRatio();
            BigDecimal divide = balance.divide(coinRatio).setScale(8,BigDecimal.ROUND_DOWN);
            //金币账户减少
            memberCannonService.updateTotalBalanceAndAvailableBalance(memberAccountGold.getId(),balance.negate(),balance.negate(),null);
            //代币账户增加
            coinService.updateWalletBalance(memberWalletCoinEntity.getId(),divide,divide,null);
 
            CannonAccountMoneyChange cannonAccountMoneyChange = new CannonAccountMoneyChange();
            cannonAccountMoneyChange.setMemberId(memberId);
            cannonAccountMoneyChange.setAmount(balance.negate());
            cannonAccountMoneyChange.setType(2);
            cannonAccountMoneyChange.setContent("金币兑换");
            cannonAccountMoneyChange.setChangeBalance(balance);
            cannonAccountMoneyChange.setChangeBefore(memberAccountGold.getAvailableBalance());
            cannonAccountMoneyChange.setChangeAfter(memberAccountGold.getAvailableBalance().subtract(balance));
            cannonAccountMoneyChangeDao.insert(cannonAccountMoneyChange);
        }else if(type == 2){
            MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId);
            MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCC.name());
            if(balance.compareTo(memberWalletCoinEntity.getAvailableBalance()) > 0){
                return Result.fail("代币不足");
            }
            BigDecimal coinRatio = cannonExchangeRatio.getCoinRatio();
            BigDecimal multiply = balance.multiply(coinRatio);
            //金币账户增加
            memberCannonService.updateTotalBalanceAndAvailableBalance(memberAccountGold.getId(),multiply,multiply,null);
            //代币账户减少
            coinService.updateWalletBalance(memberWalletCoinEntity.getId(),balance.negate(),balance.negate(),null);
 
            CannonAccountMoneyChange cannonAccountMoneyChange = new CannonAccountMoneyChange();
            cannonAccountMoneyChange.setMemberId(memberId);
            cannonAccountMoneyChange.setAmount(balance);
            cannonAccountMoneyChange.setType(3);
            cannonAccountMoneyChange.setContent("兑换金币");
            cannonAccountMoneyChange.setChangeBalance(balance);
            cannonAccountMoneyChange.setChangeBefore(memberWalletCoinEntity.getAvailableBalance());
            cannonAccountMoneyChange.setChangeAfter(memberWalletCoinEntity.getAvailableBalance().add(balance));
            cannonAccountMoneyChangeDao.insert(cannonAccountMoneyChange);
        }
        return Result.ok("兑换成功");
    }
 
    @Override
    public void updateTotalBalanceAndAvailableBalance(Long id, BigDecimal availableBalance,  BigDecimal totalBalance,BigDecimal frozenBalance) {
        if(id==null){
            return;
        }
        // 这里需要加锁 保证同一个时间只有一个线程操作一个钱包
        String key = "UPDATE_MEMBER_GOLD_"+id;
        while (true){
            boolean b = redisUtils.setNotExist(key, 1, 2);
            if(b){
                //System.out.println("我拿到了锁");
                // 拿到了锁才能扣
                memberAccountGoldDao.updateTotalBalanceAndAvailableBalance(id,availableBalance,totalBalance,frozenBalance);
                // 扣完释放锁
                redisUtils.del(key);
                break;
            }else {
 
            }
        }
    }
 
    @Override
    public Result getCannons(GetCannonsDto getCannonsDto) {
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        Page<CannonSettingVo> page = new Page<>(getCannonsDto.getPageNum(), getCannonsDto.getPageSize());
        CannonSetting cannonSetting = new CannonSetting();
        IPage<CannonSettingVo> list = cannonSettingDao.findCannonSettingInPage(page, cannonSetting);
        return Result.ok(list);
    }
 
    @Override
    public Result cannonExchange(CannonExchangeDto cannonExchangeDto) {
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        Long cannonId = cannonExchangeDto.getCannonId();
        CannonSetting cannonSetting = cannonSettingDao.selectById(cannonId);
        BigDecimal exchangePrice = cannonSetting.getExchangePrice();
        if(ObjectUtil.isEmpty(cannonSetting)){
            return Result.fail("炮塔不存在");
        }
        List<CannonOwnRecord> cannonOwnRecords = cannonOwnRecordDao.selectCannonOwnRecordsByMemberIdAndCannonCode(memberId,cannonSetting.getCode());
        if(CollUtil.isNotEmpty(cannonOwnRecords)){
            return Result.fail("炮塔已拥有");
        }
        //获取用户的USDT账户,可用余额总金额减少
        MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.USDT.name());
        if(exchangePrice.compareTo(memberWalletCoinEntity.getAvailableBalance()) > 0){
            return Result.fail("可用余额不足");
        }
        coinService.updateWalletBalance(memberWalletCoinEntity.getId(),exchangePrice.negate(),exchangePrice.negate(),null);
        //增加一条拥有记录【cannon_own_record】
        CannonOwnRecord cannonOwnRecord = new CannonOwnRecord();
        cannonOwnRecord.setMemberId(memberId);
        cannonOwnRecord.setCannonUuid(UUID.randomUUID().toString());
        cannonOwnRecord.setCannonCode(cannonSetting.getCode());
        cannonOwnRecord.setCannonName(cannonSetting.getName());
        cannonOwnRecord.setCannonPrice(cannonSetting.getExchangePrice());
        cannonOwnRecord.setType(1);
        cannonOwnRecordDao.insert(cannonOwnRecord);
        //增加一条买卖记录
        CannonAccountMoneyChange cannonAccountMoneyChange = new CannonAccountMoneyChange();
        cannonAccountMoneyChange.setMemberId(memberId);
        cannonAccountMoneyChange.setAmount(exchangePrice);
        cannonAccountMoneyChange.setType(1);
        cannonAccountMoneyChange.setContent("购买炮塔");
        cannonAccountMoneyChange.setChangeBalance(exchangePrice);
        cannonAccountMoneyChange.setChangeBefore(memberWalletCoinEntity.getAvailableBalance());
        cannonAccountMoneyChange.setChangeAfter(memberWalletCoinEntity.getAvailableBalance().subtract(exchangePrice));
        cannonAccountMoneyChangeDao.insert(cannonAccountMoneyChange);
        return Result.ok("购买成功");
    }
 
    @Override
    public Result goldExchange(GoldExchangeDto goldExchangeDto) {
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        BigDecimal balance = goldExchangeDto.getBalance();
        if (balance.compareTo(BigDecimal.ZERO) <= 0) {
            return Result.fail("兑换金额不能小于或等于0");
        }
        //获取兑换比例
        List<CannonExchangeRatio> cannonExchangeRatios = cannonSettingDao.selectCannonExchangeRatio();
        if(CollUtil.isEmpty(cannonExchangeRatios)){
            return Result.fail("系统繁忙请稍候重试");
        }
        CannonExchangeRatio cannonExchangeRatio = cannonExchangeRatios.get(0);
        //金币账户增加
        MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId);
        BigDecimal goldRatio = cannonExchangeRatio.getGoldRatio();
        BigDecimal multiply = balance.multiply(goldRatio);
        memberCannonService.updateTotalBalanceAndAvailableBalance(memberAccountGold.getId(),multiply,multiply,null);
        //获取用户的USDT账户,可用余额总金额减少
        MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.USDT.name());
        if(balance.compareTo(memberWalletCoinEntity.getAvailableBalance()) > 0){
            return Result.fail("可用余额不足");
        }
        coinService.updateWalletBalance(memberWalletCoinEntity.getId(),balance.negate(),balance.negate(),null);
        return Result.ok("兑换成功");
    }
 
    @Override
    public Result getGoldAccount() {
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId);
        if(ObjectUtil.isEmpty(memberAccountGold)){
            MemberAccountGold memberAccountGoldNew = new MemberAccountGold();
            memberAccountGoldNew.setMemberId(memberId);
            memberAccountGoldNew.setTotalBalance(BigDecimal.ZERO);
            memberAccountGoldNew.setAvailableBalance(BigDecimal.ZERO);
            memberAccountGoldNew.setFrozenBalance(BigDecimal.ZERO);
            memberAccountGoldDao.insert(memberAccountGoldNew);
        }
        GoldAccountVo goldAccountVo = memberAccountGoldDao.selectAccountGoldVoByMemberId(memberId);
        return Result.ok(goldAccountVo);
    }
 
    @Override
    public Result getOwnCannon() {
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        List<OwnCannonVo> cannonOwnRecords = cannonOwnRecordDao.selectCannonOwnRecordsByMemberId(memberId);
        return Result.ok(cannonOwnRecords);
    }
 
    @Override
    public Result fishing(FishingDto fishingDto) {
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        Integer goldWin = fishingDto.getGoldWin() == null?0:fishingDto.getGoldWin();
        if(goldWin < 0){
            return Result.fail("请求异常,请刷新页面");
        }
        Long cannonOwnId = fishingDto.getCannonOwnId();
        List<CannonOwnRecord> cannonOwnRecords = cannonOwnRecordDao.selectCannonOwnRecordsByIdAndMemberId(cannonOwnId,memberId);
        if(CollUtil.isEmpty(cannonOwnRecords)){
            Result.fail("请求异常,请刷新页面");
        }
        //消耗金币 = 每发炮弹的消耗 - 获得金币;
        CannonOwnRecord cannonOwnRecord = cannonOwnRecords.get(0);
        CannonSetting cannonSetting = cannonSettingDao.selectCannonSettingByCannonCode(cannonOwnRecord.getCannonCode());
        BigDecimal goldConsume = cannonSetting.getGoldConsume().subtract(new BigDecimal(goldWin)).setScale(0,BigDecimal.ROUND_DOWN);
        MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId);
        memberCannonService.updateTotalBalanceAndAvailableBalance(memberAccountGold.getId(),goldConsume.negate(),goldConsume.negate(),null);
        //增加一条游戏记录
        CannonGameRecord cannonGameRecord = new CannonGameRecord();
        cannonGameRecord.setMemberId(memberId);
        cannonGameRecord.setCannonOwnId(cannonOwnRecord.getId());
        cannonGameRecord.setCannonName(cannonOwnRecord.getCannonName());
        cannonGameRecord.setCannonCode(cannonOwnRecord.getCannonCode());
        cannonGameRecord.setGoldConsume(cannonSetting.getGoldConsume());
        cannonGameRecord.setGoldReward(new BigDecimal(goldWin));
        cannonGameRecordDao.insert(cannonGameRecord);
 
        return Result.ok("success");
    }
 
    @Override
    public Result getAccountAvaBanlace() {
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId);
        MemberWalletCoinEntity memberWalletCoinEntityXCC = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCC.name());
        MemberWalletCoinEntity memberWalletCoinEntityUSDT = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.USDT.name());
        AccountAvaBanlaceVo accountAvaBanlaceVo = new AccountAvaBanlaceVo();
//        accountAvaBanlaceVo.setMemberId(memberId);
        accountAvaBanlaceVo.setGoldAvailableBalance(memberAccountGold.getAvailableBalance() == null?BigDecimal.ZERO:memberAccountGold.getAvailableBalance());
        accountAvaBanlaceVo.setCoinAvailableBalance(memberWalletCoinEntityXCC.getAvailableBalance() == null?BigDecimal.ZERO:memberWalletCoinEntityXCC.getAvailableBalance());
        accountAvaBanlaceVo.setUsdtAvailableBalance(memberWalletCoinEntityUSDT.getAvailableBalance() == null?BigDecimal.ZERO:memberWalletCoinEntityUSDT.getAvailableBalance());
        return Result.ok(accountAvaBanlaceVo);
    }
 
    @Override
    public Result getAwards() {
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
 
//        Long memberId = 1L;
        AwardsVo awardsVo = cannonOwnRecordDao.getAwards();
        return Result.ok(awardsVo);
    }
 
    @Override
    public Result lotteryDraw(LotteryDrawDto lotteryDrawDto) {
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
 
//        Long memberId = 1L;
        //获取每次抽奖需要的USDT数量
        CannonAwardSet cannonAwardSet = cannonOwnRecordDao.getCannonAwardSet();
        if(ObjectUtil.isEmpty(cannonAwardSet)){
            Result.fail("活动还没开始,请稍候");
        }
        BigDecimal consume = cannonAwardSet.getConsume() == null ? BigDecimal.ZERO : cannonAwardSet.getConsume();
        if(consume.compareTo(BigDecimal.ZERO) <= 0){
            Result.fail("活动还没开始,请稍候");
        }
        //验证账户USDT余额是否足够
        MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.USDT.name());
        BigDecimal availableBalance = memberWalletCoinEntity.getAvailableBalance() == null ? BigDecimal.ZERO : memberWalletCoinEntity.getAvailableBalance();
        if(availableBalance.compareTo(consume) < 0){
            Result.fail("用户USDT余额不足");
        }
        //用户USDT余额减少
        coinService.updateWalletBalance(memberWalletCoinEntity.getId(),consume.negate(),consume.negate(),null);
        //增加一条抽奖记录
        CannonAccountMoneyChange cannonAccountMoneyChange = new CannonAccountMoneyChange();
        cannonAccountMoneyChange.setMemberId(memberId);
        cannonAccountMoneyChange.setAmount(consume);
        cannonAccountMoneyChange.setType(4);
        cannonAccountMoneyChange.setContent("抽奖");
        cannonAccountMoneyChange.setChangeBalance(consume);
        cannonAccountMoneyChange.setChangeBefore(memberWalletCoinEntity.getAvailableBalance());
        cannonAccountMoneyChange.setChangeAfter(memberWalletCoinEntity.getAvailableBalance().subtract(consume));
        cannonAccountMoneyChangeDao.insert(cannonAccountMoneyChange);
        //抽奖品
        CannonAwardVo award = getAward(memberId);
 
        CannonWinRecord cannonWinRecord = new CannonWinRecord();
        cannonWinRecord.setMemberId(memberId);
        cannonWinRecord.setAwardName(award.getName()+"*"+award.getQuantity());
        cannonWinRecord.setConsumeNum(consume);
        cannonWinRecordDao.insert(cannonWinRecord);
        return Result.ok(award);
    }
 
    private CannonAwardVo getAward(Long memberId) {
        CannonAwardVo cannonAwardVo = new CannonAwardVo();
        //获取所有的奖品列表
        List<CannonAward> cannonAwards = cannonOwnRecordDao.selectCannonAward();
        if(CollUtil.isNotEmpty(cannonAwards)){
            CannonAward cannonAward = RandomUtil.randomEle(cannonAwards);
            //获得金币
            if("GOLD".equals(cannonAward.getCode())){
                BigDecimal quantity = new BigDecimal(cannonAward.getQuantity());
                MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId);
                memberCannonService.updateTotalBalanceAndAvailableBalance(memberAccountGold.getId(),quantity,quantity,null);
                cannonAwardVo.setName(cannonAward.getName());
                cannonAwardVo.setQuantity(cannonAward.getQuantity());
            }else if("COIN".equals(cannonAward.getCode())){
                BigDecimal quantity = new BigDecimal(cannonAward.getQuantity());
                MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCC.name());
                coinService.updateWalletBalance(memberWalletCoinEntity.getId(),quantity,quantity,null);
                cannonAwardVo.setName(cannonAward.getName());
                cannonAwardVo.setQuantity(cannonAward.getQuantity());
            }else if("USDT".equals(cannonAward.getCode())){
                BigDecimal quantity = new BigDecimal(cannonAward.getQuantity());
                MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.USDT.name());
                coinService.updateWalletBalance(memberWalletCoinEntity.getId(),quantity,quantity,null);
                cannonAwardVo.setName(cannonAward.getName());
                cannonAwardVo.setQuantity(cannonAward.getQuantity());
            }else{
                CannonSetting cannonSetting = cannonSettingDao.selectCannonSettingByCannonCode(cannonAward.getCode());
                List<CannonOwnRecord> cannonOwnRecords = cannonOwnRecordDao.selectCannonOwnRecordsByMemberIdAndCannonCode(memberId, cannonAward.getCode());
                Integer cannonAccountMoneyChanges = cannonOwnRecordDao.selectCannonAccountMoneyChangeByMemberId(memberId);
                //抽奖次数小于十次的抽不到炮台
                if(CollUtil.isEmpty(cannonOwnRecords) && cannonAccountMoneyChanges > 10){
                    //增加一条拥有记录【cannon_own_record】
                    CannonOwnRecord cannonOwnRecord = new CannonOwnRecord();
                    cannonOwnRecord.setMemberId(memberId);
                    cannonOwnRecord.setCannonUuid(UUID.randomUUID().toString());
                    cannonOwnRecord.setCannonCode(cannonSetting.getCode());
                    cannonOwnRecord.setCannonName(cannonSetting.getName());
                    cannonOwnRecord.setCannonPrice(cannonSetting.getExchangePrice());
                    cannonOwnRecord.setType(1);
                    cannonOwnRecordDao.insert(cannonOwnRecord);
 
                    cannonAwardVo.setName(cannonAward.getName());
                    cannonAwardVo.setQuantity(cannonAward.getQuantity());
                }else{
                    CannonAward cannonAwardGold = cannonOwnRecordDao.selectCannonAwardByCode("GOLD");
                    BigDecimal quantity = new BigDecimal(cannonAwardGold.getQuantity());
                    MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId);
                    memberCannonService.updateTotalBalanceAndAvailableBalance(memberAccountGold.getId(),quantity,quantity,null);
                    cannonAwardVo.setName(cannonAwardGold.getName());
                    cannonAwardVo.setQuantity(cannonAwardGold.getQuantity());
                }
            }
        }
 
        return cannonAwardVo;
    }
 
 
 
    public static void main(String[] args) {
    }
 
 
}