Browse Source

苹果内购, 服务器通知退款, 退款表状态修改

linhaohong 9 months ago
parent
commit
462a0c3702
1 changed files with 8 additions and 0 deletions
  1. 8 0
      Controller/InAppPurchaseController.py

+ 8 - 0
Controller/InAppPurchaseController.py

@@ -631,6 +631,10 @@ 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)
+                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,
@@ -692,6 +696,8 @@ class InAppPurchaseView(View):
                     topic_name = 'ansjer/generic/{}'.format(thing_name)
                     req_success = CommonService.req_publish_mqtt_msg(thing_name, topic_name, msg)
                     logger.info(f'App Store服务器通知用户退款, 关闭AI:{req_success}')
+                InAppRefund.objects.filter(transaction_id=transaction_id).update(updated_time=int(time.time()),
+                                                                                 refund_progress=2)
                 return HttpResponse(status=200)
 
             elif str(decoded_payload.rawNotificationType) == "REFUND_DECLINED":
@@ -867,4 +873,6 @@ class InAppPurchaseView(View):
                 refundPreference=refundPreference,
             )
             client.send_consumption_data(transaction_id, consumption_request)
+            in_app_refund.refund_progress = 1
+            in_app_refund.save()
         return response.json(0)