Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
朱继来
/
后台订单管理
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9c8d5843
authored
Sep 12, 2019
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
推送新用户活动短信<定时脚本>
parent
3d6e924e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
0 deletions
app/Http/Controllers/CronController.php
app/Http/routes.php
app/Http/Controllers/CronController.php
View file @
9c8d5843
...
...
@@ -247,4 +247,71 @@ class CronController extends Controller
$RedisModel
->
set
(
'api_lx_activity_user_rank'
,
null
);
}
/**
* 推送新用户活动短信
*
* 条件:前一天注册,未下单的用户或下单未支付一笔订单的用户
*
* 推送时间:每天上午10点 (0 10 * * * /usr/bin/curl http://order.ichunt.net/act/useramoumt)
*/
public
function
sendActMsg
()
{
$start_time
=
strtotime
(
date
(
'Y-m-d'
,
strtotime
(
'-1 day'
)));
// 前一天0点
$last_time
=
strtotime
(
date
(
'Y-m-d'
))
-
1
;
// 前一天23:59:59
$UserMainModel
=
new
UserMainModel
;
$OrderModel
=
new
OrderModel
;
// 获取前一天新注册用户
$user
=
$UserMainModel
->
where
(
'is_type'
,
0
)
->
where
(
'is_test'
,
0
)
->
whereBetween
(
'create_time'
,
[
$start_time
,
$last_time
])
->
select
(
'user_id'
,
'is_new'
)
->
get
()
->
toArray
();
if
(
empty
(
$user
))
return
'未获取到新用户'
;
$user_send_msg
=
[];
// 需要发送短信的用户ID集合
foreach
(
$user
as
$v
)
{
if
(
$v
[
'is_new'
]
==
0
)
{
// 未下单用户
$user_send_msg
[]
=
$v
[
'user_id'
];
continue
;
}
// 已下单用户,判断订单是否有支付
$count
=
$OrderModel
->
where
(
'user_id'
,
$v
[
'user_id'
])
->
where
(
'status'
,
'>'
,
2
)
->
count
();
if
(
!
$count
)
$user_send_msg
[]
=
$v
[
'user_id'
];
// 不存在,则表示没有已付款的订单
}
if
(
empty
(
$user_send_msg
))
return
'没有需要推送活动短信的用户'
;
//调用消息接口
$url
=
Config
(
'website.api_domain'
)
.
'msg/sendmessagebyauto'
;
$keyword
=
'new_user_activity_msg'
;
$data
[
'k1'
]
=
time
();
$data
[
'k2'
]
=
md5
(
md5
(
$data
[
'k1'
])
.
'fh6y5t4rr351d2c3bryi'
);
foreach
(
$user_send_msg
as
$uid
)
{
$userData
=
[
"keyword"
=>
$keyword
,
"pf"
=>
1
,
"k1"
=>
$data
[
'k1'
],
"k2"
=>
$data
[
'k2'
],
'touser'
=>
json_encode
(
$uid
),
];
$temp
=
json_decode
(
curlApi
(
$url
,
$userData
,
"POST"
),
true
);
if
(
$temp
[
'err_code'
]
==
0
)
{
continue
;
}
else
{
errorLog
(
$temp
[
'err_code'
],
$temp
[
'err_msg'
]
.
',用户ID:'
.
$uid
);
// 消息推送失败记录
}
}
}
}
\ No newline at end of file
app/Http/routes.php
View file @
9c8d5843
...
...
@@ -149,5 +149,6 @@ Route::group(['middleware' => 'api'], function () {
Route
::
get
(
'/act/useramount'
,
'CronController@userAmount'
);
// 活动统计用户实付金额
Route
::
get
(
'/act/clear'
,
'CronController@clearData'
);
// 清除活动统计用户表和缓存
Route
::
get
(
'/handle/paylog'
,
'SpecialController@handlePayLog'
);
// 处理支付记录
Route
::
get
(
'/act/sendactmsg'
,
'CronController@sendActMsg'
);
// 推送活动短信
});
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