作者 lyh

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

@@ -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 /**
@@ -67,18 +67,25 @@ class ProjectAssociationController extends BaseController @@ -67,18 +67,25 @@ 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('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']);  
79 - } elseif (is_null($isRes)) { 77 + $bool = $this->ProjectAssociationLogic->closedState($isRes, $status);
  78 + if ($bool) {
  79 + // 关闭aicc绑定成功
  80 + $this->response('关闭aicc绑定 - 成功!');
  81 + }else{
  82 + // 关闭aicc绑定失败
  83 + $this->response('关闭aicc绑定 - 失败!');
  84 + }
  85 + }
  86 + if (is_null($isRes)) {
80 // 请开启AICC绑定 87 // 请开启AICC绑定
81 - $this->response('error', Code::SERVER_ERROR); 88 + $this->response('success', Code::SERVER_ERROR);
82 } 89 }
83 $cache = isset($cache); 90 $cache = isset($cache);
84 $result = $this->ProjectAssociationLogic->getAiccWechatLists($isRes, $cache); 91 $result = $this->ProjectAssociationLogic->getAiccWechatLists($isRes, $cache);
@@ -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 /**
@@ -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 }