|
@@ -53,7 +53,7 @@ class ProjectAssociationController extends BaseController |
|
@@ -53,7 +53,7 @@ class ProjectAssociationController extends BaseController |
|
53
|
|
53
|
|
|
54
|
/**
|
54
|
/**
|
|
55
|
* 获取aicc用户列表 并返回绑定的数据
|
55
|
* 获取aicc用户列表 并返回绑定的数据
|
|
56
|
- * @return array|void
|
56
|
+ * @return void
|
|
57
|
*/
|
57
|
*/
|
|
58
|
public function check()
|
58
|
public function check()
|
|
59
|
{
|
59
|
{
|
|
@@ -65,55 +65,23 @@ class ProjectAssociationController extends BaseController |
|
@@ -65,55 +65,23 @@ class ProjectAssociationController extends BaseController |
|
65
|
$status = (int)$status ? ProjectAssociation::STATUS_NORMAL : ProjectAssociation::STATUS_DISABLED;
|
65
|
$status = (int)$status ? ProjectAssociation::STATUS_NORMAL : ProjectAssociation::STATUS_DISABLED;
|
|
66
|
}
|
66
|
}
|
|
67
|
$isRes = $this->ProjectAssociationLogic->normal($project_id);
|
67
|
$isRes = $this->ProjectAssociationLogic->normal($project_id);
|
|
68
|
- DB::beginTransaction();
|
|
|
|
69
|
- try {
|
|
|
|
70
|
- // 当数据不存在时并开启状态,自动添加一条数据
|
|
|
|
71
|
- if (is_null($isRes) && (!is_null($status) && $status)) {
|
|
|
|
72
|
- $isRes = $this->ProjectAssociationLogic->disabled($project_id);
|
|
|
|
73
|
- if (is_null($isRes)) {
|
|
|
|
74
|
- $isRes = new ProjectAssociation();
|
|
|
|
75
|
- }
|
|
|
|
76
|
- $isRes->project_id = $project_id;
|
|
|
|
77
|
- $isRes->user_id = (int)env('AICC_WECHAT_USER_ID');
|
|
|
|
78
|
- $isRes->status = $status;
|
|
|
|
79
|
- $isRes->save();
|
|
|
|
80
|
- DB::commit();
|
|
|
|
81
|
- } // 关闭状态
|
|
|
|
82
|
- elseif (!is_null($isRes) && (!is_null($status) && empty($status))) {
|
|
|
|
83
|
- $isRes->status = $status;
|
|
|
|
84
|
- $isRes->save();
|
|
|
|
85
|
- DB::commit();
|
|
|
|
86
|
- return [
|
|
|
|
87
|
- 'code' => Code::SUCCESS,
|
|
|
|
88
|
- 'data' => [],
|
|
|
|
89
|
- 'message' => '关闭AICC绑定成功!',
|
|
|
|
90
|
- ];
|
68
|
+ // 当数据不存在时并开启状态,自动添加一条数据
|
|
|
|
69
|
+ if (is_null($isRes) && (!is_null($status) && $status)) {
|
|
|
|
70
|
+ $bool = $this->ProjectAssociationLogic->saveProject($project_id, $status);
|
|
|
|
71
|
+ if (empty($bool)) {
|
|
|
|
72
|
+ // 保存数据失败
|
|
|
|
73
|
+ $this->response('error', Code::SERVER_ERROR);
|
|
91
|
}
|
74
|
}
|
|
92
|
- } catch (\Exception $exception) {
|
|
|
|
93
|
- DB::rollBack();
|
|
|
|
94
|
- // 数据错误,请重试
|
|
|
|
95
|
- $this->response('error', Code::SERVER_ERROR);
|
|
|
|
96
|
- }
|
|
|
|
97
|
- if (is_null($isRes)) {
|
75
|
+ } // 关闭状态
|
|
|
|
76
|
+ elseif (!is_null($isRes) && (!is_null($status) && empty($status))) {
|
|
|
|
77
|
+ $res = $this->ProjectAssociationLogic->closedState($isRes, $status);
|
|
|
|
78
|
+ $this->response($res['message'], $res['code']);
|
|
|
|
79
|
+ } elseif (is_null($isRes)) {
|
|
98
|
// 请开启AICC绑定
|
80
|
// 请开启AICC绑定
|
|
99
|
- $this->response('success', Code::SERVER_ERROR);
|
|
|
|
100
|
- }
|
|
|
|
101
|
- $redis_key = 'aicc_friend_lists_' . (int)env('AICC_WECHAT_USER_ID');
|
|
|
|
102
|
- $result = isset($cache) ? false : redis_get($redis_key);
|
|
|
|
103
|
- if (empty($result)) {
|
|
|
|
104
|
- $url = env('AICC_URL') . env('AICC_WECHAT_FRIEND_API_URL');
|
|
|
|
105
|
- $result = curlGet($url);
|
|
|
|
106
|
- redis_set($redis_key, json_encode($result), 60);
|
|
|
|
107
|
- } else {
|
|
|
|
108
|
- $result = json_decode($result, true);
|
81
|
+ $this->response('error', Code::SERVER_ERROR);
|
|
109
|
}
|
82
|
}
|
|
110
|
-
|
|
|
|
111
|
- $result['info'] = [
|
|
|
|
112
|
- 'friend_id' => $isRes->friend_id ?? 0,
|
|
|
|
113
|
- 'nickname' => $isRes->nickname ?? '',
|
|
|
|
114
|
- 'user_name' => $isRes->user_name ?? '',
|
|
|
|
115
|
- 'image' => $isRes->image ?? '',
|
|
|
|
116
|
- ];
|
83
|
+ $cache = isset($cache);
|
|
|
|
84
|
+ $result = $this->ProjectAssociationLogic->getAiccWechatLists($isRes, $cache);
|
|
117
|
$this->response('success', Code::SUCCESS, $result);
|
85
|
$this->response('success', Code::SUCCESS, $result);
|
|
118
|
}
|
86
|
}
|
|
119
|
} |
87
|
} |