|
@@ -32,12 +32,13 @@ from Model.models import Device_Info, Order_Model, Store_Meal, VodHlsModel, UID_
|
|
|
ExperienceContextModel, Pay_Type, CDKcontextModel, Device_User, SysMsgModel, Unused_Uid_Meal, PromotionRuleModel, \
|
|
|
VideoPlaybackTimeModel, CouponModel, VodBucketModel, VodHlsSummary, AiService, UidSetModel, UidPushModel, \
|
|
|
VodHlsTagType, ICloudStoreMeal, IcloudUseDetails, IcloudService, StsFrequency, DeviceApplePackage, \
|
|
|
- InAppPurchasePackage
|
|
|
+ InAppPurchasePackage, CouponCombo, CouponConfigModel
|
|
|
from Object.AWS.AmazonS3Util import AmazonS3Util
|
|
|
from Object.AWS.S3Email import S3Email
|
|
|
from Object.AliPayObject import AliPayObject
|
|
|
from Object.AliSmsObject import AliSmsObject
|
|
|
from Object.ETkObject import ETkObject
|
|
|
+from Object.Enums.RedisKeyConstant import RedisKeyConstant
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
@@ -240,12 +241,14 @@ class CloudStorageView(View):
|
|
|
if CONFIG_INFO != CONFIG_CN: # 国内生产环境不筛选像素 加载所有上架套餐
|
|
|
store_qs = store_qs.filter(Q(pixel_level=pixel_level))
|
|
|
|
|
|
+ # 判断是否支持内购周期付款
|
|
|
if is_ios and version.parse(ios_version) >= version.parse("15.0"):
|
|
|
store_qs = store_qs.filter(pay_type=5, app_type=app_type)
|
|
|
elif is_ios and version.parse(ios_version) < version.parse("15.0"):
|
|
|
store_qs = store_qs.filter(pay_type=5, commodity_type=0, app_type=app_type)
|
|
|
else:
|
|
|
store_qs = store_qs.exclude(pay_type=5)
|
|
|
+
|
|
|
if uid not in ["VXJ267WU5NZ1S89H111A", "18SM4J9DYWB2AEG1111A",
|
|
|
"517J385BNUGP3CPP111A"] and CONFIG_INFO == CONFIG_TEST:
|
|
|
store_qs = store_qs.exclude(id=88)
|
|
@@ -261,8 +264,7 @@ class CloudStorageView(View):
|
|
|
store_qs = store_qs.filter(pay_type='10') # 体验套餐不区分像素等级
|
|
|
|
|
|
store_qs = store_qs.annotate(title=F('lang__title'), content=F('lang__content'),
|
|
|
- new_title=F('lang__new_title'),
|
|
|
- discount_content=F('lang__discount_content'))
|
|
|
+ new_title=F('lang__new_title'), discount_content=F('lang__discount_content'))
|
|
|
store_qs = store_qs.order_by('sort').values("id", "title", "content", "price", "day", "currency",
|
|
|
"bucket__storeDay", "new_title",
|
|
|
"bucket__bucket", "bucket__area", "commodity_code",
|
|
@@ -291,6 +293,17 @@ class CloudStorageView(View):
|
|
|
item['content'] = item['new_title'].get('1', '')
|
|
|
elif is_ai == 1:
|
|
|
item['content'] = item['new_title'].get('2', '')
|
|
|
+ if is_ios:
|
|
|
+ if item['isCoupon']:
|
|
|
+ item['isCoupon'] = False
|
|
|
+ else:
|
|
|
+ # 在列表删除这个套餐
|
|
|
+ coupon_combo_ids = CouponCombo.objects.filter(combo_id=item['id']).values_list("coupon_id",
|
|
|
+ flat=True)
|
|
|
+ coupon_config_qs = CouponConfigModel.objects.filter(id__in=coupon_combo_ids)
|
|
|
+ if coupon_config_qs.exists():
|
|
|
+ items_list.remove(item)
|
|
|
+
|
|
|
res_c = {'area': area, 'items': items_list}
|
|
|
res.append(res_c)
|
|
|
# 是否促销
|
|
@@ -1513,7 +1526,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',
|
|
|
+ values('id', 'currency', 'price', 'lang__content', 'day', 'commodity_type', 'lang__title', 'expire',
|
|
|
'commodity_code', 'discount_price', 'bucket__mold', 'cycle_config_id', 'is_ai')
|
|
|
if not store_qs.exists():
|
|
|
return response.json(173)
|
|
@@ -1745,14 +1758,32 @@ class CloudStorageView(View):
|
|
|
product_id = InAppPurchasePackage.objects.filter(id=package_id).values("product_id")[0][
|
|
|
"product_id"]
|
|
|
else:
|
|
|
- product_id = InAppPurchasePackage.objects.filter(rank_id=rank).values("product_id")[0]["product_id"]
|
|
|
+ in_app_purchase_qs = InAppPurchasePackage.objects.filter(rank_id=rank).values("product_id", "is_coupon")
|
|
|
+ product_id = in_app_purchase_qs[0]["product_id"]
|
|
|
+ is_coupon = in_app_purchase_qs[0]["is_coupon"]
|
|
|
+ # 判断是否为优惠订单锁优惠券
|
|
|
+ if is_coupon:
|
|
|
+ coupon_combo_qs = CouponCombo.objects.filter(combo_id=store_qs[0]['id']).values("coupon_id")
|
|
|
+ coupon_ids = CouponModel.objects.filter(userID=user_id, use_status=0,
|
|
|
+ coupon_config__id=coupon_combo_qs[0]["coupon_id"],
|
|
|
+ valid_time__gte=now_time).values_list("id", flat=True)
|
|
|
+ redis_obj = RedisObject()
|
|
|
+ for c_id in coupon_ids:
|
|
|
+ key_coupon = f"{RedisKeyConstant.COUPON_ID_LOCK.value}{c_id}"
|
|
|
+ coupon_lock = redis_obj.get_data(key_coupon)
|
|
|
+ if not coupon_lock:
|
|
|
+ redis_obj.set_data(key_coupon, 1, 600)
|
|
|
+ coupon_id = c_id
|
|
|
+ break
|
|
|
+ else:
|
|
|
+ return response.json(5)
|
|
|
|
|
|
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,
|
|
|
isSelectDiscounts=is_select_discount, order_type=order_type, commodity_code=commodity_code,
|
|
|
commodity_type=commodity_type, rank_id=rank, ai_rank_id=1, store_meal_name=store_meal_name,
|
|
|
- app_type=app_type,
|
|
|
+ app_type=app_type, coupon_id=coupon_id
|
|
|
)
|
|
|
return JsonResponse(status=200, data={'result_code': 0, 'reason': 'success',
|
|
|
'result': {"orderID": order_id, "productId": product_id},
|