This commit is contained in:
2025-03-22 20:52:12 +08:00
parent 2e24cf6d45
commit e58dd8acb5
11 changed files with 414 additions and 35 deletions

View File

@@ -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();
}
}

View File

@@ -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)

View File

@@ -0,0 +1,66 @@
<?php
/*
* description
* authorwh
* email
* createTime{2025/3/22} {17:48}
*/
namespace app\admin\controller;
use app\api\logic\GechatroomLogic;
use think\Controller;
class Gechatroom extends Controller
{
/**
* 查询系统微信中的群【只有群id列表】[需要手动保存为通讯录]
*
* array(3) {
[0] => 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)]);
}
}

View File

@@ -0,0 +1,96 @@
<?php
/*
* description
* authorwh
* email
* createTime{2025/3/22} {14:10}
*/
namespace app\admin\controller;
use app\api\logic\GewechatFriendsLogic;
use think\Controller;
class Gewechatfriends extends Controller
{
/**
* desc查询微信好友列表
* authorwh
* @return \think\response\Json
* @throws \Exception
*
* /api/Gewechatfriends/getFriendList
*/
function getFriendList()
{
if(cache('cache_getFriendDetailList_data'.session_admin_firm_id())){
$data = cache('cache_getFriendDetailList_data'.session_admin_firm_id());
return json(['list' => $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查询好友详细信息
* authorwh
*
* 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)]);
}
}

View File

@@ -1,24 +0,0 @@
<?php
/*
* description
* authorwh
* email
* createTime{2025/3/22} {14:10}
*/
namespace app\admin\controller;
use app\admin\logic\GewechatLogic;
use app\common\controller\Backend;
class Wechat extends Backend
{
//查询微信好友列表
function getFriendList()
{
$res = (new GewechatLogic())->getFriendDetailList();
dump($res);die;
}
}

View File

@@ -20,14 +20,19 @@
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Rel_wx')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-rel_wx" class="form-control" name="row[rel_wx]" type="text" value="">
<div class="col-xs-12 col-sm-6">
<input id="c-rel_wx" data-source="Gewechatfriends/getFriendList" data-wx_id=""
class="form-control selectpage" name="row[rel_wx]" type="text" value="">
</div>
<div class="col-xs-12 col-sm-2">
<input class="form-control firmcustomer-sync-info" type="button" value="同步信息">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Rel_group')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-rel_group" class="form-control" name="row[rel_group]" type="text" value="">
<input id="c-rel_group" data-source="Gechatroom/getChatroomList"
class="form-control selectpage" name="row[rel_group]" type="text" value="">
</div>
</div>
<div class="form-group">

View File

@@ -6,7 +6,7 @@
* createTime{2025/3/22} {14:06}
*/
namespace app\admin\logic;
namespace app\api\logic;
class BaseLogic

View File

@@ -0,0 +1,95 @@
<?php
/*
* description
* authorwh
* email
* createTime{2025/3/22} {17:52}
*/
namespace app\api\logic;
use wanghua\general_utility_tools_php\tool\Tools;
class GechatroomLogic extends BaseLogic
{
/**
* 获取群列表[带群名称],包含了群成员列表
*
* 包含了群成员列表
*
*
*/
function getChatroomList()
{
$this->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获取群成员详情
* authorwh
*/
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;
}
}

View File

@@ -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查询微信好友//关注的公众号列表[不带昵称]
* authorwh
* @return array 返回的是好友的微信id需要昵称就要调好友查询接口
*

View File

@@ -5,7 +5,7 @@
* email
* createTime{2025/3/22} {14:04}
*/
namespace app\admin\logic;
namespace app\api\logic;
class TokenLogic extends BaseLogic
{

View File

@@ -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 () {