|
@@ -1,29 +1,38 @@
|
|
|
package com.game.business.controller;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.game.business.domain.AppUser;
|
|
|
+import com.game.business.domain.AppUserAgent;
|
|
|
import com.game.business.domain.AppUserCount;
|
|
|
-import com.game.business.dto.AppAgentEditDto;
|
|
|
-import com.game.business.dto.AppAgentTeamDto;
|
|
|
+import com.game.business.domain.FinTranRecord;
|
|
|
+import com.game.business.dto.*;
|
|
|
import com.game.business.service.IAppUserAgentService;
|
|
|
-import com.game.business.dto.AgentIndexDTO;
|
|
|
import com.game.business.service.IAppUserCountService;
|
|
|
import com.game.business.service.IAppUserService;
|
|
|
+import com.game.business.service.IFinTranRecordService;
|
|
|
import com.game.business.vo.AppAgentTeamVo;
|
|
|
import com.game.business.vo.AppUserAgentJournalIndexVO;
|
|
|
+import com.game.business.vo.AppUserTeamTranserRecordVo;
|
|
|
import com.game.common.core.controller.BaseController;
|
|
|
import com.game.common.core.domain.HttpRet;
|
|
|
import com.game.common.core.domain.HttpRetPageArr;
|
|
|
+import com.game.common.core.page.TableDataInfo;
|
|
|
import com.game.common.utils.MessageUtils;
|
|
|
import com.game.common.utils.SecurityUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
@@ -40,6 +49,10 @@ public class AppAgentController extends BaseController {
|
|
|
@Autowired
|
|
|
private IAppUserAgentService appUserAgentService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IFinTranRecordService finTranRecordService;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
* 首页
|
|
|
*/
|
|
@@ -59,6 +72,7 @@ public class AppAgentController extends BaseController {
|
|
|
String formatP = "yyyy-MM-dd";
|
|
|
Date beginDate = DateUtil.beginOfMonth(nowDate);
|
|
|
Date endDate = DateUtil.endOfMonth(nowDate);
|
|
|
+
|
|
|
List<AppUserCount> appUserCountList = appUserCountService.getAppUserCount(userId,DateUtil.format(beginDate,formatP),DateUtil.format(endDate,formatP));
|
|
|
|
|
|
if(null != appUserCountList){
|
|
@@ -113,4 +127,119 @@ public class AppAgentController extends BaseController {
|
|
|
return HttpRetPageArr.success(MessageUtils.message("11022"),getDataTable(list));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 团队转账
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/transfer")
|
|
|
+ @ApiOperation(value = "团队转账", notes = "团队转账")
|
|
|
+ public HttpRet<Boolean> transfer(@RequestBody @Validated AppUserTeamTranserDto transerDto)
|
|
|
+ {
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<AppUserAgent> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(AppUserAgent::getUserId,userId);
|
|
|
+ queryWrapper.eq(AppUserAgent::getAuditStatus,1);
|
|
|
+ AppUserAgent appUserAgent = appUserAgentService.getOne(queryWrapper);
|
|
|
+ if(null == appUserAgent){
|
|
|
+ return HttpRet.fail("转账失败,受益人不是代理");
|
|
|
+ }
|
|
|
+ if(appUserAgent.getPid().longValue() == 0 || isTwoLevel(appUserAgent.getPid())){
|
|
|
+ List<AppUserAgent> appUserAgentList = appUserAgentService.selectAllAgentList(userId,transerDto.getToUserId());
|
|
|
+ if(null == appUserAgentList || appUserAgentList.size() < 1){
|
|
|
+ return HttpRet.fail("转账失败,只能给团队成员转账");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(!isTeam(userId,transerDto.getToUserId())){
|
|
|
+ return HttpRet.fail("转账失败,只能给下级成员转账");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return finTranRecordService.transfer(transerDto);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 团队转账记录
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/transferRecord")
|
|
|
+ @ApiOperation(value = "团队转账记录(分页)", notes = "团队转账记录(分页)")
|
|
|
+ public HttpRetPageArr<AppUserTeamTranserRecordVo> transferRecord(@RequestBody @Validated AppUserTeamTranserRecordDto transerDto)
|
|
|
+ {
|
|
|
+ startPage();
|
|
|
+ List<FinTranRecord> list = finTranRecordService.transferRecord(transerDto);
|
|
|
+ TableDataInfo<FinTranRecord> tableDataInfo = getDataTable(list);
|
|
|
+ TableDataInfo resultDataInfo = new TableDataInfo();
|
|
|
+ BeanUtils.copyProperties(tableDataInfo,resultDataInfo);
|
|
|
+ if(null != tableDataInfo.getRows() && tableDataInfo.getRows().size() > 0){
|
|
|
+ List<AppUser> appUsers = null;
|
|
|
+ if(0 == transerDto.getType()){
|
|
|
+
|
|
|
+ appUsers = appUserService.selectListByIds(
|
|
|
+ tableDataInfo.getRows().stream().map(e->e.getFromUid()).collect(Collectors.toList())
|
|
|
+ );
|
|
|
+ }else{
|
|
|
+
|
|
|
+ appUsers = appUserService.selectListByIds(
|
|
|
+ tableDataInfo.getRows().stream().map(e->e.getToUid()).collect(Collectors.toList())
|
|
|
+ );
|
|
|
+ }
|
|
|
+ Map<String,AppUser> userMap = new HashMap<>();
|
|
|
+ if(null != appUsers && appUsers.size() > 0){
|
|
|
+ userMap = appUsers.stream().collect(Collectors.toMap(e->{return String.valueOf(e.getUserid());}, Function.identity(),(k1,k2)->k2));
|
|
|
+ }
|
|
|
+ Map<String, AppUser> finalUserMap = userMap;
|
|
|
+ resultDataInfo.setRows(tableDataInfo.getRows().stream().map(e->{
|
|
|
+ AppUserTeamTranserRecordVo vo = new AppUserTeamTranserRecordVo();
|
|
|
+ vo.setMoney(e.getDiamondCoinChange());
|
|
|
+ vo.setTime(e.getCreateTime());
|
|
|
+ AppUser appUser = null;
|
|
|
+ if(0 == transerDto.getType()){
|
|
|
+
|
|
|
+ long userId = e.getToUid();
|
|
|
+ appUser = finalUserMap.get(String.valueOf(userId));
|
|
|
+ vo.setUserId(userId);
|
|
|
+ if(null != appUser){
|
|
|
+ vo.setNickName(appUser.getUsername());
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+
|
|
|
+ long userId = e.getFromUid();
|
|
|
+ appUser = finalUserMap.get(String.valueOf(userId));
|
|
|
+ vo.setUserId(userId);
|
|
|
+ if(null != appUser){
|
|
|
+ vo.setNickName(appUser.getUsername());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+ }else{
|
|
|
+ resultDataInfo.setRows(new ArrayList());
|
|
|
+ }
|
|
|
+ return HttpRetPageArr.success(MessageUtils.message("11022"),resultDataInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private boolean isTeam(Long pid,Long userId){
|
|
|
+
|
|
|
+ LambdaQueryWrapper<AppUserAgent> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(AppUserAgent::getUserId,userId);
|
|
|
+ queryWrapper.eq(AppUserAgent::getAuditStatus,1);
|
|
|
+ AppUserAgent appUserAgent = appUserAgentService.getOne(queryWrapper);
|
|
|
+ if(null != appUserAgent && appUserAgent.getPid().longValue() == pid){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 查询是否为第二级代理
|
|
|
+ * */
|
|
|
+ private boolean isTwoLevel(Long userId){
|
|
|
+ LambdaQueryWrapper<AppUserAgent> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(AppUserAgent::getUserId,userId);
|
|
|
+ AppUserAgent appUserAgent = appUserAgentService.getOne(queryWrapper);
|
|
|
+ if(appUserAgent.getPid().longValue() == 0){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
}
|