|
@@ -3,6 +3,7 @@ import traceback
|
|
|
import datetime
|
|
|
import time
|
|
|
from django.db import transaction
|
|
|
+from django.conf import settings
|
|
|
from rest_framework.decorators import action
|
|
|
from rest_framework_jwt.views import ObtainJSONWebToken,VerifyJSONWebToken,RefreshJSONWebToken
|
|
|
from rest_framework.serializers import ValidationError
|
|
@@ -17,6 +18,7 @@ from apps.log.models import BizLog
|
|
|
from apps.tenant.config.models import Config
|
|
|
from utils.exceptions import CustomError
|
|
|
from apps.base import Formater
|
|
|
+from apps.WechatApplet.models import WechatApplet
|
|
|
|
|
|
class TenantLoginView(ObtainJSONWebToken):
|
|
|
serializer_class = TenantJWTSerializer
|
|
@@ -116,6 +118,27 @@ class CompanyViewSet(CustomModelViewSet):
|
|
|
traceback.print_exc()
|
|
|
return response_error(u'支付失败', request)
|
|
|
|
|
|
+ @action(methods=['get'], detail=True)
|
|
|
+ def get_wxapp_code(self, request, pk):
|
|
|
+ try:
|
|
|
+ tenant = Tenant.objects.filter(id=pk).first()
|
|
|
+ if tenant:
|
|
|
+ company_no = tenant.company_no
|
|
|
+ else:
|
|
|
+ raise CustomError('获取企业信息失败,请刷新重试!')
|
|
|
+ if not tenant.wxapp_img:
|
|
|
+ applet = WechatApplet.objects.filter(authorizer_appid=settings.WEAPP['appid']).first()
|
|
|
+ filename = applet.getWXAppCode(company_no)
|
|
|
+ tenant.wxapp_img = "{0}{1}".format(settings.MEDIA_URL,filename)
|
|
|
+ tenant.save()
|
|
|
+
|
|
|
+ return response_ok(tenant.wxapp_img)
|
|
|
+ except CustomError as e:
|
|
|
+ return response_error(str(e))
|
|
|
+ except Exception as e:
|
|
|
+ traceback.print_exc()
|
|
|
+ return response_error(u'支付失败', request)
|
|
|
+
|
|
|
@action(methods=['get'], detail=True)
|
|
|
def confirm_pay(self, request, pk):
|
|
|
pay_id = request.GET.get('pay_id')
|