ソースを参照

邀请奖励、直播收益

gogs 2 ヶ月 前
コミット
c194f52a72

+ 8 - 2
game-business/src/main/java/com/game/business/controller/AppAgentController.java

@@ -133,7 +133,7 @@ public class AppAgentController extends BaseController {
 
             //计算当前用户分红
             double winLose = appUserCountList.stream().mapToDouble(e->{
-               return e.getGameLoseAmount() - (e.getGameWinAmount() - (e.getGameBetting() - e.getGameLoseAmount())) - e.getGameCommission() - e.getRechargeGive();
+               return e.getGameLoseAmount() - (e.getGameWinAmount() - (e.getGameBetting() - e.getGameLoseAmount())) - e.getGameCommission() - e.getRechargeGive() - e.getRechargeCommission() - e.getWithdrawalCommission();
             }).sum();
 
             if(winLose > 0){
@@ -187,6 +187,12 @@ public class AppAgentController extends BaseController {
                 compareTime(e.getCreateTime(),DateUtil.beginOfMonth(new Date()),DateUtil.endOfMonth(new Date()))
         ).collect(Collectors.toList()).size());
 
+        //直播收益
+        Long finalUserId = userId;
+        vo.setLiveProfit(BigDecimal.valueOf(appUserCountList.stream().filter(e->e.getUserId().equals(finalUserId)).mapToDouble(e->e.getLiveProfit()).sum()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
+        //直播邀请奖励
+        vo.setLiveInvite(BigDecimal.valueOf(appUserCountList.stream().filter(e->e.getUserId().equals(finalUserId)).mapToDouble(e->e.getLiveInvite()).sum()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
+
         return HttpRet.success(MessageUtils.message("11022"),vo);
     }
 
@@ -208,7 +214,7 @@ public class AppAgentController extends BaseController {
     public HttpRetPageArr<AppAgentTeamVo> teamList(@RequestBody AppAgentTeamDto teamDto)
     {
 
-        startPageBySize(10);//每页最多10条
+//        startPageBySize(10);//每页最多10条
         List<AppAgentTeamVo> list = appUserAgentService.teamList(teamDto);
         return HttpRetPageArr.success(MessageUtils.message("11022"),getDataTable(list));
     }

+ 17 - 0
game-business/src/main/java/com/game/business/controller/FinTranRecordController.java

@@ -6,10 +6,15 @@ import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
 
 import com.alibaba.fastjson2.JSONObject;
+import com.game.business.dto.FinTranDto;
 import com.game.business.dto.FinTranRecordDTO;
 import com.game.business.service.IAppGameBettingService;
 import com.game.business.service.IAppUserService;
+import com.game.business.vo.FinTranVo;
+import com.game.common.core.domain.HttpRetArr;
+import com.game.common.core.domain.HttpRetPageArr;
 import com.game.common.core.domain.R;
+import com.game.common.utils.MessageUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -150,4 +155,16 @@ public class FinTranRecordController extends BaseController
     {
         return toAjax(finTranRecordService.deleteFinTranRecordByIds(ids));
     }
+
+    /**
+     * 查询消费记录列表
+     */
+    @PostMapping("/selectTranList")
+    @ApiOperation(value = "查询直播收益、邀请奖励列表", notes = "查询直播收益、邀请奖励列表")
+    public HttpRetPageArr<FinTranVo> selectTranList(@RequestBody FinTranDto finTranDto)
+    {
+        startPage();
+        List<FinTranVo> list = finTranRecordService.selectTranList(finTranDto);
+        return HttpRetPageArr.success(MessageUtils.message("11022"),getDataTable(list));
+    }
 }

+ 10 - 0
game-business/src/main/java/com/game/business/domain/AppUserCount.java

@@ -76,6 +76,16 @@ public class AppUserCount {
     @ApiModelProperty(value = "直播佣金")
     private Double liveCommission;
 
+    @Excel(name = "直播佣金")
+    @TableField(value = "live_profit")
+    @ApiModelProperty(value = "直播收益")
+    private Double liveProfit;
+
+    @Excel(name = "直播邀请奖励")
+    @TableField(value = "live_invite")
+    @ApiModelProperty(value = "直播邀请奖励")
+    private Double liveInvite;
+
     @Excel(name = "游戏-下注金额")
     @TableField(value = "game_betting")
     @ApiModelProperty(value = "游戏-下注金额")

+ 1 - 1
game-business/src/main/java/com/game/business/dto/AgentIndexDTO.java

@@ -8,7 +8,7 @@ import lombok.Data;
 @ApiModel("代理首页接口")
 public class AgentIndexDTO {
 
-    @ApiModelProperty(value = "类型 0:本月  1:上月  不传默认查询本月")
+    @ApiModelProperty(value = "类型 0:本期  1:上期  不传默认查询本月")
     private int type = 0;
 
     @ApiModelProperty(value = "用户id,不传则查询本账号信息")

+ 43 - 0
game-business/src/main/java/com/game/business/dto/FinTranDto.java

@@ -0,0 +1,43 @@
+package com.game.business.dto;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+@ApiModel(value = "交易记录")
+public class FinTranDto implements Serializable {
+
+    @ApiModelProperty(value = "用户id,不传则查询当前用户")
+    private Long userId;
+
+    @ApiModelProperty(value = "类型 0:本期  1:上期  不传默认查询本月")
+    private Integer type = 0;
+
+    @ApiModelProperty(value = "交易类型 0:直播收益  1:邀请奖励 默认查询直播收益")
+    private Integer tranType = 0;
+
+    @ApiModelProperty(value = "开始时间")
+    @JsonIgnore
+    private String beginTime;
+
+    @ApiModelProperty(value = "结束时间")
+    @JsonIgnore
+    private String endTime;
+
+    @ApiModelProperty(value = "交易类型1")
+    @JsonIgnore
+    private Integer tranType1;
+
+    @ApiModelProperty(value = "交易类型2")
+    @JsonIgnore
+    private Integer tranType2;
+
+    @ApiModelProperty(value = "交易类型3")
+    @JsonIgnore
+    private Integer tranType3;
+
+}

+ 4 - 0
game-business/src/main/java/com/game/business/mapper/FinTranRecordMapper.java

@@ -6,7 +6,9 @@ import java.util.Map;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.game.business.domain.FinTranRecord;
+import com.game.business.dto.FinTranDto;
 import com.game.business.dto.FinTranRecordDTO;
+import com.game.business.vo.FinTranVo;
 
 /**
  * 消费记录Mapper接口
@@ -74,4 +76,6 @@ public interface FinTranRecordMapper extends BaseMapper<FinTranRecord> {
     List<Map<String, Object>> getWithdrawByDateSum(FinTranRecordDTO finTranRecordDTO);
 
     List<Map<String, Object>> getRechargeByDateSum(FinTranRecordDTO finTranRecordDTO);
+
+    List<FinTranVo> selectTranList(FinTranDto finTranDto);
 }

+ 4 - 0
game-business/src/main/java/com/game/business/service/IFinTranRecordService.java

@@ -8,7 +8,9 @@ import com.game.business.domain.FinTranRecord;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.game.business.dto.AppUserTeamTranserDto;
 import com.game.business.dto.AppUserTeamTranserRecordDto;
+import com.game.business.dto.FinTranDto;
 import com.game.business.dto.FinTranRecordDTO;
+import com.game.business.vo.FinTranVo;
 import com.game.common.core.domain.HttpRet;
 import com.game.common.core.domain.R;
 
@@ -91,4 +93,6 @@ public interface IFinTranRecordService extends IService<FinTranRecord> {
     public List<FinTranRecord> selecListByWrapper(LambdaQueryWrapper<FinTranRecord> queryWrapper);
 
     public JSONObject selecFinTranRecordCount(FinTranRecordDTO finTranRecordDTO);
+
+    List<FinTranVo> selectTranList(FinTranDto finTranDto);
 }

+ 6 - 0
game-business/src/main/java/com/game/business/service/impl/AppUserCountServiceImpl.java

@@ -131,6 +131,12 @@ public class AppUserCountServiceImpl extends ServiceImpl<AppUserCountMapper, App
                     if (appUserCount.getLiveBettingCommission() != null) {
                         appUserCount.setLiveBettingCommission(userCount.getLiveBettingCommission() + appUserCount.getLiveBettingCommission());
                     }
+                    if (appUserCount.getLiveInvite() != null) {
+                        appUserCount.setLiveInvite(userCount.getLiveInvite() + appUserCount.getLiveInvite());
+                    }
+                    if (appUserCount.getLiveProfit() != null) {
+                        appUserCount.setLiveProfit(userCount.getLiveProfit() + appUserCount.getLiveProfit());
+                    }
                 }
                 res = appUserCountMapper.updateById(appUserCount);
             }

+ 37 - 1
game-business/src/main/java/com/game/business/service/impl/FinTranRecordServiceImpl.java

@@ -1,5 +1,6 @@
 package com.game.business.service.impl;
 
+import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -7,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -14,11 +16,13 @@ import com.game.business.domain.AppUser;
 import com.game.business.domain.CfgCommon;
 import com.game.business.dto.AppUserTeamTranserDto;
 import com.game.business.dto.AppUserTeamTranserRecordDto;
+import com.game.business.dto.FinTranDto;
 import com.game.business.dto.FinTranRecordDTO;
 import com.game.business.service.IAppGameBettingService;
 import com.game.business.service.IAppUserService;
 import com.game.business.service.ICfgCommonService;
 import com.game.business.util.Md5Utils;
+import com.game.business.vo.FinTranVo;
 import com.game.common.annotation.DataSource;
 import com.game.common.constant.AppSceneType;
 import com.game.common.constant.finance.FinTranAddedInfo;
@@ -142,7 +146,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
         LambdaQueryWrapper<FinTranRecord> queryWrapper = new LambdaQueryWrapper<FinTranRecord>();
         queryWrapper.between(FinTranRecord::getCreateTime,beginTime,endTime);
         if(StringUtils.isNotBlank(userId)){
-            queryWrapper.eq(FinTranRecord::getFromUid,userId);
+            queryWrapper.eq(FinTranRecord::getUid,userId);
         }
         return finTranRecordMapper.selectList(queryWrapper);
     }
@@ -301,4 +305,36 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
 
         return jsonObject;
     }
+
+    @Override
+    @DataSource(DataSourceType.SLAVE)
+    public List<FinTranVo> selectTranList(FinTranDto finTranDto) {
+        if(null == finTranDto.getUserId()){
+            finTranDto.setUserId(SecurityUtils.getUserId());
+        }
+        String weekBegin = null;
+        String weekend = null;
+        Date curDate = DateUtil.date();
+        if(1 == finTranDto.getType().intValue()){
+            curDate = DateUtil.offsetDay(curDate,-15); //上一周期
+        }
+        int curDay = Integer.parseInt(DateUtil.format(curDate,"dd"));
+        if(curDay <= 15){
+            weekBegin = DateUtil.format(DateUtil.beginOfMonth(curDate),"yyyy-MM-dd").concat(" 00:00:00");
+            weekend = DateUtil.format(curDate,"yyyy-MM-".concat("15").concat(" 23:59:59"));
+        }else{
+            weekBegin = DateUtil.format(curDate,"yyyy-MM-".concat("15").concat(" 00:00:00"));
+            weekend = DateUtil.format(DateUtil.endOfMonth(curDate),"yyyy-MM-dd").concat(" 23:59:59");
+        }
+        finTranDto.setBeginTime(weekBegin);
+        finTranDto.setEndTime(weekend);
+        if(0 == finTranDto.getTranType().intValue()){
+            //直播收益
+            finTranDto.setTranType1(FinTranType1.U_Income_Coin.getType());
+            finTranDto.setTranType3(FinTranType3.CONSUM_LIVE_ROOM_REWARD.getType());
+        }else{
+            finTranDto.setTranType3(FinTranType3.CHARGE_IN_INVITE.getType());
+        }
+        return finTranRecordMapper.selectTranList(finTranDto);
+    }
 }

+ 28 - 0
game-business/src/main/java/com/game/business/task/AppUserCountTask.java

@@ -145,6 +145,20 @@ public class AppUserCountTask {
                     ).mapToDouble(e ->
                             e.getBettingAmount() * e.getBettingMultiple()
                     ).sum());
+                    //邀请奖励
+                    appUserCount.setLiveInvite(finTranRecordList.stream().filter(e->
+                            e.getUid().equals(appUser.getUserid()) &&
+                                    FinTranType3.CHARGE_IN_INVITE.getType() == e.getTranType3().intValue()
+                    ).mapToDouble(FinTranRecord::getCoinChange).sum());
+                    //直播收益
+                    List<Integer> profitTypeList = Arrays.asList(
+                            FinTranType3.CONSUM_LIVE_ROOM_REWARD.getType()
+                    );
+                    appUserCount.setLiveProfit(finTranRecordList.stream().filter(e->
+                            e.getUid().equals(appUser.getUserid()) &&
+                                    profitTypeList.contains(e.getTranType3()) &&
+                                    FinTranType1.U_Income_Coin.getType() == e.getTranType1().intValue()
+                    ).mapToDouble(FinTranRecord::getCoinChange).sum());
                     appUserCountService.createAppUserCount(appUserCount);
                 });
             }
@@ -244,6 +258,20 @@ public class AppUserCountTask {
                     }).mapToDouble(e -> dealMoney(e.getCoinChange())).sum());
                     //直播佣金
                     appUserCount.setLiveCommission(liveDividedRecordList.stream().filter(e -> e.getUserId().equals(appUser.getUserid())).mapToDouble(e -> e.getMoney().doubleValue()).sum());
+                    //邀请奖励
+                    appUserCount.setLiveInvite(finTranRecordList.stream().filter(e->
+                            e.getUid().equals(appUser.getUserid()) &&
+                            FinTranType3.CHARGE_IN_INVITE.getType() == e.getTranType3().intValue()
+                    ).mapToDouble(FinTranRecord::getCoinChange).sum());
+                    //直播收益
+                    List<Integer> profitTypeList = Arrays.asList(
+                            FinTranType3.CONSUM_LIVE_ROOM_REWARD.getType()
+                    );
+                    appUserCount.setLiveProfit(finTranRecordList.stream().filter(e->
+                            e.getUid().equals(appUser.getUserid()) &&
+                                    profitTypeList.contains(e.getTranType3()) &&
+                                    FinTranType1.U_Income_Coin.getType() == e.getTranType1().intValue()
+                    ).mapToDouble(FinTranRecord::getCoinChange).sum());
                     appUserCountService.createAppUserCount(appUserCount);
                 });
             }

+ 8 - 0
game-business/src/main/java/com/game/business/vo/AppUserAgentJournalIndexVO.java

@@ -1,6 +1,8 @@
 package com.game.business.vo;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.game.common.annotation.Excel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -54,4 +56,10 @@ public class AppUserAgentJournalIndexVO {
     @ApiModelProperty(value = "月新增")
     private int monthUser = 0;
 
+    @ApiModelProperty(value = "直播收益")
+    private Double liveProfit;
+
+    @ApiModelProperty(value = "直播邀请奖励")
+    private Double liveInvite;
+
 }

+ 51 - 0
game-business/src/main/java/com/game/business/vo/FinTranVo.java

@@ -0,0 +1,51 @@
+package com.game.business.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@ApiModel(value = "交易记录")
+public class FinTranVo implements Serializable {
+
+    @ApiModelProperty(value = "用户id")
+    private Long userId;
+
+    @ApiModelProperty(value = "用户昵称")
+    private String username;
+
+    @ApiModelProperty(value = "收益来源用户iD")
+    private Long fromUid;
+
+    @ApiModelProperty(value = "收益来源用户昵称")
+    private String fromUsername;
+
+    @ApiModelProperty(value = "变动金币")
+    private Double coinChange;
+
+    @ApiModelProperty(value = "变动余额")
+    private Double diamondCoinChange;
+
+    @ApiModelProperty(value = "交易类型1")
+    private Integer tranType1;
+
+    @ApiModelProperty(value = "交易类型2")
+    private Integer tranType2;
+
+    @ApiModelProperty(value = "交易类型3")
+    private Integer tranType3;
+
+    @ApiModelProperty(value = "交易说明")
+    private String remarks;
+
+    @ApiModelProperty(value = "交易时间")
+    @NotNull(message = "交易时间")
+    @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
+    private Date createTime;
+
+}

+ 35 - 0
game-business/src/main/resources/mapper/business/FinTranRecordMapper.xml

@@ -304,4 +304,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         group by type
     </select>
 
+    <select id="selectTranList" parameterType="com.game.business.dto.FinTranDto" resultType="com.game.business.vo.FinTranVo">
+        SELECT
+            a.uid AS userId,
+            b.username,
+            a.from_uid AS fromUid,
+            c.username AS fromUsername,
+            a.coin_change AS coinChange,
+            a.diamond_coin_change AS diamondCoinChange,
+            a.tran_type1 AS tranType1,
+            a.tran_type2 AS tranType2,
+            a.tran_type3 AS tranType3,
+            a.create_time,
+            a.remarks
+        FROM
+        fin_tran_record AS a
+        LEFT JOIN app_user AS b ON a.uid = b.userid
+        LEFT JOIN app_user AS c ON a.from_uid = c.userid
+        where a.uid = #{userId}
+        <if test="beginTime != null and beginTime != ''">
+           and <![CDATA[ a.create_time >= #{beginTime} ]]>
+        </if>
+        <if test="endTime != null and endTime != ''">
+           and <![CDATA[ a.create_time <= #{endTime} ]]>
+        </if>
+        <if test="tranType1 != null">
+           and a.tran_type1 = #{tranType1}
+        </if>
+        <if test="tranType2 != null">
+           and a.tran_type2 = #{tranType2}
+        </if>
+        <if test="tranType3 != null">
+           and a.tran_type3 = #{tranType3}
+        </if>
+    </select>
+
 </mapper>