|
@@ -375,47 +375,47 @@ class AiView(View):
|
|
redisObj.CONN.expire(redis_key, 60)
|
|
redisObj.CONN.expire(redis_key, 60)
|
|
if not isLock:
|
|
if not isLock:
|
|
return response.json(5)
|
|
return response.json(5)
|
|
|
|
+ try:
|
|
|
|
+ if pay_type == 10: # 判断是否已体验过套餐
|
|
|
|
+ exc_ai_qs = ExperienceAiModel.objects.filter(uid=uid, experience_type=0)
|
|
|
|
+ if exc_ai_qs.exists():
|
|
|
|
+ return response.json(5)
|
|
|
|
+
|
|
|
|
+ if cdk is not None and pay_type == 11:
|
|
|
|
+ cdk_qs = CDKcontextModel.objects.filter(cdk=cdk).values('is_activate', 'rank__id', 'rank__commodity_code')
|
|
|
|
+ if not cdk_qs.exists():
|
|
|
|
+ return response.json(10040)
|
|
|
|
+ if cdk_qs[0]['is_activate'] == 1:
|
|
|
|
+ return response.json(10039)
|
|
|
|
+ rank = cdk_qs[0]['rank__id']
|
|
|
|
+
|
|
|
|
+ if uid is None or channel is None or pay_type is None or rank is None:
|
|
|
|
+ redisObj.del_data(key=redis_key)
|
|
|
|
+ return response.json(444)
|
|
|
|
|
|
- if pay_type == 10: # 判断是否已体验过套餐
|
|
|
|
- exc_ai_qs = ExperienceAiModel.objects.filter(uid=uid, experience_type=0)
|
|
|
|
- if exc_ai_qs.exists():
|
|
|
|
- return response.json(5)
|
|
|
|
-
|
|
|
|
- if cdk is not None and pay_type == 11:
|
|
|
|
- cdk_qs = CDKcontextModel.objects.filter(cdk=cdk).values('is_activate', 'rank__id', 'rank__commodity_code')
|
|
|
|
- if not cdk_qs.exists():
|
|
|
|
- return response.json(10040)
|
|
|
|
- if cdk_qs[0]['is_activate'] == 1:
|
|
|
|
- return response.json(10039)
|
|
|
|
- rank = cdk_qs[0]['rank__id']
|
|
|
|
-
|
|
|
|
- if uid is None or channel is None or pay_type is None or rank is None:
|
|
|
|
- redisObj.del_data(key=redis_key)
|
|
|
|
- return response.json(444)
|
|
|
|
|
|
+ # 判断是否为主用户操作
|
|
|
|
+ device_info_qs = Device_Info.objects.filter(Q(UID=uid) & ~Q(vodPrimaryUserID='')).values('vodPrimaryUserID')
|
|
|
|
+ if device_info_qs.exists():
|
|
|
|
+ if device_info_qs[0]['vodPrimaryUserID'] != userID:
|
|
|
|
+ if pay_type == 10:
|
|
|
|
+ return response.json(10035)
|
|
|
|
+ if pay_type == 11:
|
|
|
|
+ return response.json(10036)
|
|
|
|
|
|
- # 判断是否为主用户操作
|
|
|
|
- device_info_qs = Device_Info.objects.filter(Q(UID=uid) & ~Q(vodPrimaryUserID='')).values('vodPrimaryUserID')
|
|
|
|
- if device_info_qs.exists():
|
|
|
|
- if device_info_qs[0]['vodPrimaryUserID'] != userID:
|
|
|
|
- if pay_type == 10:
|
|
|
|
- return response.json(10035)
|
|
|
|
- if pay_type == 11:
|
|
|
|
- return response.json(10036)
|
|
|
|
|
|
+ dv_qs = Device_Info.objects.filter(userID_id=userID, UID=uid, isShare=False, isExist=1)
|
|
|
|
+ if not dv_qs.exists():
|
|
|
|
+ return response.json(12)
|
|
|
|
|
|
- dv_qs = Device_Info.objects.filter(userID_id=userID, UID=uid, isShare=False, isExist=1)
|
|
|
|
- if not dv_qs.exists():
|
|
|
|
- return response.json(12)
|
|
|
|
|
|
+ orderID = CommonService.createOrderID()
|
|
|
|
+ nowTime = int(time.time())
|
|
|
|
+ ai_store_meal_qs = AiStoreMeal.objects.filter(id=rank, lang__lang=lang, is_show=1). \
|
|
|
|
+ values('lang__content', 'price', 'currency', 'effective_day', 'commodity_type')
|
|
|
|
+ if not ai_store_meal_qs.exists():
|
|
|
|
+ return response.json(173)
|
|
|
|
|
|
- orderID = CommonService.createOrderID()
|
|
|
|
- nowTime = int(time.time())
|
|
|
|
- ai_store_meal_qs = AiStoreMeal.objects.filter(id=rank, lang__lang=lang, is_show=1). \
|
|
|
|
- values('expire', 'lang__content', 'price', 'currency', 'effective_day')
|
|
|
|
- if not ai_store_meal_qs.exists():
|
|
|
|
- return response.json(173)
|
|
|
|
|
|
+ effective_day = ai_store_meal_qs[0]['effective_day']
|
|
|
|
+ endTime = nowTime + effective_day * 24 * 60 * 60 # 套餐结束时间
|
|
|
|
|
|
- effective_day = ai_store_meal_qs[0]['effective_day']
|
|
|
|
- endTime = nowTime + effective_day * 24 * 60 * 60 # 套餐结束时间
|
|
|
|
- try:
|
|
|
|
with transaction.atomic():
|
|
with transaction.atomic():
|
|
# 订单表创建数据
|
|
# 订单表创建数据
|
|
Order_Model.objects.create(orderID=orderID, UID=uid, channel=channel, userID_id=userID,
|
|
Order_Model.objects.create(orderID=orderID, UID=uid, channel=channel, userID_id=userID,
|
|
@@ -441,7 +441,8 @@ class AiView(View):
|
|
redisObj.del_data(key=redis_key)
|
|
redisObj.del_data(key=redis_key)
|
|
pay_ok_url = "{}cloudstorage/payOK?paytype={}&lang={}".format(SERVER_DOMAIN_SSL, pay_type, lang)
|
|
pay_ok_url = "{}cloudstorage/payOK?paytype={}&lang={}".format(SERVER_DOMAIN_SSL, pay_type, lang)
|
|
return response.json(0, pay_ok_url)
|
|
return response.json(0, pay_ok_url)
|
|
- except Exception:
|
|
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print(e)
|
|
redisObj.del_data(key=redis_key)
|
|
redisObj.del_data(key=redis_key)
|
|
return response.json(474)
|
|
return response.json(474)
|
|
|
|
|