Browse Source

内购退款问题修复

linhaohong 8 tháng trước cách đây
mục cha
commit
3c96acb0a6
1 tập tin đã thay đổi với 12 bổ sung8 xóa
  1. 12 8
      Controller/InAppPurchaseController.py

+ 12 - 8
Controller/InAppPurchaseController.py

@@ -679,14 +679,18 @@ class InAppPurchaseView(View):
                 uid = orders_qs[0].UID
                 now_time = int(time.time())
                 put_time = now_time + 11.5 * 60 * 60
-                in_app_refund_qs = InAppRefund.objects.filter(transaction_id=transaction_id)
+                in_app_refund_qs = InAppRefund.objects.filter(transaction_id=transaction_id).values("refund_progress")
                 if in_app_refund_qs.exists():
-                    in_app_refund_qs.update(refund_progress=0, updated_time=now_time,
-                                            put_time=put_time, app_account_token=app_account_token)
-                InAppRefund.objects.create(transaction_id=transaction_id, orderID=orderID,
-                                           uid=uid, app_type=app_type, created_time=now_time,
-                                           updated_time=now_time, put_time=put_time,
-                                           app_account_token=app_account_token)
+                    if in_app_refund_qs[0]["refund_progress"] == 4:
+                        in_app_refund_qs.update(refund_progress=0, updated_time=now_time,
+                                                put_time=put_time, app_account_token=app_account_token)
+                    else:
+                        in_app_refund_qs.update(updated_time=now_time, app_account_token=app_account_token)
+                else:
+                    InAppRefund.objects.create(transaction_id=transaction_id, orderID=orderID,
+                                               uid=uid, app_type=app_type, created_time=now_time,
+                                               updated_time=now_time, put_time=put_time,
+                                               app_account_token=app_account_token)
                 return HttpResponse(status=200)
 
             elif str(decoded_payload.rawNotificationType) == "DID_CHANGE_RENEWAL_STATUS":
@@ -764,7 +768,7 @@ class InAppPurchaseView(View):
                 orders_qs = Order_Model.objects.filter(transaction_id=transaction_id)
                 if not orders_qs.exists():
                     return HttpResponse(status=400)
-                InAppRefund.objects.filter(transaction_id=transaction_id).update(refund_progress=3)
+                InAppRefund.objects.filter(transaction_id=transaction_id).update(refund_progress=3, updated_time=int(time.time()))
 
             else:
                 logger.info(f"App Store服务器通知decoded_payload.rawNotificationType 未处理")