Commit b7c5bb73 by 朱继来

新用户推送到CRM

parent b2060a0b
......@@ -273,10 +273,14 @@ class CronController extends Controller
if (empty($user)) return '未获取到新用户';
$user_send_msg = []; // 需要发送短信的用户ID集合
$crm_params = []; // 推送到crm用户集合
foreach ($user as $v) {
foreach ($user as $k=>$v) {
if ($v['is_new'] == 0) { // 未下单用户
$user_send_msg[] = $v['user_id'];
$crm_params[$k]['user_id'] = $v['user_id'];
$crm_params[$k]['is_create_order'] = 0;
continue;
}
......@@ -284,6 +288,9 @@ class CronController extends Controller
$count = $OrderModel->where('user_id', $v['user_id'])->where('status', '>', 2)->count();
if (!$count) $user_send_msg[] = $v['user_id']; // 不存在,则表示没有已付款的订单
$crm_params[$k]['user_id'] = $v['user_id'];
$crm_params[$k]['is_create_order'] = 1; // 标记已下单
}
if (empty($user_send_msg)) return '没有需要推送活动短信的用户';
......@@ -312,6 +319,17 @@ class CronController extends Controller
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(10001, '新用户推送到crm失败 '.$res['err_msg']); // 推送crm失败记录
}
}
}
\ No newline at end of file
......@@ -80,4 +80,7 @@ return [
// 订单微服务
'order_api_domain' => 'http://orderapi.liexin.com',
// crm
'crm_domain' => 'http://lcrm.liexin.net',
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment