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
4f73eb15
authored
Oct 23, 2019
by
朱继来
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' of
http://119.23.72.7/zhujilai/Order
into zjl_perm_20191022
parents
e3dabe64
b3206861
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
12 deletions
app/Http/Controllers/CronController.php
config/website.php
app/Http/Controllers/CronController.php
View file @
4f73eb15
...
@@ -266,52 +266,83 @@ class CronController extends Controller
...
@@ -266,52 +266,83 @@ class CronController extends Controller
$user
=
$UserMainModel
->
where
(
'is_type'
,
0
)
$user
=
$UserMainModel
->
where
(
'is_type'
,
0
)
->
where
(
'is_test'
,
0
)
->
where
(
'is_test'
,
0
)
->
whereBetween
(
'create_time'
,
[
$start_time
,
$last_time
])
->
whereBetween
(
'create_time'
,
[
$start_time
,
$last_time
])
->
select
(
'user_id'
,
'is_new'
)
->
select
(
'user_id'
,
'is_new'
,
'create_time'
)
->
get
()
->
get
()
->
toArray
();
->
toArray
();
if
(
empty
(
$user
))
return
'未获取到新用户'
;
if
(
empty
(
$user
))
return
'未获取到新用户'
;
$user_send_msg
=
[];
// 需要发送短信的用户ID集合
$user_send_msg
=
[];
// 需要发送短信的用户ID集合
$crm_params
=
[];
// 推送到crm用户集合
foreach
(
$user
as
$v
)
{
foreach
(
$user
as
$
k
=>
$
v
)
{
if
(
$v
[
'is_new'
]
==
0
)
{
// 未下单用户
if
(
$v
[
'is_new'
]
==
0
)
{
// 未下单用户
$user_send_msg
[]
=
$v
[
'user_id'
];
$user_send_msg
[
$k
][
'user_id'
]
=
$v
[
'user_id'
];
$user_send_msg
[
$k
][
'create_time'
]
=
$v
[
'create_time'
];
$crm_params
[
$k
][
'user_id'
]
=
$v
[
'user_id'
];
$crm_params
[
$k
][
'is_create_order'
]
=
0
;
continue
;
continue
;
}
}
// 已下单用户,判断订单是否有支付
// 已下单用户,判断订单是否有支付
$count
=
$OrderModel
->
where
(
'user_id'
,
$v
[
'user_id'
])
->
where
(
'status'
,
'>'
,
2
)
->
count
();
$count
=
$OrderModel
->
where
(
'user_id'
,
$v
[
'user_id'
])
->
where
(
'status'
,
'>'
,
2
)
->
count
();
if
(
!
$count
)
$user_send_msg
[]
=
$v
[
'user_id'
];
// 不存在,则表示没有已付款的订单
if
(
!
$count
)
{
// 不存在,则表示没有已付款的订单
$user_send_msg
[
$k
][
'user_id'
]
=
$v
[
'user_id'
];
$user_send_msg
[
$k
][
'create_time'
]
=
$v
[
'create_time'
];
}
$crm_params
[
$k
][
'user_id'
]
=
$v
[
'user_id'
];
$crm_params
[
$k
][
'is_create_order'
]
=
1
;
// 标记已下单
}
}
if
(
empty
(
$user_send_msg
))
return
'没有需要推送活动短信的用户'
;
if
(
empty
(
$user_send_msg
))
return
'没有需要推送活动短信的用户'
;
//调用消息接口
//调用消息接口
$url
=
Config
(
'website.api_domain'
)
.
'msg/sendmessagebyauto'
;
$url
=
Config
(
'website.api_domain'
)
.
'msg/sendmessagebyauto'
;
$keyword
=
'new_user_activity_msg'
;
$data
[
'k1'
]
=
time
();
$data
[
'k1'
]
=
time
();
$data
[
'k2'
]
=
md5
(
md5
(
$data
[
'k1'
])
.
'fh6y5t4rr351d2c3bryi'
);
$data
[
'k2'
]
=
md5
(
md5
(
$data
[
'k1'
])
.
'fh6y5t4rr351d2c3bryi'
);
foreach
(
$user_send_msg
as
$uid
)
{
foreach
(
$user_send_msg
as
$msg
)
{
// 判断用户注册时间
$time
=
time
()
-
$msg
[
'create_time'
];
$reg_day
=
intval
(
ceil
(
$time
/
86400
));
switch
(
$reg_day
)
{
case
1
:
$keyword
=
'new_user_activity_msg_1'
;
break
;
case
3
:
$keyword
=
'new_user_activity_msg_3'
;
break
;
case
7
:
$keyword
=
'new_user_activity_msg_7'
;
break
;
case
15
:
$keyword
=
'new_user_activity_msg_15'
;
break
;
default
:
$keyword
=
''
;
break
;
}
if
(
!
$keyword
)
continue
;
$userData
=
[
$userData
=
[
"keyword"
=>
$keyword
,
"keyword"
=>
$keyword
,
"pf"
=>
1
,
"pf"
=>
1
,
"k1"
=>
$data
[
'k1'
],
"k1"
=>
$data
[
'k1'
],
"k2"
=>
$data
[
'k2'
],
"k2"
=>
$data
[
'k2'
],
'touser'
=>
json_encode
(
$
uid
),
'touser'
=>
json_encode
(
$
msg
[
'user_id'
]
),
];
];
$temp
=
json_decode
(
curlApi
(
$url
,
$userData
,
"POST"
),
true
);
$temp
=
json_decode
(
curlApi
(
$url
,
$userData
,
"POST"
),
true
);
if
(
$temp
[
'err_code'
]
==
0
)
{
if
(
empty
(
$temp
)
||
$temp
[
'err_code'
]
!=
0
)
errorLog
(
10001
,
'消息推送失败记录,用户ID:'
.
$uid
);
continue
;
}
else
{
continue
;
errorLog
(
$temp
[
'err_code'
],
$temp
[
'err_msg'
]
.
',用户ID:'
.
$uid
);
// 消息推送失败记录
}
}
}
// 推送到crm
$crm_url
=
Config
(
'website.crm_domain'
)
.
'/api/notifyNewUser'
;
$crm_header
=
array
(
'api-key: crm a1b2c3d4e5f6g7h8i9jk'
);
$res
=
json_decode
(
curlApi
(
$crm_url
,
$crm_params
,
"POST"
,
false
,
$crm_header
),
true
);
if
(
!
$res
||
$res
[
'err_code'
]
!=
0
)
errorLog
(
10002
,
'新用户推送到crm失败 '
.
$res
[
'err_msg'
]);
}
}
}
}
\ No newline at end of file
config/website.php
View file @
4f73eb15
...
@@ -80,4 +80,7 @@ return [
...
@@ -80,4 +80,7 @@ return [
// 订单微服务
// 订单微服务
'order_api_domain'
=>
'http://orderapi.liexin.com'
,
'order_api_domain'
=>
'http://orderapi.liexin.com'
,
// crm
'crm_domain'
=>
'http://lcrm.liexin.net'
,
];
];
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