石田成 vor 2 Monaten
Ursprung
Commit
9805e13811

+ 24 - 1
game-business/src/main/java/com/game/business/controller/AppUserController.java

@@ -139,6 +139,10 @@ public class AppUserController extends BaseController
             userChargeDto.setRate(channel.getRate());
             remark = "后台充值补单,渠道:".concat(channel.getName());
         }
+        /*if(StringUtils.isNotBlank(userChargeDto.getRemark())){
+            String r = userChargeDto.getRemark().replace("后台充值","");
+            remark = remark.concat(",").concat(r);
+        }*/
         //流水 余额
         FinTranAddedInfo addedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
         FinTranRecord tran = null;
@@ -173,6 +177,24 @@ public class AppUserController extends BaseController
                 rateTran.setRemarks("充值手续费");
                 appUserService.updateUserAmount(rateTran);
             }
+            double give = 0;
+//            if(null != userChargeDto.getGiveAmount() && userChargeDto.getGiveAmount() > 0){
+                give = BigDecimal.valueOf(userChargeDto.getAmount().doubleValue()
+                        * appUsersChargeService.isChargeToday(userChargeDto.getUserId())).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
+                //赠送
+                FinTranRecord giveTran = new FinTranRecord();
+                BeanUtils.copyProperties(tran,giveTran);
+                if(TranCurrencyType.Balance.getType() == giveTran.getCurrencyType()){
+                    giveTran.setDiamondCoinChange(give);
+                }else if(TranCurrencyType.Coin.getType() == giveTran.getCurrencyType()){
+                    giveTran.setCoinChange(give);
+                }
+                giveTran.setTranType3(FinTranType3.CHARGE_IN_SEND.getType());
+                giveTran.setTranType2(FinTranType3.CHARGE_IN_SEND.getTranType2().getType());
+                giveTran.setTranType1(userChargeDto.getType() == 1?FinTranType1.U_Income_Coin_Balance.getType():FinTranType1.U_Income_Coin.getType());
+                giveTran.setRemarks("充值赠送");
+                appUserService.updateUserAmount(giveTran);
+//            }
             AppUser afterUser = appUserService.selectAppUserByUserid(userChargeDto.getUserId());
             //充值记录
             AppUsersCharge appUsersCharge = new AppUsersCharge();
@@ -193,10 +215,11 @@ public class AppUserController extends BaseController
             appUsersCharge.setOptUser(String.valueOf(SecurityUtils.getUserId()));
             // 操作类型 1:充值金币 2:扣减金币
             appUsersCharge.setOptType(userChargeDto.getAmount()<0?2L:1L);
+            //赠送金额
+            appUsersCharge.setCoinGive(BigDecimal.valueOf(give));
             appUsersCharge.setAddtime(new Date());
             appUsersCharge.setPlatformService(rate.doubleValue());
             appUsersCharge.setPlatformServiceRate(userChargeDto.getRate());
-            appUsersCharge.setCoinGive(BigDecimal.valueOf(0));
             appUsersCharge.setAfterCoin(userChargeDto.getType()==0?BigDecimal.valueOf(afterUser.getCoin()):BigDecimal.valueOf(afterUser.getDiamondCoin()));
             appUsersChargeService.insertAppUsersCharge(appUsersCharge);
         } catch (Exception e) {

+ 7 - 0
game-business/src/main/java/com/game/business/domain/AppUsersCharge.java

@@ -41,6 +41,13 @@ private static final long serialVersionUID=1L;
     @TableField(value = "addtime")
     private Date addtime;
 
+    /** 更新时间 */
+    @ApiModelProperty(value = "更新时间")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "添加时间" , width = 30, dateFormat = "yyyy-MM-dd")
+    @TableField(value = "update_time")
+    private Date updateTime;
+
     /** 当前剩余金币 */
     @ApiModelProperty(value = "当前剩余金币")
     @Excel(name = "当前剩余金币")

+ 6 - 0
game-business/src/main/java/com/game/business/dto/UserChargeDto.java

@@ -13,6 +13,12 @@ public class UserChargeDto implements Serializable {
     @NotNull(message = "充值金额")
     private Double amount;
 
+    /*@NotNull(message = "充值赠送金额")
+    private Double giveAmount;
+
+    @NotNull(message = "说明")
+    private String remark;*/
+
     @NotNull(message = "充值类型 0:金币  1:余额")
     private int type = 0;
 

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

@@ -65,4 +65,9 @@ public interface IAppUsersChargeService extends IService<AppUsersCharge> {
      *
      * */
     public List<AppUsersCharge> getChargeList(Long userId,String beginTime,String endTime);
+
+    /**
+     * 查询返佣比例
+     * */
+    public double isChargeToday(Long userId);
 }

+ 18 - 0
game-business/src/main/java/com/game/business/service/impl/AppUsersChargeServiceImpl.java

@@ -1,14 +1,17 @@
 package com.game.business.service.impl;
 
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
 import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 
 import com.game.common.annotation.DataSource;
 import com.game.common.enums.DataSourceType;
+import com.game.common.utils.DateUtils;
 import com.game.common.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -62,6 +65,7 @@ public class AppUsersChargeServiceImpl extends ServiceImpl<AppUsersChargeMapper,
     public int insertAppUsersCharge(AppUsersCharge appUsersCharge) {
        appUsersChargeMapper.getNewId();
        appUsersCharge.setId(appUsersChargeMapper.getMaxId());
+       appUsersCharge.setUpdateTime(new Date());
 
        return appUsersChargeMapper.insertAppUsersCharge(appUsersCharge);
     }
@@ -116,4 +120,18 @@ public class AppUsersChargeServiceImpl extends ServiceImpl<AppUsersChargeMapper,
         queryWrapper.notIn(AppUsersCharge::getType,new Integer[]{6,7});
         return appUsersChargeMapper.selectList(queryWrapper);
     }
