Browse Source

youxi

release_toaliyun_real
xhxu 5 years ago
parent
commit
03f8e28ef0
1 changed files with 44 additions and 33 deletions
  1. +44
    -33
      mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java

+ 44
- 33
mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java View File

@@ -422,8 +422,14 @@ public class WxGameServiceImpl implements WxGameService {
int y = 0;
if(couponIdsList != null || couponIdsList.size() > 0){
for (Object a:couponIdsList) {
Map map= new org.apache.commons.beanutils.BeanMap(a);
int weight = (int) map.get("gameWeight");
int weight = 0;
if(a instanceof Map){
Map map = (Map) a;
weight = (int) map.get("gameWeight");
}else if(a instanceof WxCouponChannelVo){
WxCouponChannelVo vo = (WxCouponChannelVo) a;
weight = vo.getGameWeight();
}
y += weight;
if(x <= y){
resultData.data = a;
@@ -433,36 +439,21 @@ public class WxGameServiceImpl implements WxGameService {
}
Object data = resultData.data;
if(data != null){
Map dataMap= new org.apache.commons.beanutils.BeanMap(data);
Integer prizeType = (Integer) dataMap.get("prizeType");
if(prizeType != null && prizeType == 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.setCreditType(EnumScoreType.GAME_ADD_CREDIT.getCode());
wxCreditHistory.setChangePurpose(EnumScoreType.GAME_ADD_CREDIT.getMessage());
wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId(),wxGame) ;
WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory);
if(data instanceof Map){
Map dataMap = (Map) data;
// Integer prizeType = (Integer) dataMap.get("prizeType");
// if(prizeType != null && prizeType == 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.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);
}else{
OrderSaveDto orderSaveDto = new OrderSaveDto();
orderSaveDto.setCouponChannelId((Long)dataMap.get("id"));
orderSaveDto.setCouponId((Long)dataMap.get("couponId"));
ResultData resultData1 = wxOrderService.saveOrder(orderSaveDto, userId, EnumPayWay.PAY_WAY_WECHAT, wxGame);
if(resultData1.code == Result.SUCCESS && resultData1.data != null){
Map map1= new org.apache.commons.beanutils.BeanMap(resultData1.data);
final IdWorker idWorker = IdWorker.get();
WxGameActionLog wxGameActionLog = new WxGameActionLog();
wxGameActionLog.setId(idWorker.nextId());
@@ -470,12 +461,32 @@ public class WxGameServiceImpl implements WxGameService {
wxGameActionLog.updateTenantInfo(wxGame);
wxGameActionLog.setGameId(gameId);
wxGameActionLog.setCreateTime(new Date());
wxGameActionLog.setCouponOrderId((Long)map1.get("id"));
wxGameActionLog.setAddCredit(wxCreditHistory.getCreditNum());
wxGameActionLogMapper.insert(wxGameActionLog);
// }

}else if(data instanceof WxCouponChannelVo){
WxCouponChannelVo vo = (WxCouponChannelVo) data;
OrderSaveDto orderSaveDto = new OrderSaveDto();
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{
return resultData1;
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);
}

}


Loading…
Cancel
Save