Selaa lähdekoodia

增加周分红接口

dos 3 kuukautta sitten
vanhempi
commit
73a3e87126
19 muutettua tiedostoa jossa 909 lisäystä ja 1 poistoa
  1. 2 0
      game-admin/src/main/resources/i18n/messages.properties
  2. 2 0
      game-admin/src/main/resources/i18n/messages_ar.properties
  3. 2 0
      game-admin/src/main/resources/i18n/messages_en.properties
  4. 2 0
      game-admin/src/main/resources/i18n/messages_tr.properties
  5. 69 0
      game-business/src/main/java/com/game/business/controller/AppUserCountDividendController.java
  6. 106 0
      game-business/src/main/java/com/game/business/domain/AppUserCountDividend.java
  7. 38 1
      game-business/src/main/java/com/game/business/domain/FinTranRecord.java
  8. 21 0
      game-business/src/main/java/com/game/business/dto/AppUserDividendListDto.java
  9. 19 0
      game-business/src/main/java/com/game/business/dto/AppUserDividendSendDto.java
  10. 68 0
      game-business/src/main/java/com/game/business/mapper/AppUserCountDividendMapper.java
  11. 72 0
      game-business/src/main/java/com/game/business/service/IAppUserCountDividendService.java
  12. 5 0
      game-business/src/main/java/com/game/business/service/IAppUserService.java
  13. 198 0
      game-business/src/main/java/com/game/business/service/impl/AppUserCountDividendServiceImpl.java
  14. 11 0
      game-business/src/main/java/com/game/business/service/impl/AppUserServiceImpl.java
  15. 105 0
      game-business/src/main/resources/mapper/business/AppUserCountDividendMapper.xml
  16. 46 0
      game-common/src/main/java/com/game/common/constant/AppSceneType.java
  17. 126 0
      game-common/src/main/java/com/game/common/constant/finance/FinTranAddedInfo.java
  18. 12 0
      game-common/src/main/java/com/game/common/constant/finance/FinTranType1.java
  19. 5 0
      game-common/src/main/java/com/game/common/constant/finance/FinTranType3.java

+ 2 - 0
game-admin/src/main/resources/i18n/messages.properties

@@ -1274,6 +1274,8 @@
 11571=\u51CF\u5C11\u4F59\u989D
 11572=\u4F59\u989D\u63D0\u73B0
 11573=\u6DFB\u52A0\u4F59\u989D
+11574=\u5546\u54C1
+11575=\u4EE3\u7406\u5206\u7EA2
 
 not.null=* \u5FC5\u987B\u586B\u5199
 user.jcaptcha.error=\u9A8C\u8BC1\u7801\u9519\u8BEF

+ 2 - 0
game-admin/src/main/resources/i18n/messages_ar.properties

@@ -1272,6 +1272,8 @@
 11570=\u0631\u0635\u064A\u062F
 11572=\u0633\u062D\u0628 \u0627\u0644\u0631\u0635\u064A\u062F
 11573=\u0625\u0636\u0627\u0641\u0629 \u0627\u0644\u0631\u0635\u064A\u062F
+11574=\u0633\u0644\u0639\u0629
+11575=\u0623\u0631\u0628\u0627\u062D \u0627\u0644\u0648\u0643\u0627\u0644\u0629
 # 11568 =
 # 11569 =
 # 11570 =

+ 2 - 0
game-admin/src/main/resources/i18n/messages_en.properties

@@ -1272,6 +1272,8 @@
 11570=Balance
 11572=Balance withdrawal
 11573=Add Balance
+11574=commodity
+11575=Agency dividend
 #11568=
 #11569=
 #11570=

+ 2 - 0
game-admin/src/main/resources/i18n/messages_tr.properties

@@ -1273,6 +1273,8 @@
 11570=Balance
 11572=Bakiyenin \u00E7ekilmesi
 11573=Bakiye ekle
+11574=emtia
+11575=Ajans temett\u00FC
 #11568=
 #11569=
 #11570=

+ 69 - 0
game-business/src/main/java/com/game/business/controller/AppUserCountDividendController.java

