diff --git a/Server/application/chukebao/config/route.php b/Server/application/chukebao/config/route.php index 1af6fa36..9dd32c2c 100644 --- a/Server/application/chukebao/config/route.php +++ b/Server/application/chukebao/config/route.php @@ -166,6 +166,7 @@ Route::group('v1/', function () { }); + Route::post('dataProcessing', 'app\chukebao\controller\DataProcessing@index'); // 修改数据 }); diff --git a/Server/application/chukebao/controller/DataProcessing.php b/Server/application/chukebao/controller/DataProcessing.php new file mode 100644 index 00000000..46e7e68a --- /dev/null +++ b/Server/application/chukebao/controller/DataProcessing.php @@ -0,0 +1,82 @@ +getUserInfo('id'); + $companyId = $this->getUserInfo('companyId'); + $type = $this->request->param('type', ''); + $wechatAccountId = $this->request->param('wechatAccountId', ''); + //微信好友 + $toAccountId = $this->request->param('toAccountId', ''); + $wechatFriendId = $this->request->param('wechatFriendId', ''); + $newRemark = $this->request->param('newRemark', ''); + $labels = $this->request->param('labels', []); + //微信群 + $wechatChatroomId = $this->request->param('wechatChatroomId', ''); + $typeData = [ + 'CmdModifyFriendRemark', //好友修改备注 {newRemark、wechatAccountId、wechatFriendId} + 'CmdModifyFriendLabel', //好友修改标签 {labels、wechatAccountId、wechatFriendId} + 'CmdAllotFriend', //转让好友 {labels、wechatAccountId、wechatFriendId} + 'CmdChatroomOperate', //修改群信息 {chatroomName(群名)、announce(公告)、extra(公告)、wechatAccountId、wechatChatroomId} + ]; + + if (empty($type) || empty($wechatAccountId)) { + return ResponseHelper::error('参数缺失'); + } + + if (!in_array($type, $typeData)) { + return ResponseHelper::error('类型错误'); + } + $msg = ''; + switch ($type) { + case 'CmdModifyFriendRemark': //修改好友备注 + if(empty($wechatFriendId) || empty($newRemark)){ + return ResponseHelper::error('参数缺失'); + } + $friend = WechatFriendModel::where(['id' => $wechatFriendId,'wechatAccountId' => $wechatAccountId])->find(); + if(empty($friend)){ + return ResponseHelper::error('好友不存在'); + } + $friend->conRemark = $newRemark; + $friend->updateTime = time(); + $friend->save(); + $msg = '修改备成功'; + break; + case 'CmdModifyFriendLabel': //修改好友标签 + if(empty($wechatFriendId)){ + return ResponseHelper::error('参数缺失'); + } + $friend = WechatFriendModel::where(['id' => $wechatFriendId,'wechatAccountId' => $wechatAccountId])->find(); + if(empty($friend)){ + return ResponseHelper::error('好友不存在'); + } + $friend->labels = json_encode($labels,256); + $friend->updateTime = time(); + $friend->save(); + $msg = '修标签成功'; + break; + case 'CmdAllotFriend': + if(empty($toAccountId)){ + return ResponseHelper::error('参数缺失'); + } + + $friend = WechatFriendModel::where(['id' => $wechatFriendId,'wechatAccountId' => $wechatAccountId])->find(); + if(empty($friend)){ + return ResponseHelper::error('好友不存在'); + } + $friend->accountId = $toAccountId; + $friend->updateTime = time(); + $friend->save(); + $msg = '好友转移成功'; + break; + } + return ResponseHelper::success('',$msg); + } +} \ No newline at end of file