提交 1896dfeb authored 作者: 李思鑫's avatar 李思鑫

宴会申请调整

上级 310b40b0
...@@ -45,8 +45,7 @@ class Policy(models.Model): ...@@ -45,8 +45,7 @@ class Policy(models.Model):
(2,_('以宴席桌数为准')), (2,_('以宴席桌数为准')),
(3,_('严格的箱与桌公式设定')), (3,_('严格的箱与桌公式设定')),
(4,_('箱数为主要条件,桌数为次要条件')), (4,_('箱数为主要条件,桌数为次要条件')),
(5,_('桌数为主要条件,箱数为次要条件')), (5,_('桌数为主要条件,箱数为次要条件'))),default=3)
(6,_('按扫码瓶数换算箱数计算'))),default=3)
grades=models.JSONField(_('奖励等级'),default=list,blank=True,null=True) grades=models.JSONField(_('奖励等级'),default=list,blank=True,null=True)
# [{ # [{
...@@ -166,10 +165,12 @@ class Apply(models.Model): ...@@ -166,10 +165,12 @@ class Apply(models.Model):
status = models.SmallIntegerField(_('状态'), choices=( status = models.SmallIntegerField(_('状态'), choices=(
(0, _('未审核')), (0, _('未审核')),
(1, _('已通过')), (1, _('已通过')),
(2, _('未通过')), (2, _('未通过')),
(3, _('结算审核中')), (3, _('结算审核中')),
(4, _('结算中')), (4, _('结算中')),
(5, _('已结算')), (5, _('已结算')),
(6, _('开瓶数量不足,未通过结算奖励')),
(7, _('宴席资料异常')),
), default=0) ), default=0)
reason = models.CharField(_('原因'), max_length=500, blank=True, null=True) reason = models.CharField(_('原因'), max_length=500, blank=True, null=True)
annotation = models.CharField(_('批注'), max_length=500, blank=True, null=True) annotation = models.CharField(_('批注'), max_length=500, blank=True, null=True)
...@@ -185,6 +186,9 @@ class Apply(models.Model): ...@@ -185,6 +186,9 @@ class Apply(models.Model):
actual_table_num = models.SmallIntegerField(_('实际宴席桌数'), blank=True, null=True, default=0) actual_table_num = models.SmallIntegerField(_('实际宴席桌数'), blank=True, null=True, default=0)
actual_qty_x=models.IntegerField(_('实际箱数'),default=0) actual_qty_x=models.IntegerField(_('实际箱数'),default=0)
actual_qty_p=models.IntegerField(_('实际瓶数'),default=0) actual_qty_p=models.IntegerField(_('实际瓶数'),default=0)
scan_num=models.IntegerField(_('扫码数量'),default=0)
bottle_num=models.IntegerField(_('瓶数'),default=0)
is_ck=models.BooleanField(_('是否出库'),default=False,db_index=True)
class Meta: class Meta:
verbose_name = _('宴会申请') verbose_name = _('宴会申请')
......
...@@ -25,9 +25,9 @@ sK = 'fgfdvgu$#&3t@j' ...@@ -25,9 +25,9 @@ sK = 'fgfdvgu$#&3t@j'
from utils.views import time_key_check from utils.views import time_key_check
from inventory.views import LabelQuery, decrypt_11h from inventory.views import LabelQuery, decrypt_11h
from wx.views import transfer_batch from wx.views import transfer_batch
from mall.views import update_member_points_agent
import redis import redis
import math import math
from mall.views import update_member_points_agent
#2020-12-21 微信redis库 #2020-12-21 微信redis库
...@@ -99,6 +99,8 @@ def banquetList(request,obj): ...@@ -99,6 +99,8 @@ def banquetList(request,obj):
3: ['结算审核中','blue'], 3: ['结算审核中','blue'],
4: ['结算中','blue'], 4: ['结算中','blue'],
5: ['已结算','#07c160'], 5: ['已结算','#07c160'],
6: ['开瓶数量不足,未通过结算奖励','red'],
7: ['宴席资料异常','red'],
} }
status = dict[r[16]] status = dict[r[16]]
color = 'blue' color = 'blue'
...@@ -317,6 +319,9 @@ def banquetList(request,obj): ...@@ -317,6 +319,9 @@ def banquetList(request,obj):
data['data'].append([ data['data'].append([
r[1],r[2],float(r[3]),r[4],r[5],r[6],btns r[1],r[2],float(r[3]),r[4],r[5],r[6],btns
]) ])
elif obj == "code_search":
return render(request, 'banquet/code_search.html', data)
return render(request, 'obj/list_obj.html', data) return render(request, 'obj/list_obj.html', data)
...@@ -385,7 +390,8 @@ def ajax_banquet(request,obj): ...@@ -385,7 +390,8 @@ def ajax_banquet(request,obj):
return JsonResponse(ajaxBanquetConsumerScanAnalysis(id)) return JsonResponse(ajaxBanquetConsumerScanAnalysis(id))
elif obj == "manual_settle": elif obj == "manual_settle":
return ajaxBanquetManualSettle(request) return ajaxBanquetManualSettle(request)
elif obj == "code_search":
return ajaxBanquetCodeSearch(request)
def ajaxBanquetApply(request): def ajaxBanquetApply(request):
res = { res = {
...@@ -396,8 +402,7 @@ def ajaxBanquetApply(request): ...@@ -396,8 +402,7 @@ def ajaxBanquetApply(request):
'company_id' in d and 'company_id' in d and
'applyer_id' in d and 'applyer_id' in d and
'category_id' in d and 'category_id' in d and
'policy' in d and 'policy' in d and
'address' in d and
'table_num' in d and 'table_num' in d and
'user_name' in d and 'user_name' in d and
'user_phone' in d and 'user_phone' in d and
...@@ -407,8 +412,7 @@ def ajaxBanquetApply(request): ...@@ -407,8 +412,7 @@ def ajaxBanquetApply(request):
company_id = d['company_id'] company_id = d['company_id']
applyer_id = d['applyer_id'] applyer_id = d['applyer_id']
category_id = d['category_id'] category_id = d['category_id']
policy = d['policy'] policy = d['policy']
address = d['address']
table_num = d['table_num'] table_num = d['table_num']
user_name = d['user_name'] user_name = d['user_name']
user_phone = d['user_phone'] user_phone = d['user_phone']
...@@ -419,7 +423,6 @@ def ajaxBanquetApply(request): ...@@ -419,7 +423,6 @@ def ajaxBanquetApply(request):
applyer_id and applyer_id and
category_id and category_id and
policy and policy and
address and
table_num and table_num and
user_name and user_name and
user_phone and user_phone and
...@@ -433,14 +436,20 @@ def ajaxBanquetApply(request): ...@@ -433,14 +436,20 @@ def ajaxBanquetApply(request):
apply.ancestor_id = c.ancestor_id apply.ancestor_id = c.ancestor_id
apply.applyer_id = applyer_id apply.applyer_id = applyer_id
apply.company = c apply.company = c
if apply.status == 6:
res['e'] = '当前状态不允许修改'
return JsonResponse(res)
apply.category_id = category_id apply.category_id = category_id
if 'product_id' in d and d['product_id']: if 'product_id' in d and d['product_id']:
product_id = d['product_id'] product_id = d['product_id']
apply.product_id = product_id apply.product_id = product_id
if 'address' in d and d['address']:
apply.address = d['address']
apply.policy = policy apply.policy = policy
apply.address = address
apply.table_num = table_num apply.table_num = table_num
apply.user_name = user_name apply.user_name = user_name
apply.user_phone = user_phone apply.user_phone = user_phone
...@@ -872,9 +881,9 @@ def ajaxBanquetCancel(request): ...@@ -872,9 +881,9 @@ def ajaxBanquetCancel(request):
if obj.status == 0: if obj.status == 0:
obj.delete() obj.delete()
else: else:
res['e'] = '无法删除已审核申请' data['e'] = '无法删除已审核申请'
else: else:
res['e'] = '数据丢失' data['e'] = '数据丢失'
return JsonResponse(res) return JsonResponse(res)
...@@ -1096,10 +1105,15 @@ def ajaxBanquetSettle(request): ...@@ -1096,10 +1105,15 @@ def ajaxBanquetSettle(request):
# 如果提交箱数和核销相同 且 实际桌数与申请桌数相同 则自动返利 并修改状态为结算中 # 如果提交箱数和核销相同 且 实际桌数与申请桌数相同 则自动返利 并修改状态为结算中
if apply_codes_cnt == writeoff_cnt and apply.actual_table_num == apply.table_num: if apply_codes_cnt == writeoff_cnt and apply.actual_table_num == apply.table_num:
if apply.ancestor_id == 208869: if apply.ancestor_id == 208869:
d = ajaxBanquetConsumerScanAnalysis(id) apply.status = 3 #结算审核中
#print(d) #pids = [10558, 10559, 10560, 10561, 10562]
if d['scan_rate'] >= 0.5: # 如果是一代产品则直接结算
apply.status = 4 #结算中 #if apply.product_id in pids:
# apply.status = 4 #结算中
#else:
# d = ajaxBanquetConsumerScanAnalysis(id)
# if d['scan_rate'] >= 1:
# apply.status = 4 #结算中
else: else:
apply.status = 4 #结算中 apply.status = 4 #结算中
...@@ -1168,7 +1182,7 @@ def ajaxBanquetConsumerScanAnalysis(id): ...@@ -1168,7 +1182,7 @@ def ajaxBanquetConsumerScanAnalysis(id):
data['e'] = '数据丢失' data['e'] = '数据丢失'
return data return data
def ajaxBanquetManualSettle(request): def ajaxBanquetManualSettle(request):
data = {'e': ''} data = {'e': ''}
id = int(request.POST.get('id','0')) id = int(request.POST.get('id','0'))
...@@ -1199,6 +1213,19 @@ def ajaxBanquetManualSettle(request): ...@@ -1199,6 +1213,19 @@ def ajaxBanquetManualSettle(request):
data['e'] = '无数据' data['e'] = '无数据'
return JsonResponse(data) return JsonResponse(data)
def ajaxBanquetCodeSearch(request):
data = {'e': '','apply_id':0}
code = request.GET.get('code','')
if code:
bc = Apply_Codes.objects.filter(code=code)
if bc:
data['apply_id'] = bc[0].apply_id
else:
data['e'] = '数据不存在'
else:
data['e'] = '数据丢失'
return JsonResponse(data)
# 2024-06-24 # 2024-06-24
def policy(request,action='list',id=None): def policy(request,action='list',id=None):
u=request.user u=request.user
...@@ -1223,7 +1250,7 @@ def policy(request,action='list',id=None): ...@@ -1223,7 +1250,7 @@ def policy(request,action='list',id=None):
else: else:
form=PolicyForm(request.POST,instance=obj) form=PolicyForm(request.POST,instance=obj)
print(form)
if form.is_valid(): if form.is_valid():
form.save() form.save()
...@@ -1452,7 +1479,7 @@ def close_applys(request,agent_id,apply_id=None): ...@@ -1452,7 +1479,7 @@ def close_applys(request,agent_id,apply_id=None):
amt='0' amt='0'
for r in rs: for r in rs:
id=str(r[0]) id=str(r[0])
app=str(r[1]) app=str(r[1])
# 宴席桌数 # 宴席桌数
z=str(r[2]) z=str(r[2])
...@@ -1465,7 +1492,7 @@ def close_applys(request,agent_id,apply_id=None): ...@@ -1465,7 +1492,7 @@ def close_applys(request,agent_id,apply_id=None):
p=ps[0] p=ps[0]
if p.sql: if p.sql:
amt=p.sql amt=p.sql
if p.consumer_scan_strategy: if p.consumer_scan_strategy:
cur.execute(f""" cur.execute(f"""
select count(0) from sales_consumerwinner where company_id = {str(ancestor_id)} and xcode in ( select count(0) from sales_consumerwinner where company_id = {str(ancestor_id)} and xcode in (
...@@ -1508,39 +1535,27 @@ def close_applys(request,agent_id,apply_id=None): ...@@ -1508,39 +1535,27 @@ def close_applys(request,agent_id,apply_id=None):
if points: if points:
update_member_points_agent(agent_id,points,'消费者宴会扫码返利') update_member_points_agent(agent_id,points,'消费者宴会扫码返利')
data['apply_ids'].append(r[1]) data['apply_ids'].append(r[1])
# 箱数
x_num = 'count(*)'
# 查询手动结算记录,如果有手动结算,则以手动结算为准 # 查询手动结算记录,如果有手动结算,则以手动结算为准
cur.execute("select amt from banquet_settlerecord where apply_id = "+app+" order by id desc limit 1") cur.execute("select amt from banquet_settlerecord where apply_id = "+app+" order by id desc limit 1")
r = cur.fetchone() r = cur.fetchone()
if r: if r:
amt = str(r[0]) amt = str(r[0])
else:
# # 查询扫码率 过滤不需要扫码的产品
if ancestor_id == 208869:
include_product_ids = [10124, 10125, 10126, 10127, 10128]
if product_id in include_product_ids:
analysis = ajaxBanquetConsumerScanAnalysis(int(app))
if analysis['bottle_num']:
x_num = str(math.floor(analysis['bottle_num'] / 6))
print(amt)
if amt !='0': if amt !='0':
# 写入奖励记录产品名称 # 写入奖励记录
s="insert into banquet_bonus(ancestor_id,agent_id,policy_id,apply_id,product_id,qty_x,table_num,amt,qty_p) "+\ s="insert into banquet_bonus(ancestor_id,agent_id,policy_id,apply_id,product_id,qty_x,table_num,amt,qty_p) "+\
"select "+aid+","+agent_id+","+id+","+app+",product_id,X,Z,"+amt+",P from "+\ "select "+aid+","+agent_id+","+id+","+app+",product_id,X,Z,"+amt+",P from "+\
"(select product_id,"+x_num+" X, "+z+" Z,sum(P) P from "+\ "(select product_id,count(*) X, "+z+" Z,sum(P) P from "+\
"(select label_pk_id,product_id,"+\ "(select label_pk_id,product_id,"+\
"(select count(*) from banquet_writeoff where apply_id="+app+" and label_pk_id=w.label_pk_id and label_pkg!=3) P "+\ "(select count(*) from banquet_writeoff where apply_id="+app+" and label_pk_id=w.label_pk_id and label_pkg!=3) P "+\
"from banquet_writeoff w where apply_id="+app+\ "from banquet_writeoff w where apply_id="+app+\
" group by label_pk_id,product_id"+\ " group by label_pk_id,product_id"+\
") g group by product_id"+\ ") g group by product_id"+\
") gg" ") gg"
print(s)
cur.execute(s) cur.execute(s)
#print(s)
# 写入剩余实物 # 写入剩余实物
s="INSERT INTO banquet_surplus(ancestor_id,agent_id,policy_id,apply_id,product_id,qty_x,qty_p,dt,tm) "+\ s="INSERT INTO banquet_surplus(ancestor_id,agent_id,policy_id,apply_id,product_id,qty_x,qty_p,dt,tm) "+\
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
event.preventDefault(); event.preventDefault();
var status = $("#status_select option:selected").val(); var status = $("#status_select option:selected").val();
var remark = $("#txt_remark").val(); var remark = $("#txt_remark").val();
$.ajax({ $.ajax({
url: '/banquet/ajax/permit', url: '/banquet/ajax/permit',
data:{ data:{
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
success:function(res){ success:function(res){
if(res.e === ''){ if(res.e === ''){
$(".alert-success").fadeIn(); $(".alert-success").fadeIn();
changeTableData(status) changeTableData(status)
//$.RefreshContent("/banquet/list/apply/"); //$.RefreshContent("/banquet/list/apply/");
setTimeout(function(){ setTimeout(function(){
$(".alert-success").fadeOut(); $(".alert-success").fadeOut();
...@@ -49,11 +49,13 @@ ...@@ -49,11 +49,13 @@
var status = {{status}} var status = {{status}}
if(status >= 3){ if(status >= 3){
$("#status_select").html(` $("#status_select").html(`
<option value="2">驳回</option>
<option value="4">通过</option> <option value="4">通过</option>
<option value="1">驳回(重新核销)</option>
<option value="2">驳回(重新申请)</option>
<option value="6">开瓶数量不足,未通过结算奖励</option>
`) `)
} }
function changeTableData(status){ function changeTableData(status){
var status_dict = { var status_dict = {
0: ['未审核','blue'], 0: ['未审核','blue'],
...@@ -62,6 +64,8 @@ ...@@ -62,6 +64,8 @@
3: ['结算审核中','blue'], 3: ['结算审核中','blue'],
4: ['结算中','blue'], 4: ['结算中','blue'],
5: ['已结算','#07c160'], 5: ['已结算','#07c160'],
6: ['开瓶数量不足,未通过结算奖励','red'],
7: ['宴席资料异常','red'],
} }
var firstLink = $(window.click_row).find('td:first a'); var firstLink = $(window.click_row).find('td:first a');
$(firstLink).text(status_dict[status][0]) $(firstLink).text(status_dict[status][0])
...@@ -86,6 +90,7 @@ ...@@ -86,6 +90,7 @@
<option value="0">未审核</option> <option value="0">未审核</option>
<option value="1">通过</option> <option value="1">通过</option>
<option value="2">未通过</option> <option value="2">未通过</option>
<option value="7">宴席资料异常</option>
</select> </select>
</div> </div>
</div> </div>
...@@ -95,6 +100,7 @@ ...@@ -95,6 +100,7 @@
<textarea id="txt_remark" cols="30" rows="10" placeholder="填写备注" style="width: 100%;"></textarea> <textarea id="txt_remark" cols="30" rows="10" placeholder="填写备注" style="width: 100%;"></textarea>
</div> </div>
</div> </div>
<h3 style="text-align: center; margin-top:20px;">宴会信息审核</h3>
<div> <div>
<button class="btn btn-primary" id="btn_permit" style="float:right;">保存</button> <button class="btn btn-primary" id="btn_permit" style="float:right;">保存</button>
</div> </div>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论