dos 3 місяців тому
батько
коміт
d6dad238a3

+ 32 - 1
game-admin/src/main/java/com/game/web/controller/system/SysConfigController.java

@@ -2,6 +2,10 @@ package com.game.web.controller.system;
 
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.game.common.core.domain.R;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
@@ -72,7 +76,8 @@ public class SysConfigController extends BaseController
     @GetMapping(value = "/configKey/{configKey}")
     public AjaxResult getConfigKey(@PathVariable String configKey)
     {
-        return success(configService.selectConfigByKey(configKey));
+        String data = configService.selectConfigByKey(configKey);
+        return AjaxResult.success(data,data);
     }
 
     /**
@@ -130,4 +135,30 @@ public class SysConfigController extends BaseController
         configService.resetConfigCache();
         return success();
     }
+
+    /**
+     * 根据参数键名更新参数
+     */
+    @PostMapping(value = "/updateByKey")
+    @ApiOperation(value = "根据参数键名更新参数", notes = "根据参数键名更新参数")
+    public R updateByKey(@RequestBody SysConfig config)
+    {
+        LambdaQueryWrapper<SysConfig> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(SysConfig::getConfigKey, config.getConfigKey());
+        SysConfig sysConfig = configService.getOne(queryWrapper);
+        if(null != sysConfig){
+            SysConfig userConfig = new SysConfig();
+            sysConfig.setConfigValue(config.getConfigValue());
+            configService.updateConfig(sysConfig);
+        }else{
+            sysConfig = new SysConfig();
+            sysConfig.setConfigName(config.getConfigName());
+            sysConfig.setConfigKey(config.getConfigKey());
+            sysConfig.setConfigType("Y");
+            sysConfig.setRemark(config.getRemark());
+            sysConfig.setCreateBy(getUsername());
+            configService.insertConfig(sysConfig);
+        }
+        return R.ok("更新成功");
+    }
 }

+ 12 - 5
game-business/src/main/java/com/game/business/controller/AppUserController.java

@@ -19,6 +19,7 @@ import com.game.business.task.AppUserCountTask;
 import com.game.business.util.Md5Utils;
 import com.game.business.util.im.HttpClientUtils;
 import com.game.business.util.im.TencentCloudImUtil;
+import com.game.business.vo.AppRechargeConfigVo;
 import com.game.common.annotation.RepeatSubmit;
 import com.game.common.constant.AppSceneType;
 import com.game.common.constant.finance.*;
@@ -291,16 +292,22 @@ public class AppUserController extends BaseController
                 appUserService.updateUserAmount(rateTran);*/
             }
             double give = 0;
