Browse Source

优化提现审核

dos 3 tuần trước cách đây
mục cha
commit
4e6c1e8ccd

+ 48 - 9
game-business/src/main/java/com/game/business/controller/AppUserController.java

@@ -4,6 +4,7 @@ import java.math.BigDecimal;
 import java.util.*;
 import javax.servlet.http.HttpServletResponse;
 
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.http.HttpRequest;
@@ -387,7 +388,11 @@ public class AppUserController extends BaseController
             //流水 余额
             FinTranAddedInfo addedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
             FinTranRecord tran = null;
-            tran = FinTranRecord.initFinTranRecordSomeParams(addedInfo, FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW, withdrawDto.getAmount()<0?FinTranType1.U_Income_Coin_Balance:FinTranType1.U_Outcome_Balance, appUser);
+            FinTranType3 type3 = FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW;
+            if(withdrawDto.getAmount().doubleValue()<0){
+                type3 = FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW_OUT;
+            }
+            tran = FinTranRecord.initFinTranRecordSomeParams(addedInfo, type3, withdrawDto.getAmount()<0?FinTranType1.U_Income_Coin_Balance:FinTranType1.U_Outcome_Balance, appUser);
             tran.setDiamondCoinChange(withdrawDto.getAmount()*-1);
             tran.setAfterDiamondCoin(appUser.getDiamondCoin());
             tran.setCurrencyType(TranCurrencyType.Balance.getType());
@@ -463,17 +468,51 @@ public class AppUserController extends BaseController
     {
         RechargeAmountVo amountVo = finTranRecordService.selectRechargeAmount(userid,0);
         if(null == amountVo){
-            return R.ok(new RechargeAmountVo());
+            amountVo = new RechargeAmountVo();
         }
         //查询用户已下注金额
         Date time = finTranRecordService.selectRechargeDate(userid,0);
-        String type3s = FinTranType3.CONSUM_GAME_ANCHOR_ZHUANPAN.getType() + "," + FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW.getType();
-        List<FinTranRecord> curTranList = finTranRecordService.selectUserTran(null,type3s,userid,time,new Date(),0);
-        double bettingAmount = curTranList.stream().filter(e->
-                e.getCurrencyType().intValue() == 4
-        ).mapToDouble(FinTranRecord::getDiamondCoinChange).sum() * -1;
-        amountVo.setGameAmount(bettingAmount);
-        double amount = (amountVo.getAmount() + amountVo.getGiveAmount()) * 2 - amountVo.getGameAmount();
+        double amount = 0;
+        double bettingAmount = 0;
+        if(null != time){
+            //查询本次充值下注金额
+            double outAmount = finTranRecordService.sumCoinByType(userid,Arrays.asList(FinTranType3.CONSUM_GAME_ANCHOR_ZHUANPAN.getType(),
+                    FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW.getType(),
+                    FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW_OUT.getType()), DateUtil.format(time,"yyyy-MM-dd HH:mm:ss")) * -1;
+            amount = (amountVo.getAmount() + amountVo.getGiveAmount()) * 2 - outAmount;
+        }else{
+            //查询最近一次满足提现流水时间
+            FinTranRecord finTranRecord = finTranRecordService.getFinByUserId(userid);
+            if(null != finTranRecord){
+                double outAmount = finTranRecordService.sumCoinByType(userid,Arrays.asList(FinTranType3.CONSUM_GAME_ANCHOR_ZHUANPAN.getType(),
+                        FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW.getType(),
+                        FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW_OUT.getType()), DateUtil.format(finTranRecord.getCreateTime(),"yyyy-MM-dd HH:mm:ss")) * -1;
+                if(outAmount < 0){
+                    amount = outAmount * -1;
+                }
+            }else{
+                double outAmount = finTranRecordService.sumCoinByType(userid,Arrays.asList(FinTranType3.CONSUM_GAME_ANCHOR_ZHUANPAN.getType(),
+                        FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW.getType(),
+                        FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW_OUT.getType()), null);
+                if(outAmount < 0){
+                    amount = outAmount * -1;
+                }
+            }
+        }
+        //查询总打码量
+        bettingAmount = finTranRecordService.sumCoinByType(userid,Arrays.asList(FinTranType3.CONSUM_GAME_ANCHOR_ZHUANPAN.getType(),
+                FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW.getType(),
+                FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW_OUT.getType()),null) * -1;
+        //查询已提现金额
+        double withdrawAmount = finTranRecordService.sumCoinByType(userid,Arrays.asList(FinTranType3.CASH_DIAMOND_INCOME_BACK.getType(),
+                FinTranType3.CASH_DIAMOND_INCOME.getType()), null);
+        double totalAmount = bettingAmount-(withdrawAmount*-1*2);
+        amountVo.setGameAmount(totalAmount<0?0:totalAmount);
+        /*//查询额外补足流水
+        double outAmount = finTranRecordService.sumCoinByType(userid,Arrays.asList(FinTranType3.CONSUM_GAME_ANCHOR_ZHUANPAN.getType(),
+                FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW.getType(),
+                FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW_OUT.getType()), DateUtil.format(time,"yyyy-MM-dd HH:mm:ss"));
+        amount += outAmount;*/
         amountVo.setLackAmount(amount>0?amount:0);
         return R.ok(amountVo);
     }

