> 1
+# -*- coding: utf-8 -*-
2
+
3
+from django.db import models
4
+from django.utils.translation import ugettext_lazy as _
5
+from django_models_ext import BaseModelMixin
6
+
7
+
8
+class MarketCodeInfo(BaseModelMixin):
9
+    isv_application_id = models.CharField(_(u'isv_application_id'), max_length=128, blank=True, null=True, help_text=u'外部单号', db_index=True)
10
+    application_id = models.IntegerField(_(u'application_id'), default=0, help_text=u'申请单号', db_index=True)
11
+
12
+    lattice = models.CharField(_(u'code'), max_length=361, blank=True, null=True, help_text=u'361 字节的 01 点阵,用于支持生成 19 * 19 的微型码,0 为白,1 为黑')
13
+    code = models.CharField(_(u'code'), max_length=16, blank=True, null=True, help_text=u'九位的字符串原始码', db_index=True)
14
+    code_index = models.IntegerField(_(u'code_index'), default=0, help_text=u'该码在批次中的偏移量	')
15
+    code_url = models.CharField(_(u'code_url'), max_length=128, blank=True, null=True, help_text=u'28位普通码字符	', db_index=True)
16
+
17
+    has_used = models.BooleanField(_(u'has_used'), default=False, help_text=_(u'是否已使用'), db_index=True)
18
+
19
+    class Meta:
20
+        verbose_name = _(u'一物一码信息')
21
+        verbose_name_plural = _(u'一物一码信息')
22
+
23
+    def __unicode__(self):
24
+        return unicode(self.pk)

+ 6 - 0
marketcode/tests.py

@@ -0,0 +1,6 @@
1
+# -*- coding: utf-8 -*-
2
+from __future__ import unicode_literals
3
+
4
+from django.test import TestCase
5
+
6
+# Create your tests here.

+ 6 - 0
marketcode/views.py

@@ -0,0 +1,6 @@
1
+# -*- coding: utf-8 -*-
2
+from __future__ import unicode_literals
3
+
4
+from django.shortcuts import render
5
+
6
+# Create your views here.

+ 41 - 0
pre/market_code.py

@@ -0,0 +1,41 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+from django.conf import settings
4
+from pywe_marketcode import applycodedownload
5
+from pywe_storage import RedisStorage
6
+
7
+from marketcode.models import MarketCodeInfo
8
+from utils.redis.connect import r
9
+
10
+
11
+WECHAT = settings.WECHAT
12
+
13
+
14
+def marketcodedownload(application_id, code_start, code_end, isv_application_id=''):
15
+    wxcfg = WECHAT.get('JSAPI', {})
16
+
17
+    appid = wxcfg.get('appID')
18
+    secret = wxcfg.get('appsecret')
19
+
20
+    codes = applycodedownload(application_id=application_id, code_start=code_start, code_end=code_end, appid=appid, secret=secret, token=None, storage=RedisStorage(r))
21
+
22
+    lattice, code, code_index, code_url = ''
23
+    for idx, item in enumerate(codes):
24
+        if idx % 4 == 0:
25
+            lattice = item
26
+        if idx % 4 == 1:
27
+            code = item
28
+        if idx % 4 == 2:
29
+            code_index = item
30
+        if idx % 4 == 3:
31
+            code_url = item
32
+            MarketCodeInfo.objects.create(
33
+                isv_application_id=isv_application_id,
34
+                application_id=application_id,
35
+                lattice=lattice,
36
+                code=code,
37
+                code_index=code_index,
38
+                code_url=code_url
39
+            )
40
+
41
+

+ 1 - 0
requirements_pywe.txt

@@ -2,6 +2,7 @@ pywe-card==1.0.0
2 2
 pywe-component==1.0.1
3 3
 pywe-component-preauthcode==1.0.3
4 4
 pywe-jssdk==1.1.0
5
+pywe-marketcode==1.0.1
5 6
 pywe-membercard==1.0.3
6 7
 pywe-miniapp==1.1.5
7 8
 pywe-oauth==1.0.7

+ 33 - 0
utils/error/errno_utils.py

@@ -59,6 +59,39 @@ class ProductStatusCode(BaseStatusCode):
59 59
     PRODUCT_NOT_USED = StatusCodeField(502012, 'Product Not Used', description=u'产品未使用')
60 60
 
61 61
 