-            if(userChargeDto.getType() == 1  && userChargeDto.getAmount() > 0 && null != userChargeDto.getRate() && userChargeDto.getRate() > 0) { //金币充值不赠送
+            //查询赠送配置
+            AppRechargeConfigVo configVo = appUsersChargeService.getRechargeConfig();
+            if(userChargeDto.getType() == 1
+                    && userChargeDto.getAmount() > 0
+                    && null != userChargeDto.getRate()
+                    && userChargeDto.getRate() > 0
+            ) { //金币充值不赠送
 //            if(null != userChargeDto.getGiveAmount() && userChargeDto.getGiveAmount() > 0){
                 //今日已赠送金额
                 double todayGiveMoney = appUsersChargeService.isChargeToday(userChargeDto.getUserId(),userChargeDto.getType());
-                double giveRate = todayGiveMoney>0?0.02:0.1; //当然首充10% 否则2%
-                if(todayGiveMoney < 2000) { //当日2000封顶
+                double giveRate = todayGiveMoney>0?configVo.getSend()/100:configVo.getFirstSend()/100; //当然首充10% 否则2%
+                if(todayGiveMoney < configVo.getMaxSend() && giveRate > 0) { //当日2000封顶
                     give = BigDecimal.valueOf(userChargeDto.getAmount().doubleValue()
                             * giveRate).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
-                    if((give + todayGiveMoney) > 2000){
-                        give = give - (give + todayGiveMoney - 2000); //赠送金额超过2000则扣减多出的余额
+                    if((give + todayGiveMoney) > configVo.getMaxSend()){
+                        give = give - (give + todayGiveMoney - configVo.getMaxSend()); //赠送金额超过2000则扣减多出的余额
                     }
                     //赠送
                     FinTranRecord giveTran = new FinTranRecord();

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

@@ -3,6 +3,7 @@ package com.game.business.service;
 import java.util.List;
 import com.game.business.domain.AppUsersCharge;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.game.business.vo.AppRechargeConfigVo;
 
 /**
  * 充值记录Service接口
@@ -74,4 +75,6 @@ public interface IAppUsersChargeService extends IService<AppUsersCharge> {
     AppUsersCharge selectByOrderNo(String orderNo);
 
     Double sumCharge(Long userId);
+
+    AppRechargeConfigVo getRechargeConfig();
 }

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

@@ -9,10 +9,12 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
+import com.game.business.vo.AppRechargeConfigVo;
 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 com.game.system.service.ISysConfigService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.game.business.mapper.AppUsersChargeMapper;
@@ -30,6 +32,9 @@ public class AppUsersChargeServiceImpl extends ServiceImpl<AppUsersChargeMapper,
     @Autowired
     private AppUsersChargeMapper appUsersChargeMapper;
 
+    @Autowired
+    private ISysConfigService configService;
+
     /**
      * 查询充值记录
      *
@@ -152,4 +157,17 @@ public class AppUsersChargeServiceImpl extends ServiceImpl<AppUsersChargeMapper,
     public Double sumCharge(Long userId) {
         return appUsersChargeMapper.sumCharge(userId);
     }
+
+    @Override
+    public AppRechargeConfigVo getRechargeConfig() {
+        AppRechargeConfigVo configVo = new AppRechargeConfigVo();
+        String config = configService.selectConfigByKey("app_recharge_config");
+        if(StringUtils.isNotBlank(config)){
+            String[] arr = config.split(",");
+            configVo.setFirstSend(Double.valueOf(arr[0]));
+            configVo.setSend(Double.valueOf(arr[1]));
+            configVo.setMaxSend(Double.valueOf(arr[2]));
+        }
+        return configVo;
+    }
 }

+ 24 - 0
game-business/src/main/java/com/game/business/vo/AppRechargeConfigVo.java

@@ -0,0 +1,24 @@
+package com.game.business.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+@ApiModel("充值配置-app")
+public class AppRechargeConfigVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "当日首充赠送比例%")
+    private Double firstSend = 0.00;
+
+    @ApiModelProperty(value = "非首充赠送比例%")
+    private Double send = 0.00;
+
+    @ApiModelProperty(value = "当日赠送上限")
+    private Double maxSend = 0.00;
+
+}

+ 19 - 0
game-framework/src/main/java/com/game/framework/config/WebConfig.java

@@ -0,0 +1,19 @@
+package com.game.framework.config;
+
+import com.game.framework.interceptor.RequestLoggingInterceptor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@Configuration
+public class WebConfig implements WebMvcConfigurer {
+
+    @Autowired
+    private RequestLoggingInterceptor requestLoggingInterceptor;
+
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        registry.addInterceptor(requestLoggingInterceptor);
+    }
+}

+ 55 - 0
game-framework/src/main/java/com/game/framework/interceptor/RequestLoggingInterceptor.java

@@ -0,0 +1,55 @@
+package com.game.framework.interceptor;
+
+import com.game.common.utils.SecurityUtils;
+import com.game.common.utils.ip.IpUtils;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedReader;
+
+@Log4j2
+@Component
+public class RequestLoggingInterceptor implements HandlerInterceptor {
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
+        Long userId = null;
+        try {
+            userId = SecurityUtils.getUserId();
+        }catch (Exception e){
+
+        }
+        log.info("IP:{},UserId:{},Request Method: {},Version: {}, URL: {}, Parameters: {}",
+                IpUtils.getIpAddr(request),
+                userId,
+                request.getMethod(),
+                request.getHeader("Version"),
+                request.getRequestURL(),
+                request.getMethod().equals("GET")?request.getParameterMap():getBodyParameter(request));
+        return true;
+    }
+
+    @Override
+    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
+        log.info("Response Status: {}", response.getStatus());
+    }
+
+    public String getBodyParameter(HttpServletRequest request) {
+        try {
+            StringBuilder body = new StringBuilder();
+            BufferedReader reader = request.getReader();
+            String line;
+            while ((line = reader.readLine()) != null) {
+                body.append(line);
+            }
+            return body.toString();
+        }catch (Exception e){
+
+        }
+        return "";
+    }
+
+}

+ 3 - 1
game-system/src/main/java/com/game/system/mapper/SysConfigMapper.java

@@ -1,6 +1,8 @@
 package com.game.system.mapper;
 
 import java.util.List;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.game.system.domain.SysConfig;
 
 /**
@@ -8,7 +10,7 @@ import com.game.system.domain.SysConfig;
  * 
  * @author recruit
  */
-public interface SysConfigMapper
+public interface SysConfigMapper extends BaseMapper<SysConfig>
 {
     /**
      * 查询参数配置信息

+ 11 - 9
game-system/src/main/java/com/game/system/service/ISysConfigService.java

@@ -1,6 +1,8 @@
 package com.game.system.service;
 
 import java.util.List;
+
+import com.baomidou.mybatisplus.extension.service.IService;
 import com.game.system.domain.SysConfig;
 
 /**
@@ -8,11 +10,11 @@ import com.game.system.domain.SysConfig;
  * 
  * @author ruoyi
  */
-public interface ISysConfigService
+public interface ISysConfigService extends IService<SysConfig>
 {
     /**
      * 查询参数配置信息
-     * 
+     *
      * @param configId 参数配置ID
      * @return 参数配置信息
      */
@@ -20,7 +22,7 @@ public interface ISysConfigService
 
     /**
      * 根据键名查询参数配置信息
-     * 
+     *
      * @param configKey 参数键名
      * @return 参数键值
      */
@@ -28,14 +30,14 @@ public interface ISysConfigService
 
     /**
      * 获取验证码开关
-     * 
+     *
      * @return true开启,false关闭
      */
     public boolean selectCaptchaEnabled();
 
     /**
      * 查询参数配置列表
-     * 
+     *
      * @param config 参数配置信息
      * @return 参数配置集合
      */
@@ -43,7 +45,7 @@ public interface ISysConfigService
 
     /**
      * 新增参数配置
-     * 
+     *
      * @param config 参数配置信息
      * @return 结果
      */
@@ -51,7 +53,7 @@ public interface ISysConfigService
 
     /**
      * 修改参数配置
-     * 
+     *
      * @param config 参数配置信息
      * @return 结果
      */
@@ -59,7 +61,7 @@ public interface ISysConfigService
 
     /**
      * 批量删除参数信息
-     * 
+     *
      * @param configIds 需要删除的参数ID
      */
     public void deleteConfigByIds(Long[] configIds);
@@ -81,7 +83,7 @@ public interface ISysConfigService
 
     /**
      * 校验参数键名是否唯一
-     * 
+     *
      * @param config 参数信息
      * @return 结果
      */

+ 12 - 10
game-system/src/main/java/com/game/system/service/impl/SysConfigServiceImpl.java

@@ -3,6 +3,8 @@ package com.game.system.service.impl;
 import java.util.Collection;
 import java.util.List;
 import javax.annotation.PostConstruct;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.game.common.annotation.DataSource;
@@ -23,7 +25,7 @@ import com.game.system.service.ISysConfigService;
  * @author recruit
  */
 @Service
-public class SysConfigServiceImpl implements ISysConfigService
+public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements ISysConfigService
 {
     @Autowired
     private SysConfigMapper configMapper;
@@ -42,7 +44,7 @@ public class SysConfigServiceImpl implements ISysConfigService
 
     /**
      * 查询参数配置信息
-     * 
+     *
      * @param configId 参数配置ID
      * @return 参数配置信息
      */
@@ -57,7 +59,7 @@ public class SysConfigServiceImpl implements ISysConfigService
 
     /**
      * 根据键名查询参数配置信息
-     * 
+     *
      * @param configKey 参数key
      * @return 参数键值
      */
@@ -82,7 +84,7 @@ public class SysConfigServiceImpl implements ISysConfigService
 
     /**
      * 获取验证码开关
-     * 
+     *
      * @return true开启,false关闭
      */
     @Override
@@ -98,7 +100,7 @@ public class SysConfigServiceImpl implements ISysConfigService
 
     /**
      * 查询参数配置列表
-     * 
+     *
      * @param config 参数配置信息
      * @return 参数配置集合
      */
@@ -110,7 +112,7 @@ public class SysConfigServiceImpl implements ISysConfigService
 
     /**
      * 新增参数配置
-     * 
+     *
      * @param config 参数配置信息
      * @return 结果
      */
@@ -127,7 +129,7 @@ public class SysConfigServiceImpl implements ISysConfigService
 
     /**
      * 修改参数配置
-     * 
+     *
      * @param config 参数配置信息
      * @return 结果
      */
@@ -150,7 +152,7 @@ public class SysConfigServiceImpl implements ISysConfigService
 
     /**
      * 批量删除参数信息
-     * 
+     *
      * @param configIds 需要删除的参数ID
      */
     @Override
@@ -203,7 +205,7 @@ public class SysConfigServiceImpl implements ISysConfigService
 
     /**
      * 校验参数键名是否唯一
-     * 
+     *
      * @param config 参数配置信息
      * @return 结果
      */
@@ -221,7 +223,7 @@ public class SysConfigServiceImpl implements ISysConfigService
 
     /**
      * 设置cache key
-     * 
+     *
      * @param configKey 参数键
      * @return 缓存键key
      */

+ 8 - 0
game-ui/src/api/system/config.js

@@ -8,6 +8,14 @@ export function listConfig(query) {
     params: query
   })
 }
+// 新增参数配置
+export function updateByKey(data) {
+  return request({
+    url: '/system/config/updateByKey',
+    method: 'post',
+    data: data
+  })
+}
 
 // 查询参数详细
 export function getConfig(configId) {

+ 184 - 0
game-ui/src/views/business/rechargeconfig/index.vue

@@ -0,0 +1,184 @@
+<template>
+  <div class="app-container">
+    <el-form ref="form" :model="form" :rules="rules" label-width="180px">
+      <el-form-item label="每日首充赠送比例(%)" prop="firstSend">
+        <el-input v-model="form.firstSend" type="number" placeholder="请输入当日首充" />
+      </el-form-item>
+      <el-form-item label="非每日首充赠送比例(%)" prop="send" label-width="180px">
+        <el-input v-model="form.send" type="number" placeholder="请输入非每日首充" />
+      </el-form-item>
+      <el-form-item label="每日赠送封顶" prop="maxSend" label-width="180px">
+        <el-input v-model="form.maxSend" type="number" placeholder="请输入每日赠送封顶" />
+      </el-form-item>
+    </el-form>
+    <div slot="footer" class="dialog-footer" style="text-align: right">
+      <el-button type="primary" @click="submitForm">确 定</el-button>
+    </div>
+  </div>
+</template>
+
+<script>
+import {
+  listConfig,
+  getConfig,
+  delConfig,
+  addConfig,
+  updateConfig,
+  refreshCache,
+  getConfigKey,
+  updateByKey
+} from "@/api/system/config";
+
+export default {
+  name: "Channel",
+  dicts: ['app_status_enable', 'app_recharge_withdraw_type', 'app_account_type'],
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      // 选中数组
+      ids: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      typeMap:{},
+      typeList:[],
+      configKey:"app_recharge_config",
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        currencyId: null,
+        icon: null,
+        name: null,
+        key: null,
+        account: null,
+        accountName: null,
+        staus: null,
+        rechargeRate: null,
+        withdrawRate: null,
+        showType:0,
+        otherName:null,
+        otherKey:null
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {
+      }
+    };
+  },
+  created() {
+      this.getList();
+  },
+  methods: {
+    /** 查询充提渠道列表 */
+    getList() {
+      this.loading = true;
+      this.reset();
+      getConfigKey(this.configKey).then(response => {
+        let data= response.data;
+        if(data != undefined && data != null){
+          let arr = data.split(",");
+          this.form = {
+            firstSend: arr[0],
+            send: arr[1],
+            maxSend: arr[2],
+            configKey: this.configKey
+          }
+        }
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        firstSend: '',
+        send: '',
+        maxSend: ''
+      };
+      this.resetForm("form");
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.id)
+      this.single = selection.length!==1
+      this.multiple = !selection.length
+    },
+    /** 新增按钮操作 */
+    handleAdd() {
+      this.reset();
+      this.open = true;
+      this.title = "添加充提渠道";
+    },
+    /** 修改按钮操作 */
+    handleUpdate(row) {
+      this.reset();
+      const id = row.id || this.ids
+      getChannel(id).then(response => {
+        this.form = response.data;
+        this.open = true;
+        this.title = "修改充提渠道";
+      });
+    },
+    /** 提交按钮 */
+    submitForm() {
+      this.$refs["form"].validate(valid => {
+        if (valid) {
+          this.$confirm('是否确认修改?', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning'
+          }).then(() => {
+            const loading = this.$loading({
+              lock: true,
+              text: 'Loading',
+              spinner: 'el-icon-loading',
+              background: 'rgba(0, 0, 0, 0.7)'
+            });
+            this.form["configValue"] = this.form.firstSend + "," + this.form.send + "," + this.form.maxSend;
+            this.form["configName"] = "充值赠送设置";
+            this.form["remark"] = "充值赠送设置逗号隔开,今日首充(%),非今日首充(%),赠送上限";
+            updateByKey(this.form).then(response=>{
+              this.$message({
+                type: 'success',
+                message: '修改成功!'
+              });
+              this.getList();
+              loading.close();
+            })
+          }).catch(() => {
+            this.$message({
+              type: 'info',
+              message: '已取消修改'
+            });
+          });
+        }
+      });
+    }
+  }
+};
+</script>

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

@@ -28,7 +28,7 @@
       <el-form-item label="登录ip地址" prop="ipaddr">
         <el-input
           v-model="queryParams.ipaddr"
-          placeholder="请输入手机号 "
+          placeholder="请输入登录ip地址 "
           clearable
           @keyup.enter.native="handleQuery"
         />