作者 李美松

v6优化程序 OA绑定AICC 优化程序 - success

@@ -67,19 +67,23 @@ class ProjectAssociationController extends BaseController @@ -67,19 +67,23 @@ class ProjectAssociationController extends BaseController
67 $isRes = $this->ProjectAssociationLogic->normal($project_id); 67 $isRes = $this->ProjectAssociationLogic->normal($project_id);
68 // 当数据不存在时并开启状态,自动添加一条数据 68 // 当数据不存在时并开启状态,自动添加一条数据
69 if (is_null($isRes) && (!is_null($status) && $status)) { 69 if (is_null($isRes) && (!is_null($status) && $status)) {
70 - $bool = $this->ProjectAssociationLogic->saveProject($project_id, $status);  
71 - if (empty($bool)) { 70 + $isRes = $this->ProjectAssociationLogic->saveProject($project_id, $status);
  71 + if (is_null($isRes)) {
72 // 保存数据失败 72 // 保存数据失败
73 $this->response('绑定AICC数据失败!', Code::SERVER_ERROR); 73 $this->response('绑定AICC数据失败!', Code::SERVER_ERROR);
74 } 74 }
75 } // 关闭状态 75 } // 关闭状态
76 elseif (!is_null($isRes) && (!is_null($status) && empty($status))) { 76 elseif (!is_null($isRes) && (!is_null($status) && empty($status))) {
77 $bool = $this->ProjectAssociationLogic->closedState($isRes, $status); 77 $bool = $this->ProjectAssociationLogic->closedState($isRes, $status);
78 - if (empty($bool)) { 78 + if ($bool) {
  79 + // 关闭aicc绑定成功
  80 + $this->response('关闭aicc绑定 - 成功!');
  81 + }else{
79 // 关闭aicc绑定失败 82 // 关闭aicc绑定失败
80 - $this->response('关闭aicc绑定失败!', Code::SERVER_ERROR); 83 + $this->response('关闭aicc绑定 - 失败!', Code::SERVER_ERROR);
81 } 84 }
82 - } elseif (is_null($isRes)) { 85 + }
  86 + if (is_null($isRes)) {
83 // 请开启AICC绑定 87 // 请开启AICC绑定
84 $this->response('success'); 88 $this->response('success');
85 } 89 }
@@ -52,7 +52,7 @@ class ProjectAssociationLogic extends Logic @@ -52,7 +52,7 @@ class ProjectAssociationLogic extends Logic
52 * 初始化数据/修改数据 52 * 初始化数据/修改数据
53 * @param int $project_id 53 * @param int $project_id
54 * @param int $status 54 * @param int $status
55 - * @return bool 55 + * @return Builder|Model|object|ProjectAssociation|null
56 */ 56 */
57 public function saveProject($project_id, $status) 57 public function saveProject($project_id, $status)
58 { 58 {
@@ -66,12 +66,12 @@ class ProjectAssociationLogic extends Logic @@ -66,12 +66,12 @@ class ProjectAssociationLogic extends Logic
66 $isRes->user_id = (int)env('AICC_WECHAT_USER_ID'); 66 $isRes->user_id = (int)env('AICC_WECHAT_USER_ID');
67 $isRes->status = $status; 67 $isRes->status = $status;
68 try { 68 try {
69 - $bool = $isRes->save(); 69 + $isRes->save();
70 DB::commit(); 70 DB::commit();
71 } catch (\Exception $exception) { 71 } catch (\Exception $exception) {
72 DB::rollBack(); 72 DB::rollBack();
73 } 73 }
74 - return $bool; 74 + return $isRes;
75 } 75 }
76 76
77 /** 77 /**