diff --git a/admin/application/admin/controller/Firmcustomer.php b/admin/application/admin/controller/Firmcustomer.php index 81b9f49..d6d0175 100644 --- a/admin/application/admin/controller/Firmcustomer.php +++ b/admin/application/admin/controller/Firmcustomer.php @@ -4,6 +4,9 @@ namespace app\admin\controller; use app\common\controller\Backend; use think\Db; +use think\Exception; +use think\exception\PDOException; +use think\exception\ValidateException; use think\Request; /** @@ -78,4 +81,96 @@ class Firmcustomer extends Backend return $this->view->fetch(); } + + /** + * 添加 + * + * @return string + * @throws \think\Exception + */ + public function add() + { + if (false === $this->request->isPost()) { + return $this->view->fetch(); + } + dump(input()); + die; + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; + $this->model->validateFailException()->validate($validate); + } + $result = $this->model->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } + + /** + * 编辑 + * + * @param $ids + * @return string + * @throws DbException + * @throws \think\Exception + */ + public function edit($ids = null) + { + $row = $this->model->get($ids); + if (!$row) { + $this->error(__('No Results were found')); + } + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) { + $this->error(__('You have no permission')); + } + if (false === $this->request->isPost()) { + $this->view->assign('row', $row); + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; + $row->validateFailException()->validate($validate); + } + $result = $row->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if (false === $result) { + $this->error(__('No rows were updated')); + } + $this->success(); + } + } diff --git a/admin/application/admin/controller/Firmemployee.php b/admin/application/admin/controller/Firmemployee.php index 1030aee..5ef5673 100644 --- a/admin/application/admin/controller/Firmemployee.php +++ b/admin/application/admin/controller/Firmemployee.php @@ -25,8 +25,6 @@ class Firmemployee extends Backend $this->view->assign("statusList", $this->model->getStatusList()); $this->view->assign("employeeTypeList", $this->model->getEmployeeTypeList()); - $this->model->where('firmemployee.firm_id',session_admin_firm_id()); - $this->model->where('firmemployee.firmstore_id',session_admin_firmstore_id()); } @@ -54,6 +52,8 @@ class Firmemployee extends Backend } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + $this->model->where('firmemployee.firm_id',session_admin_firm_id()); + $this->model->where('firmemployee.firmstore_id',session_admin_firmstore_id()); $list = $this->model ->with(['firmduty']) ->where($where) diff --git a/admin/application/admin/controller/Gechatroom.php b/admin/application/admin/controller/Gechatroom.php new file mode 100644 index 0000000..70704e9 --- /dev/null +++ b/admin/application/admin/controller/Gechatroom.php @@ -0,0 +1,66 @@ + string(19) "7037032174@chatroom" + [1] => string(20) "52468523601@chatroom" + [2] => string(20) "52984126208@chatroom" + } + * + * /api/Gechatroom/getChatroomList + */ + function getChatroomList() + { + //if(cache('cache_getChatroomList_data'.session_admin_firm_id())){ + // $data = cache('cache_getChatroomList_data'.session_admin_firm_id()); + // //自带id,name + // return json(['list' => $data, 'total' => count($data)]); + //} + $data = (new GechatroomLogic())->getChatroomList(); + dump($data);die; + //缓存群成员列表 + cache('cache_getChatroomList_data'.session_admin_firm_id(),$data,3600); + //自带id,name + return json(['list' => $data, 'total' => count($data)]); + } + + + /** + * 查询群成员列表 + */ + function getChatroomMemberList() + { + $chatroom_id = input('chatroom_id'); + if(empty($chatroom_id)){ + return json(['list' => [], 'total' => 0]); + } + if(cache('cache_getChatroomList_data'.session_admin_firm_id())){ + $cache_data = cache('cache_getChatroomList_data'.session_admin_firm_id()); + $memberList = $cache_data[$chatroom_id]['memberList']; + return json(['list' => $memberList, 'total' => count($memberList)]); + } + $data = (new GechatroomLogic())->getChatroomList(); + //缓存群成员列表 + cache('cache_getChatroomList_data'.session_admin_firm_id(),$data['memberList'],3600); + $memberList = $data[$chatroom_id]['memberList']; + return json(['list' => $memberList, 'total' => count($memberList)]); + } + +} \ No newline at end of file diff --git a/admin/application/admin/controller/Gewechatfriends.php b/admin/application/admin/controller/Gewechatfriends.php new file mode 100644 index 0000000..e1dc509 --- /dev/null +++ b/admin/application/admin/controller/Gewechatfriends.php @@ -0,0 +1,96 @@ + $data, 'total' => count($data)]); + } + $res = (new GewechatFriendsLogic())->getFriendDetailList(); + $data = $res['data']; + foreach ($data as $k => &$v){ + $v['id'] = $v['userName'] ?? '无'; + $v['name'] = $v['nickName'] ?? '无'; + } + cache('cache_getFriendDetailList_data'.session_admin_firm_id(),$data,96400); + return json(['list' => $data, 'total' => count($data)]); + } + + + + /** + * desc:查询好友详细信息 + * author:wh + * + * array(22) { + ["userName"] => string(19) "wxid_lqhlkt5nq80n12" + ["nickName"] => string(6) "AI dev" + ["pyInitial"] => string(5) "AIDEV" + ["quanPin"] => string(5) "AIdev" + ["sex"] => int(0) + ["remark"] => NULL + ["remarkPyInitial"] => NULL + ["remarkQuanPin"] => NULL + ["signature"] => NULL + ["alias"] => string(7) "AIhuamn" + ["snsBgImg"] => NULL + ["country"] => NULL + ["bigHeadImgUrl"] => string(194) "https://wx.qlogo.cn/mmhead/ver_1/iaHvw1ich96Wdvm3SF81ySOczyzUxvHj1DviaGVlt7R8OicvmItOD61GaCGG0A5UhoHZfIOolV4Q7tHHMGgicNicEGjGWDE0nZh0udwMNFicHTV5bLoXJiae6AZRzhzbeoQ9DJnhJTAI9h300LjicaTGkAvZt1A/0" + ["smallHeadImgUrl"] => string(196) "https://wx.qlogo.cn/mmhead/ver_1/iaHvw1ich96Wdvm3SF81ySOczyzUxvHj1DviaGVlt7R8OicvmItOD61GaCGG0A5UhoHZfIOolV4Q7tHHMGgicNicEGjGWDE0nZh0udwMNFicHTV5bLoXJiae6AZRzhzbeoQ9DJnhJTAI9h300LjicaTGkAvZt1A/132" + ["description"] => NULL + ["cardImgUrl"] => NULL + ["labelList"] => NULL + ["province"] => NULL + ["city"] => NULL + ["phoneNumList"] => NULL + ["id"] => string(19) "wxid_lqhlkt5nq80n12" + ["name"] => string(6) "AI dev" + } + * + * + * @return \think\response\Json + * @throws \Exception + * + * /api/Gewechatfriends/getFriendDetail + */ + function getFriendDetail() + { + $wx_id = input('wx_id'); + $data = []; + if(cache('cache_getFriendDetailList_data'.session_admin_firm_id())){ + $cache_data = cache('cache_getFriendDetailList_data'.session_admin_firm_id()); + foreach ($cache_data as $k => $v){ + if($v['id'] == $wx_id){ + $data = $v; + break; + } + } + return json(['data' => $data, 'total' => count($data)]); + } + return json(['data' => $data, 'total' => count($data)]); + } + +} \ No newline at end of file diff --git a/admin/application/admin/controller/Wechat.php b/admin/application/admin/controller/Wechat.php deleted file mode 100644 index d7cc0e9..0000000 --- a/admin/application/admin/controller/Wechat.php +++ /dev/null @@ -1,24 +0,0 @@ -getFriendDetailList(); - dump($res);die; - } -} \ No newline at end of file diff --git a/admin/application/admin/view/firmcustomer/add.html b/admin/application/admin/view/firmcustomer/add.html index 074e2da..907fc14 100644 --- a/admin/application/admin/view/firmcustomer/add.html +++ b/admin/application/admin/view/firmcustomer/add.html @@ -20,14 +20,19 @@
-
- +
+ +
+
+
- +
diff --git a/admin/application/admin/logic/BaseLogic.php b/admin/application/api/logic/BaseLogic.php similarity index 98% rename from admin/application/admin/logic/BaseLogic.php rename to admin/application/api/logic/BaseLogic.php index a52dc5a..821c095 100644 --- a/admin/application/admin/logic/BaseLogic.php +++ b/admin/application/api/logic/BaseLogic.php @@ -6,7 +6,7 @@ * createTime:{2025/3/22} {14:06} */ -namespace app\admin\logic; +namespace app\api\logic; class BaseLogic diff --git a/admin/application/api/logic/GechatroomLogic.php b/admin/application/api/logic/GechatroomLogic.php new file mode 100644 index 0000000..62f6f25 --- /dev/null +++ b/admin/application/api/logic/GechatroomLogic.php @@ -0,0 +1,95 @@ +getChatroomMemberList();die; + //去查询群名称 + $wxids_arr = (new GewechatFriendsLogic())->getFriendWxIdsList(); + $chatrooms = $wxids_arr['data']['chatrooms']; + dump($chatrooms); + $url = '/group/getChatroomInfo'; + Tools::log_to_write_txt(['获取群列表[带群名称],包含了群成员列表,入参:$chatrooms'=>$chatrooms]); + $arr = []; + foreach ($chatrooms as $v){ + $post_data = ['chatroomId'=>$v]; + $res = self::curl_post_json($url, $post_data); + dump($res);die; + //群号=>群信息[含群成员列表] + $arr[$v] = array_merge($res['data'],[ + 'id'=>$v, + 'name'=>$res['data']['nickName'] + ]); + } + Tools::log_to_write_txt(['获取群列表[带群名称],包含了群成员列表,出参:$res'=>count($arr)]); + return $arr; + } + + function getChatroomMemberList(){ + //去查询群名称 + $wxids_arr = (new GewechatFriendsLogic())->getFriendWxIdsList(); + $chatrooms = $wxids_arr['data']['chatrooms']; + dump($chatrooms); + $url = '/group/getChatroomMemberDetail'; + Tools::log_to_write_txt(['获取群列表[带群名称],包含了群成员列表,入参:$chatrooms'=>$chatrooms]); + $arr = []; + foreach ($chatrooms as $v){ + $post_data = ['chatroomId'=>$v]; + $res = self::curl_post_json($url, $post_data); + dump($res);die; + //群号=>群信息[含群成员列表] + $arr[$v] = array_merge($res['data'],[ + 'id'=>$v, + 'name'=>$res['data']['nickName'] + ]); + } + Tools::log_to_write_txt(['获取群列表[带群名称],包含了群成员列表,出参:$res'=>count($arr)]); + return $arr; + } + + /** + * desc:获取群成员详情 + * author:wh + */ + function getChatroomMemberDetail(){ + //去查询群名称 + $wxids_arr = (new GewechatFriendsLogic())->getFriendWxIdsList(); + $chatrooms = $wxids_arr['data']['chatrooms']; + dump($chatrooms); + $url = '/group/getChatroomMemberDetail'; + Tools::log_to_write_txt(['获取群列表[带群名称],包含了群成员列表,入参:$chatrooms'=>$chatrooms]); + $arr = []; + foreach ($chatrooms as $v){ + $post_data = ['chatroomId'=>$v]; + $res = self::curl_post_json($url, $post_data); + dump($res);die; + //群号=>群信息[含群成员列表] + $arr[$v] = array_merge($res['data'],[ + 'id'=>$v, + 'name'=>$res['data']['nickName'] + ]); + } + Tools::log_to_write_txt(['获取群列表[带群名称],包含了群成员列表,出参:$res'=>count($arr)]); + return $arr; + } +} \ No newline at end of file diff --git a/admin/application/admin/logic/GewechatLogic.php b/admin/application/api/logic/GewechatFriendsLogic.php similarity index 93% rename from admin/application/admin/logic/GewechatLogic.php rename to admin/application/api/logic/GewechatFriendsLogic.php index 69e5b20..c48f32f 100644 --- a/admin/application/admin/logic/GewechatLogic.php +++ b/admin/application/api/logic/GewechatFriendsLogic.php @@ -6,18 +6,17 @@ * createTime:{2025/3/22} {14:11} */ -namespace app\admin\logic; +namespace app\api\logic; -use wanghua\general_utility_tools_php\http\Curl; use wanghua\general_utility_tools_php\tool\Tools; -class GewechatLogic extends BaseLogic +class GewechatFriendsLogic extends BaseLogic { /** - * desc:查询微信好友列表[不带昵称] + * desc:查询微信好友/群/关注的公众号列表[不带昵称] * author:wh * @return array 返回的是好友的微信id,需要昵称就要调好友查询接口 * diff --git a/admin/application/admin/logic/TokenLogic.php b/admin/application/api/logic/TokenLogic.php similarity index 96% rename from admin/application/admin/logic/TokenLogic.php rename to admin/application/api/logic/TokenLogic.php index 9b69b32..123ed4d 100644 --- a/admin/application/admin/logic/TokenLogic.php +++ b/admin/application/api/logic/TokenLogic.php @@ -5,7 +5,7 @@ * email: * createTime:{2025/3/22} {14:04} */ -namespace app\admin\logic; +namespace app\api\logic; class TokenLogic extends BaseLogic { diff --git a/admin/public/assets/js/backend/firmcustomer.js b/admin/public/assets/js/backend/firmcustomer.js index c262587..5c91882 100644 --- a/admin/public/assets/js/backend/firmcustomer.js +++ b/admin/public/assets/js/backend/firmcustomer.js @@ -47,10 +47,57 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ] }); + + //当表格数据加载完成时 + table.on('load-success.bs.table', function (e, data) { + //这里可以获取从服务端获取的JSON数据 + // console.log(data); + //这里我们手动设置底部的值 + // $("#money").text(data.extend.money); + // $("#price").text(data.extend.price); + + // + let load_index = layer.load(1); + $.post('Gewechatfriends/getFriendList',{},function (res) { + layer.close(load_index); + },'json'); + // $("#c-rel_wx").data("eSelect", function(data){ + // //后续操作 + // console.log(data); + // + // }); + + // $(document).on("change", "#c-rel_wx", function(data){ + // //变更后的回调事件 + // // $('input[name="c-rel_wx"]').attr('wx_id'); + // console.log(data); + // }); + }); + // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { + //设置下拉框后的值 + $(document).on("change", "#c-rel_wx", function(data){ + //变更后的回调事件 + // console.log(data.currentTarget.defaultValue); + $('#c-rel_wx').attr('data-wx_id',data.currentTarget.defaultValue); + }); + + + $('.firmcustomer-sync-info').on('click',function (e){ + //读取下拉框的值 + let wx_id = $('#c-rel_wx').attr('data-wx_id'); + console.log(wx_id); + // console.log(e); + let load_index = layer.load(1); + $.post('Gewechatfriends/getFriendDetail',{wx_id:wx_id},function (res) { + layer.close(load_index); + //回显 + $('#c-headimage').val(res.data.smallHeadImgUrl); + },'json'); + }); Controller.api.bindevent(); }, edit: function () {