提交 fb70619c authored 作者: 张颂恩's avatar 张颂恩

消费者扫码自动出库逻辑优化

上级 6ae71216
...@@ -5691,20 +5691,35 @@ def wx_label_scan_record(request): ...@@ -5691,20 +5691,35 @@ def wx_label_scan_record(request):
# http://localhost:8000/wx/label/scan_record/?uid=%22gAAAAABm69JXNwYZh4LL__7YjX-SG3xkbrJnMUycv-75qfkzQNN6NkfEKmR741XVASxtVAeCXptkOF4Fc12fz48Z0uMhZynaeQ%3D%3D%22&compid=199264&fwcode=129701910053&lat=20.0076&lng=110.29357 # http://localhost:8000/wx/label/scan_record/?uid=%22gAAAAABm69JXNwYZh4LL__7YjX-SG3xkbrJnMUycv-75qfkzQNN6NkfEKmR741XVASxtVAeCXptkOF4Fc12fz48Z0uMhZynaeQ%3D%3D%22&compid=199264&fwcode=129701910053&lat=20.0076&lng=110.29357
s_len = len(d['stock_dev']) s_len = len(d['stock_dev'])
if s_len and product_id and data['label_pkg'] == 1 and compid == '199264': if s_len and product_id and data['label_pkg'] == 1 and compid == '199264':
last_row = d['stock_dev'][s_len-1] is_rk = False
print(last_row) is_ck = False
if last_row['voucher_type'] == '成品入库': rk_row = None
lbcode = fwcode
if fwcode.startswith('9'):
cur.execute(f"select code_a from label.lbl_abcode where code_b = '{fwcode}' ")
r = cur.fetchone()
if r and r[0]:
lbcode = r[0]
for stk in d['stock_dev']:
if stk['voucher_type'] == '成品入库' and (stk['label_code'] == lbcode or stk['label_code'] == fwcode or stk['package'] == '箱标'):
is_rk = True
rk_row = stk
if stk['voucher_type'] == '销售出库' and stk['label_code'] == lbcode:
is_ck = True
if is_rk and not is_ck:
code = 'ZDCK-'+datetime.datetime.now().strftime('%Y%m%d%H%M%S%f')[:-3] code = 'ZDCK-'+datetime.datetime.now().strftime('%Y%m%d%H%M%S%f')[:-3]
# 节流 # 节流
if rd_wx.set('ZDCK-'+fwcode, code, px=5000, nx=True): if rd_wx.set('ZDCK-'+lbcode, code, px=5000, nx=True):
t=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') t=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
m2=hashlib.md5((sK+t).encode('utf8')) m2=hashlib.md5((sK+t).encode('utf8'))
codes = [fwcode] codes = [lbcode]
data={ postData={
"bill_number": code, "bill_number": code,
"company_id": last_row['company_id'], "company_id": rk_row['company_id'],
"to_company_id": 11013, "to_company_id": 11013,
"user_id": last_row['user_id'], "user_id": rk_row['user_id'],
"product_id": product_id, "product_id": product_id,
"voucher_id": 2, "voucher_id": 2,
"voucher_time":t, "voucher_time":t,
...@@ -5713,7 +5728,7 @@ def wx_label_scan_record(request): ...@@ -5713,7 +5728,7 @@ def wx_label_scan_record(request):
"key":m2.hexdigest(), "key":m2.hexdigest(),
} }
request.method = 'POST' request.method = 'POST'
request._body=json.dumps(data) request._body=json.dumps(postData)
request.META['CONTENT_TYPE']='application/json' request.META['CONTENT_TYPE']='application/json'
r = fg_update(request) r = fg_update(request)
...@@ -12196,6 +12211,8 @@ def channelredeem_online(request): ...@@ -12196,6 +12211,8 @@ def channelredeem_online(request):
cid=str(u.company_id) cid=str(u.company_id)
if not rd_wx.set(cid+':'+user_id, user_id, px=5000, nx=True): if not rd_wx.set(cid+':'+user_id, user_id, px=5000, nx=True):
return JsonResponse({'e':'网络繁忙,请稍后再试'}) return JsonResponse({'e':'网络繁忙,请稍后再试'})
if u.ancestor_id == 238273:
return JsonResponse({'e':'提现功能不可用'})
if method=='wx': if method=='wx':
if not wx_openid or not user_id or not amount: if not wx_openid or not user_id or not amount:
data['e']='wxopenid,user id,amount required' data['e']='wxopenid,user id,amount required'
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论