| @@ -15,11 +15,11 @@ from pywe_storage import RedisStorage | ||
| 15 | 15 | from account.models import UserInfo | 
| 16 | 16 | from logs.models import MchInfoDecryptLogInfo, MchInfoEncryptLogInfo | 
| 17 | 17 | from marketcode.models import MarketCodeInfo | 
| 18 | -from mch.models import ActivityInfo, BrandInfo, ModelInfo, ConsumeShotUnbindingInfo | |
| 18 | +from mch.models import ActivityInfo, BrandInfo, ConsumeShotUnbindingInfo, ModelInfo | |
| 19 | 19 | from utils.algorithm.b64 import b64_decrypt, b64_encrypt | 
| 20 | 20 | from utils.algorithm.caesar import caesar_decrypt, caesar_encrypt | 
| 21 | 21 | from utils.algorithm.rsalg import rsa_decrypt, rsa_encrypt | 
| 22 | -from utils.error.errno_utils import MarketCodeStatusCode, UserStatusCode | |
| 22 | +from utils.error.errno_utils import CiphertextStatusCode, MarketCodeStatusCode, UserStatusCode | |
| 23 | 23 | from utils.redis.connect import r | 
| 24 | 24 |  | 
| 25 | 25 |  | 
| @@ -108,7 +108,10 @@ def encrypt(request): | ||
| 108 | 108 | def decrypt(request, v='v2'): | 
| 109 | 109 |      ciphertext = request.POST.get('ciphertext', '') | 
| 110 | 110 |  | 
| 111 | -    prefix, cipherlen, ciphertext = ciphertext.split('+', 2) | |
| 111 | + try: | |
| 112 | +        prefix, cipherlen, ciphertext = ciphertext.split('+', 2) | |
| 113 | + except Exception: | |
| 114 | + return response(CiphertextStatusCode.CIPHERTEXT_INVALID) | |
| 112 | 115 |  | 
| 113 | 116 | ciphertext = ciphertext[:int(cipherlen)] | 
| 114 | 117 |  | 
| @@ -197,6 +197,11 @@ class MarketCodeStatusCode(BaseStatusCode): | ||
| 197 | 197 | MARKET_CODE_NOT_FOUND = StatusCodeField(505001, 'Market Code Not Found', description=u'一物一码不存在') | 
| 198 | 198 |  | 
| 199 | 199 |  | 
| 200 | +class CiphertextStatusCode(BaseStatusCode): | |
| 201 | + """ 加解密相关错误码 5050xx """ | |
| 202 | + CIPHERTEXT_INVALID = StatusCodeField(505011, 'Ciphertext Invalid', description=u'密文无效') | |
| 203 | + | |
| 204 | + | |
| 200 | 205 | class MaintenancePointStatusCode(BaseStatusCode): | 
| 201 | 206 | """ 维修点相关错误码 5060xx """ | 
| 202 | 207 | MAINTENACE_POINT_NOT_FOUND = StatusCodeField(506001, 'Maintenance Point Not Found', description=u'维修点不存在') |