+
+    @Override
+    @DataSource(DataSourceType.SLAVE)
+    public double isChargeToday(Long userId) {
+        Date now = new Date();
+        LambdaQueryWrapper<AppUsersCharge> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(AppUsersCharge::getUid,userId);
+        queryWrapper.eq(AppUsersCharge::getStatus,1);
+        queryWrapper.ge(AppUsersCharge::getUpdateTime, DateUtil.format(now,"yyyy-MM-dd").concat(" 00:00:00"));
+        queryWrapper.le(AppUsersCharge::getUpdateTime, DateUtil.format(now,"yyyy-MM-dd").concat(" 23:59:59"));
+        int count = appUsersChargeMapper.selectCount(queryWrapper).intValue();
+        double rate = count>0?0.02:0.1;
+        return rate;
+    }
 }

+ 6 - 1
game-business/src/main/resources/mapper/business/AppUsersChargeMapper.xml

@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="com.game.business.domain.AppUsersCharge" id="AppUsersChargeResult">
         <result property="id"    column="id"    />
         <result property="addtime"    column="addtime"    />
+        <result property="updateTime"    column="update_time"    />
         <result property="afterCoin"    column="after_coin"    />
         <result property="agentId"    column="agent_id"    />
         <result property="ambient"    column="ambient"    />
@@ -37,13 +38,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectAppUsersChargeVo">
-        select id, addtime, after_coin, agent_id, ambient, coin, coin_type, coin_give,platform_service_rate,platform_service, is_agent, is_delete, is_water, money, opt_type, opt_user, orderno, pid, pid_level1, pid_level2, pid_level3, pid_level4, remarks, rule_id, status, touid, trade_no, type, uid from app_users_charge
+        select id, addtime,update_time, after_coin, agent_id, ambient, coin, coin_type, coin_give,platform_service_rate,platform_service, is_agent, is_delete, is_water, money, opt_type, opt_user, orderno, pid, pid_level1, pid_level2, pid_level3, pid_level4, remarks, rule_id, status, touid, trade_no, type, uid from app_users_charge
     </sql>
 
     <select id="selectAppUsersChargeList" parameterType="com.game.business.domain.AppUsersCharge" resultMap="AppUsersChargeResult">
         <include refid="selectAppUsersChargeVo"/>
         <where>  
             <if test="addtime != null "> and addtime = #{addtime}</if>
+            <if test="updateTime != null "> and update_time = #{updateTime}</if>
             <if test="afterCoin != null "> and after_coin = #{afterCoin}</if>
             <if test="agentId != null "> and agent_id = #{agentId}</if>
             <if test="ambient != null "> and ambient = #{ambient}</if>
@@ -84,6 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="id != null">id,</if>
             <if test="addtime != null">addtime,</if>
+            <if test="updateTime != null">update_time,</if>
             <if test="afterCoin != null">after_coin,</if>
             <if test="agentId != null">agent_id,</if>
             <if test="ambient != null">ambient,</if>
@@ -115,6 +118,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
             <if test="addtime != null">#{addtime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
             <if test="afterCoin != null">#{afterCoin},</if>
             <if test="agentId != null">#{agentId},</if>
             <if test="ambient != null">#{ambient},</if>
@@ -149,6 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         update app_users_charge
         <trim prefix="SET" suffixOverrides=",">
             <if test="addtime != null">addtime = #{addtime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="afterCoin != null">after_coin = #{afterCoin},</if>
             <if test="agentId != null">agent_id = #{agentId},</if>
             <if test="ambient != null">ambient = #{ambient},</if>

+ 6 - 1
game-common/src/main/java/com/game/common/constant/finance/FinTranType3.java

@@ -42,10 +42,15 @@ public enum FinTranType3 {
      */
     CHARGE_OUT_RATE(FinTranType2.CHARGE, 1104, MessageUtils.message("11277") + ProjConfig.getD_ticketName(),0),
 
+    /**
+     * 充值 - 赠送
+     */
+    CHARGE_IN_SEND(FinTranType2.CHARGE, 1106, MessageUtils.message("11277") + ProjConfig.getD_ticketName(),0),
+
     /**
      * 分红 - 代理分红
      */
-    AGENT_DIVIDED(FinTranType2.REWARD_Income, 1104, "11575",0),
+    AGENT_DIVIDED(FinTranType2.REWARD_Income, 1105, "11575",0),
 
     /**
      * 活动 - 首充奖励