|
@@ -1,19 +1,27 @@
|
|
|
package com.game.business.controller;
|
|
|
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
+import com.game.business.domain.AppGame;
|
|
|
+import com.game.business.domain.AppGameBetting;
|
|
|
+import com.game.business.domain.AppGameCommission;
|
|
|
+import com.game.business.dto.AppUserAgentDTO;
|
|
|
+import com.game.business.service.IAppGameCommissionService;
|
|
|
+import com.game.business.service.IAppGameService;
|
|
|
+import com.game.business.vo.AppGameBettingDetailsCountVO;
|
|
|
+import com.game.business.vo.AppGameCommissionVO;
|
|
|
+import com.game.business.vo.AppUserAgentVO;
|
|
|
+import com.game.common.annotation.Anonymous;
|
|
|
+import com.game.common.core.domain.HttpRet;
|
|
|
+import com.game.common.core.domain.HttpRetPageArr;
|
|
|
import com.game.common.core.domain.R;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import com.game.common.annotation.Log;
|
|
|
import com.game.common.core.controller.BaseController;
|
|
|
import com.game.common.core.domain.AjaxResult;
|
|
@@ -39,77 +47,151 @@ public class AppUserAgentController extends BaseController
|
|
|
@Autowired
|
|
|
private IAppUserAgentService appUserAgentService;
|
|
|
|
|
|
- /**
|
|
|
- * 查询用户代理表列表
|
|
|
- */
|
|
|
- @PreAuthorize("@ss.hasPermi('business:agent:list')")
|
|
|
- @GetMapping("/list")
|
|
|
- @ApiOperation(value = "查询用户代理表列表", notes = "获取用户代理表列表")
|
|
|
- public TableDataInfo<AppUserAgent> list(AppUserAgent appUserAgent)
|
|
|
- {
|
|
|
- startPage();
|
|
|
- List<AppUserAgent> list = appUserAgentService.selectAppUserAgentList(appUserAgent);
|
|
|
- return getDataTable(list);
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ private IAppGameCommissionService appGameCommissionService;
|
|
|
|
|
|
- /**
|
|
|
- * 导出用户代理表列表
|
|
|
- */
|
|
|
- @PreAuthorize("@ss.hasPermi('business:agent:export')")
|
|
|
- @Log(title = "用户代理表", businessType = BusinessType.EXPORT)
|
|
|
- @PostMapping("/export")
|
|
|
- @ApiOperation(value = "导出用户代理表列表", notes = "导出用户代理表列表")
|
|
|
- public void export(HttpServletResponse response, AppUserAgent appUserAgent)
|
|
|
- {
|
|
|
- List<AppUserAgent> list = appUserAgentService.selectAppUserAgentList(appUserAgent);
|
|
|
- ExcelUtil<AppUserAgent> util = new ExcelUtil<AppUserAgent>(AppUserAgent.class);
|
|
|
- util.exportExcel(response, list, "用户代理表数据");
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ private IAppGameService appGameService;
|
|
|
|
|
|
- /**
|
|
|
- * 获取用户代理表详细信息
|
|
|
- */
|
|
|
- @PreAuthorize("@ss.hasPermi('business:agent:query')")
|
|
|
- @GetMapping(value = "/{id}")
|
|
|
- @ApiOperation(value = "获取用户代理表详细信息", notes = "获取用户代理表详细信息")
|
|
|
- public R<AppUserAgent> getInfo(@PathVariable("id") Long id)
|
|
|
- {
|
|
|
- return R.ok(appUserAgentService.selectAppUserAgentById(id));
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * 新增用户代理表
|
|
|
- */
|
|
|
- @PreAuthorize("@ss.hasPermi('business:agent:add')")
|
|
|
- @Log(title = "用户代理表", businessType = BusinessType.INSERT)
|
|
|
- @ApiOperation(value = "新增用户代理表", notes = "新增用户代理表")
|
|
|
- @PostMapping
|
|
|
- public R add(@RequestBody AppUserAgent appUserAgent)
|
|
|
+ @Anonymous
|
|
|
+ @PostMapping("/add")
|
|
|
+ @ApiOperation(value = "添加代理", notes = "添加代理")
|
|
|
+ public HttpRet addAgent(@RequestBody AppUserAgentDTO appUserAgent)
|
|
|
{
|
|
|
- return R.ok(appUserAgentService.insertAppUserAgent(appUserAgent));
|
|
|
+ if(appUserAgent == null){
|
|
|
+ return HttpRet.fail("代理数据为空。");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(appUserAgent.getPid() == null){
|
|
|
+ return HttpRet.fail("上级代理ID为空。");
|
|
|
+ }
|
|
|
+
|
|
|
+ AppUserAgent userAgent = new AppUserAgent();
|
|
|
+ userAgent.setUserId(appUserAgent.getUserId());
|
|
|
+ List<AppUserAgent> list = appUserAgentService.selectAppUserAgentList(userAgent);
|
|
|
+
|
|
|
+ if(list != null && !list.isEmpty()){
|
|
|
+ return HttpRet.fail("当前用户已经是代理。");
|
|
|
+ }
|
|
|
+
|
|
|
+ AppUserAgent pUserAgent = new AppUserAgent();
|
|
|
+ pUserAgent.setUserId(appUserAgent.getPid());
|
|
|
+ List<AppUserAgent> pList = appUserAgentService.selectAppUserAgentList(pUserAgent);
|
|
|
+
|
|
|
+ if(pList == null || pList.isEmpty()){
|
|
|
+ return HttpRet.fail("上级代理不存在或不是代理。");
|
|
|
+ }
|
|
|
+
|
|
|
+ AppUserAgent dbPuserAgent = pList.get(0);
|
|
|
+ AppUserAgent dbUserAgent = new AppUserAgent();
|
|
|
+ BeanUtils.copyProperties(appUserAgent, dbUserAgent);
|
|
|
+
|
|
|
+ dbUserAgent.setTopId(dbPuserAgent.getTopId());
|
|
|
+ dbUserAgent.setAuditStatus("0");
|
|
|
+ dbUserAgent.setCreateTime(new Date());
|
|
|
+ dbUserAgent.setId(IdUtil.getSnowflakeNextId());
|
|
|
+ appUserAgentService.insertAppUserAgent(dbUserAgent);
|
|
|
+
|
|
|
+ if(appUserAgent.getCommissions() != null && !appUserAgent.getCommissions().isEmpty()){
|
|
|
+ List<AppGameCommission> commissionList = appUserAgent.getCommissions();
|
|
|
+ for(AppGameCommission commission : commissionList){
|
|
|
+ if(commission.getPid() == null){
|
|
|
+ commission.setPid(appUserAgent.getPid());
|
|
|
+ }
|
|
|
+ commission.setId(IdUtil.getSnowflakeNextId());
|
|
|
+ appGameCommissionService.insertAppGameCommission(commission);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return HttpRet.success("添加成功");
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 修改用户代理表
|
|
|
- */
|
|
|
- @PreAuthorize("@ss.hasPermi('business:agent:edit')")
|
|
|
- @Log(title = "用户代理表", businessType = BusinessType.UPDATE)
|
|
|
- @ApiOperation(value = "修改用户代理表", notes = "修改用户代理表")
|
|
|
- @PutMapping
|
|
|
- public R edit(@RequestBody AppUserAgent appUserAgent)
|
|
|
+ @Anonymous
|
|
|
+ @PostMapping("/update")
|
|
|
+ @ApiOperation(value = "修改代理", notes = "修改代理")
|
|
|
+ public HttpRet updateAgent(@RequestBody AppUserAgentDTO appUserAgent)
|
|
|
{
|
|
|
- return R.ok(appUserAgentService.updateAppUserAgent(appUserAgent));
|
|
|
+
|
|
|
+ AppUserAgent dbUserAgent = new AppUserAgent();
|
|
|
+ dbUserAgent.setLiveRate(appUserAgent.getLiveRate());
|
|
|
+ dbUserAgent.setDividendGuaranteeRate(appUserAgent.getDividendGuaranteeRate());
|
|
|
+ dbUserAgent.setUpdateTime(new Date());
|
|
|
+ appUserAgentService.updateAppUserAgent(dbUserAgent);
|
|
|
+
|
|
|
+ if(appUserAgent.getCommissions() != null && !appUserAgent.getCommissions().isEmpty()){
|
|
|
+ List<AppGameCommission> commissionList = appUserAgent.getCommissions();
|
|
|
+ for(AppGameCommission commission : commissionList){
|
|
|
+ if(commission.getId() == null){
|
|
|
+ if(commission.getPid() == null){
|
|
|
+ commission.setPid(appUserAgent.getPid());
|
|
|
+ }
|
|
|
+ commission.setId(IdUtil.getSnowflakeNextId());
|
|
|
+ appGameCommissionService.insertAppGameCommission(commission);
|
|
|
+ }else{
|
|
|
+ appGameCommissionService.updateAppGameCommission(commission);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return HttpRet.success("修改成功");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 删除用户代理表
|
|
|
+ * 游戏输赢详情列表
|
|
|
*/
|
|
|
- @PreAuthorize("@ss.hasPermi('business:agent:remove')")
|
|
|
- @Log(title = "用户代理表", businessType = BusinessType.DELETE)
|
|
|
- @ApiOperation(value = "删除用户代理表", notes = "删除用户代理表")
|
|
|
- @DeleteMapping("/{ids}")
|
|
|
- public R remove(@PathVariable Long[] ids)
|
|
|
+ @Anonymous
|
|
|
+ @PostMapping(value = "/getUserAgent")
|
|
|
+ @ApiOperation(value = "获取代理成员设置", notes = "获取代理成员设置")
|
|
|
+ public HttpRet<AppUserAgentVO> getListByGameId(@RequestParam(name = "pid") Long pid, @RequestParam(name = "userId") Long userId)
|
|
|
{
|
|
|
- return R.ok(appUserAgentService.deleteAppUserAgentByIds(ids));
|
|
|
+ AppUserAgent userAgent = new AppUserAgent();
|
|
|
+ userAgent.setPid(pid);
|
|
|
+ userAgent.setUserId(userId);
|
|
|
+ List<AppUserAgent> userAgents = appUserAgentService.selectAppUserAgentList(userAgent);
|
|
|
+
|
|
|
+ if(userAgents == null || userAgents.isEmpty()){
|
|
|
+ return HttpRet.fail("代理信息不存在。");
|
|
|
+ }
|
|
|
+
|
|
|
+ AppUserAgentVO appUserAgentVO = new AppUserAgentVO();
|
|
|
+ BeanUtils.copyProperties(userAgents.get(0), appUserAgentVO);
|
|
|
+
|
|
|
+ AppGameCommission appGameCommission = new AppGameCommission();
|
|
|
+ appGameCommission.setPid(pid);
|
|
|
+ appGameCommission.setUserId(userId);
|
|
|
+ List<AppGameCommission> gameCommissions = appGameCommissionService.selectAppGameCommissionList(appGameCommission);
|
|
|
+ Map<Long, List<AppGameCommission>> idGameMap = null;
|
|
|
+ if(gameCommissions != null && !gameCommissions.isEmpty()){
|
|
|
+ idGameMap = gameCommissions.stream().collect(Collectors.groupingBy(AppGameCommission::getGameId));
|
|
|
+ }else{
|
|
|
+ idGameMap = new HashMap<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<AppGameCommissionVO> gameCommissionVOList = new ArrayList<>();
|
|
|
+ List<AppGame> gameList = appGameService.selectAppGameList(new AppGame());
|
|
|
+ if(gameList != null && !gameList.isEmpty()){
|
|
|
+ for (int i = 0; i < gameList.size(); i++) {
|
|
|
+ AppGame appGame = gameList.get(i);
|
|
|
+
|
|
|
+
|
|
|
+ AppGameCommissionVO appGameCommissionVO = new AppGameCommissionVO();
|
|
|
+
|
|
|
+ if(idGameMap.containsKey(appGame.getId())){
|
|
|
+ AppGameCommission gameCommission = idGameMap.get(appGame.getId()).get(0);
|
|
|
+ BeanUtils.copyProperties(gameCommission, appGameCommissionVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ appGameCommissionVO.setGameId(appGame.getId());
|
|
|
+ appGameCommissionVO.setGameName(appGame.getName());
|
|
|
+ appGameCommissionVO.setLogoUrl(appGame.getLogoUrl());
|
|
|
+ appGameCommissionVO.setGamePath(appGame.getGamePath());
|
|
|
+
|
|
|
+ gameCommissionVOList.add(appGameCommissionVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ appUserAgentVO.setCommissions(gameCommissionVOList);
|
|
|
+ return HttpRet.success("查询成功", appUserAgentVO);
|
|
|
}
|
|
|
}
|