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
c5276e56
Commit
c5276e56
authored
Jun 10, 2019
by
gaoming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
somebug
parent
62d8d565
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
16 deletions
+37
-16
models.cpython-36.pyc
like/__pycache__/models.cpython-36.pyc
+0
-0
views.cpython-36.pyc
like/__pycache__/views.cpython-36.pyc
+0
-0
models.py
like/models.py
+22
-1
views.py
like/views.py
+15
-15
No files found.
like/__pycache__/models.cpython-36.pyc
View file @
c5276e56
No preview for this file type
like/__pycache__/views.cpython-36.pyc
View file @
c5276e56
No preview for this file type
like/models.py
View file @
c5276e56
...
@@ -24,6 +24,7 @@ class PromotionChannel(models.Model):
...
@@ -24,6 +24,7 @@ class PromotionChannel(models.Model):
db_table
=
'like_promotion_channel'
db_table
=
'like_promotion_channel'
app_label
=
'like'
app_label
=
'like'
#这里改一下吧
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'
)
...
@@ -34,7 +35,7 @@ class PromotionChannel(models.Model):
...
@@ -34,7 +35,7 @@ class PromotionChannel(models.Model):
imei
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
u'imei'
)
imei
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
u'imei'
)
#设备物理地址
#设备物理地址
mac
=
models
.
CharField
(
max_length
=
100
,
verbose_name
=
u'
iOS设备的idfv或
Android设备的mac'
,
null
=
True
,
default
=
""
)
mac
=
models
.
CharField
(
max_length
=
100
,
verbose_name
=
u'Android设备的mac'
,
null
=
True
,
default
=
""
)
platform
=
models
.
CharField
(
max_length
=
100
,
verbose_name
=
u'IOS或安卓类型'
,
default
=
PLATFORM_CHANNEL
.
UNKNOWN
.
value
[
0
])
platform
=
models
.
CharField
(
max_length
=
100
,
verbose_name
=
u'IOS或安卓类型'
,
default
=
PLATFORM_CHANNEL
.
UNKNOWN
.
value
[
0
])
model
=
models
.
CharField
(
verbose_name
=
u'Model'
,
null
=
True
,
max_length
=
40
)
#这是什么
model
=
models
.
CharField
(
verbose_name
=
u'Model'
,
null
=
True
,
max_length
=
40
)
#这是什么
...
@@ -62,6 +63,14 @@ class PromotionChannel(models.Model):
...
@@ -62,6 +63,14 @@ class PromotionChannel(models.Model):
last_activity
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
u'最后活跃时间'
)
last_activity
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
u'最后活跃时间'
)
def
save
(
self
,
data
=
None
,
*
args
,
**
kwargs
):
if
data
:
self
.
__dict__
.
update
(
data
)
super
()
.
save
(
*
args
,
**
kwargs
)
@staticmethod
@staticmethod
def
filter_exists_propertys
(
**
kwargs
):
def
filter_exists_propertys
(
**
kwargs
):
'''
'''
...
@@ -75,6 +84,17 @@ class PromotionChannel(models.Model):
...
@@ -75,6 +84,17 @@ class PromotionChannel(models.Model):
return
params
return
params
@staticmethod
def
activate
(
record
,
kwargs
):
'''
激活设备
'''
params
=
PromotionChannel
.
filter_exists_propertys
(
**
kwargs
)
record
.
active_time
=
datetime
.
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
record
.
save
(
data
=
kwargs
)
@staticmethod
@staticmethod
def
record
(
request
,
sub_name
=
None
,
**
kwargs
):
def
record
(
request
,
sub_name
=
None
,
**
kwargs
):
"""
"""
...
@@ -106,3 +126,4 @@ class PromotionChannel(models.Model):
...
@@ -106,3 +126,4 @@ class PromotionChannel(models.Model):
return
False
,
CHANNEL_STATUS
.
ADD_FAIL_GENERAL
.
value
return
False
,
CHANNEL_STATUS
.
ADD_FAIL_GENERAL
.
value
return
True
,
''
return
True
,
''
like/views.py
View file @
c5276e56
...
@@ -39,7 +39,6 @@ class Statistic(View):
...
@@ -39,7 +39,6 @@ class Statistic(View):
# 迈可思, 趣米, 广点通, 爱思助手激活回调(增加点入)
# 迈可思, 趣米, 广点通, 爱思助手激活回调(增加点入)
self
.
async_active_callback
.
delay
(
**
data
)
self
.
async_active_callback
.
delay
(
**
data
)
print
(
data
)
#self.async_active_callback(**data)
#self.async_active_callback(**data)
return
JsonResponse
({
return
JsonResponse
({
...
@@ -78,7 +77,7 @@ class Statistic(View):
...
@@ -78,7 +77,7 @@ class Statistic(View):
record
=
PromotionChannel
.
objects
.
raw
(
sql
)
record
=
PromotionChannel
.
objects
.
raw
(
sql
)
#如果不存在,谷歌推广
?
#如果不存在,谷歌推广
if
not
record
:
if
not
record
:
kwargs
.
update
({
"appid"
:
"google"
,
"active_time"
:
datetime
.
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)})
kwargs
.
update
({
"appid"
:
"google"
,
"active_time"
:
datetime
.
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)})
record
=
PromotionChannel
.
record
(
None
,
**
kwargs
)
record
=
PromotionChannel
.
record
(
None
,
**
kwargs
)
...
@@ -92,13 +91,11 @@ class Statistic(View):
...
@@ -92,13 +91,11 @@ class Statistic(View):
if
record
and
record
.
active_time
:
if
record
and
record
.
active_time
:
return
return
#激活
#激活
record
.
active_time
=
datetime
.
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
PromotionChannel
.
activate
(
record
,
kwargs
)
record
.
save
()
#无回调,不做处理
#无回调,不做处理
if
record
.
callback_type
==
CHANNEL_CALLBACK_TYPE
.
NO_CALLBACK
:
if
record
.
callback_type
==
CHANNEL_CALLBACK_TYPE
.
NO_CALLBACK
.
value
[
0
]
:
return
return
#无回调url,不做处理
#无回调url,不做处理
...
@@ -112,17 +109,23 @@ class Statistic(View):
...
@@ -112,17 +109,23 @@ class Statistic(View):
try
:
try
:
import
requests
import
requests
#GET回调
#GET回调
if
record
.
callback_type
==
CHANNEL_CALLBACK_TYPE
.
GET_CALLBACK
:
if
record
.
callback_type
==
CHANNEL_CALLBACK_TYPE
.
GET_CALLBACK
.
value
[
0
]:
response
=
requests
.
get
(
url
,
verify
=
_VERIFIED
)
print
(
url
)
response
=
requests
.
get
(
url
)
#POST回调
#POST回调
if
record
.
callback_type
==
CHANNEL_CALLBACK_TYPE
.
POST_CALLBACK
:
if
record
.
callback_type
==
CHANNEL_CALLBACK_TYPE
.
POST_CALLBACK
.
value
[
0
]:
response
=
requests
.
post
(
url
,
verify
=
_VERIFIED
)
response
=
requests
.
post
(
url
)
record
.
response
=
response
.
text
;
record
.
save
()
except
Exception
as
e
:
except
Exception
as
e
:
channel_logger
.
error
(
str
(
e
))
print
(
e
)
#channel_logger.error(str(e))
return
JsonResponse
({
'error'
:
0
,
'msg'
:
''
})
return
{
'error'
:
0
,
'msg'
:
''
}
class
DoubleCheck
(
View
):
class
DoubleCheck
(
View
):
...
@@ -167,9 +170,6 @@ class Channel(View):
...
@@ -167,9 +170,6 @@ class Channel(View):
platform
=
request
.
path
.
split
(
'/'
)[
2
]
platform
=
request
.
path
.
split
(
'/'
)[
2
]
print
(
platform
)
print
(
sub_name
)
#获得渠道数据
#获得渠道数据
try
:
try
:
data
=
Channel
.
__dict__
.
get
(
platform
)(
self
)
data
=
Channel
.
__dict__
.
get
(
platform
)(
self
)
...
...
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