+ 6 - 0
game-business/src/main/java/com/game/business/domain/FinTranRecord.java

@@ -237,6 +237,12 @@ private static final long serialVersionUID=1L;
     @TableField(value = "withdraw_flag")
     private Integer withdrawFlag;
 
+    /**  已满足提现时间 */
+    @ApiModelProperty(value = " 已满足提现时间")
+    @Excel(name = "已满足提现时间")
+    @TableField(value = "withdraw_time")
+    private Date withdrawTime;
+
     @TableField(exist = false)
     private String beginTime;
 

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

@@ -92,4 +92,6 @@ public interface FinTranRecordMapper extends BaseMapper<FinTranRecord> {
     RechargeAmountVo selectRechargeAmount(@Param("userId") Long userId, @Param("withdrawFlag") Integer withdrawFlag);
 
     Date selectRechargeDate(@Param("userId") Long userId, @Param("withdrawFlag") Integer withdrawFlag);
+
+    Double sumCoinByType(@Param("userId") Long userId,@Param("type3s") List<Integer> type3s,@Param("dateTime") String dateTime);
 }

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

@@ -119,4 +119,13 @@ public interface IFinTranRecordService extends IService<FinTranRecord> {
     RechargeAmountVo selectRechargeAmount(Long userId, Integer withdrawFlag);
 
     Date selectRechargeDate(Long userId,Integer withdrawFlag);
+
+    Double sumCoinByType(Long userId,List<Integer> type3s,String dateTime);
+
+    /**
+     * 查询最近一条已满足/作废提现充值流水
+     * */
+    FinTranRecord getFinByUserId(Long userId);
+
+
 }

+ 24 - 0
game-business/src/main/java/com/game/business/service/impl/FinTranRecordServiceImpl.java

@@ -5,6 +5,8 @@ import cn.hutool.core.thread.ThreadUtil;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
 import java.math.BigDecimal;
@@ -468,4 +470,26 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
     public Date selectRechargeDate(Long userId, Integer withdrawFlag) {
         return finTranRecordMapper.selectRechargeDate(userId,withdrawFlag);
     }
+
+    @Override
+    @DataSource(DataSourceType.SLAVE)
+    public Double sumCoinByType(Long userId, List<Integer> type3s, String dateTime) {
+        return finTranRecordMapper.sumCoinByType(userId,type3s,dateTime);
+    }
+
+    @Override
+    @DataSource(DataSourceType.SLAVE)
+    public FinTranRecord getFinByUserId(Long userId) {
+        LambdaQueryWrapper<FinTranRecord> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(FinTranRecord::getUid,userId);
+        queryWrapper.in(FinTranRecord::getTranType3,FinTranType3.ON_LINE_CHARGE.getType(), FinTranType3.CHARGE_IN.getType(),FinTranType3.CHARGE_IN_Back.getType());
+        queryWrapper.eq(FinTranRecord::getCurrencyType,4);
+        queryWrapper.in(FinTranRecord::getWithdrawFlag,1,2);
+        queryWrapper.orderByDesc(FinTranRecord::getCreateTime);
+        IPage<FinTranRecord> page = finTranRecordMapper.selectPage(new Page<FinTranRecord>(0,1),queryWrapper);
+        if(null != page && null != page.getRecords() && page.getRecords().size() > 0) {
+            return page.getRecords().get(0);
+        }
+        return null;
+    }
 }

+ 24 - 1
game-business/src/main/java/com/game/business/task/AppUserCountTask.java

