xuzhiheng 4 жил өмнө
parent
commit
aafc0dce7a

+ 3 - 1
manage/user/user.go

@@ -67,9 +67,11 @@ func userProductChoose(c *gin.Context) {
 		productArr = sutils.ObjArrToMapArr(_products)
 		productArr = sutils.ObjArrToMapArr(_products)
 		log.Println(productArr)
 		log.Println(productArr)
 	}
 	}
-	//log.Println(len(productArr), appId)
+	log.Println("appid", appId)
+	log.Println(len(productArr), appId)
 	if appId != "" && len(productArr) > 0 {
 	if appId != "" && len(productArr) > 0 {
 		status, haveProductId, err := service.CreateUserProduct(appId, productArr, buyType)
 		status, haveProductId, err := service.CreateUserProduct(appId, productArr, buyType)
+		log.Println(status, haveProductId, err)
 		if status == 1 && err == nil {
 		if status == 1 && err == nil {
 			if haveProductId != "" {
 			if haveProductId != "" {
 				response.OkWithMessage("用户已购买过"+haveProductId+"产品,请去充值", c)
 				response.OkWithMessage("用户已购买过"+haveProductId+"产品,请去充值", c)

+ 4 - 0
router/pageRouter.go

@@ -9,6 +9,7 @@ func pageRouterRegister(router *gin.Engine) {
 	//pageRouterGroup.Use(middleware.JwtAuth())
 	//pageRouterGroup.Use(middleware.JwtAuth())
 	{
 	{
 		pageRouterGroup.GET("/main", mainPage)
 		pageRouterGroup.GET("/main", mainPage)
+		pageRouterGroup.GET("/chooseProductPage", chooseProductPage)
 		pageRouterGroup.GET("/createUser", createUser)
 		pageRouterGroup.GET("/createUser", createUser)
 		pageRouterGroup.GET("/userRecharge", userRechargePage)
 		pageRouterGroup.GET("/userRecharge", userRechargePage)
 	}
 	}
@@ -18,6 +19,9 @@ func mainPage(context *gin.Context) {
 	context.HTML(200, "login.html", nil)
 	context.HTML(200, "login.html", nil)
 }
 }
 
 
+func chooseProductPage(context *gin.Context) {
+	context.HTML(200, "chooseProduct.html", nil)
+}
 func createUser(context *gin.Context) {
 func createUser(context *gin.Context) {
 	context.HTML(200, "create_user.html", nil)
 	context.HTML(200, "create_user.html", nil)
 }
 }

+ 149 - 0
static/templates/chooseProduct.html

@@ -0,0 +1,149 @@
+{{define "chooseProduct.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>
+        <script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.js"></script>
+        <title>用户选择产品页面</title>
+    </head>
+    <body>
+    <table border="0" id="tableId">
+        <thead>
+        <tr class="tableTitle">
+            <th style="width: 20px"><input type="checkbox" name="item">
+            </td></th>
+            <th style="width: 50px">序号</th>
+            <th style="width: 100px">产品名称</th>
+            <th style="width: 200px">url</th>
+            <th style="width: 100px">产品单价</th>
+            <th style="width: 100px">产品类型</th>
+            <th style="width: 100px">最小单位</th>
+            <th style="width: 100px">试用次数</th>
+            {{/*            <th style="width: 100px">开始时间</th>*/}}
+            {{/*            <th style="width: 100px">结束时间</th>*/}}
+            {{/*            <th style="width: 100px">结束时间</th>*/}}
+        </tr>
+        </thead>
+        <tbody class="box">
+
+        </tbody>
+    </table>
+    <div style="margin-top: 20px">
+        开始时间:<input id="startTime" type="text">
+        结束时间:<input id="endTime" type="text" name="" id=""><br>
+        扣费模式:<select id="costModel" style="width: 165px;height: 25px;margin-top: 10px">
+            <option value="0">剩余量</option>
+            <option value="1">余额</option>
+        </select>
+        充值量:<input id="leftNum" type="text"><br>
+        充值金额:<input id="money" type="text">
+        产品状态:<select id="interfaceStatus" style="width: 165px;height: 25px;margin-top: 10px">
+            <option value="0">开启</option>
+            <option value="1">关闭</option>
+        </select><br>
+        每日调用次数:<input id="dayLimit" type="text">
+        每次获取数据量:<input id="oneLimit" type="text">
+        用户appid:<input id="appId" type="text">
+    </div>
+    <div style="margin-top: 10px">
+        <button type="submit" onclick="submit()" style="width: 80px;height: 30px;">提交</button>
+    </div>
+
+    <div>
+        <p class="result"></p>
+    </div>
+
+    </body>
+    </html>
+    <script>
+        productList()
+
+        function productList() {
+            $.ajax({
+                url: "/manage/product/list",
+                type: "POST",
+                dataType: "json",
+                async: false,
+                success: function (r) {
+                    if (r.code === 0) {
+                        console.log(r.data)
+                        var str = ""
+                        for (var i = 0; i < r.data.length; i++) {
+                            var item = r.data[i];
+                            str += '<tr>';
+                            str += '<td style="width: 20px"><input id=' + item["id"] + ' value=' + item["id"] + ' type="radio" name="item"></td>';
+                            str += '<td style="width: 50px">' + (i + 1) + '</td>';
+                            str += '<td style="width: 100px">' + item.name + '</td>';
+                            str += '<td style="width: 200px">' + item.url + '</td>';
+                            str += '<td style="width: 100px">' + item.unit_price + '</td>';
+                            if (item.product_type === 0) {
+                                str += '<td style="width: 100px">按次</td>';
+                            } else {
+                                str += '<td style="width: 100px">按条</td>';
+                            }
+
+                            str += '<td style="width: 100px">' + item.min_unit + '</td>';
+                            str += '<td style="width: 100px">' + item.test_num + '</td>';
+                            str += '</tr>';
+                        }
+                        $('.box').html(str);
+                    } else {
+
+                    }
+                }
+            })
+        }
+
+        function submit() {
+            var productId = $("input[name='item']:checked").val();
+            var startTime = $("#startTime").val();
+            var endTime = $("#endTime").val();
+            var leftNum = $("#leftNum").val();
+            var money = $("#money").val();
+            var costModel = $("#costModel").find("option:selected").val();
+            var interfaceStatus = $("#interfaceStatus").find("option:selected").val();
+            var dayLimit = $("#dayLimit").val();
+            var oneLimit = $("#oneLimit").val();
+            var appId = $("#appId").val();
+            var product = {}
+            product["productId"] = productId
+            product["startTime"] = startTime
+            product["endTime"] = endTime
+            product["leftNum"] = leftNum
+            product["tradeMoney"] = money
+            product["costModel"] = costModel
+            product["interfaceStatus"] = interfaceStatus
+            product["callTimesLimitDay"] = dayLimit
+            product["dataNumOneTimes"] = oneLimit
+            var products = []
+            products.push(product)
+            param = {
+                "products": products,
+                "appId": appId,
+                "buyType": 1,
+            }
+            console.log("参数:", param)
+            /*if (productId === undefined || productId === "") {
+                return
+            }*/
+            $.ajax({
+                url: "/manage/user/userProductChoose",
+                data: JSON.stringify(param),
+                type: "POST",
+                dataType: "json",
+                async: false,
+                success: function (r) {
+                    var a = JSON.stringify(r)
+                    $(".result").html(a);
+                    /*if (r.code == 0) {
+                        $(".result").html("请求成功!" + r.msg);
+                    } else {
+                        $(".result").html("购买产品失败!" + r.msg);
+                    }
+*/
+                }
+            })
+        }
+    </script>
+{{end}}

+ 8 - 2
static/templates/login.html

@@ -8,7 +8,7 @@
         <title>接口服务平台后台管理系统</title>
         <title>接口服务平台后台管理系统</title>
     </head>
     </head>
     <style>
     <style>
-      
+
     </style>
     </style>
     <body>
     <body>
         <dev id="main">
         <dev id="main">
@@ -22,6 +22,12 @@
             <dev>
             <dev>
                 <a href="/page/createUser">1.创建用户</a>
                 <a href="/page/createUser">1.创建用户</a>
             </dev>
             </dev>
+            <h1>产品接口</h1>
+            <dev>
+                <a href="/page/chooseProductPage">1.选择产品</a>
+                <a>2.余额充值</a>
+                <a>3.产品充值</a>
+            </dev>
         </dev>
         </dev>
         <dev id="projectList" style="display: none;">
         <dev id="projectList" style="display: none;">
             <input type="text" id="projectName" placeholder="请输入项目名">
             <input type="text" id="projectName" placeholder="请输入项目名">
@@ -100,7 +106,7 @@
                 }
                 }
                 submit(param,rType,url,hearders,"listDetail");
                 submit(param,rType,url,hearders,"listDetail");
             })
             })
-        </script>
+    </script>
     </body>
     </body>
     </html>
     </html>
 {{end}}
 {{end}}