|
@@ -19,6 +19,7 @@ class ScrmController extends ApiBaseController
|
|
|
private $httpClient;
|
|
|
private $app_key;
|
|
|
private $app_secret;
|
|
|
+ private $registerService;
|
|
|
|
|
|
/**
|
|
|
* SmsService constructor.
|
|
@@ -26,7 +27,7 @@ class ScrmController extends ApiBaseController
|
|
|
* @param $app_secret
|
|
|
* @param $sign_key
|
|
|
*/
|
|
|
- public function __construct()
|
|
|
+ public function __construct(RegisterService $registerService)
|
|
|
{
|
|
|
$this->app_key = '817267c4c2f3476b863522525b97ac78';
|
|
|
$this->app_secret = '559f778b1b4f4e47b0265fa5fbedfb54';
|
|
@@ -34,6 +35,7 @@ class ScrmController extends ApiBaseController
|
|
|
$this->httpClient=new Client([
|
|
|
'http_errors' => false
|
|
|
]);
|
|
|
+ $this->registerService = $registerService;
|
|
|
}
|
|
|
|
|
|
public function pullData(Request $request)
|
|
@@ -56,14 +58,13 @@ class ScrmController extends ApiBaseController
|
|
|
$user = Member::where('mobile',$customer['mobile'])->first();
|
|
|
if(!$user){
|
|
|
//手机号找不到聚才网账户,进行注册并入库
|
|
|
- $registerService = new RegisterService();
|
|
|
- $user = $registerService->registerPersonScrm($customer);
|
|
|
+ $user = $this->registerService->registerPersonScrm($customer);
|
|
|
}
|
|
|
//如果手机号在聚才网已存在账户,将信息入库
|
|
|
$shuobo_exist = MemberShuobo::where('uid',$user->id)->first();
|
|
|
$shuobo_data = array_only($customer,['uid','realname','sex','mobile','email','birthday','education','school','pro','graduation_time','address','country','weixin','company','job','come_in_time','require','trade_type','speciality']);
|
|
|
if(!$shuobo_exist){
|
|
|
- $customer['uid'] = $user->id;
|
|
|
+ $shuobo_data['uid'] = $user->id;
|
|
|
MemberShuobo::create($shuobo_data);
|
|
|
}else{
|
|
|
MemberShuobo::where('uid',$user->id)->update($shuobo_data);
|
|
@@ -304,38 +305,69 @@ class ScrmController extends ApiBaseController
|
|
|
return $res['data'];
|
|
|
}
|
|
|
|
|
|
+ public function get_customer_events(int $cid,$start,$end,$page,$pageSize){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public function test()
|
|
|
{
|
|
|
+ /*===========客户旅程==============*/
|
|
|
+ $params = [
|
|
|
+ 'cid' => 42832294,
|
|
|
+ 'startTime' => str_pad(strtotime('2021-11-01'),13,'0',STR_PAD_RIGHT),
|
|
|
+ 'endTime' => str_pad(strtotime('2021-11-30'),13,'0',STR_PAD_RIGHT),
|
|
|
+ 'page'=>2,
|
|
|
+ 'pageSize'=>50
|
|
|
+ ];
|
|
|
+ $params = json_encode($params);
|
|
|
+ $appSecret = substr(openssl_digest(openssl_digest($this->app_secret, 'sha1', true), 'sha1', true), 0, 16);
|
|
|
+ $time = time();
|
|
|
+ $sign = md5($params);
|
|
|
+ $checksum = bin2hex(openssl_encrypt($this->app_key. $sign. $time, 'AES-128-ECB', $appSecret, OPENSSL_RAW_DATA));
|
|
|
+ $headers = [
|
|
|
+ 'Content-Type' => 'application/json',
|
|
|
+ 'ur-appkey' => $this->app_key,
|
|
|
+ 'ur-sign' => $sign,
|
|
|
+ 'ur-curtime' => $time,
|
|
|
+ 'ur-checksum' => $checksum
|
|
|
+ ];
|
|
|
|
|
|
- $curl = curl_init();
|
|
|
- curl_setopt($curl, CURLOPT_URL, 'https://www.jucai.gov.cn/api/scrm/data');
|
|
|
- //设置头文件的信息作为数据流输出
|
|
|
- curl_setopt($curl, CURLOPT_HEADER, 0);
|
|
|
- //设置获取的信息以文件流的形式返回,而不是直接输出。
|
|
|
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
|
- // 超时设置
|
|
|
- curl_setopt($curl, CURLOPT_TIMEOUT, 10);
|
|
|
+ $response = $this->httpClient->post('https://huke.163.com/openapi/customer/getCustomerEvents', ['body'=>$params,'headers' => $headers]);
|
|
|
+ $res = json_decode($response->getBody()->getContents(),true);
|
|
|
|
|
|
- // 超时设置,以毫秒为单位
|
|
|
- // curl_setopt($curl, CURLOPT_TIMEOUT_MS, 500);
|
|
|
+ return $res;
|
|
|
|
|
|
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE );
|
|
|
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE );
|
|
|
+ dd($res);
|
|
|
|
|
|
- //设置post方式提交
|
|
|
- curl_setopt($curl, CURLOPT_POST, 1);
|
|
|
- $post = [
|
|
|
- 'eid' => '1000459',
|
|
|
- 'type' => '1011',
|
|
|
- 'cid' => '108720798',
|
|
|
- 'params' => [
|
|
|
- 'customerEvent' => '{"id":1687628552,"eid":1000459,"cid":110762053,"createTime":1637073249037,"eventCode":309,"eventName":"更新客户资料","fieldList":[{"value":"中国福建泉州","name":"15352636"},{"value":"1656604800000","name":"15352650"},{"value":"1656604800000","name":"15354507"}]}'
|
|
|
- ]
|
|
|
- ];
|
|
|
- curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
|
|
|
- //执行命令
|
|
|
- $data = curl_exec($curl);
|
|
|
- dd($data);
|
|
|
+// $curl = curl_init();
|
|
|
+// curl_setopt($curl, CURLOPT_URL, 'https://www.jucai.gov.cn/api/scrm/data');
|
|
|
+// //设置头文件的信息作为数据流输出
|
|
|
+// curl_setopt($curl, CURLOPT_HEADER, 0);
|
|
|
+// //设置获取的信息以文件流的形式返回,而不是直接输出。
|
|
|
+// curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
|
+// // 超时设置
|
|
|
+// curl_setopt($curl, CURLOPT_TIMEOUT, 10);
|
|
|
+//
|
|
|
+// // 超时设置,以毫秒为单位
|
|
|
+// // curl_setopt($curl, CURLOPT_TIMEOUT_MS, 500);
|
|
|
+//
|
|
|
+// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE );
|
|
|
+// curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE );
|
|
|
+//
|
|
|
+// //设置post方式提交
|
|
|
+// curl_setopt($curl, CURLOPT_POST, 1);
|
|
|
+// $post = [
|
|
|
+// 'eid' => '1000459',
|
|
|
+// 'type' => '1011',
|
|
|
+// 'cid' => '108720798',
|
|
|
+// 'params' => [
|
|
|
+// 'customerEvent' => '{"id":1687628552,"eid":1000459,"cid":110762053,"createTime":1637073249037,"eventCode":309,"eventName":"更新客户资料","fieldList":[{"value":"中国福建泉州","name":"15352636"},{"value":"1656604800000","name":"15352650"},{"value":"1656604800000","name":"15354507"}]}'
|
|
|
+// ]
|
|
|
+// ];
|
|
|
+// curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
|
|
|
+// //执行命令
|
|
|
+// $data = curl_exec($curl);
|
|
|
+// dd($data);
|
|
|
$params = [
|
|
|
'type' => 3,
|
|
|
'targets' => [
|