幸运礼物完善
This commit is contained in:
parent
cb0da0ab2d
commit
ea9cf1913e
@ -62,15 +62,7 @@ import java.io.Serializable;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -219,7 +211,28 @@ public class GameLuckyGiftCommon {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public void run(GameLuckyGiftParamCmd cmd) {
|
public void run(GameLuckyGiftParamCmd cmd) {
|
||||||
runLuckyGiftGame(cmd);
|
// runLuckyGiftGame(cmd);
|
||||||
|
runLuckyGiftGameNew(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抽奖.
|
||||||
|
*/
|
||||||
|
private void runLuckyGiftGameNew(GameLuckyGiftParamCmd cmd) {
|
||||||
|
// 组装幸运礼物参数
|
||||||
|
GameLuckyGiftParam param = toBuildGameLuckyGift(cmd);
|
||||||
|
log.info("runLuckyGiftGame param:{}", JSON.toJSONString(param));
|
||||||
|
if (Objects.isNull(param)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> orderIds = List.of("LG_" + param.getId().toString());
|
||||||
|
ThirdPartyLotteryResult apiResult = callThirdPartyLotteryApi(param, orderIds);
|
||||||
|
|
||||||
|
Integer totalAwardAmount = apiResult.getOrderResults().stream().mapToInt(OrderResult::getRewardNum).sum();
|
||||||
|
|
||||||
|
// 保存幸运礼物流水
|
||||||
|
sendMessageNew(param, Long.valueOf(String.valueOf(totalAwardAmount)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -301,6 +314,45 @@ public class GameLuckyGiftCommon {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理用户连续赠送幸运礼物奖励逻辑
|
||||||
|
*/
|
||||||
|
private void sendMessageNew(GameLuckyGiftParam param, Long awardAmount) {
|
||||||
|
|
||||||
|
long payAmount = param.getQuantity() * param.getGift().getGiftCandy().longValue();
|
||||||
|
int multiple = (int) (awardAmount / payAmount);
|
||||||
|
|
||||||
|
gameLuckyGiftCountService.save(new GameLuckyGiftCount()
|
||||||
|
.setId(param.getId())
|
||||||
|
.setGiftId(param.getGiftId())
|
||||||
|
.setRoomId(param.getRoomId())
|
||||||
|
.setQuantity(param.getQuantity())
|
||||||
|
.setUserId(param.getUserId())
|
||||||
|
.setSysOrigin(param.getSysOrigin())
|
||||||
|
.setGiftIncCount(param.getGiftsCount())
|
||||||
|
.setGiftCombos(param.getComboCount())
|
||||||
|
.setGiftCover(param.getGift().getGiftPhoto())
|
||||||
|
.setPayAmount(payAmount)
|
||||||
|
.setMultiple(multiple)
|
||||||
|
.setChangeInventory(false)
|
||||||
|
.setSysGiftIncCount(param.getTemplate().getGiftGiveTotal())
|
||||||
|
.setAwardAmount(awardAmount)
|
||||||
|
.setRegionCode(param.getRoomRegionCode())
|
||||||
|
.setDateNumber(ZonedDateTimeAsiaRiyadhUtils.nowDateToInt())
|
||||||
|
);
|
||||||
|
|
||||||
|
if (awardAmount <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送中奖金币
|
||||||
|
BigDecimal balance = sendGold(param.getUserId(), param.getSysOrigin(), awardAmount);
|
||||||
|
|
||||||
|
// 发送中奖通知
|
||||||
|
sendMsg(param, multiple, balance);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开启全部模式的情况下抽奖.
|
* 开启全部模式的情况下抽奖.
|
||||||
*
|
*
|
||||||
@ -770,6 +822,7 @@ public class GameLuckyGiftCommon {
|
|||||||
private ThirdPartyLotteryResult createFailedResult() {
|
private ThirdPartyLotteryResult createFailedResult() {
|
||||||
ThirdPartyLotteryResult result = new ThirdPartyLotteryResult();
|
ThirdPartyLotteryResult result = new ThirdPartyLotteryResult();
|
||||||
result.setSuccess(false);
|
result.setSuccess(false);
|
||||||
|
result.setOrderResults(Collections.emptyList());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user