Compare commits

...

46 Commits
zm ... master

Author SHA1 Message Date
张萌 c158015019 Merge pull request '待进入公海提醒' (#47) from zm into master
2 years ago
张萌 ed5cf68658 Merge pull request '公海回收bug fix' (#46) from zm into master
2 years ago
张萌 311f024b5a Merge pull request '公海自动回收规则调整' (#45) from zm into master
2 years ago
杨赟 b8650a1044 Merge pull request '修复' (#44) from yy-4.20 into master
2 years ago
杨赟 8b2d951a88 修复
2 years ago
杨赟 216fd7dbf0 Merge pull request '修复' (#43) from yy-4.20 into master
2 years ago
杨赟 c61dd5910e 修复
2 years ago
杨赟 6ebd628712 修复
2 years ago
杨赟 f76905042a Merge pull request '修复' (#42) from yy-4.20 into master
2 years ago
杨赟 15f8edc15f 修复
2 years ago
杨赟 ae8094a955 Merge pull request '修复' (#41) from yy-4.20 into master
2 years ago
杨赟 7d9ff20d3d 修复
2 years ago
杨赟 b7cf5e96ff Merge pull request '添加客户端' (#40) from yy-4.20 into master
2 years ago
杨赟 ef0d5ea764 添加客户端
2 years ago
张萌 7e63f7b86b Merge pull request '客户领取问题修复' (#39) from zm into master
2 years ago
张萌 1ef6ac4960 Merge pull request '列表展示字段' (#38) from zm into master
2 years ago
张萌 9b4ded5d2b Merge pull request 'zm' (#37) from zm into master
2 years ago
张萌 ebd8a5e366 Merge pull request 'bug fix' (#35) from zm into master
2 years ago
张萌 9a69d54646 Merge pull request '公海客户类型配置调整' (#34) from zm into master
2 years ago
张萌 fa411cad4d Merge pull request '客户类型公海设置' (#33) from zm into master
2 years ago
张萌 b58bbbef4b Merge pull request 'bug fix' (#32) from zm into master
2 years ago
张萌 59eb058bc1 Merge pull request 'bug fix' (#31) from zm into master
2 years ago
张萌 c57233837d Merge pull request '销售漏斗' (#30) from zm into master
2 years ago
张萌 92aabd8f0e Merge pull request '添加字段' (#29) from zm into master
2 years ago
张萌 1495e9f39f Merge pull request 'zm' (#28) from zm into master
2 years ago
张萌 f2f72b2fd5 Merge pull request '拒绝后再次审批' (#27) from zm into master
2 years ago
张萌 f4b3d06283 Merge pull request 'zm' (#26) from zm into master
2 years ago
张萌 3a9b3fbb61 Merge pull request 'bug fix' (#25) from zm into master
2 years ago
张萌 aaf895df3f Merge pull request '添加返回字段' (#24) from zm into master
2 years ago
张萌 9c41c94b33 Merge pull request 'bug fix' (#23) from zm into master
2 years ago
张萌 4cc8915334 Merge pull request 'bug fix' (#22) from zm into master
2 years ago
张萌 6e9afbeed9 Merge pull request 'flow_id 解决' (#21) from zm into master
2 years ago
张萌 9e9fc2f798 Merge pull request '客户详情' (#20) from zm into master
2 years ago
张萌 b90464e037 Merge pull request 'zm' (#19) from zm into master
2 years ago
张萌 be8ef58780 Merge pull request '返回数据修改' (#17) from zm into master
2 years ago
张萌 07926c46c3 Merge pull request '字段更改' (#16) from zm into master
2 years ago
张萌 fa8ecd6c4a Merge pull request 'bug fix' (#15) from zm into master
2 years ago
张萌 587783aba8 Merge pull request 'bug fix' (#14) from zm into master
2 years ago
张萌 d5684b44fd Merge pull request 'bug fix' (#13) from zm into master
2 years ago
张萌 efc8c29ed9 Merge pull request '待审批公海池客户捞取 返回数据' (#12) from zm into master
2 years ago
张萌 c799780ea0 Merge pull request '客户捞取待办事项' (#11) from zm into master
2 years ago
张萌 58166864d4 Merge pull request 'zm' (#10) from zm into master
2 years ago
张萌 c49d7e4548 Merge pull request 'bug fix' (#9) from zm into master
2 years ago
张萌 724309eae8 Merge pull request '待办事项添加记录添加' (#8) from zm into master
2 years ago
张萌 d9698c68b2 Merge pull request 'bug fix' (#7) from zm into master
2 years ago
张萌 4c2938446f Merge pull request '待办事项' (#6) from zm into master
2 years ago

@ -12,6 +12,7 @@ use think\Request;
use think\Db; use think\Db;
use app\common\adapter\AuthAdapter; use app\common\adapter\AuthAdapter;
use app\common\controller\Common; use app\common\controller\Common;
use think\Session;
class ApiCommon extends Common class ApiCommon extends Common
@ -25,6 +26,9 @@ class ApiCommon extends Common
$authKey = trim($header['authkey']); $authKey = trim($header['authkey']);
$sessionId = trim($header['sessionid']); $sessionId = trim($header['sessionid']);
if ($authKey == "wxwork" && Session::get('user_id')) {
return;
}
$paramArr = $request->param(); $paramArr = $request->param();
$platform = $paramArr['platform'] ? '_'.$paramArr['platform'] : ''; //请求平台(mobile,ding) $platform = $paramArr['platform'] ? '_'.$paramArr['platform'] : ''; //请求平台(mobile,ding)
$cache = Cache::get('Auth_'.$authKey.$platform); $cache = Cache::get('Auth_'.$authKey.$platform);

@ -13,6 +13,7 @@ use app\admin\model\Common;
use com\verify\HonrayVerify; use com\verify\HonrayVerify;
use think\Cache; use think\Cache;
use think\Request; use think\Request;
use think\Session;
class User extends Common class User extends Common
{ {
@ -647,8 +648,15 @@ class User extends Common
$data['loginExpire'] = $loginExpire; $data['loginExpire'] = $loginExpire;
//保存authKey信息 //保存authKey信息
$userData = []; $userData = [];
$userData['authkey'] = $authKey;
$userData['authkey_time'] = time() + $loginExpire; $wxuser_id = Session::get('wxuser_id');
if ($wxuser_id) {
$data['authKey'] = 'wxwork';
$userData['wxwork_id'] = $wxuser_id;
} else {
$userData['authkey'] = $authKey;
$userData['authkey_time'] = time() + $loginExpire;
}
//把状态未激活至为启用 //把状态未激活至为启用
if ($userInfo['status'] == 2) { if ($userInfo['status'] == 2) {
$userData['status'] = 1; $userData['status'] = 1;

@ -9,6 +9,7 @@ namespace app\common\behavior;
use think\Cache; use think\Cache;
use think\Request; use think\Request;
use think\Db; use think\Db;
use think\Session;
class AuthenticateBehavior class AuthenticateBehavior
{ {
@ -32,6 +33,9 @@ class AuthenticateBehavior
/*获取头部信息*/ /*获取头部信息*/
$header = $request->header(); $header = $request->header();
$authKey = trim($header['authkey']); $authKey = trim($header['authkey']);
if ($authKey == "wxwork" && Session::get('user_id')) {
return true;
}
$paramArr = $request->param(); $paramArr = $request->param();
$platform = $paramArr['platform'] ? '_'.$paramArr['platform'] : ''; //请求分类(mobile,ding) $platform = $paramArr['platform'] ? '_'.$paramArr['platform'] : ''; //请求分类(mobile,ding)

@ -13,6 +13,9 @@ class Api {
protected static $getAccessToken = 'gettoken'; protected static $getAccessToken = 'gettoken';
protected static $contactInfo = 'externalcontact/get'; protected static $contactInfo = 'externalcontact/get';
protected static $getUserInfo = 'auth/getuserinfo';
protected static $userGet = 'user/get';
protected $corpId = ''; protected $corpId = '';
protected $corpSecret = ''; protected $corpSecret = '';
@ -37,6 +40,30 @@ class Api {
]); ]);
} }
/**
* 获取用户身份
* @param $code
* @return mixed
*/
function getUserInfo($code) {
return $this->get(self::$getUserInfo, [
'access_token' => $this->getAccessToken(),
'code' => $code
]);
}
/**
* 获取用户信息
* @param $code
* @return mixed
*/
function userGet($userid) {
return $this->get(self::$userGet, [
'access_token' => $this->getAccessToken(),
'userid' => $userid
]);
}
/** /**
* 获取accessToken * 获取accessToken
* @return false|mixed * @return false|mixed

@ -9,9 +9,11 @@ namespace app\crm\controller;
use app\common\wework\api\Api; use app\common\wework\api\Api;
use app\common\wework\callback\WXBizMsgCrypt; use app\common\wework\callback\WXBizMsgCrypt;
use think\Cache;
use think\Controller; use think\Controller;
use think\Log; use think\Log;
use think\Request; use think\Request;
use think\Session;
class Callback extends Controller class Callback extends Controller
{ {
@ -33,15 +35,43 @@ class Callback extends Controller
switch ($simpleXMLElement->Event->__toString()) { switch ($simpleXMLElement->Event->__toString()) {
case 'change_external_contact': case 'change_external_contact':
$api = new Api(config('wework.corpId'), config('wework.corpSecret')); $api = new Api(config('wework.corpId'), config('wework.corpSecret'));
$contactInfo = $api->contactInfo('wm9nLQEAAA6lshIXRN5xdd1iZjqevSyA'); $contactInfo = $api->contactInfo($simpleXMLElement->ExternalUserID->__toString());
foreach ($contactInfo['follow_user'] as $contactUserInfo) { foreach ($contactInfo['follow_user'] as $contactUserInfo) {
if ($contactUserInfo['userid'] == $simpleXMLElement->UserID->__toString()) { if ($contactUserInfo['userid'] == $simpleXMLElement->UserID->__toString()) {
$customerInfo = model('Customer')->where('name', $contactUserInfo['remark_corp_name'])->find(); $customerInfo = model('Customer')->where('name', $contactUserInfo['remark_corp_name'])->find();
if ($customerInfo) { if ($customerInfo) {
$wxwork = db('admin_wxwork')->where("user_id", $contactUserInfo['userid'])->find();
if (!$wxwork) {
$userGet = $api->userGet($contactUserInfo['userid']);
$wxwork = [
'user_id' => $userGet['userid'],
'name' => $userGet['name'],
'create_time' => time(),
'update_time' => time(),
];
db('admin_wxwork')->insert($wxwork);
$wxwork = db('admin_wxwork')->where("user_id", $contactUserInfo['userid'])->find();
if (!$wxwork) {
Log::record('联系人添加失败');
return;
}
}
if ($wxwork['update_time']+86400*3 < time()) {
db('admin_wxwork')->where("id", $wxwork['id'])->update([
'name' => $userGet['name'],
'update_time' => time(),
]);
}
$contactsInfo = model('Contacts')->where([ $contactsInfo = model('Contacts')->where([
'name' => $contactUserInfo['remark'], 'external_userid' => $simpleXMLElement->ExternalUserID->__toString(),
'customer_id' => $customerInfo['customer_id'] 'customer_id' => $customerInfo['customer_id'],
'wxwork_id' => $wxwork['id']
])->find(); ])->find();
$mobile = '';
if ($contactUserInfo['remark_mobiles']) {
$mobile = $contactUserInfo['remark_mobiles'][0];
}
if (!$contactsInfo) { if (!$contactsInfo) {
$param = [ $param = [
'business_id' => null, 'business_id' => null,
@ -49,13 +79,22 @@ class Callback extends Controller
'owner_user_id' => 1, 'owner_user_id' => 1,
'customer_id' => $customerInfo['customer_id'], 'customer_id' => $customerInfo['customer_id'],
'name' => $contactUserInfo['remark'], 'name' => $contactUserInfo['remark'],
'mobile' => $contactUserInfo['remark_mobiles'][0], 'mobile' => $mobile,
'external_userid' => $simpleXMLElement->ExternalUserID->__toString(),
'wxwork_id' => $wxwork['id']
]; ];
if (model('Contacts')->createData($param)) { if (model('Contacts')->createData($param)) {
Log::record('联系人添加成功'); Log::record('联系人添加成功');
} else { } else {
Log::record('联系人添加失败'); Log::record('联系人添加失败');
} }
} else {
$param = [
'name' => $contactUserInfo['remark'],
'mobile' => $mobile
];
model('Contacts')->where('contacts_id', $contactsInfo['contacts_id'])->update($param);
Log::record('联系人更新成功');
} }
} }
} }
@ -83,4 +122,41 @@ class Callback extends Controller
} }
} }
} }
public function work() {
$code = Request::instance()->get('code');
$api = new Api(config('wework.corpId'), config('wework.corpSecret'));
$userInfo = $api->getUserInfo($code);
Log::record('用户信息'.json_encode($userInfo));
if (isset($userInfo['userid']) && $userInfo['userid']) {
Session::set('wxuser_id', $userInfo['userid']);
$adminUser = db('admin_user')->where('wxwork_id', $userInfo['userid'])->find();
if ($adminUser) {
Session::set('user_id', $adminUser['id']);
$info['userInfo'] = $adminUser;
$info['sessionId'] = session_id();
// $info['_AUTH_LIST_'] = $dataList['rulesList'];
$info['authKey'] = 'wxwork';
if (!Cache::get('Auth_wxwork')) {
Cache::set('Auth_wxwork', $info);
}
return redirect('http://web.lbschem.com:8088/?authkey=wxwork&sessionid='.session_id());
} elseif (Session::get('user_id')) {
db('admin_user')->where('id', Session::get('user_id'))->update([
'wxwork_id' => $userInfo['userid']
]);
$adminUser = db('admin_user')->where('id', Session::get('user_id'))->find();
$info['userInfo'] = $adminUser;
$info['sessionId'] = session_id();
// $info['_AUTH_LIST_'] = $dataList['rulesList'];
$info['authKey'] = 'wxwork';
if (!Cache::get('Auth_wxwork')) {
Cache::set('Auth_wxwork', $info);
}
return redirect('http://web.lbschem.com:8088/?authkey=wxwork&sessionid='.session_id());
}
}
return redirect('http://web.lbschem.com:8088/');
}
} }

@ -206,6 +206,11 @@ class Contacts extends Common
$list[$k]['owner_user_id_info'] = isset($v['owner_user_id']) ? $userModel->getUserById($v['owner_user_id']) : []; $list[$k]['owner_user_id_info'] = isset($v['owner_user_id']) ? $userModel->getUserById($v['owner_user_id']) : [];
$list[$k]['customer_id_info']['customer_id'] = $v['customer_id'] ?: ''; $list[$k]['customer_id_info']['customer_id'] = $v['customer_id'] ?: '';
$list[$k]['customer_id_info']['name'] = $v['customer_name'] ?: ''; $list[$k]['customer_id_info']['name'] = $v['customer_name'] ?: '';
$list[$k]['wxwork_name'] = '';
if ($list[$k]['wxwork_id']) {
$wxwork = db('admin_wxwork')->where('id', $list[$k]['wxwork_id'])->find();
$list[$k]['wxwork_name'] = $wxwork['name'];
}
foreach ($userField as $key => $val) { foreach ($userField as $key => $val) {
$usernameField = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : []; $usernameField = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
$list[$k][$val] = implode($usernameField, ','); $list[$k][$val] = implode($usernameField, ',');

@ -536,6 +536,7 @@ return [
// 企业微信回调 // 企业微信回调
'crm/callback/index' => ['crm/callback/index', ['method' => 'POST|GET']], 'crm/callback/index' => ['crm/callback/index', ['method' => 'POST|GET']],
'crm/callback/work' => ['crm/callback/work', ['method' => 'POST|GET']],
// MISS路由 // MISS路由
'__miss__' => 'admin/base/miss', '__miss__' => 'admin/base/miss',

Loading…
Cancel
Save