diff --git a/fir_ser/api/utils/pay/ali.py b/fir_ser/api/utils/pay/ali.py index 5ed7d68..d1fe961 100644 --- a/fir_ser/api/utils/pay/ali.py +++ b/fir_ser/api/utils/pay/ali.py @@ -13,7 +13,7 @@ from api.utils.storage.caches import update_order_info, update_order_status import json import logging -logger = logging.getLogger(__name__) +logger = logging.getLogger('pay') class Alipay(object): @@ -47,9 +47,10 @@ class Alipay(object): return_url=self.ali_config.get("RETURN_URL"), passback_params=json.dumps(passback_params) ) - - return {'type': self.p_type, 'url': "https://openapi.alipay.com/gateway.do?%s" % order_string, - 'out_trade_no': out_trade_no} + result = {'type': self.p_type, 'url': "https://openapi.alipay.com/gateway.do?%s" % order_string, + 'out_trade_no': out_trade_no} + logger.info(f"支付宝支付连接生成成功 {result}") + return result def valid_order(self, request): data = request.data.copy().dict() diff --git a/fir_ser/api/utils/pay/wx.py b/fir_ser/api/utils/pay/wx.py index 03fadd7..414606b 100644 --- a/fir_ser/api/utils/pay/wx.py +++ b/fir_ser/api/utils/pay/wx.py @@ -10,7 +10,7 @@ from api.utils.storage.caches import update_order_info, update_order_status import json import logging -logger = logging.getLogger(__name__) +logger = logging.getLogger('pay') class Weixinpay(object): @@ -43,7 +43,9 @@ class Weixinpay(object): time_expire=time_expire, attach=json.dumps(passback_params), ) - return {'type': self.p_type, 'url': json.loads(data).get('code_url', ''), 'out_trade_no': out_trade_no} + result = {'type': self.p_type, 'url': json.loads(data).get('code_url', ''), 'out_trade_no': out_trade_no} + logger.info(f"微信支付连接生成成功 {result}") + return result def valid_order(self, request): headers = { diff --git a/fir_ser/api/utils/serializer.py b/fir_ser/api/utils/serializer.py index 01cfa3c..cb61586 100644 --- a/fir_ser/api/utils/serializer.py +++ b/fir_ser/api/utils/serializer.py @@ -143,7 +143,7 @@ class AppsSerializer(serializers.ModelSerializer): def get_has_combo(self, obj): if obj.has_combo: obj.has_combo.has_combo = None - return AppsSerializer(obj.has_combo, context=self.context).data + return AppsListSerializer(obj.has_combo, context=self.context).data preview_url = serializers.SerializerMethodField() @@ -206,6 +206,35 @@ class AppsSerializer(serializers.ModelSerializer): return {} +class AppsListSerializer(AppsSerializer): + class Meta: + model = models.Apps + fields = ["app_id", "bundle_id", "issupersign", "name", "preview_url", "short", "type", "master_release", + "has_combo"] + + def get_master_release(self, obj): + master_release_obj = get_app_master_obj_from_context(self, obj) + if master_release_obj: + key = '' + icon_url = get_download_url_from_context(self, obj, key, master_release_obj.icon_url) + datainfo = { + "app_version": master_release_obj.app_version, + "icon_url": icon_url, + "build_version": master_release_obj.build_version, + "binary_size": bytes2human(master_release_obj.binary_size), + "binary_url": master_release_obj.binary_url, + "release_type": master_release_obj.release_type, + } + return datainfo + else: + return {} + + def get_has_combo(self, obj): + if obj.has_combo: + obj.has_combo.has_combo = None + return AppsListSerializer(obj.has_combo, context=self.context).data + + class AdminAppsSerializer(AppsSerializer): class Meta: model = models.Apps diff --git a/fir_ser/api/utils/storage/caches.py b/fir_ser/api/utils/storage/caches.py index 8037526..a118427 100644 --- a/fir_ser/api/utils/storage/caches.py +++ b/fir_ser/api/utils/storage/caches.py @@ -443,7 +443,7 @@ def update_order_info(user_id, out_trade_no, payment_number, payment_type): order_obj.description = "充值成功,充值下载次数 %s ,现共可用次数 %s" % ( download_times, user_obj.download_times + download_times) order_obj.save( - update_fields=["status", "payment_type", "order_type", "payment_number", "pay_time", + update_fields=["status", "payment_type", "payment_number", "pay_time", "description"]) add_user_download_times(user_id, download_times) logger.info(f"{user_obj} 订单 {out_trade_no} msg:{order_obj.description}") diff --git a/fir_ser/api/views/apps.py b/fir_ser/api/views/apps.py index c701dd5..bac9225 100644 --- a/fir_ser/api/views/apps.py +++ b/fir_ser/api/views/apps.py @@ -15,7 +15,7 @@ from api.utils.app.supersignutils import IosUtils from api.utils.storage.storage import Storage from api.utils.storage.caches import del_cache_response_by_short, get_app_today_download_times, del_cache_by_delete_app from api.models import Apps, AppReleaseInfo, APPToDeveloper, AppIOSDeveloperInfo, UserInfo, AppScreenShot -from api.utils.serializer import AppsSerializer, AppReleaseSerializer +from api.utils.serializer import AppsSerializer, AppReleaseSerializer, AppsListSerializer from rest_framework.pagination import PageNumberPagination import logging from api.utils.utils import delete_local_files, delete_app_screenshots_files @@ -94,7 +94,7 @@ class AppsView(APIView): app_page_serializer = page_obj.paginate_queryset(queryset=apps_obj.order_by("-updated_time"), request=request, view=self) - app_serializer = AppsSerializer(app_page_serializer, many=True, context={"storage": Storage(request.user)}) + app_serializer = AppsListSerializer(app_page_serializer, many=True, context={"storage": Storage(request.user)}) res.userinfo = {} res.has_next = {} diff --git a/fir_ser/api/views/login.py b/fir_ser/api/views/login.py index f502920..3642465 100644 --- a/fir_ser/api/views/login.py +++ b/fir_ser/api/views/login.py @@ -425,6 +425,7 @@ class UserInfoView(APIView): res = BaseResponse() serializer = UserInfoSerializer(request.user) res.data = serializer.data + del res.data['username'] res.data['login_type'] = get_login_type() return Response(res.dict) diff --git a/fir_ser/fir_ser/settings.py b/fir_ser/fir_ser/settings.py index 80d89e4..488ed47 100644 --- a/fir_ser/fir_ser/settings.py +++ b/fir_ser/fir_ser/settings.py @@ -299,10 +299,33 @@ LOGGING = { 'formatter': 'standard', 'encoding': 'utf-8', }, + 'warning': { + 'level': 'WARNING', + 'class': 'logging.handlers.RotatingFileHandler', # 保存到文件,自动切 + 'filename': os.path.join(BASE_LOG_DIR, "flyapp_warning.log"), # 日志文件 + 'maxBytes': 1024 * 1024 * 5, # 日志大小 50M + 'backupCount': 10, + 'formatter': 'standard', + 'encoding': 'utf-8', + }, + 'pay': { + 'level': 'DEBUG', + 'class': 'logging.handlers.RotatingFileHandler', # 保存到文件,自动切 + 'filename': os.path.join(BASE_LOG_DIR, "flyapp_pay.log"), # 日志文件 + 'maxBytes': 1024 * 1024 * 5, # 日志大小 50M + 'backupCount': 10, + 'formatter': 'standard', + 'encoding': 'utf-8', + }, }, 'loggers': { '': { # 默认的logger应用如下配置 - 'handlers': ['TF', 'console', 'error'], # 上线之后可以把'console'移除 + 'handlers': ['TF', 'console', 'error', 'warning'], # 上线之后可以把'console'移除 + 'level': 'DEBUG', + 'propagate': True, + }, + 'pay': { # 默认的logger应用如下配置 + 'handlers': ['pay'], # 上线之后可以把'console'移除 'level': 'DEBUG', 'propagate': True, },