@@ -642,7 +642,7 @@ public class AppUserCountTask {
     private boolean dealTran(List<FinTranRecord> userChargeList,Date beginDate,Date endDate,Long userId,Double money){
         boolean flag = false;
         //查询用户这段时间流水记录
-        String type3s = FinTranType3.CONSUM_GAME_ANCHOR_ZHUANPAN.getType() + "," + FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW.getType();
+        String type3s = FinTranType3.CONSUM_GAME_ANCHOR_ZHUANPAN.getType() + "," + FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW.getType() + "," + FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW_OUT;
         List<FinTranRecord> curTranList = finTranRecordService.selectUserTran(null,type3s,userId,beginDate,endDate,0);
         //获取用户资产
         AppUser appUser = appUserService.getUserAsset(userId);
@@ -688,6 +688,7 @@ public class AppUserCountTask {
                     FinTranRecord updateTran = new FinTranRecord();
                     updateTran.setId(e.getId());
                     updateTran.setWithdrawFlag(1);
+                    updateTran.setWithdrawTime(new Date());
                     finTranRecordService.updateFinTranRecord(updateTran);
                 });
                 flag = true;
@@ -740,6 +741,28 @@ public class AppUserCountTask {
                    /* List<FinTranRecord> curTranList = finTranRecordService.selectUserTran(null, null, userId, null, null, null);
                     double withdrawAble = curTranList.stream().filter(e->FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW.getType()!=e.getTranType3().intValue()).mapToDouble(FinTranRecord::getDiamondCoinChange).sum();*/
                     double withdrawAble = finTranRecordService.sumUserTran(null, null, userId, null, null, null);
+                    //查询最后一次已满足充值提现条件时间
+                    FinTranRecord finTranRecord = finTranRecordService.getFinByUserId(userId);
+                    if(null != finTranRecord){
+                        double amount = finTranRecordService.sumCoinByType(userId,Arrays.asList(FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW_OUT.getType())
+                                ,DateUtil.format(finTranRecord.getWithdrawTime(),"yyyy-MM-dd HH:mm:ss"));
+                        amount = amount * -1;//转为正数
+                        if(amount > 0){
+                            //如果后台扣减了打码量
+                            double dAmount = finTranRecordService.sumCoinByType(userId,
+                                    Arrays.asList(
+                                            FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW_OUT.getType(),
+                                            FinTranType3.CONSUM_GAME_ANCHOR_ZHUANPAN.getType(),
+                                            FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW.getType()
+                                    )
+                                    ,DateUtil.format(finTranRecord.getWithdrawTime(),"yyyy-MM-dd HH:mm:ss"));
+                            if(dAmount < 0 ){
+                                //未满足后台扣减的打码量 扣除对应可提现金额
+                                withdrawAble -= BigDecimal.valueOf(amount).divide(BigDecimal.valueOf(2),BigDecimal.ROUND_HALF_UP).doubleValue();
+                            }
+                        }
+                    }
+
                     AppUser updateUser = new AppUser();
                     updateUser.setUserid(userId);
                     updateUser.setWithdrawAble(withdrawAble);

+ 1 - 1
game-business/src/main/java/com/game/business/vo/RechargeAmountVo.java

@@ -16,7 +16,7 @@ public class RechargeAmountVo implements Serializable {
     @ApiModelProperty(value = "赠送金额")
     private Double giveAmount = 0.0;
 
-    @ApiModelProperty(value = "打码量")
+    @ApiModelProperty(value = "打码量")
     private Double gameAmount = 0.0;
 
     @ApiModelProperty(value = "缺少打码量")

+ 27 - 1
game-business/src/main/resources/mapper/business/FinTranRecordMapper.xml

@@ -40,10 +40,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="tranType3"    column="tran_type3"    />
         <result property="uid"    column="uid"    />
         <result property="withdrawFlag"    column="withdraw_flag"    />
+        <result property="withdrawTime"    column="withdraw_time"    />
     </resultMap>
 
     <sql id="selectFinTranRecordVo">
-        select id, after_coin, after_money, after_ticket, after_diamond_coin, agent_id, coin_change, diamond_coin_change, commission_related_uid, consumption_coin, consumption_money, create_time, currency_type, from_uid, goods_id, guild_id, manager_co_id, manager_id, money_change, order_id, perc, pro_count, pro_id, remarks, scene_id1, scene_id2, scene_type, ticket_change, to_uid, tran_group_id, tran_type1, tran_type2, tran_type3, uid,withdraw_flag from fin_tran_record
+        select id, after_coin, after_money, after_ticket, after_diamond_coin, agent_id, coin_change, diamond_coin_change, commission_related_uid, consumption_coin, consumption_money, create_time, currency_type, from_uid, goods_id, guild_id, manager_co_id, manager_id, money_change, order_id, perc, pro_count, pro_id, remarks, scene_id1, scene_id2, scene_type, ticket_change, to_uid, tran_group_id, tran_type1, tran_type2, tran_type3, uid,withdraw_flag,withdraw_time from fin_tran_record
     </sql>
 
     <select id="selectFinTranRecordList" parameterType="com.game.business.domain.FinTranRecord" resultMap="FinTranRecordResult">
@@ -131,6 +132,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="tranType3 != null">tran_type3,</if>
             <if test="uid != null">uid,</if>
             <if test="withdrawFlag != null">withdraw_flag,</if>
+            <if test="withdrawTime != null">withdraw_time,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
@@ -168,6 +170,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="tranType3 != null">#{tranType3},</if>
             <if test="uid != null">#{uid},</if>
             <if test="withdrawFlag != null">#{withdrawFlag},</if>
+            <if test="withdrawTime != null">#{withdrawTime},</if>
          </trim>
     </insert>
 
@@ -208,6 +211,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="tranType3 != null">tran_type3 = #{tranType3},</if>
             <if test="uid != null">uid = #{uid},</if>
             <if test="withdrawFlag != null">withdraw_flag = #{withdrawFlag},</if>
+            <if test="withdrawTime != null">withdraw_time = #{withdrawTime},</if>
         </trim>
         where id = #{id}
     </update>
@@ -447,6 +451,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           <if test="withdrawFlag != null">
                 AND a.withdraw_flag = #{withdrawFlag}
           </if>
+          <if test="withdrawFlag == null">
+                AND a.withdraw_flag != -1
+          </if>
           AND a.uid = #{userId}
           AND a.currency_type = 4
         ORDER BY
@@ -470,4 +477,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             a.create_time DESC
     </select>
 
+    <select id="sumCoinByType" resultType="java.lang.Double">
+        SELECT
+            ifnull( sum( diamond_coin_change ), 0 )
+        FROM
+            fin_tran_record
+        WHERE
+            uid = #{userId}
+            and currency_type = 4
+          <if test="type3s != null">
+              and tran_type3 IN
+              <foreach item="id" collection="type3s" open="(" separator="," close=")">
+                  #{id}
+              </foreach>
+          </if>
+          <if test="dateTime != null and dateTime != ''">
+              AND create_time &gt;= #{dateTime}
+          </if>
+    </select>
+
 </mapper>

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

@@ -217,6 +217,11 @@ public enum FinTranType3 {
      */
     CONSUM_GAME_ANCHOR_WITHDRAW(FinTranType2.CONSUM_GAME, 20002, "11577",0),
 
+    /**
+     * 游戏 - 游戏消费 (后台扣减补充流水,用于加大提现条件)
+     */
+    CONSUM_GAME_ANCHOR_WITHDRAW_OUT(FinTranType2.CONSUM_GAME, 20003, "11577",0),
+
     /**
      * 红包 - 发红包
      */

+ 10 - 3
game-ui/src/views/business/user/index.vue

@@ -577,7 +577,11 @@
         <el-form-item label="用户id" prop="userId">
           <el-input v-model="resetWithdrawForm.userId" disabled />
         </el-form-item>
-        <el-form-item label="打码量剩余" prop="userId">
+        <el-form-item label="总打码量" prop="gameAmount">
+          <el-input v-model="rechargeAmount.gameAmount" disabled />
+          <span style="color:red;">包含金额输完后失效的打码量</span>
+        </el-form-item>
+        <el-form-item label="离提现缺少打码量" prop="lackAmount">
           <el-input v-model="rechargeAmount.lackAmount" disabled />
         </el-form-item>
         <el-form-item label="金额" prop="amount">
@@ -595,7 +599,7 @@
     <el-dialog :title="title" :visible.sync="liveOpen" width="700px" append-to-body>
       <el-form :validate-on-rule-change=false label-width="150px">
         <el-form-item label="关播提示" prop="amount" v-if="liveLive.islive == 1">
-          <el-input type="text" v-model="resetWithdrawForm.amount" placeholder="请输入" />
+          <el-input type="text" v-model="liveLive.title" placeholder="请输入" />
         </el-form-item>
 
       </el-form>
@@ -1828,7 +1832,10 @@ export default {
       getRechargeAmount(userid).then(response=>{
         this.rechargeAmount = response.data;
         this.resetWithdrawopen = true;
-        this.resetWithdrawForm.amount = this.rechargeAmount.lackAmount;
+        this.resetWithdrawForm = {
+          userId:userid,
+          amount:this.rechargeAmount.lackAmount
+        };
         this.title = "补足提现流水";
         loading.close();
       })