提交 2d9b90ae authored 作者: 李思鑫's avatar 李思鑫

核销id批量核销

上级 f27bf620
......@@ -5615,10 +5615,10 @@ def do_hexiao(request):
remark = request.GET.get('remark', '')
parent_agent_id = request.GET.get('parent_agent_id', '')
hexiao_id = request.GET.get('hexiao_id', '')
hexiao_ids = request.GET.get('hexiao_ids', '')
applyer_id = request.GET.get('applyer_id', '')
lat = request.GET.get('lat','0')
lng = request.GET.get('lng','0')
cur = connection.cursor()
if parent_agent_id == 'undefined':
parent_agent_id = ''
......@@ -5696,6 +5696,62 @@ def do_hexiao(request):
else:
data['e'] = '奖品不需要核销'
return JsonResponse(data);
elif hexiao_ids:#批量核销
no_need_hexiao_ids = []
need_hexiao_ids = []
# 先判断所有记录的核销条件
hexiao_ids = hexiao_ids.split(',')
if len(hexiao_ids) > 20 :
data['e'] = '一次最多核销20个'
for hx_id in hexiao_ids:
hx = HeXiao_Record.objects.get(id=int(hx_id))
if hx.is_need_agent_writeoff:
if not hx.is_agent_writeoff:
need_hexiao_ids.append(hx) # 符合条件的记录,加入处理列表
else:
no_need_hexiao_ids.append(f'ID {hx_id}: 奖品已被核销')
else:
no_need_hexiao_ids.append(f'ID {hx_id}: 奖品不需要核销')
if len(no_need_hexiao_ids):
print('no_need_hexiao_ids',no_need_hexiao_ids)
data['e'] = '存在不需要核销记录' + ','.join(no_need_hexiao_ids)
elif len(hexiao_ids) <= 20 and len(no_need_hexiao_ids) == 0 and len(need_hexiao_ids) > 0:
for hx in need_hexiao_ids:
agent = Company.objects.get(id=int(agent_id))
if hx.agent_id != agent.id:
award = hx.award
consumer = hx.consumer
money = award.amount if award.amount else 0
record = HeXiao_Record(
company_id=int(company_id),
award=award,
consumer=consumer,
activity=hx.activity,
activity_name=hx.activity.name,
agent=agent,
award_name=award.name,
consumer_name=consumer.name,
consumer_phone=consumer.phone,
agent_name=agent.name,
remark=remark,
money=money,
winner_id=hx.winner_id,
is_redeemed=False,
hexiao_id=hx.id,
is_need_dispatch=False
)
if applyer_id:
record.applyer_id = int(applyer_id)
if agent.level_id != 1:
record.is_need_agent_writeoff = True
record.save()
hx.is_agent_writeoff = True
hx.save()
else:
data['e'] = '无核销权限'
return JsonResponse(data)
if c:
vs = VoidLabel.objects.filter(label_code=c.label_code)
if len(vs) == 0:
......@@ -9872,7 +9928,7 @@ def activity_lottery_plan_edit(request, id=None):
#lisin 修改成批量
if win_scan_num:
win_scan_num = [int(num) for num in win_scan_num.split(',')]
if(len(win_scan_num) > 2):
if(len(win_scan_num) > 20):
e = '设置数量不能超过20个'
return render(request, 'sales/activity_lottery_plan.html', {e : e})
......
......@@ -124,10 +124,10 @@ def app_autocomplete(request,what):
return JsonResponse(data,safe=False)
#2020-07-10
rd=redis.StrictRedis(host='localhost', port=settings.RD['port'], decode_responses=True)
rd=redis.StrictRedis(host='localhost', port=settings.RD['port'], password='tjredis139', decode_responses=True)
#2020-12-21 微信redis库
rd_wx=redis.StrictRedis(host='localhost', port=settings.RD['port'], db=5, decode_responses=True)
rd_wx=redis.StrictRedis(host='localhost', port=settings.RD['port'], db=5, password='tjredis139', decode_responses=True)
WX_ERRS={
1:'标签号码不存在',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论