@@ -24,3 +24,24 @@ def exec_send_jsapi_hb(user, elog, amount): |
||
24 | 24 |
redpack_type=RedpackSendLogInfo.WX_REDPACK, |
25 | 25 |
redpack_amount=amount, |
26 | 26 |
) |
27 |
+ |
|
28 |
+ |
|
29 |
+def exec_clerk_send_jsapi_hb(user, elog, amount): |
|
30 |
+ send_jsapi_hb(user.brand_id, user.openid, amount, transfer=False) |
|
31 |
+ |
|
32 |
+ elog.has_clerk_send_redpack = True |
|
33 |
+ elog.clerk_redpack_send_amount = amount |
|
34 |
+ elog.user_id = user.user_id |
|
35 |
+ elog.nickname = user.nickname |
|
36 |
+ elog.save() |
|
37 |
+ |
|
38 |
+ RedpackSendLogInfo.objects.create( |
|
39 |
+ brand_id=user.brand_id, |
|
40 |
+ user_id=user.user_id, |
|
41 |
+ nickname=user.nickname, |
|
42 |
+ phone=user.phone, |
|
43 |
+ sn=elog.sn, |
|
44 |
+ redpack_type=RedpackSendLogInfo.WX_REDPACK, |
|
45 |
+ redpack_amount=amount, |
|
46 |
+ is_clerk_redpack=True, |
|
47 |
+ ) |
@@ -6,7 +6,7 @@ from django.db import transaction |
||
6 | 6 |
from django_six import CompatibilityBaseCommand, close_old_connections |
7 | 7 |
|
8 | 8 |
from account.models import UserInfo |
9 |
-from api.hb_views import exec_send_jsapi_hb |
|
9 |
+from api.hb_views import exec_clerk_send_jsapi_hb, exec_send_jsapi_hb |
|
10 | 10 |
from logs.models import MchInfoEncryptLogInfo |
11 | 11 |
from utils.redis.connect import r |
12 | 12 |
from utils.redis.rkeys import REDPACK_WAITING_SEND_LIST |
@@ -25,6 +25,7 @@ class Command(CompatibilityBaseCommand): |
||
25 | 25 |
# 'sn': 'sn', |
26 | 26 |
# 'user_id': 'user_id', |
27 | 27 |
# 'amount': amount, |
28 |
+ # 'is_clerk': 1, |
|
28 | 29 |
# }) |
29 | 30 |
k, v = r.blpopjson(REDPACK_WAITING_SEND_LIST, 60) |
30 | 31 |
if not v: |
@@ -51,6 +52,9 @@ class Command(CompatibilityBaseCommand): |
||
51 | 52 |
r.rpushjson(REDPACK_WAITING_SEND_LIST, v) |
52 | 53 |
continue |
53 | 54 |
|
54 |
- exec_send_jsapi_hb(user, elog, v.get('amount', 100)) |
|
55 |
+ if v.get('user_id', '') == 1: |
|
56 |
+ exec_clerk_send_jsapi_hb(user, elog, v.get('amount', 100)) |
|
57 |
+ else: |
|
58 |
+ exec_send_jsapi_hb(user, elog, v.get('amount', 100)) |
|
55 | 59 |
|
56 | 60 |
close_old_connections() |
@@ -7,9 +7,9 @@ from logs.models import MchInfoDecryptLogInfo, MchInfoEncryptLogInfo, MchLogInfo |
||
7 | 7 |
|
8 | 8 |
|
9 | 9 |
class MchInfoEncryptLogInfoAdmin(Readonly2ModelAdmin, admin.ModelAdmin): |
10 |
- list_display = ('plaintext', 'alg', 'ciphertext', 'brand_pk', 'model_pk', 'distributor_pk', 'sn', 'operator_id', 'is_send_redpack', 'redpack_amount', 'redpack_max_amount', 'has_send_redpack', 'redpack_send_amount', 'user_id', 'nickname', 'status', 'created_at', 'updated_at') |
|
11 |
- list_filter = ('alg', 'brand_pk', 'model_pk', 'distributor_pk', 'operator_id', 'is_send_redpack', 'has_send_redpack', 'status') |
|
12 |
- readonly_fields_exclude = ('is_send_redpack', 'redpack_amount', 'redpack_max_amount') |
|
10 |
+ list_display = ('plaintext', 'alg', 'ciphertext', 'brand_pk', 'model_pk', 'distributor_pk', 'sn', 'operator_id', 'is_send_redpack', 'redpack_amount', 'redpack_max_amount', 'has_send_redpack', 'redpack_send_amount', 'is_clerk_send_redpack', 'clerk_redpack_amount', 'clerk_redpack_max_amount', 'has_clerk_send_redpack', 'clerk_redpack_send_amount', 'user_id', 'nickname', 'status', 'created_at', 'updated_at') |
|
11 |
+ list_filter = ('alg', 'brand_pk', 'model_pk', 'distributor_pk', 'operator_id', 'is_send_redpack', 'has_send_redpack', 'is_clerk_send_redpack', 'has_clerk_send_redpack', 'status') |
|
12 |
+ readonly_fields_exclude = ('is_send_redpack', 'redpack_amount', 'redpack_max_amount', 'is_clerk_send_redpack', 'clerk_redpack_amount', 'clerk_redpack_max_amount') |
|
13 | 13 |
|
14 | 14 |
|
15 | 15 |
class MchInfoDecryptLogInfoAdmin(ReadOnlyModelAdmin, admin.ModelAdmin): |
@@ -24,7 +24,8 @@ class MchLogInfoAdmin(ReadOnlyModelAdmin, admin.ModelAdmin): |
||
24 | 24 |
|
25 | 25 |
|
26 | 26 |
class RedpackSendLogInfoAdmin(ReadOnlyModelAdmin, admin.ModelAdmin): |
27 |
- list_display = ('brand_id', 'user_id', 'nickname', 'phone', 'sn', 'redpack_type', 'redpack_amount', 'status', 'created_at', 'updated_at') |
|
27 |
+ list_display = ('brand_id', 'user_id', 'nickname', 'phone', 'sn', 'redpack_type', 'redpack_amount', 'is_clerk_redpack', 'status', 'created_at', 'updated_at') |
|
28 |
+ list_filter = ('redpack_type', 'is_clerk_redpack', 'status') |
|
28 | 29 |
|
29 | 30 |
|
30 | 31 |
admin.site.register(MchInfoDecryptLogInfo, MchInfoDecryptLogInfoAdmin) |
@@ -0,0 +1,45 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+# Generated by Django 1.11.22 on 2019-08-16 10:15 |
|
3 |
+from __future__ import unicode_literals |
|
4 |
+ |
|
5 |
+from django.db import migrations, models |
|
6 |
+ |
|
7 |
+ |
|
8 |
+class Migration(migrations.Migration): |
|
9 |
+ |
|
10 |
+ dependencies = [ |
|
11 |
+ ('logs', '0008_auto_20190813_1708'), |
|
12 |
+ ] |
|
13 |
+ |
|
14 |
+ operations = [ |
|
15 |
+ migrations.AddField( |
|
16 |
+ model_name='mchinfoencryptloginfo', |
|
17 |
+ name='clerk_redpack_amount', |
|
18 |
+ field=models.IntegerField(default=0, help_text='\u9500\u552e\u5458\u7ea2\u5305\u56fa\u5b9a\u91d1\u989d\uff0c\u5355\u4f4d\uff1a\u5206', verbose_name='clerk_redpack_amount'), |
|
19 |
+ ), |
|
20 |
+ migrations.AddField( |
|
21 |
+ model_name='mchinfoencryptloginfo', |
|
22 |
+ name='clerk_redpack_max_amount', |
|
23 |
+ field=models.IntegerField(default=0, help_text='\u9500\u552e\u5458\u7ea2\u5305\u91d1\u989d\u8303\u56f4\uff0c\u5355\u4f4d\uff1a\u5206\uff09', verbose_name='clerk_redpack_max_amount'), |
|
24 |
+ ), |
|
25 |
+ migrations.AddField( |
|
26 |
+ model_name='mchinfoencryptloginfo', |
|
27 |
+ name='clerk_redpack_send_amount', |
|
28 |
+ field=models.IntegerField(default=0, help_text='\u9500\u552e\u5458\u7ea2\u5305\u53d1\u653e\u91d1\u989d\uff0c\u5355\u4f4d\uff1a\u5206\uff09', verbose_name='clerk_redpack_send_amount'), |
|
29 |
+ ), |
|
30 |
+ migrations.AddField( |
|
31 |
+ model_name='mchinfoencryptloginfo', |
|
32 |
+ name='has_clerk_send_redpack', |
|
33 |
+ field=models.BooleanField(db_index=True, default=False, help_text='\u9500\u552e\u5458\u662f\u5426\u5df2\u53d1\u653e\u7ea2\u5305', verbose_name='has_clerk_send_redpack'), |
|
34 |
+ ), |
|
35 |
+ migrations.AddField( |
|
36 |
+ model_name='mchinfoencryptloginfo', |
|
37 |
+ name='is_clerk_send_redpack', |
|
38 |
+ field=models.BooleanField(db_index=True, default=False, help_text='\u9500\u552e\u5458\u662f\u5426\u53d1\u653e\u7ea2\u5305', verbose_name='is_clerk_send_redpack'), |
|
39 |
+ ), |
|
40 |
+ migrations.AddField( |
|
41 |
+ model_name='redpacksendloginfo', |
|
42 |
+ name='is_clerk_redpack', |
|
43 |
+ field=models.BooleanField(db_index=True, default=False, help_text='\u662f\u5426\u4e3a\u9500\u552e\u5458\u7ea2\u5305', verbose_name='is_clerk_redpack'), |
|
44 |
+ ), |
|
45 |
+ ] |
@@ -25,6 +25,13 @@ class MchInfoEncryptLogInfo(BaseModelMixin): |
||
25 | 25 |
redpack_max_amount = models.IntegerField(_(u'redpack_max_amount'), default=0, help_text=u'红包金额范围,单位:分)') |
26 | 26 |
has_send_redpack = models.BooleanField(_(u'has_send_redpack'), default=False, help_text=u'是否已发放红包', db_index=True) |
27 | 27 |
redpack_send_amount = models.IntegerField(_(u'redpack_send_amount'), default=0, help_text=u'红包发放金额,单位:分)') |
28 |
+ |
|
29 |
+ is_clerk_send_redpack = models.BooleanField(_(u'is_clerk_send_redpack'), default=False, help_text=u'销售员是否发放红包', db_index=True) |
|
30 |
+ clerk_redpack_amount = models.IntegerField(_(u'clerk_redpack_amount'), default=0, help_text=u'销售员红包固定金额,单位:分') |
|
31 |
+ clerk_redpack_max_amount = models.IntegerField(_(u'clerk_redpack_max_amount'), default=0, help_text=u'销售员红包金额范围,单位:分)') |
|
32 |
+ has_clerk_send_redpack = models.BooleanField(_(u'has_clerk_send_redpack'), default=False, help_text=u'销售员是否已发放红包', db_index=True) |
|
33 |
+ clerk_redpack_send_amount = models.IntegerField(_(u'clerk_redpack_send_amount'), default=0, help_text=u'销售员红包发放金额,单位:分)') |
|
34 |
+ |
|
28 | 35 |
user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识(红包)', db_index=True) |
29 | 36 |
nickname = models.CharField(_(u'nickname'), max_length=255, blank=True, null=True, help_text=u'用户昵称') |
30 | 37 |
|
@@ -99,6 +106,8 @@ class RedpackSendLogInfo(BaseModelMixin): |
||
99 | 106 |
redpack_type = models.IntegerField(_(u'redpack_type'), default=WX_REDPACK, choices=REDPACK_TYPE_TUPLE, help_text=u'红包发放方式', db_index=True) |
100 | 107 |
redpack_amount = models.IntegerField(_(u'redpack_amount'), default=0, help_text=u'红包发放金额') |
101 | 108 |
|
109 |
+ is_clerk_redpack = models.BooleanField(_(u'is_clerk_redpack'), default=False, help_text=u'是否为销售员红包', db_index=True) |
|
110 |
+ |
|
102 | 111 |
class Meta: |
103 | 112 |
verbose_name = _(u'红包发放记录') |
104 | 113 |
verbose_name_plural = _(u'红包发放记录') |
@@ -65,7 +65,7 @@ class BrandInfoAdmin(admin.ModelAdmin): |
||
65 | 65 |
|
66 | 66 |
|
67 | 67 |
class ModelInfoAdmin(admin.ModelAdmin): |
68 |
- list_display = ('brand_id', 'brand_name', 'jancode', 'model_id', 'model_name', 'model_uni_name', 'model_full_name', 'model_descr', 'category', 'warehouse', 'image', 'url', 'image2', 'factory_yuan', 'integral', 'is_send_redpack', 'redpack_amount', 'redpack_max_amount', 'position', 'display', 'status', 'created_at', 'updated_at') |
|
68 |
+ list_display = ('brand_id', 'brand_name', 'jancode', 'model_id', 'model_name', 'model_uni_name', 'model_full_name', 'model_descr', 'category', 'warehouse', 'image', 'url', 'image2', 'factory_yuan', 'integral', 'is_send_redpack', 'redpack_amount', 'redpack_max_amount', 'is_clerk_send_redpack', 'clerk_redpack_amount', 'clerk_redpack_max_amount', 'position', 'display', 'status', 'created_at', 'updated_at') |
|
69 | 69 |
list_filter = ('brand_name', 'category', 'warehouse', 'display', 'status') |
70 | 70 |
readonly_fields = ('brand_name', 'factory_fee') |
71 | 71 |
search_fields = ('brand_id', 'brand_name', 'jancode', 'model_id', 'model_name', 'model_uni_name', 'model_full_name', 'model_descr', 'category', 'warehouse') |
@@ -83,6 +83,7 @@ class ModelInfoAdmin(admin.ModelAdmin): |
||
83 | 83 |
obj.save() |
84 | 84 |
|
85 | 85 |
MchInfoEncryptLogInfo.objects.filter(has_send_redpack=False).update(is_send_redpack=obj.is_send_redpack, redpack_amount=obj.redpack_amount, redpack_max_amount=obj.redpack_max_amount) |
86 |
+ MchInfoEncryptLogInfo.objects.filter(has_clerk_send_redpack=False).update(is_clerk_send_redpack=obj.is_clerk_send_redpack, clerk_redpack_amount=obj.clerk_redpack_amount, clerk_redpack_max_amount=obj.clerk_redpack_max_amount) |
|
86 | 87 |
|
87 | 88 |
|
88 | 89 |
class ModelImageInfoAdmin(admin.ModelAdmin): |
@@ -0,0 +1,30 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+# Generated by Django 1.11.22 on 2019-08-16 10:15 |
|
3 |
+from __future__ import unicode_literals |
|
4 |
+ |
|
5 |
+from django.db import migrations, models |
|
6 |
+ |
|
7 |
+ |
|
8 |
+class Migration(migrations.Migration): |
|
9 |
+ |
|
10 |
+ dependencies = [ |
|
11 |
+ ('mch', '0044_auto_20190816_1459'), |
|
12 |
+ ] |
|
13 |
+ |
|
14 |
+ operations = [ |
|
15 |
+ migrations.AddField( |
|
16 |
+ model_name='modelinfo', |
|
17 |
+ name='clerk_redpack_amount', |
|
18 |
+ field=models.IntegerField(default=0, help_text='\u9500\u552e\u5458\u7ea2\u5305\u56fa\u5b9a\u91d1\u989d\uff0c\u5355\u4f4d\uff1a\u5206', verbose_name='clerk_redpack_amount'), |
|
19 |
+ ), |
|
20 |
+ migrations.AddField( |
|
21 |
+ model_name='modelinfo', |
|
22 |
+ name='clerk_redpack_max_amount', |
|
23 |
+ field=models.IntegerField(default=0, help_text='\u9500\u552e\u5458\u7ea2\u5305\u91d1\u989d\u8303\u56f4\uff0c\u5355\u4f4d\uff1a\u5206\uff09', verbose_name='clerk_redpack_max_amount'), |
|
24 |
+ ), |
|
25 |
+ migrations.AddField( |
|
26 |
+ model_name='modelinfo', |
|
27 |
+ name='is_clerk_send_redpack', |
|
28 |
+ field=models.BooleanField(db_index=True, default=False, help_text='\u9500\u552e\u5458\u662f\u5426\u53d1\u653e\u7ea2\u5305', verbose_name='is_clerk_send_redpack'), |
|
29 |
+ ), |
|
30 |
+ ] |
@@ -165,6 +165,10 @@ class ModelInfo(BaseModelMixin): |
||
165 | 165 |
redpack_amount = models.IntegerField(_(u'redpack_amount'), default=0, help_text=u'红包固定金额,单位:分') |
166 | 166 |
redpack_max_amount = models.IntegerField(_(u'redpack_max_amount'), default=0, help_text=u'红包金额范围,单位:分)') |
167 | 167 |
|
168 |
+ is_clerk_send_redpack = models.BooleanField(_(u'is_clerk_send_redpack'), default=False, help_text=u'销售员是否发放红包', db_index=True) |
|
169 |
+ clerk_redpack_amount = models.IntegerField(_(u'clerk_redpack_amount'), default=0, help_text=u'销售员红包固定金额,单位:分') |
|
170 |
+ clerk_redpack_max_amount = models.IntegerField(_(u'clerk_redpack_max_amount'), default=0, help_text=u'销售员红包金额范围,单位:分)') |
|
171 |
+ |
|
168 | 172 |
position = models.IntegerField(_(u'position'), default=1, help_text=u'排序') |
169 | 173 |
|
170 | 174 |
display = models.BooleanField(_(u'display'), default=True, help_text=_(u'Display'), db_index=True) |
@@ -2,6 +2,8 @@ |
||
2 | 2 |
|
3 | 3 |
from __future__ import division |
4 | 4 |
|
5 |
+import random |
|
6 |
+ |
|
5 | 7 |
from django.conf import settings |
6 | 8 |
from django.db import transaction |
7 | 9 |
from django_logit import logit |
@@ -10,6 +12,7 @@ from paginator import pagination |
||
10 | 12 |
from TimeConvert import TimeConvert as tc |
11 | 13 |
|
12 | 14 |
from api.encrypt_views import decrypt |
15 |
+from api.hb_views import exec_clerk_send_jsapi_hb |
|
13 | 16 |
from account.models import UserInfo |
14 | 17 |
from logs.models import MchInfoDecryptLogInfo, MchInfoEncryptLogInfo |
15 | 18 |
from integral.models import SaleclerkIntegralIncomeExpensesInfo, SaleclerkSubmitLogInfo |
@@ -21,6 +24,8 @@ from utils.algorithm.caesar import caesar_decrypt |
||
21 | 24 |
from utils.algorithm.rsalg import rsa_decrypt |
22 | 25 |
from utils.error.errno_utils import (ProductBrandStatusCode, ProductDistributorStatusCode, ProductModelStatusCode, |
23 | 26 |
SaleclerkStatusCode) |
27 |
+from utils.redis.connect import r |
|
28 |
+from utils.redis.rkeys import REDPACK_WAITING_SEND_LIST |
|
24 | 29 |
|
25 | 30 |
|
26 | 31 |
# CIPHER_ALGORITHM = ('CAESAR', 'B64', 'RSA') |
@@ -681,6 +686,30 @@ def clerk_sale_submit_api(request): |
||
681 | 686 |
sssi.num += 1 |
682 | 687 |
sssi.save() |
683 | 688 |
|
689 |
+ # 重复上传执行不到此处,为了下面的统一,这里直接赋值 |
|
690 |
+ dupload = False |
|
691 |
+ |
|
692 |
+ try: |
|
693 |
+ elog = MchInfoEncryptLogInfo.objects.select_for_update().get(sn=serialNo) |
|
694 |
+ except MchInfoEncryptLogInfo.DoesNotExist: |
|
695 |
+ elog = None |
|
696 |
+ except MchInfoEncryptLogInfo.MultipleObjectsReturned: |
|
697 |
+ elog = None |
|
698 |
+ |
|
699 |
+ if elog and (not dupload) and elog.is_clerk_send_redpack and (not elog.has_clerk_send_redpack) and (elog.clerk_redpack_amount or elog.clerk_redpack_max_amount): |
|
700 |
+ amount = elog.clerk_redpack_amount |
|
701 |
+ if elog.clerk_redpack_max_amount: |
|
702 |
+ amount = random.randint(100, elog.clerk_redpack_max_amount) |
|
703 |
+ if user.openid: |
|
704 |
+ exec_clerk_send_jsapi_hb(user, elog, amount) |
|
705 |
+ else: |
|
706 |
+ r.rpushjson(REDPACK_WAITING_SEND_LIST, { |
|
707 |
+ 'sn': serialNo, |
|
708 |
+ 'user_id': user.user_id, |
|
709 |
+ 'amount': amount, |
|
710 |
+ 'is_clerk': 1, |
|
711 |
+ }) |
|
712 |
+ |
|
684 | 713 |
return response(200, data={ |
685 | 714 |
'integral': integral, |
686 | 715 |
'total_integral': clerk.integral, |