|
...
|
...
|
@@ -53,7 +53,7 @@ class ProjectAssociationController extends BaseController |
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取aicc用户列表 并返回绑定的数据
|
|
|
|
* @return array|void
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function check()
|
|
|
|
{
|
|
...
|
...
|
@@ -65,55 +65,23 @@ class ProjectAssociationController extends BaseController |
|
|
|
$status = (int)$status ? ProjectAssociation::STATUS_NORMAL : ProjectAssociation::STATUS_DISABLED;
|
|
|
|
}
|
|
|
|
$isRes = $this->ProjectAssociationLogic->normal($project_id);
|
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
// 当数据不存在时并开启状态,自动添加一条数据
|
|
|
|
if (is_null($isRes) && (!is_null($status) && $status)) {
|
|
|
|
$isRes = $this->ProjectAssociationLogic->disabled($project_id);
|
|
|
|
if (is_null($isRes)) {
|
|
|
|
$isRes = new ProjectAssociation();
|
|
|
|
}
|
|
|
|
$isRes->project_id = $project_id;
|
|
|
|
$isRes->user_id = (int)env('AICC_WECHAT_USER_ID');
|
|
|
|
$isRes->status = $status;
|
|
|
|
$isRes->save();
|
|
|
|
DB::commit();
|
|
|
|
} // 关闭状态
|
|
|
|
elseif (!is_null($isRes) && (!is_null($status) && empty($status))) {
|
|
|
|
$isRes->status = $status;
|
|
|
|
$isRes->save();
|
|
|
|
DB::commit();
|
|
|
|
return [
|
|
|
|
'code' => Code::SUCCESS,
|
|
|
|
'data' => [],
|
|
|
|
'message' => '关闭AICC绑定成功!',
|
|
|
|
];
|
|
|
|
// 当数据不存在时并开启状态,自动添加一条数据
|
|
|
|
if (is_null($isRes) && (!is_null($status) && $status)) {
|
|
|
|
$bool = $this->ProjectAssociationLogic->saveProject($project_id, $status);
|
|
|
|
if (empty($bool)) {
|
|
|
|
// 保存数据失败
|
|
|
|
$this->response('error', Code::SERVER_ERROR);
|
|
|
|
}
|
|
|
|
} catch (\Exception $exception) {
|
|
|
|
DB::rollBack();
|
|
|
|
// 数据错误,请重试
|
|
|
|
$this->response('error', Code::SERVER_ERROR);
|
|
|
|
}
|
|
|
|
if (is_null($isRes)) {
|
|
|
|
} // 关闭状态
|
|
|
|
elseif (!is_null($isRes) && (!is_null($status) && empty($status))) {
|
|
|
|
$res = $this->ProjectAssociationLogic->closedState($isRes, $status);
|
|
|
|
$this->response($res['message'], $res['code']);
|
|
|
|
} elseif (is_null($isRes)) {
|
|
|
|
// 请开启AICC绑定
|
|
|
|
$this->response('success', Code::SERVER_ERROR);
|
|
|
|
}
|
|
|
|
$redis_key = 'aicc_friend_lists_' . (int)env('AICC_WECHAT_USER_ID');
|
|
|
|
$result = isset($cache) ? false : redis_get($redis_key);
|
|
|
|
if (empty($result)) {
|
|
|
|
$url = env('AICC_URL') . env('AICC_WECHAT_FRIEND_API_URL');
|
|
|
|
$result = curlGet($url);
|
|
|
|
redis_set($redis_key, json_encode($result), 60);
|
|
|
|
} else {
|
|
|
|
$result = json_decode($result, true);
|
|
|
|
$this->response('error', Code::SERVER_ERROR);
|
|
|
|
}
|
|
|
|
|
|
|
|
$result['info'] = [
|
|
|
|
'friend_id' => $isRes->friend_id ?? 0,
|
|
|
|
'nickname' => $isRes->nickname ?? '',
|
|
|
|
'user_name' => $isRes->user_name ?? '',
|
|
|
|
'image' => $isRes->image ?? '',
|
|
|
|
];
|
|
|
|
$cache = isset($cache);
|
|
|
|
$result = $this->ProjectAssociationLogic->getAiccWechatLists($isRes, $cache);
|
|
|
|
$this->response('success', Code::SUCCESS, $result);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|