提交 07b558b6 authored 作者: 李思鑫's avatar 李思鑫

Merge branch 'dev' of http://124.225.116.118:35236/tj_django/datacenter into dev

......@@ -1104,6 +1104,8 @@ urlpatterns = [
url(r'^sales/lotterywinnerseeds/delete/(?P<id>\d+)/$', sal_views.lotterywinnerseeds_delete),
#核销管理
url(r'^sales/do_hexiao/$', sal_views.do_hexiao),
url(r'^sales/do_agent_winner_hexiao/$', sal_views.do_agent_winner_hexiao),
url(r'^sales/do_agent_withdraw_hexiao/$', sal_views.do_agent_withdraw_hexiao),
# 经销商给终端店兑付
url(r'^sales/do-redeem/$', sal_views.do_redeem),
url(r'^sales/do_hexiao_dispatch/$', sal_views.do_hexiao_dispatch),
......
......@@ -5846,6 +5846,99 @@ def do_hexiao(request):
return JsonResponse(data)
# 核销接口
@csrf_exempt
def do_agent_winner_hexiao(request):
data = {
'e': '',
'reason': ''
}
company_id = int(request.GET.get('company_id', '0'))
user_id = int(request.GET.get('user_id', '0'))
winner_id = request.GET.get('winner_id', '')
if company_id and user_id and winner_id:
winner_id = decrypt_p(winner_id)
win = AgentWinner.objects.get(id=int(winner_id))
if win.is_need_hexiao:
if not win.is_hexiao:
if win.company_id != company_id:
c = Company.objects.get(id=company_id)
h = HeXiao_Record(
company_id=win.ancestor_id,
award_id=win.award_id,
award_name=win.award_name,
activity_id=win.activity_id,
activity_name=win.activity.name,
agent_id=c.id,
agent_name=c.name,
applyer_id=user_id,
agent_winner_id=win.id,
money=0
)
h.save()
win.is_hexiao = True
win.write_off_company_id = company_id
win.write_off_user_id = user_id
win.write_off_tm = now()
win.save()
else:
data['e'] = '您不能自己核销'
else:
data['e'] = '数据已核销'
else:
data['e'] = '数据无需核销'
else:
data['e'] = '数据丢失'
return JsonResponse(data)
# 核销提现接口
@csrf_exempt
def do_agent_withdraw_hexiao(request):
data = {
'e': ''
}
company_id = int(request.GET.get('company_id', '0'))
user_id = int(request.GET.get('user_id', '0'))
agent_id = int(request.GET.get('agent_id', '0'))
amount = float(request.GET.get('amount', '0'))
lat = request.GET.get('lat', '0')
lng = request.GET.get('lng', '0')
if company_id and user_id and agent_id and amount:
agent = Company.objects.get(id=agent_id)
u = User.objects.get(id=user_id)
if u.ancestor_id == agent.ancestor_id:
# 限制只能公司级别核销
if u.level_id != 1:
data['e']='无核销权限'
return JsonResponse(data)
s="select coalesce(rval,0.00),coalesce(dval,0.00) from "+\
"(select "+\
"(select sum(val) from sales_channelrebatebatch where company_id="+str(agent_id)+") rval,"+\
"(select sum(val) from sales_channelrebateredeemed where company_id="+str(agent_id)+") dval "+\
") t"
cur=connection.cursor()
cur.execute(s)
r=cur.fetchone()
if amount+float(r[1])>float(r[0]):
data['e']='可提现金额不足'
return JsonResponse(data)
rd=ChannelRebateRedeemed(
company_id=agent_id,
ancestor_id=u.company.ancestor_id,
user_id=u.id,
val=amount,
remark='核销提现'
)
rd.save()
else:
data['e'] = '无权限核销'
else:
data['e'] = '数据丢失'
return JsonResponse(data)
# 经销商给终端店兑付
@csrf_exempt
......
......@@ -584,7 +584,6 @@ def get_activity(company_id,label_code,lng=0,lat=0,phone='',activity_id=0, jmcpi
# "order by priority desc limit 1"
cur.execute(s)
r=cur.fetchone()
if r:
......@@ -5647,10 +5646,50 @@ def wx_label_scan_record(request):
cur.execute(s)
fwcode=cur.fetchone()[0]
#print
# 辽宁铁研后的公司走新查询接口
if int(compid)>=243885:
d = LabelQuery(int(compid),fwcode)
p = d.get_product()
product_id = p['id']
package_id = d.infor['label_pk_pkg']
pkid = d.infor['label_pk_id']
data['label_pkg']=package_id
data['label_pk_id'] = pkid
if product_id:
data['product_id']=product_id
cur.execute("select contents, name, photo, remark from product_product where id = "+ str(product_id))
rr = cur.fetchone()
if rr:
if rr[0]:
data['product_contents'] = urllib.parse.quote(rr[0])
data['product_name'] = rr[1]
data['product_photo'] = rr[2]
data['product_remark'] = rr[3]
stock_dev = d.get_stk_dev()
if stock_dev:
for sto in stock_dev:
if sto['voucher'] == '成品入库' and not data['voucher_no']:
data['voucher_no'] = sto['bill_no']
if sto['voucher'] == '销售出库' and not data['agent_name']:
agent_name = sto['agent']['name']
data['agent_name'] = agent_name
data['agent_id'] = sto['agent']['id']
data['fh_time'] = sto['tm']
# 辽宁铁研
if compid == '243885':
xcode = d.infor['label_pk_code']
data['boxes'] = xcode
if xcode:
cur.execute(f"select to_char(tm,'yyyy-mm-dd HH24:MI:SS') from mes_labelbindpx where carton_code = '"+xcode+"' limit 1")
r = cur.fetchone()
if r and r[0]:
data['bind_tm'] = r[0]
else:
d = label_sys_info(fwcode, comp[0], has_price=False)
#print(fwcode)
print(json.dumps(d))
# 2023-08-29
if d['label_pk_id']:
pkid=d['label_pk_id']
......@@ -5732,15 +5771,6 @@ def wx_label_scan_record(request):
request.META['CONTENT_TYPE']='application/json'
r = fg_update(request)
# 辽宁铁研
if compid == '243885':
xcode = d['boxes']['pk']
data['boxes'] = d['boxes']
if xcode:
cur.execute(f"select to_char(tm,'yyyy-mm-dd HH24:MI:SS') from mes_labelbindhx where carton_code = '"+xcode+"' limit 1")
r = cur.fetchone()
if r and r[0]:
data['bind_tm'] = r[0]
if compid == '189137':
r = requests.get('http://www.china315net.com:35222/fjbq/json/'+fwcode+'/')
......@@ -12987,8 +13017,23 @@ def get_fwcode_by_nfc_code(request):
def get_nfc_code_by_label_code(request):
data = {'e': '', 'label': ''}
label_code = request.GET.get('label_code', '')
userid = int(request.GET.get('userid', '0'))
if label_code:
if userid:
u = User.objects.get(id=userid)
cur = connection.cursor()
# 南京海邦需要先查箱绑定的盒码
if u.company_id == 212916:
unbind_codes = []
s = "SELECT box_code, (SELECT count(0) FROM logistics.z_labelnfc_details where label = box_code) FROM logistics.mes_labelbindhx WHERE carton_code = '"+label_code+"' "
cur.execute(s)
rs = cur.fetchall()
for r in rs:
if r[1] == 0:
unbind_codes.append(r[0])
if len(unbind_codes):
data['e'] = '存在未绑数据'
else:
s = f"select nfc from z_labelnfc_details where label = '{label_code}' order by id desc limit 1"
cur.execute(s)
r = cur.fetchone()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论