Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
ypt_mgw_local
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
苏星豪
ypt_mgw_local
Commits
1726fb0f
提交
1726fb0f
authored
7月 19, 2023
作者:
张颂恩
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增消费者助力活动接口,修改门店打卡接口必填字段判断
上级
e1fe3937
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
139 行增加
和
6 行删除
+139
-6
0341_auto_20230719_1617.py
sales/migrations/0341_auto_20230719_1617.py
+39
-0
models.py
sales/models.py
+14
-5
views.py
wx/views.py
+86
-1
没有找到文件。
sales/migrations/0341_auto_20230719_1617.py
0 → 100644
浏览文件 @
1726fb0f
# Generated by Django 3.1.4 on 2023-07-19 16:17
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'company'
,
'0327_terminalregister_parent_user'
),
(
'sales'
,
'0340_lotteryseeds_is_terminal_rebate'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'activityawards'
,
name
=
'help_num'
,
field
=
models
.
IntegerField
(
default
=
0
,
verbose_name
=
'助力次数'
),
preserve_default
=
False
,
),
migrations
.
CreateModel
(
name
=
'ConsumerHelp'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'award_name'
,
models
.
CharField
(
blank
=
True
,
max_length
=
200
,
null
=
True
,
verbose_name
=
'奖品名称'
)),
(
'label_code'
,
models
.
CharField
(
blank
=
True
,
db_index
=
True
,
max_length
=
20
,
null
=
True
,
verbose_name
=
'标签号码'
)),
(
'dt'
,
models
.
DateField
(
auto_now_add
=
True
,
db_index
=
True
,
verbose_name
=
'日期'
)),
(
'tm'
,
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'时间'
)),
(
'activity'
,
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
SET_NULL
,
to
=
'sales.activities'
,
verbose_name
=
'活动名称'
)),
(
'award'
,
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
SET_NULL
,
to
=
'sales.activityawards'
,
verbose_name
=
'奖品'
)),
(
'company'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'company.company'
,
verbose_name
=
'公司名称'
)),
(
'consumer'
,
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
SET_NULL
,
to
=
'sales.consumeraccount'
,
verbose_name
=
'消费者帐号'
)),
],
options
=
{
'verbose_name'
:
'消费者助力记录'
,
'verbose_name_plural'
:
'消费者助力记录'
,
},
),
]
sales/models.py
浏览文件 @
1726fb0f
...
...
@@ -385,6 +385,8 @@ class ActivityAwards(models.Model):
# 2023-05-30 当前奖项对终端返利金额/点值
terminal_rebate
=
models
.
DecimalField
(
_
(
'消费者扫码返终端'
),
max_digits
=
12
,
decimal_places
=
2
,
blank
=
True
,
null
=
True
)
# 2023-07-19 达到该助力次数后中奖
help_num
=
models
.
IntegerField
(
_
(
'助力次数'
))
#terminal_scan_amt=models.DecimalField(_('终端扫码返利'), max_digits=12, decimal_places=2, blank=True, null=True)
...
...
@@ -2264,11 +2266,18 @@ class ChannelRebateAccumulation(models.Model):
verbose_name
=
_
(
"消费者扫码累计返利"
)
verbose_name_plural
=
_
(
"消费者扫码累计返利)"
)
class
ConsumerHelp
(
models
.
Model
):
company
=
models
.
ForeignKey
(
'company.Company'
,
verbose_name
=
_
(
'公司名称'
),
on_delete
=
models
.
CASCADE
)
activity
=
models
.
ForeignKey
(
Activities
,
verbose_name
=
_
(
'活动名称'
),
on_delete
=
models
.
SET_NULL
,
blank
=
True
,
null
=
True
)
award
=
models
.
ForeignKey
(
ActivityAwards
,
verbose_name
=
_
(
'奖品'
),
on_delete
=
models
.
SET_NULL
,
blank
=
True
,
null
=
True
)
award_name
=
models
.
CharField
(
_
(
'奖品名称'
),
max_length
=
200
,
blank
=
True
,
null
=
True
)
consumer
=
models
.
ForeignKey
(
ConsumerAccount
,
verbose_name
=
_
(
'消费者帐号'
),
on_delete
=
models
.
SET_NULL
,
blank
=
True
,
null
=
True
)
label_code
=
models
.
CharField
(
_
(
'标签号码'
),
max_length
=
20
,
db_index
=
True
,
blank
=
True
,
null
=
True
)
dt
=
models
.
DateField
(
_
(
'日期'
),
auto_now_add
=
True
,
db_index
=
True
)
tm
=
models
.
DateTimeField
(
_
(
'时间'
),
auto_now_add
=
True
)
class
Meta
:
verbose_name
=
_
(
"消费者助力记录"
)
verbose_name_plural
=
_
(
"消费者助力记录"
)
# 2023-05-31 消费者中奖后需要执行的额外操作
def
consumerwinner_hit
(
winner
):
...
...
wx/views.py
浏览文件 @
1726fb0f
...
...
@@ -4912,7 +4912,7 @@ def wx_salesmanCallOn(request):
report
=
request
.
POST
.
get
(
'report'
,
''
)
lng_lat
=
lng_lat
.
split
(
','
)
if
not
uid
or
not
lng_lat
or
not
terminal_id
or
not
report
:
if
not
uid
or
not
lng_lat
or
not
terminal_id
:
return
JsonResponse
({
'e'
:
'lack of parameters'
})
c
=
Company
.
objects
.
filter
(
id
=
terminal_id
)
...
...
@@ -11412,3 +11412,87 @@ def channelredeem_online(request):
cur
.
close
()
return
JsonResponse
(
data
)
# 2023-07-19
@csrf_exempt
def
ajax_consumer_read_share
(
request
):
label_code
=
request
.
GET
.
get
(
'label_code'
,
''
)
company_id
=
request
.
GET
.
get
(
'company_id'
,
''
)
consumer_id
=
request
.
GET
.
get
(
'consumer_id'
,
''
)
if
not
label_code
or
not
company_id
or
not
consumer_id
:
return
JsonResponse
({
'e'
:
'数据丢失'
})
data
=
{
'e'
:
''
}
if
label_code
and
company_id
and
consumer_id
:
cur
=
connection
.
cursor
()
# 查询需要助力的用户信息、活动信息
cur
.
execute
(
f
"""
select
consumer_id,
activity_id,
(select wx_openid from sales_consumeraccount where id = consumer_id),
(select name from sales_activity where id = activity_id)
from
sales_consumerwinner
where
label_code = '{label_code}' and
company_id = {company_id}
order by id
limit 1
"""
)
rs
=
cur
.
fetchall
()
if
rs
:
r
=
rs
[
0
]
consumer_helped_id
=
r
[
0
]
activity_id
=
r
[
1
]
openid
=
r
[
2
]
activity_name
=
r
[
3
]
# 查询已助力次数
cur
.
execute
(
"select count(*) from sales_consumerhelp where label_code = '"
+
label_code
+
"'"
)
help_num
=
cur
.
fetchone
()[
0
]
# 寻找这次助力的奖品
activity_award
=
None
awards
=
ActivityAwards
.
objects
.
filter
(
activity_id
=
activity_id
,
help_num
=
(
help_num
+
1
))
if
awards
:
activity_award
=
awards
[
0
]
add_flag
=
False
if
activity_award
:
award
=
activity_award
.
award
if
award
.
awardcat_id
==
4
:
money
=
int
(
award
.
amount
*
100
)
err
=
send_hb
(
openid
,
money
,
int
(
company_id
))
if
err
[
'return_code'
]
==
'SUCCESS'
and
err
[
'result_code'
]
==
'SUCCESS'
:
w
=
ConsumerWinner
(
company_id
=
int
(
company_id
),
consumer_id
=
consumer_helped_id
,
label_code
=
label_code
,
activity_id
=
activity_id
,
activity_name
=
activity_name
,
award_id
=
activity_award
.
id
,
award_name
=
award
.
name
,
award_amount
=
award
.
amount
,
original_award
=
award
,
award_cat
=
'微信红包'
,
tm_redeemed
=
now
()
)
w
.
save
()
add_flag
=
True
else
:
add_flag
=
True
if
add_flag
:
ch
=
ConsumerHelp
()
ch
.
company_id
=
int
(
company_id
)
ch
.
activity_id
=
activity_id
ch
.
award
=
activity_award
if
activity_award
:
ch
.
award_name
=
activity_award
.
name
ch
.
consumer_id
=
int
(
consumer_id
)
ch
.
label_code
=
label_code
ch
.
save
()
return
JsonResponse
(
data
)
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论