|
@@ -564,9 +564,9 @@ class UnicomManageControllerView(View):
|
|
|
sheet.cell(row=i + 1, column=1, value=vo.code)
|
|
|
filename = '国内流量年卡兑换码-{}.xlsx'.format(exchange_code.count())
|
|
|
# 创建一个http响应
|
|
|
- res = HttpResponse(content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
|
|
|
+ res = HttpResponse(content_type='application/vnd.ms-excel')
|
|
|
# 设置响应头,告诉浏览器文件要下载而不是直接打开
|
|
|
- res['Content-Disposition'] = f'attachment; filename="{filename}"'
|
|
|
+ res['Content-Disposition'] = 'attachment; filename={}'.format(filename)
|
|
|
# 将excel文档保存到http响应中
|
|
|
wb.save(res)
|
|
|
exchange_code.update(is_down=True, updated_time=int(time.time()))
|
|
@@ -595,7 +595,8 @@ class UnicomManageControllerView(View):
|
|
|
now_time = int(time.time())
|
|
|
if combo.combo_type == 3:
|
|
|
for i in range(int(quantity)):
|
|
|
- code = cls.generate_code()
|
|
|
+ # 10位兑换码 后面两位为标识代表五兴电信
|
|
|
+ code = cls.generate_code() + 'WD'
|
|
|
exchange_code_list.append(ExchangeCode(code=code, status=False, is_down=0,
|
|
|
package_type=1, package_id=combo.id,
|
|
|
expire_time=0,
|
|
@@ -619,5 +620,5 @@ class UnicomManageControllerView(View):
|
|
|
# 使用SHA1算法生成哈希值
|
|
|
sha1 = hashlib.sha1(uuid_str.encode('utf-8'))
|
|
|
# 取哈希值的前8位,并将其转换为大写字母
|
|
|
- code = sha1.hexdigest()[:16].upper()
|
|
|
+ code = sha1.hexdigest()[:8].upper()
|
|
|
return code
|