62
+class MemberGoodStatusCode(BaseStatusCode):
63
+    """ 会员商品相关错误码 5035xx """
64
+    GOOD_NOT_FOUND = StatusCodeField(503501, 'Good Not Found', description=u'商品不存在')
65
+
66
+    GOOD_NO_EXCHANGE_PERMISSION = StatusCodeField(503502, 'Good No Exchange Permission', description=u'商品无兑换权限')
67
+    GOOD_INTEGRAL_NOT_ENOUGH = StatusCodeField(503503, 'Good Integral Not Enough', description=u'商品兑换积分不足')
68
+    GOOD_STOCK_NOT_ENOUGH = StatusCodeField(503504, 'Good Integral Not Enough', description=u'商品库存不足')
69
+
70
+
71
+class MemberRightStatusCode(BaseStatusCode):
72
+    """ 会员商品相关错误码 5036xx """
73
+    RIGHT_NOT_FOUND = StatusCodeField(503601, 'Right Not Found', description=u'权益不存在')
74
+
75
+
76
+class MemberActivityStatusCode(BaseStatusCode):
77
+    """ 会员活动相关错误码 5037xx """
78
+    ACTIVITY_NOT_FOUND = StatusCodeField(503701, 'Activity Not Found', description=u'活动不存在')
79
+
80
+
81
+class MemberCouponStatusCode(BaseStatusCode):
82
+    """ 会员优惠券相关错误码 5040xx """
83
+    USER_COUPON_NOT_FOUND = StatusCodeField(504001, 'User Coupon Not Found', description=u'用户优惠券不存在')
84
+
85
+    USER_COUPON_HAS_USED = StatusCodeField(504010, 'User Coupon Has Used', description=u'用户优惠券已使用')
86
+    USER_COUPON_NOT_ACTIVED = StatusCodeField(504011, 'User Coupon Not Actived', description=u'用户优惠券未生效')
87
+    USER_COUPON_HAS_EXPIRED = StatusCodeField(504012, 'User Coupon Has Expired', description=u'用户优惠券已过期')
88
+
89
+
90
+class MarketCodeStatusCode(BaseStatusCode):
91
+    """ 一物一码相关错误码 5050xx """
92
+    MARKET_CODE_NOT_FOUND = StatusCodeField(505001, 'Market Code Not Found', description=u'一物一码不存在')
93
+
94
+
62 95
 class LensmanStatusCode(BaseStatusCode):
63 96
     """ 摄影师相关错误码 4000xx """
64 97
     LENSMAN_NOT_FOUND = StatusCodeField(400001, 'Lensman Not Found', description=u'摄影师不存在')

kodo - Gogs: Go Git Service

Brak opisu

huangqimin: 4ab2404bea MarketCode 6 lat temu
..
migrations 4ab2404bea MarketCode 6 lat temu
__init__.py 4ab2404bea MarketCode 6 lat temu
admin.py 4ab2404bea MarketCode 6 lat temu
apps.py 4ab2404bea MarketCode 6 lat temu
models.py 4ab2404bea MarketCode 6 lat temu
tests.py 4ab2404bea MarketCode 6 lat temu
views.py 4ab2404bea MarketCode 6 lat temu
kodo - Gogs: Go Git Service

Nessuna descrizione

huangqimin: 714f03e3d9 :art: Opt MEMBERCARD_USERINFO_LIST 6 anni fa
..
algorithm f38d3bf980 Caesar Alg 8 anni fa
error 212f24c882 MarketCode 6 anni fa
redis 714f03e3d9 :art: Opt MEMBERCARD_USERINFO_LIST 6 anni fa
sql f3cf68f957 Add PAI2_HOME_WX_API for request.weixin 8 anni fa
zbar 3d0d214667 :sparkles: Member Infos 6 anni fa
__init__.py 52ce35cbfc add api uuid_init/uuid 10 anni fa
admin_utils.py 9e4ac4fd3b Add admin_status for GroupUserInfo 9 anni fa
disk_utils.py af2b3f483f change download.html to be generated from download.tmpl.html 10 anni fa
group_photo_utils.py 0e7b5eb1af Update order_by of group session photos 9 anni fa
message_utils.py 21b4a5403a add api lensman_brief_api 10 anni fa
original_CGzC_10a50000c8811190.bak.jpg 290ff6960f pyzbar 6 anni fa
original_CGzC_10a50000c8811190.jpg 680f424408 Update water mark 9 anni fa
paiai_96_96.png 4a8b4f8819 add watermark 10 anni fa
paiai_water_mark.png 680f424408 Update water mark 9 anni fa
price_utils.py 24e345a32f Add price func get_group_photo_price 9 anni fa
qiniucdn.py 4ce7f5c87b :art: Member Relative APIs 6 anni fa
rdm_utils.py 4efb7f6f87 Statistic 8 anni fa
storage_qiniu_utils.py f2fc73685d Update package django_xxx 8 anni fa
storage_utils.py f2fc73685d Update package django_xxx 8 anni fa
thumbnail_utils.py 5c9e21b29b add Only Once Function statistic_thumbnail_size to statistic thumbnail size 10 anni fa
time_utils.py 511533855d Change oauth to use http 8 anni fa
url_utils.py 135c21b40c from models_ext import BaseModelMixin, upload_file_url, upload_path 8 anni fa
version_utils.py 13816e8774 Fix Bug: REQUEST 8 anni fa
watermark_utils.py 5411626ebe Change watermark position 9 anni fa
wx_utils.py 32a7d9ffa0 Update wx relative 9 anni fa