wushaodong 4 år sedan
förälder
incheckning
ca6ad541c8
3 ändrade filer med 29 tillägg och 27 borttagningar
  1. 14 13
      apps/tenant/models.py
  2. 1 1
      uis/tenant/company/index.html
  3. 14 13
      uis/tenant/company/pay_order.html

+ 14 - 13
apps/tenant/models.py

@@ -9,6 +9,7 @@ from django.utils import timezone
 from apps.base import Formater
 from apps.WeChatResponse import WeChatResponse
 from apps.Alipay import Alipay
+from apps.tenant.config.models import Config
 
 class Tenant(models.Model):
 
@@ -84,19 +85,6 @@ class Tenant(models.Model):
             raise CustomError(u'未找到相应的企业信息!')
         return tenant
 
-
-class RenewLog(models.Model):
-
-    tenant = models.ForeignKey(Tenant, verbose_name=u"企业", on_delete=models.PROTECT, editable=False, )
-    amount = models.FloatField(verbose_name='金额')
-    create_time = models.DateTimeField(verbose_name=u'续费时间', auto_now_add=True, editable=False)
-    end_date = models.DateField(verbose_name=u'到期时间', editable=False, blank=True, null=True)
-
-    class Meta:
-        db_table = 'tenant_renew_log'
-        ordering = ['-id']
-        verbose_name = '企业续费记录'
-
 class Pay(models.Model):
     WAIT = 0
     PAY = 1
@@ -145,6 +133,19 @@ class Pay(models.Model):
         self.amount = Formater.formatAmount(pay_amount)
         self.save()
 
+        year = Config.objects.filter(property=Config.KEY_RENEW_YEAR_1).first()
+        today = datetime.datetime.now().strftime('%Y-%m-%d')
+        today_stamp = time.mktime(time.strptime(today, "%Y-%m-%d"))
+
+        end_date = time.mktime(time.strptime(self.tenant.end_date.strftime('%Y-%m-%d'), '%Y-%m-%d'))
+        diff = int(end_date) - int(today_stamp)
+        if diff >= 0:
+            renew_date = (self.tenant.end_date + datetime.timedelta(days=365 * int(year))).strftime('%Y-%m-%d')
+        else:
+            renew_date = (datetime.datetime.now() + datetime.timedelta(days=365 * int(year))).strftime('%Y-%m-%d')
+        self.tenant.end_date = renew_date
+        self.tenant.save()
+
     # 支付宝回调,付款
     def payConfirm(self, no):
         if self.status != Pay.PAY:

+ 1 - 1
uis/tenant/company/index.html

@@ -199,7 +199,7 @@
                 title: '在线续费',
                 shadeClose: false,
                 area: ['60%', '70%'],
-                btn: ['验证支付', '取消'],
+                btn: ['支付已完成', '取消'],
                 yes: function (index, dom) {
                     layui.onSubmitChild = function (data) {
                         layer.msg('支付验证通过!')

+ 14 - 13
uis/tenant/company/pay_order.html

@@ -46,7 +46,7 @@
         base: '../../../layuiadmin/' //静态资源所在路径
     }).extend({
         index: 'lib/index',
-    }).use(['index', 'form',  'table', 'utils'], function () {
+    }).use(['index', 'form', 'table', 'utils'], function () {
         var $ = layui.$
             , admin = layui.admin
             , form = layui.form
@@ -56,7 +56,7 @@
         var pay_channel = layui.view.getParameterByName('pay_channel');
         var pay_id = ''
         admin.req({
-            url: '/tenant/company/'+company_id+'/get_code/',
+            url: '/tenant/company/' + company_id + '/get_code/',
             data: {company_id: company_id, pay_channel: pay_channel},
             done: function (res) {
                 if (pay_channel == 1) {
@@ -64,7 +64,7 @@
                 } else {
                     $('#id_pay_channel').html('支付宝')
                 }
-                $('#id_year').html(res.data.year+'年')
+                $('#id_year').html(res.data.year + '年')
                 $('#id_renew_date').html(res.data.renew_date)
                 $('#id_amount').html(res.data.amount)
                 pay_id = res.data.id
@@ -91,16 +91,17 @@
 
         form.on('submit(component-form-element)', function (data) {
             //layer.msg(JSON.stringify(data.field));
-            admin.req({
-                url: '/tenant/company/'+company_id+'/confirm_pay/'
-                , data: {pay_id:pay_id}
-                , type: 'get'
-                , done: function (res) {
-                    if(res.code == 0){
-                        parent.layui.onSubmitChild();
-                    }
-                }
-            });
+            // admin.req({
+            //l   url: '/tenant/company/'+company_id+'/confirm_pay/'
+            //l  , data: {pay_id:pay_id}
+            //l  , type: 'get'
+            //l  , done: function (res) {
+            //l     if(res.code == 0){
+            //l         parent.layui.onSubmitChild();
+            //l     }
+            //l   }
+            //l });
+            parent.layui.onSubmitChild();
 
             return false;
         });