|
@@ -44,6 +44,7 @@ from Service.CommonService import CommonService
|
|
|
from Service.PayService import PaymentService
|
|
|
from Service.VodHlsService import SplitVodHlsObject
|
|
|
from Object.ApplePayObject import ApplePayObject
|
|
|
+from Object.UnionPayObject import UnionPayObject
|
|
|
|
|
|
ssl._create_default_https_context = ssl._create_unverified_context
|
|
|
LOGGER = logging.getLogger('info')
|
|
@@ -1372,7 +1373,7 @@ class CloudStorageView(View):
|
|
|
@return: response
|
|
|
"""
|
|
|
logger = logging.getLogger('info')
|
|
|
- logger.info('---------进入apple异步回调')
|
|
|
+ logger.info('---------进入apple异步回调,参数:{}'.format(request_dict))
|
|
|
receipt_data = request_dict.get('receipt_data', None)
|
|
|
order_id = request_dict.get('order_id', None)
|
|
|
lang = request_dict.get('lang', 'en')
|
|
@@ -1391,8 +1392,7 @@ class CloudStorageView(View):
|
|
|
return response.json(173)
|
|
|
promotion_rule_id = ''
|
|
|
try:
|
|
|
- apple_obj = ApplePayObject()
|
|
|
- verify_result = apple_obj.verify(receipt_data)
|
|
|
+ verify_result = ApplePayObject().verify(receipt_data)
|
|
|
logger.info("verify_result:{}".format(verify_result))
|
|
|
|
|
|
if not verify_result:
|
|
@@ -1402,7 +1402,6 @@ class CloudStorageView(View):
|
|
|
redis_obj.del_data(key=order_id + 'do_notify')
|
|
|
return response.json(0, {'url': red_url})
|
|
|
|
|
|
- trade_no = verify_result['transactionId']
|
|
|
order_list = order_qs.values("UID", "channel", "commodity_code", "rank", "isSelectDiscounts",
|
|
|
"userID__userID", "userID__username", "coupon_id")
|
|
|
userid = order_list[0]['userID__userID']
|
|
@@ -1471,7 +1470,7 @@ class CloudStorageView(View):
|
|
|
logger.info(
|
|
|
'uid:{},uid_bucket_id:{},update_status:{},order_id:{}'.format(uid, uid_bucket_id, update_status,
|
|
|
order_id))
|
|
|
- order_qs.update(status=1, updTime=now_time, uid_bucket_id=uid_bucket_id, trade_no=trade_no,
|
|
|
+ order_qs.update(status=1, updTime=now_time, uid_bucket_id=uid_bucket_id,
|
|
|
promotion_rule_id=promotion_rule_id)
|
|
|
date_time = time.strftime("%Y-%m-%d", time.localtime())
|
|
|
# 开通AI服务
|
|
@@ -1570,7 +1569,7 @@ class CloudStorageView(View):
|
|
|
now_time = int(time.time())
|
|
|
store_qs = Store_Meal.objects.filter(id=rank, pay_type=pay_type, lang__lang=lang, is_show=0). \
|
|
|
values('currency', 'price', 'lang__content', 'day', 'commodity_type', 'lang__title', 'expire',
|
|
|
- 'commodity_code', 'discount_price', 'bucket__mold', 'cycle_config_id')
|
|
|
+ 'commodity_code', 'discount_price', 'bucket__mold', 'cycle_config_id', 'is_ai')
|
|
|
if not store_qs.exists():
|
|
|
return response.json(173)
|
|
|
store_meal_qs = Store_Meal.objects.filter(id=rank, lang__lang='cn', is_show=0).values('lang__title',
|
|
@@ -1581,6 +1580,8 @@ class CloudStorageView(View):
|
|
|
store_meal_name = '未知套餐'
|
|
|
currency = store_qs[0]['currency']
|
|
|
price = store_qs[0]['price']
|
|
|
+ is_ai = store_qs[0]['is_ai']
|
|
|
+ order_type = 1 if is_ai else 0
|
|
|
if is_select_discount == '1':
|
|
|
price = float(store_qs[0]['price']) + float(store_qs[0]['discount_price'])
|
|
|
content = store_qs[0]['lang__content']
|
|
@@ -1626,7 +1627,7 @@ class CloudStorageView(View):
|
|
|
Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
|
desc=content, payType=pay_type, payTime=now_time,
|
|
|
price=price, currency=currency, addTime=now_time,
|
|
|
- updTime=now_time,
|
|
|
+ updTime=now_time, order_type=order_type,
|
|
|
pay_url=sub_info['url'], isSelectDiscounts=is_select_discount,
|
|
|
commodity_code=commodity_code, commodity_type=commodity_type,
|
|
|
rank_id=rank, plan_id=sub_info['plan_id'], coupon_id=coupon_id,
|
|
@@ -1661,7 +1662,7 @@ class CloudStorageView(View):
|
|
|
Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
|
desc=content, payType=pay_type, payTime=now_time,
|
|
|
price=price, currency=currency, addTime=now_time,
|
|
|
- updTime=now_time,
|
|
|
+ updTime=now_time, order_type=order_type,
|
|
|
pay_url=approval_url, isSelectDiscounts=is_select_discount,
|
|
|
commodity_code=commodity_code, commodity_type=commodity_type,
|
|
|
rank_id=rank, paymentID=payment_id, coupon_id=coupon_id,
|
|
@@ -1731,9 +1732,12 @@ class CloudStorageView(View):
|
|
|
'orderId': order_id,
|
|
|
'error_code': 0})
|
|
|
elif pay_type == 4:
|
|
|
- notify_url = "{}cloudstorage/doapplenotify".format(SERVER_DOMAIN_SSL)
|
|
|
content = CommonService.Package_Type(0, content) # 云存套餐
|
|
|
-
|
|
|
+ union_pay_obj = UnionPayObject()
|
|
|
+ pay_result = union_pay_obj.pay(order_id, int(price * 100))
|
|
|
+ if not pay_result:
|
|
|
+ return response.json(10, '生成订单错误.')
|
|
|
+ tn = pay_result['tn']
|
|
|
# 回调函数
|
|
|
Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
|
desc=content, payType=pay_type, payTime=now_time,
|
|
@@ -1742,8 +1746,7 @@ class CloudStorageView(View):
|
|
|
commodity_code=commodity_code, commodity_type=commodity_type,
|
|
|
rank_id=rank,
|
|
|
ai_rank_id=1, store_meal_name=store_meal_name)
|
|
|
- return JsonResponse(status=200, data={'result_code': 0, 'reason': 'success',
|
|
|
- 'result': {"redirectUrl": notify_url, "orderID": order_id},
|
|
|
+ return JsonResponse(status=200, data={'result_code': 0, 'reason': 'success', 'result': {"orderID": tn},
|
|
|
'error_code': 0})
|
|
|
|
|
|
def do_experience_order(self, request_dict, user_id, response): # 生成体验订单
|
|
@@ -1828,6 +1831,7 @@ class CloudStorageView(View):
|
|
|
if not uid_set_qs.exists():
|
|
|
return response.json(173)
|
|
|
is_ai = 1 if uid_set_qs[0]['is_ai'] != 2 else 0
|
|
|
+ order_type = 1 if is_ai and CONFIG_INFO != CONFIG_CN else 0
|
|
|
use_flag = True
|
|
|
end_time = CommonService.calcMonthLater(expire)
|
|
|
# icloud_store_meal_id = store_qs[0]['icloud_store_meal_id']
|
|
@@ -1879,7 +1883,7 @@ class CloudStorageView(View):
|
|
|
Order_Model.objects.create(orderID=order_id, UID=uid, channel=channel, userID_id=user_id,
|
|
|
desc=store_qs[0]['lang__content'], payType=pay_type, payTime=now_time,
|
|
|
price=store_qs[0]['price'], currency=store_qs[0]['currency'],
|
|
|
- addTime=now_time,
|
|
|
+ addTime=now_time, order_type=order_type,
|
|
|
updTime=now_time,
|
|
|
pay_url="体验版", store_meal_name=store_meal_name,
|
|
|
commodity_code=commodity_code, commodity_type=store_qs[0]['commodity_type'],
|