Bläddra i källkod

支付响应HTML内容封装到PaymentService类

locky 3 år sedan
förälder
incheckning
41c10e4c59
2 ändrade filer med 185 tillägg och 172 borttagningar
  1. 4 172
      Controller/CloudStorage.py
  2. 181 0
      Service/PayService.py

+ 4 - 172
Controller/CloudStorage.py

@@ -60,6 +60,7 @@ from Ansjer.config import SERVER_TYPE
 from Service.ModelService import ModelService
 
 # SERVER_DOMAIN = 'http://test.dvema.com/'
+from Service.PayService import PaymentService
 
 '''
 生成订单
@@ -625,184 +626,15 @@ class CloudStorageView(View):
 
     def do_pay_error(self):
         response = HttpResponse()
-        response.content = '''
-<!DOCTYPE html>
-<html>
-<head>
-	<!--浏览器不缓存-->
-	<meta http-equiv="Pragma" content="no-cache">
-	<meta http-equiv="Cache-Control" content="no-cache">
-	<meta http-equiv="Expires" content="0">
-	<!--utf-8-->
-    <meta http-equiv="content-type" content="text/html;charset=utf-8">
-    <!-- viewport的<meta>标签,这个标签可以修改在大部分的移动设备上面的显示,为了确保适当的绘制和触屏缩放。-->
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <link rel="shortcut icon" href="https://test.zositechc.cn/web/images/favicon.ico" type="image/x-icon"  charset="utf-8"/>  
-    <title>Trading particulars</title>
-    <style>
-    	.title_head{
-    		height: 50px;
-    		border-radius: 5px;
-    		background-color: #c3c6c7; 
-    		text-align: center;
-    		line-height: 50px;
-    	}
-    	.content{
-    		text-align: center;
-    		margin-top: 50px;
-    		font-size: 20px;
-    		color : #ec7648
-    	}
-    	.content_img{
-    		width: 60px; 
-    		height: 60px;
-    	}
-    	.bottom{
-    		 margin-bottom: 10px; 
-    		 margin-top: 250px; 
-    		 color : #ec7648
-    	}
-    	.bottom_div{
-    		border: 1px solid #ec7648; 
-    		line-height: 38px; 
-    		text-align: center; 
-    		width: 100px; 
-    		height: 38px;
-    		border-radius: 5px;
-    	}
-    	
-    	.bottom_div:hover{
-    		background-color: #dde4e2;
-    	}
-    </style>
-</head>
-<body>
-	<div class="title_head">Trading particulars</div>
-    <div class="content">
-    	<p >
-    		<img src="https://test.zositechc.cn/web/images/failed.jpg" class="content_img">
-    		<br />
-    		Payment failure
-    	</p>
-    </div>
-    <center class="bottom">
-    	<div class="bottom_div" onclick="payOKButton()"> 
-    	 Finish
-    	</div>
-    </center>
-    <script> 	    // 点击付款成功按钮
-    function payOKButton() {
-        // 复杂数据
-        console.log('success')
-        window.location.href="https://www.baidu.com?page=closePage";
-    }
-	</script>
-</body> 
-</html>
-                '''
+        response.content = PaymentService.get_pay_error_content()
         return response
 
     def do_pay_ok(self, request_dict):  # 支付成功
         response = HttpResponse()
-        paytype = request_dict.get('paytype', None)
         lang = request_dict.get('lang', 'en')
+        pay_type = request_dict.get('paytype', None)
 
-        showtitle = "支付成功"
-        if paytype == "10" :
-            showtitle = "成功体验云存"
-
-        if paytype == "11":
-            showtitle = "兑换成功"
-
-        wancheng = '完成'
-        if lang != 'cn':
-            showtitle = "Payment successful"
-            if paytype == "10":
-                showtitle = "Successful experience of cloud storage"
-
-            if paytype == "11":
-                showtitle = "Successful exchange"
-
-            wancheng = 'complete'
-        response.content = '''
-        
-<html>
-<head>
-        <!--浏览器不缓存-->
-        <meta http-equiv="Pragma" content="no-cache">
-        <meta http-equiv="Cache-Control" content="no-cache">
-        <meta http-equiv="Expires" content="0">
-        <!--utf-8-->
-    <meta http-equiv="content-type" content="text/html;charset=utf-8">
-    <!-- viewport的<meta>标签,这个标签可以修改在大部分的移动设备上面的显示,为了确保适当的绘制和触屏缩放。-->
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <link rel="shortcut icon" href="https://test.zositechc.cn/web/images/favicon.ico" type="image/x-icon" charset="utf-8">  
-    <title>''' + showtitle + '''</title>
-    <style>
-            .title_head{
-                    height: 50px;
-                    border-radius: 5px;
-                    background-color: #c3c6c7; 
-                    text-align: center;
-                    line-height: 50px;
-            }
-            .content{
-                    text-align: center;
-                    margin-top: 50px;
-                    font-size: 15px;
-                    color:#0000008A;
-					
-            }
-            .content_img{
-					margin-bottom:15px;
-                    width: 60px; 
-                    height: 60px;
-            }
-            .bottom{
-                     margin-bottom: 10px; 
-                     margin-top: 250px; 
-                     color : white;
-            }
-            .bottom_div{
-                    border: 1px solid #68c9c5; 
-                    line-height: 38px; 
-                    text-align: center; 
-                    width: 100px; 
-                    height: 38px;
-                    border-radius: 30px;
-					background-color:#68c9c5; 
-            }
-            
-            .bottom_div:hover{
-                    background-color: #dde4e2;
-            }
-    </style>
-</head>
-<body style="" rlt="1" inmaintabuse="true">
-        
-    <div class="content">
-            <p>
-					<img src="https://test.zositechc.cn/web/images/success.png" class="content_img">
-                    <br>
-                    ''' + showtitle + '''
-            </p>
-    </div>
-    <center class="bottom">
-            <div class="bottom_div" onclick="payOKButton()"> 
-             '''+wancheng+'''
-            </div>
-    </center>
-    <script src="//hm.baidu.com/hm.js?eaa57ca47dacb4ad4f5a257001a3457c"></script><script>             // 点击付款成功按钮
-    function payOKButton() {
-        // 复杂数据
-        console.log('success')
-        window.location.href="https://www.baidu.com?page=closePage"  
-    }
-        </script>
- 
-
-        <div id="qds" style="display:none;"></div></body></html>
-        '''
+        response.content = PaymentService.get_pay_ok_content(lang, pay_type)
         return response
 
     def do_pay_by_ali_callback(self, request):  # 阿里支付回调

+ 181 - 0
Service/PayService.py

@@ -0,0 +1,181 @@
+# -*- coding: utf-8 -*-
+# 支付类
+
+
+class PaymentService:
+
+    # 返回支付失败html内容
+    @staticmethod
+    def get_pay_error_content():
+        return '''
+<!DOCTYPE html>
+<html>
+<head>
+	<!--浏览器不缓存-->
+	<meta http-equiv="Pragma" content="no-cache">
+	<meta http-equiv="Cache-Control" content="no-cache">
+	<meta http-equiv="Expires" content="0">
+	<!--utf-8-->
+    <meta http-equiv="content-type" content="text/html;charset=utf-8">
+    <!-- viewport的<meta>标签,这个标签可以修改在大部分的移动设备上面的显示,为了确保适当的绘制和触屏缩放。-->
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <link rel="shortcut icon" href="https://test.zositechc.cn/web/images/favicon.ico" type="image/x-icon"  charset="utf-8"/>
+    <title>Trading particulars</title>
+    <style>
+    	.title_head{
+    		height: 50px;
+    		border-radius: 5px;
+    		background-color: #c3c6c7;
+    		text-align: center;
+    		line-height: 50px;
+    	}
+    	.content{
+    		text-align: center;
+    		margin-top: 50px;
+    		font-size: 20px;
+    		color : #ec7648
+    	}
+    	.content_img{
+    		width: 60px;
+    		height: 60px;
+    	}
+    	.bottom{
+    		 margin-bottom: 10px;
+    		 margin-top: 250px;
+    		 color : #ec7648
+    	}
+    	.bottom_div{
+    		border: 1px solid #ec7648;
+    		line-height: 38px;
+    		text-align: center;
+    		width: 100px;
+    		height: 38px;
+    		border-radius: 5px;
+    	}
+
+    	.bottom_div:hover{
+    		background-color: #dde4e2;
+    	}
+    </style>
+</head>
+<body>
+	<div class="title_head">Trading particulars</div>
+    <div class="content">
+    	<p >
+    		<img src="https://test.zositechc.cn/web/images/failed.jpg" class="content_img">
+    		<br />
+    		Payment failure
+    	</p>
+    </div>
+    <center class="bottom">
+    	<div class="bottom_div" onclick="payOKButton()">
+    	 Finish
+    	</div>
+    </center>
+    <script> 	    // 点击付款成功按钮
+    function payOKButton() {
+        // 复杂数据
+        console.log('success')
+        window.location.href="https://www.baidu.com?page=closePage";
+    }
+	</script>
+</body>
+</html>
+                '''
+
+    # 返回支付成功html内容
+    @staticmethod
+    def get_pay_ok_content(lang, pay_type):
+        title = "支付成功"
+        complete = '完成'
+        if lang == 'cn':
+            if pay_type == "10":
+                title = "体验成功"
+            if pay_type == "11":
+                title = "兑换成功"
+        else:
+            title = "Payment successful"
+            complete = 'complete'
+            if pay_type == "10":
+                title = "Successful experience"
+            if pay_type == "11":
+                title = "Successful exchange"
+
+        return '''
+        <html>
+        <head>
+                <!--浏览器不缓存-->
+                <meta http-equiv="Pragma" content="no-cache">
+                <meta http-equiv="Cache-Control" content="no-cache">
+                <meta http-equiv="Expires" content="0">
+                <!--utf-8-->
+            <meta http-equiv="content-type" content="text/html;charset=utf-8">
+            <!-- viewport的<meta>标签,这个标签可以修改在大部分的移动设备上面的显示,为了确保适当的绘制和触屏缩放。-->
+            <meta name="viewport" content="width=device-width, initial-scale=1.0">
+            <link rel="shortcut icon" href="https://test.zositechc.cn/web/images/favicon.ico" type="image/x-icon" charset="utf-8">
+            <title>''' + title + '''</title>
+            <style>
+                    .title_head{
+                            height: 50px;
+                            border-radius: 5px;
+                            background-color: #c3c6c7;
+                            text-align: center;
+                            line-height: 50px;
+                    }
+                    .content{
+                            text-align: center;
+                            margin-top: 50px;
+                            font-size: 15px;
+                            color:#0000008A;
+
+                    }
+                    .content_img{
+        					margin-bottom:15px;
+                            width: 60px;
+                            height: 60px;
+                    }
+                    .bottom{
+                             margin-bottom: 10px;
+                             margin-top: 250px;
+                             color : white;
+                    }
+                    .bottom_div{
+                            border: 1px solid #68c9c5;
+                            line-height: 38px;
+                            text-align: center;
+                            width: 100px;
+                            height: 38px;
+                            border-radius: 30px;
+        					background-color:#68c9c5;
+                    }
+
+                    .bottom_div:hover{
+                            background-color: #dde4e2;
+                    }
+            </style>
+        </head>
+        <body style="" rlt="1" inmaintabuse="true">
+
+            <div class="content">
+                    <p>
+        					<img src="https://test.zositechc.cn/web/images/success.png" class="content_img">
+                            <br>
+                            ''' + title + '''
+                    </p>
+            </div>
+            <center class="bottom">
+                    <div class="bottom_div" onclick="payOKButton()">
+                     ''' + complete + '''
+                    </div>
+            </center>
+            <script src="//hm.baidu.com/hm.js?eaa57ca47dacb4ad4f5a257001a3457c"></script><script>             // 点击付款成功按钮
+            function payOKButton() {
+                // 复杂数据
+                console.log('success')
+                window.location.href="https://www.baidu.com?page=closePage"
+            }
+                </script>
+
+
+                <div id="qds" style="display:none;"></div></body></html>
+                '''