@@ -0,0 +1,69 @@
+package com.game.business.controller;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import com.game.business.dto.AppUserDividendListDto;
+import com.game.business.dto.AppUserDividendSendDto;
+import com.game.common.core.domain.HttpRet;
+import com.game.common.core.domain.R;
+import com.game.common.utils.SecurityUtils;
+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 com.game.common.annotation.Log;
+import com.game.common.core.controller.BaseController;
+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.AppUserCountDividend;
+import com.game.business.service.IAppUserCountDividendService;
+import com.game.common.utils.poi.ExcelUtil;
+import com.game.common.core.page.TableDataInfo;
+
+/**
+ * 用户代理分红Controller
+ * 
+ * @author game
+ * @date 2024-06-30
+ */
+@RestController
+@RequestMapping("/business/dividend")
+@Api(value = "AppUserCountDividendController", description = "用户代理表接口", tags = {"用户代理表接口"})
+public class AppUserCountDividendController extends BaseController
+{
+    @Autowired
+    private IAppUserCountDividendService appUserCountDividendService;
+
+    /**
+     * 查询用户代理分红列表
+     */
+    @GetMapping("/list")
+    @ApiOperation(value = "查询周分红列表", notes = "获取周分红列表")
+    public TableDataInfo<AppUserCountDividend> list(AppUserDividendListDto dto)
+    {
+        startPage();
+        List<AppUserCountDividend> list = appUserCountDividendService.selectUserDividendList(SecurityUtils.getUserId());
+        return getDataTable(list);
+    }
+
+    /**
+     * 查询用户代理分红列表
+     */
+    @GetMapping("/send")
+    @ApiOperation(value = "发放分红", notes = "发放分红")
+    public HttpRet<Boolean> send(AppUserDividendSendDto dto)
+    {
+
+        return appUserCountDividendService.send(dto.getUserId(),dto.getDateNum());
+    }
+
+}

+ 106 - 0
game-business/src/main/java/com/game/business/domain/AppUserCountDividend.java

@@ -0,0 +1,106 @@
+package com.game.business.domain;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.game.common.annotation.Excel;
+import com.game.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+/**
+ * 用户代理分红对象 app_user_count_dividend
+ *
+ * @author game
+ * @date 2024-06-30
+ */
+@ApiModel(value = "app_user_count_dividend", description = "用户代理分红")
+@TableName(value= "app_user_count_dividend")
+@Data
+public class AppUserCountDividend
+        {
+private static final long serialVersionUID=1L;
+
+    /**  */
+    @ApiModelProperty(value = "")
+    @TableId(value = "id" , type = IdType.AUTO)
+    private Long id;
+
+    /** 用户id */
+    @ApiModelProperty(value = "用户id")
+    @Excel(name = "用户id")
+    @TableField(value = "user_id")
+    private Long userId;
+
+    /** 统计周期-开始 */
+    @ApiModelProperty(value = "期号")
+    @Excel(name = "期号" , width = 30)
+    @TableField(value = "date_no")
+    private String dateNo;
+
+    /** 统计周期-开始 */
+    @ApiModelProperty(value = "统计周期-开始")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "统计周期-开始" , width = 30, dateFormat = "yyyy-MM-dd")
+    @TableField(value = "beginTime")
+    private Date beginTime;
+
+    /** 统计周期-结束 */
+    @ApiModelProperty(value = "统计周期-结束")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "统计周期-结束" , width = 30, dateFormat = "yyyy-MM-dd")
+    @TableField(value = "endTime")
+    private Date endTime;
+
+    /** 盈亏 */
+    @ApiModelProperty(value = "盈亏")
+    @Excel(name = "盈亏")
+    @TableField(value = "profit_loss")
+    private Double profitLoss;
+
+    /** 百分比 */
+    @ApiModelProperty(value = "百分比")
+    @Excel(name = "百分比")
+    @TableField(value = "rate")
+    private Double rate;
+
+    /** 金币 */
+    @ApiModelProperty(value = "金币")
+    @Excel(name = "金币")
+    @TableField(value = "coin")
+    private Double coin;
+
+    /** 余额 */
+    @ApiModelProperty(value = "余额")
+    @Excel(name = "余额")
+    @TableField(value = "diamond_coin")
+    private Double diamondCoin;
+
+    /** 状态 0:未发放  1:已发放 */
+    @ApiModelProperty(value = "状态 0:未发放  1:已发放")
+    @Excel(name = "状态 0:未发放  1:已发放")
+    @TableField(value = "status")
+    private Long status;
+
+    /** 创建时间 */
+    @ApiModelProperty(value = "创建时间")
+    @TableField(value = "create_time")
+    private Date createTime;
+
+    /** 更新时间 */
+    @ApiModelProperty(value = "更新时间")
+    @TableField(value = "update_time")
+    private Date updateTime;
+
+    @TableField(exist = false)
+    @ApiModelProperty(value = "昵称")
+    private String nickName;
+
+}

