Browse Source

配置接口

dos 2 months ago
parent
commit
2b9604339e

+ 115 - 0
game-business/src/main/java/com/game/business/controller/CfgCommonController.java

@@ -0,0 +1,115 @@
+package com.game.business.controller;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import com.game.common.core.domain.R;
+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.CfgCommon;
+import com.game.business.service.ICfgCommonService;
+import com.game.common.utils.poi.ExcelUtil;
+import com.game.common.core.page.TableDataInfo;
+
+/**
+ * 公共配置Controller
+ * 
+ * @author game
+ * @date 2024-07-13
+ */
+@RestController
+@RequestMapping("/business/common")
+@Api(value = "CfgCommonController", description = "公共配置接口", tags = {"公共配置"})
+public class CfgCommonController extends BaseController
+{
+    @Autowired
+    private ICfgCommonService cfgCommonService;
+
+    /**
+     * 查询公共配置列表
+     */
+    @PreAuthorize("@ss.hasPermi('business:common:list')")
+    @GetMapping("/list")
+    @ApiOperation(value = "查询公共配置列表", notes = "获取公共配置列表")
+    public TableDataInfo<CfgCommon> list(CfgCommon cfgCommon)
+    {
+        startPage();
+        List<CfgCommon> list = cfgCommonService.selectCfgCommonList(cfgCommon);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出公共配置列表
+     */
+    @PreAuthorize("@ss.hasPermi('business:common:export')")
+    @Log(title = "公共配置", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    @ApiOperation(value = "导出公共配置列表", notes = "导出公共配置列表")
+    public void export(HttpServletResponse response, CfgCommon cfgCommon)
+    {
+        List<CfgCommon> list = cfgCommonService.selectCfgCommonList(cfgCommon);
+        ExcelUtil<CfgCommon> util = new ExcelUtil<CfgCommon>(CfgCommon.class);
+        util.exportExcel(response, list, "公共配置数据");
+    }
+
+    /**
+     * 获取公共配置详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('business:common:query')")
+    @GetMapping(value = "/{id}")
+    @ApiOperation(value = "获取公共配置详细信息", notes = "获取公共配置详细信息")
+    public R<CfgCommon> getInfo(@PathVariable("id") Long id)
+    {
+        return R.ok(cfgCommonService.selectCfgCommonById(id));
+    }
+
+    /**
+     * 新增公共配置
+     */
+    @PreAuthorize("@ss.hasPermi('business:common:add')")
+    @Log(title = "公共配置", businessType = BusinessType.INSERT)
+    @ApiOperation(value = "新增公共配置", notes = "新增公共配置")
+    @PostMapping
+    public R add(@RequestBody CfgCommon cfgCommon)
+    {
+        return R.ok(cfgCommonService.insertCfgCommon(cfgCommon));
+    }
+
+    /**
+     * 修改公共配置
+     */
+    @PreAuthorize("@ss.hasPermi('business:common:edit')")
+    @Log(title = "公共配置", businessType = BusinessType.UPDATE)
+    @ApiOperation(value = "修改公共配置", notes = "修改公共配置")
+    @PutMapping
+    public R edit(@RequestBody CfgCommon cfgCommon)
+    {
+        return R.ok(cfgCommonService.updateCfgCommon(cfgCommon));
+    }
+
+    /**
+     * 删除公共配置
+     */
+    @PreAuthorize("@ss.hasPermi('business:common:remove')")
+    @Log(title = "公共配置", businessType = BusinessType.DELETE)
+    @ApiOperation(value = "删除公共配置", notes = "删除公共配置")
+	@DeleteMapping("/{ids}")
+    public R remove(@PathVariable Long[] ids)
+    {
+        return R.ok(cfgCommonService.deleteCfgCommonByIds(ids));
+    }
+}

+ 45 - 0
game-business/src/main/java/com/game/business/domain/CfgCommon.java

@@ -0,0 +1,45 @@
+package com.game.business.domain;
+
+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;
+
+/**
+ * 公共配置对象 cfg_common
+ *
+ * @author game
+ * @date 2024-07-13
+ */
+@ApiModel(value = "cfg_common", description = "公共配置")
+@TableName(value= "cfg_common")
+@Data
+public class CfgCommon
+        {
+private static final long serialVersionUID=1L;
+
+    /** $column.columnComment */
+    @ApiModelProperty(value = "$column.columnComment")
+    @TableId(value = "id" , type = IdType.AUTO)
+    private Long id;
+
+    /** 配置值 */
+    @ApiModelProperty(value = "配置值")
+    @Excel(name = "配置值")
+    @TableField(value = "cfg_value")
+    private String cfgValue;
+
+    /** 类型 0:团队转账限额  10:邀请奖励 */
+    @ApiModelProperty(value = "类型 0:团队转账限额  10:邀请奖励  20:直播客服  30:游戏客服 40:支付客服")
+    @Excel(name = "类型 0:团队转账限额  10:邀请奖励  20:直播客服  30:游戏客服 40:支付客服")
+    @TableField(value = "type")
+    private int type;
+
+}

+ 61 - 0
game-business/src/main/java/com/game/business/mapper/CfgCommonMapper.java

@@ -0,0 +1,61 @@
+package com.game.business.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.game.business.domain.CfgCommon;
+
+/**
+ * 公共配置Mapper接口
+ *
+ * @author game
+ * @date 2024-07-13
+ */
+public interface CfgCommonMapper extends BaseMapper<CfgCommon> {
+    /**
+     * 查询公共配置
+     *
+     * @param id 公共配置主键
+     * @return 公共配置
+     */
+    public CfgCommon selectCfgCommonById(Long id);
+
+    /**
+     * 查询公共配置列表
+     *
+     * @param cfgCommon 公共配置
+     * @return 公共配置集合
+     */
+    public List<CfgCommon> selectCfgCommonList(CfgCommon cfgCommon);
+
+    /**
+     * 新增公共配置
+     *
+     * @param cfgCommon 公共配置
+     * @return 结果
+     */
+    public int insertCfgCommon(CfgCommon cfgCommon);
+
+    /**
+     * 修改公共配置
+     *
+     * @param cfgCommon 公共配置
+     * @return 结果
+     */
+    public int updateCfgCommon(CfgCommon cfgCommon);
+
+    /**
+     * 删除公共配置
+     *
+     * @param id 公共配置主键
+     * @return 结果
+     */
+    public int deleteCfgCommonById(Long id);
+
+    /**
+     * 批量删除公共配置
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteCfgCommonByIds(Long[] ids);
+}

+ 66 - 0
game-business/src/main/java/com/game/business/service/ICfgCommonService.java

@@ -0,0 +1,66 @@
+package com.game.business.service;
+
+import java.util.List;
+import com.game.business.domain.CfgCommon;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 公共配置Service接口
+ *
+ * @author game
+ * @date 2024-07-13
+ */
+public interface ICfgCommonService extends IService<CfgCommon> {
+    /**
+     * 查询公共配置
+     *
+     * @param id 公共配置主键
+     * @return 公共配置
+     */
+    public CfgCommon selectCfgCommonById(Long id);
+
+    /**
+     * 查询公共配置列表
+     *
+     * @param cfgCommon 公共配置
+     * @return 公共配置集合
+     */
+    public List<CfgCommon> selectCfgCommonList(CfgCommon cfgCommon);
+
+    /**
+     * 新增公共配置
+     *
+     * @param cfgCommon 公共配置
+     * @return 结果
+     */
+    public int insertCfgCommon(CfgCommon cfgCommon);
+
+    /**
+     * 修改公共配置
+     *
+     * @param cfgCommon 公共配置
+     * @return 结果
+     */
+    public int updateCfgCommon(CfgCommon cfgCommon);
+
+    /**
+     * 批量删除公共配置
+     *
+     * @param ids 需要删除的公共配置主键集合
+     * @return 结果
+     */
+    public int deleteCfgCommonByIds(Long[] ids);
+
+    /**
+     * 删除公共配置信息
+     *
+     * @param id 公共配置主键
+     * @return 结果
+     */
+    public int deleteCfgCommonById(Long id);
+
+    /**
+     * 获取根据类型配置
+     * */
+    public CfgCommon getCfg(int type);
+}

+ 105 - 0
game-business/src/main/java/com/game/business/service/impl/CfgCommonServiceImpl.java

@@ -0,0 +1,105 @@
+package com.game.business.service.impl;
+
+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.List;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.game.business.mapper.CfgCommonMapper;
+import com.game.business.domain.CfgCommon;
+import com.game.business.service.ICfgCommonService;
+import com.game.common.annotation.DataSource;
+import com.game.common.enums.DataSourceType;
+
+/**
+ * 公共配置Service业务层处理
+ *
+ * @author game
+ * @date 2024-07-13
+ */
+@Service
+public class CfgCommonServiceImpl extends ServiceImpl<CfgCommonMapper, CfgCommon> implements ICfgCommonService {
+    @Autowired
+    private CfgCommonMapper cfgCommonMapper;
+
+    /**
+     * 查询公共配置
+     *
+     * @param id 公共配置主键
+     * @return 公共配置
+     */
+    @Override
+    @DataSource(DataSourceType.SLAVE)
+    public CfgCommon selectCfgCommonById(Long id) {
+        return cfgCommonMapper.selectCfgCommonById(id);
+    }
+
+    /**
+     * 查询公共配置列表
+     *
+     * @param cfgCommon 公共配置
+     * @return 公共配置
+     */
+    @Override
+    @DataSource(DataSourceType.SLAVE)
+    public List<CfgCommon> selectCfgCommonList(CfgCommon cfgCommon) {
+        return cfgCommonMapper.selectCfgCommonList(cfgCommon);
+    }
+
+    /**
+     * 新增公共配置
+     *
+     * @param cfgCommon 公共配置
+     * @return 结果
+     */
+    @Override
+    @DataSource(DataSourceType.SLAVE)
+    public int insertCfgCommon(CfgCommon cfgCommon) {
+            return cfgCommonMapper.insertCfgCommon(cfgCommon);
+    }
+
+    /**
+     * 修改公共配置
+     *
+     * @param cfgCommon 公共配置
+     * @return 结果
+     */
+    @Override
+    @DataSource(DataSourceType.SLAVE)
+    public int updateCfgCommon(CfgCommon cfgCommon) {
+        return cfgCommonMapper.updateCfgCommon(cfgCommon);
+    }
+
+    /**
+     * 批量删除公共配置
+     *
+     * @param ids 需要删除的公共配置主键
+     * @return 结果
+     */
+    @Override
+    @DataSource(DataSourceType.SLAVE)
+    public int deleteCfgCommonByIds(Long[] ids) {
+        return cfgCommonMapper.deleteCfgCommonByIds(ids);
+    }
+
+    /**
+     * 删除公共配置信息
+     *
+     * @param id 公共配置主键
+     * @return 结果
+     */
+    @Override
+    @DataSource(DataSourceType.SLAVE)
+    public int deleteCfgCommonById(Long id) {
+        return cfgCommonMapper.deleteCfgCommonById(id);
+    }
+
+    @Override
+    @DataSource(DataSourceType.SLAVE)
+    public CfgCommon getCfg(int type) {
+        LambdaQueryWrapper<CfgCommon> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(CfgCommon::getType, type);
+        return cfgCommonMapper.selectOne(queryWrapper);
+    }
+}

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

@@ -161,6 +161,11 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
         if(appUser.getDiamondCoin().longValue() < transfer.getMoney().longValue()){
             return HttpRet.fail("转账金额不足");
         }
+        //查询当笔限额
+        CfgCommon cfgSignleCommon = cfgCommonService.getCfg(1);
+        if(null != cfgSignleCommon && transfer.getMoney() > Double.parseDouble(cfgSignleCommon.getCfgValue())){
+            return HttpRet.fail("转账失败超出单笔最大限额");
+        }
         //查询当日限额
         CfgCommon cfgCommon = cfgCommonService.getCfg(0);
         if(null != cfgCommon){