作者 lyh

Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6 into develop

... ... @@ -48,7 +48,7 @@ class ProjectAssociationController extends BaseController
$image = request()->post('image', '');
$data = compact('project_id', 'user_id', 'friend_id', 'nickname', 'user_name', 'image');
$this->ProjectAssociationLogic->saveWeChatData($data);
$this->response('success');
$this->response('绑定成功');
}
/**
... ... @@ -67,18 +67,25 @@ class ProjectAssociationController extends BaseController
$isRes = $this->ProjectAssociationLogic->normal($project_id);
// 当数据不存在时并开启状态,自动添加一条数据
if (is_null($isRes) && (!is_null($status) && $status)) {
$bool = $this->ProjectAssociationLogic->saveProject($project_id, $status);
if (empty($bool)) {
$isRes = $this->ProjectAssociationLogic->saveProject($project_id, $status);
if (is_null($isRes)) {
// 保存数据失败
$this->response('error', Code::SERVER_ERROR);
$this->response('绑定AICC数据失败!', Code::SERVER_ERROR);
}
} // 关闭状态
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)) {
$bool = $this->ProjectAssociationLogic->closedState($isRes, $status);
if ($bool) {
// 关闭aicc绑定成功
$this->response('关闭aicc绑定 - 成功!');
}else{
// 关闭aicc绑定失败
$this->response('关闭aicc绑定 - 失败!');
}
}
if (is_null($isRes)) {
// 请开启AICC绑定
$this->response('error', Code::SERVER_ERROR);
$this->response('success', Code::SERVER_ERROR);
}
$cache = isset($cache);
$result = $this->ProjectAssociationLogic->getAiccWechatLists($isRes, $cache);
... ...
... ... @@ -52,7 +52,7 @@ class ProjectAssociationLogic extends Logic
* 初始化数据/修改数据
* @param int $project_id
* @param int $status
* @return bool
* @return Builder|Model|object|ProjectAssociation|null
*/
public function saveProject($project_id, $status)
{
... ... @@ -66,12 +66,12 @@ class ProjectAssociationLogic extends Logic
$isRes->user_id = (int)env('AICC_WECHAT_USER_ID');
$isRes->status = $status;
try {
$bool = $isRes->save();
$isRes->save();
DB::commit();
} catch (\Exception $exception) {
DB::rollBack();
}
return $bool;
return $isRes;
}
/**
... ... @@ -104,27 +104,19 @@ class ProjectAssociationLogic extends Logic
* 关闭状态
* @param ProjectAssociation $res
* @param int $status 1 - 正常, 0 - 禁用
* @return array
* @return bool
*/
public function closedState($res, $status)
{
DB::beginTransaction();
$bool = false;
try {
$res->status = $status;
$res->save();
$bool = $res->save();
DB::commit();
$code = Code::SUCCESS;
$message = '关闭AICC绑定成功!';
} catch (\Exception $exception) {
DB::rollBack();
// 数据错误,请重试
$code = Code::SERVER_ERROR;
$message = 'error';
}
return [
'code' => $code,
'data' => [],
'message' => $message,
];
return $bool;
}
}
... ...