diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxGameController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxGameController.java index 2c1a488af..df4086083 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxGameController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxGameController.java @@ -117,7 +117,7 @@ public class WxGameController extends BaseController { if((playLimit > 0 && playCount >= playLimit) || playLimit < 0){ return new ResultData(ErrorCode.GAME_NOT_HAVE_COUNT); } - ResultData resultData = wxGameService.luckDraw(gameIdL, getMemberId()); + ResultData resultData = wxGameService.luckDraw(gameIdL, getMemberId(),0); removeCacheCUser(); return resultData; } catch (Exception e){ diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxGameActionLog.java b/mallinkService/src/main/java/com/iformall/domain/po/WxGameActionLog.java index 5bf60896d..c721ad690 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxGameActionLog.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxGameActionLog.java @@ -33,7 +33,7 @@ public class WxGameActionLog extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="",name="createTime") private Date createTime; - @io.swagger.annotations.ApiModelProperty(value = "", name = "type") + @io.swagger.annotations.ApiModelProperty(value = "0:免费玩1:积分玩", name = "type") private Integer type; @io.swagger.annotations.ApiModelProperty(value = "", name = "usedCredit") diff --git a/mallinkService/src/main/java/com/iformall/service/WxGameService.java b/mallinkService/src/main/java/com/iformall/service/WxGameService.java index a19dcc49c..18d470c55 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxGameService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxGameService.java @@ -59,7 +59,7 @@ public interface WxGameService { void deleteById(Long id); - ResultData luckDraw(Long gameId, Long userId); + ResultData luckDraw(Long gameId, Long userId,Integer userCredit); ResultData cridetLuckDraw(Long gameIdL, Long memberId); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java index 8081bd8b6..587ba2933 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java @@ -239,6 +239,7 @@ public class WxGameServiceImpl implements WxGameService { map.put("prizeType",0); map.put("gameWeight",couponChanObj.getInteger("weight")); map.put("credit",couponChanObj.getInteger("credit")); + map.put("couponId",couponChanObj.getLong("couponId")); couponIdsList.add(map); }else{ Long couponId = couponChanObj.getLong("couponId"); @@ -412,7 +413,7 @@ public class WxGameServiceImpl implements WxGameService { @Transactional(rollbackFor = Exception.class) @Override - public ResultData luckDraw(Long gameId,Long userId){ + public ResultData luckDraw(Long gameId,Long userId,Integer userCredit){ ResultData resultData = new ResultData(); WxGame wxGame = this.getById(gameId); List couponIdsList = wxGame.getCouponIdsList(); @@ -436,31 +437,29 @@ public class WxGameServiceImpl implements WxGameService { } } Object data = resultData.data; + Long orderId = 0L; + Integer addCredit = 0; if(data != null){ if(data instanceof Map){ Map dataMap = (Map) data; // Integer prizeType = (Integer) dataMap.get("prizeType"); // if(prizeType != null && prizeType == 0){ + Integer credit = (Integer) dataMap.get("credit"); + if(credit > 0){ WxCreditHistory wxCreditHistory = new WxCreditHistory(); wxCreditHistory.setTenantId(wxGame.getFinalTenantId()); wxCreditHistory.setCUserId(userId); wxCreditHistory.setOperatorId(userId); wxCreditHistory.setOperatorType(EnumUserType.CUSER.getCode()); - wxCreditHistory.setCreditNum((Integer) dataMap.get("credit")); + wxCreditHistory.setCreditNum(credit); wxCreditHistory.setCreditType(EnumScoreType.GAME_ADD_CREDIT.getCode()); wxCreditHistory.setChangePurpose(EnumScoreType.GAME_ADD_CREDIT.getMessage()); wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId(),wxGame) ; - WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory); - - final IdWorker idWorker = IdWorker.get(); - WxGameActionLog wxGameActionLog = new WxGameActionLog(); - wxGameActionLog.setId(idWorker.nextId()); - wxGameActionLog.setUserId(userId); - wxGameActionLog.updateTenantInfo(wxGame); - wxGameActionLog.setGameId(gameId); - wxGameActionLog.setCreateTime(new Date()); - wxGameActionLog.setAddCredit(wxCreditHistory.getCreditNum()); - wxGameActionLogMapper.insert(wxGameActionLog); + wxCreditHistoryService.saveOrUpdate(wxCreditHistory); + addCredit = credit; + orderId = -1L; + } + resultData.data = null; // } }else if(data instanceof WxCouponChannelVo){ @@ -469,25 +468,32 @@ public class WxGameServiceImpl implements WxGameService { orderSaveDto.setCouponChannelId(vo.getId()); orderSaveDto.setCouponId(vo.getCouponId()); ResultData resultData1 = wxOrderService.saveOrder(orderSaveDto, userId, EnumPayWay.PAY_WAY_WECHAT, wxGame); - Long orderId = null; + if(resultData1.code == Result.SUCCESS && resultData1.data != null && resultData1.data instanceof WxOrder){ WxOrder order = (WxOrder)resultData1.data; orderId = order.getId(); }else{ resultData.data = null; } - final IdWorker idWorker = IdWorker.get(); - WxGameActionLog wxGameActionLog = new WxGameActionLog(); - wxGameActionLog.setId(idWorker.nextId()); - wxGameActionLog.setUserId(userId); - wxGameActionLog.updateTenantInfo(wxGame); - wxGameActionLog.setGameId(gameId); - wxGameActionLog.setCreateTime(new Date()); - wxGameActionLog.setCouponOrderId(orderId); - wxGameActionLogMapper.insert(wxGameActionLog); } } + final IdWorker idWorker = IdWorker.get(); + WxGameActionLog wxGameActionLog = new WxGameActionLog(); + wxGameActionLog.setId(idWorker.nextId()); + wxGameActionLog.setUserId(userId); + wxGameActionLog.updateTenantInfo(wxGame); + wxGameActionLog.setGameId(gameId); + wxGameActionLog.setCreateTime(new Date()); + wxGameActionLog.setUsedCredit(userCredit); + if(userCredit > 0){ + wxGameActionLog.setType(1); + } + wxGameActionLog.setCouponOrderId(orderId); + wxGameActionLog.setAddCredit(addCredit); + + wxGameActionLogMapper.insert(wxGameActionLog); + return resultData; } @@ -508,7 +514,7 @@ public class WxGameServiceImpl implements WxGameService { wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId(),wxGame) ; WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory); - return this.luckDraw(gameId,userId); + return this.luckDraw(gameId,userId,wxGame.getPlayCredit()); }else{ return new ResultData(ErrorCode.GAME_NOT_C_COUNT); } diff --git a/mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml b/mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml index 715b1ed0e..772fde1ba 100644 --- a/mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml @@ -148,7 +148,7 @@