:bug: Fix Bug: send coupon error

huangqimin001 4 年之前
父节点
当前提交
370e41dab2
共有 2 个文件被更改,包括 8 次插入2 次删除
  1. 5 2
      api/mch_views.py
  2. 3 0
      commands/management/commands/cpon.py

+ 5 - 2
api/mch_views.py

@@ -445,8 +445,13 @@ def consumer_info_api(request):
445 445
         user.shots_num += 1
446 446
         user.integral += model.shot_member_integral
447 447
         # 配件不增加会员等级,只发放积分。
448
+        to_send_coupon = False
448 449
         if user.level < UserInfo.MEMBER_BLACK_GOLD and model.shot_type_id != 'V6PkivthL4sdADp4GNpQ4C':
449 450
             user.level += 1
451
+            to_send_coupon = True
452
+        user.save()
453
+
454
+        if to_send_coupon:
450 455
             # 发放会员权益
451 456
             r.rpushjson(MEMBER_SEND_COUPON_LIST, {
452 457
                 'brand_id': brand.brand_id,
@@ -455,8 +460,6 @@ def consumer_info_api(request):
455 460
             # 会员升级提示
456 461
             r.set(MEMBER_UPGRADE_INFO % (brand.brand_id, user_id), 1)
457 462
 
458
-        user.save()
459
-
460 463
     return response(200, 'Submit Consumer Info Success', u'提交消费者信息成功')
461 464
 
462 465
 

+ 3 - 0
commands/management/commands/cpon.py

@@ -37,6 +37,9 @@ class Command(CompatibilityBaseCommand):
37 37
                 user_id = v.get('user_id', '')
38 38
                 coupon_id = v.get('coupon_id', '')
39 39
 
40
+                # TODO: Opt by delay execute
41
+                time.sleep(5)
42
+
40 43
                 try:
41 44
                     user = UserInfo.objects.get(user_id=user_id)
42 45
                 except UserInfo.DoesNotExist: