作者 李美松

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

@@ -48,7 +48,7 @@ class ProjectAssociationController extends BaseController @@ -48,7 +48,7 @@ class ProjectAssociationController extends BaseController
48 $image = request()->post('image', ''); 48 $image = request()->post('image', '');
49 $data = compact('project_id', 'user_id', 'friend_id', 'nickname', 'user_name', 'image'); 49 $data = compact('project_id', 'user_id', 'friend_id', 'nickname', 'user_name', 'image');
50 $this->ProjectAssociationLogic->saveWeChatData($data); 50 $this->ProjectAssociationLogic->saveWeChatData($data);
51 - $this->response('success'); 51 + $this->response('绑定成功');
52 } 52 }
53 53
54 /** 54 /**
@@ -70,15 +70,18 @@ class ProjectAssociationController extends BaseController @@ -70,15 +70,18 @@ class ProjectAssociationController extends BaseController
70 $bool = $this->ProjectAssociationLogic->saveProject($project_id, $status); 70 $bool = $this->ProjectAssociationLogic->saveProject($project_id, $status);
71 if (empty($bool)) { 71 if (empty($bool)) {
72 // 保存数据失败 72 // 保存数据失败
73 - $this->response('error', 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 - $res = $this->ProjectAssociationLogic->closedState($isRes, $status);  
78 - $this->response($res['message'], $res['code']); 77 + $bool = $this->ProjectAssociationLogic->closedState($isRes, $status);
  78 + if (empty($bool)) {
  79 + // 关闭aicc绑定失败
  80 + $this->response('关闭aicc绑定失败!', Code::SERVER_ERROR);
  81 + }
79 } elseif (is_null($isRes)) { 82 } elseif (is_null($isRes)) {
80 // 请开启AICC绑定 83 // 请开启AICC绑定
81 - $this->response('error', Code::SERVER_ERROR); 84 + $this->response('success');
82 } 85 }
83 $cache = isset($cache); 86 $cache = isset($cache);
84 $result = $this->ProjectAssociationLogic->getAiccWechatLists($isRes, $cache); 87 $result = $this->ProjectAssociationLogic->getAiccWechatLists($isRes, $cache);
@@ -104,27 +104,19 @@ class ProjectAssociationLogic extends Logic @@ -104,27 +104,19 @@ class ProjectAssociationLogic extends Logic
104 * 关闭状态 104 * 关闭状态
105 * @param ProjectAssociation $res 105 * @param ProjectAssociation $res
106 * @param int $status 1 - 正常, 0 - 禁用 106 * @param int $status 1 - 正常, 0 - 禁用
107 - * @return array 107 + * @return bool
108 */ 108 */
109 public function closedState($res, $status) 109 public function closedState($res, $status)
110 { 110 {
111 DB::beginTransaction(); 111 DB::beginTransaction();
  112 + $bool = false;
112 try { 113 try {
113 $res->status = $status; 114 $res->status = $status;
114 - $res->save(); 115 + $bool = $res->save();
115 DB::commit(); 116 DB::commit();
116 - $code = Code::SUCCESS;  
117 - $message = '关闭AICC绑定成功!';  
118 } catch (\Exception $exception) { 117 } catch (\Exception $exception) {
119 DB::rollBack(); 118 DB::rollBack();
120 - // 数据错误,请重试  
121 - $code = Code::SERVER_ERROR;  
122 - $message = 'error';  
123 } 119 }
124 - return [  
125 - 'code' => $code,  
126 - 'data' => [],  
127 - 'message' => $message,  
128 - ]; 120 + return $bool;
129 } 121 }
130 } 122 }