|
@@ -27,7 +27,7 @@ from django.views.generic.base import View
|
|
|
|
|
|
from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, OSS_ROLE_ARN, SERVER_DOMAIN, PAYPAL_CRD, \
|
|
|
SERVER_DOMAIN_SSL
|
|
|
-from Model.models import Device_Info, Order_Model, Store_Meal, VodHlsModel, OssCrdModel, UID_Bucket, StsCrdModel, ExperienceContextModel
|
|
|
+from Model.models import Device_Info, Order_Model, Store_Meal, VodHlsModel, OssCrdModel, UID_Bucket, StsCrdModel, ExperienceContextModel, Pay_Type
|
|
|
from Object.AliPayObject import AliPayObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
@@ -78,6 +78,8 @@ class CloudStorageView(View):
|
|
|
return self.do_pay_by_paypal_callback(request_dict, response)
|
|
|
elif operation == 'doalicallback':
|
|
|
return self.do_pay_by_ali_callback(request)
|
|
|
+ elif operation == 'dowechatnotify':
|
|
|
+ return self.do_pay_by_wechat_callback(request_dict,response)
|
|
|
elif operation == 'getsignsts':
|
|
|
ip = CommonService.get_ip_address(request)
|
|
|
return self.do_get_sign_sts(request_dict, ip, response)
|
|
@@ -187,16 +189,15 @@ class CloudStorageView(View):
|
|
|
qs = qs.all()
|
|
|
|
|
|
if eq:
|
|
|
- qs=qs.filter(~Q(type='10'))
|
|
|
+ qs=qs.filter(~Q(pay_type='10'))
|
|
|
else:
|
|
|
- qs = qs.filter(type='10')
|
|
|
+ qs = qs.filter(pay_type='10')
|
|
|
|
|
|
qs = qs.values("id", "title", "content", "price",
|
|
|
"day", "currency", "bucket__storeDay",
|
|
|
- "bucket__bucket", "bucket__area", "type",
|
|
|
+ "bucket__bucket", "bucket__area",
|
|
|
"commodity_code", "commodity_type")
|
|
|
|
|
|
-
|
|
|
if qs.exists():
|
|
|
ql = list(qs)
|
|
|
from operator import itemgetter
|
|
@@ -204,7 +205,12 @@ class CloudStorageView(View):
|
|
|
ql.sort(key=itemgetter('bucket__area'))
|
|
|
res = []
|
|
|
for area, items in groupby(ql, key=itemgetter('bucket__area')):
|
|
|
- res_c = {'area': area, 'items': list(items)}
|
|
|
+ items_list = list(items)
|
|
|
+ for key, val in enumerate(items_list):
|
|
|
+ pay_types = Pay_Type.objects.filter(store_meal=items_list[key]['id']).values("id","payment")
|
|
|
+ items_list[key]['pay_type'] = list(pay_types)
|
|
|
+
|
|
|
+ res_c = {'area': area, 'items': items_list}
|
|
|
res.append(res_c)
|
|
|
result = {
|
|
|
'meals': res,
|
|
@@ -225,7 +231,8 @@ class CloudStorageView(View):
|
|
|
now_time = int(time.time())
|
|
|
vh_qs = VodHlsModel.objects.filter(uid=uid, channel=channel, time=storeTime, endTime__gte=now_time). \
|
|
|
values("sec", "fg", "bucket__bucket", "bucket__endpoint", "bucket__region", "bucket__mold")
|
|
|
- if not vh_qs.exists(): return response.json(11,'不存在.')
|
|
|
+ if not vh_qs.exists():
|
|
|
+ return response.json(11,'不存在.')
|
|
|
sec = vh_qs[0]['sec']
|
|
|
fg = vh_qs[0]['fg']
|
|
|
bucket__region = vh_qs[0]['bucket__region']
|
|
@@ -460,10 +467,6 @@ class CloudStorageView(View):
|
|
|
( uid=uid, channel=channel, time__range=(startTime, endTime), endTime__gte=now_time). \
|
|
|
values("time", "sec", "bucket__bucket", "fg", "bucket__endpoint", "bucket__region", "bucket__mold")
|
|
|
vod_play_list = []
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
print(int(time.time()))
|
|
|
for vod in vh_qs:
|
|
|
bucket__mold = vod["bucket__mold"]
|
|
@@ -731,80 +734,82 @@ class CloudStorageView(View):
|
|
|
def do_pay_ok(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="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.dvema.com/web/images/favicon.ico" type="image/x-icon" charset="utf-8"/>
|
|
|
+ <link rel="shortcut icon" href="https://test.dvema.com/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 : green
|
|
|
- }
|
|
|
- .content_img{
|
|
|
- width: 60px;
|
|
|
- height: 60px;
|
|
|
- }
|
|
|
- .bottom{
|
|
|
- margin-bottom: 10px;
|
|
|
- margin-top: 250px;
|
|
|
- color : green
|
|
|
- }
|
|
|
- .bottom_div{
|
|
|
- border: 1px solid green;
|
|
|
- line-height: 38px;
|
|
|
- text-align: center;
|
|
|
- width: 100px;
|
|
|
- height: 38px;
|
|
|
- border-radius: 5px;
|
|
|
- }
|
|
|
-
|
|
|
- .bottom_div:hover{
|
|
|
- background-color: #dde4e2;
|
|
|
- }
|
|
|
+ .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>
|
|
|
- <div class="title_head">Trading particulars</div>
|
|
|
+<body style="" rlt="1" inmaintabuse="true">
|
|
|
+
|
|
|
<div class="content">
|
|
|
- <p >
|
|
|
- <img src="https://test.dvema.com/web/images/timg.jpg" class="content_img">
|
|
|
- <br />
|
|
|
- Successful payment
|
|
|
- </p>
|
|
|
+ <p>
|
|
|
+ <img src="https://test.dvema.com/web/images/success.png" class="content_img">
|
|
|
+ <br>
|
|
|
+ 支付成功
|
|
|
+ </p>
|
|
|
</div>
|
|
|
<center class="bottom">
|
|
|
- <div class="bottom_div" onclick="payOKButton()">
|
|
|
- Finish
|
|
|
- </div>
|
|
|
+ <div class="bottom_div" onclick="payOKButton()">
|
|
|
+ 完成
|
|
|
+ </div>
|
|
|
</center>
|
|
|
- <script> // 点击付款成功按钮
|
|
|
+ <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>
|
|
|
-</body>
|
|
|
-</html>
|
|
|
+ </script>
|
|
|
+
|
|
|
+
|
|
|
+ <div id="qds" style="display:none;"></div></body></html>
|
|
|
'''
|
|
|
return response
|
|
|
|
|
@@ -911,6 +916,50 @@ class CloudStorageView(View):
|
|
|
red_url = "{SERVER_DOMAIN}cloudstorage/payOK".format(SERVER_DOMAIN=SERVER_DOMAIN)
|
|
|
return HttpResponseRedirect(red_url)
|
|
|
|
|
|
+
|
|
|
+ def do_pay_by_wechat_callback(self, request_dict, response):
|
|
|
+ result_code = request_dict.get('result_code', None)
|
|
|
+ if result_code == 'SUCCESS':
|
|
|
+ response = HttpResponse()
|
|
|
+ check_sign = WechatPayObject.get_notifypay(request_dict)
|
|
|
+ if not check_sign:
|
|
|
+ return HttpResponse(WechatPayObject.xml_to_dict({'return_code':'FAIL', 'return_msg':'签名失败'}))
|
|
|
+ orderID = request_dict.get('out_trade_no',None)
|
|
|
+ order_qs = Order_Model.objects.filter(orderID=orderID)
|
|
|
+ nowTime = int(time.time())
|
|
|
+ order_list = order_qs.values("UID", "channel", "commodity_code")
|
|
|
+ UID = order_list[0]['UID']
|
|
|
+ channel = order_list[0]['channel']
|
|
|
+ commodity_code = order_list[0]['commodity_code']
|
|
|
+ smqs = Store_Meal.objects.filter(commodity_code=commodity_code). \
|
|
|
+ values("day", "bucket_id", "bucket__storeDay")
|
|
|
+ bucketId = smqs[0]['bucket_id']
|
|
|
+ if not smqs.exists():
|
|
|
+ return HttpResponse(WechatPayObject.xml_to_dict({'return_code':'FAIL', 'return_msg':'套餐不存在'}))
|
|
|
+ addTime = int(smqs[0]["day"]) * 24 * 3600
|
|
|
+ # ##
|
|
|
+ ubqs = UID_Bucket.objects.filter(uid=UID, channel=channel, endTime__gte=nowTime). \
|
|
|
+ values("bucket__storeDay", "bucket__region", "endTime")
|
|
|
+ if ubqs.exists():
|
|
|
+ ubqs_count = ubqs.count()
|
|
|
+ print(ubqs_count)
|
|
|
+ ubq = ubqs[ubqs_count - 1]
|
|
|
+ print(ubq)
|
|
|
+ new_starTime = ubq['endTime'] + 1
|
|
|
+ ub_cqs = UID_Bucket.objects.create \
|
|
|
+ (uid=UID, channel=channel, bucket_id=bucketId,
|
|
|
+ endTime=new_starTime + addTime)
|
|
|
+ uid_bucket_id = ub_cqs.id
|
|
|
+ else:
|
|
|
+ ub_cqs = UID_Bucket.objects.create \
|
|
|
+ (uid=UID, channel=channel, bucket_id=bucketId, endTime=nowTime + addTime)
|
|
|
+ uid_bucket_id = ub_cqs.id
|
|
|
+ order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
|
|
|
+
|
|
|
+ return HttpResponse(WechatPayObject.xml_to_dict({'return_code':'SUCCESS', 'return_msg':'OK'}))
|
|
|
+
|
|
|
+ return HttpResponse(WechatPayObject.xml_to_dict({'return_code':'FAIL', 'return_msg':'参数格式校验错误'}))
|
|
|
+
|
|
|
def do_create_pay_order(self, request_dict, userID, response):
|
|
|
uid = request_dict.get('uid', None)
|
|
|
channel = request_dict.get('channel', None)
|
|
@@ -940,7 +989,7 @@ class CloudStorageView(View):
|
|
|
# new_starTime = ubq['endTime'] + 1
|
|
|
nowTime = int(time.time())
|
|
|
orderID = CommonService.createOrderID()
|
|
|
- if pay_type == 0:
|
|
|
+ if pay_type == 1:
|
|
|
call_sub_url = "{SERVER_DOMAIN}cloudstorage/dopaypalcallback?orderID={orderID}". \
|
|
|
format(SERVER_DOMAIN=SERVER_DOMAIN, orderID=orderID)
|
|
|
# call_sub_url = "http://192.168.136.40:8077/cloudstorage/payExecute?orderID={orderID}".format(
|
|
@@ -973,7 +1022,7 @@ class CloudStorageView(View):
|
|
|
commodity_code=commodity_code, commodity_type=commodity_type,rank_id=rank)
|
|
|
return response.json(0, {"redirectUrl": approval_url, "orderID": orderID})
|
|
|
return response.json(10, 'generate_order_false')
|
|
|
- elif pay_type == 1:
|
|
|
+ elif pay_type == 2:
|
|
|
try:
|
|
|
aliPayObj = AliPayObject()
|
|
|
alipay = aliPayObj.conf()
|
|
@@ -1007,27 +1056,26 @@ class CloudStorageView(View):
|
|
|
else:
|
|
|
return response.json(10, '生成订单错误.')
|
|
|
|
|
|
- elif pay_type == 2:
|
|
|
- # 调用统一支付接口
|
|
|
- # 订单id
|
|
|
- # 描述信息
|
|
|
- body = 'zosi云存支付'
|
|
|
- # 价格
|
|
|
- total_fee = '50'
|
|
|
- # 调用微信支付API的机器IP
|
|
|
+ elif pay_type == 3:
|
|
|
# spbill_create_ip = '127.0.0.1'
|
|
|
spbill_create_ip = '120.237.157.184'
|
|
|
pay = WechatPayObject()
|
|
|
- notify_url="{SERVER_DOMAIN_SSL}cloudstorage/dowxcallback".format(
|
|
|
+ notify_url="{SERVER_DOMAIN_SSL}cloudstorage/dowechatnotify".format(
|
|
|
SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
|
|
|
# 获取参数
|
|
|
- parameter_dict = pay.get_parameter(orderID, body, total_fee, spbill_create_ip, notify_url)
|
|
|
+ parameter_dict = pay.get_parameter(orderID, content, price, spbill_create_ip, notify_url)
|
|
|
print('parameter_dict', parameter_dict)
|
|
|
# parameter_dict 参数中获取MWEB_URL 调转页面在路径后面添加redirect_url
|
|
|
# 统一调用接口
|
|
|
response = pay.re_finall()
|
|
|
- print(response)
|
|
|
+ if not response:
|
|
|
+ return response.json(10, '生成订单错误.')
|
|
|
# 回调函数
|
|
|
+ Order_Model.objects.create(orderID=orderID, UID=uid, channel=channel, userID_id=userID,
|
|
|
+ desc=content, payType=pay_type, payTime=nowTime,
|
|
|
+ price=price, currency=currency, addTime=nowTime, updTime=nowTime,
|
|
|
+ endTime=(nowTime + int(day) * 3600 * 24), pay_url=notify_url,
|
|
|
+ commodity_code=commodity_code, commodity_type=commodity_type,rank_id=rank)
|
|
|
return JsonResponse(status=200, data={'result_code': 0, 'reason': 'success',
|
|
|
'result': response,
|
|
|
'orderId': orderID,
|