+ 38 - 1
game-business/src/main/java/com/game/business/domain/FinTranRecord.java

@@ -7,6 +7,9 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.game.common.annotation.Excel;
+import com.game.common.constant.finance.FinTranAddedInfo;
+import com.game.common.constant.finance.FinTranType1;
+import com.game.common.constant.finance.FinTranType3;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModel;
 import lombok.Data;
@@ -98,7 +101,7 @@ private static final long serialVersionUID=1L;
     @ApiModelProperty(value = "货币类型 1:人民币 2:金币 3:映票 4:余额")
     @Excel(name = "货币类型 1:人民币 2:金币 3:映票 4:余额")
     @TableField(value = "currency_type")
-    private Long currencyType;
+    private Integer currencyType;
 
     /**  送礼人ID */
     @ApiModelProperty(value = " 送礼人ID")
@@ -226,4 +229,38 @@ private static final long serialVersionUID=1L;
     @TableField(value = "uid")
     private Long uid;
 
+    /**
+     * 初始化 基本信息
+     *
+     * @param info      记录的基础信息
+     * @param tranType3 记录三级类型
+     * @param tranType1 记录一级类型
+     * @return
+     */
+    public static FinTranRecord initFinTranRecordSomeParams(FinTranAddedInfo info, FinTranType3 tranType3, FinTranType1 tranType1, AppUser user) {
+        FinTranRecord tran = new FinTranRecord();
+        tran.proId = info.proId;
+        tran.proCount = info.proCount.longValue();
+        tran.goodsId = info.goodsId;
+        tran.orderId = info.orderId;
+        tran.sceneId1 = info.sceneId1;
+        tran.sceneType = info.sceneType.longValue();
+        tran.sceneId2 = info.sceneId2;
+        tran.remarks = info.remarks;
+        tran.tranType3 = tranType3.getType();
+        tran.tranType2 = tranType3.getTranType2().getType();
+        tran.tranType1 = tranType1.getType();
+        tran.uid = user.getUserid();
+        tran.agentId = user.getAgentId();
+        tran.guildId = user.getGuildId();
+        tran.managerId = user.getManagerId();
+        tran.managerCoId = user.getManagerCoId();
+        tran.afterMoney = user.getAmount();
+        tran.afterCoin = user.getCoin();
+        tran.afterTicket = user.getVotes();
+        tran.afterDiamondCoin = user.getDiamondCoin();
+        tran.createTime = new Date();
+        return tran;
+    }
+
 }

+ 21 - 0
game-business/src/main/java/com/game/business/dto/AppUserDividendListDto.java

@@ -0,0 +1,21 @@
+package com.game.business.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+@ApiModel("查询周分红")
+public class AppUserDividendListDto implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "每页条数")
+    private int pageSize;
+
+    @ApiModelProperty(value = "页码")
+    private int pageNum;
+
+}

+ 19 - 0
game-business/src/main/java/com/game/business/dto/AppUserDividendSendDto.java

@@ -0,0 +1,19 @@
+package com.game.business.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class AppUserDividendSendDto implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "用户id")
+    private String userId;
+
+    @ApiModelProperty(value = "期号")
+    private String dateNum;
+
+}

+ 68 - 0
game-business/src/main/java/com/game/business/mapper/AppUserCountDividendMapper.java

