|
@@ -23,6 +23,7 @@ import com.game.common.core.domain.HttpRet;
|
|
|
import com.game.common.core.domain.HttpRetPageArr;
|
|
|
import com.game.common.core.domain.R;
|
|
|
import com.game.common.core.redis.RedisCache;
|
|
|
+import com.game.common.exception.ServiceException;
|
|
|
import com.game.common.utils.MoneyUtils;
|
|
|
import com.game.common.utils.SecurityUtils;
|
|
|
import com.game.common.utils.StringUtils;
|
|
@@ -79,7 +80,7 @@ public class AppUserCountDividendController extends BaseController
|
|
|
public HttpRetPageArr<AppUserCountDividend> list(AppUserDividendListDto dto)
|
|
|
{
|
|
|
startPage();
|
|
|
- List<AppUserCountDividend> list = appUserCountDividendService.selectUserDividendList(SecurityUtils.getUserId());
|
|
|
+ List<AppUserCountDividend> list = appUserCountDividendService.selectUserDividendList(SecurityUtils.getUserId(),null,null);
|
|
|
return HttpRetPageArr.success("查询成功", getDataTable(list));
|
|
|
}
|
|
|
|
|
@@ -98,119 +99,134 @@ public class AppUserCountDividendController extends BaseController
|
|
|
if(null == userId && StringUtils.isBlank(dateNo)){
|
|
|
return HttpRet.fail("发放失败,参数为空");
|
|
|
}
|
|
|
- LambdaQueryWrapper<AppUserCountDividend> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- if(StringUtils.isNotBlank(dateNo)){
|
|
|
- queryWrapper.eq(AppUserCountDividend::getDateNo,dateNo);
|
|
|
- }
|
|
|
- if(null != userId){
|
|
|
- queryWrapper.eq(AppUserCountDividend::getUserId,userId);
|
|
|
- }
|
|
|
- queryWrapper.eq(AppUserCountDividend::getStatus,0);
|
|
|
- List<AppUserCountDividend> dividendList = appUserCountDividendService.list(queryWrapper);
|
|
|
+ List<AppUserCountDividend> dividendList = appUserCountDividendService.selectUserDividendList(SecurityUtils.getUserId(), org.apache.commons.lang3.StringUtils.isBlank(userId)?null:Long.parseLong(userId),dateNo);
|
|
|
if(null == dividendList || dividendList.size() < 1){
|
|
|
return HttpRet.fail("发放失败,不存在或已发放");
|
|
|
}
|
|
|
- AppUser curUser = appUserService.selectAppUserByUserid(curUserId);
|
|
|
+
|
|
|
if(curUser.getDiamondCoin() < dividendList.stream().mapToDouble(e->e.getDiamondCoin()).sum()){
|
|
|
return HttpRet.fail("发放失败,余额不足");
|
|
|
}
|
|
|
if(curUser.getCoin() < dividendList.stream().mapToDouble(e->e.getCoin()).sum()){
|
|
|
return HttpRet.fail("发放失败,金币不足");
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
List<Long> ids = dividendList.stream().map(AppUserCountDividend::getUserId).collect(Collectors.toList());
|
|
|
List<AppUser> userList = appUserService.selectListByIds(ids);
|
|
|
if(null != userList && userList.size()>0) {
|
|
|
Map<String, AppUser> userMap = userList.stream().collect(Collectors.toMap(e -> String.valueOf(e.getUserid()), Function.identity(), (k1, k2) -> k2));
|
|
|
- dividendList.forEach(e->{
|
|
|
- List<FinTranRecord> tranRecordList = new ArrayList<>();
|
|
|
- AppUser appUser = userMap.get(String.valueOf(e.getUserId()));
|
|
|
-
|
|
|
- AppUser curUpdateAppUser = new AppUser();
|
|
|
-
|
|
|
- if(null != e.getDiamondCoin() && e.getDiamondCoin()>0){
|
|
|
-
|
|
|
-
|
|
|
- curUser.setDiamondCoin(curUser.getDiamondCoin() - e.getDiamondCoin());
|
|
|
- curUser.setDiamondCoinTotal(curUser.getDiamondCoinTotal() - e.getDiamondCoin());
|
|
|
- curUpdateAppUser.setUserid(curUser.getUserid());
|
|
|
- curUpdateAppUser.setDiamondCoinCash(curUser.getDiamondCoinCash());
|
|
|
- curUpdateAppUser.setDiamondCoin(curUser.getDiamondCoin());
|
|
|
- curUpdateAppUser.setDiamondCoinTotal(curUser.getDiamondCoinTotal());*/
|
|
|
-
|
|
|
- FinTranAddedInfo curAddedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
|
|
|
- FinTranRecord curTran = FinTranRecord.initFinTranRecordSomeParams(curAddedInfo, FinTranType3.AGENT_DIVIDED, FinTranType1.U_Outcome_Balance, curUser);
|
|
|
- curTran.setDiamondCoinChange(e.getDiamondCoin() * -1);
|
|
|
-
|
|
|
- curTran.setCurrencyType(TranCurrencyType.Balance.getType());
|
|
|
- curTran.setRemarks(e.getDateNo() + " 发放团队分红奖励");
|
|
|
- curTran.setFromUid(curUserId);
|
|
|
- tranRecordList.add(curTran);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- updateAppUser.setDiamondCoinTotal(appUser.getDiamondCoinTotal() + e.getDiamondCoin());
|
|
|
- updateAppUser.setDiamondCoinCash(appUser.getDiamondCoinCash() + e.getDiamondCoin());*/
|
|
|
-
|
|
|
- FinTranAddedInfo addedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
|
|
|
- FinTranRecord tran = FinTranRecord.initFinTranRecordSomeParams(addedInfo, FinTranType3.AGENT_DIVIDED, FinTranType1.Agent_Income_Diamond_Coin, appUser);
|
|
|
- tran.setDiamondCoinChange(e.getDiamondCoin());
|
|
|
- tran.setAfterDiamondCoin(appUser.getDiamondCoin() + e.getDiamondCoin());
|
|
|
- tran.setCurrencyType(TranCurrencyType.Balance.getType());
|
|
|
- tran.setRemarks(e.getDateNo() + " 团队周分红奖励");
|
|
|
- tran.setFromUid(curUserId);
|
|
|
- tranRecordList.add(tran);
|
|
|
- }
|
|
|
- if(null != e.getCoin() && e.getCoin()>0){
|
|
|
-
|
|
|
-
|
|
|
- curUser.setCoin(curUser.getCoin() - e.getCoin());
|
|
|
- curUpdateAppUser.setUserid(curUser.getUserid());
|
|
|
- curUpdateAppUser.setCoinCash(curUser.getCoinCash());
|
|
|
- curUpdateAppUser.setCoin(curUser.getCoin());*/
|
|
|
-
|
|
|
- FinTranAddedInfo curAddedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
|
|
|
- FinTranRecord curTran = FinTranRecord.initFinTranRecordSomeParams(curAddedInfo, FinTranType3.AGENT_DIVIDED, FinTranType1.U_Outcome_Coin, curUser);
|
|
|
- curTran.setDiamondCoinChange(e.getDiamondCoin() * -1);
|
|
|
-
|
|
|
- curTran.setCurrencyType(TranCurrencyType.Coin.getType());
|
|
|
- curTran.setRemarks(e.getDateNo() + " 发放团队分红奖励");
|
|
|
- curTran.setFromUid(curUserId);
|
|
|
- tranRecordList.add(curTran);
|
|
|
+ String errMsg = "";
|
|
|
+ for(AppUserCountDividend countDividend : dividendList){
|
|
|
+ Long errUserId = countDividend.getUserId();
|
|
|
+ try {
|
|
|
+ List<FinTranRecord> tranRecordList = new ArrayList<>();
|
|
|
+ AppUser appUser = userMap.get(countDividend.getUserId());
|
|
|
+ AppUser curUser = appUserService.selectAppUserByUserid(curUserId);
|
|
|
+ if(!curUserId.equals(appUser.getPid())){
|
|
|
+ throw new ServiceException("只能给直属团队成员发放");
|
|
|
+ }
|
|
|
+
|
|
|
+ AppUser curUpdateAppUser = new AppUser();
|
|
|
+
|
|
|
+ if (null != countDividend.getDiamondCoin() && countDividend.getDiamondCoin() > 0) {
|
|
|
+ if(null != countDividend.getDiamondCoin() && appUser.getDiamondCoin() < countDividend.getDiamondCoin()){
|
|
|
+ throw new ServiceException("余额不足");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ curUser.setDiamondCoin(curUser.getDiamondCoin() - e.getDiamondCoin());
|
|
|
+ curUser.setDiamondCoinTotal(curUser.getDiamondCoinTotal() - e.getDiamondCoin());
|
|
|
+ curUpdateAppUser.setUserid(curUser.getUserid());
|
|
|
+ curUpdateAppUser.setDiamondCoinCash(curUser.getDiamondCoinCash());
|
|
|
+ curUpdateAppUser.setDiamondCoin(curUser.getDiamondCoin());
|
|
|
+ curUpdateAppUser.setDiamondCoinTotal(curUser.getDiamondCoinTotal());*/
|
|
|
+
|
|
|
+ FinTranAddedInfo curAddedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
|
|
|
+ FinTranRecord curTran = FinTranRecord.initFinTranRecordSomeParams(curAddedInfo, FinTranType3.AGENT_DIVIDED, FinTranType1.U_Outcome_Balance, curUser);
|
|
|
+ curTran.setDiamondCoinChange(countDividend.getDiamondCoin() * -1);
|
|
|
+
|
|
|
+ curTran.setCurrencyType(TranCurrencyType.Balance.getType());
|
|
|
+ curTran.setRemarks(countDividend.getDateNo() + " 发放团队分红奖励");
|
|
|
+ curTran.setFromUid(curUserId);
|
|
|
+ tranRecordList.add(curTran);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- FinTranAddedInfo addedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
|
|
|
- FinTranRecord tran = FinTranRecord.initFinTranRecordSomeParams(addedInfo, FinTranType3.AGENT_DIVIDED, FinTranType1.Agent_Income_Coin, appUser);
|
|
|
- tran.setDiamondCoinChange(e.getDiamondCoin());
|
|
|
-
|
|
|
- tran.setCurrencyType(TranCurrencyType.Coin.getType());
|
|
|
- tran.setRemarks(e.getDateNo() + " 团队周分红奖励");
|
|
|
- tran.setFromUid(curUserId);
|
|
|
- tranRecordList.add(tran);
|
|
|
- }
|
|
|
-
|
|
|
- appUserService.updateAppUser(curUpdateAppUser);*/
|
|
|
-
|
|
|
-
|
|
|
- if(tranRecordList.size() > 0){
|
|
|
-
|
|
|
-
|
|
|
- appUserService.updateUserAmount(t);
|
|
|
- });*/
|
|
|
- for(FinTranRecord finTranRecord :tranRecordList){
|
|
|
- try {
|
|
|
- appUserService.updateUserAmount(finTranRecord);
|
|
|
- } catch (Exception ex) {
|
|
|
- throw new RuntimeException(ex);
|
|
|
+
|
|
|
+
|
|
|
+ updateAppUser.setDiamondCoinTotal(appUser.getDiamondCoinTotal() + e.getDiamondCoin());
|
|
|
+ updateAppUser.setDiamondCoinCash(appUser.getDiamondCoinCash() + e.getDiamondCoin());*/
|
|
|
+
|
|
|
+ FinTranAddedInfo addedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
|
|
|
+ FinTranRecord tran = FinTranRecord.initFinTranRecordSomeParams(addedInfo, FinTranType3.AGENT_DIVIDED, FinTranType1.Agent_Income_Diamond_Coin, appUser);
|
|
|
+ tran.setDiamondCoinChange(countDividend.getDiamondCoin());
|
|
|
+ tran.setAfterDiamondCoin(appUser.getDiamondCoin() + countDividend.getDiamondCoin());
|
|
|
+ tran.setCurrencyType(TranCurrencyType.Balance.getType());
|
|
|
+ tran.setRemarks(countDividend.getDateNo() + " 团队周分红奖励");
|
|
|
+ tran.setFromUid(curUserId);
|
|
|
+
|
|
|
+ appUserService.updateUserAmount(tran);
|
|
|
+ }
|
|
|
+ if (null != countDividend.getCoin() && countDividend.getCoin() > 0) {
|
|
|
+ if(null != countDividend.getCoin() && appUser.getCoin() < countDividend.getCoin()){
|
|
|
+ throw new ServiceException("金币不足");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ curUser.setCoin(curUser.getCoin() - e.getCoin());
|
|
|
+ curUpdateAppUser.setUserid(curUser.getUserid());
|
|
|
+ curUpdateAppUser.setCoinCash(curUser.getCoinCash());
|
|
|
+ curUpdateAppUser.setCoin(curUser.getCoin());*/
|
|
|
+
|
|
|
+ FinTranAddedInfo curAddedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
|
|
|
+ FinTranRecord curTran = FinTranRecord.initFinTranRecordSomeParams(curAddedInfo, FinTranType3.AGENT_DIVIDED, FinTranType1.U_Outcome_Coin, curUser);
|
|
|
+ curTran.setDiamondCoinChange(countDividend.getDiamondCoin() * -1);
|
|
|
+
|
|
|
+ curTran.setCurrencyType(TranCurrencyType.Coin.getType());
|
|
|
+ curTran.setRemarks(countDividend.getDateNo() + " 发放团队分红奖励");
|
|
|
+ curTran.setFromUid(curUserId);
|
|
|
+ tranRecordList.add(curTran);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ FinTranAddedInfo addedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
|
|
|
+ FinTranRecord tran = FinTranRecord.initFinTranRecordSomeParams(addedInfo, FinTranType3.AGENT_DIVIDED, FinTranType1.Agent_Income_Coin, appUser);
|
|
|
+ tran.setDiamondCoinChange(countDividend.getDiamondCoin());
|
|
|
+
|
|
|
+ tran.setCurrencyType(TranCurrencyType.Coin.getType());
|
|
|
+ tran.setRemarks(countDividend.getDateNo() + " 团队周分红奖励");
|
|
|
+ tran.setFromUid(curUserId);
|
|
|
+ appUserService.updateUserAmount(tran);
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+ appUserService.updateAppUser(curUpdateAppUser);*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ *
|
|
|
+
|
|
|
+ appUserService.updateUserAmount(t);
|
|
|
+ });*
|
|
|
+ for(FinTranRecord finTranRecord :tranRecordList){
|
|
|
+ try {
|
|
|
+ appUserService.updateUserAmount(finTranRecord);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ throw new RuntimeException(ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ AppUserCountDividend userCountDividend = new AppUserCountDividend();
|
|
|
+ userCountDividend.setId(countDividend.getId());
|
|
|
+ userCountDividend.setStatus(1);
|
|
|
+ appUserCountDividendService.updateAppUserCountDividend(userCountDividend);
|
|
|
+ }catch (Exception ex){
|
|
|
+ errMsg = "发放失败:".concat(ex.getMessage());
|
|
|
+ logger.info("{}发放失败:{}",errUserId,ex.getMessage());
|
|
|
+ break;
|
|
|
}
|
|
|
- AppUserCountDividend userCountDividend = new AppUserCountDividend();
|
|
|
- userCountDividend.setId(e.getId());
|
|
|
- userCountDividend.setStatus(1);
|
|
|
- appUserCountDividendService.updateAppUserCountDividend(userCountDividend);
|
|
|
- });
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(errMsg)){
|
|
|
+ return HttpRet.fail(errMsg);
|
|
|
+ }
|
|
|
}
|
|
|
return HttpRet.success("发放成功",true);
|
|
|
|