|
@@ -823,7 +823,7 @@ class serveManagement(View):
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|
|
def getCouponList(request_dict, response):
|
|
def getCouponList(request_dict, response):
|
|
- combo_id = request_dict.get('comboID', None)
|
|
|
|
|
|
+ combo_ids = request_dict.get('comboID', None)
|
|
pageNo = request_dict.get('pageNo', None)
|
|
pageNo = request_dict.get('pageNo', None)
|
|
pageSize = request_dict.get('pageSize', None)
|
|
pageSize = request_dict.get('pageSize', None)
|
|
|
|
|
|
@@ -834,8 +834,9 @@ class serveManagement(View):
|
|
line = int(pageSize)
|
|
line = int(pageSize)
|
|
|
|
|
|
try:
|
|
try:
|
|
- if combo_id: # 根据套餐id查询
|
|
|
|
- coupon_id_list = CouponCombo.objects.filter(combo_id=combo_id).values_list('coupon_id', flat=True)
|
|
|
|
|
|
+ if combo_ids: # 根据套餐id查询
|
|
|
|
+ combo_id_list = combo_ids.split(",")
|
|
|
|
+ coupon_id_list = CouponCombo.objects.filter(combo_id=combo_id_list).values_list('coupon_id', flat=True)
|
|
coupon_qs = CouponConfigModel.objects.filter(id__in=coupon_id_list).values(
|
|
coupon_qs = CouponConfigModel.objects.filter(id__in=coupon_id_list).values(
|
|
'id', 'type', 'use_range', 'coupon_discount')
|
|
'id', 'type', 'use_range', 'coupon_discount')
|
|
else:
|
|
else:
|
|
@@ -845,9 +846,9 @@ class serveManagement(View):
|
|
coupon_list = list(coupon_qs[(page - 1) * line:page * line])
|
|
coupon_list = list(coupon_qs[(page - 1) * line:page * line])
|
|
for coupon in coupon_list:
|
|
for coupon in coupon_list:
|
|
coupon['combo_id'] = 'NA'
|
|
coupon['combo_id'] = 'NA'
|
|
- coupon_combo_qs = CouponCombo.objects.filter(coupon_id=coupon['id']).values('combo_id')
|
|
|
|
|
|
+ coupon_combo_qs = CouponCombo.objects.filter(coupon_id=coupon['id']).values_list('combo_id', flat=True)
|
|
if coupon_combo_qs.exists():
|
|
if coupon_combo_qs.exists():
|
|
- coupon['combo_id'] = coupon_combo_qs[0]['combo_id']
|
|
|
|
|
|
+ coupon['combo_id'] = list(set(list(coupon_combo_qs)))
|
|
return response.json(0, {'list': coupon_list, 'total': count})
|
|
return response.json(0, {'list': coupon_list, 'total': count})
|
|
except Exception as e:
|
|
except Exception as e:
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
@@ -860,13 +861,13 @@ class serveManagement(View):
|
|
@staticmethod
|
|
@staticmethod
|
|
def addOrEditCoupon(request_dict, response):
|
|
def addOrEditCoupon(request_dict, response):
|
|
coupon_id = request_dict.get('couponID', None)
|
|
coupon_id = request_dict.get('couponID', None)
|
|
- combo_id = request_dict.get('comboID', None)
|
|
|
|
|
|
+ combo_ids = request_dict.get('comboID', None)
|
|
coupon_type = int(request_dict.get('type', 0))
|
|
coupon_type = int(request_dict.get('type', 0))
|
|
- use_range = request_dict.get('useRange', '')
|
|
|
|
|
|
+ use_range = request_dict.get('useRange', 0)
|
|
coupon_discount = request_dict.get('couponDiscount', '')
|
|
coupon_discount = request_dict.get('couponDiscount', '')
|
|
is_edit = request_dict.get('isEdit', None)
|
|
is_edit = request_dict.get('isEdit', None)
|
|
|
|
|
|
- if not all([coupon_type, use_range, coupon_discount]):
|
|
|
|
|
|
+ if not all([coupon_type, coupon_discount]):
|
|
return response.json(444)
|
|
return response.json(444)
|
|
|
|
|
|
try:
|
|
try:
|
|
@@ -876,17 +877,22 @@ class serveManagement(View):
|
|
'use_range': use_range,
|
|
'use_range': use_range,
|
|
'coupon_discount': coupon_discount
|
|
'coupon_discount': coupon_discount
|
|
}
|
|
}
|
|
|
|
+ combo_id_list = combo_ids.split(",")
|
|
if is_edit:
|
|
if is_edit:
|
|
if not coupon_id:
|
|
if not coupon_id:
|
|
return response.json(444)
|
|
return response.json(444)
|
|
CouponConfigModel.objects.filter(id=coupon_id).update(**coupon_data)
|
|
CouponConfigModel.objects.filter(id=coupon_id).update(**coupon_data)
|
|
- CouponCombo.objects.filter(coupon_id=coupon_id).update(combo_id=combo_id, update_time=now_time)
|
|
|
|
|
|
+ CouponCombo.objects.filter(coupon_id=coupon_id).delete()
|
|
|
|
+ for combo_id in combo_id_list:
|
|
|
|
+ CouponCombo.objects.create(coupon_id=coupon_id, combo_id=combo_id,
|
|
|
|
+ create_time=now_time, update_time=now_time)
|
|
else:
|
|
else:
|
|
coupon = CouponConfigModel.objects.create(**coupon_data)
|
|
coupon = CouponConfigModel.objects.create(**coupon_data)
|
|
coupon_id = coupon.id
|
|
coupon_id = coupon.id
|
|
# 关联套餐
|
|
# 关联套餐
|
|
- CouponCombo.objects.create(coupon_id=coupon_id, combo_id=combo_id,
|
|
|
|
- create_time=now_time, update_time=now_time)
|
|
|
|
|
|
+ for combo_id in combo_id_list:
|
|
|
|
+ CouponCombo.objects.create(coupon_id=coupon_id, combo_id=combo_id,
|
|
|
|
+ create_time=now_time, update_time=now_time)
|
|
return response.json(0)
|
|
return response.json(0)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
@@ -2834,7 +2840,7 @@ class serveManagement(View):
|
|
uid = request_dict.get("uid", None)
|
|
uid = request_dict.get("uid", None)
|
|
apple_order = request_dict.get("appleOrder", None)
|
|
apple_order = request_dict.get("appleOrder", None)
|
|
app_type = request_dict.get("appType", None)
|
|
app_type = request_dict.get("appType", None)
|
|
- page = int(request_dict.get('page', 0)) # 默认值设为 0
|
|
|
|
|
|
+ page = int(request_dict.get('page', 1)) # 默认值设为 1
|
|
page_size = int(request_dict.get('pageSize', 10)) # 默认值设为 10
|
|
page_size = int(request_dict.get('pageSize', 10)) # 默认值设为 10
|
|
|
|
|
|
in_app_refund_qs = InAppRefund.objects.all()
|
|
in_app_refund_qs = InAppRefund.objects.all()
|
|
@@ -2927,30 +2933,32 @@ class serveManagement(View):
|
|
order_lookup_response = client.look_up_order_id(apple_order)
|
|
order_lookup_response = client.look_up_order_id(apple_order)
|
|
signed_transactions = order_lookup_response.signedTransactions
|
|
signed_transactions = order_lookup_response.signedTransactions
|
|
if signed_transactions:
|
|
if signed_transactions:
|
|
- transaction_payload = signed_data_verifier.verify_and_decode_signed_transaction(signed_transactions[0])
|
|
|
|
- transaction_id = transaction_payload.transactionId
|
|
|
|
- orders_qs = orders_qs.filter(transaction_id=transaction_id)
|
|
|
|
- if InAppRefund.objects.filter(orderID=order_id).exists():
|
|
|
|
- return response.json(174)
|
|
|
|
|
|
+ transaction_ids = []
|
|
|
|
+ for signed_transaction in signed_transactions:
|
|
|
|
+ transaction_payload = signed_data_verifier.verify_and_decode_signed_transaction(signed_transaction)
|
|
|
|
+ transaction_id = transaction_payload.transactionId
|
|
|
|
+ transaction_ids.append(transaction_id)
|
|
|
|
+ orders_qs = orders_qs.filter(transaction_id__in=transaction_ids)
|
|
else:
|
|
else:
|
|
return response.json(800)
|
|
return response.json(800)
|
|
if not orders_qs.exists():
|
|
if not orders_qs.exists():
|
|
return response.json(173, "订单不存在")
|
|
return response.json(173, "订单不存在")
|
|
-
|
|
|
|
- uid = orders_qs[0].UID
|
|
|
|
- order_id = orders_qs[0].orderID
|
|
|
|
- transaction_id = orders_qs[0].transaction_id
|
|
|
|
- now_time = int(time.time())
|
|
|
|
- if app_type:
|
|
|
|
- InAppRefund.objects.create(
|
|
|
|
- uid=uid, transaction_id=transaction_id,
|
|
|
|
- orderID=order_id, refund_progress=4, app_type=app_type,
|
|
|
|
- created_time=now_time, updated_time=now_time)
|
|
|
|
- else:
|
|
|
|
- InAppRefund.objects.create(
|
|
|
|
- uid=uid, transaction_id=transaction_id,
|
|
|
|
- orderID=order_id, refund_progress=4,
|
|
|
|
- created_time=now_time, updated_time=now_time)
|
|
|
|
|
|
+ for order in orders_qs:
|
|
|
|
+ uid = order.UID
|
|
|
|
+ order_id = order.orderID
|
|
|
|
+ transaction_id = order.transaction_id
|
|
|
|
+ now_time = int(time.time())
|
|
|
|
+ if not InAppRefund.objects.filter(transaction_id=transaction_id).exists():
|
|
|
|
+ if app_type:
|
|
|
|
+ InAppRefund.objects.create(
|
|
|
|
+ uid=uid, transaction_id=transaction_id,
|
|
|
|
+ orderID=order_id, refund_progress=4, app_type=app_type,
|
|
|
|
+ created_time=now_time, updated_time=now_time)
|
|
|
|
+ else:
|
|
|
|
+ InAppRefund.objects.create(
|
|
|
|
+ uid=uid, transaction_id=transaction_id,
|
|
|
|
+ orderID=order_id, refund_progress=4,
|
|
|
|
+ created_time=now_time, updated_time=now_time)
|
|
return response.json(0)
|
|
return response.json(0)
|
|
|
|
|
|
|
|
|