@@ -0,0 +1,68 @@
+package com.game.business.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.game.business.domain.AppUserCountDividend;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 用户代理分红Mapper接口
+ *
+ * @author game
+ * @date 2024-06-30
+ */
+public interface AppUserCountDividendMapper extends BaseMapper<AppUserCountDividend> {
+    /**
+     * 查询用户代理分红
+     *
+     * @param id 用户代理分红主键
+     * @return 用户代理分红
+     */
+    public AppUserCountDividend selectAppUserCountDividendById(Long id);
+
+    /**
+     * 查询用户代理分红列表
+     *
+     * @param appUserCountDividend 用户代理分红
+     * @return 用户代理分红集合
+     */
+    public List<AppUserCountDividend> selectAppUserCountDividendList(AppUserCountDividend appUserCountDividend);
+
+    /**
+     * 新增用户代理分红
+     *
+     * @param appUserCountDividend 用户代理分红
+     * @return 结果
+     */
+    public int insertAppUserCountDividend(AppUserCountDividend appUserCountDividend);
+
+    /**
+     * 修改用户代理分红
+     *
+     * @param appUserCountDividend 用户代理分红
+     * @return 结果
+     */
+    public int updateAppUserCountDividend(AppUserCountDividend appUserCountDividend);
+
+    /**
+     * 删除用户代理分红
+     *
+     * @param id 用户代理分红主键
+     * @return 结果
+     */
+    public int deleteAppUserCountDividendById(Long id);
+
+    /**
+     * 批量删除用户代理分红
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteAppUserCountDividendByIds(Long[] ids);
+
+    /**
+     * 查询用户团队分红列表
+     *
+     * */
+    public List<AppUserCountDividend> selectUserDividendList(@Param("pid") Long pid);
+}

+ 72 - 0
game-business/src/main/java/com/game/business/service/IAppUserCountDividendService.java

@@ -0,0 +1,72 @@
+package com.game.business.service;
+
+import java.util.List;
+import com.game.business.domain.AppUserCountDividend;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.game.common.core.domain.HttpRet;
+
+/**
+ * 用户代理分红Service接口
+ *
+ * @author game
+ * @date 2024-06-30
+ */
+public interface IAppUserCountDividendService extends IService<AppUserCountDividend> {
+    /**
+     * 查询用户代理分红
+     *
+     * @param id 用户代理分红主键
+     * @return 用户代理分红
+     */
+    public AppUserCountDividend selectAppUserCountDividendById(Long id);
+
+    /**
+     * 查询用户代理分红列表
+     *
+     * @param appUserCountDividend 用户代理分红
+     * @return 用户代理分红集合
+     */
+    public List<AppUserCountDividend> selectAppUserCountDividendList(AppUserCountDividend appUserCountDividend);
+
+    /**
+     * 新增用户代理分红
+     *
+     * @param appUserCountDividend 用户代理分红
+     * @return 结果
+     */
+    public int insertAppUserCountDividend(AppUserCountDividend appUserCountDividend);
+
+    /**
+     * 修改用户代理分红
+     *
+     * @param appUserCountDividend 用户代理分红
+     * @return 结果
+     */
+    public int updateAppUserCountDividend(AppUserCountDividend appUserCountDividend);
+
+    /**
+     * 批量删除用户代理分红
+     *
+     * @param ids 需要删除的用户代理分红主键集合
+     * @return 结果
+     */
+    public int deleteAppUserCountDividendByIds(Long[] ids);
+
+    /**
+     * 删除用户代理分红信息
+     *
+     * @param id 用户代理分红主键
+     * @return 结果
+     */
+    public int deleteAppUserCountDividendById(Long id);
+
+    /**
+     * 查询团队分红
+     * */
+    public List<AppUserCountDividend> selectUserDividendList(Long userId);
+
+    /**
+     * 发放分红
+     * */
+    public HttpRet<Boolean> send(String userId,String dateNo);
+}

+ 5 - 0
game-business/src/main/java/com/game/business/service/IAppUserService.java

@@ -62,4 +62,9 @@ public interface IAppUserService extends IService<AppUser> {
     public int getCount(Long pid,String beginTime,String endTime);
 
     boolean getMobileCount(String mobile);
+
+    /**
+     * 根据用户id集合查询用户列表
+     * */
+    public List<AppUser> selectListByIds(List<Long> ids);
 }

+ 198 - 0
game-business/src/main/java/com/game/business/service/impl/AppUserCountDividendServiceImpl.java

