|
@@ -2,14 +2,20 @@ package com.game.business.controller;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
-import com.game.business.domain.AppGameBetting;
|
|
|
+import com.game.business.domain.*;
|
|
|
+import com.game.business.dto.AppGameItemDTO;
|
|
|
+import com.game.business.service.IAppGameClassifyService;
|
|
|
+import com.game.business.service.IAppGameService;
|
|
|
import com.game.business.vo.AppGameBettingVO;
|
|
|
import com.game.business.vo.AppGameItemVO;
|
|
|
import com.game.common.core.domain.HttpRetArr;
|
|
|
import com.game.common.core.domain.R;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -27,7 +33,6 @@ import com.game.common.core.domain.AjaxResult;
|
|
|
import com.game.common.enums.BusinessType;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import com.game.business.domain.AppGameItem;
|
|
|
import com.game.business.service.IAppGameItemService;
|
|
|
import com.game.common.utils.poi.ExcelUtil;
|
|
|
import com.game.common.core.page.TableDataInfo;
|
|
@@ -46,6 +51,12 @@ public class AppGameItemController extends BaseController
|
|
|
@Autowired
|
|
|
private IAppGameItemService appGameItemService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IAppGameClassifyService appGameClassifyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IAppGameService appGameService;
|
|
|
+
|
|
|
|
|
|
* 查询游戏选项列表
|
|
|
*/
|
|
@@ -166,4 +177,62 @@ public class AppGameItemController extends BaseController
|
|
|
{
|
|
|
return R.ok(appGameItemService.deleteAppGameItemByIds(ids));
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 同步游戏选项
|
|
|
+ */
|
|
|
+ @Log(title = "同步游戏选项", businessType = BusinessType.UPDATE)
|
|
|
+ @ApiOperation(value = "同步游戏选项", notes = "同步游戏选项")
|
|
|
+ @PostMapping("/synItem")
|
|
|
+ public R synItem(@RequestBody AppGameItemDTO appGameItemDTO)
|
|
|
+ {
|
|
|
+ if(StringUtils.isBlank(appGameItemDTO.getClassId())){
|
|
|
+ return R.fail("平台ID为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ AppGameClassify appGameClassify = appGameClassifyService.getByCode(appGameItemDTO.getClassId());
|
|
|
+
|
|
|
+ if(appGameClassify == null){
|
|
|
+ return R.fail("平台ID不正确");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(appGameItemDTO.getGameId())){
|
|
|
+ return R.fail("平台不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ AppGame appGame = appGameService.selectAppGameByClassIdAndCode(appGameClassify.getId(), appGameItemDTO.getGameId());
|
|
|
+
|
|
|
+ if(appGame == null){
|
|
|
+ return R.fail("游戏不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(appGameItemDTO.getConfig())){
|
|
|
+ return R.fail("游戏赔率配置为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ AppGameItem appGameItem = new AppGameItem();
|
|
|
+ appGameItem.setGameId(appGame.getId());
|
|
|
+ List<AppGameItem> itemList = appGameItemService.selectAppGameItemList(appGameItem);
|
|
|
+ if(itemList == null || itemList.isEmpty()){
|
|
|
+ return R.fail("游戏未配置选项设置");
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] configArry = appGameItemDTO.getConfig().split(",");
|
|
|
+
|
|
|
+ if(itemList.size() != configArry.length){
|
|
|
+ return R.fail("游戏赔率配置长度与选项长度不一致");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Collections.sort(itemList, Comparator.comparing(AppGameItem::getItemLocation));
|
|
|
+
|
|
|
+ for (int i = 0; i < itemList.size(); i++) {
|
|
|
+ AppGameItem gameItem = itemList.get(i);
|
|
|
+ gameItem.setItemMultiple(Integer.valueOf(configArry[i]));
|
|
|
+ appGameItemService.updateAppGameItem(gameItem);
|
|
|
+ }
|
|
|
+ return R.ok("同步成功");
|
|
|
+ }
|
|
|
}
|