jiaojiao7 4 years ago
parent
commit
add8e8801f

+ 1 - 0
conf/dev/base.toml

@@ -19,3 +19,4 @@
     log-in-console= true
 [session]
     redis_token = "token=39.107.203.162:10079,limit=192.168.3.128:1712"
+    interface_call_rate = 20

+ 8 - 5
manage/user/userRecharge.go

@@ -1,13 +1,12 @@
 package user
 
 import (
+	"github.com/gin-gonic/gin"
+	"go.uber.org/zap"
 	"sfbase/global"
 	"sfis/model/response"
 	"sfis/service"
 	"strconv"
-
-	"github.com/gin-gonic/gin"
-	"go.uber.org/zap"
 )
 
 //余额充值接口
@@ -37,8 +36,10 @@ func productRecharge(c *gin.Context) {
 	appid := c.PostForm("appid")
 	productId, err := strconv.Atoi(c.PostForm("productId"))
 	rechargeNum, errs := strconv.Atoi(c.PostForm("rechargeNum"))
+	startTime := c.PostForm("startTime")
 	endTime := c.PostForm("endTime")
-	if err != nil || errs != nil {
+	tradeMoney, errs_ := strconv.Atoi(c.PostForm("tradeMoney"))
+	if err != nil || errs != nil || errs_ != nil {
 		response.FailWithDetailed(response.ParamError, nil, "参数错误", c)
 		return
 	}
@@ -46,10 +47,12 @@ func productRecharge(c *gin.Context) {
 		"appid":       appid,
 		"productId":   productId,
 		"rechargeNum": rechargeNum,
+		"startTime":   startTime,
 		"endTime":     endTime,
+		"tradeMoney":  tradeMoney,
 	}
 	global.Logger.Info("api productRecharge:", zap.Any("param:", p))
-	errss := service.ProductRecharge(appid, productId, rechargeNum, endTime, c)
+	errss := service.ProductRecharge(appid, productId, rechargeNum, startTime, endTime, tradeMoney, c)
 	if errs == nil {
 		response.Ok(c)
 	} else {

+ 1 - 0
model/user.go

@@ -62,6 +62,7 @@ func (p *UserBuyRecord) TableName() string {
 type UserCallRecord struct {
 	ID            int       `json:"id" gorm:"primaryKey"`
 	AppID         string    `json:"app_id"`
+	ProductId     int       `json:"product_id"`
 	UserProductId int       `json:"user_product_id"`
 	Status        int       `json:"status"`
 	Ip            string    `json:"ip"`

+ 4 - 1
router/pageRouter.go

@@ -17,6 +17,7 @@ func pageRouterRegister(router *gin.Engine) {
 		pageRouterGroup.GET("/projectListDetail", projectListDetailPage)
 		pageRouterGroup.GET("/interfaceListPage", interfaceListPage)
 		pageRouterGroup.GET("/moneyRechargePage", moneyRechargePage)
+		pageRouterGroup.GET("/callLogPage", callLogPage)
 	}
 }
 
@@ -56,4 +57,6 @@ func moneyRechargePage(context *gin.Context) {
 	context.HTML(200, "moneyRecharge.html", nil)
 }
 
-
+func callLogPage(context *gin.Context) {
+	context.HTML(200, "callLog.html", nil)
+}

+ 6 - 1
service/callLog.go

@@ -4,6 +4,7 @@ import (
 	"log"
 	"sfis/db"
 	"sfis/model"
+	"sfis/utils"
 	"strings"
 	"time"
 )
@@ -31,11 +32,15 @@ func CallLog(appid, startTime, endTime string) ([]map[string]interface{}, error)
 		return nil, err
 	} else {
 		for _, v := range userCallRecord {
+			productname := ""
+			if product, ok := utils.ProductCaches.Map.Load(v.ProductId); ok {
+				productname = product.(*model.Product).Name
+			}
 			dataMap := map[string]interface{}{
 				"app_id":     v.AppID,
 				"invok_time": v.CreateAt.Local().Format("2006-01-02 15:04:05"),
 				"ip":         v.Ip,
-				//TODO
+				"name":       productname,
 			}
 			datas = append(datas, dataMap)
 		}

+ 3 - 4
service/user.go

@@ -63,13 +63,12 @@ func CreateUserProduct(appId string, productArr []map[string]interface{}) (statu
 	return 1, haveProductId, errArr
 }
 
-func UserProductList(appId string, c *gin.Context) (userProduct []model.UserProduct, err error) {
-	//userProduct := []model.UserProduct{}
-	err = db.GetSFISDB().Where("app_id = ? ", appId).Find(&userProduct).Error
+func UserProductList(appId string, c *gin.Context) (results []map[string]interface{}, err error) {
+	err = db.GetSFISDB().Table("user_product").Select("user_product.app_id, user_product.product_id,user_product.create_at,user_product.start_at,user_product.end_at,user_product.left_num,user_product.cost_model,user_product.interface_status,user_product.call_times_limit_day,user_product.data_num_limit_one_times,product.name").Joins("left join product on product.id = user_product.product_id").Where("app_id = ? ", appId).Scan(&results).Error
 	if err != nil {
 		log.Printf("appID:[%s] find into user_product error:[%v]", appId, err)
 	}
-	return userProduct, err
+	return results, err
 }
 
 //创建用户

+ 16 - 21
service/userRecharge.go

@@ -1,17 +1,15 @@
 package service
 
 import (
+	"fmt"
+	"github.com/gin-gonic/gin"
+	"gorm.io/gorm"
+	"log"
 	"sfis/db"
 	"sfis/lock"
 	"sfis/model"
-
-	"github.com/gin-gonic/gin"
-
-	"log"
 	"sfis/utils"
 	"time"
-
-	"gorm.io/gorm"
 )
 
 func MoneyRecharge(appid string, money int, context *gin.Context) error {
@@ -46,42 +44,39 @@ func MoneyRecharge(appid string, money int, context *gin.Context) error {
 	return errs
 }
 
-func ProductRecharge(appid string, productId, rechargeNum int, endTime string, context *gin.Context) error {
+func ProductRecharge(appid string, productId, rechargeNum int, startTime string, endTime string, tradeMoney int, context *gin.Context) error {
 	//取出用户锁
 	lock.MainLock.Lock()
 	userLock := lock.UserLockMap[appid]
 	lock.MainLock.Unlock()
 	userLock.Lock()
 	defer userLock.Unlock()
-	endTimes := ""
-	if endTime != "" {
-		end := endTime + " 23:59:59"
-		loc, _ := time.LoadLocation("Local")
-		if ends, err := time.ParseInLocation("2006-01-02 15:04:05", end, loc); err == nil {
-			endTimes = ends.Local().Format("2006-01-02 15:04:05")
-		}
-	}
+
 	//查用户当前剩余量
+	fmt.Println(startTime, endTime)
 	userProduct := &model.UserProduct{}
 	db.GetSFISDB().First(userProduct, &model.UserProduct{AppID: appid, ProductID: productId})
 	product := &model.Product{}
 	if products, ok := utils.ProductCaches.Map.Load(productId); ok {
 		product = products.(*model.Product)
 	}
+	// 更新时间
+	nowStr := time.Now().Local().Format("2006-01-02 15:04:05")
+
 	errs := db.GetSFISDB().Transaction(func(tx *gorm.DB) error {
 		before := userProduct.LeftNum
 		after := userProduct.LeftNum + rechargeNum
 		//充值
 		var err error
-		if endTimes != "" {
-			err = tx.Exec("update user_product set left_num = ?,end_at = ? WHERE `app_id` = ? and product_id = ?", after, endTimes, appid, productId).Error
+		if endTime != "" && startTime != "" {
+			err = tx.Exec("update user_product set left_num = ?,start_at=?,end_at = ? ,update_at = ? WHERE `app_id` = ? and product_id = ?", after, startTime, endTime,nowStr, appid, productId).Error
 			if err != nil {
-				log.Printf("appID:[%s],left_num:[%d],endtime:[%s] execute cost user_product error:[%v]", appid, after, endTimes, err)
+				log.Printf("appID:[%s],left_num:[%d],endtime:[%s],starttime:[%s]  execute cost user_product error:[%v]", appid, after, endTime, startTime, err)
 				tx.Rollback()
 				return err
 			}
 		} else {
-			err = tx.Exec("update user_product set left_num = ? WHERE `app_id` = ? and product_id = ?", after, appid, productId).Error
+			err = tx.Exec("update user_product set left_num = ?,update_at = ? WHERE `app_id` = ? and product_id = ?", after,nowStr, appid, productId).Error
 			if err != nil {
 				log.Printf("appID:[%s],left_num:[%d] execute cost user_product error:[%v]", appid, after, err)
 				tx.Rollback()
@@ -89,9 +84,9 @@ func ProductRecharge(appid string, productId, rechargeNum int, endTime string, c
 			}
 		}
 		//生购买记录
-		err = tx.Exec("insert into user_buy_record (app_id,product_id,user_product_id,`before`,`after`,trade_money,buy_type,history_unit_price) values (?,?,?,?,?,?,?,?)", appid, productId, userProduct.ID, before, after, product.UnitPrice*rechargeNum, 1, product.UnitPrice).Error
+		err = tx.Exec("insert into user_buy_record (app_id,product_id,user_product_id,`before`,`after`,trade_money,buy_type,history_unit_price,create_at) values (?,?,?,?,?,?,?,?,?)", appid, productId, userProduct.ID, before, after, tradeMoney, 1, product.UnitPrice,nowStr).Error
 		if err != nil {
-			log.Printf("appID:[%s],product_id:[%d],user_product_id:[%d],after:[%d],trade_money:[%d] execute insert into user_buy_record error:[%v]", appid, productId, userProduct.ID, after, product.UnitPrice*rechargeNum, err)
+			log.Printf("appID:[%s],product_id:[%d],user_product_id:[%d],after:[%d],trade_money:[%d] execute insert into user_buy_record error:[%v]", appid, productId, userProduct.ID, after, tradeMoney, err)
 			tx.Rollback()
 			return err
 		}

+ 94 - 0
static/templates/callLog.html

@@ -0,0 +1,94 @@
+{{define "callLog.html"}}
+    <!DOCTYPE html>
+    <html lang="en">
+    <head>
+        <meta charset="UTF-8">
+        <title>项目列表页面</title>
+        <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
+        <script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.js"></script>
+    </head>
+    <body>
+    <div id="tableDiv" hidden>
+        <table border="0" id="tableId">
+            <thead>
+            <tr class="tableTitle">
+                {{/*                <th style="width: 20px"><input type="checkbox" name="item"></td></th>*/}}
+                <th style="width: 5%;">序号</th>
+                <th style="width: 20%">接口名称</th>
+                <th style="width: 10%">ip</th>
+                <th style="width: 20%">调用时间</th>
+            </tr>
+            </thead>
+            <tbody class="box">
+
+            </tbody>
+        </table>
+    </div>
+
+    </body>
+    <style>
+        .box tr .td {
+            text-align: center;
+        }
+    </style>
+    <script>
+        var LocString = String(window.document.location.href);
+
+        // 获取页面跳转传过来的参数
+        function GetQueryString(name) {
+            var rs = new RegExp("(^|)" + name + "=([^&]*)(&|$)", "gi").exec(LocString);
+            var tmp;
+            if (tmp = rs) {
+                return decodeURI(tmp[2])
+            }
+            return "";
+        }
+
+        var appid = GetQueryString("appId");
+        var key = GetQueryString("key");
+        
+        var param = {
+            "app_id": appid
+        };
+        var url = "/sfis/api/v1/callLog";
+        var rType = "post";
+        var now = new Date().getTime();
+        var token = md5(appid + Math.round(now / 1000) + key);
+        var hearders = {
+            "timestamp": "" + Math.round(now / 1000),
+            "token": token
+        }
+        $("#tableDiv").hide();
+        submit(param, rType, url, hearders, "callLog");
+
+        function submit(param, rType, url, hearders, str) {
+            $.ajax({
+                url: url,
+                type: rType,
+                headers: hearders,
+                data: param,
+                success: function (r) {
+                    $("#resultContent").text("");
+                    if (r.data) {
+                        $("#tableDiv").show();
+                        var str = "";
+                        for (var i = 0; i < r.data.length; i++) {
+                            var item = r.data[i]
+                            str += '<tr >';
+                            // str += '<td style="width: 20px"></td>';
+                            str += '<td class="td">' + (i + 1) + '</td>';
+                            str += '<td class="td">' + item.name + '</td>';
+                            str += '<td class="td">' + item.ip + '</td>';
+                            str += '<td class="td">' + item.invok_time + '</td>';
+                            str += '</tr>';
+                        }
+                        $(".box").html(str);
+                    } else {
+                        $("#resultContent").text(r.msg);
+                    }
+                }
+            })
+        }
+    </script>
+    </html>
+{{end}}

+ 61 - 11
static/templates/login.html

@@ -79,6 +79,7 @@
                 <tr class="tableTitle">
                     <th style="width: 5%">序号</th>
                     <th style="width: 5%">产品ID</th>
+                    <th style="width: 8%">产品名称</th>
                     <th style="width: 25%">用户APPID</th>
                     <th style="width: 5%">剩余量</th>
                     <th style="width: 10%">扣费模式</th>
@@ -96,11 +97,13 @@
 
     </div>
 
-    {{/*<div class="test">
-        <h3 id="demo">并发测试</h3>
-        <input type="text" placeholder="请输入并发量">
-        <button>确定</button>
-    </div>*/}}
+    {{/*
+<div class="test">
+    <h3 id="demo">并发测试</h3>
+    <input type="text" placeholder="请输入并发量">
+    <button>确定</button>
+</div>
+*/}}
     <div class="result"></div>
 
 
@@ -168,6 +171,7 @@
                                 str += "<tr>";
                                 str += "<td>" + (i + 1) + "</td>";
                                 str += "<td>" + item.product_id + "</td>";
+                                str += "<td>" + item.name + "</td>";
                                 str += "<td>" + item.app_id + "</td>";
                                 str += "<td>" + item.left_num + "</td>";
                                 if (item.cost_model == 0) {
@@ -230,12 +234,58 @@
                     async: false,
                     data: param,
                     success: function (r) {
-                        // if (r.code === 0) {
-                        alert(JSON.stringify(r))
-                        // $(".result").html(r)
-                        // } else {
-                        //
-                        // }
+                        if (r.code === 0) {
+                            var str = "";
+                            console.log(r.data)
+                            if (r.data.length != 0) {
+                                $(".nodata").html("");
+                                $(".userProductDiv").show();
+                                $(".userProTbody").html("");
+                                for (var i = 0; i < r.data.length; i++) {
+                                    var item = r.data[i];
+                                    str += "<tr>";
+                                    str += "<td>" + (i + 1) + "</td>";
+                                    str += "<td>" + item.product_id + "</td>";
+                                    str += "<td>" + item.app_id + "</td>";
+                                    str += "<td>" + item.left_num + "</td>";
+                                    if (item.cost_model == 0) {
+                                        str += "<td>扣量</td>";
+                                    } else {
+                                        str += "<td>扣余额</td>";
+                                    }
+                                    if (item.interface_status == 0) {
+                                        str += "<td>开启</td>";
+                                    } else {
+                                        str += "<td>关闭</td>";
+                                    }
+                                    str += "<td>" + item.call_times_limit_day + "</td>";
+                                    str += "<td>" + item.data_num_limit_one_times + "</td>";
+                                    if (item.product_id === 1000 || item.product_id === 1001) {
+                                        str += "<td class='handle' style='width: 100px ;'><a href=\"/page/projectListPage?appId=" + appId + "&key=" + key + "\" >测试接口</a>";
+                                    } else {
+                                        str += "<td class='handle' style='width: 100px;'><a href=\"/page/projectListDetail?appId=" + appId + "&key=" + key + "\"  >测试接口</a>";
+                                    }
+                                    if (item.cost_model == 0) {
+                                        str += "<a href=\"/page/userRecharge?appId=" + appId + "\"  >剩余量充值</a>"
+                                    }
+                                    str += "<a href=\"/page/callLogPage?appId=" + appId + "&key=" + key + "\"  >调用记录</a>";
+                                    str += "<a onclick=\"myFunction('" + appId + "','" + key + "','" + item.product_id + "')\"  href='javascript:void(0);' style='pointer:hand;'>并发测试</a>"
+                                    // else {
+                                    //
+                                    // }
+                                    str += "</td>";
+                                    str += "</tr>";
+                                }
+                                // console.log(str);
+                                let trBody = $(str);
+                                $(".userProTbody").append(trBody);
+                            } else {
+                                $(".userProductDiv").hide();
+                            }
+
+                        } else {
+                            $(".userProductList").html(r.msg);
+                        }
                     }
                 })
 

+ 117 - 91
static/templates/userRecharge.html

@@ -1,96 +1,122 @@
 {{define "userRecharge.html"}}
-    <!DOCTYPE html>
-    <html lang="en">
-    <head>
-        <meta charset="UTF-8">
-        <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
-        <title>接口服务平台后台管理系统</title>
-    </head>
-    <style>
-      .list a {
-          text-decoration: none;
-      }
-    </style>
-    <body>
-        {{/*<div id="main">
-            <div class="list">
-                <h1>充值接口</h1>
-                <a href="#" onclick="$('#money').show();$('#main').hide();">1.余额充值</a><br>
-                <a href="#" onclick="$('#product').show();$('#main').hide();">2.剩余量充值</a>
-            </div>
-        </div>*/}}
-        {{/*<div id="money" style="display: none;">
-            <input type="number" id="moneys" placeholder="请输入充值金额">
-            <button type="button" id="moneyBtn">提交</button>
-        </div>*/}}
-        <h3>剩余量充值</h3>
-        <div id="product">
-            <!-- <input type="number" id="productId" placeholder="请输入产品id"> -->
-            产品 <select id="productId"></select>
-            <input type="number" id="rechargeNum" placeholder="请输入充值次数">
-            <input type="text" id="endTime" placeholder="请输入结束时间">
-            <button type="button" id="productBtn">提交</button>
-        </div>
-        <div id="resultContent"></div>
-        <script>
-            var appid = getParam("appId");
-            if (appid !== "") {
-                $.ajax({
-                    url: "/manage/user/userProductList",
-                    type: "post",
-                    data: {"appId":appid},
-                    success:function(r){
-                    	if(r.data){
-                            var html = ""
-                            for (var i in r.data){
-                                html += `<option value ="${r.data[i]["product_id"]}">${r.data[i]["product_id"]}</option>`
-                            }
-                            $("#productId").append(html);
-                    	}
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
+    <title>接口服务平台后台管理系统</title>
+</head>
+<style>
+    .list a {
+        text-decoration: none;
+    }
+</style>
+<body>
+{{/*
+<div id="main">
+    <div class="list">
+        <h1>充值接口</h1>
+        <a href="#" onclick="$('#money').show();$('#main').hide();">1.余额充值</a><br>
+        <a href="#" onclick="$('#product').show();$('#main').hide();">2.剩余量充值</a>
+    </div>
+</div>
+*/}}
+{{/*
+<div id="money" style="display: none;">
+    <input type="number" id="moneys" placeholder="请输入充值金额">
+    <button type="button" id="moneyBtn">提交</button>
+</div>
+*/}}
+<h3>剩余量充值</h3>
+<div id="product">
+    <!-- <input type="number" id="productId" placeholder="请输入产品id"> -->
+    产品 <select id="productId"></select><br><br>
+    充值次数 <input type="number" id="rechargeNum" placeholder="请输入充值次数"><br><br>
+    开始时间 <input type="text" id="startTime" placeholder="请输入开始时间"><br><br>
+    结束时间 <input type="text" id="endTime" placeholder="请输入结束时间"><br><br>
+    交易金额 <input type="text" id="tradeMoney" placeholder="请输入交易金额"> <br><br>
+    <button type="button" id="productBtn">提交</button>
+</div>
+<div id="resultContent"></div>
+<script>
+    $(document).ready(function () {
+        // 初始化内容
+        var myDate = new Date;
+        var year = myDate.getFullYear(); //获取当前年
+        var mon = myDate.getMonth() + 1; //获取当前月
+        var date = myDate.getDate(); //获取当前日
+        var h = myDate.getHours();//获取当前小时数(0-23)
+        var m = myDate.getMinutes();//获取当前分钟数(0-59)
+        var s = myDate.getSeconds();//获取当前秒
+        startTime = year + "-" + mon + "-" + date + " " + h + ":" + m + ":" + s
+        endYear = year + 1
+        endTime = endYear + "-" + mon + "-" + date + " " + h + ":" + m + ":" + s
+        console.log(startTime)
+        $("#startTime").val(startTime)
+        $("#endTime").val(endTime)
+    });
+
+    var appid = getParam("appId");
+    if (appid !== "") {
+        $.ajax({
+            url: "/manage/user/userProductList",
+            type: "post",
+            data: {"appId": appid},
+            success: function (r) {
+                if (r.data) {
+                    var html = ""
+                    for (var i in r.data) {
+                        html += `<option value ="${r.data[i]["product_id"]}">${r.data[i]["name"]}(${r.data[i]["product_id"]})</option>`
                     }
-                })
+                    $("#productId").append(html);
+                }
             }
-            
-            $("#productBtn").on("click", function(){
-                var param = {
-                    "appid": appid,
-                    "rechargeNum": $("#rechargeNum").val(),
-                    "productId": $("#productId option:selected").val(),
-                    "endTime": $("#endTime").val()
-                };
-                var url = "/manage/user/productRecharge";
-                var rType = "post";
-                submit(param,rType,url);
-            })
-            
-            // 获取上个页面传来的参数
-            function getParam(name) {
-                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
-                var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
-                var context = "";
-                if (r != null)
-                    context = r[2];
-                reg = null;
-                r = null;
-                return context == null || context == "" || context == "undefined" ? "" : context;
+        })
+    }
+
+    $("#productBtn").on("click", function () {
+        var param = {
+            "appid": appid,
+            "rechargeNum": $("#rechargeNum").val(),
+            "productId": $("#productId option:selected").val(),
+            "startTime": $("#startTime").val(),
+            "endTime": $("#endTime").val(),
+            "tradeMoney": $("#tradeMoney").val() * 100
+        };
+        var url = "/manage/user/productRecharge";
+        var rType = "post";
+        submit(param, rType, url);
+    })
+
+    // 获取上个页面传来的参数
+    function getParam(name) {
+        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
+        var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
+        var context = "";
+        if (r != null)
+            context = r[2];
+        reg = null;
+        r = null;
+        return context == null || context == "" || context == "undefined" ? "" : context;
+    }
+
+    function submit(param, rType, url, hearders) {
+        $.ajax({
+            url: url,
+            type: rType,
+            headers: hearders,
+            data: param,
+            success: function (r) {
+                $("#resultContent").text("");
+                if (r.code === 1000) {
+                    $("#resultContent").text(r.msg);
+                } else {
+                    $("#resultContent").text(r.msg);
+                }
             }
-            function submit(param, rType, url, hearders) {
-                $.ajax({
-                    url: url,
-                    type: rType,
-                    headers: hearders,
-                    data: param,
-                    success: function (r) {
-                        $("#resultContent").text("");
-                        if (r.code === 1000) {
-                            $("#resultContent").text(r.msg);
-                        } else {
-                            $("#resultContent").text(r.msg);
-                        }
-                    }
-                })
-            }
-        </script>
-    </body>
-    </html>
+        })
+    }
+</script>
+</body>
+</html>
 {{end}}

+ 7 - 5
utils/api_util.go

@@ -61,11 +61,13 @@ func Check(appID string, productID int, c *gin.Context, getData func() ([]map[st
 			redis.Put("limit", limittodaykey, 0, int(max-now))
 		}
 	}
-	//
-	limitrate := fmt.Sprintf("limitrate_%d_%s", userProduct.ProductID, userProduct.AppID)
-	Exists, _ := redis.Exists("limit", limitrate)
-	if Exists {
-		response.FailWithDetailed(response.CallRate, nil, "请求频率过快,请稍后重试", c)
+	//请求频率限制
+	if !concurrentTest {
+		limitrate := fmt.Sprintf("limitrate_%d_%s", userProduct.ProductID, userProduct.AppID)
+		Exists, _ := redis.Exists("limit", limitrate)
+		if Exists {
+			response.FailWithDetailed(response.CallRate, nil, "请求频率过快,请稍后重试", c)
+		}
 	}
 	//2.2 取用户(产品余量|钱包账户余额)校验-必须加锁
 	costModel := userProduct.CostModel //扣费模式 0扣余量,1-扣余额