@@ -0,0 +1,198 @@
+package com.game.business.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import com.game.business.domain.AppUser;
+import com.game.business.domain.FinTranRecord;
+import com.game.business.service.IAppUserService;
+import com.game.business.service.IFinTranRecordService;
+import com.game.common.constant.AppSceneType;
+import com.game.common.constant.finance.FinTranAddedInfo;
+import com.game.common.constant.finance.FinTranType1;
+import com.game.common.constant.finance.FinTranType3;
+import com.game.common.constant.finance.TranCurrencyType;
+import com.game.common.core.domain.HttpRet;
+import com.game.common.utils.DateUtils;
+import com.game.common.utils.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.game.business.mapper.AppUserCountDividendMapper;
+import com.game.business.domain.AppUserCountDividend;
+import com.game.business.service.IAppUserCountDividendService;
+import com.game.common.annotation.DataSource;
+import com.game.common.enums.DataSourceType;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * 用户代理分红Service业务层处理
+ *
+ * @author game
+ * @date 2024-06-30
+ */
+@Service
+public class AppUserCountDividendServiceImpl extends ServiceImpl<AppUserCountDividendMapper, AppUserCountDividend> implements IAppUserCountDividendService {
+    @Autowired
+    private AppUserCountDividendMapper appUserCountDividendMapper;
+    @Autowired
+    private IAppUserService appUserService;
+    @Autowired
+    private IFinTranRecordService finTranRecordService;
+
+    /**
+     * 查询用户代理分红
+     *
+     * @param id 用户代理分红主键
+     * @return 用户代理分红
+     */
+    @Override
+    public AppUserCountDividend selectAppUserCountDividendById(Long id) {
+        return appUserCountDividendMapper.selectAppUserCountDividendById(id);
+    }
+
+    /**
+     * 查询用户代理分红列表
+     *
+     * @param appUserCountDividend 用户代理分红
+     * @return 用户代理分红
+     */
+    @Override
+    public List<AppUserCountDividend> selectAppUserCountDividendList(AppUserCountDividend appUserCountDividend) {
+        return appUserCountDividendMapper.selectAppUserCountDividendList(appUserCountDividend);
+    }
+
+    /**
+     * 新增用户代理分红
+     *
+     * @param appUserCountDividend 用户代理分红
+     * @return 结果
+     */
+    @Override
+    public int insertAppUserCountDividend(AppUserCountDividend appUserCountDividend) {
+                appUserCountDividend.setCreateTime(DateUtils.getNowDate());
+            return appUserCountDividendMapper.insertAppUserCountDividend(appUserCountDividend);
+    }
+
+    /**
+     * 修改用户代理分红
+     *
+     * @param appUserCountDividend 用户代理分红
+     * @return 结果
+     */
+    @Override
+    public int updateAppUserCountDividend(AppUserCountDividend appUserCountDividend) {
+                appUserCountDividend.setUpdateTime(DateUtils.getNowDate());
+        return appUserCountDividendMapper.updateAppUserCountDividend(appUserCountDividend);
+    }
+
+    /**
+     * 批量删除用户代理分红
+     *
+     * @param ids 需要删除的用户代理分红主键
+     * @return 结果
+     */
+    @Override
+    public int deleteAppUserCountDividendByIds(Long[] ids) {
+        return appUserCountDividendMapper.deleteAppUserCountDividendByIds(ids);
+    }
+
+    /**
+     * 删除用户代理分红信息
+     *
+     * @param id 用户代理分红主键
+     * @return 结果
+     */
+    @Override
+    public int deleteAppUserCountDividendById(Long id) {
+        return appUserCountDividendMapper.deleteAppUserCountDividendById(id);
+    }
+
+    @Override
+    public List<AppUserCountDividend> selectUserDividendList(Long userId) {
+        List<AppUserCountDividend> dividendList = appUserCountDividendMapper.selectUserDividendList(userId);
+        if(null != dividendList && dividendList.size()>0){
+            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->{
+                    AppUser appUser = userMap.get(String.valueOf(e.getUserId()));
+                    if(null != appUser){
+                        e.setNickName(appUser.getNickname());
+                    }
+                });
+            }
+        }
+        return dividendList;
+    }
+
+    @Override
+    @Transactional
+    public HttpRet<Boolean> send(String userId, String dateNo) {
+        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 = appUserCountDividendMapper.selectList(queryWrapper);
+        if(null == dividendList || dividendList.size() < 1){
+            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 updateAppUser = new AppUser();
+                updateAppUser.setUserid(appUser.getUserid());
+                if(null != e.getDiamondCoin() && e.getDiamondCoin()>0){
+                    updateAppUser.setDiamondCoin(appUser.getDiamondCoin() + e.getDiamondCoin());
+                    updateAppUser.setDiamondCoinTotal(appUser.getDiamondCoinTotal() + 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());
+                    tranRecordList.add(tran);
+                }
+                if(null != e.getCoin() && e.getCoin()>0){
+                    updateAppUser.setCoin(appUser.getDiamondCoin() + e.getDiamondCoin());
+                    //流水 余额
+                    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.setAfterDiamondCoin(appUser.getDiamondCoin() + e.getDiamondCoin());
+                    tran.setCurrencyType(TranCurrencyType.Coin.getType());
+                    tranRecordList.add(tran);
+                }
+                appUserService.updateAppUser(updateAppUser);
+                if(tranRecordList.size() > 0){
+                    tranRecordList.forEach(t->{
+                        finTranRecordService.insertFinTranRecord(t);
+                    });
+                }
+                updateAppUser.setDiamondCoin(e.getDiamondCoin());
+            });
+        }
+        return HttpRet.success("发放成功",true);
+    }
+
+
+}

