Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
channels
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
backend
channels
Commits
4632b860
Commit
4632b860
authored
Aug 12, 2019
by
gaoming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
activate
parent
0283df2f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
2 deletions
+74
-2
0005_auto_20190812_1122.py
like/migrations/0005_auto_20190812_1122.py
+23
-0
0006_auto_20190812_1125.py
like/migrations/0006_auto_20190812_1125.py
+17
-0
0007_auto_20190812_1128.py
like/migrations/0007_auto_20190812_1128.py
+23
-0
models.py
like/models.py
+2
-1
views.py
like/views.py
+9
-1
No files found.
like/migrations/0005_auto_20190812_1122.py
0 → 100644
View file @
4632b860
# Generated by Django 2.2.1 on 2019-08-12 11:22
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'like'
,
'0004_promotioninfo_app'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'promotionchannel'
,
name
=
'idfa'
,
field
=
models
.
CharField
(
max_length
=
64
,
unique
=
True
,
verbose_name
=
'idfa'
),
),
migrations
.
AlterField
(
model_name
=
'promotionchannel'
,
name
=
'imei'
,
field
=
models
.
CharField
(
max_length
=
64
,
unique
=
True
,
verbose_name
=
'imei'
),
),
]
like/migrations/0006_auto_20190812_1125.py
0 → 100644
View file @
4632b860
# Generated by Django 2.2.1 on 2019-08-12 11:25
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'like'
,
'0005_auto_20190812_1122'
),
]
operations
=
[
migrations
.
AlterUniqueTogether
(
name
=
'promotionchannel'
,
unique_together
=
{(
'device_id'
,
'idfa'
,
'idfv'
,
'imei'
)},
),
]
like/migrations/0007_auto_20190812_1128.py
0 → 100644
View file @
4632b860
# Generated by Django 2.2.1 on 2019-08-12 11:28
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'like'
,
'0006_auto_20190812_1125'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'promotionchannel'
,
name
=
'idfa'
,
field
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
'idfa'
),
),
migrations
.
AlterField
(
model_name
=
'promotionchannel'
,
name
=
'imei'
,
field
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
'imei'
),
),
]
like/models.py
View file @
4632b860
...
@@ -46,7 +46,7 @@ class PromotionChannel(models.Model):
...
@@ -46,7 +46,7 @@ class PromotionChannel(models.Model):
app_name
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
u'app名字'
,
default
=
APP_TYPE
.
GENGMEI
.
value
[
0
])
app_name
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
u'app名字'
,
default
=
APP_TYPE
.
GENGMEI
.
value
[
0
])
appid
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
u'渠道id'
)
appid
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
u'渠道id'
)
device_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
u'设备id'
)
device_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
u'设备id'
)
idfa
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
u'idfa'
)
idfa
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
u'idfa'
)
idfv
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
u'idfv'
)
idfv
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
u'idfv'
)
udid
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
u'udid'
)
udid
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
u'udid'
)
uuid
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
u'uuid'
)
uuid
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
u'uuid'
)
...
@@ -124,6 +124,7 @@ class PromotionChannel(models.Model):
...
@@ -124,6 +124,7 @@ class PromotionChannel(models.Model):
if
request
:
if
request
:
params
.
update
({
"request"
:
json
.
dumps
(
request
.
GET
.
dict
())})
params
.
update
({
"request"
:
json
.
dumps
(
request
.
GET
.
dict
())})
#appid加前缀和子渠道
#appid加前缀和子渠道
appid
=
params
.
get
(
"appid"
)
appid
=
params
.
get
(
"appid"
)
appid
=
'{0}{1}'
.
format
(
appid
,
"_{0}"
.
format
(
sub_name
)
if
sub_name
else
""
)
appid
=
'{0}{1}'
.
format
(
appid
,
"_{0}"
.
format
(
sub_name
)
if
sub_name
else
""
)
...
...
like/views.py
View file @
4632b860
...
@@ -102,7 +102,8 @@ class Statistic(View):
...
@@ -102,7 +102,8 @@ class Statistic(View):
#获取查询子串并对每一个关联字段做一次md5加密查询
#获取查询子串并对每一个关联字段做一次md5加密查询
sub_query
=
[
item
for
key
,
value
in
kwargs
.
items
()
if
key
in
[
"device_id"
,
"idfa"
,
"idfv"
,
"imei"
,
"mac"
]
for
item
in
(
"{0}='{1}'"
.
format
(
key
,
value
),
"{0}='{1}'"
.
format
(
key
,
md5
(
value
)))]
sub_query
=
[
item
for
key
,
value
in
kwargs
.
items
()
if
key
in
[
"device_id"
,
"idfa"
,
"idfv"
,
"imei"
,
"mac"
]
for
item
in
(
"{0}='{1}'"
.
format
(
key
,
value
),
"{0}='{1}'"
.
format
(
key
,
md5
(
value
)))]
sql
=
"select * from like_promotion_channel where {0}"
.
format
(
" or "
.
join
(
sub_query
))
#顺序查找取第一个,如果已经激活,将不再激活
sql
=
"select * from like_promotion_channel where {0} order by id desc"
.
format
(
" or "
.
join
(
sub_query
))
channel_logger
.
info
(
sql
)
channel_logger
.
info
(
sql
)
record
=
PromotionChannel
.
objects
.
raw
(
sql
)
record
=
PromotionChannel
.
objects
.
raw
(
sql
)
...
@@ -125,6 +126,13 @@ class Statistic(View):
...
@@ -125,6 +126,13 @@ class Statistic(View):
return
return
if
record
:
if
record
:
#如果曾经激活过,将不再激活
for
item
in
record
:
if
item
.
active_time
:
print
(
"has activate---"
)
channel_logger
.
info
(
"已激活,不能再激活---"
)
return
record
=
record
[
0
]
record
=
record
[
0
]
channel_logger
.
info
(
"存在待激活记录---"
)
channel_logger
.
info
(
"存在待激活记录---"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment