sud小游戏-门票-付费
This commit is contained in:
@@ -44,8 +44,6 @@ public class AutoGenRobotService extends BaseService {
|
||||
@Autowired
|
||||
private AutoGenRobotMapper autoGenRobotMapper;
|
||||
@Autowired
|
||||
private ErBanNetEaseService erBanNetEaseService;
|
||||
@Autowired
|
||||
private AccountMapper accountMapper;
|
||||
@Autowired
|
||||
private NetEaseService netEaseService;
|
||||
|
@@ -49,6 +49,7 @@ public class UploadAvatarService extends BaseService {
|
||||
@Autowired
|
||||
private SendSysMsgService sendSysMsgService;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private RoomService roomService;
|
||||
@Autowired
|
||||
private GuildService guildService;
|
||||
|
@@ -1,20 +1,32 @@
|
||||
package com.accompany.business.service.miniGame.impl;
|
||||
|
||||
import com.accompany.business.dto.miniGame.MiniGameLudoConfigDto;
|
||||
import com.accompany.business.service.purse.UserPurseService;
|
||||
import com.accompany.business.service.record.BillRecordService;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.core.enumeration.BillObjTypeEnum;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.SysConfService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Service
|
||||
public class MiniGameLudoService {
|
||||
|
||||
@Autowired
|
||||
private SysConfService sysConfService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private MiniGameLudoTicketService ticketService;
|
||||
|
||||
|
||||
public MiniGameLudoConfigDto getConfig(){
|
||||
String configStr = sysConfService.getSysConfValueById(Constant.SysConfId.MINI_GAME_SUD_LUDO_CONFIG);
|
||||
@@ -35,4 +47,16 @@ public class MiniGameLudoService {
|
||||
}
|
||||
|
||||
|
||||
public void payTicket(Long uid, String mgId, Long roomUid) {
|
||||
Users u = usersService.getNotNullUsersByUid(uid);
|
||||
MiniGameLudoConfigDto partitionConfigDto = getConfigByPartitionId(u.getPartitionId());
|
||||
if (!partitionConfigDto.getMgIdStr().equals(mgId)){
|
||||
return;
|
||||
}
|
||||
BigDecimal ticket = partitionConfigDto.getTicket();
|
||||
if (BigDecimal.ZERO.compareTo(ticket) >= 0){
|
||||
return;
|
||||
}
|
||||
ticketService.pay(uid, u.getPartitionId(), mgId, roomUid, ticket);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,40 @@
|
||||
package com.accompany.business.service.miniGame.impl;
|
||||
|
||||
import com.accompany.business.service.purse.UserPurseService;
|
||||
import com.accompany.business.service.record.BillRecordService;
|
||||
import com.accompany.core.enumeration.BillObjTypeEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.redisson.api.RMap;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MiniGameLudoTicketService {
|
||||
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
@Autowired
|
||||
private UserPurseService userPurseService;
|
||||
@Autowired
|
||||
private BillRecordService billRecordService;
|
||||
|
||||
public void pay(Long uid, Integer partitionId, String mgId, Long roomUid, BigDecimal ticket) {
|
||||
String objId = String.join("_", mgId, partitionId.toString(), roomUid.toString());
|
||||
userPurseService.subGold(uid, ticket.doubleValue(), BillObjTypeEnum.MINI_GAME_LUDO_TICKET_OUT,
|
||||
(up)-> billRecordService.insertGeneralBillRecord(uid, objId, BillObjTypeEnum.MINI_GAME_LUDO_TICKET_OUT, ticket.doubleValue(), up));
|
||||
|
||||
Integer once = 1;
|
||||
Integer afterNum = getTicketCountCacheMap(objId).addAndGet(uid, once);
|
||||
Integer beforeNum = afterNum - once;
|
||||
log.info("[miniGameLudoTicket] uid {} mgId {} partitionId {} roomUid {} beforeNum {} afterNum {}",
|
||||
uid, mgId, partitionId, roomUid, beforeNum, afterNum);
|
||||
}
|
||||
|
||||
public RMap<Long, Integer> getTicketCountCacheMap(String key) {
|
||||
return redissonClient.getMap(key);
|
||||
}
|
||||
}
|
@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -40,6 +41,7 @@ public class MiniGameServiceImpl extends ServiceImpl<MiniGameMapper, MiniGame> i
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private RoomService roomService;
|
||||
@Autowired
|
||||
private MiniGameLudoService miniGameLudoService;
|
||||
|
@@ -160,8 +160,6 @@ public class RoomService extends BaseService {
|
||||
@Lazy
|
||||
private SuperAdminWebService superAdminWebService;
|
||||
@Autowired
|
||||
private LevelService levelService;
|
||||
@Autowired
|
||||
private DfaService dfaService;
|
||||
@Autowired
|
||||
private RobotV2Service robotV2Service;
|
||||
@@ -174,6 +172,7 @@ public class RoomService extends BaseService {
|
||||
@Autowired
|
||||
private MiniGameRoomService miniGameRoomService;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private MiniGameService miniGameService;
|
||||
@Autowired
|
||||
private MiniGameSwitchRecordService miniGameSwitchRecordService;
|
||||
|
@@ -0,0 +1,43 @@
|
||||
package com.accompany.business.controller.miniGame;
|
||||
|
||||
import com.accompany.business.service.miniGame.impl.MiniGameLudoService;
|
||||
import com.accompany.common.annotation.Authorization;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.core.base.UidContextHolder;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Api(tags = "sud小游戏")
|
||||
@RestController
|
||||
@RequestMapping("/miniGame")
|
||||
public class MiniGamePayTicketController {
|
||||
|
||||
@Autowired
|
||||
private MiniGameLudoService service;
|
||||
|
||||
@ApiOperation("付门票")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "mgId", value = "游戏id", required = true),
|
||||
@ApiImplicitParam(name = "roomUid", value = "房间uid", required = true),
|
||||
})
|
||||
@Authorization
|
||||
@PostMapping("/payTicket")
|
||||
public BusiResult<Void> payTicket(String mgId, Long roomUid){
|
||||
if(!StringUtils.hasText(mgId) || roomUid==null){
|
||||
throw new ServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
Long uid = UidContextHolder.get();
|
||||
service.payTicket(uid, mgId, roomUid);
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user