+ 11 - 0
game-business/src/main/java/com/game/business/service/impl/AppUserServiceImpl.java

@@ -2,6 +2,8 @@ package com.game.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import java.util.Collections;
 import java.util.List;
 
 import com.game.common.annotation.DataSource;
@@ -121,4 +123,13 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
         queryWrapper.eq(AppUser::getUsername, userName);
         return appUserMapper.selectCount(queryWrapper) > 0;
     }
+
+    @Override
+    @DataSource(DataSourceType.SLAVE)
+    public List<AppUser> selectListByIds(List<Long> ids) {
+        LambdaQueryWrapper<AppUser> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(AppUser::getUserid,ids);
+        queryWrapper.eq(AppUser::getDelFlag,0);
+        return appUserMapper.selectList(queryWrapper);
+    }
 }

+ 105 - 0
game-business/src/main/resources/mapper/business/AppUserCountDividendMapper.xml

@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.game.business.mapper.AppUserCountDividendMapper">
+    
+    <resultMap type="com.game.business.domain.AppUserCountDividend" id="AppUserCountDividendResult">
+        <result property="id"    column="id"    />
+        <result property="userId"    column="user_id"    />
+        <result property="dateNo"    column="date_no"    />
+        <result property="beginTime"    column="beginTime"    />
+        <result property="endTime"    column="endTime"    />
+        <result property="profitLoss"    column="profit_loss"    />
+        <result property="rate"    column="rate"    />
+        <result property="coin"    column="coin"    />
+        <result property="diamondCoin"    column="diamond_coin"    />
+        <result property="status"    column="status"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+    </resultMap>
+
+    <sql id="selectAppUserCountDividendVo">
+        select id, user_id, beginTime, endTime, profit_loss, rate, coin, diamond_coin, status, create_time, update_time from app_user_count_dividend
+    </sql>
+
+    <select id="selectAppUserCountDividendList" parameterType="com.game.business.domain.AppUserCountDividend" resultMap="AppUserCountDividendResult">
+        <include refid="selectAppUserCountDividendVo"/>
+        <where>  
+            <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="beginTime != null "> and beginTime = #{beginTime}</if>
+            <if test="endTime != null "> and endTime = #{endTime}</if>
+            <if test="profitLoss != null "> and profit_loss = #{profitLoss}</if>
+            <if test="rate != null "> and rate = #{rate}</if>
+            <if test="coin != null "> and coin = #{coin}</if>
+            <if test="diamondCoin != null "> and diamond_coin = #{diamondCoin}</if>
+            <if test="status != null "> and status = #{status}</if>
+        </where>
+    </select>
+    
+    <select id="selectAppUserCountDividendById" parameterType="Long" resultMap="AppUserCountDividendResult">
+        <include refid="selectAppUserCountDividendVo"/>
+        where id = #{id}
+    </select>
+        
+    <insert id="insertAppUserCountDividend" parameterType="com.game.business.domain.AppUserCountDividend" useGeneratedKeys="true" keyProperty="id">
+        insert into app_user_count_dividend
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="userId != null">user_id,</if>
+            <if test="beginTime != null">beginTime,</if>
+            <if test="endTime != null">endTime,</if>
+            <if test="profitLoss != null">profit_loss,</if>
+            <if test="rate != null">rate,</if>
+            <if test="coin != null">coin,</if>
+            <if test="diamondCoin != null">diamond_coin,</if>
+            <if test="status != null">status,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="userId != null">#{userId},</if>
+            <if test="beginTime != null">#{beginTime},</if>
+            <if test="endTime != null">#{endTime},</if>
+            <if test="profitLoss != null">#{profitLoss},</if>
+            <if test="rate != null">#{rate},</if>
+            <if test="coin != null">#{coin},</if>
+            <if test="diamondCoin != null">#{diamondCoin},</if>
+            <if test="status != null">#{status},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+         </trim>
+    </insert>
+
+    <update id="updateAppUserCountDividend" parameterType="com.game.business.domain.AppUserCountDividend">
+        update app_user_count_dividend
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="beginTime != null">beginTime = #{beginTime},</if>
+            <if test="endTime != null">endTime = #{endTime},</if>
+            <if test="profitLoss != null">profit_loss = #{profitLoss},</if>
+            <if test="rate != null">rate = #{rate},</if>
+            <if test="coin != null">coin = #{coin},</if>
+            <if test="diamondCoin != null">diamond_coin = #{diamondCoin},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteAppUserCountDividendById" parameterType="Long">
+        delete from app_user_count_dividend where id = #{id}
+    </delete>
+
+    <delete id="deleteAppUserCountDividendByIds" parameterType="String">
+        delete from app_user_count_dividend where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+
+    <select id="selectUserDividendList" parameterType="String" resultMap="AppUserCountDividendResult">
+        select a.* from app_user_count_dividend as a inner join app_user_agent as b on a.user_id = b.user_id
+        where b.pid = #{pid}
+    </select>
+</mapper>

+ 46 - 0
game-common/src/main/java/com/game/common/constant/AppSceneType.java

@@ -0,0 +1,46 @@
+package com.game.common.constant;
+
+public enum AppSceneType {
+    /*
+     * /** 直播房间类型(1.视频直播房间,2.语音直播房间,3.一对一直播房间,7.私聊,8.群聊,9.短视频)
+     */
+    Scene_None(0, ""),
+    Scene_VideoLive(1, "视频直播房间"), Scene_VoiceLive(2, "语音直播房间"), Scene_OOOLive(3, "一对一直播房间"), Scene_OOOChat(7, "私聊"),
+    Scene_ChatFamily(8, "家族"), Scene_ShortVideo(9, "短视频"), Scene_PersonalPage(10, "个人主页"),Scene_GroupChat(11, "家族"), Scene_tv(12, "长视频");
+
+    private String name;
+    private int type;
+
+    AppSceneType(int type, String name) {
+        this.type = type;
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public int getType() {
+        return type;
+    }
+
+    public static String getNameDescribe(int n) {
+        for (AppSceneType m : AppSceneType.values()) {
+            if (m.type == n) {
+                return m.name;
+            }
+        }
+        return null;
+    }
+
+    public static AppSceneType getByType(int type) {
+        for (AppSceneType m : AppSceneType.values()) {
+            if (m.type == type) {
+                return m;
+            }
+        }
+        return AppSceneType.Scene_None;
+
+    }
+
+}

+ 126 - 0
game-common/src/main/java/com/game/common/constant/finance/FinTranAddedInfo.java

@@ -0,0 +1,126 @@
+package com.game.common.constant.finance;
+
+import com.game.common.constant.AppSceneType;
+
+public class FinTranAddedInfo {
+
+	/**
+	 * (礼物、守护、坐骑、靓号、短视频、动态、svpi、贵族、游戏)ID
+	 */
+	public long proId;
+	/**
+	 * (礼物、守护、坐骑、靓号、短视频、动态、svpi、贵族、游戏)数量
+	 */
+	public Integer proCount;
+	/**
+	 * 第三表记录id(如:支付记录表id,提现记录表id,游戏记录id)
+	 */
+	public long orderId;
+	/**
+	 * 消费日志ID(此记录关联的购买的商品的ID)
+	 */
+	public long goodsId;
+
+	/**
+	 * 场景id(视频直播房间id,语音直播房间id,一对一直播房间id)
+	 */
+	public long sceneId1;
+
+	/**
+	 * 直播房间类型(1.视频直播房间,2.语音直播房间,3.一对一直播房间,7.私聊,8.群聊,9.短视频)
+	 */
+	public Integer sceneType;
+	/**
+	 * 某次直播时间段内的一个标识
+	 */
+	public String sceneId2;
+
+	/**
+	 * 备注;翻译前端消费记录中的语言
+	 */
+	public String remarks;
+
+
+	public long getProId() {
+		return proId;
+	}
+
+	public void setProId(long proId) {
+		this.proId = proId;
+	}
+
+	public int getProCount() {
+		return proCount;
+	}
+
+	public void setProCount(int proCount) {
+		this.proCount = proCount;
+	}
+
+	public long getOrderId() {
+		return orderId;
+	}
+
+	public void setOrderId(long orderId) {
+		this.orderId = orderId;
+	}
+
+	public long getGoodsId() {
+		return goodsId;
+	}
+
+	public void setGoodsId(long goodsId) {
+		this.goodsId = goodsId;
+	}
+
+	public long getSceneId1() {
+		return sceneId1;
+	}
+
+	public void setSceneId1(long sceneId1) {
+		this.sceneId1 = sceneId1;
+	}
+
+	public int getSceneType() {
+		return sceneType;
+	}
+
+	public void setSceneType(int sceneType) {
+		this.sceneType = sceneType;
+	}
+
+	public String getSceneId2() {
+		return sceneId2;
+	}
+
+	public void setSceneId2(String sceneId2) {
+		this.sceneId2 = sceneId2;
+	}
+
+	public String getRemarks() {
+		return remarks;
+	}
+
+	public void setRemarks(String remarks) {
+		this.remarks = remarks;
+	}
+
+	/**
+	 *
+	 * @param proId             (礼物、守护、坐骑、靓号、短视频、动态、svpi、贵族、游戏)ID
+	 * @param proCount          (礼物、守护、坐骑、靓号、短视频、动态、svpi、贵族、游戏)数量
+	 * @param sceneId1          场景id(视频直播房间id,语音直播房间id,一对一直播房间id)
+	 * @param sceneType         直播房间类型(视频直播房间,语音直播房间,一对一直播房间)
+	 * @param sceneId2         某次直播时间段内的一个标识
+	 * @return
+	 */
+	public static FinTranAddedInfo createTranInfo(long proId, int proCount, long sceneId1, AppSceneType sceneType, String sceneId2) {
+		FinTranAddedInfo tranInfo = new FinTranAddedInfo();
+		tranInfo.proId = proId;
+		tranInfo.proCount = proCount;
+		tranInfo.sceneId1 = sceneId1;
+		tranInfo.sceneType = sceneType.getType();
+		tranInfo.sceneId2 = sceneId2;
+		return tranInfo;
+	}
+}

+ 12 - 0
game-common/src/main/java/com/game/common/constant/finance/FinTranType1.java

@@ -48,6 +48,18 @@ public enum FinTranType1 {
      * 代理获得的(人民币)AgentAmount 仅用于 FinAdminTranRecord 表
      */
     Agent_Income_Money(21, "11333"),
+
+
+    /**
+     * 代理获得的(金币)
+     */
+    Agent_Income_Coin(22, "11333"),
+
+
+    /**
+     * 代理获得的(余额)
+     */
+    Agent_Income_Diamond_Coin(23, "11333"),
     /**
      * 工会获得的(映票) GuildTicket 仅用于 FinAdminTranRecord 表
      */

+ 5 - 0
game-common/src/main/java/com/game/common/constant/finance/FinTranType3.java

@@ -37,6 +37,11 @@ public enum FinTranType3 {
      */
     CHARGE_WIN_GAME(FinTranType2.GAME_REWARD, 1103, "11215"),
 
+    /**
+     * 分红 - 代理分红
+     */
+    AGENT_DIVIDED(FinTranType2.REWARD_Income, 1104, "11575"),
+
     /**
      * 活动 - 首充奖励
      */