Browse Source

first commit

wang jun 3 years ago
commit
4be1e9cbaa
100 changed files with 13927 additions and 0 deletions
  1. 6 0
      .gitignore
  2. 42 0
      .travis.yml
  3. 32 0
      LICENSE.txt
  4. 129 0
      README.md
  5. 1 0
      application/.htaccess
  6. 12 0
      application/command.php
  7. 234 0
      application/common.php
  8. 240 0
      application/config.php
  9. 58 0
      application/database.php
  10. 54 0
      application/extra/database_labourunion.php
  11. 54 0
      application/extra/database_labouruniondev.php
  12. 14 0
      application/extra/queue.php
  13. 323 0
      application/index/controller/Index.php
  14. 100 0
      application/index/controller/Party.php
  15. 133 0
      application/index/logic/businesslogic.php
  16. 285 0
      application/index/logic/companylogic.php
  17. 23 0
      application/index/logic/errorCode.php
  18. 79 0
      application/index/logic/evaluatelogic.php
  19. 64 0
      application/index/logic/feedbacklogic.php
  20. 268 0
      application/index/logic/grouplogic.php
  21. 216 0
      application/index/logic/homepagelogic.php
  22. 820 0
      application/index/logic/inventlogic.php
  23. 838 0
      application/index/logic/inventv1logic.php
  24. 454 0
      application/index/logic/jobhuntinglogic.php
  25. 102 0
      application/index/logic/loginlogic.php
  26. 261 0
      application/index/logic/orderlogic.php
  27. 253 0
      application/index/logic/partnerlogic.php
  28. 231 0
      application/index/logic/partylogic.php
  29. 14 0
      application/index/logic/permissionlogic.php
  30. 229 0
      application/index/logic/rolelogic.php
  31. 164 0
      application/index/logic/safenotelogic.php
  32. 129 0
      application/index/logic/scorelogic.php
  33. 115 0
      application/index/logic/signinlogic.php
  34. 79 0
      application/index/logic/smslogic.php
  35. 168 0
      application/index/logic/trainlogic.php
  36. 168 0
      application/index/logic/trainsignuserlogic.php
  37. 547 0
      application/index/logic/useraccountlogic.php
  38. 479 0
      application/index/logic/useractionlogic.php
  39. 106 0
      application/index/logic/userapplyloglogic.php
  40. 743 0
      application/index/logic/userinfologic.php
  41. 95 0
      application/index/logic/usershareloglogic.php
  42. 61 0
      application/index/logic/versionlogic.php
  43. 450 0
      application/index/logic/webmanger.php
  44. 101 0
      application/index/logic/webuserloglogic.php
  45. 65 0
      application/index/logic/workerlogic.php
  46. 71 0
      application/index/logic/workerskilllogic.php
  47. 83 0
      application/index/logic/worktypelogic.php
  48. 73 0
      application/index/logic/wxBizDataCrypt.php
  49. 84 0
      application/index/logic/wxlogic.php
  50. 61 0
      application/index/model/businesstypemodel.php
  51. 61 0
      application/index/model/buyscorekindmodel.php
  52. 101 0
      application/index/model/companymodel.php
  53. 88 0
      application/index/model/evaluatemodel.php
  54. 44 0
      application/index/model/feedbackmodel.php
  55. 69 0
      application/index/model/groupmodel.php
  56. 55 0
      application/index/model/groupusermodel.php
  57. 240 0
      application/index/model/inventmodel.php
  58. 242 0
      application/index/model/inventv1model.php
  59. 148 0
      application/index/model/jobhuntingmodel.php
  60. 19 0
      application/index/model/logmodel.php
  61. 92 0
      application/index/model/memodel.php
  62. 61 0
      application/index/model/partnergainmodel.php
  63. 72 0
      application/index/model/partnermembermodel.php
  64. 61 0
      application/index/model/partnermodel.php
  65. 62 0
      application/index/model/partybusinessmodel.php
  66. 114 0
      application/index/model/payordermodel.php
  67. 61 0
      application/index/model/permissionmodel.php
  68. 61 0
      application/index/model/permissionusermodel.php
  69. 61 0
      application/index/model/rolesmodel.php
  70. 68 0
      application/index/model/roleusermodel.php
  71. 61 0
      application/index/model/safenotemodel.php
  72. 73 0
      application/index/model/scorebusinessmodel.php
  73. 61 0
      application/index/model/scorebusinessrecordmodel.php
  74. 61 0
      application/index/model/scoreordermodel.php
  75. 80 0
      application/index/model/signinmodel.php
  76. 69 0
      application/index/model/smscoderecordmodel.php
  77. 266 0
      application/index/model/statisticssqlmodel.php
  78. 61 0
      application/index/model/trainmodel.php
  79. 61 0
      application/index/model/trainsignusermodel.php
  80. 77 0
      application/index/model/useraccountaddrecordmodel.php
  81. 55 0
      application/index/model/useraccountmodel.php
  82. 163 0
      application/index/model/useraccountuserrecordmodel.php
  83. 24 0
      application/index/model/useractionrecordmodel.php
  84. 72 0
      application/index/model/userapplylogmodel.php
  85. 226 0
      application/index/model/userconnectrecorddaymodel.php
  86. 210 0
      application/index/model/userconnectrecordmodel.php
  87. 182 0
      application/index/model/userinfomodel.php
  88. 83 0
      application/index/model/userlocationmodel.php
  89. 62 0
      application/index/model/userpartymodel.php
  90. 65 0
      application/index/model/userpartypicturemodel.php
  91. 24 0
      application/index/model/usersearchrecordmodel.php
  92. 76 0
      application/index/model/usersharelogmodel.php
  93. 61 0
      application/index/model/versionmodel.php
  94. 61 0
      application/index/model/webuserlogmodel.php
  95. 79 0
      application/index/model/webusermodel.php
  96. 66 0
      application/index/model/workerinfomodel.php
  97. 51 0
      application/index/model/workermodel.php
  98. 55 0
      application/index/model/workerskillmodel.php
  99. 81 0
      application/index/model/worktypemodel.php
  100. 170 0
      application/index/server/applybusinessserver.php

+ 6 - 0
.gitignore

@@ -0,0 +1,6 @@
+.idea
+composer.lock
+*.log
+thinkphp
+*.zip
+/runtime

+ 42 - 0
.travis.yml

@@ -0,0 +1,42 @@
+sudo: false
+
+language: php
+
+branches:
+  only:
+    - stable
+
+cache:
+  directories:
+    - $HOME/.composer/cache
+
+before_install:
+  - composer self-update
+
+install:
+  - composer install --no-dev --no-interaction --ignore-platform-reqs
+  - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Core.zip .
+  - composer require --update-no-dev --no-interaction "topthink/think-image:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0"
+  - composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0"
+  - composer require --dev --update-no-dev --no-interaction "topthink/think-testing:^1.0"
+  - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Full.zip .
+
+script:
+  - php think unit
+
+deploy:
+  provider: releases
+  api_key:
+    secure: TSF6bnl2JYN72UQOORAJYL+CqIryP2gHVKt6grfveQ7d9rleAEoxlq6PWxbvTI4jZ5nrPpUcBUpWIJHNgVcs+bzLFtyh5THaLqm39uCgBbrW7M8rI26L8sBh/6nsdtGgdeQrO/cLu31QoTzbwuz1WfAVoCdCkOSZeXyT/CclH99qV6RYyQYqaD2wpRjrhA5O4fSsEkiPVuk0GaOogFlrQHx+C+lHnf6pa1KxEoN1A0UxxVfGX6K4y5g4WQDO5zT4bLeubkWOXK0G51XSvACDOZVIyLdjApaOFTwamPcD3S1tfvuxRWWvsCD5ljFvb2kSmx5BIBNwN80MzuBmrGIC27XLGOxyMerwKxB6DskNUO9PflKHDPI61DRq0FTy1fv70SFMSiAtUv9aJRT41NQh9iJJ0vC8dl+xcxrWIjU1GG6+l/ZcRqVx9V1VuGQsLKndGhja7SQ+X1slHl76fRq223sMOql7MFCd0vvvxVQ2V39CcFKao/LB1aPH3VhODDEyxwx6aXoTznvC/QPepgWsHOWQzKj9ftsgDbsNiyFlXL4cu8DWUty6rQy8zT2b4O8b1xjcwSUCsy+auEjBamzQkMJFNlZAIUrukL/NbUhQU37TAbwsFyz7X0E/u/VMle/nBCNAzgkMwAUjiHM6FqrKKBRWFbPrSIixjfjkCnrMEPw=
+  file:
+    - ThinkPHP_Core.zip
+    - ThinkPHP_Full.zip
+  skip_cleanup: true
+  on:
+    tags: true

+ 32 - 0
LICENSE.txt

@@ -0,0 +1,32 @@
+
+ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
+版权所有Copyright © 2006-2017 by ThinkPHP (http://thinkphp.cn)
+All rights reserved。
+ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
+
+Apache Licence是著名的非盈利开源组织Apache采用的协议。
+该协议和BSD类似,鼓励代码共享和尊重原作者的著作权,
+允许代码修改,再作为开源或商业软件发布。需要满足
+的条件: 
+1. 需要给代码的用户一份Apache Licence ;
+2. 如果你修改了代码,需要在被修改的文件中说明;
+3. 在延伸的代码中(修改和有源代码衍生的代码中)需要
+带有原来代码中的协议,商标,专利声明和其他原来作者规
+定需要包含的说明;
+4. 如果再发布的产品中包含一个Notice文件,则在Notice文
+件中需要带有本协议内容。你可以在Notice中增加自己的
+许可,但不可以表现为对Apache Licence构成更改。 
+具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.

+ 129 - 0
README.md

@@ -0,0 +1,129 @@
+ThinkPHP 5.0
+===============
+
+[![Total Downloads](https://poser.pugx.org/topthink/think/downloads)](https://packagist.org/packages/topthink/think)
+[![Latest Stable Version](https://poser.pugx.org/topthink/think/v/stable)](https://packagist.org/packages/topthink/think)
+[![Latest Unstable Version](https://poser.pugx.org/topthink/think/v/unstable)](https://packagist.org/packages/topthink/think)
+[![License](https://poser.pugx.org/topthink/think/license)](https://packagist.org/packages/topthink/think)
+
+ThinkPHP5在保持快速开发和大道至简的核心理念不变的同时,PHP版本要求提升到5.4,对已有的CBD模式做了更深的强化,优化核心,减少依赖,基于全新的架构思想和命名空间实现,是ThinkPHP突破原有框架思路的颠覆之作,其主要特性包括:
+
+ + 基于命名空间和众多PHP新特性
+ + 核心功能组件化
+ + 强化路由功能
+ + 更灵活的控制器
+ + 重构的模型和数据库类
+ + 配置文件可分离
+ + 重写的自动验证和完成
+ + 简化扩展机制
+ + API支持完善
+ + 改进的Log类
+ + 命令行访问支持
+ + REST支持
+ + 引导文件支持
+ + 方便的自动生成定义
+ + 真正惰性加载
+ + 分布式环境支持
+ + 更多的社交类库
+
+> ThinkPHP5的运行环境要求PHP5.4以上。
+
+详细开发文档参考 [ThinkPHP5完全开发手册](http://www.kancloud.cn/manual/thinkphp5)
+
+## 目录结构
+
+初始的目录结构如下:
+
+~~~
+www  WEB部署目录(或者子目录)
+├─application           应用目录
+│  ├─common             公共模块目录(可以更改)
+│  ├─module_name        模块目录
+│  │  ├─config.php      模块配置文件
+│  │  ├─common.php      模块函数文件
+│  │  ├─controller      控制器目录
+│  │  ├─model           模型目录
+│  │  ├─view            视图目录
+│  │  └─ ...            更多类库目录
+│  │
+│  ├─command.php        命令行工具配置文件
+│  ├─common.php         公共函数文件
+│  ├─config.php         公共配置文件
+│  ├─route.php          路由配置文件
+│  ├─tags.php           应用行为扩展定义文件
+│  └─database.php       数据库配置文件
+│
+├─public                WEB目录(对外访问目录)
+│  ├─index.php          入口文件
+│  ├─router.php         快速测试文件
+│  └─.htaccess          用于apache的重写
+│
+├─thinkphp              框架系统目录
+│  ├─lang               语言文件目录
+│  ├─library            框架类库目录
+│  │  ├─think           Think类库包目录
+│  │  └─traits          系统Trait目录
+│  │
+│  ├─tpl                系统模板目录
+│  ├─base.php           基础定义文件
+│  ├─console.php        控制台入口文件
+│  ├─convention.php     框架惯例配置文件
+│  ├─helper.php         助手函数文件
+│  ├─phpunit.xml        phpunit配置文件
+│  └─start.php          框架入口文件
+│
+├─extend                扩展类库目录
+├─runtime               应用的运行时目录(可写,可定制)
+├─vendor                第三方类库目录(Composer依赖库)
+├─build.php             自动生成定义文件(参考)
+├─composer.json         composer 定义文件
+├─LICENSE.txt           授权说明文件
+├─README.md             README 文件
+├─think                 命令行入口文件
+~~~
+
+> router.php用于php自带webserver支持,可用于快速测试
+> 切换到public目录后,启动命令:php -S localhost:8888  router.php
+> 上面的目录结构和名称是可以改变的,这取决于你的入口文件和配置参数。
+
+## 命名规范
+
+`ThinkPHP5`遵循PSR-2命名规范和PSR-4自动加载规范,并且注意如下规范:
+
+### 目录和文件
+
+*   目录不强制规范,驼峰和小写+下划线模式均支持;
+*   类库、函数文件统一以`.php`为后缀;
+*   类的文件名均以命名空间定义,并且命名空间的路径和类库文件所在路径一致;
+*   类名和类文件名保持一致,统一采用驼峰法命名(首字母大写);
+
+### 函数和类、属性命名
+*   类的命名采用驼峰法,并且首字母大写,例如 `User`、`UserType`,默认不需要添加后缀,例如`UserController`应该直接命名为`User`;
+*   函数的命名使用小写字母和下划线(小写字母开头)的方式,例如 `get_client_ip`;
+*   方法的命名使用驼峰法,并且首字母小写,例如 `getUserName`;
+*   属性的命名使用驼峰法,并且首字母小写,例如 `tableName`、`instance`;
+*   以双下划线“__”打头的函数或方法作为魔法方法,例如 `__call` 和 `__autoload`;
+
+### 常量和配置
+*   常量以大写字母和下划线命名,例如 `APP_PATH`和 `THINK_PATH`;
+*   配置参数以小写字母和下划线命名,例如 `url_route_on` 和`url_convert`;
+
+### 数据表和字段
+*   数据表和字段采用小写加下划线方式命名,并注意字段名不要以下划线开头,例如 `think_user` 表和 `user_name`字段,不建议使用驼峰和中文作为数据表字段命名。
+
+## 参与开发
+请参阅 [ThinkPHP5 核心框架包](https://github.com/top-think/framework)。
+
+## 版权信息
+
+ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
+
+本项目包含的第三方源码和二进制文件之版权信息另行标注。
+
+版权所有Copyright © 2006-2017 by ThinkPHP (http://thinkphp.cn)
+
+All rights reserved。
+
+ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
+
+更多细节参阅 [LICENSE.txt](LICENSE.txt)

+ 1 - 0
application/.htaccess

@@ -0,0 +1 @@
+deny from all

+ 12 - 0
application/command.php

@@ -0,0 +1,12 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: yunwuxin <448901948@qq.com>
+// +----------------------------------------------------------------------
+
+return [];

+ 234 - 0
application/common.php

@@ -0,0 +1,234 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: 流年 <liu21st@gmail.com>
+// +----------------------------------------------------------------------
+
+// 应用公共文件
+/*微信小程序用
+ * code 成功
+ * 20210927
+ * wj
+ */
+
+function backjson($code, $data)
+{
+    $jsonData = [
+        'code' => $code,
+        'resultData' => $data,
+    ];
+    return json_encode($jsonData, 320);
+}
+/*app用
+ * 20210927
+ * wj
+ */
+function backjson2($code, $msg = "", $data = [])
+{
+    $jsonData = [
+        'code' => $code,
+        'msg' => $msg,
+        'data' => $data,
+    ];
+    return json_encode($jsonData, 336);
+}
+/* 内部使用
+ * 20210927
+ * wj
+ */
+function backarr($status, $msg = "", $data = [])
+{
+    $backData = [
+        'status' => $status,
+        'msg' => $msg,
+        'data' => $data,
+    ];
+    return $backData;
+}
+/***
+ * 获取订单号
+ * wj
+ * 20210911
+ */
+function createOrderNo()
+{
+    $ordrNo = date("YmdHis") . rand(0, 1000);
+    return $ordrNo;
+}
+/***
+ * 获取随机字符串
+ * wj
+ * 20210911
+ */
+function getRandomStrings($str = "")
+{
+    $str .= time();
+    return md5($str);
+}
+/***
+ * 判断是否为日期
+ * wj
+ * 20211013
+ */
+function isDate($date, $foramt)
+{
+    $date1 = $date;
+    $time = strtotime($date1);
+    if (!$time) {
+        return false;
+    }
+    $date2 = date($foramt, $time);
+    return $date1 == $date2;
+}
+
+//curl请求
+function requestCurl($url, $method = "get", $data = '', $header = [], $second = 10)
+{
+    $method = strtoupper($method);
+    $method = in_array($method, ['GET', 'POST']) ? $method : 'GET';
+
+    $ch = curl_init();
+    //设置超时
+    curl_setopt($ch, CURLOPT_TIMEOUT, $second);
+    curl_setopt($ch, CURLOPT_URL, $url);
+    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+
+    //要求结果为字符串且输出到屏幕上
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+
+    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //严格校验2
+    //设置header
+    curl_setopt($ch, CURLOPT_HEADER, false);
+    if (!empty($header)) {
+        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+    }
+    if ('POST' == $method) {
+        //$data = json_encode($data, JSON_UNESCAPED_UNICODE);
+        curl_setopt($ch, CURLOPT_POST, true);
+        if (is_array($data)) {
+            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, ''));
+        }
+        if (is_string($data)) {
+            curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
+        }
+    }
+    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //禁止 cURL 验证对等证书
+    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //是否检测服务器的域名与证书上的是否一致
+    //运行curl
+    $data = curl_exec($ch);
+    if (curl_errno($ch)) { //出错则显示错误信息
+        $error = curl_error($ch);
+        curl_close($ch);
+        return $error;
+    } else {
+        curl_close($ch);
+        return $data;
+    }
+}
+function arry_string($data)
+{
+    if (!is_array($data)) {
+        return false;
+    }
+    $usedata = [];
+    foreach ($data as $key => $value) {
+        if (!is_string($value) && !is_numeric($value)) {
+            return false;
+        }
+        $usedata[] = $key . '=' . $value;
+    }
+    $str = implode('&', $usedata);
+    return $str;
+}
+
+//根据身份证获取性别
+function getGenderBySfzid($sfzid)
+{
+    $gender = false;
+    switch (mb_strlen($sfzid)) {
+        case 15:
+            $genderNum = substr($sfzid, 14, 1);
+            break;
+        case 18:
+            $genderNum = substr($sfzid, 16, 1);
+            break;
+    }
+    if (($genderNum % 2) === 0) {
+        $gender = "女";
+    } else {
+        $gender = "男";
+    }
+    return $gender;
+}
+function getGenderByAge($sfzid)
+{
+    $birthday = substr($sfzid, 6, 8);
+    $bmd = substr($birthday, 4, 4);
+    $byear = substr($birthday, 0, 4);
+    $strtoday = date('Ymd');
+    $md = substr($strtoday, 4, 4);
+    $year = substr($strtoday, 0, 4);
+    $age = intval($year) - intval($byear);
+    if ($md < $bmd) {
+        $age = $age - 1;
+    }
+    return $age;
+}
+//获取身份证结束时间
+function getSfzend($sfzenddate)
+{
+    if (is_numeric($sfzenddate)) {
+        if (isDate($sfzenddate, "Ymd")) {
+            $strenddate = $sfzenddate;
+            $strendmonth = substr($strenddate, 4, 2);
+            $strendyear = substr($strenddate, 0, 4);
+            $strendday = substr($strenddate, 6, 2);
+            $sfzenddate = $strendyear . '-' . $strendmonth . '-' . $strendday;
+        } else {
+            $sfzenddate = '2050-12-31';
+        }
+    } else {
+        $sfzenddate = false;
+    }
+    return $sfzenddate;
+}
+//为cp后台请求验证token
+function checkToken()
+{
+    $l_w = new app\index\logic\webmanger();
+    $token = request()->server('HTTP_TOKEN');
+    $param = ['token' => $token];
+    $result = $l_w->queryinfobytoken($param);
+    if (1 != $result['status']) {
+        $str = backjson2(0, '登录失效', $result['data']);
+        exit($str);
+    }
+}
+//判断是否是手机号
+function isMoblid($tel)
+{
+    if (preg_match("/^1[3-9]{1}\d{9}$/", $tel)) {
+        return true;
+    } else {
+        return false;
+    }
+}
+
+//为移动端请求验证token
+/*function checkUserinfoToken()
+{
+$l_w = new app\index\logic\userinfomodel();
+$token = request()->server('HTTP_TOKEN');
+$param = ['token' => $token];
+$result = $l_w->queryinfobytoken($param);
+if (1 != $result['status']) {
+$str = backjson2(0, '登录失效', $result['data']);
+exit($str);
+}
+}*/

+ 240 - 0
application/config.php

@@ -0,0 +1,240 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: liu21st <liu21st@gmail.com>
+// +----------------------------------------------------------------------
+
+return [
+    // +----------------------------------------------------------------------
+    // | 应用设置
+    // +----------------------------------------------------------------------
+
+    // 应用调试模式
+    'app_debug' => true,
+    // 应用Trace
+    'app_trace' => false,
+    // 应用模式状态
+    'app_status' => '',
+    // 是否支持多模块
+    'app_multi_module' => true,
+    // 入口自动绑定模块
+    'auto_bind_module' => false,
+    // 注册的根命名空间
+    'root_namespace' => [],
+    // 扩展函数文件
+    'extra_file_list' => [THINK_PATH . 'helper' . EXT],
+    // 默认输出类型
+    'default_return_type' => 'html',
+    // 默认AJAX 数据返回格式,可选json xml ...
+    'default_ajax_return' => 'json',
+    // 默认JSONP格式返回的处理方法
+    'default_jsonp_handler' => 'jsonpReturn',
+    // 默认JSONP处理方法
+    'var_jsonp_handler' => 'callback',
+    // 默认时区
+    'default_timezone' => 'PRC',
+    // 是否开启多语言
+    'lang_switch_on' => false,
+    // 默认全局过滤方法 用逗号分隔多个
+    'default_filter' => 'htmlspecialchars,addslashes,strip_tags,trim',
+    // 默认语言
+    'default_lang' => 'zh-cn',
+    // 应用类库后缀
+    'class_suffix' => false,
+    // 控制器类后缀
+    'controller_suffix' => false,
+
+    // +----------------------------------------------------------------------
+    // | 模块设置
+    // +----------------------------------------------------------------------
+
+    // 默认模块名
+    'default_module' => 'index',
+    // 禁止访问模块
+    'deny_module_list' => ['common'],
+    // 默认控制器名
+    'default_controller' => 'Index',
+    // 默认操作名
+    'default_action' => 'index',
+    // 默认验证器
+    'default_validate' => '',
+    // 默认的空控制器名
+    'empty_controller' => 'Error',
+    // 操作方法后缀
+    'action_suffix' => '',
+    // 自动搜索控制器
+    'controller_auto_search' => false,
+
+    // +----------------------------------------------------------------------
+    // | URL设置
+    // +----------------------------------------------------------------------
+
+    // PATHINFO变量名 用于兼容模式
+    'var_pathinfo' => 's',
+    // 兼容PATH_INFO获取
+    'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'],
+    // pathinfo分隔符
+    'pathinfo_depr' => '/',
+    // URL伪静态后缀
+    'url_html_suffix' => 'html',
+    // URL普通方式参数 用于自动生成
+    'url_common_param' => false,
+    // URL参数方式 0 按名称成对解析 1 按顺序解析
+    'url_param_type' => 0,
+    // 是否开启路由
+    'url_route_on' => true,
+    // 路由使用完整匹配
+    'route_complete_match' => false,
+    // 路由配置文件(支持配置多个)
+    'route_config_file' => ['route'],
+    // 是否强制使用路由
+    'url_route_must' => false,
+    // 域名部署
+    'url_domain_deploy' => false,
+    // 域名根,如thinkphp.cn
+    'url_domain_root' => '',
+    // 是否自动转换URL中的控制器和操作名
+    'url_convert' => true,
+    // 默认的访问控制器层
+    'url_controller_layer' => 'controller',
+    // 表单请求类型伪装变量
+    'var_method' => '_method',
+    // 表单ajax伪装变量
+    'var_ajax' => '_ajax',
+    // 表单pjax伪装变量
+    'var_pjax' => '_pjax',
+    // 是否开启请求缓存 true自动缓存 支持设置请求缓存规则
+    'request_cache' => false,
+    // 请求缓存有效期
+    'request_cache_expire' => null,
+    // 全局请求缓存排除规则
+    'request_cache_except' => [],
+
+    // +----------------------------------------------------------------------
+    // | 模板设置
+    // +----------------------------------------------------------------------
+
+    'template' => [
+        // 模板引擎类型 支持 php think 支持扩展
+        'type' => 'Think',
+        // 模板路径
+        'view_path' => '',
+        // 模板后缀
+        'view_suffix' => 'html',
+        // 模板文件名分隔符
+        'view_depr' => DS,
+        // 模板引擎普通标签开始标记
+        'tpl_begin' => '{',
+        // 模板引擎普通标签结束标记
+        'tpl_end' => '}',
+        // 标签库标签开始标记
+        'taglib_begin' => '{',
+        // 标签库标签结束标记
+        'taglib_end' => '}',
+    ],
+
+    // 视图输出字符串内容替换
+    'view_replace_str' => [],
+    // 默认跳转页面对应的模板文件
+    'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
+    'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
+
+    // +----------------------------------------------------------------------
+    // | 异常及错误设置
+    // +----------------------------------------------------------------------
+
+    // 异常页面的模板文件
+    'exception_tmpl' => THINK_PATH . 'tpl' . DS . 'think_exception.tpl',
+
+    // 错误显示信息,非调试模式有效
+    'error_message' => '页面错误!请稍后再试~',
+    // 显示错误信息
+    'show_error_msg' => false,
+    // 异常处理handle类 留空使用 \think\exception\Handle
+    'exception_handle' => '',
+
+    // +----------------------------------------------------------------------
+    // | 日志设置
+    // +----------------------------------------------------------------------
+
+    'log' => [
+        // 日志记录方式,内置 file socket 支持扩展
+        'type' => 'File',
+        // 日志保存目录
+        'path' => LOG_PATH,
+        // 日志记录级别
+        'level' => [],
+    ],
+
+    // +----------------------------------------------------------------------
+    // | Trace设置 开启 app_trace 后 有效
+    // +----------------------------------------------------------------------
+    'trace' => [
+        // 内置Html Console 支持扩展
+        'type' => 'Html',
+    ],
+
+    // +----------------------------------------------------------------------
+    // | 缓存设置
+    // +----------------------------------------------------------------------
+
+    'cache' => [
+        // 驱动方式
+        'type' => 'File',
+        // 缓存保存目录
+        'path' => CACHE_PATH,
+        // 缓存前缀
+        'prefix' => '',
+        // 缓存有效期 0表示永久缓存
+        'expire' => 0,
+    ],
+
+    // +----------------------------------------------------------------------
+    // | 会话设置
+    // +----------------------------------------------------------------------
+
+    'session' => [
+        'id' => '',
+        // SESSION_ID的提交变量,解决flash上传跨域
+        'var_session_id' => '',
+        // SESSION 前缀
+        'prefix' => 'think',
+        // 驱动方式 支持redis memcache memcached
+        'type' => '',
+        // 是否自动开启 SESSION
+        'auto_start' => true,
+    ],
+
+    // +----------------------------------------------------------------------
+    // | Cookie设置
+    // +----------------------------------------------------------------------
+    'cookie' => [
+        // cookie 名称前缀
+        'prefix' => '',
+        // cookie 保存时间
+        'expire' => 0,
+        // cookie 保存路径
+        'path' => '/',
+        // cookie 有效域名
+        'domain' => '',
+        //  cookie 启用安全传输
+        'secure' => false,
+        // httponly设置
+        'httponly' => '',
+        // 是否使用 setcookie
+        'setcookie' => true,
+    ],
+
+    //分页配置
+    'paginate' => [
+        'type' => 'bootstrap',
+        'var_page' => 'page',
+        'list_rows' => 15,
+    ],
+
+];

+ 58 - 0
application/database.php

@@ -0,0 +1,58 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: liu21st <liu21st@gmail.com>
+// +----------------------------------------------------------------------
+
+return [
+    // 数据库类型
+    'type' => 'mysql',
+    // 服务器地址
+    //  'hostname'        => '103.236.252.194',
+    //'hostname' => '42.193.106.113',
+    'hostname' => '127.0.0.1',
+    // 数据库名
+    //'database' => 'watercat_dev',
+    'database' => 'watercat',
+    // 用户名
+    'username' => 'root',
+    // 密码
+    // 'password'        => 'watercat2019',
+    'password' => 'zhonghui0123',
+    // 端口
+    'hostport' => '3306',
+    // 连接dsn
+    'dsn' => '',
+    // 数据库连接参数
+    'params' => [],
+    // 数据库编码默认采用utf8
+    'charset' => 'utf8mb4',
+    // 数据库表前缀
+    'prefix' => '',
+    // 数据库调试模式
+    'debug' => true,
+    // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
+    'deploy' => 0,
+    // 数据库读写是否分离 主从式有效
+    'rw_separate' => false,
+    // 读写分离后 主服务器数量
+    'master_num' => 1,
+    // 指定从服务器序号
+    'slave_no' => '',
+    // 是否严格检查字段是否存在
+    'fields_strict' => true,
+    // 数据集返回类型
+    //'resultset_type' => 'array',
+    'resultset_type' => '\think\Collection',
+    // 自动写入时间戳字段
+    'auto_timestamp' => false,
+    // 时间字段取出后的默认时间格式
+    'datetime_format' => 'Y-m-d H:i:s',
+    // 是否需要进行SQL性能分析
+    'sql_explain' => false,
+];

+ 54 - 0
application/extra/database_labourunion.php

@@ -0,0 +1,54 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: liu21st <liu21st@gmail.com>
+// +----------------------------------------------------------------------
+
+return [
+	// 数据库类型
+	'type' => 'mysql',
+	// 服务器地址
+	'hostname' => '42.193.106.113',
+	// 数据库名
+	'database' => 'labourunion_opr',
+	// 用户名
+	'username' => 'root',
+	// 密码
+	//'password'        => 'watercat2019',
+	'password' => 'zhonghui0123',
+	// 端口
+	'hostport' => '3306',
+	// 连接dsn
+	'dsn' => '',
+	// 数据库连接参数
+	'params' => [],
+	// 数据库编码默认采用utf8
+	'charset' => 'utf8',
+	// 数据库表前缀
+	'prefix' => '',
+	// 数据库调试模式
+	'debug' => true,
+	// 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
+	'deploy' => 0,
+	// 数据库读写是否分离 主从式有效
+	'rw_separate' => false,
+	// 读写分离后 主服务器数量
+	'master_num' => 1,
+	// 指定从服务器序号
+	'slave_no' => '',
+	// 是否严格检查字段是否存在
+	'fields_strict' => true,
+	// 数据集返回类型
+	'resultset_type' => 'array',
+	// 自动写入时间戳字段
+	'auto_timestamp' => false,
+	// 时间字段取出后的默认时间格式
+	'datetime_format' => 'Y-m-d H:i:s',
+	// 是否需要进行SQL性能分析
+	'sql_explain' => false,
+];

+ 54 - 0
application/extra/database_labouruniondev.php

@@ -0,0 +1,54 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: liu21st <liu21st@gmail.com>
+// +----------------------------------------------------------------------
+
+return [
+	// 数据库类型
+	'type' => 'mysql',
+	// 服务器地址
+	'hostname' => '42.193.106.113',
+	// 数据库名
+	'database' => 'labourunion_dev',
+	// 用户名
+	'username' => 'root',
+	// 密码
+	//'password'        => 'watercat2019',
+	'password' => 'zhonghui0123',
+	// 端口
+	'hostport' => '3306',
+	// 连接dsn
+	'dsn' => '',
+	// 数据库连接参数
+	'params' => [],
+	// 数据库编码默认采用utf8
+	'charset' => 'utf8',
+	// 数据库表前缀
+	'prefix' => '',
+	// 数据库调试模式
+	'debug' => true,
+	// 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
+	'deploy' => 0,
+	// 数据库读写是否分离 主从式有效
+	'rw_separate' => false,
+	// 读写分离后 主服务器数量
+	'master_num' => 1,
+	// 指定从服务器序号
+	'slave_no' => '',
+	// 是否严格检查字段是否存在
+	'fields_strict' => true,
+	// 数据集返回类型
+	'resultset_type' => 'array',
+	// 自动写入时间戳字段
+	'auto_timestamp' => false,
+	// 时间字段取出后的默认时间格式
+	'datetime_format' => 'Y-m-d H:i:s',
+	// 是否需要进行SQL性能分析
+	'sql_explain' => false,
+];

+ 14 - 0
application/extra/queue.php

@@ -0,0 +1,14 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: yunwuxin <448901948@qq.com>
+// +----------------------------------------------------------------------
+
+return [
+    'connector' => 'Sync'
+];

+ 323 - 0
application/index/controller/Index.php

@@ -0,0 +1,323 @@
+<?php
+namespace app\index\controller;
+
+use app\index\logic\wxBizDataCrypt;
+use app\index\model\memodel;
+use think\Log;
+
+class Index
+{
+    public function index()
+    {
+        return '<style type="text/css">*{ padding: 0; margin: 0; } .think_default_text{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p> ThinkPHP V5<br/><span style="font-size:30px">这是8116labourunion</span></p><span style="font-size:22px;">[ V5.0 版本由 <a href="http://www.qiniu.com" target="qiniu">七牛云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="https://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script><script type="text/javascript" src="https://e.topthink.com/Public/static/client.js"></script><think id="ad_bd568ce7058a1091"></think>';
+    }
+
+    public function getOpenid()
+    {
+        $userinfo = request()->param();
+        $code = $userinfo['code'];
+
+        $appid = 'wxcacf6eb6e7478e29';
+        $appSecret = '3722c3f95df0569498a0e32ae6e85153';
+
+        $wxUrl = 'https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code';
+        $getUrl = sprintf($wxUrl, $appid, $appSecret, $code);
+
+//        echo $getUrl;
+
+        $result = $this->curl_get($getUrl);
+        //  echo $result;
+        $wxResult = json_decode($result, true);
+        if (empty($wxResult)) {
+            $res_r['code'] = 200;
+            $res_r['errmsg'] = '错误';
+            return json($res_r);
+        } else {
+            $logfail = array_key_exists('errcode', $wxResult);
+            if ($logfail) {
+                var_dump($wxResult);
+                Log::write(json_encode($wxResult));
+            } else {
+                $openid = $wxResult['openid'];
+                // $unionid=null;
+                $unionid = '';
+                if (array_key_exists('unionid', $wxResult)) {
+                    $unionid = $wxResult['unionid'];
+                } else {
+                    Log::write(json_encode($wxResult));
+                }
+                $res_r['code'] = 200;
+                $res_r['resultData']['openId'] = $openid;
+                $res_r['resultData']['openid'] = $openid;
+                if (array_key_exists('unionid', $wxResult)) {
+                    $res_r['resultData']['unionid'] = $unionid;
+                    $t_m = new memodel();
+                    $urec = $t_m->getinfobyopenid($openid);
+                    if ($urec) {
+                        if (!$urec['union_id']) {
+                            $t_m->updunionidbyopenid($openid, $unionid);
+                        }
+                    }
+                }
+
+                return json($res_r);
+//                   return json($wxResult);
+            }
+        }
+    }
+
+    public function curl_get($url, &$httpCode = 0)
+    {
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+
+        //不做证书校验,部署在linux环境下请改为true
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
+        $file_contents = curl_exec($ch);
+        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+        curl_close($ch);
+        return $file_contents;
+    }
+
+    public function getAccessToken()
+    {
+        $appid = 'wxcacf6eb6e7478e29';
+        $appSecret = '3722c3f95df0569498a0e32ae6e85153';
+        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $appSecret;
+        //echo $url;
+        $result = $this->curl_get($url);
+        //echo $result;
+        $wxResult = json_decode($result, true);
+        //echo $wxResult['access_token'];
+        return $wxResult;
+    }
+    public function getAccessTokenWCGZH()
+    {
+        $appid = 'wxc77d58456db8082b'; //服务号
+        $appSecret = '456c9c2a328b3bee5001f2326d862916';
+        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $appSecret;
+        //echo $url;
+        $result = $this->curl_get($url);
+        //echo $result;
+        $wxResult = json_decode($result, true);
+        //echo $wxResult['access_token'];
+        return $wxResult;
+    }
+
+    //获得二维码
+    public function create_qrcode()
+    {
+
+        $sharepage = request()->param();
+
+        $qr_path = "./Uploads/";
+        if (!file_exists($qr_path . 'user/')) {
+            mkdir($qr_path . 'user/', 0700, true); //判断保存目录是否存在,不存在自动生成文件目录
+        }
+        $filename = 'user/' . time() . '.png';
+        $file = $qr_path . $filename;
+
+        $access = $this->getAccessToken(); //json_decode($this->getAccessToken(),true);
+        $access_token = $access['access_token'];
+        $url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $access_token;
+
+        $qrcode = array(
+            'scene' => $sharepage['scene'], //二维码所带参数
+            'width' => 200,
+            'page' => $sharepage['page'], //二维码跳转路径(要已发布小程序)
+            'auto_color' => true,
+        );
+
+        $result = $this->sendCmd($url, json_encode($qrcode)); //请求微信接口
+
+        $errcode = json_decode($result, true)['errcode'];
+        $errmsg = json_decode($result, true)['errmsg'];
+        if ($errcode) {
+            echo $errcode;
+            echo $errmsg;
+            //$this->render(0,$errmsg);
+        }
+
+        $res = file_put_contents($file, $result); //将微信返回的图片数据流写入文件
+
+        if ($res === false) {
+            echo '生成二维码失败';
+            // $this->render(0,'生成二维码失败');
+        } else {
+            $result_qrcode['resultData'] = '127.0.0.1:8094/Uploads/' . $filename;
+            $result_qrcode['code'] = '200';
+            return json_encode($result_qrcode);
+            //$this->return['data'] = $this->config->item('base_url').'/Uploads/'.$filename;//返回图片地址链接给前端
+        }
+    }
+    //开启curl post请求
+    public function sendCmd($url, $data)
+    {
+        $curl = curl_init(); // 启动一个CURL会话
+        curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
+        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检测
+        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); // 从证书中检查SSL加密算法是否存在
+        curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect:')); //解决数据包大不能提交
+        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
+        curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer
+        curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
+        curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
+        curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循
+        curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
+
+        $tmpInfo = curl_exec($curl); // 执行操作
+        if (curl_errno($curl)) {
+            echo 'Errno' . curl_error($curl);
+        }
+        curl_close($curl); // 关键CURL会话
+        return $tmpInfo; // 返回数据
+    }
+    public function getticket()
+    {
+        $access = $this->getAccessTokenWCGZH();
+        $access_token = $access['access_token'];
+        $url = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=' . $access_token;
+        $result = $this->sendCmd($url, []);
+        $result_arr = json_decode($result, true);
+        if ('ok' != $result_arr['errmsg']) {
+            echo 'error:' . $result_arr['errmsg'];
+            exit;
+        }
+        $ticket = $result_arr['ticket'];
+        return $ticket;
+    }
+//网上代骊,待修改
+    public function WxDecode()
+    {
+
+        // 接收参数
+        $data = request()->param();
+
+        // 引入解密文件 在微信小程序开发文档下载
+        // vendor('wx.WXBizDataCrypt');
+        //vendor('wx.ErrorCode');
+        //
+        //        $appid = config('APPID');
+        //        $appsecret = config('APPSECREET');
+        $appid = 'wxcacf6eb6e7478e29';
+        $appsecret = '3722c3f95df0569498a0e32ae6e85153';
+
+        $grant_type = "authorization_code"; //授权(必填)
+
+        $code = $data['code']; //有效期5分钟 登录会话
+
+        $encryptedData = $data['encryptedData'];
+        $iv = $data['iv'];
+//        $signature = $data['signature'];
+        //        $rawData = $data['rawData'];
+
+        // 拼接url
+        $url = "https://api.weixin.qq.com/sns/jscode2session?" . "appid=" . $appid . "&secret=" . $appsecret . "&js_code=" . $code . "&grant_type=" . $grant_type;
+        $res = json_decode($this->curl_get($url), true);
+        // var_dump($res);
+
+        $sessionKey = $res['session_key']; //取出json里对应的值
+        //        $signature2 =  sha1(htmlspecialchars_decode($rawData).$sessionKey);
+        //        // 验证签名
+        //        if ($signature2 !== $signature){
+        //            return json("验签失败");
+        //        }
+
+        $pc = new wxBizDataCrypt($appid, $sessionKey);
+
+        $errCode = $pc->decryptData($encryptedData, $iv, $data);
+
+        // var_dump($data);
+        //这里是按二手设备做的,以后应该单独变成逻辑,由逻辑层完成,以应对不同的需求
+        if ($errCode == 0) {
+            $result['code'] = 200;
+            $resultData['msg'] = '解密成功';
+            $resultData['userInfo'] = json_decode($data);
+            $result['resultData'] = $resultData;
+            echo json_encode($result);
+            // exit(json_encode($data,JSON_UNESCAPED_UNICODE));
+
+        } else {
+            return json($errCode);
+        }
+    }
+
+    //获得二维码
+    public function download_qrcode()
+    {
+
+        $sharepage = request()->param();
+
+        $qr_path = "./Uploads/";
+        if (!file_exists($qr_path . 'user/')) {
+            mkdir($qr_path . 'user/', 0700, true); //判断保存目录是否存在,不存在自动生成文件目录
+        }
+        $filename = 'user/' . time() . '.png';
+        $file = $qr_path . $filename;
+
+        $access = $this->getAccessToken(); //json_decode($this->getAccessToken(),true);
+        $access_token = $access['access_token'];
+        $url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $access_token;
+
+        $qrcode = array(
+            'scene' => $sharepage['scene'], //二维码所带参数
+            'width' => 200,
+            'page' => $sharepage['page'], //二维码跳转路径(要已发布小程序)
+            'auto_color' => true,
+        );
+
+        $result = $this->sendCmd($url, json_encode($qrcode)); //请求微信接口
+
+        $errcode = json_decode($result, true)['errcode'];
+        $errmsg = json_decode($result, true)['errmsg'];
+        if ($errcode) {
+            echo $errcode;
+            echo $errmsg;
+            //$this->render(0,$errmsg);
+        }
+
+        $res = file_put_contents($file, $result); //将微信返回的图片数据流写入文件
+
+        $strfile = 'Uploads/' . $filename;
+        //echo $strfile;
+
+        $file1 = fopen($strfile, 'r');
+
+        header("Content-Type: application/force-download");
+        header("Content-Type: application/octet-stream");
+        header("Content-Type: application/download");
+        header('Content-Disposition:inline;filename="' . $strfile . '"');
+
+        ob_clean();
+        flush();
+
+        echo fread($file1, filesize($file));
+        fclose($file1);
+
+        // $result->save('php://output');
+
+        if ($res === false) {
+            echo '生成二维码失败';
+            // $this->render(0,'生成二维码失败');
+        } else {
+            $result_qrcode['resultData'] = 'https://app.gasgrid.cn::21443/Uploads/' . $filename;
+            $result_qrcode['code'] = '200';
+
+            return json_encode($result_qrcode);
+            //$this->return['data'] = $this->config->item('base_url').'/Uploads/'.$filename;//返回图片地址链接给前端
+        }
+    }
+    public function getsharedata()
+    {
+        $appid = 'wxc77d58456db8082b'; //服务号
+        $ticket = $this->getticket();
+        $timestamp = time();
+        $nonceStr = getRandomStrings();
+        $data = ['ticket' => $ticket, 'timestamp' => $timestamp, 'nonceStr' => $nonceStr, 'appid' => $appid];
+        return $data;
+    }
+
+}

+ 100 - 0
application/index/controller/Party.php

@@ -0,0 +1,100 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-11-18 13:51:19
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-29 14:49:22
+ */
+
+namespace app\index\controller;
+
+use app\index\logic\partylogic;
+use think\Controller;
+
+class Party extends Controller
+{
+    /**
+     * 用于参与活动
+     * wj
+     * 20220112
+     *
+     * @return void
+     */
+    public function partinparty()
+    {
+        $param = request()->param();
+        $l_p = new partylogic();
+        $result = $l_p->partinparty($param);
+        if (1 != $result['status']) {
+            return backjson2($result['status'], $result['msg']);
+        }
+        return backjson2(200, '操作成功', $result['data']);
+    }
+    /**
+     * 保存用户信息
+     * wj
+     * 20220112
+     *
+     * @return void
+     */
+    public function saveinfo()
+    {
+        $param = request()->param();
+        $l_p = new partylogic();
+        $result = $l_p->saveinfo($param);
+        if (1 != $result['status']) {
+            return backjson2(0, $result['msg'] );
+        }
+        return backjson2(200, '操作成功', $result['data']);
+    }
+    /**
+     * 保存用户图片
+     * wj
+     * 20220112
+     *
+     * @return void
+     */
+    public function savepicture()
+    {
+        $param = request()->param();
+        $l_p = new partylogic();
+        $result = $l_p->savepicture($param);
+        if (1 != $result['status']) {
+            return backjson2(0, $result['msg']);
+        }
+        return backjson2(200,"success",$result['data']);
+    }
+    /**
+     * 获取用户图片
+     * wj
+     * 20220112
+     *
+     * @return void
+     */
+    public function getpicture()
+    {
+        $param = request()->param();
+        $l_p = new partylogic();
+        $result = $l_p->getpicture($param);
+        if (1 != $result['status']) {
+            return backjson2(0, $result['msg']);
+        }
+        return backjson2(200,"查询成功", $result['data']);
+    }
+    /**
+     * 用户完成活动
+     * wj
+     * 20220114
+     *
+     * @return void
+     */
+    public function setisoverbyid(){
+        $param = request()->param();
+        $l_p = new partylogic();
+        $result = $l_p->setisoverbyid($param);
+        if (1 != $result['status']) {
+            return backjson2(0, $result['msg']);
+        }
+        return backjson2(200,"查询成功", $result['data']);
+    }
+}

+ 133 - 0
application/index/logic/businesslogic.php

@@ -0,0 +1,133 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:16:29
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-23 17:42:01
+ */
+
+namespace app\index\logic;
+
+use app\index\server\businessserver;
+use think\Log;
+
+class businesslogic
+{
+    //新增延后操作
+    public function newbusiness()
+    {
+    }
+    /**
+     * 积分业务处理
+     * 20220104
+     * wj
+     * */
+    public function handlescorebusinessforopenid($arr)
+    {
+        try {
+
+            $fillfields = ['openid', 'type', 'typeid'];
+            foreach ($fillfields as $key => $value) {
+                if (!isset($arr[$value]) || empty($arr[$value]) || !is_string((string) $arr[$value])) {
+                    return backarr(0, "业务处理,请求失败");
+                }
+            }
+            $type = $arr['type'];
+            $kind = 'score';
+            $s_b = new businessserver();
+            $serverobj = $s_b->getserverobj($kind, $type);
+            if (!$serverobj) {
+                return backarr(0, "无对应处理");
+            }
+            $result = $serverobj->dobusiness($arr);
+            return $result;
+        } catch (\Exception $e) {
+            $msg = $e->getMessage();
+            Log::error($msg);
+            Log::error($e->getTraceAsString());
+            return backarr(0, $msg);
+        }
+    }
+    public function handlescorebusinessforuserid($arr)
+    {
+        try {
+            $fillfields = ['userid', 'type', 'typeid'];
+            foreach ($fillfields as $key => $value) {
+                if (!isset($arr[$value]) || empty($arr[$value]) || !is_string((string) $arr[$value])) {
+                    return backarr(0, "业务处理,请求失败");
+                }
+            }
+            $type = $arr['type'];
+            $kind = 'score';
+            $s_b = new businessserver();
+            $serverobj = $s_b->getserverobj($kind, $type);
+            if (!$serverobj) {
+                return backarr(0, "无对应处理");
+            }
+            $result = $serverobj->dobusiness($arr);
+            return $result;
+        } catch (\Exception $e) {
+            $msg = $e->getMessage();
+            Log::error($msg);
+            Log::error($e->getTraceAsString());
+            return backarr(0, $msg);
+        }
+    }
+    public function handlescorebusiness($arr)
+    {
+        try {
+            $fillfields = ['type', 'typeid'];
+            foreach ($fillfields as $key => $value) {
+                if (!isset($arr[$value]) || empty($arr[$value]) || !is_string((string) $arr[$value])) {
+                    return backarr(0, "业务处理,请求失败");
+                }
+            }
+            $type = $arr['type'];
+            $kind = 'score';
+            $s_b = new businessserver();
+            $serverobj = $s_b->getserverobj($kind, $type);
+            if (!$serverobj) {
+                return backarr(0, "无对应处理");
+            }
+            $result = $serverobj->dobusiness($arr);
+            return $result;
+        } catch (\Exception $e) {
+            $msg = $e->getMessage();
+            Log::error($msg);
+            Log::error($e->getTraceAsString());
+            return backarr(0, $msg);
+        }
+    }
+    /**
+     * 处理活动业务 仅使用userid
+     *
+     * @param [array] $arr
+     * @return array
+     */
+    public function handlepartybusiness($arr)
+    {
+        try {
+            $fillfields = ['type', 'typeid'];
+            foreach ($fillfields as $key => $value) {
+                if (!isset($arr[$value]) || empty($arr[$value]) || !is_string((string) $arr[$value])) {
+                    return backarr(0, "业务处理,请求失败");
+                }
+            }
+            $type = $arr['type'];
+            $kind = 'party';
+            $s_b = new businessserver();
+            $serverobj = $s_b->getserverobj($kind, $type);
+            if (!$serverobj) {
+                return backarr(0, "无对应处理");
+            }
+            $result = $serverobj->dobusiness($arr);
+            return $result;
+        } catch (\Exception $e) {
+            $code = $e->getCode();
+            $msg = $e->getMessage();
+            Log::error($msg);
+            Log::error($e->getTraceAsString());
+            return backarr($code, $msg);
+        }
+    }
+}

+ 285 - 0
application/index/logic/companylogic.php

@@ -0,0 +1,285 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:16:29
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-09 16:21:40
+ */
+namespace app\index\logic;
+
+use app\index\model\companymodel;
+use app\index\model\userinfomodel;
+
+class companylogic
+{
+    /**
+     * 新增企业
+     * 20211221
+     * wj
+     */
+    public function newinfo($info)
+    {
+        if (!isset($info['userid']) || empty($info['userid'])) {
+            return backarr(0, "请求失败");
+        }
+        $m_u = new userinfomodel();
+        $m_c = new companymodel();
+        $userid = $info['userid'];
+        //userid 去重
+        $cinfo = $m_c->getInfo(['userid' => $userid, 'isactive' => 1], ['id']);
+        if (!empty($cinfo)) {
+            return backarr(0, "用户id已存在");
+        }
+        $uinfo = $m_u->getInfo(['id' => $userid], 'id');
+        if (empty($uinfo)) {
+            return backarr(0, "无数据");
+        }
+        //tel 去重
+        if (isset($info['telno']) && !empty($info['telno'])) {
+            $telno = $info['telno'];
+            $cinfo = $m_c->getInfo(['telno' => $telno, 'isactive' => 1], ['id']);
+            if ($cinfo) {
+                return backarr(0, "手机号已存在");
+            }
+        }
+        if (!isset($info['createtime']) || empty($info['createtime'])) {
+            $info['createtime'] = date('Y-m-d H:i:s', time());
+        }
+        $id = $m_c->insertData($info);
+        if (!$id) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    /**
+     * 改详细信息
+     * 20211221
+     * wj
+     */
+    public function updateinfo($arr)
+    {
+        if (!isset($arr['id']) || empty($arr['id'])) {
+            return backarr(0, "请求失败");
+        }
+        $m_c = new companymodel();
+        $m_u = new userinfomodel();
+        $id = $arr['id'];
+        $where = ['id' => $id];
+        $cinfo = $m_c->getInfo($where);
+        if (empty($cinfo)) {
+            return backarr(0, "无数据");
+        }
+        $updateField = ['company', 'legalperson', 'telno'];
+        $updateData = [];
+        if (isset($arr['company']) && $cinfo['company'] != $arr['company']) {
+            $updateData['company'] = $arr['company'];
+        }
+        if (isset($arr['legalperson']) && $cinfo['legalperson'] != $arr['legalperson']) {
+            $updateData['legalperson'] = $arr['legalperson'];
+        }
+        if (isset($arr['telno']) && $cinfo['telno'] != $arr['telno']) {
+            $telno = $arr['telno'];
+            if (!isMoblid($telno)) {
+                return backarr(0, "手机号格式错误");
+            }
+            $ccinfo = $m_c->getInfo(['telno' => $telno, 'isactive' => 1]);
+            if (!empty($ccinfo)) {
+                return backarr(0, "手机号已存在");
+            }
+            //$uupateData = ['telno' => $telno];
+            //$uwhere = ['id' => $cinfo['userid']];
+            //$uinfo = $m_u->getInfo($uwhere);
+            //$row = $m_u->updateinfo($uwhere, $uupateData);
+            /*$enterprisename = isset($updateData['company']) ? $updateData['company'] : $uinfo['enterprisename'];
+            if (empty($uinfo)) {
+            $insertData = [
+            'telno' => $telno,
+            'enterprisename' => $enterprisename,
+            ];
+            $userid = $m_u->insertData($insertData);
+            } else {
+            $userid = $uinfo['id'];
+            }*/
+            /*if (empty($row)) {
+            return backarr(0, "用户信息修改失败");
+            }*/
+            $updateData['telno'] = $telno;
+        }
+        if (empty($updateData)) {
+            return backarr(0, "无修改数据");
+        }
+        $row = $m_c->updateinfo($where, $updateData);
+        if (!$row) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    /**
+     * 获取信息根据id
+     * 20211221
+     * wj
+     */
+    public function getinfobyid($arr)
+    {
+        if (!isset($arr['id']) || empty($arr['id'])) {
+            return backarr(0, "请求失败");
+        }
+        $id = $arr['id'];
+        $m_c = new companymodel();
+        $where = ['id' => $id];
+        $cinfo = $m_c->getInfo($where);
+        if (empty($cinfo)) {
+            return backarr(0, "无数据");
+        }
+        return backarr(1, "操作成功", $cinfo);
+    }
+    /**
+     * 获取信息根据userid
+     * 20211221
+     * wj
+     */
+    public function getinfobyuserid($arr)
+    {
+        if (!isset($arr['userid']) || empty($arr['userid'])) {
+            return backarr(0, "请求失败");
+        }
+        $userid = $arr['userid'];
+        $m_c = new companymodel();
+        $where = ['userid' => $userid];
+        $cinfo = $m_c->getInfo($where);
+        if (empty($cinfo)) {
+            return backarr(0, "无数据");
+        }
+        return backarr(1, "操作成功", $cinfo);
+    }
+    /**
+     * 修改ispass根据id
+     * 20211221
+     * wj
+     */
+    public function updateispassbyid($arr)
+    {
+        if (!isset($arr['idlist']) || empty($arr['idlist']) || !is_array($arr['idlist']) ||
+            !isset($arr['ispass']) || !in_array($arr['ispass'], [1, 2])) {
+            return backarr(0, "请求失败");
+        }
+        $idlist = $arr['idlist'];
+        $ispass = $arr['ispass'];
+        $m_c = new companymodel();
+        $where = ['id' => ['in', $idlist], 'isactive' => 1];
+        switch ($ispass) {
+            case 1:
+                $where['ispass'] = ['in', [0, 2]];
+                break;
+            case 2:
+                $where['ispass'] = ['in', [0]];
+                break;
+        }
+        /*$cinfo = $m_c->getInfo($where);
+        if (empty($cinfo)) {
+        return backarr(0, "无数据");
+        }
+        $updateData = [];
+        if (in_array($cinfo['ispass'], [0, 2]) && 1 == $ispass) {
+        $updateData['ispass'] = $ispass;
+        } elseif (in_array($cinfo['ispass'], [0]) && 2 == $ispass) {
+        $updateData['ispass'] = $ispass;
+        }
+        if (empty($updateData)) {
+        return backarr(0, "无修改数据");
+        }*/
+        $updateData = [
+            'ispass' => $ispass,
+            'passtime' => date('Y-m-d H:i:s'),
+        ];
+        $row = $m_c->updateinfo($where, $updateData);
+        if (!$row) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['idlist' => $idlist, 'ispass' => $ispass]);
+    }
+    /**
+     * 修改isactive根据id
+     * 20211221
+     * wj
+     */
+    public function updateisactivebyid($arr)
+    {
+        if (!isset($arr['id']) || empty($arr['id']) || !isset($arr['isactive']) || !in_array($arr['isactive'], [0, 1])) {
+            return backarr(0, "请求失败");
+        }
+        $id = $arr['id'];
+        $isactive = $arr['isactive'];
+        $m_c = new companymodel();
+        $where = ['id' => $id];
+        $cinfo = $m_c->getInfo($where);
+        if (empty($cinfo)) {
+            return backarr(0, "无数据");
+        }
+        $updateData = [];
+        if ($isactive !== $cinfo['isactive']) {
+            $updateData['isactive'] = $isactive;
+        }
+        if (empty($updateData)) {
+            return backarr(1, "无修改", ['id' => $id]);
+        }
+        $row = $m_c->updateinfo($where, $updateData);
+        if (!$row) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id, 'isactive' => $isactive]);
+    }
+
+    /***
+     * 获取列表
+     * 20211221
+     * wj
+     */
+    public function getlistbywhere($arr)
+    {
+        $m_c = new companymodel();
+        $m_u = new userinfomodel();
+        $where = [];
+        if (isset($arr['company']) && !empty($arr['company'])) {
+            $where['company'] = $arr['company'];
+        }
+        if (isset($arr['wname']) && !empty($arr['wname'])) {
+            $where['wname'] = $arr['wname'];
+        }
+        if (isset($arr['telno']) && !empty($arr['telno'])) {
+            $where['telno'] = $arr['telno'];
+        }
+        if (isset($arr['isactive']) && is_numeric($arr['isactive']) && in_array($arr['isactive'], [0, 1])) {
+            $where['isactive'] = $arr['isactive'];
+        }
+        if (isset($arr['ispass']) && is_numeric($arr['ispass']) && in_array($arr['ispass'], [0, 1, 2])) {
+            $where['ispass'] = $arr['ispass'];
+        }
+        if (isset($arr['createtime']) && is_array($arr['createtime'])) {
+            $createtime = array_filter($arr['createtime']);
+            if (2 == count($createtime)) {
+                $where['createtime'] = $arr['createtime'];
+            }
+        }
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $count = $m_c->getList($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_c->getList($where, '*', $page, $size);
+        foreach ($list as $key => &$value) {
+            $uinfo = $m_u->getInfo(['id' => $value['userid']], 'wname');
+            if (empty($uinfo)) {
+                $list[$key]['wname'] = '';
+            } else {
+                $list[$key]['wname'] = $uinfo['wname'];
+            }
+        }
+        $data = [
+            'count' => $count,
+            'list' => $list,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+}

+ 23 - 0
application/index/logic/errorCode.php

@@ -0,0 +1,23 @@
+<?php
+namespace app\index\logic;
+/**
+ * error code 说明.
+ * <ul>
+
+ *    <li>-41001: encodingAesKey 非法</li>
+ *    <li>-41003: aes 解密失败</li>
+ *    <li>-41004: 解密后得到的buffer非法</li>
+ *    <li>-41005: base64加密失败</li>
+ *    <li>-41016: base64解密失败</li>
+ * </ul>
+ */
+class errorCode
+{
+	public static $OK = 0;
+	public static $IllegalAesKey = -41001;
+	public static $IllegalIv = -41002;
+	public static $IllegalBuffer = -41003;
+	public static $DecodeBase64Error = -41004;
+}
+
+?>

+ 79 - 0
application/index/logic/evaluatelogic.php

@@ -0,0 +1,79 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2021/11/18
+ * Time: 14:31
+ */
+namespace app\index\logic;
+
+use app\index\model\evaluatemodel;
+use app\index\model\inventmodel;
+use app\index\model\jobhuntingmodel;
+
+class evaluatelogic
+{
+    /*
+     * 获取评论列表
+     * 20211214
+     * wj
+     */
+    public function getlistforadmin($arr)
+    {
+        $m_e = new evaluatemodel();
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $where = [];
+        if (isset($arr['wname']) && !empty($arr['wname']) && is_string($arr['wname'])) {
+            $where['wname'] = $arr['wname'];
+        }
+        if (isset($arr['telno']) && !empty($arr['telno']) && is_numeric($arr['telno'])) {
+            $where['telno'] = $arr['telno'];
+        }
+        if (isset($arr['sourcetype']) && !empty($arr['sourcetype']) && in_array($arr['sourcetype'], [1, 2])) {
+            $where['sourcetype'] = $arr['sourcetype'];
+        }
+        if (isset($arr['evaluatetype']) && !empty($arr['evaluatetype']) && in_array($arr['evaluatetype'], [1])) {
+            $where['evaluatetype'] = $arr['evaluatetype'];
+        }
+        if (isset($arr['code']) && !empty($arr['code']) && is_string($arr['code'])) {
+            $where['code'] = $arr['code'];
+        }
+        if (isset($arr['evaluatememo']) && !empty($arr['evaluatememo']) && is_string($arr['evaluatememo'])) {
+            $where['evaluatememo'] = $arr['evaluatememo'];
+        }
+        if (isset($arr['evaluatetime']) && is_array($arr['evaluatetime'])) {
+            $evaluatetime = array_filter($arr['evaluatetime']);
+            if (2 == count($evaluatetime)) {
+                $where['evaluatetime'] = $arr['evaluatetime'];
+            }
+        }
+        $count = $m_e->getlistforadmin($where, true);
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_e->getlistforadmin($where, false, $page, $size);
+        foreach ($list as $key => $value) {
+            switch ($value['sourcetype']) {
+                case 1:
+                    $m_i = new inventmodel();
+                    $where = ['id' => $value['sourceid']];
+                    $info = $m_i->getInfo($where);
+                    $list[$key]['code'] = empty($info) ? '' : $info['code'];
+                    $list[$key]['isactive'] = empty($info) ? '' : $info['isactive'];
+                    break;
+                case 2:
+                    $m_j = new jobhuntingmodel();
+                    $where = ['id' => $value['sourceid']];
+                    $info = $m_j->getInfo($where);
+                    $list[$key]['isactive'] = empty($info) ? '' : $info['isactive'];
+                    break;
+            }
+        }
+        $data = [
+            'count' => $count,
+            'list' => $list,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+}

+ 64 - 0
application/index/logic/feedbacklogic.php

@@ -0,0 +1,64 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2021/11/18
+ * Time: 14:31
+ */
+namespace app\index\logic;
+
+use app\index\model\feedbackmodel;
+
+class feedbacklogic
+{
+    /*
+     * 20211118
+     * steelxu5
+     */
+    public function savenewfeedback($arr)
+    {
+        $t_f = new feedbackmodel();
+        $arr['createtime'] = date('Y-m-d H:i:s');
+        $id = $t_f->insinfo($arr);
+        return $id;
+    }
+    /*
+     * 20211227
+     * steelxu5
+     */
+    public function getlistbywhere($arr)
+    {
+        $t_f = new feedbackmodel();
+        $where = [];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        if (isset($arr['wname']) && !empty($arr['wname']) && is_string($arr['wname'])) {
+            $where['u.wname'] = ['like', "%" . $arr['wname'] . "%"];
+        }
+        if (isset($arr['telno']) && !empty($arr['telno']) && is_numeric($arr['telno'])) {
+            $where['fb.usertel'] = ['like', "%" . $arr['telno'] . "%"];
+        }
+        if (isset($arr['isopr']) && is_numeric($arr['isopr']) && in_array($arr['isopr'], [0, 1])) {
+            $where['fb.isopr'] = $arr['isopr'];
+        }
+        if (isset($arr['istel']) && is_numeric($arr['istel']) && in_array($arr['istel'], [0, 1])) {
+            $where['fb.istel'] = $arr['istel'];
+        }
+        if (isset($arr['createtime']) && is_array($arr['createtime'])) {
+            $createtime = array_filter($arr['createtime']);
+            if (2 == count($createtime)) {
+                $where['fb.createtime'] = ['between', $arr['createtime']];
+            }
+        }
+        $count = $t_f->getList($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $t_f->getList($where, 'fb.*,u.wname,u.telno', $page, $size);
+        $data = [
+            'count' => $count,
+            'list' => $list,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+}

+ 268 - 0
application/index/logic/grouplogic.php

@@ -0,0 +1,268 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2021/10/7
+ * Time: 23:43
+ */
+namespace app\index\logic;
+
+use app\index\model\groupmodel;
+use app\index\model\groupusermodel;
+use app\index\model\userinfomodel;
+use app\index\model\workermodel;
+use think\Log;
+
+class grouplogic
+{
+
+    /*
+     * 20211007
+     * steelxu
+     *
+     */
+    public function savenewgroup($arr)
+    {
+        $arr['createdate'] = date('Y-m-d H:i:s');
+        $t_g = new groupmodel();
+        $rid = $t_g->insinfo($arr);
+        return $rid;
+
+    }
+    /***
+     * 根据id获取信息
+     *20211011
+     * wj
+     */
+    public function getinfobyid($arr)
+    {
+        if (!isset($arr['id'])) {
+            return backarr(0, "请求错误");
+        }
+        $t_g = new groupmodel();
+        $where = [
+            "id" => $arr['id'],
+        ];
+        $info = $t_g->getinfo($where);
+        if (empty($info)) {
+            return backarr(0, "无数据");
+        }
+        return backarr(1, "查询成功", $info);
+    }
+
+    /***
+     * 获取用户信息和附加信息
+     * count_user 组总人数
+     * wj 20211023
+     * eidt by steelxu
+     * edit in 20211031
+     * 获取创建人信息
+     */
+    public function getinfoallbyid($arr)
+    {
+        if (!isset($arr['id'])) {
+            return backarr(0, "请求错误");
+        }
+        $m_g = new groupmodel();
+        $m_gu = new groupusermodel();
+        $where = [
+            "id" => $arr['id'],
+        ];
+        $info = $m_g->getinfo($where);
+        if (empty($info)) {
+            return backarr(0, "无班组信息");
+        }
+        $id = $info['id'];
+        //创建人信息
+        $cuid=$info['createuid'];
+        $t_u=new userinfomodel();
+        $cuinfo=$t_u->selconinfobyid($cuid);
+        $info['coninfo']=$cuinfo;
+        //加总人数
+        $guwhere = [
+            'groupid' => $id,
+        ];
+        $countUser = $m_gu->getList($guwhere, 'count');
+        $info['count_user'] = $countUser;
+        return backarr(1, "查询成功", $info);
+    }
+    /***
+     * 获取我创建的班组列表
+     * 20211012
+     * wj
+     */
+    public function getlistbyuserid($arr)
+    {
+        $m_g = new groupmodel();
+        if (!isset($arr['userid'])) {
+            return backarr(0, "请求错误");
+        }
+        $userid = $arr['userid'];
+        $where = ['createuid' => $userid];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $count = $m_g->getList($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_g->getList($where, 'id', $page, $size);
+        foreach ($list as $key => &$value) {
+            $result = $this->getinfoallbyid(['id' => $value['id']]);
+            $list[$key] = $result['data'];
+        }
+        return backarr(1, "查询成功", $list);
+    }
+    /***
+     * 获取我参与的班组列表
+     * 20211012
+     * wj
+     */
+    public function getpartinlistbyuserid($arr)
+    {
+        $m_g = new groupmodel();
+        if (!isset($arr['userid'])) {
+            return backarr(0, "请求错误");
+        }
+        $userid = $arr['userid'];
+        $where = ['gu.userid' => $userid];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $count = $m_g->getpartinlist($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_g->getpartinlist($where, 'g.*,gu.createdate as partindate', $page, $size);
+        foreach ($list as $key => &$value) {
+            $result = $this->getinfoallbyid(['id' => $value['id']]);
+            $list[$key] = $result['data'];
+        }
+        return backarr(1, "查询成功", $list);
+    }
+    /***
+     * 参与班组 通过userid
+     * 20211012
+     * wj
+     */
+    public function partingroupbyuserid($arr)
+    {
+        $m_g = new groupmodel();
+        $m_gu = new groupusermodel();
+        if (!isset($arr['groupid']) || empty($arr['groupid'])) {
+            return backarr(0, "请求错误");
+        }
+        if (!isset($arr['userid']) || empty($arr['userid'])) {
+            return backarr(0, "请求错误");
+        }
+        $where = [
+            'groupid' => $arr['groupid'],
+            'userid' => $arr['userid'],
+        ];
+        $info = $m_gu->getinfo($where);
+        if (!empty($info)) {
+            if (1 === $info['isactive']) {
+                return backarr(0, "用户已参与班组");
+            }
+            $guid = $info['id'];
+            $updateData = [
+                'isactive' => 1,
+            ];
+            $row = $m_gu->updateinfo(['id' => $guid], $updateData);
+            if (empty($row)) {
+                return backarr(0, "操作失败");
+            }
+        } else {
+            $arr['createdate'] = date('Y-m-d H:i:s');
+            $guid = $m_gu->insinfo($arr);
+            if (empty($guid)) {
+                return backarr(0, "添加失败");
+            }
+        }
+        return backarr(1, "添加成功", ['id' => $guid]);
+    }
+    /***
+     * 退出班组 通过userid
+     * 20211025
+     * wj
+     */
+    public function quitgroupbyuserid($arr)
+    {
+        $m_g = new groupmodel();
+        $m_gu = new groupusermodel();
+        if (!isset($arr['groupid']) || empty($arr['groupid'])) {
+            return backarr(0, "请求错误");
+        }
+        if (!isset($arr['userid']) || empty($arr['userid'])) {
+            return backarr(0, "请求错误");
+        }
+        $where = [
+            'groupid' => $arr['groupid'],
+            'userid' => $arr['userid'],
+        ];
+        $info = $m_gu->getinfo($where);
+        if (empty($info)) {
+            return backarr(0, "无用户与班组关系");
+        }
+        if (1 !== $info['isactive']) {
+            return backarr(0, "用户未参与班组");
+        }
+        $guid = $info['id'];
+        $updateData = [
+            'isactive' => 0,
+        ];
+        $row = $m_gu->updateinfo(['id' => $guid], $updateData);
+        if (empty($row)) {
+            return backarr(0, "操作失败");
+        }
+        log::info("groupid[" . $arr['groupid'] . '],userid[' . $arr['userid'] . '],退出班组' . date('Y-m-d H:i:s'));
+        return backarr(1, "操作成功", ['id' => $guid]);
+    }
+
+    /***
+     * 获取参与组的用户列表 通过组id
+     * 20211023
+     * wj
+     */
+    public function getlistgroupuserbyid($arr)
+    {
+        if (!isset($arr['id'])) {
+            return backarr(0, "请求错误");
+        }
+        $m_g = new groupmodel();
+        $m_gu = new groupusermodel();
+        $m_w = new workermodel();
+        $m_u = new userinfomodel();
+        $where = [
+            "id" => $arr['id'],
+        ];
+        $info = $m_g->getinfo($where);
+        if (empty($info)) {
+            return backarr(0, "无班组信息");
+        }
+        $id = $info['id'];
+        //加总人数
+        $guwhere = [
+            'groupid' => $id,
+        ];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $list = $m_gu->getList($guwhere, '*', $page, $size);
+        if (empty($list)) {
+            return backarr(0, "无数据");
+        }
+        //工种 年龄 性别 名字 头像
+        $userfields = ['id', 'wname', 'gender', 'wage', 'photourl'];
+        $workerfields = ['worktype'];
+        foreach ($list as $key => &$value) {
+            $uid = $value['userid'];
+            $userinfo = ['id' => $uid];
+            $uinfo = $m_u->getinfo(['id' => $uid], $userfields);
+            if (empty($uinfo)) {
+                $value = $userinfo;
+                continue;
+            }
+            $winfo = $m_w->getInfo(['userid' => $uid], $workerfields);
+            $list[$key] = array_merge($userinfo, $uinfo->toArray(), $winfo->toArray());
+        }
+        return backarr(1, "查询成功", $list);
+    }
+}

+ 216 - 0
application/index/logic/homepagelogic.php

@@ -0,0 +1,216 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-11-17 13:37:50
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-18 10:19:03
+ */
+namespace app\index\logic;
+
+use app\index\model\companymodel;
+use app\index\model\inventmodel;
+use app\index\model\jobhuntingmodel;
+use app\index\model\payordermodel;
+use app\index\model\statisticssqlmodel;
+use app\index\model\userinfomodel;
+
+class homepagelogic
+{
+    public function getcountlist()
+    {
+        $m_u = new userinfomodel();
+        $m_i = new inventmodel();
+        $m_j = new jobhuntingmodel();
+        $m_p = new payordermodel();
+        $m_c = new companymodel();
+        $userinfo = $m_u->getcount();
+        $invent = $m_i->getcount();
+        $jobhunting = $m_j->getcount();
+        $payorder = $m_p->getcount();
+        $company = $m_c->getcount();
+        $list = [
+            'userinfo' => $userinfo,
+            'invent' => $invent,
+            'jobhunting' => $jobhunting,
+            'payorder' => $payorder,
+            'company' => $company,
+        ];
+        return $list;
+    }
+    public function getstatistics()
+    {
+        $m_u = new userinfomodel();
+        $m_i = new inventmodel();
+        $m_j = new jobhuntingmodel();
+        $m_p = new payordermodel();
+        $m_c = new companymodel();
+        $userinfo = $m_u->statistics();
+        $invent = $m_i->statistics();
+        $jobhunting = $m_j->statistics();
+        $payorder = $m_p->statistics();
+        $company = $m_c->statistics();
+        $list = [
+            'userinfo' => $userinfo,
+            'invent' => $invent,
+            'jobhunting' => $jobhunting,
+            'payorder' => $payorder,
+            'company' => $company,
+        ];
+        $listUse = [];
+        foreach ($list as $key => $value) {
+            foreach ($value as $vk => $vv) {
+                $vv['kind'] = $key;
+                $listUse[] = $vv;
+            }
+        }
+        //$list = $listUse;
+        return $list;
+    }
+    //获取统计数据
+    /**
+     * 获取电话统计数据
+     * 20211206
+     * wj
+     */
+    public function getTelnoConnectNum()
+    {
+        $m_ss = new statisticssqlmodel();
+        $data = $m_ss->getTelnoConnectNum();
+        return $data;
+    }
+    /**
+     * 获取无代发数据
+     * 20211206
+     * wj
+     */
+    public function getinventcount1()
+    {
+        $m_ss = new statisticssqlmodel();
+        $data = $m_ss->getinventcount1();
+        return $data;
+    }
+    /***
+     * 近两日 打电话数量及人数
+     * 20211220
+     * wj
+     */
+    public function getinventcount2()
+    {
+        $m_ss = new statisticssqlmodel();
+        $data = $m_ss->getinventcount2();
+        return $data;
+    }
+    /***
+     * 各招工电话联系 联系数量 列表
+     * 20211206
+     * wj
+     */
+    public function getinventitemtelnoconnectlist($arr)
+    {
+        $m_ss = new statisticssqlmodel();
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $count = $m_ss->getinventitemtelnoconnectlist(true);
+        $count = $count[0]['count'];
+        $list = [];
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_ss->getinventitemtelnoconnectlist(false, $page, $size);
+        $data = [
+            'count' => $count,
+            'list' => $list,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+    /***
+     * 各招工电话联系 联系数量 列表 今日
+     * 20211220
+     * wj
+     */
+    public function getinventitemtelnoconnectbydaylist($arr)
+    {
+        $m_ss = new statisticssqlmodel();
+        $list = $m_ss->getinventitemtelnoconnectbydaylist();
+        return backarr(1, "查询成功", $list);
+    }
+    /***
+     * 各招工电话联系 间隔时间 列表
+     * 20211206
+     * wj
+     */
+    public function getinventitemtelnointervallist($arr)
+    {
+        $m_ss = new statisticssqlmodel();
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $count = $m_ss->getinventitemtelnointervallist(true);
+        $count = $count[0]['count'];
+        $list = [];
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_ss->getinventitemtelnointervallist(false, $page, $size);
+        $data = [
+            'count' => $count,
+            'list' => $list,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+    /***
+     * 各招工电话联系 间隔时间 列表 平均
+     * 20211220
+     * wj
+     */
+    public function getinventitemtelnoavgbydaylist($arr)
+    {
+        $m_ss = new statisticssqlmodel();
+        $list = $m_ss->getinventitemtelnoavgbydaylist();
+        return backarr(1, "查询成功", $list);
+    }
+    /***
+     * 招工 已招满
+     * 20211206
+     * wj
+     */
+    public function getinventfull()
+    {
+        $m_ss = new statisticssqlmodel();
+        $data = $m_ss->getinventfull();
+        return $data;
+    }
+    /***
+     * 招工没接电话
+     * 20211206
+     * wj
+     */
+    public function getinventnotanswer()
+    {
+        $m_ss = new statisticssqlmodel();
+        $data = $m_ss->getinventnotanswer();
+        return $data;
+    }
+    /***
+     * 统计用户积分
+     * 20211206
+     * wj
+     */
+    public function getuseraccount($arr)
+    {
+        $m_ss = new statisticssqlmodel();
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $count = $m_ss->getuseraccount(true);
+        $count = $count[0]['count'];
+        $list = [];
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_ss->getuseraccount(false, $page, $size);
+        $data = [
+            'count' => $count,
+            'list' => $list,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+}

+ 820 - 0
application/index/logic/inventlogic.php

@@ -0,0 +1,820 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 09:02:06
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-24 16:30:10
+ */
+namespace app\index\logic;
+
+use app\index\model\companymodel;
+use app\index\model\inventmodel;
+use app\index\model\logmodel;
+use app\index\model\userinfomodel;
+use app\index\model\webusermodel;
+use app\index\model\workermodel;
+use think\Db;
+use think\Log;
+
+class inventlogic
+{
+    private $inventmodel;
+    public function __construct()
+    {
+        $this->inventmodel = new inventmodel();
+    }
+    /*
+     * edit in 20211025
+     * edit by steelxu
+     * 增加了发布人的通讯信息
+     */
+    public function getinfobyid($id)
+    {
+        $where = ['id' => $id];
+        $info = $this->inventmodel->getInfo($where);
+        if (empty($info)) {
+            return false;
+        }
+        //edit by steelxu 20211025
+        $t_u = new userinfomodel();
+        $uid = $info['createuid'];
+        $uinfo = $t_u->selconinfobyid($uid);
+        $info['coninfo'] = empty($uinfo) ? false : $uinfo;
+        if (!empty($info['releaseid'])) {
+            $m_wu = new webusermodel();
+            $wuinfo = $m_wu->getInfo(['id' => $info['releaseid']], ['user_name']);
+            if (empty($wuinfo)) {
+                $info['release_user'] = '';
+            } else {
+                $info['release_user'] = $wuinfo['user_name'];
+            }
+        } else {
+            $info['release_user'] = '';
+        }
+        $m_c = new companymodel();
+        $cinfo = $m_c->getInfo(['userid' => $info['createuid'], 'isactive' => 1, 'ispass' => 1]);
+        if (empty($cinfo)) {
+            $info['is_company'] = 0;
+            $info['company'] = 0;
+        } else {
+            $info['is_company'] = 1;
+            $info['company'] = $cinfo['company'];
+        }
+        return $info;
+    }
+    /**
+     * 20211221
+     *  wj
+     * 查询详细 仅列表用
+     */
+    public function getinfobyidforlist($id)
+    {
+        $where = ['id' => $id];
+        $info = $this->inventmodel->getInfo($where);
+        if (empty($info)) {
+            return false;
+        }
+        $t_u = new userinfomodel();
+        $uid = $info['createuid'];
+        $uinfo = $t_u->selconinfobyid($uid);
+        $info['coninfo'] = empty($uinfo) ? false : $uinfo;
+        if (!empty($info['releaseid'])) {
+            $m_wu = new webusermodel();
+            $wuinfo = $m_wu->getInfo(['id' => $info['releaseid']], ['user_name']);
+            if (empty($wuinfo)) {
+                $info['release_user'] = '';
+            } else {
+                $info['release_user'] = $wuinfo['user_name'];
+            }
+        } else {
+            $info['release_user'] = '';
+        }
+        $m_c = new companymodel();
+        $cinfo = $m_c->getInfo(['userid' => $info['createuid'], 'isactive' => 1, 'ispass' => 1]);
+        if (empty($cinfo)) {
+            $info['is_company'] = 0;
+            $info['company'] = 0;
+        } else {
+            $info['is_company'] = 1;
+            $info['company'] = $cinfo['company'];
+        }
+        return $info;
+    }
+    public function insertinfo($info)
+    {
+        if (!isset($info['createuid']) || empty($info['createuid'])) {
+            return backarr(0, "请求错误");
+        }
+        $uid = $info['createuid'];
+        $t_u = new userinfomodel();
+        $uinfo = $t_u->selconinfobyid($uid);
+        if (empty($uinfo)) {
+            return backarr(0, "无用户信息");
+        }
+        if (!isset($info['createdate']) || empty($info['createdate'])) {
+            $info['createdate'] = date('Y-m-d H:i:s', time());
+        }
+        if (isset($info['daysalary'])) {
+            if (!is_numeric($info['daysalary'])) {
+                return backarr(0, "日结工资格式错误");
+            }
+        }
+        if (isset($info['disstr']) || !empty($info['disstr'])) {
+            if (mb_strlen($info['disstr']) > 20) {
+                return backarr(0, "内容简介过长");
+            }
+        }
+        $info['code'] = $this->getCode();
+
+        log::info($info); //调试用
+        $id = $this->inventmodel->insertData($info);
+        if (!$id) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    /*
+     * 20211002
+     * edit by steelxu
+     * upade 改为 update
+     */
+
+    public function updateinfobyid($id, $updateData)
+    {
+        $where = ['id' => $id];
+        //记录userlog wj
+        log::info('update:' . $id);
+        log::info($updateData);
+        $m_l = new logmodel();
+        $jsonData = [
+            'inventid' => $id,
+            'webuserid' => isset($updateData['releaseid']) ? $updateData['releaseid'] : '',
+            'createuid' => isset($updateData['createuid']) ? $updateData['createuid'] : '',
+        ];
+        $logData = [
+            'type' => '招工修改',
+            'json' => json_encode($jsonData),
+            'create_date' => date('Y-m-d H:i:s'),
+        ];
+        $m_l->savelog(json_encode($logData));
+        $result = $this->inventmodel->update($where, $updateData);
+        return $result;
+    }
+    /*
+     * 改可用状态
+     */
+    public function updateisactivebyid($param)
+    {
+        if (!isset($param['id']) || empty($param['id'])) {
+            return backarr(0, "请求数据错误");
+        }
+        $id = $param['id'];
+        $info = $this->getinfobyid($id);
+        if (empty($info)) {
+            return backarr(0, "无数据");
+        }
+        if (1 != $info['isactive']) {
+            return backarr(0, "已关闭");
+        }
+        $updateData = [
+            'isactive' => 0,
+            'unactivetime' => date("y-m-d H:i:s", time()),
+        ];
+        $updateWhere = [
+            'id' => $id,
+        ];
+        $row = $this->inventmodel->updateinfo($updateWhere, $updateData);
+        if (!$row) {
+            return backarr(0, "修改失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    /*
+     * 加联系次数
+     */
+    public function incconcountbyid($param)
+    {
+        if (!isset($param['id']) || empty($param['id'])) {
+            return backarr(0, "请求数据错误");
+        }
+        $id = $param['id'];
+        $info = $this->getinfobyid($id);
+        if (empty($info)) {
+            return backarr(0, "无数据");
+        }
+        $isadd = true;
+        $isclose = false;
+        if (!$info['isactive']) {
+            return backarr(0, "已关闭");
+        }
+        if ($info['maxconcount'] > 0) {
+            if ($info['concount'] >= $info['maxconcount']) {
+                $isadd = false;
+                $isclose = true;
+            }
+            if ($isadd) {
+                if ($info['concount'] + 1 >= $info['maxconcount']) {
+                    $isclose = true;
+                }
+            }
+            if ($isclose) {
+                $updateData = [
+                    'isactive' => 0,
+                    'unactivetime' => date("y-m-d H:i:s", time()),
+                ];
+                $updateWhere = [
+                    'id' => $id,
+                ];
+                $row = $this->inventmodel->updateinfo($updateWhere, $updateData);
+                if (!$row) {
+                    return backarr(0, "自动关闭修改失败");
+                }
+            }
+        }
+        if ($isadd) {
+            $updateWhere = [
+                'id' => $id,
+            ];
+            $row = $this->inventmodel->incField($updateWhere, 'concount');
+            if (!$row) {
+                return backarr(0, "修改失败");
+            }
+        }
+        $info = $this->getinfobyid($id);
+        return backarr(1, "操作成功", ['concount' => $info['concount']]);
+    }
+    /*
+     * 改联系次数
+     * 20211221
+     * wj
+     */
+    public function updatemaxconcountbyid($param)
+    {
+        if (!isset($param['id']) || empty($param['id']) || !isset($param['maxconcount']) || !is_numeric($param['maxconcount'])) {
+            return backarr(0, "请求数据错误");
+        }
+        $id = $param['id'];
+        $maxconcount = $param['maxconcount'];
+        $info = $this->getinfobyid($id);
+        if (empty($info)) {
+            return backarr(0, "无数据");
+        }
+        $updateData = [
+            'maxconcount' => $maxconcount,
+        ];
+        $updateWhere = [
+            'id' => $id,
+        ];
+        $row = $this->inventmodel->updateinfo($updateWhere, $updateData);
+        if (!$row) {
+            return backarr(0, "修改失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    //根据经纬度获取列表
+    /*
+     * 20211003
+     * edit by steelxu5
+     * 需加上 isactive=1,只提供未关闭的信息
+     * 20211003
+     * edit by steelxu5
+     * 需要加上头像和通讯信息,
+     *
+     */
+    public function getlistbyrange($arr)
+    {
+        $fillArr = ['lng', 'lat'];
+        foreach ($fillArr as $key => $value) {
+            if (!isset($arr[$value]) || empty($arr[$value])) {
+                return backarr(0, "请求数据错误");
+            }
+        }
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $radii = isset($arr['radii']) && !empty($arr['radii']) ? $arr['radii'] : 100;
+        $minlat = $arr['lat'] - $radii;
+        $maxlat = $arr['lat'] + $radii;
+        $minlng = $arr['lng'] - $radii;
+        $maxlng = $arr['lng'] + $radii;
+        $where = [
+            'gps_lat' => ['between', $minlat . "," . $maxlat],
+            'gps_lng' => ['between', $minlng . "," . $maxlng],
+            'isactive' => 1,
+            'ispass' => 1,
+        ];
+        $order = 'id desc';
+        if (isset($arr['order']) && !empty($arr['order'])) {
+            $order = $arr['order'];
+        }
+        $list = $this->inventmodel->getList($where, '*', $page, $size, $order);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        $t_u = new userinfomodel();
+        foreach ($list as $key => &$invent) {
+            $list[$key] = $this->getinfobyidforlist($invent['id']);
+        }
+        return backarr(1, "查询成功", $list);
+    }
+    /*
+     * 20211003
+     * edit by steelxu5
+     * 需加上 isactive=1,只提供未关闭的信息
+     *
+     */
+    public function getlistbyaddress($arr)
+    {
+        $where = [];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        if (isset($arr['city'])) {
+            $where['city'] = ['like', "%" . $arr['city'] . "%"];
+        }
+        if (isset($arr['disc'])) {
+            $where['disc'] = ['like', "%" . $arr['disc'] . "%"];
+        }
+        if (isset($arr['town'])) {
+            $where['town'] = ['like', "%" . $arr['town'] . "%"];
+        }
+        if (isset($arr['address'])) {
+            $where['address'] = ['like', "%" . $arr['address'] . "%"];
+        }
+        if (empty($where)) {
+            return backarr(0, "请求数据错误");
+        }
+        $where['isactive'] = 1; //edit by steelxu 20211003
+        $where['ispass'] = 1;
+        $order = 'id desc';
+        if (isset($arr['order']) && !empty($arr['order'])) {
+            $order = $arr['order'];
+        }
+        $list = $this->inventmodel->getList($where, "*", $page, $size, $order);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        $t_u = new userinfomodel();
+        foreach ($list as $key => &$invent) {
+            $list[$key] = $this->getinfobyidforlist($invent['id']);
+        }
+        return backarr(1, "查询成功", $list);
+    }
+
+    /*
+     * 20211002
+     * steelxu5
+     * 获取用户本人发的招工信息
+     */
+    public function getinventlistbycuid($arr)
+    {
+        $crid = $arr['uid'];
+        $list = $this->inventmodel->sellistbyuid($crid);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        foreach ($list as $key => &$invent) {
+            $list[$key] = $this->getinfobyidforlist($invent['id']);
+        }
+        return backarr(1, "查询成功", $list);
+
+    }
+
+    /*
+     * 20211007
+     * edit by steelxu5
+     * 没有结果时,获取全部信息按地址发布
+     *
+     */
+    public function getlistbytime($arr)
+    {
+        $where = [];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $where['isactive'] = 1;
+        $where['ispass'] = 1;
+        $order = 'id desc';
+        if (isset($arr['order']) && !empty($arr['order'])) {
+            $order = $arr['order'];
+        }
+        $list = $this->inventmodel->getList($where, "*", $page, $size, $order);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        $t_u = new userinfomodel();
+        foreach ($list as $key => &$invent) {
+            $list[$key] = $this->getinfobyidforlist($invent['id']);
+        }
+        return backarr(1, "查询成功", $list);
+    }
+    /*
+     * 20211007
+     * wj
+     * 根据查询条件返回结果
+     * 目前仅pc后台使用
+     */
+    public function getlistbysearch($arr)
+    {
+        $m_wu = new webusermodel();
+        $where = [];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        if (isset($arr['telno'])) {
+            $where['telno'] = $arr['telno'];
+        }
+        if (isset($arr['wname'])) {
+            $where['wname'] = $arr['wname'];
+        }
+        if (isset($arr['code'])) {
+            $where['code'] = $arr['code'];
+        }
+        if (isset($arr['isactive'])) {
+            $where['isactive'] = $arr['isactive'];
+        }
+        if (isset($arr['ispass'])) {
+            $where['ispass'] = $arr['ispass'];
+        }
+        if (isset($arr['createdate']) && is_array($arr['createdate'])) {
+            $createdate = array_filter($arr['createdate']);
+            if (2 == count($createdate)) {
+                $where['createdate'] = $arr['createdate'];
+            }
+        }
+        $order = 'id desc';
+        if (isset($arr['order']) && !empty($arr['order'])) {
+            $order = $arr['order'];
+        }
+        $count = $this->inventmodel->getlistjoinuser($where, "count", $page, $size, $order);
+        if ($count < 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $this->inventmodel->getlistjoinuser($where, "*", $page, $size, $order);
+        foreach ($list as $key => &$invent) {
+            $list[$key] = $this->getinfobyidforlist($invent['id']);
+        }
+        /*foreach ($list as $key => &$value) {
+        if (!empty($value['releaseid'])) {
+        $wuinfo = $m_wu->getInfo(['id' => $value['releaseid']], ['user_name']);
+        if (empty($wuinfo)) {
+        $value['release_user'] = '';
+        } else {
+        $value['release_user'] = $wuinfo['user_name'];
+        }
+        } else {
+        $value['release_user'] = '';
+        }
+        }*/
+        $data = [
+            'count' => $count ? $count : 0,
+            'list' => $list,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+    /***
+     * 20211026
+     * 按工种查询
+     * wj
+     */
+    public function getlistbyworktype($arr)
+    {
+        if (!isset($arr['worktype']) || empty($arr['worktype'])) {
+            return backarr(0, "请求数据错误");
+        }
+        if (!isset($arr['city']) || empty($arr['city'])) {
+            $arr['city'] = "天津";
+        }
+        $where = [];
+        $worktype = $arr['worktype'];
+        $where['worktype'] = $worktype;
+        if (isset($arr['city']) && !empty($arr['city'])) {
+            $where['city'] = ['like', '%' . $arr['city'] . '%'];
+        }
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $where['isactive'] = 1;
+        $where['ispass'] = 1;
+        $order = 'id desc';
+        if (isset($arr['order']) && !empty($arr['order'])) {
+            $order = $arr['order'];
+        }
+        $list = $this->inventmodel->getList($where, "*", $page, $size, $order);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        $t_u = new userinfomodel();
+        foreach ($list as $key => &$invent) {
+            $list[$key] = $this->getinfobyidforlist($invent['id']);
+        }
+        return backarr(1, "查询成功", $list);
+    }
+    //代发
+    // 20211101 wj
+    public function insertinfobyrelease($arr)
+    {
+        $fillFiled = ['telno', 'releaseid', 'info', 'worktype', 'disc', 'city', 'address'];
+        foreach ($fillFiled as $key => $value) {
+            if (!isset($arr[$value]) || empty($arr[$value])) {
+                return backarr(0, "请求错误");
+            }
+        }
+        $m_u = new userinfomodel();
+        $m_wu = new webusermodel();
+        $m_w = new workermodel();
+        Db::startTrans();
+        try {
+            $telno = $arr['telno'];
+            $userinfo = $m_u->getInfo(['telno' => $telno]);
+            if (empty($userinfo)) {
+                $addData = [
+                    'telno' => $telno,
+                    'isactive' => 0,
+                    'createtime' => date('Y-m-d H:i:s', time()),
+                    'platform' => '管理后台',
+                ];
+                $createuid = $m_u->insertData($addData);
+                if (empty($createuid)) {
+                    throw new \Exception("会员创建失败");
+                }
+                $winsertInfo = [
+                    'userid' => $createuid,
+                    'telno' => $telno,
+                ];
+                $wid = $m_w->insertData($winsertInfo);
+                if (empty($wid)) {
+                    throw new \Exception("会员工人信息创建失败");
+                }
+            } else {
+                if (1 != $userinfo['isright']) {
+                    throw new \Exception("发布状态为无效");
+                }
+                $createuid = $userinfo['id'];
+            }
+            $wuinfo = $m_wu->getInfo(['id' => $arr['releaseid']]);
+            if (empty($wuinfo)) {
+                throw new \Exception("用户信息错误");
+            }
+            unset($arr['telno']);
+            $arr['createuid'] = $createuid;
+            if (!isset($arr['createdate']) || empty($arr['createdate'])) {
+                $arr['createdate'] = date('Y-m-d H:i:s', time());
+            }
+            if (isset($arr['daysalary'])) {
+                if (!is_numeric($arr['daysalary'])) {
+                    throw new \Exception("日结工资格式错误");
+                }
+            }
+            $arr['code'] = $this->getCode();
+            $arr['ispass'] = 1;
+            $arr['passtime'] = date('Y-m-d H:i:s');
+            $arr['passtype'] = 1;
+            if (isset($arr['info']) && !empty($arr['info'])) {
+                if (!isset($arr['disstr']) || empty($arr['disstr'])) {
+                    $arr['disstr'] = mb_substr($arr['info'], 0, 10);
+                }
+            }
+            $id = $this->inventmodel->insertData($arr);
+            if (!$id) {
+                throw new \Exception("操作失败");
+            }
+            Db::commit();
+            return backarr(1, "操作成功", ['id' => $id]);
+        } catch (\Exception $e) {
+            Db::rollback();
+            return backarr(0, $e->getMessage());
+        }
+    }
+    private function getCode()
+    {
+        $code = 'I' . date('YmdHis');
+        return $code;
+    }
+    //修改
+    // 20211102 wj
+    public function updateinventfromadmin($arr)
+    {
+        $fillFiled = ['id', 'telno', 'releaseid', 'disstr', 'info', 'worktype', 'disc', 'city', 'address'];
+        foreach ($fillFiled as $key => $value) {
+            if (!isset($arr[$value]) || empty($arr[$value])) {
+                return backarr(0, "请求错误");
+            }
+        }
+        $m_u = new userinfomodel();
+        $m_wu = new webusermodel();
+        $m_i = new inventmodel();
+        $m_w = new workermodel();
+        $inventInfo = $m_i->getInfo(['id' => $arr['id']]);
+        if (empty($inventInfo)) {
+            return backarr(0, "无数据");
+        }
+        Db::startTrans();
+        try {
+            $wuinfo = $m_wu->getInfo(['id' => $arr['releaseid']]);
+            if (empty($wuinfo)) {
+                throw new \Exception("用户信息错误");
+            }
+            $id = $inventInfo['id'];
+            $telno = $arr['telno'];
+            $userinfo = $m_u->getInfo(['telno' => $telno]);
+            if (empty($userinfo)) {
+                $addData = [
+                    'telno' => $telno,
+                    'isactive' => 0,
+                    'createtime' => date('Y-m-d H:i:s', time()),
+                    'platform' => '管理后台',
+                ];
+                $createuid = $m_u->insertData($addData);
+                if (empty($createuid)) {
+                    throw new \Exception("会员创建失败");
+                }
+                $workerAddData = [
+                    'userid' => $createuid,
+                    'telno' => $telno,
+                ];
+                $wid = $m_w->insertData($workerAddData);
+                if (empty($wid)) {
+                    throw new \Exception("工人信息创建失败");
+                }
+            } else {
+                $createuid = $userinfo['id'];
+            }
+            $arr['createuid'] = $createuid;
+            $updateData = [];
+            $updateField = ['createuid', 'city', 'disc', 'address', 'disstr', 'worktypeid', 'worktype', 'daysalary', 'info', 'town'];
+            foreach ($updateField as $key => $value) {
+                if ($arr[$value] !== $inventInfo[$value]) {
+                    $updateData[$value] = $arr[$value];
+                }
+            }
+            if (empty($inventInfo['code'])) {
+                $updateData['code'] = $this->getCode();
+            }
+            $row = $this->inventmodel->updateinfo(['id' => $id], $updateData);
+            if (empty($row)) {
+                throw new \Exception("需改失败");
+            }
+            //修改成功 记录log
+            log::info('update:' . $id);
+            log::info($updateData);
+            $m_l = new logmodel();
+            $jsonData = [
+                'inventid' => $id,
+                'webuserid' => isset($updateData['releaseid']) ? $updateData['releaseid'] : '',
+                'createuid' => isset($updateData['createuid']) ? $updateData['createuid'] : '',
+            ];
+            $logData = [
+                'type' => '招工修改',
+                'json' => json_encode($jsonData),
+                'create_date' => date('Y-m-d H:i:s'),
+            ];
+            $m_l->savelog(json_encode($logData));
+            Db::commit();
+            return backarr(1, "操作成功", ['id' => $id]);
+        } catch (\Exception $e) {
+            Db::rollback();
+            return backarr(0, $e->getMessage());
+        }
+    }
+    /***
+     * px端审核用
+     * 未审核 审核失败-》 审核成功
+     * 未审核->审核失败
+     * 20211117
+     * wj
+     */
+    public function updateispassbyid($arr)
+    {
+
+        if (!isset($arr['idlist']) || !is_array($arr['idlist'])) {
+            return backarr(0, "请求错误1");
+        }
+        if (!isset($arr['ispass']) || !in_array($arr['ispass'], [2, 1])) {
+            return backarr(0, "请求错误");
+        }
+        $ispass = $arr['ispass'];
+        $idlist = $arr['idlist'];
+        $m_i = new inventmodel();
+        $where = ['isactive' => 1];
+        switch ($ispass) {
+            case 1:
+                $where['ispass'] = ['in', [0, 2]];
+                break;
+            case 2:
+                $where['ispass'] = ['in', [0]];
+                break;
+        }
+        $where['id'] = ['in', $idlist];
+        $update = [
+            'ispass' => $ispass,
+            'passtime' => date('Y-m-d H:i:s'),
+            'passtype' => 2,
+        ];
+        $row = $m_i->updateinfo($where, $update);
+        if ($row <= 0) {
+            return backarr(0, "修改失败");
+        }
+        return backarr(1, "修改成功", ['row' => $row, 'idlist' => $idlist, 'ispass' => $ispass]);
+    }
+    /**
+     * 根据类型获取列表
+     * 20211213
+     * wj
+     */
+    public function getlistbywhere($arr)
+    {
+        //字段转译 key 请求字段 value 查询使用字段
+        $fileds = [
+            'a' => 'address', //用字符|分割
+            'lng' => 'lng',
+            'lat' => 'lat',
+            'wt' => 'worktype',
+            'r' => 'radii',
+            'od' => 'orderdaysalary', //order daysalary desc
+        ];
+        $page = isset($arr['page']) && !empty($arr['page']) && is_numeric($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) && is_numeric($arr['size']) ? $arr['size'] : 10;
+        $useValue = [];
+        $pattern = '/[\'+%-]+/';
+        foreach ($fileds as $key => $value) {
+            if (isset($arr[$key]) && !empty($arr[$key]) && is_string($arr[$key])) {
+                $str = preg_match_all($pattern, $arr[$key]);
+                if ($str) {
+                    return backarr(0, "查询请求数据错误");
+                }
+                $useValue[$value] = $arr[$key];
+            }
+        }
+        $where = [];
+        if (isset($useValue['address']) && !empty($useValue['address'])) {
+            $addressArr = explode('|', $useValue['address']);
+            $searchAddress = [
+                'city' => isset($addressArr[0]) ? $addressArr[0] : '',
+                'disc' => isset($addressArr[1]) ? $addressArr[1] : '',
+                'town' => isset($addressArr[2]) ? $addressArr[2] : '',
+                'address' => isset($addressArr[3]) ? $addressArr[3] : '',
+            ];
+            $searchAddress = array_filter($searchAddress);
+            if (!empty($searchAddress)) {
+                $where = array_merge($where, $searchAddress);
+            }
+        }
+        if (isset($useValue['orderdaysalary']) && !empty($useValue['orderdaysalary'])) {
+            $useValue['orderdaysalary'] = true;
+        } else {
+            $useValue['orderdaysalary'] = false;
+        }
+        if (isset($useValue['radii']) && is_numeric($useValue['radii']) && !empty($useValue['radii'])) {
+            //有经纬度
+            $fillFidle = ['lng', 'lat'];
+            foreach ($fillFidle as $key => $value) {
+                if (isset($useValue[$value]) && is_numeric($useValue[$value]) && !empty($useValue[$value])) {
+                    $where[$value] = $useValue[$value];
+                }
+            }
+            $where['radii'] = $useValue['radii'];
+        }
+        if (isset($useValue['worktype']) && !empty($useValue['worktype'])) {
+            $where['worktype'] = $useValue['worktype'];
+        }
+        $order = 'id desc'; //默认时间倒序
+        if ($useValue['orderdaysalary']) {
+            $order = 'daysalary desc'; //工资倒序
+        }
+        $m_i = new inventmodel();
+        $list = $m_i->getlistbymultiplecondition($where, $page, $size, $order);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        $t_u = new userinfomodel();
+        foreach ($list as $key => &$invent) {
+            $list[$key] = $this->getinfobyidforlist($invent['id']);
+        }
+        return backarr(1, "查询成功", $list);
+    }
+    /**
+     * 获取一定时间内无联系数量 默认5分钟
+     * 20211222
+     * wj
+     */
+    public function getnocalldata($arr)
+    {
+        $page = isset($arr['page']) && !empty($arr['page']) && is_numeric($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) && is_numeric($arr['size']) ? $arr['size'] : 10;
+        $where = [];
+        if (isset($arr['wname']) && !empty($arr['wname']) && is_string($arr['wname'])) {
+            $where['wname'] = $arr['wname'];
+        }
+        if (isset($arr['telno']) && !empty($arr['telno']) && is_numeric($arr['telno'])) {
+            $where['telno'] = $arr['telno'];
+        }
+        $m_i = new inventmodel();
+        //获取5分钟内无联系招工
+        $count = $m_i->getnocalldata(5, $where, true);
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_i->getnocalldata(5, $where, false, $page, $size);
+        $data = [
+            'count' => $count,
+            'list' => $list,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+}

+ 838 - 0
application/index/logic/inventv1logic.php

@@ -0,0 +1,838 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 09:02:06
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-16 17:43:00
+ */
+namespace app\index\logic;
+
+use app\index\model\companymodel;
+use app\index\model\inventv1model;
+use app\index\model\logmodel;
+use app\index\model\userinfomodel;
+use app\index\model\webusermodel;
+use app\index\model\workermodel;
+use think\Db;
+use think\Log;
+
+class inventv1logic
+{
+    private $inventmodel;
+    public function __construct()
+    {
+        $this->inventmodel = new inventv1model();
+    }
+    /*
+     * edit in 20211025
+     * edit by steelxu
+     * 增加了发布人的通讯信息
+     */
+    public function getinfobyid($id)
+    {
+        $where = ['id' => $id];
+        $info = $this->inventmodel->getInfo($where);
+        if (empty($info)) {
+            return false;
+        }
+        //edit by steelxu 20211025
+        $t_u = new userinfomodel();
+        $uid = $info['createuid'];
+        $uinfo = $t_u->selconinfobyid($uid);
+        $info['coninfo'] = empty($uinfo) ? false : $uinfo;
+        if (!empty($info['releaseid'])) {
+            $m_wu = new webusermodel();
+            $wuinfo = $m_wu->getInfo(['id' => $info['releaseid']], ['user_name']);
+            if (empty($wuinfo)) {
+                $info['release_user'] = '';
+            } else {
+                $info['release_user'] = $wuinfo['user_name'];
+            }
+        } else {
+            $info['release_user'] = '';
+        }
+        $m_c = new companymodel();
+        $cinfo = $m_c->getInfo(['userid' => $info['createuid'], 'isactive' => 1, 'ispass' => 1]);
+        if (empty($cinfo)) {
+            $info['is_company'] = 0;
+            $info['company'] = 0;
+        } else {
+            $info['is_company'] = 1;
+            $info['company'] = $cinfo['company'];
+        }
+        return $info;
+    }
+    /**
+     * 20211221
+     *  wj
+     * 查询详细 仅列表用
+     */
+    public function getinfobyidforlist($id)
+    {
+        $where = ['id' => $id];
+        $info = $this->inventmodel->getInfo($where);
+        if (empty($info)) {
+            return false;
+        }
+        $t_u = new userinfomodel();
+        $uid = $info['createuid'];
+        $uinfo = $t_u->selconinfobyid($uid);
+        $info['coninfo'] = empty($uinfo) ? false : $uinfo;
+        if (!empty($info['releaseid'])) {
+            $m_wu = new webusermodel();
+            $wuinfo = $m_wu->getInfo(['id' => $info['releaseid']], ['user_name']);
+            if (empty($wuinfo)) {
+                $info['release_user'] = '';
+            } else {
+                $info['release_user'] = $wuinfo['user_name'];
+            }
+        } else {
+            $info['release_user'] = '';
+        }
+        $m_c = new companymodel();
+        $cinfo = $m_c->getInfo(['userid' => $info['createuid'], 'isactive' => 1, 'ispass' => 1]);
+        if (empty($cinfo)) {
+            $info['is_company'] = 0;
+            $info['company'] = 0;
+        } else {
+            $info['is_company'] = 1;
+            $info['company'] = $cinfo['company'];
+        }
+        return $info;
+    }
+    public function insertinfo($info)
+    {
+        if (!isset($info['createuid']) || empty($info['createuid'])) {
+            return backarr(0, "请求错误");
+        }
+        $uid = $info['createuid'];
+        $t_u = new userinfomodel();
+        $uinfo = $t_u->selconinfobyid($uid);
+        if (empty($uinfo)) {
+            return backarr(0, "无用户信息");
+        }
+        if (!isset($info['createdate']) || empty($info['createdate'])) {
+            $info['createdate'] = date('Y-m-d H:i:s', time());
+        }
+        if (isset($info['daysalary'])) {
+            if (!is_numeric($info['daysalary'])) {
+                return backarr(0, "日结工资格式错误");
+            }
+        }
+        if (isset($info['disstr']) || !empty($info['disstr'])) {
+            if (mb_strlen($info['disstr']) > 20) {
+                return backarr(0, "内容简介过长");
+            }
+        }
+        $info['code'] = $this->getCode();
+
+        log::info($info); //调试用
+        $id = $this->inventmodel->insertData($info);
+        if (!$id) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    /*
+     * 20211002
+     * edit by steelxu
+     * upade 改为 update
+     */
+
+    public function updateinfobyid($id, $updateData)
+    {
+        $where = ['id' => $id];
+        //记录userlog wj
+        log::info('update:' . $id);
+        log::info($updateData);
+        $m_l = new logmodel();
+        $jsonData = [
+            'inventid' => $id,
+            'webuserid' => isset($updateData['releaseid']) ? $updateData['releaseid'] : '',
+            'createuid' => isset($updateData['createuid']) ? $updateData['createuid'] : '',
+        ];
+        $logData = [
+            'type' => '招工修改',
+            'json' => json_encode($jsonData),
+            'create_date' => date('Y-m-d H:i:s'),
+        ];
+        $m_l->savelog(json_encode($logData));
+        $result = $this->inventmodel->update($where, $updateData);
+        return $result;
+    }
+    /*
+     * 改可用状态
+     */
+    public function updateisactivebyid($param)
+    {
+        if (!isset($param['id']) || empty($param['id'])) {
+            return backarr(0, "请求数据错误");
+        }
+        $id = $param['id'];
+        $info = $this->getinfobyid($id);
+        if (empty($info)) {
+            return backarr(0, "无数据");
+        }
+        if (1 != $info['isactive']) {
+            return backarr(0, "已关闭");
+        }
+        $updateData = [
+            'isactive' => 0,
+            'unactivetime' => date("y-m-d H:i:s", time()),
+        ];
+        $updateWhere = [
+            'id' => $id,
+        ];
+        $row = $this->inventmodel->updateinfo($updateWhere, $updateData);
+        if (!$row) {
+            return backarr(0, "修改失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    /*
+     * 加联系次数
+     */
+    public function incconcountbyid($param)
+    {
+        if (!isset($param['id']) || empty($param['id'])) {
+            return backarr(0, "请求数据错误");
+        }
+        $id = $param['id'];
+        $info = $this->getinfobyid($id);
+        if (empty($info)) {
+            return backarr(0, "无数据");
+        }
+        $isadd = true;
+        $isclose = false;
+        if (!$info['isactive']) {
+            return backarr(0, "已关闭");
+        }
+        if ($info['maxconcount'] > 0) {
+            if ($info['concount'] >= $info['maxconcount']) {
+                $isadd = false;
+                $isclose = true;
+            }
+            if ($isadd) {
+                if ($info['concount'] + 1 >= $info['maxconcount']) {
+                    $isclose = true;
+                }
+            }
+            if ($isclose) {
+                $updateData = [
+                    'isactive' => 0,
+                    'unactivetime' => date("y-m-d H:i:s", time()),
+                ];
+                $updateWhere = [
+                    'id' => $id,
+                ];
+                $row = $this->inventmodel->updateinfo($updateWhere, $updateData);
+                if (!$row) {
+                    return backarr(0, "自动关闭修改失败");
+                }
+            }
+        }
+        if ($isadd) {
+            $updateWhere = [
+                'id' => $id,
+            ];
+            $row = $this->inventmodel->incField($updateWhere, 'concount');
+            if (!$row) {
+                return backarr(0, "修改失败");
+            }
+        }
+        return backarr(1, "操作成功");
+    }
+    /*
+     * 改联系次数
+     * 20211221
+     * wj
+     */
+    public function updatemaxconcountbyid($param)
+    {
+        if (!isset($param['id']) || empty($param['id']) || !isset($param['maxconcount']) || !is_numeric($param['maxconcount'])) {
+            return backarr(0, "请求数据错误");
+        }
+        $id = $param['id'];
+        $maxconcount = $param['maxconcount'];
+        $info = $this->getinfobyid($id);
+        if (empty($info)) {
+            return backarr(0, "无数据");
+        }
+        $updateData = [
+            'maxconcount' => $maxconcount,
+        ];
+        $updateWhere = [
+            'id' => $id,
+        ];
+        $row = $this->inventmodel->updateinfo($updateWhere, $updateData);
+        if (!$row) {
+            return backarr(0, "修改失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    //根据经纬度获取列表
+    /*
+     * 20211003
+     * edit by steelxu5
+     * 需加上 isactive=1,只提供未关闭的信息
+     * 20211003
+     * edit by steelxu5
+     * 需要加上头像和通讯信息,
+     *
+     */
+    public function getlistbyrange($arr)
+    {
+        $fillArr = ['lng', 'lat'];
+        foreach ($fillArr as $key => $value) {
+            if (!isset($arr[$value]) || empty($arr[$value])) {
+                return backarr(0, "请求数据错误");
+            }
+        }
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $radii = isset($arr['radii']) && !empty($arr['radii']) ? $arr['radii'] : 100;
+        $minlat = $arr['lat'] - $radii;
+        $maxlat = $arr['lat'] + $radii;
+        $minlng = $arr['lng'] - $radii;
+        $maxlng = $arr['lng'] + $radii;
+        $where = [
+            'gps_lat' => ['between', $minlat . "," . $maxlat],
+            'gps_lng' => ['between', $minlng . "," . $maxlng],
+            //'isactive' => 1,
+            'ispass' => 1,
+        ];
+        if (isset($arr['isactive']) && in_array($arr['isactive'], [0, 1]) && is_numeric($arr['isactive'])) {
+            $where['isactive'] = $arr['isactive'];
+        }
+        $order = 'id desc';
+        if (isset($arr['order']) && !empty($arr['order'])) {
+            $order = $arr['order'];
+        }
+        $list = $this->inventmodel->getList($where, '*', $page, $size, $order);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        $t_u = new userinfomodel();
+        foreach ($list as $key => &$invent) {
+            $list[$key] = $this->getinfobyidforlist($invent['id']);
+        }
+        return backarr(1, "查询成功", $list);
+    }
+    /*
+     * 20211003
+     * edit by steelxu5
+     * 需加上 isactive=1,只提供未关闭的信息
+     *
+     */
+    public function getlistbyaddress($arr)
+    {
+        $where = [];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        if (isset($arr['city'])) {
+            $where['city'] = ['like', "%" . $arr['city'] . "%"];
+        }
+        if (isset($arr['disc'])) {
+            $where['disc'] = ['like', "%" . $arr['disc'] . "%"];
+        }
+        if (isset($arr['town'])) {
+            $where['town'] = ['like', "%" . $arr['town'] . "%"];
+        }
+        if (isset($arr['address'])) {
+            $where['address'] = ['like', "%" . $arr['address'] . "%"];
+        }
+        if (isset($arr['isactive']) && in_array($arr['isactive'], [0, 1]) && is_numeric($arr['isactive'])) {
+            $where['isactive'] = $arr['isactive'];
+        }
+        if (empty($where)) {
+            return backarr(0, "请求数据错误");
+        }
+        //$where['isactive'] = 1; //edit by steelxu 20211003
+        $where['ispass'] = 1;
+        $order = 'id desc';
+        if (isset($arr['order']) && !empty($arr['order'])) {
+            $order = $arr['order'];
+        }
+        $list = $this->inventmodel->getList($where, "*", $page, $size, $order);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        $t_u = new userinfomodel();
+        foreach ($list as $key => &$invent) {
+            $list[$key] = $this->getinfobyidforlist($invent['id']);
+        }
+        return backarr(1, "查询成功", $list);
+    }
+
+    /*
+     * 20211002
+     * steelxu5
+     * 获取用户本人发的招工信息
+     */
+    public function getinventlistbycuid($arr)
+    {
+        $crid = $arr['uid'];
+        $list = $this->inventmodel->sellistbyuid($crid);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        foreach ($list as $key => &$invent) {
+            $list[$key] = $this->getinfobyidforlist($invent['id']);
+        }
+        return backarr(1, "查询成功", $list);
+
+    }
+
+    /*
+     * 20211007
+     * edit by steelxu5
+     * 没有结果时,获取全部信息按地址发布
+     *
+     */
+    public function getlistbytime($arr)
+    {
+        $where = [];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        if (isset($arr['isactive']) && in_array($arr['isactive'], [0, 1]) && is_numeric($arr['isactive'])) {
+            $where['isactive'] = $arr['isactive'];
+        }
+        //$where['isactive'] = 1;
+        $where['ispass'] = 1;
+        $order = 'id desc';
+        if (isset($arr['order']) && !empty($arr['order'])) {
+            $order = $arr['order'];
+        }
+        $list = $this->inventmodel->getList($where, "*", $page, $size, $order);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        $t_u = new userinfomodel();
+        foreach ($list as $key => &$invent) {
+            $list[$key] = $this->getinfobyidforlist($invent['id']);
+        }
+        return backarr(1, "查询成功", $list);
+    }
+    /*
+     * 20211007
+     * wj
+     * 根据查询条件返回结果
+     * 目前仅pc后台使用
+     */
+    public function getlistbysearch($arr)
+    {
+        $m_wu = new webusermodel();
+        $where = [];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        if (isset($arr['telno'])) {
+            $where['telno'] = $arr['telno'];
+        }
+        if (isset($arr['wname'])) {
+            $where['wname'] = $arr['wname'];
+        }
+        if (isset($arr['code'])) {
+            $where['code'] = $arr['code'];
+        }
+        if (isset($arr['isactive'])) {
+            $where['isactive'] = $arr['isactive'];
+        }
+        if (isset($arr['ispass'])) {
+            $where['ispass'] = $arr['ispass'];
+        }
+        if (isset($arr['createdate']) && is_array($arr['createdate'])) {
+            $createdate = array_filter($arr['createdate']);
+            if (2 == count($createdate)) {
+                $where['createdate'] = $arr['createdate'];
+            }
+        }
+        $order = 'id desc';
+        if (isset($arr['order']) && !empty($arr['order'])) {
+            $order = $arr['order'];
+        }
+        $count = $this->inventmodel->getlistjoinuser($where, "count", $page, $size, $order);
+        if ($count < 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $this->inventmodel->getlistjoinuser($where, "*", $page, $size, $order);
+        foreach ($list as $key => &$invent) {
+            $list[$key] = $this->getinfobyidforlist($invent['id']);
+        }
+        /*foreach ($list as $key => &$value) {
+        if (!empty($value['releaseid'])) {
+        $wuinfo = $m_wu->getInfo(['id' => $value['releaseid']], ['user_name']);
+        if (empty($wuinfo)) {
+        $value['release_user'] = '';
+        } else {
+        $value['release_user'] = $wuinfo['user_name'];
+        }
+        } else {
+        $value['release_user'] = '';
+        }
+        }*/
+        $data = [
+            'count' => $count ? $count : 0,
+            'list' => $list,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+    /***
+     * 20211026
+     * 按工种查询
+     * wj
+     */
+    public function getlistbyworktype($arr)
+    {
+        if (!isset($arr['worktype']) || empty($arr['worktype'])) {
+            return backarr(0, "请求数据错误");
+        }
+        if (!isset($arr['city']) || empty($arr['city'])) {
+            $arr['city'] = "天津";
+        }
+        $where = [];
+        $worktype = $arr['worktype'];
+        $where['worktype'] = $worktype;
+        if (isset($arr['city']) && !empty($arr['city'])) {
+            $where['city'] = ['like', '%' . $arr['city'] . '%'];
+        }
+        if (isset($arr['isactive']) && in_array($arr['isactive'], [0, 1]) && is_numeric($arr['isactive'])) {
+            $where['isactive'] = $arr['isactive'];
+        }
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        //$where['isactive'] = 1;
+        $where['ispass'] = 1;
+        $order = 'id desc';
+        if (isset($arr['order']) && !empty($arr['order'])) {
+            $order = $arr['order'];
+        }
+        $list = $this->inventmodel->getList($where, "*", $page, $size, $order);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        $t_u = new userinfomodel();
+        foreach ($list as $key => &$invent) {
+            $list[$key] = $this->getinfobyidforlist($invent['id']);
+        }
+        return backarr(1, "查询成功", $list);
+    }
+    //代发
+    // 20211101 wj
+    public function insertinfobyrelease($arr)
+    {
+        $fillFiled = ['telno', 'releaseid', 'info', 'worktype', 'disc', 'city', 'address'];
+        foreach ($fillFiled as $key => $value) {
+            if (!isset($arr[$value]) || empty($arr[$value])) {
+                return backarr(0, "请求错误");
+            }
+        }
+        $m_u = new userinfomodel();
+        $m_wu = new webusermodel();
+        $m_w = new workermodel();
+        Db::startTrans();
+        try {
+            $telno = $arr['telno'];
+            $userinfo = $m_u->getInfo(['telno' => $telno]);
+            if (empty($userinfo)) {
+                $addData = [
+                    'telno' => $telno,
+                    'isactive' => 0,
+                    'createtime' => date('Y-m-d H:i:s', time()),
+                    'platform' => '管理后台',
+                ];
+                $createuid = $m_u->insertData($addData);
+                if (empty($createuid)) {
+                    throw new \Exception("会员创建失败");
+                }
+                $winsertInfo = [
+                    'userid' => $createuid,
+                    'telno' => $telno,
+                ];
+                $wid = $m_w->insertData($winsertInfo);
+                if (empty($wid)) {
+                    throw new \Exception("会员工人信息创建失败");
+                }
+            } else {
+                if (1 != $userinfo['isright']) {
+                    throw new \Exception("发布状态为无效");
+                }
+                $createuid = $userinfo['id'];
+            }
+            $wuinfo = $m_wu->getInfo(['id' => $arr['releaseid']]);
+            if (empty($wuinfo)) {
+                throw new \Exception("用户信息错误");
+            }
+            unset($arr['telno']);
+            $arr['createuid'] = $createuid;
+            if (!isset($arr['createdate']) || empty($arr['createdate'])) {
+                $arr['createdate'] = date('Y-m-d H:i:s', time());
+            }
+            if (isset($arr['daysalary'])) {
+                if (!is_numeric($arr['daysalary'])) {
+                    throw new \Exception("日结工资格式错误");
+                }
+            }
+            $arr['code'] = $this->getCode();
+            $arr['ispass'] = 1;
+            $arr['passtime'] = date('Y-m-d H:i:s');
+            $arr['passtype'] = 1;
+            if (isset($arr['info']) && !empty($arr['info'])) {
+                if (!isset($arr['disstr']) || empty($arr['disstr'])) {
+                    $arr['disstr'] = mb_substr($arr['info'], 0, 10);
+                }
+            }
+            $id = $this->inventmodel->insertData($arr);
+            if (!$id) {
+                throw new \Exception("操作失败");
+            }
+            Db::commit();
+            return backarr(1, "操作成功", ['id' => $id]);
+        } catch (\Exception $e) {
+            Db::rollback();
+            return backarr(0, $e->getMessage());
+        }
+    }
+    private function getCode()
+    {
+        $code = 'I' . date('YmdHis');
+        return $code;
+    }
+    //修改
+    // 20211102 wj
+    public function updateinventfromadmin($arr)
+    {
+        $fillFiled = ['id', 'telno', 'releaseid', 'disstr', 'info', 'worktype', 'disc', 'city', 'address'];
+        foreach ($fillFiled as $key => $value) {
+            if (!isset($arr[$value]) || empty($arr[$value])) {
+                return backarr(0, "请求错误");
+            }
+        }
+        $m_u = new userinfomodel();
+        $m_wu = new webusermodel();
+        $m_i = new inventv1model();
+        $m_w = new workermodel();
+        $inventInfo = $m_i->getInfo(['id' => $arr['id']]);
+        if (empty($inventInfo)) {
+            return backarr(0, "无数据");
+        }
+        Db::startTrans();
+        try {
+            $wuinfo = $m_wu->getInfo(['id' => $arr['releaseid']]);
+            if (empty($wuinfo)) {
+                throw new \Exception("用户信息错误");
+            }
+            $id = $inventInfo['id'];
+            $telno = $arr['telno'];
+            $userinfo = $m_u->getInfo(['telno' => $telno]);
+            if (empty($userinfo)) {
+                $addData = [
+                    'telno' => $telno,
+                    'isactive' => 0,
+                    'createtime' => date('Y-m-d H:i:s', time()),
+                    'platform' => '管理后台',
+                ];
+                $createuid = $m_u->insertData($addData);
+                if (empty($createuid)) {
+                    throw new \Exception("会员创建失败");
+                }
+                $workerAddData = [
+                    'userid' => $createuid,
+                    'telno' => $telno,
+                ];
+                $wid = $m_w->insertData($workerAddData);
+                if (empty($wid)) {
+                    throw new \Exception("工人信息创建失败");
+                }
+            } else {
+                $createuid = $userinfo['id'];
+            }
+            $arr['createuid'] = $createuid;
+            $updateData = [];
+            $updateField = ['createuid', 'city', 'disc', 'address', 'disstr', 'worktypeid', 'worktype', 'daysalary', 'info', 'town'];
+            foreach ($updateField as $key => $value) {
+                if ($arr[$value] !== $inventInfo[$value]) {
+                    $updateData[$value] = $arr[$value];
+                }
+            }
+            if (empty($inventInfo['code'])) {
+                $updateData['code'] = $this->getCode();
+            }
+            $row = $this->inventmodel->updateinfo(['id' => $id], $updateData);
+            if (empty($row)) {
+                throw new \Exception("需改失败");
+            }
+            //修改成功 记录log
+            log::info('update:' . $id);
+            log::info($updateData);
+            $m_l = new logmodel();
+            $jsonData = [
+                'inventid' => $id,
+                'webuserid' => isset($updateData['releaseid']) ? $updateData['releaseid'] : '',
+                'createuid' => isset($updateData['createuid']) ? $updateData['createuid'] : '',
+            ];
+            $logData = [
+                'type' => '招工修改',
+                'json' => json_encode($jsonData),
+                'create_date' => date('Y-m-d H:i:s'),
+            ];
+            $m_l->savelog(json_encode($logData));
+            Db::commit();
+            return backarr(1, "操作成功", ['id' => $id]);
+        } catch (\Exception $e) {
+            Db::rollback();
+            return backarr(0, $e->getMessage());
+        }
+    }
+    /***
+     * px端审核用
+     * 未审核 审核失败-》 审核成功
+     * 未审核->审核失败
+     * 20211117
+     * wj
+     */
+    public function updateispassbyid($arr)
+    {
+
+        if (!isset($arr['idlist']) || !is_array($arr['idlist'])) {
+            return backarr(0, "请求错误1");
+        }
+        if (!isset($arr['ispass']) || !in_array($arr['ispass'], [2, 1])) {
+            return backarr(0, "请求错误");
+        }
+        $ispass = $arr['ispass'];
+        $idlist = $arr['idlist'];
+        $m_i = new inventv1model();
+        $where = ['isactive' => 1];
+        switch ($ispass) {
+            case 1:
+                $where['ispass'] = ['in', [0, 2]];
+                break;
+            case 2:
+                $where['ispass'] = ['in', [0]];
+                break;
+        }
+        $where['id'] = ['in', $idlist];
+        $update = [
+            'ispass' => $ispass,
+            'passtime' => date('Y-m-d H:i:s'),
+            'passtype' => 2,
+        ];
+        $row = $m_i->updateinfo($where, $update);
+        if ($row <= 0) {
+            return backarr(0, "修改失败");
+        }
+        return backarr(1, "修改成功", ['row' => $row, 'idlist' => $idlist, 'ispass' => $ispass]);
+    }
+    /**
+     * 根据类型获取列表
+     * 20211213
+     * wj
+     */
+    public function getlistbywhere($arr)
+    {
+        //字段转译 key 请求字段 value 查询使用字段
+        $fileds = [
+            'a' => 'address', //用字符|分割
+            'lng' => 'lng',
+            'lat' => 'lat',
+            'wt' => 'worktype',
+            'r' => 'radii',
+            'od' => 'orderdaysalary', //order daysalary desc
+            'active' => 'isactive',
+        ];
+        $page = isset($arr['page']) && !empty($arr['page']) && is_numeric($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) && is_numeric($arr['size']) ? $arr['size'] : 10;
+        $useValue = [];
+        $pattern = '/[\'+%-]+/';
+        foreach ($fileds as $key => $value) {
+            if (isset($arr[$key]) && !empty($arr[$key]) && is_string($arr[$key])) {
+                $str = preg_match_all($pattern, $arr[$key]);
+                if ($str) {
+                    return backarr(0, "查询请求数据错误");
+                }
+                $useValue[$value] = $arr[$key];
+            }
+        }
+        $where = [];
+        if (isset($useValue['address']) && !empty($useValue['address'])) {
+            $addressArr = explode('|', $useValue['address']);
+            $searchAddress = [
+                'city' => isset($addressArr[0]) ? $addressArr[0] : '',
+                'disc' => isset($addressArr[1]) ? $addressArr[1] : '',
+                'town' => isset($addressArr[2]) ? $addressArr[2] : '',
+                'address' => isset($addressArr[3]) ? $addressArr[3] : '',
+            ];
+            $searchAddress = array_filter($searchAddress);
+            if (!empty($searchAddress)) {
+                $where = array_merge($where, $searchAddress);
+            }
+        }
+        if (isset($useValue['orderdaysalary']) && !empty($useValue['orderdaysalary'])) {
+            $useValue['orderdaysalary'] = true;
+        } else {
+            $useValue['orderdaysalary'] = false;
+        }
+        if (isset($useValue['radii']) && is_numeric($useValue['radii']) && !empty($useValue['radii'])) {
+            //有经纬度
+            $fillFidle = ['lng', 'lat'];
+            foreach ($fillFidle as $key => $value) {
+                if (isset($useValue[$value]) && is_numeric($useValue[$value]) && !empty($useValue[$value])) {
+                    $where[$value] = $useValue[$value];
+                }
+            }
+            $where['radii'] = $useValue['radii'];
+        }
+        if (isset($useValue['worktype']) && !empty($useValue['worktype'])) {
+            $where['worktype'] = $useValue['worktype'];
+        }
+        if (isset($useValue['isactive']) && in_array($useValue['isactive'], [0, 1]) && is_numeric($useValue['isactive'])) {
+            $where['isactive'] = $useValue['isactive'];
+        }
+        //$where['isactive'] = 1;
+        $where['ispass'] = 1;
+
+        $order = 'id desc'; //默认时间倒序
+        if ($useValue['orderdaysalary']) {
+            $order = 'daysalary desc'; //工资倒序
+        }
+        $m_i = new inventv1model();
+        $list = $m_i->getlistbymultiplecondition($where, $page, $size, $order);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        $t_u = new userinfomodel();
+        foreach ($list as $key => &$invent) {
+            $list[$key] = $this->getinfobyidforlist($invent['id']);
+        }
+        return backarr(1, "查询成功", $list);
+    }
+    /**
+     * 获取一定时间内无联系数量 默认5分钟
+     * 20211222
+     * wj
+     */
+    public function getnocalldata($arr)
+    {
+        $page = isset($arr['page']) && !empty($arr['page']) && is_numeric($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) && is_numeric($arr['size']) ? $arr['size'] : 10;
+        $where = [];
+        if (isset($arr['wname']) && !empty($arr['wname']) && is_string($arr['wname'])) {
+            $where['wname'] = $arr['wname'];
+        }
+        if (isset($arr['telno']) && !empty($arr['telno']) && is_numeric($arr['telno'])) {
+            $where['telno'] = $arr['telno'];
+        }
+        $m_i = new inventv1model();
+        //获取5分钟内无联系招工
+        $count = $m_i->getnocalldata(5, $where, true);
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_i->getnocalldata(5, $where, false, $page, $size);
+        $data = [
+            'count' => $count,
+            'list' => $list,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+}

+ 454 - 0
application/index/logic/jobhuntinglogic.php

@@ -0,0 +1,454 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 09:02:06
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-20 16:33:51
+ */
+namespace app\index\logic;
+
+use app\index\model\groupmodel;
+use app\index\model\jobhuntingmodel;
+use app\index\model\userinfomodel;
+use think\Log;
+
+class jobhuntinglogic
+{
+    private $jobhuntingmodel;
+    public function __construct()
+    {
+        $this->jobhuntingmodel = new jobhuntingmodel();
+    }
+    /*
+     * create by wj
+     * edit in 20211026
+     * edit by steelxu
+     * 增加联系信息
+     */
+    public function getinfobyid($id)
+    {
+        $where = ['id' => $id];
+        $info = $this->jobhuntingmodel->getInfo($where);
+        if (empty($info)) {
+            return false;
+        }
+        //edit by steelxu 20211026
+        $t_u = new userinfomodel();
+        $uid = $info['createuid'];
+        $uinfo = $t_u->selconinfobyid($uid);
+        $info['coninfo'] = $uinfo;
+        return $info;
+    }
+    public function insertinfo($info)
+    {
+        log::info($info);
+        if (!isset($info['createuid']) || empty($info['createuid'])) {
+            return backarr(0, "请求错误");
+        }
+        $uid = $info['createuid'];
+        $t_u = new userinfomodel();
+        $uinfo = $t_u->selconinfobyid($uid);
+        if (empty($uinfo)) {
+            return backarr(0, "无用户信息");
+        }
+        if (!isset($info['createdate']) || empty($info['createdate'])) {
+            $info['createdate'] = date('Y-m-d H:i:s', time());
+        }
+        if (isset($info['userstyle'])) {
+            if (!is_numeric($info['userstyle']) || !in_array($info['userstyle'], [1, 2])) {
+                $info['userstyle'] = 1;
+            }
+            if (2 == $info['userstyle']) {
+                $m_g = new groupmodel();
+                if (!isset($info['groupid']) || empty($info['groupid'])) {
+                    return backarr(0, "无班组id");
+                }
+                $groupinfo = $m_g->getinfo(['id' => $info['groupid']]);
+                if (empty($groupinfo)) {
+                    return backarr(0, "无组信息");
+                }
+            }
+            if (1 == $info['userstyle']) {
+                $m_u = new userinfomodel();
+                if (!isset($info['createuid']) || empty($info['createuid'])) {
+                    return backarr(0, "无创建人id");
+                }
+                $userinfo = $m_u->getinfo(['id' => $info['createuid']]);
+                if (empty($userinfo)) {
+                    return backarr(0, "无用户信息");
+                }
+                if (isset($info['groupid'])) {
+                    unset($info['groupid']);
+                }
+            }
+        }
+        if (isset($info['daysalary'])) {
+            if (!is_numeric($info['daysalary'])) {
+                return backarr(0, "日均工资格式错误");
+            }
+        }
+        /*
+        $where = [];
+        if (isset($info['userstyle']) && !empty($info['userstyle'])) {
+        $where['userstyle'] = $info['userstyle'];
+        }
+        if (isset($info['createuid']) && !empty($info['createuid'])) {
+        $where['createuid'] = $info['createuid'];
+        }
+        if (isset($info['groupid']) && !empty($info['groupid'])) {
+        $where['groupid'] = $info['groupid'];
+        }
+        if (!empty($where)) {
+        $where['isactive'] = 1;
+        $jhinfo = $this->jobhuntingmodel->getinfo($where);
+        if (!empty($jhinfo)) {
+        return backarr(0, "数据已存在");
+        }
+        }
+         */
+        $id = $this->jobhuntingmodel->insertData($info);
+        if (empty($id)) {
+            return backarr(0, "添加失败");
+        } else {
+            return backarr(1, "添加成功", ['id' => $id]);
+        }
+    }
+    /*
+     * 20211002
+     * edit by steelxu
+     * upade 改为 update
+     */
+
+    public function updateinfobyid($id, $updateData)
+    {
+        $where = ['id' => $id];
+        $result = $this->jobhuntingmodel->update($where, $updateData);
+        return $result;
+    }
+    public function updateisactivebyid($param)
+    {
+        if (!isset($param['id']) || empty($param['id'])) {
+            return backarr(0, "请求数据错误");
+        }
+        $id = $param['id'];
+        $info = $this->getinfobyid($id);
+        if (empty($info)) {
+            return backarr(0, "无数据");
+        }
+        if (1 != $info['isactive']) {
+            return backarr(0, "已关闭");
+        }
+        $updateData = [
+            'isactive' => 0,
+            'unactivetime' => date("y-m-d H:i:s", time()),
+        ];
+        $updateWhere = [
+            'id' => $id,
+        ];
+        $row = $this->jobhuntingmodel->updateinfo($updateWhere, $updateData);
+        if (!$row) {
+            return backarr(0, "修改失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    public function incconcountbyid($param)
+    {
+        if (!isset($param['id']) || empty($param['id'])) {
+            return backarr(0, "请求数据错误");
+        }
+        $id = $param['id'];
+        $info = $this->getinfobyid($id);
+        if (empty($info)) {
+            return backarr(0, "无数据");
+        }
+        $updateWhere = [
+            'id' => $id,
+        ];
+        $row = $this->jobhuntingmodel->incField($updateWhere, 'concount');
+        if (!$row) {
+            return backarr(0, "修改失败");
+        }
+        return backarr(1, "操作成功");
+    }
+    //根据经纬度获取列表
+    /*
+     * 20211003
+     * edit by steelxu5
+     * 需加上 isactive=1,只提供未关闭的信息
+     * 20211003
+     * edit by steelxu5
+     * 需要加上头像和通讯信息,
+     *
+     */
+    public function getlistbyrange($arr)
+    {
+        $fillArr = ['lng', 'lat'];
+        foreach ($fillArr as $key => $value) {
+            if (!isset($arr[$value]) || empty($arr[$value])) {
+                return backarr(0, "请求数据错误");
+            }
+        }
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $radii = isset($arr['radii']) && !empty($arr['radii']) ? $arr['radii'] : 100;
+        $minlat = $arr['lat'] - $radii;
+        $maxlat = $arr['lat'] + $radii;
+        $minlng = $arr['lng'] - $radii;
+        $maxlng = $arr['lng'] + $radii;
+        $where = [
+            'gps_lat' => ['between', $minlat . "," . $maxlat],
+            'gps_lng' => ['between', $minlng . "," . $maxlng],
+            'isactive' => 1,
+            'ispass' => 1,
+        ];
+        $list = $this->jobhuntingmodel->getList($where, '*', $page, $size);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        $t_u = new userinfomodel();
+        foreach ($list as &$invent) {
+            $uid = $invent['createuid'];
+            $uinfo = $t_u->selconinfobyid($uid);
+            $invent['coninfo'] = $uinfo;
+        }
+        return backarr(1, "查询成功", $list);
+    }
+    /*
+     * 20211003
+     * edit by steelxu5
+     * 需加上 isactive=1,只提供未关闭的信息
+     *
+     */
+    public function getlistbyaddress($arr)
+    {
+        $where = [];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        if (isset($arr['city'])) {
+            $where['city'] = ['like', "%" . $arr['city'] . "%"];
+        }
+        if (isset($arr['disc'])) {
+            $where['disc'] = ['like', "%" . $arr['disc'] . "%"];
+        }
+        if (isset($arr['address'])) {
+            $where['address'] = ['like', "%" . $arr['address'] . "%"];
+        }
+        if (empty($where)) {
+            return backarr(0, "请求数据错误");
+        }
+        $where['isactive'] = 1; //edit by steelxu 20211003
+        $where['ispass'] = 1;
+        $list = $this->jobhuntingmodel->getList($where, "*", $page, $size);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        $t_u = new userinfomodel();
+        foreach ($list as &$invent) {
+            $uid = $invent['createuid'];
+            $uinfo = $t_u->selconinfobyid($uid);
+            $invent['coninfo'] = $uinfo;
+        }
+        return backarr(1, "查询成功", $list);
+    }
+
+    /*
+     * 20211002
+     * steelxu5
+     * 获取用户本人发的招工信息
+     */
+    public function getinventlistbycuid($arr)
+    {
+        $crid = $arr['uid'];
+        $list = $this->jobhuntingmodel->sellistbyuid($crid);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        return backarr(1, "查询成功", $list);
+
+    }
+
+    /*
+     * 20211007
+     * edit by steelxu5
+     * 没有结果时,获取全部信息按地址发布
+     *
+     */
+    public function getlistbytime($arr)
+    {
+        $where = [];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $where['isactive'] = 1; //edit by steelxu 20211003
+        $where['ispass'] = 1;
+        $list = $this->jobhuntingmodel->getList($where, "*", $page, $size);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        $t_u = new userinfomodel();
+        foreach ($list as &$invent) {
+            $uid = $invent['createuid'];
+            $uinfo = $t_u->selconinfobyid($uid);
+            $invent['coninfo'] = $uinfo;
+        }
+        return backarr(1, "查询成功", $list);
+    }
+    /***
+     * 按工种查询
+     * 20211026
+     * wj
+     */
+    public function getlistbyworktype($arr)
+    {
+        if (!isset($arr['worktype']) || empty($arr['worktype'])) {
+            return backarr(0, "请求数据错误");
+        }
+        $where = [];
+        $worktype = $arr['worktype'];
+        $where['worktype'] = $worktype;
+        if (isset($arr['city']) && !empty($arr['city'])) {
+            $where['city'] = $arr['city'];
+        }
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $where['isactive'] = 1;
+        $where['ispass'] = 1;
+        /*$order = 'id desc';
+        if (isset($arr['order']) && !empty($arr['order'])) {
+        $order = $arr['order'];
+        }*/
+        $list = $this->jobhuntingmodel->getList($where, "*", $page, $size);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        $t_u = new userinfomodel();
+        foreach ($list as &$invent) {
+            $uid = $invent['createuid'];
+            $uinfo = $t_u->selconinfobyid($uid);
+            $invent['coninfo'] = $uinfo;
+        }
+        return backarr(1, "查询成功", $list);
+    }
+    /*
+     * 20211007
+     * wj
+     * 根据查询条件返回结果
+     * 目前仅pc后台使用
+     */
+    public function getlistbysearch($arr)
+    {
+        $where = [];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        if (isset($arr['userstyle'])) {
+            $where['userstyle'] = $arr['userstyle'];
+        }
+        if (isset($arr['wname'])) {
+            $where['wname'] = $arr['wname'];
+        }
+        if (isset($arr['telno'])) {
+            $where['telno'] = $arr['telno'];
+        }
+        if (isset($arr['isactive'])) {
+            $where['isactive'] = $arr['isactive'];
+        }
+        if (isset($arr['ispass'])) {
+            $where['ispass'] = $arr['ispass'];
+        }
+        if (isset($arr['worktype'])) {
+            $where['worktype'] = $arr['worktype'];
+        }
+        if (isset($arr['createdate']) && is_array($arr['createdate'])) {
+            $createdate = array_filter($arr['createdate']);
+            if (2 == count($createdate)) {
+                $where['createdate'] = $arr['createdate'];
+            }
+        }
+        $order = 'id desc';
+        if (isset($arr['order']) && !empty($arr['order'])) {
+            $order = $arr['order'];
+        }
+        $count = $this->jobhuntingmodel->getlistjoinuser($where, "count", $page, $size, $order);
+        if ($count < 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $this->jobhuntingmodel->getlistjoinuser($where, "*", $page, $size, $order);
+        $data = [
+            'count' => $count ? $count : 0,
+            'list' => $list,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+    /***
+     * pc端审核用
+     * 未审核 审核失败-》 审核成功
+     * 未审核->审核失败
+     * 20211117
+     * wj
+     */
+    public function updateispassbyid($arr)
+    {
+        if (!isset($arr['idlist']) || !is_array($arr['idlist'])) {
+            return backarr(0, "请求错误");
+        }
+        if (!isset($arr['ispass']) || !in_array($arr['ispass'], [2, 1])) {
+            return backarr(0, "请求错误");
+        }
+        $ispass = $arr['ispass'];
+        $idlist = $arr['idlist'];
+        $passtype = $arr['passtype'];
+        $where = ['isactive' => 1];
+        switch ($ispass) {
+            case 1:
+                $where['ispass'] = ['in', [0, 2]];
+                break;
+            case 2:
+                $where['ispass'] = ['in', [0]];
+                break;
+        }
+        $where['id'] = ['in', $idlist];
+        $update = [
+            'ispass' => $ispass,
+            'passtime' => date('Y-m-d H:i:s'),
+            'passtype' => $passtype,
+        ];
+        $row = $this->jobhuntingmodel->updateinfo($where, $update);
+        if ($row <= 0) {
+            return backarr(0, "修改失败");
+        }
+        return backarr(1, "修改成功", ['row' => $row, 'idlist' => $idlist, 'ispass' => $ispass]);
+    }
+    /**
+     * pc 后台改数据
+     * 20211207
+     * wj
+     */
+    public function updateinfoforadmin($arr)
+    {
+        if (!isset($arr['id']) || !is_numeric($arr['id'])) {
+            return backarr(0, "请求错误");
+        }
+        $id = $arr['id'];
+        $where = ['id' => $id];
+        $info = $this->jobhuntingmodel->getInfo($where);
+        if (empty($info)) {
+            return backarr(0, "无数据");
+        }
+        $updateField = ['info'];
+        $upateData = [];
+        foreach ($updateField as $key => $value) {
+            if (isset($arr[$value])) {
+                if ($arr[$value] != $info[$value]) {
+                    $upateData[$value] = $arr[$value];
+                }
+            }
+        }
+        if (empty($upateData)) {
+            return backarr(0, "无修改数据");
+        }
+        $row = $this->jobhuntingmodel->updateinfo($where, $upateData);
+        if ($row <= 0) {
+            return backarr(0, "修改错误");
+        }
+        return backarr(1, "修改成功", ['id' => $id]);
+    }
+}

+ 102 - 0
application/index/logic/loginlogic.php

@@ -0,0 +1,102 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-03 15:18:25
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-10 17:41:01
+ */
+namespace app\index\logic;
+
+use app\index\model\companymodel;
+use app\index\model\smscoderecordmodel;
+use app\index\model\userinfomodel;
+use app\index\model\workermodel;
+
+class loginlogic
+{
+    private function checkwechatlogin($loginfo)
+    {
+        if (!isset($loginfo['unionid']) || empty($loginfo['unionid'])) {
+            return false;
+        }
+        return true;
+    }
+    //短信登录
+    /*
+     * 20210908
+     * edit by steelxu
+     * 如果短信验证成功应当返回用户数据
+     */
+    public function smslogin($loginfo)
+    {
+        $m_sc = new smscoderecordmodel();
+        $m_u = new userinfomodel();
+        $m_w = new workermodel();
+        $checkResult = $this->checksmslogin($loginfo);
+        if (!$checkResult) {
+            return backarr(-1, '请求数据错误');
+        }
+        $tel = $loginfo['tel'];
+        $smscode = $loginfo['smscode'];
+        $searchData = [
+            'tel' => $tel,
+            'smscode' => $smscode,
+        ];
+        $sccInfo = $m_sc->getinfo($searchData);
+        if ($sccInfo) {
+            $m_sc->deletebyid($sccInfo['id']);
+            $uInfo = $m_u->getInfo(['telno' => $tel]);
+            if (empty($uInfo['isactive'])) {
+                return backarr(0, '用户状态不可用');
+            }
+            if (!$uInfo) {
+                $insertinfo['telno'] = $tel;
+                $id = $m_u->insertData($insertinfo);
+                $info = [
+                    'id' => $id,
+                    'gender' => '',
+                    'telno' => $tel,
+                    'wname' => '',
+                    'isactive' => '1',
+                    'labid' => 0,
+                    'sfzid' => false,
+                    'company' => [], //非企业用户
+                ];
+                //worderinsert
+                $winsertInfo = [
+                    'userid' => $id,
+                    'telno' => $tel,
+                ];
+                $wid = $m_w->insertData($winsertInfo);
+                //return backarr(2, '未注册');
+                return backarr(1, '登录成功', $info);
+            } else {
+                //$m_sc->deletebyid($sccInfo['id']);
+                $m_c = new companymodel();
+                $cinfo = $m_c->getInfo(['userid' => $uInfo['id'], 'isactive' => 1], ['id', 'company']);
+                $info = array();
+                $info['id'] = $uInfo['id'];
+                $info['gender'] = $uInfo['gender'];
+                $info['telno'] = $uInfo['telno'];
+                $info['wname'] = $uInfo['wname'];
+                $info['isactive'] = strval($uInfo['isactive']);
+                $info['labid'] = $uInfo['labid'];
+                $info['sfzid'] = empty($uInfo['sfzid']) ? false : true;
+                $info['company'] = empty($cinfo) ? [] : $cinfo;
+                return backarr(1, '登录成功', $info);
+            }
+        } else {
+            return backarr(0, '登录失败');
+        }
+    }
+    private function checksmslogin($loginfo)
+    {
+        $fillFiled = ['tel', 'smscode'];
+        foreach ($fillFiled as $value) {
+            if (!isset($loginfo[$value]) || empty($loginfo[$value]) || !is_numeric($loginfo[$value])) {
+                return false;
+            }
+        }
+        return true;
+    }
+}

+ 261 - 0
application/index/logic/orderlogic.php

@@ -0,0 +1,261 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2021/6/25
+ * Time: 15:52
+ */
+namespace app\index\logic;
+
+use app\index\model\payordermodel;
+use app\index\model\scoreordermodel;
+use app\index\model\userinfomodel;
+use think\Db;
+
+class orderlogic
+{
+    /*
+     * 20210625
+     */
+    public function savenewpayorder($arr)
+    {
+        $t_p = new payordermodel();
+        $rid = $t_p->insinfo($arr);
+        return $rid;
+
+    }
+
+    /**
+     * 根据订单号获取订单信息
+     */
+    public function getorderinfobyoutorderno($outorderno)
+    {
+        $t_p = new payordermodel();
+        $info = $t_p->selinfobyorder($outorderno);
+        return $info;
+    }
+    /**
+     * 根据订单号获取积分订单信息
+     */
+    public function getscoreorderinfobyoutorderno($outorderno)
+    {
+        $m_so = new scoreordermodel();
+        $info = $m_so->getInfo(['outorderno' => $outorderno]);
+        return $info;
+    }
+
+    /***
+     * 积分购买 下订单信息
+     * wj
+     *  20211108
+     */
+    public function createbuyscoreorder($arr)
+    {
+        if (!isset($arr['total_fee']) || !isset($arr['score'])) {
+            return backarr(0, "请求错误");
+        }
+        $m_u = new userinfomodel();
+        if (isset($arr['openid'])) {
+            $wuInfo = $m_u->getInfo(['openid' => $arr['openid']]);
+        }
+        if (isset($arr['wid'])) {
+            $wuInfo = $m_u->getInfo(['id' => $arr['wid']]);
+        }
+        if (empty($wuInfo)) {
+            return backarr(0, "无用户信息");
+        }
+        if (!isset($arr['siliverscore']) || empty($arr['siliverscore'])) {
+            $arr['siliverscore'] = 0;
+        }
+        $wid = $wuInfo['id'];
+        $total_fee = $arr['total_fee'];
+        $openid = $wuInfo['openid'];
+        $score = $arr['score'];
+        $ordrNo = createOrderNo();
+        $total_fee = bcmul($total_fee, 100); //分
+        $body = "水猫工匠(天津)科技有限公司-网上服务平台-积分购买";
+        $orderData = [
+            'wid' => $wid,
+            'orderNo' => $ordrNo,
+            'total_fee' => $total_fee,
+            'body' => $body,
+            'openid' => $openid,
+            'time' => time(),
+            'score' => $score,
+            'siliverscore' => $arr['siliverscore'],
+        ];
+        return backarr(1, '', $orderData);
+    }
+    /***
+     * 保存购买积分订单
+     * 20211108
+     * wj
+     */
+    public function savebuyscore($info)
+    {
+        $m_po = new payordermodel();
+        $m_so = new scoreordermodel();
+        $outorderno = $info['orderNo'];
+        $poinfo = $m_po->selinfobyorder($outorderno);
+        if ($poinfo) {
+            return backarr(0, "支付单已存在");
+        }
+        $soinfo = $m_so->getInfo(['outorderno' => $outorderno]);
+        if ($soinfo) {
+            return backarr(0, "积分订单已存在");
+        }
+        //保存支付数据
+        Db::startTrans();
+        try {
+            $openid = isset($info['openid']) ? $info['openid'] : '';
+            $payorder['wid'] = $info['wid'];
+            $payorder['openid'] = $openid;
+            $payorder['prepay_id'] = $info['prepay_id'];
+            $payorder['createtime'] = date('Y-m-d H:i:s', time());
+            $payorder['payfee'] = $info['total_fee'];
+            $payorder['outorderno'] = $info['orderNo'];
+            $payorder['order_type'] = 2;
+            $orderid = $m_po->insinfo($payorder);
+            if (empty($orderid)) {
+                throw new \Exception('支付单创建失败');
+            }
+            //保存积分数据
+            $moInsertInfo = [
+                'orderid' => $orderid,
+                'score' => $info['score'],
+                'siliverscore' => $info['siliverscore'],
+                'wid' => $info['wid'],
+                'openid' => $openid,
+                'outorderno' => $info['orderNo'],
+            ];
+            $soid = $m_so->insertData($moInsertInfo);
+            if (empty($soid)) {
+                throw new \Exception('积分订单创建失败');
+            }
+            Db::commit();
+            return backarr(1, '创建成功', ['orderid' => $orderid]);
+        } catch (\Exception $e) {
+            Db::rollback();
+            return backarr(0, $e->getMessage());
+        }
+
+    }
+
+    /***
+     * 积分购买回调
+     * wj
+     * 20211108
+     */
+    public function callbackbuyscore($arr)
+    {
+        $fillField = ['outorderno', 'orderstatus', 'ispay'];
+        foreach ($fillField as $key => $value) {
+            if (!isset($arr[$value])) {
+                return backarr(0, "请求错误");
+            }
+        }
+        $m_so = new scoreordermodel();
+        $m_po = new payordermodel();
+        $outorderno = $arr['outorderno'];
+        $orderstatus = $arr['orderstatus'];
+        $isfrontback = 0;
+        $isreatback = 0;
+        if (isset($arr['is_front_back'])) {
+            $isfrontback = 1;
+        }
+        if (isset($arr['is_reat_back'])) {
+            $isreatback = 1;
+        }
+
+        $ispay = $arr['ispay'];
+        $poinfo = $m_po->selinfobyorder($outorderno);
+        if (empty($poinfo)) {
+            return backarr(0, "无支付单信息");
+        }
+        if (1 == $poinfo['ispay']) {
+            //已支付不再修改
+            return backarr(2, "订单已支付");
+        }
+        $soinfo = $m_so->getInfo(['outorderno' => $outorderno]);
+        if (empty($soinfo)) {
+            return backarr(0, "无积分订单信息");
+        }
+        $poUpdateData = [
+            'paytime' => date('Y-m-d H:i:s'),
+            'orderstatus' => $orderstatus,
+            'ispay' => $ispay,
+            'is_front_back' => $isfrontback,
+            'is_reat_back' => $isreatback,
+        ];
+        $row = $m_po->updorederstatusbyid($poinfo['id'], $poUpdateData);
+        if (empty($row)) {
+            return backarr(0, "支付单修改失败");
+        }
+        if (1 == $ispay) {
+            $soUpdateData = [
+                'paytime' => date('Y-m-d H:i:s'),
+            ];
+            $row = $m_so->updateinfo(['id' => $soinfo['id']], $soUpdateData);
+            if (empty($row)) {
+                return backarr(0, "积分订单修改失败");
+            }
+        }
+        if (8 == $orderstatus) {
+            return backarr(3, "支付失败");
+        }
+        if (3 == $orderstatus) {
+            $reurnData = [
+                'orderid' => $poinfo['id'],
+                'outorderno' => $outorderno,
+            ];
+            return backarr(1, "支付成功", $reurnData);
+        }
+    }
+
+    /**
+     * 购买积分列表 仅pc端用
+     * 20211228
+     * wj
+     */
+    public function getlistbywhere($arr)
+    {
+        $t_f = new payordermodel();
+        $where = [];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        if (isset($arr['wname']) && !empty($arr['wname']) && is_string($arr['wname'])) {
+            $where['u.wname'] = ['like', "%" . $arr['wname'] . "%"];
+        }
+        if (isset($arr['telno']) && !empty($arr['telno']) && is_numeric($arr['telno'])) {
+            $where['u.telno'] = ['like', "%" . $arr['telno'] . "%"];
+        }
+        if (isset($arr['ispay']) && is_numeric($arr['ispay']) && in_array($arr['ispay'], [0, 1])) {
+            $where['po.ispay'] = $arr['ispay'];
+        }
+        if (isset($arr['ordertype']) && is_numeric($arr['ordertype'])) {
+            $where['po.order_type'] = $arr['ordertype'];
+        }
+        if (isset($arr['createtime']) && is_array($arr['createtime'])) {
+            $createtime = array_filter($arr['createtime']);
+            if (2 == count($createtime)) {
+                $where['po.createtime'] = ['between', $arr['createtime']];
+            }
+        }
+        if (isset($arr['paytime']) && is_array($arr['paytime'])) {
+            $createtime = array_filter($arr['paytime']);
+            if (2 == count($createtime)) {
+                $where['po.paytime'] = ['between', $arr['paytime']];
+            }
+        }
+        $count = $t_f->getList($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $t_f->getList($where, 'po.*,u.wname,u.telno', $page, $size);
+        $data = [
+            'count' => $count,
+            'list' => $list,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+}

+ 253 - 0
application/index/logic/partnerlogic.php

@@ -0,0 +1,253 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-11-18 11:26:25
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-29 14:44:51
+ */
+namespace app\index\logic;
+
+use app\index\model\partnergainmodel;
+use app\index\model\partnermembermodel;
+use app\index\model\partnermodel;
+use app\index\model\userinfomodel;
+
+class partnerlogic
+{
+    /**
+     * 新建合伙人
+     * 20211118
+     * wj
+     */
+    public function newpartnerinfo($arr)
+    {
+        if (!isset($arr['userid']) || empty($arr['userid'])) {
+            return backarr(0, "请求错误");
+        }
+        $userid = $arr['userid'];
+        $m_u = new userinfomodel();
+        $uwhere = ['id' => $userid];
+        $userinfo = $m_u->getInfo($uwhere);
+        if (empty($userinfo)) {
+            return backarr(0, "无用户信息");
+        }
+        if (!isset($arr['username']) || empty($arr['username'])) {
+            $name = $userinfo['wname'];
+        } else {
+            $name = $arr['username'];
+        }
+        $m_p = new partnermodel();
+        $pwhere = ['userid' => $userid];
+        $pinfo = $m_p->getInfo($pwhere);
+        if (!empty($pinfo)) {
+            return backarr(0, "已存在");
+        }
+        $insertData = [
+            'userid' => $userid,
+            'username' => $name,
+            'createdate' => date("Y-m-d H:i:s"),
+        ];
+
+        $id = $m_p->insertData($insertData);
+        if (empty($id)) {
+            return backarr(0, "操作失败");
+        }
+        $where = ['id' => $id];
+        $pinfo = $m_p->getInfo($where);
+        return backarr(1, "操作成功", $pinfo);
+    }
+
+    /***
+     * 新建合伙人下级
+     * 20211118
+     * wj
+     * eidt by steelxu
+     * 20220112
+     * 因为合伙人可能从通过专用分享码中拉取更多人的用户中提升,所以一开始panter用户并不一定是真正的合伙人,
+     *
+     */
+    public function newpartnermember($arr)
+    {
+        $fillfield = ['partneruserid', 'memberuserid'];
+        foreach ($fillfield as $key => $value) {
+            if (!isset($arr[$value]) || empty($arr[$value])) {
+                return backarr(0, "请求错误");
+            }
+        }
+        $partneruserid = $arr['partneruserid'];
+        $memberuserid = $arr['memberuserid'];
+        $m_u = new userinfomodel();
+        $uwhere = ['id' => $partneruserid];
+        $puserinfo = $m_u->getInfo($uwhere);
+        if (empty($puserinfo)) {
+            return backarr(0, "无合伙人用户信息");
+        }
+        $uwhere = ['id' => $memberuserid];
+        $muserinfo = $m_u->getInfo($uwhere);
+        if (empty($muserinfo)) {
+            return backarr(0, "无下级用户信息");
+        }
+        if (empty($muserinfo['sfzid'])) {
+            $arr['isadd'] = 0;
+            if (isset($arr['addmemberdate'])) {
+                unset($arr['addmemberdate']);
+            }
+        } else {
+            $arr['isadd'] = 1;
+            $arr['addmemberdate'] = date('Y-m-d H:i:s');
+        }
+        //steelxu5 edity 20220112 取消校验
+       /* $m_p = new partnermodel();
+        $pinfo = $m_p->getInfo(['userid' => $partneruserid, 'isactive' => 1]);
+        if (empty($pinfo)) {
+            return backarr(0, "合伙人信息不存在");
+        }*/
+        $m_pm = new partnermembermodel();
+        $pmwhere = [
+            'partneruserid' => $partneruserid,
+            'memberuserid' => $memberuserid,
+        ];
+        $pminfo = $m_pm->getInfo($pmwhere);
+        if (!empty($pminfo)) {
+            return backarr(0, "已存在");
+        }
+        $arr['intodate'] = date('Y-m-d H:i:s');
+        $id = $m_pm->insertData($arr);
+        if (empty($id)) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+
+    /**
+     * 修改合伙人下级信息 上级:下级 1:n
+     * 20211118
+     * wj
+     */
+    public function addbymemberuserid($arr)
+    {
+        if (!isset($arr['memberuserid']) || empty($arr['memberuserid'])) {
+            return backarr(0, "请求错误");
+        }
+        $memberuserid = $arr['memberuserid'];
+        $m_pm = new partnermembermodel();
+        $where = [
+            'memberuserid' => $memberuserid,
+            'isadd' => 0,
+        ];
+        $info = $m_pm->getInfo($where);
+        if (empty($info)) {
+            return backarr(0, "无数据");
+        }
+        $updateData = [
+            'isadd' => 1,
+            'addmemberdate' => date('Y-m-d H:i:s'),
+        ];
+        $row = $m_pm->updateinfo(['id' => $info['id']], $updateData);
+        if ($row <= 0) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(0, "操作成功", ['id' => $info['id']]);
+    }
+
+    /***
+     * 新建合伙人收益
+     * 20211118
+     * wj
+     */
+    public function newpartnergain($arr)
+    {
+        $fillfield = ['userid', 'daygain'];
+        foreach ($fillfield as $key => $value) {
+            if (!isset($arr[$value]) || empty($arr[$value])) {
+                return backarr(0, "请求错误");
+            }
+        }
+        $userid = $arr['userid'];
+        $m_u = new userinfomodel();
+        $uwhere = ['id' => $userid];
+        $userinfo = $m_u->getInfo($uwhere);
+        if (empty($userinfo)) {
+            return backarr(0, "无用户信息");
+        }
+        $m_p = new partnermodel();
+        $pinfo = $m_p->getInfo(['userid' => $userid, 'isactive' => 1]);
+        if (empty($pinfo)) {
+            return backarr(0, "合伙人信息不存在");
+        }
+        $arr['gaindate'] = date('Y-m-d H:i:s');
+        $m_pg = new partnergainmodel();
+        $id = $m_pg->insertData($arr);
+        if (empty($id)) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(0, "操作成功", ['id' => $id]);
+    }
+
+    /**
+     * 获取合伙人下级列表
+     * 20211118
+     * wj
+     */
+    public function getpartnermemberlist($arr)
+    {
+        if (!isset($arr['partneruserid']) || empty($arr['partneruserid'])) {
+            return backarr(0, "请求错误");
+        }
+        $partneruserid = $arr['partneruserid'];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $where = [];
+        if (isset($arr['isadd']) && in_array($arr['isadd'], [0, 1])) {
+            $where['isadd'] = $arr['isadd'];
+        }
+        if (isset($arr['isadd']) && in_array($arr['isadd'], [0, 1])) {
+            $where['isadd'] = $arr['isadd'];
+        }
+        $m_pm = new partnermembermodel();
+        $m_u = new userinfomodel();
+        $count = $m_pm->getList($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_pm->getList($where, '*', $page, $size, 'id asc')->toArray();
+        $userinfofiled = ['wname', 'gender', 'wage'];
+        foreach ($list as $key => $value) {
+            $uwhere = ['id' => $value['memberuserid']];
+            $userinfo = $m_u->getInfo($uwhere, $userinfofiled)->toArray();
+            $list[$key] = array_merge($value, $userinfo);
+        }
+        return backarr(1, "查询成功", $list);
+    }
+
+    /**
+     * 修改合伙人信息
+     * 20211229
+     * wj
+     */
+    public function updateinfobyid($id, $updatedata)
+    {
+        $m_p = new partnermodel();
+        $where = ['id' => $id];
+        //$info = $m_p->getInfo($where);
+        $row = $m_p->updateinfo($where, $updatedata);
+        if (!$row) {
+            return backarr(0, "修改失败");
+        }
+        return backarr(1, "修改成功", $where);
+    }
+
+    /*
+     * steelxu5
+     * 20220113
+     *  获得某人拉来的人员数量
+     * 不需要考虑实名认证,也就是不需要是正式的合伙人下级
+     */
+    public function getmembercountbypartnerid($arr){
+        $partneruid=$arr['puserid'];
+        $t_pm=new partnermembermodel();
+        $rcount=$t_pm->selcountbypartnerid($partneruid);
+        return backarr(1, "汇总数据", $rcount);
+    }
+
+}

+ 231 - 0
application/index/logic/partylogic.php

@@ -0,0 +1,231 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-11-18 11:26:25
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-29 14:44:51
+ */
+
+namespace app\index\logic;
+
+use app\index\model\userpartymodel;
+use app\index\model\userpartypicturemodel;
+use app\index\logic\businesslogic;
+use app\index\model\userinfomodel;
+
+class partylogic
+{
+    /**
+     * 获取活动信息
+     *
+     * @param [array] $arr
+     * @return void
+     */
+    public function getpartyinfo($arr)
+    {
+        if (!isset($arr['code']) || empty($arr['code'])) {
+            return backarr(0, "请求失败");
+        }
+        $code = $arr['code'];
+        $data = [
+            'type' => 'normal',
+            'typeid' => 1,
+            //'code' => 'P202201121202'
+            'code' => $code
+        ];
+        $l_bl = new businesslogic();
+        $result = $l_bl->handlepartybusiness($data);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        return backarr(1, "success", $result['data']);
+    }
+    /**
+     * 用户参与活动
+     * wj
+     * 20220112
+     * @return array
+     */
+    public function partinparty($arr)
+    {
+        $fillfield = ['userid', 'code'];
+        foreach ($fillfield as $key => $value) {
+            if (!isset($arr[$value]) || empty($arr[$value])) {
+                return backarr(0, "请求失败");
+            }
+        }
+        $userid = $arr['userid'];
+        $code = $arr['code'];
+        //活动业务处理
+        $data = [
+            'userid' => $userid,
+            'type' => 'normal',
+            'typeid' => 1,
+            //'code' => 'P202201121202'
+            'code' => $code
+        ];
+        $l_bl = new businesslogic();
+        $result = $l_bl->handlepartybusiness($data);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $partyinfo = $result['data'];
+        $partyid = $partyinfo['id'];
+        $m_u = new userinfomodel();
+        $uinfo = $m_u->getInfo(['id' => $userid], ['wname', 'id']);
+        if (empty($uinfo)) {
+            return backarr(0, "无用户信息");
+        }
+        $m_up = new userpartymodel();
+        $where  = [
+            'partyid' => $partyid,
+            'userid' => $userid
+        ];
+        $upinfo = $m_up->getInfo($where);
+        $isnew = false;
+        if (empty($upinfo)) {
+            $upinsertData = [
+                'partyid' => $partyid,
+                'userid' => $userid,
+                'createtime' => date('Y-m-d H:i:s')
+            ];
+            $upid = $m_up->insertData($upinsertData);
+            if (empty($upid)) {
+                return backarr(0, "用户活动信息创建失败");
+            }
+            $where = ['id' => $upid];
+            $upinfo = $m_up->getInfo($where);
+            $isnew = true;
+        }
+        $upinfo['isnew'] = $isnew;
+        $upinfo['userinfo'] = $uinfo;
+        return backarr(1, "查询成功", $upinfo);
+    }
+    /**
+     * 保存参与信息
+     * wj
+     * 20220112
+     * @return array
+     */
+    public function saveinfo($arr)
+    {
+        if (!isset($arr['id']) || empty($arr['id'])) {
+            return backarr(0, "请求失败");
+        }
+        $id = $arr['id'];
+        $m_up = new userpartymodel();
+        $where  = [
+            'id' => $id
+        ];
+        $upinfo = $m_up->getInfo($where);
+        if (empty($upinfo)) {
+            return backarr(0, '无对应信息');
+        }
+        $updateData = [];
+        if (isset($arr['info']) && !empty($arr['info']) && is_string($arr['info'])) {
+            $updateData['info'] = $arr['info'];
+        }
+        if (empty($updateData)) {
+            return backarr(0, "无修改信息");
+        }
+        $row = $m_up->updateinfo($where, $updateData);
+        return backarr(1, "修改成功", ['id' => $id]);
+    }
+    /**
+     * 保存参与图片
+     * wj
+     * 20220112
+     * @return array
+     */
+    public function savepicture($arr)
+    {
+        $m_upp = new userpartypicturemodel();
+        $isnew = true;
+        $id = 0;
+        if (isset($arr['id']) && !empty($arr['id'])) {
+            $where = [
+                'id' => $arr['id'],
+                'userid' => $arr['userid'],
+                'partyid' => $arr['partyid'],
+            ];
+            $info = $m_upp->getInfo($where);
+            if ($info) {
+                $isnew = false;
+                $id = $info['id'];
+                $updatefield = ['pictureurl'];
+                $updateData = [];
+                foreach ($updatefield as $key => $value) {
+                    if (isset($arr[$value]) && $arr[$value] != $info[$value]) {
+                        $updateData[$value] = $arr[$value];
+                    }
+                }
+                if (!empty($updateData)) {
+                    $where = ['id' => $id];
+                    $row = $m_upp->updateinfo($where, $updateData);
+                    if (empty($row)) {
+                        return backarr(0, "图片修改失败");
+                    }
+                }
+            }
+        }
+        if ($isnew) {
+            $id = $m_upp->insertData($arr);
+            if (empty($id)) {
+                return backarr(0, "新增失败");
+            }
+        }
+        if (empty($id)) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "新增成功", ['id' => $id]);
+    }
+    /**
+     * 获取上传图片
+     * wj
+     * 20220112
+     * @return array
+     */
+    public function getpicture($arr)
+    {
+        $m_upp = new userpartypicturemodel();
+        $where = [
+            'partyid' => $arr['partyid'],
+            'userid' => $arr['userid']
+        ];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $count = $m_upp->getList($where, "count");
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list  = $m_upp->getList($where, "*", $page, $size, 'sort asc');
+        $data = [
+            'count' => $count,
+            'list' => $list
+        ];
+        return backarr(1, "新增成功", $data);
+    }
+    /**
+     * 设置上传完成
+     * wj
+     * 20220114
+     * @return array
+     */
+    public function setisoverbyid($arr){
+        if (!isset($arr['id']) || empty($arr['id'])) {
+            return backarr(0, "请求失败");
+        }
+        $id = $arr['id'];
+        $m_up = new userpartymodel();
+        $where  = [
+            'id' => $id
+        ];
+        $upinfo = $m_up->getInfo($where);
+        if (empty($upinfo)) {
+            return backarr(0, '无对应信息');
+        }
+        $updateData = ['isover'=>1];
+        $row = $m_up->updateinfo($where, $updateData);
+        return backarr(1, "修改成功", ['id' => $id]);
+    }
+}

+ 14 - 0
application/index/logic/permissionlogic.php

@@ -0,0 +1,14 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:16:29
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-29 16:18:26
+ */
+//use app\index\model\rolesmodel;
+//use app\index\model\roleusermodel;
+
+class permissionlogic
+{
+
+}

+ 229 - 0
application/index/logic/rolelogic.php

@@ -0,0 +1,229 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:16:29
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-09 16:21:40
+ */
+namespace app\index\logic;
+
+use app\index\model\rolesmodel;
+use app\index\model\roleusermodel;
+use app\index\model\webusermodel;
+
+class rolelogic
+{
+    /**
+     * 用户组新增
+     * 20211029
+     * wj
+     */
+    public function newinfo($info)
+    {
+        $m_r = new rolesmodel();
+        $flagbit = $info['flag_bit'];
+        $roleinfo = $m_r->getInfo(['flag_bit' => $flagbit], ['id']);
+        if ($roleinfo) {
+            return backarr(0, "数据已存在");
+        }
+        $id = $m_r->insertData($info);
+        if (!$id) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    /**
+     * 用户组修改
+     * 20211029
+     * wj
+     */
+    public function updateinfo($arr)
+    {
+        if (!isset($arr['id']) || empty($arr['id'])) {
+            return backarr(0, "请求失败");
+        }
+        $m_r = new rolesmodel();
+        $id = $arr['id'];
+        $where = ['id' => $id];
+        $rinfo = $m_r->getInfo($where);
+        if (empty($rinfo)) {
+            return backarr(0, "无数据");
+        }
+        $updateData = [];
+        if (isset($arr['is_active']) && $rinfo['is_active'] != $arr['is_active']) {
+            $updateData['is_active'] = $arr['is_active'];
+        }
+        if (isset($arr['pre_id']) && $rinfo['pre_id'] != $arr['pre_id']) {
+            $updateData['pre_id'] = $arr['pre_id'];
+        }
+        if (isset($arr['flag_bit']) && $rinfo['flag_bit'] != $arr['flag_bit']) {
+            $updateData['flag_bit'] = $arr['flag_bit'];
+        }
+        if (isset($arr['name']) && $rinfo['name'] != $arr['name']) {
+            $updateData['name'] = $arr['name'];
+        }
+        if (empty($updateData)) {
+            return backarr(0, "无修改数据");
+        }
+        $row = $m_r->updateinfo($where, $updateData);
+        if (!$row) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    /**
+     * 用户组删除 不使用
+     * 20211029
+     * wj
+     */
+    public function deleteinfo($arr)
+    {
+        if (!isset($arr['id']) || empty($arr['id'])) {
+            return backarr(0, "请求失败");
+        }
+        $m_r = new rolesmodel();
+        $id = $arr['id'];
+        $where = ['id' => $id];
+        $rinfo = $m_r->getInfo($where);
+        if (empty($rinfo)) {
+            return backarr(0, "无数据");
+        }
+        $row = $m_r->deleteinfo($where);
+        if (!$row) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    /**
+     * 加入用户组
+     * 20211029
+     * wj
+     * uid 用户id
+     * rid 组id
+     */
+    public function addroleuser($info)
+    {
+        $result = $this->checkUser($info);
+        if (!$uinfo) {
+            return backarr(0, "无用户数据");
+        }
+        if (!empty($result['ruinfo'])) {
+            return backarr(0, "数据已存在");
+        }
+        $m_ru = new roleusermodel();
+        $id = $m_ru->insertData($info);
+        if (!$id) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    /**
+     * 删除用户组用户
+     * 20211029
+     * wj
+     */
+    public function deleteroleuser($arr)
+    {
+        $id = $arr['id'];
+        $m_ru = new roleusermodel();
+        $row = $m_ru->deleteinfo(['id' => $id]);
+        if (!$row) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+
+    private function checkUser($info)
+    {
+        //校验用户
+        $m_wu = new webusermodel();
+        $uid = $info['uid'];
+        $where = [
+            'id' => $uid,
+        ];
+        $wuinfo = $m_wu->getInfo($where);
+        if (empty($wuinfo)) {
+            return false;
+        }
+        //校验组
+        $rid = $info['rid'];
+        $where = [
+            'id' => $rid,
+            'is_active' => 1,
+        ];
+        $m_r = new rolesmodel();
+        $rinfo = $m_r->getInfo($where);
+        if (empty($rinfo)) {
+            return false;
+        }
+        //获取关系数据
+        $where = [
+            'uid' => $wuinfo['id'],
+            'rid' => $rinfo['id'],
+        ];
+        $m_ru = new roleusermodel();
+        $ruinfo = $m_ru->getInfo($where);
+        return [
+            'wuinfo' => $wuinfo,
+            'rinfo' => $rinfo,
+            'ruinfo' => $ruinfo,
+        ];
+    }
+    /**
+     * 获取顶层组
+     */
+    public function getlistgroupname($arr)
+    {
+        $where = [
+            'pre_id' => 0,
+            'is_active' => 1,
+        ];
+        $m_r = new rolesmodel();
+        $list = $m_r->getList($where, '*', 1, 0);
+        if (empty($list)) {
+            return backarr(0, "无数据");
+        }
+        return backarr(1, "查询成功", $list);
+    }
+    /**
+     * 获取组结构
+     * 仅两层
+     * 20211109
+     * wj
+     */
+    public function getlisttree($arr)
+    {
+        $order = "id asc";
+        $preid = !isset($arr['pre_id']) || empty($arr['pre_id']) ? 0 : $arr['pre_id'];
+        $where = ['pre_id' => $preid];
+        if (isset($arr['is_active'])) {
+            if (empty($arr['is_active'])) {
+                $where['is_active'] = 0;
+            } else {
+                $where['is_active'] = 1;
+            }
+        }
+        $m_r = new rolesmodel();
+        $datalist = $m_r->getList($where, '*', 1, 0, $order);
+        if (empty($datalist)) {
+            return backarr(0, "无数据");
+        }
+        $list = [];
+        $datalist = $datalist->toArray();
+        foreach ($datalist as $key => $value) {
+            $list[$key] = $value;
+            $where2 = ['pre_id' => $value['id']];
+            if (isset($where['is_active'])) {
+                $where2['is_active'] = $where['is_active'];
+            }
+            $datalist2 = $m_r->getList($where2, '*', 1, 0, $order);
+            $datalist2 = $datalist2->toArray();
+            if ($datalist2) {
+                foreach ($datalist2 as $key2 => $value2) {
+                    $list[$key]['children'][] = $value2;
+                }
+            }
+        }
+        return backarr(1, "查询成功", $list);
+    }
+}

+ 164 - 0
application/index/logic/safenotelogic.php

@@ -0,0 +1,164 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:16:29
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-09 16:21:40
+ */
+namespace app\index\logic;
+
+use app\index\model\safenotemodel;
+use think\Log;
+
+class safenotelogic
+{
+    /**
+     * 新增信息
+     * 20211127
+     * wj
+     */
+    public function newinfo($info)
+    {
+        log::info($info);
+        $fillField = ['Label', 'Suggestion', 'type', 'DataId'];
+        $fillFieldNum = ['Score'];
+        foreach ($fillField as $key => $value) {
+            if (!isset($info[$value]) || empty($info[$value])) {
+                return backarr(0, "请求错误");
+            }
+        }
+        foreach ($fillFieldNum as $key => $value) {
+            if (!isset($info[$value]) || !is_numeric($info[$value])) {
+                return backarr(0, "请求错误");
+            }
+        }
+        $label = $info['Label'];
+        $suggestion = $info['Suggestion'];
+        $score = $info['Score'];
+        $type = $info['type'];
+        $contentid = $info['DataId'];
+        $insertData = [
+            'label' => $info['Label'],
+            'suggestion' => $info['Suggestion'],
+            'score' => $info['Score'],
+            'contentid' => $contentid,
+            'createtime' => date("Y-m-d H:i:s"),
+        ];
+        //招工,找活
+        $tablensme = '';
+        switch ($type) {
+            case '1':
+                $tablensme = "invent";
+                break;
+            case '2':
+                $tablensme = "jobhunting";
+                break;
+        }
+        $insertData['tablename'] = $tablensme;
+        log::info($insertData);
+        $m_s = new safenotemodel();
+        $id = $m_s->insertData($insertData);
+        if (!$id) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    public function getresult($content, $dataid = null, $userid = null)
+    {
+        $type = 'wc';
+        $data = [
+            'content' => $content,
+            'type' => $type,
+        ];
+        if ($dataid) {
+            $data['dataid'] = $dataid;
+        }
+        if ($userid) {
+            $data['userid'] = $userid;
+        }
+        log::info($data);
+        $url = 'https://app.tjzhxx.cn:5443/api/tencent_cloud/safenote';
+        $header = ['Content-Type:application/x-www-form-urlencoded'];
+        $result = requestCurl($url, 'post', $data, $header);
+        log::info($result);
+        $result = json_decode($result, true);
+        log::info($result);
+        if (empty($result)) {
+            return backarr(0, "无文本校验结果");
+        }
+        return $result;
+    }
+    //根据接口返回数据 自动审核
+    //
+    public function automaticcheck($data, $type = 1, $strict = true)
+    {
+        if ($strict) {
+            //相应时间段 不严格校验
+            //招工高峰时间段 13:00 - 17:00
+            //找活高峰时间段 5:00 - 10:00
+            $inventTime = ['0500', '1000'];
+            $jobhuntingTime = ['1300', '1700'];
+            $time = date('Hi');
+            switch ($type) {
+                case 1:
+                    if ($time >= $inventTime[0] && $time <= $inventTime[1]) {
+                        $strict = false;
+                    }
+                    break;
+                case 2:
+                    if ($time >= $jobhuntingTime[0] && $time <= $jobhuntingTime[1]) {
+                        $strict = false;
+                    }
+                    break;
+            }
+        }
+        //总是模糊校验的label
+        $noStrictLabel = ['Ad', 'Normal'];
+        $label = $data['Label'];
+        $isNoStrictLabel = false;
+        if (in_array($label, $noStrictLabel)) {
+            $strict = false;
+            $isNoStrictLabel = true;
+        }
+        //$suggestion = $data['Suggestion'];
+        $suggestion = 'Block';
+        if ($strict) {
+            //Pass 审核通过
+            $allowSuggestion = ['Pass'];
+            if (in_array($suggestion, $allowSuggestion)) {
+                return true;
+            }
+        } else {
+            //Review Pass 审核通过
+            $allowSuggestion = ['Review', 'Pass'];
+            if ($isNoStrictLabel) {
+                array_push($allowSuggestion, 'Block');
+            }
+            if (in_array($suggestion, $allowSuggestion)) {
+                return true;
+            }
+        }
+        return false;
+    }
+    public function replaceTel($str)
+    {
+        if (!is_string($str)) {
+            return false;
+        }
+        preg_match_all("(1[3-9]{1}\d{9})", $str, $matches);
+        $matches = $matches[0];
+        if (is_array($matches)) {
+            foreach ($matches as $key => $value) {
+                $telno = $value;
+                $endNum = substr($telno, -4, 4);
+                $str = str_replace($endNum, "****", $str);
+            }
+        } elseif (is_string($matches)) {
+            $telno = $matches;
+            $endNum = substr($telno, -4, 4);
+            $telstr = str_replace($endNum, "****", $str);
+            $str = str_replace($telno, $telstr, $str);
+        }
+        return $str;
+    }
+}

+ 129 - 0
application/index/logic/scorelogic.php

@@ -0,0 +1,129 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:16:29
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-15 11:10:20
+ */
+namespace app\index\logic;
+
+use app\index\model\buyscorekindmodel;
+
+class scorelogic
+{
+    /**
+     * 新建类型
+     * 20211113
+     * wj
+     */
+    public function newinfo($info)
+    {
+        $m_bsk = new buyscorekindmodel();
+        $id = $m_bsk->insertData($info);
+        return $id;
+    }
+
+    /**
+     * 修改信息
+     * 20211113
+     * wj
+     */
+    public function updateinfobyid($arr)
+    {
+        if (!isset($arr['id']) || empty($arr['id'])) {
+            return backarr(0, '请求错误');
+        }
+        $m_bsk = new buyscorekindmodel();
+        $id = $arr['id'];
+        $where = ['id' => $id];
+        $updateData = [];
+        if (isset($arr['total_fee']) && !empty($arr['total_fee'])) {
+            $updateData['total_fee'] = $arr['total_fee'];
+        }
+        if (isset($arr['score']) && !empty($arr['score'])) {
+            $updateData['score'] = $arr['score'];
+        }
+        if (isset($arr['siliverscore']) && !empty($arr['siliverscore'])) {
+            $updateData['siliverscore'] = $arr['siliverscore'];
+        }
+        if (empty($updateData)) {
+            return backarr(0, '无修改内容');
+        }
+        $row = $m_bsk->updateinfo($where, $updateData);
+        if (empty($row)) {
+            return backarr(0, '无数据');
+        }
+        return backarr(1, '操作成功', ['id' => $id]);
+    }
+
+    /**
+     * 修改状态
+     * 20211113
+     * wj
+     */
+    public function updateisactivebyid($arr)
+    {
+        if (!isset($arr['id']) || empty($arr['id'])) {
+            return backarr(0, '请求错误');
+        }
+        $m_bsk = new buyscorekindmodel();
+        $id = $arr['id'];
+        $where = ['id' => $id];
+        if ($arr['isactive']) {
+            $arr['isactive'] = 1;
+        } else {
+            $arr['isactive'] = 0;
+        }
+        $updateData = [
+            'isactive' => $arr['isactive'],
+        ];
+        $row = $m_bsk->updateinfo($where, $updateData);
+        if (empty($row)) {
+            return backarr(0, '无数据');
+        }
+        return backarr(1, '操作成功', ['id' => $id]);
+    }
+
+    /**
+     * 获取列表
+     * 20211113
+     * wj
+     */
+    public function getlist($arr)
+    {
+        $where = [
+            'isactive' => 1,
+        ];
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $m_bsk = new buyscorekindmodel();
+        $count = $m_bsk->getList($where, 'count', $page, $size);
+        if ($count <= 0) {
+            return backarr(0, '无数据');
+        }
+        $list = $m_bsk->getList($where, '*', $page, $size, 'id asc');
+        return backarr(1, '查询成功', $list->toArray());
+    }
+
+    /**
+     * 获取信息
+     * 20211113
+     * wj
+     */
+    public function getinfobyid($arr)
+    {
+        if (!isset($arr['id']) || empty($arr['id'])) {
+            return backarr(0, '请求错误');
+        }
+        $where = [
+            'id' => $arr['id'],
+        ];
+        $m_bsk = new buyscorekindmodel();
+        $info = $m_bsk->getInfo($where);
+        if (empty($info)) {
+            return backarr(0, '无数据');
+        }
+        return backarr(1, '查询成功', $info);
+    }
+
+}

+ 115 - 0
application/index/logic/signinlogic.php

@@ -0,0 +1,115 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:16:29
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-09 16:21:40
+ */
+namespace app\index\logic;
+
+use app\index\logic\businesslogic;
+use app\index\model\signinmodel;
+use app\index\model\userinfomodel;
+use think\Log;
+
+class signinlogic
+{
+    /**
+     * 用户签到
+     * 20220105
+     * wj
+     */
+    public function usersignin($info)
+    {
+        if (!isset($info['userid']) && !isset($info['openid'])) {
+            return backarr(0, "请求数据错误");
+        }
+        if (isset($info['userid'])) {
+            if (!is_numeric($info['userid']) || empty($info['userid'])) {
+                return backarr(0, "用户id错误");
+            }
+        }
+        if (isset($info['openid'])) {
+            if (!is_string($info['openid']) || empty($info['openid'])) {
+                return backarr(0, "openid错误");
+            }
+        }
+        $uinfo = $this->getuserinfo($info);
+        $userid = $uinfo['id'];
+        $issign = $this->issign($info);
+        if ($issign) {
+            return backarr(0, "已签到");
+        }
+        $signid = $this->newsignin($info);
+        if (!$signid) {
+            return backarr(0, "签到失败");
+        }
+        //积分处理
+        $data = [
+            'userid' => $uinfo['id'],
+            'type' => 'signin',
+            'typeid' => 1,
+            'checkuserinfo' => false,
+        ];
+        $l_bl = new businesslogic();
+        $result = $l_bl->handlescorebusinessforuserid($data);
+        log::info($result);
+        if (1 != $result['status']) {
+            return backarr(0, $result['msg']);
+        }
+        return backarr(1, "签到成功", ['id' => $signid]);
+    }
+    /**
+     * 是否签到
+     * 20220105
+     * wj
+     */
+    private function issign($param)
+    {
+        $m_s = new signinmodel();
+        $where = [
+            'userid' => $param['userid'],
+            'signdate' => date('Y-m-d'),
+        ];
+        $info = $m_s->getinfo($where, 'id');
+        return empty($info) ? false : true;
+    }
+    /**
+     * 签到数据入库
+     * 20220105
+     * wj
+     */
+    private function newsignin($param)
+    {
+        $m_s = new signinmodel();
+        $signdata = [
+            'signdate' => date("Y-m-d"),
+            'signtime' => date("Y-m-d H:i:s"),
+        ];
+        $signdata = array_merge($signdata, $param);
+        $id = $m_s->insertData($signdata);
+        return empty($id) ? false : $id;
+    }
+    /**
+     * 获取分享详情
+     * 20220104
+     * wj
+     */
+    private function getuserinfo($param)
+    {
+        $m_u = new userinfomodel();
+        $where = [];
+        if (isset($param['userid'])) {
+            $where['id'] = $param['userid'];
+        }
+        if (isset($param['openid'])) {
+            $where['openid'] = $param['openid'];
+        }
+        $info = $m_u->getInfo($where);
+        if (empty($info)) {
+            throw new Exception("无用户信息");
+        }
+        return $info;
+    }
+
+}

+ 79 - 0
application/index/logic/smslogic.php

@@ -0,0 +1,79 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-03 16:33:07
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-09-03 17:58:59
+ */
+namespace app\index\logic;
+
+use app\index\model\smscoderecordmodel;
+use app\index\model\userinfomodel;
+
+class smslogic
+{
+    /***
+     * 20210903
+     * wj
+     * 创建验证码
+     */
+    public function createCode($arr)
+    {
+        $m_scr = new smscoderecordmodel();
+        $m_u = new userinfomodel();
+        if (!isset($arr['smscode']) || !empty($arr['smscode']) || !is_numeric($arr['smscode'])) {
+            return false;
+        }
+        $tel = $arr['tel'];
+        $wuInfo = $m_u->getInfo(['telno' => $tel]);
+        $wid = empty($wuInfo) ? 0 : $wuInfo['id'];
+        $insertData = [
+            'tel' => $tel,
+            'wid' => $wid,
+            'smscode' => $arr['smscode'],
+            'createtime' => time(),
+        ];
+        $id = $m_scr->insinfo($insertData);
+        return $id;
+    }
+    /***
+     * 20210903
+     * wj
+     * 根据id删除验证码
+     */
+    public function deleteCoeById($id)
+    {
+        $m_scr = new smscoderecordmodel();
+        $result = $m_scr->delbyid($id);
+        return $result;
+    }
+    public function getinfobyid($id)
+    {
+        $m_scr = new smscoderecordmodel();
+        $sccInfo = $m_scr->getinfobyid($id);
+        return $sccInfo;
+    }
+    public function getlastinfobytel($tel)
+    {
+        $m_scr = new smscoderecordmodel();
+        $sccInfo = $m_scr->getlastinfobytel($tel);
+        return $sccInfo;
+    }
+    public function deletebytime($tel)
+    {
+        $m_scr = new smscoderecordmodel();
+        //间隔时间大于2分钟删除
+        //$maxtime = 120;
+        $maxtime = 120;
+        $time = time();
+        $where['tel'] = $tel;
+        $sccInfo = $m_scr->getinfo($where, false);
+        foreach ($sccInfo as $value) {
+            $createTime = $value['createtime'];
+            if ($time > $createTime && $time - $createTime >= $maxtime) {
+                $result = $m_scr->deletebyid($value['id']);
+            }
+        }
+    }
+
+}

+ 168 - 0
application/index/logic/trainlogic.php

@@ -0,0 +1,168 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:16:29
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-24 15:11:29
+ */
+namespace app\index\logic;
+
+use app\index\model\trainmodel;
+use app\index\model\trainsignusermodel;
+
+class trainlogic
+{
+    /**
+     * 新增培训
+     * 20211224
+     * wj
+     */
+    public function newinfo($info)
+    {
+        $fillField = ['name', 'maxpersion'];
+        foreach ($fillField as $key => $value) {
+            if (!isset($info[$value]) || empty($info[$value])) {
+                return backarr(0, "请求失败");
+            }
+        }
+        $m_t = new trainmodel();
+        if (!isset($info['createtime']) || empty($info['createtime'])) {
+            $info['createtime'] = date('Y-m-d H:i:s', time());
+        }
+        $id = $m_t->insertData($info);
+        if (!$id) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    /**
+     * 改详细信息
+     * 20211224
+     * wj
+     */
+    public function updateinfo($arr)
+    {
+        if (!isset($arr['id']) || empty($arr['id'])) {
+            return backarr(0, "请求失败");
+        }
+        $m_t = new trainmodel();
+        $id = $arr['id'];
+        $where = ['id' => $id];
+        $tinfo = $m_t->getInfo($where);
+        if (empty($tinfo)) {
+            return backarr(0, "无数据");
+        }
+        $updateField = ['name', 'disstr', 'starttime', 'endtime', 'maxpersion'];
+        $updateData = [];
+        foreach ($updateField as $key => $value) {
+            if (isset($arr[$value]) && !empty($arr[$value]) && $tinfo[$value] != $arr[$value]) {
+                $updateData[$value] = $arr[$value];
+            }
+        }
+        if (isset($updateField['starttime']) && isset($updateField['endtime'])) {
+            if (strtotime($updateField['starttime']) > strtotime($updateField['endtime'])) {
+                return backarr(0, "时间段错误");
+            }
+        }
+        if (empty($updateData)) {
+            return backarr(0, "无修改数据");
+        }
+        $row = $m_t->updateinfo($where, $updateData);
+        if (!$row) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    /**
+     * 获取信息根据id
+     * 20211224
+     * wj
+     */
+    public function getinfobyid($arr)
+    {
+        if (!isset($arr['id']) || empty($arr['id'])) {
+            return backarr(0, "请求失败");
+        }
+        $id = $arr['id'];
+        $m_t = new trainmodel();
+        $where = ['id' => $id];
+        $cinfo = $m_t->getInfo($where);
+        if (empty($cinfo)) {
+            return backarr(0, "无数据");
+        }
+        return backarr(1, "操作成功", $cinfo);
+    }
+    /**
+     * 修改isactive根据id
+     * 20211224
+     * wj
+     */
+    public function updateisactivebyid($arr)
+    {
+        if (!isset($arr['id']) || empty($arr['id']) || !isset($arr['isactive']) || !in_array($arr['isactive'], [0, 1])) {
+            return backarr(0, "请求失败");
+        }
+        $id = $arr['id'];
+        $isactive = $arr['isactive'];
+        $m_t = new trainmodel();
+        $where = ['id' => $id];
+        $cinfo = $m_t->getInfo($where);
+        if (empty($cinfo)) {
+            return backarr(0, "无数据");
+        }
+        $updateData = [];
+        if ($isactive != $cinfo['isactive']) {
+            $updateData['isactive'] = $isactive;
+        }
+        if (empty($updateData)) {
+            return backarr(0, "无修改数据", ['id' => $id]);
+        }
+        $row = $m_t->updateinfo($where, $updateData);
+        if (!$row) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id, 'isactive' => $isactive]);
+    }
+
+    /***
+     * 获取列表 按时间倒序
+     * 20211224
+     * wj
+     */
+    public function getlistbywhere($arr)
+    {
+        $m_t = new trainmodel();
+        $where = [];
+        if (isset($arr['name']) && !empty($arr['name'])) {
+            $where['name'] = ['like', '%' . $arr['name'] . '%'];
+        }
+        if (isset($arr['isactive']) && is_numeric($arr['isactive']) && in_array($arr['isactive'], [0, 1])) {
+            $where['isactive'] = $arr['isactive'];
+        }
+        if (isset($arr['worktype']) && !empty($arr['worktype'])) {
+            $where['worktype'] = ['like', '%' . $arr['worktype'] . '%'];
+        }
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $count = $m_t->getList($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_t->getList($where, '*', $page, $size);
+        if (isset($arr['userid']) && !empty($arr['userid'])) {
+            $userid = $arr['userid'];
+            $m_tu = new trainsignusermodel();
+            foreach ($list as $key => $value) {
+                $list[$key]['userid'] = $userid;
+                $where = ['tid' => $value['id'], 'userid' => $userid, 'status' => 1];
+                $tuinfo = $m_tu->getInfo($where);
+                if (empty($tuinfo)) {
+                    $list[$key]['status'] = 0;
+                } else {
+                    $list[$key]['status'] = 1;
+                }
+            }
+        }
+        return backarr(1, "查询成功", $list);
+    }
+}

+ 168 - 0
application/index/logic/trainsignuserlogic.php

@@ -0,0 +1,168 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:16:29
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-30 10:20:43
+ */
+namespace app\index\logic;
+
+use app\index\model\trainmodel;
+use app\index\model\trainsignusermodel;
+use app\index\model\userinfomodel;
+
+class trainsignuserlogic
+{
+    /**
+     * 新增培训
+     * 20211224
+     * wj
+     */
+    public function newinfo($info)
+    {
+        $fillField = ['userid', 'tid'];
+        foreach ($fillField as $key => $value) {
+            if (!isset($info[$value]) || empty($info[$value]) || !is_numeric($info[$value])) {
+                return backarr(0, "请求失败");
+            }
+        }
+        $userid = $info['userid'];
+        $tid = $info['tid'];
+        $m_t = new trainmodel();
+        $m_tu = new trainsignusermodel();
+        $m_u = new userinfomodel();
+        $tuwhere = [
+            'userid' => $userid,
+            'tid' => $tid,
+            'status' => 1,
+        ];
+        $tuinfo = $m_tu->getInfo($tuwhere, 'id');
+        if (!empty($tuinfo)) {
+            return backarr(0, "已报名");
+        }
+        $uwhere = [
+            'id' => $userid,
+        ];
+        $uinfo = $m_u->getInfo($uwhere);
+        if (empty($uinfo)) {
+            return backarr(0, "无用户");
+        }
+        $twhere = [
+            'id' => $tid,
+        ];
+        $tinfo = $m_t->getInfo($twhere);
+        if (empty($tinfo)) {
+            return backarr(0, "无培训信息");
+        }
+        if (!empty($tinfo['starttime']) || !empty($tinfo['endtime'])) {
+            if ($tinfo['starttime']) {
+                if (time() < strtotime($tinfo['starttime'])) {
+                    return backarr(0, "非可报名时间段");
+                }
+            }
+            if ($tinfo['endtime']) {
+                if (time() > strtotime($tinfo['endtime'])) {
+                    return backarr(0, "非可报名时间段");
+                }
+            }
+        }
+        $count = $m_tu->getList($tuwhere, 'count');
+        if ($count >= $tinfo['maxpersion']) {
+            return backarr(0, "已招满");
+        }
+        if (!isset($info['createtime']) || empty($info['createtime'])) {
+            $info['createtime'] = date('Y-m-d H:i:s', time());
+        }
+        $id = $m_tu->insertData($info);
+        if (!$id) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+
+    /**
+     * 获取信息根据userid
+     * 20211224
+     * wj
+     */
+    public function getinfobyuserid($arr)
+    {
+        if (!isset($arr['userid']) || empty($arr['userid'])) {
+            return backarr(0, "请求失败");
+        }
+        $userid = $arr['userid'];
+        $m_tu = new trainsignusermodel();
+        $where = ['userid' => $userid, 'status' => 1];
+        $cinfo = $m_tu->getInfo($where);
+        if (empty($cinfo)) {
+            return backarr(0, "无数据");
+        }
+        return backarr(1, "操作成功", $cinfo);
+    }
+
+    /***
+     * 获取列表 按userid查询 按id倒序
+     * 20211224
+     * wj
+     */
+    public function getlistbyuserid($arr)
+    {
+        if (!isset($arr['userid']) || empty($arr['userid']) && !is_numeric($arr['userid'])) {
+            return backarr(0, "请求失败");
+        }
+        $userid = $arr['userid'];
+        $m_tu = new trainsignusermodel();
+        $m_t = new trainmodel();
+        $where = ['userid' => $userid];
+        if (isset($arr['status']) && is_numeric($arr['status']) && in_array($arr['status'], [0, 1])) {
+            $where['status'] = $arr['status'];
+        }
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $count = $m_tu->getList($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_tu->getList($where, '*', $page, $size);
+        foreach ($list as $key => &$value) {
+            $tinfo = $m_t->getInfo(['id' => $value['tid']], 'name');
+            if (empty($tinfo)) {
+                $list[$key]['name'] = '';
+            } else {
+                $list[$key]['name'] = $tinfo['name'];
+            }
+        }
+        return backarr(1, "查询成功", $list);
+    }
+    /**
+     * 修改status根据id 1报名 0取消报名
+     * 20211224
+     * wj
+     */
+    public function updatestatusbyid($arr)
+    {
+        if (!isset($arr['id']) || empty($arr['id']) || !isset($arr['status']) || !in_array($arr['status'], [0, 1])) {
+            return backarr(0, "请求失败");
+        }
+        $id = $arr['id'];
+        $status = $arr['status'];
+        $m_tu = new trainsignusermodel();
+        $where = ['id' => $id];
+        $tuinfo = $m_tu->getInfo($where);
+        if (empty($tuinfo)) {
+            return backarr(0, "无数据");
+        }
+        $updateData = [];
+        if ($status != $tuinfo['status']) {
+            $updateData['status'] = $status;
+        }
+        if (empty($updateData)) {
+            return backarr(0, "无修改数据");
+        }
+        $row = $m_tu->updateinfo($where, $updateData);
+        if (!$row) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+}

+ 547 - 0
application/index/logic/useraccountlogic.php

@@ -0,0 +1,547 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-11-05 09:07:47
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-29 16:50:10
+ */
+namespace app\index\logic;
+
+use app\index\model\useraccountaddrecordmodel;
+use app\index\model\useraccountmodel;
+//use app\index\model\useraccountuserrecordbydaymodel;
+use app\index\model\useraccountuserrecordmodel;
+use app\index\model\userinfomodel;
+use think\Db;
+
+class useraccountlogic
+{
+    /***
+     * 查询用户积分
+     * 20211105
+     * wj
+     */
+    public function getinfobyuid($arr)
+    {
+        if (!isset($arr['userid']) || empty($arr['userid'])) {
+            return backarr(0, "请求错误");
+        }
+        $uid = $arr['userid'];
+        $m_u = new userinfomodel();
+        $m_ua = new useraccountmodel();
+        $userwhere = ['id' => $uid];
+        $userinfo = $m_u->getInfo($userwhere);
+        if (empty($userinfo)) {
+            return backarr(0, "无用户信息");
+        }
+        $where = ['userid' => $uid];
+        $info = $m_ua->getInfo($where);
+        if (empty($info)) {
+            $defaultData = [
+                'userid' => $uid,
+                'goldscore' => 0,
+                'siliverscore' => 0,
+            ];
+            $id = $m_ua->insertData($defaultData);
+            $info = $defaultData;
+            $info['id'] = $id;
+        }
+        return backarr(1, "查询成功", $info);
+    }
+
+    /***
+     * 扣除用户积分
+     * type 0 先扣银币再扣 1金分 2银分
+     * 20211105
+     * wj
+     */
+    public function reduceuserscore($arr, $type = 0)
+    {
+        $fillFields = ['userid', 'usescore', 'usetype'];
+        foreach ($fillFields as $key => $value) {
+            if (!isset($arr[$value]) || empty($arr[$value])) {
+                return backarr(0, "请求错误");
+            }
+        }
+        $m_u = new userinfomodel();
+        $userid = $arr['userid'];
+        $usescore = $arr['usescore'];
+        $usetype = $arr['usetype'];
+        $userwhere = ['id' => $userid];
+        $userinfo = $m_u->getInfo($userwhere);
+        if (empty($userinfo)) {
+            return backarr(0, "无用户信息");
+        }
+        Db::startTrans();
+        try {
+            //操作总表
+            $result = $this->reduceuseraccount($userid, $usescore, $type);
+            if (1 != $result['status']) {
+                throw new \Exception($result['msg']);
+            }
+            $m_uaur = new useraccountuserrecordmodel();
+            $m_uaar = new useraccountaddrecordmodel();
+            //$m_uaurd = new useraccountuserrecordbydaymodel();
+            $list = $this->getaddrecordlistforreduce($userid);
+            if (!$list) {
+                if (empty($userinfo)) {
+                    return backarr(0, "无可扣除积分");
+                }
+            }
+            /*$uaurdDay = date("Y-m-d");
+            $uaurdInfo = $m_uaurd->getInfoByKey($userid, $uaurdDay);
+            if (empty($uaurdInfo)) {
+                $insertUaurdInfo = [
+                    'userid' => $userid,
+                    'usetime' => $uaurdDay,
+                    'usescore' => $usescore,
+                ];
+                $uaurdid = $m_uaurd->insertGetId($insertUaurdInfo);
+                if (empty($uaurdid)) {
+                    throw new \Exception("积分统计表创建失败");
+                }
+            } else {
+                $uaurdUsescore = bcadd($usescore, $uaurdInfo['usescore']);
+                $row = $m_uaurd->updateinfo(['id' => $uaurdInfo['id'], ['usescore' => $uaurdUsescore]]);
+                if (empty($row)) {
+                    throw new \Exception("积分统计表修改失败");
+                }
+            }*/
+            $residueScore = $usescore; //剩余抵扣积分
+            foreach ($list as $key => $value) {
+                if ($residueScore <= 0) {
+                    break;
+                }
+                $diffScore = $value['activescore'] - $residueScore;
+                if ($diffScore > 0) {
+                    $recordScore = $residueScore;
+                    $activescore = $diffScore;
+                    $residueScore = 0;
+                } else {
+                    $recordScore = $value['activescore'];
+                    $activescore = 0;
+                    $residueScore = abs($diffScore);
+                }
+                $uaurinsertdata = [
+                    'sourcerecordid' => $value['id'],
+                    'userid' => $userid,
+                    'usescore' => $recordScore,
+                    'usetype' => $usetype,
+                    'usetime' => date("Y-m-d H:i:s"),
+                ];
+                if (isset($arr['usedemo']) && !empty($arr['usedemo'])) {
+                    $uaurinsertdata['usedemo'] = $arr['usedemo'];
+                }
+                $uaurid = $m_uaur->insertData($uaurinsertdata);
+                if (empty($uaurid)) {
+                    throw new \Exception("用户积分记录添加失败");
+                }
+                $uaarwhere = ['id' => $value['id']];
+                $uaarupdatedata = [
+                    'activescore' => $activescore,
+                ];
+                $row = $m_uaar->updateinfo($uaarwhere, $uaarupdatedata);
+                if (empty($row)) {
+                    throw new \Exception("用户积分增加记录修改失败");
+                }
+            }
+            Db::commit();
+            return backarr(1, '操作成功');
+        } catch (\Exception $e) {
+            Db::rollback();
+            return backarr(0, $e->getMessage());
+        }
+    }
+    /***
+     * 验证用户积分
+     * 积分不够返回错误
+     * type 0 总积分 1金分 2银分
+     * 20211105
+     * wj
+     */
+    private function checkreducedata($uid, $userscore, $type = 0)
+    {
+        $result = $this->getinfobyuid(['userid' => $uid]);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $info = $result['data'];
+        switch ($type) {
+            case 0:
+                $count = bcadd($info['goldscore'], $info['siliverscore']);
+                break;
+            case 2:
+                $count = $info['siliverscore'];
+                break;
+            case 1:
+                $count = $info['goldscore'];
+                break;
+        }
+        if ($count < $userscore) {
+            return backarr(0, "用户积分不足");
+        }
+        return backarr(1, '', $info);
+    }
+    /**
+     * 扣除用户积分 总表修改
+     * type 0 先扣银币再扣 1金分 2银分
+     * 20211105
+     * wj
+     */
+    private function reduceuseraccount($uid, $userscore, $type = 0)
+    {
+        $result = $this->checkreducedata($uid, $userscore, $type);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $info = $result['data'];
+        $updateData = [];
+        switch ($type) {
+            case 0:
+                $subsiliverscore = $info['siliverscore'] - $userscore;
+                if ($subsiliverscore >= 0) {
+                    $updateData['siliverscore'] = $subsiliverscore;
+                } else {
+                    $updateData['siliverscore'] = 0;
+                    $updateData['goldscore'] = bcsub($info['goldscore'], abs($subsiliverscore));
+                }
+                break;
+            case 2:
+                $updateData['siliverscore'] = $info['siliverscore'] - $userscore;
+                break;
+            case 1:
+                $updateData['goldscore'] = $info['goldscore'] - $userscore;
+                break;
+        }
+        $m_ua = new useraccountmodel();
+        $where = ['id' => $info['id']];
+        $row = $m_ua->updateinfo($where, $updateData);
+        if (empty($row)) {
+            return backarr(0, "用户积分修改失败");
+        }
+        return backarr(1, "用户积分修改成功", ['id' => $info['id']]);
+    }
+    /***
+     * 加用户积分
+     * $scoretype 1金,2银
+     * 20211105
+     * wj
+     */
+    public function adduserscore($arr)
+    {
+        $fillFields = ['userid', 'scoretype', 'addscore', 'sourcetype'];
+        foreach ($fillFields as $key => $value) {
+            if (!isset($arr[$value]) || empty($arr[$value])) {
+                return backarr(0, "请求错误");
+            }
+        }
+        $m_u = new userinfomodel();
+        $userid = $arr['userid'];
+        $scoretype = $arr['scoretype'];
+        $addscore = $arr['addscore'];
+        $sourcetype = $arr['sourcetype'];
+
+        $userwhere = ['id' => $userid];
+        $userinfo = $m_u->getInfo($userwhere);
+        if (empty($userinfo)) {
+            return backarr(0, "无用户信息");
+        }
+        Db::startTrans();
+        try {
+            $result = $this->adduseraccount($userid, $addscore, $scoretype);
+            if (1 != $result['status']) {
+                throw new \Exception($result['msg']);
+            }
+            $insertData = [
+                'activescore' => $addscore,
+                'createdate' => date('Y-m-d H:i:s'),
+            ];
+            $insertData = array_merge($insertData, $arr);
+            $m_uaar = new useraccountaddrecordmodel();
+            $uaarid = $m_uaar->insertData($insertData);
+            if (empty($uaarid)) {
+                throw new \Exception("积分记录添加失败");
+            }
+            Db::commit();
+            return backarr(1, "积分增加成功", ['uaarid' => $uaarid, 'uid' => $userid, 'addscore' => $addscore]);
+        } catch (\Exception $e) {
+            Db::rollback();
+            return backarr(0, $e->getMessage());
+        }
+    }
+    /***
+     * 加用户积分 总表修改
+     * $scoretype 1金,2银
+     * 20211105
+     * wj
+     */
+    private function adduseraccount($uid, $addscore, $scoretype)
+    {
+        $result = $this->getinfobyuid(['userid' => $uid]);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $info = $result['data'];
+        $updateData = [];
+        switch ($scoretype) {
+            case 1:
+                $updateData['goldscore'] = bcadd($info['goldscore'], $addscore);
+                break;
+            case 2:
+                $updateData['siliverscore'] = bcadd($info['siliverscore'], $addscore);
+                break;
+        }
+        $m_ua = new useraccountmodel();
+        $where = ['id' => $info['id']];
+        $row = $m_ua->updateinfo($where, $updateData);
+        if (empty($row)) {
+            return backarr(0, "用户积分修改失败");
+        }
+        return backarr(1, "用户积分修改成功", ['id' => $info['id']]);
+    }
+
+    /**
+     * 获取用户可扣除积分
+     * type 0 先银再扣金 1金分 2银分
+     * 20211105
+     * wj
+     */
+    public function getaddrecordlistforreduce($userid, $scoretype = 0)
+    {
+        $m_u = new userinfomodel();
+        $m_uaar = new useraccountaddrecordmodel();
+        $userwhere = ['id' => $userid];
+        $userinfo = $m_u->getInfo($userwhere);
+        //$startDate = empty($userinfo['createtime']) ? '2021-10-01 00:00:00' : $userinfo['createtime'];
+        $endData = date('Y-m-d H:i:s');
+        $list = $m_uaar->getaddrecordlistforreduce($userid, $endData, $scoretype);
+        if (empty($list)) {
+            return false;
+        }
+        return $list;
+    }
+
+    /**
+     * 获取用户增加积分的记录
+     * 2021105
+     * wj
+     */
+    public function addregisterscore($arr)
+    {
+        $m_uaar = new useraccountaddrecordmodel();
+        $userid = $arr['userid'];
+        $sourcedemo = '注册-水猫';
+        if (isset($arr['platform']) && !empty($arr['platform'])) {
+            $sourcedemo = '注册-' . $arr['platform'];
+        }
+        $userid = $arr['userid'];
+        $where = [
+            'userid' => $userid,
+            'actiontype' => 1,
+        ];
+        $data = $m_uaar->getInfo($where);
+        if ($data) {
+            return backarr(0, "用户已有注册积分");
+        }
+        $insertData = [
+            'userid' => $userid,
+            'scoretype' => 2,
+            'addscore' => 5,
+            'sourcetype' => 2,
+            'sourcedemo' => $sourcedemo,
+            'actiontype' => 1,
+        ];
+        return $result = $this->adduserscore($insertData);
+    }
+
+    /**
+     * 获取积分增加列表
+     * 20211108
+     * wj
+     * */
+    public function getaddlist($arr)
+    {
+        if (!isset($arr['userid']) || empty($arr['userid'])) {
+            return backarr(0, "请求错误");
+        }
+        $m_uaar = new useraccountaddrecordmodel();
+        $page = !isset($arr['page']) || empty($arr['page']) ? 1 : $arr['page'];
+        $size = !isset($arr['size']) || empty($arr['size']) ? 10 : $arr['size'];
+        $userid = $arr['userid'];
+        $where = ['userid' => $userid];
+        $count = $m_uaar->getList($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_uaar->getList($where, '*', $page, $size);
+        return backarr(1, "查询成功", $list);
+    }
+    /**
+     * 获取积分使用列表
+     * 20211108
+     * wj
+     * */
+    public function getusedlist($arr)
+    {
+        if (!isset($arr['userid']) || empty($arr['userid'])) {
+            return backarr(0, "请求错误");
+        }
+        $m_uaur = new useraccountuserrecordmodel();
+        $page = !isset($arr['page']) || empty($arr['page']) ? 1 : $arr['page'];
+        $size = !isset($arr['size']) || empty($arr['size']) ? 10 : $arr['size'];
+        $userid = $arr['userid'];
+        $where = ['userid' => $userid];
+        $count = $m_uaur->getList($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_uaur->getList($where, '*', $page, $size);
+        return backarr(1, "查询成功", $list);
+    }
+    /**
+     * 根据时间和最少积分获取列表
+     * 20211130
+     * wj
+     */
+    public function getgivelistbytype($arr)
+    {
+        $fillFields = ['type', 'minsocre'];
+        foreach ($fillFields as $key => $value) {
+            if (!isset($arr[$value])) {
+                return backarr(0, "请求失败");
+            }
+        }
+        $type = $arr['type'];
+        $minsocre = $arr['minsocre'];
+        if (!is_numeric($type) || !in_array($type, [1, 2])) {
+            return backarr(0, "类型错误");
+        }
+        if (!is_numeric($minsocre)) {
+            return backarr(0, "最小值错误");
+        }
+        $page = !isset($arr['page']) || empty($arr['page']) ? 1 : $arr['page'];
+        $size = !isset($arr['size']) || empty($arr['size']) ? 10 : $arr['size'];
+
+        $m_uaur = new useraccountuserrecordmodel();
+        $count = $m_uaur->getsumscorebytype($type, $minsocre, true);
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_uaur->getsumscorebytype($type, $minsocre, false, $page, $size, "sum desc");
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        $data = [
+            'count' => $count,
+            'list' => $list,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+    /**
+     * 为用户加积分
+     * 20211130
+     * wj
+     */
+    public function givescorebyuid($arr)
+    {
+        $fillFields = ['uid', 'score'];
+        foreach ($fillFields as $key => $value) {
+            if (!isset($arr[$value])) {
+                return backarr(0, "请求失败");
+            }
+        }
+        $uid = $arr['uid'];
+        $socre = $arr['score'];
+        $sourcedemo = "后台管理根基积分消耗赠送";
+        if (isset($arr['sourcedemo']) && is_string($arr['sourcedemo']) && !empty($arr['sourcedemo'])) {
+            $sourcedemo = $arr['sourcedemo'];
+        }
+        $insertData = [
+            'userid' => $uid,
+            'scoretype' => 2,
+            'addscore' => $socre,
+            'sourcetype' => 2,
+            'sourcedemo' => $sourcedemo,
+            'actiontype' => 5,
+        ];
+        return $result = $this->adduserscore($insertData);
+    }
+    /**
+     * 根据查询条件和最少积分获取列表
+     * 20211208
+     * wj
+     */
+    public function getsumscorebywhere($arr)
+    {
+        $fillFields = ['minsocre'];
+        foreach ($fillFields as $key => $value) {
+            if (!isset($arr[$value])) {
+                return backarr(0, "请求失败");
+            }
+        }
+        $minsocre = $arr['minsocre'];
+        if (!is_numeric($minsocre)) {
+            return backarr(0, "最小值错误");
+        }
+        $page = !isset($arr['page']) || empty($arr['page']) ? 1 : $arr['page'];
+        $size = !isset($arr['size']) || empty($arr['size']) ? 10 : $arr['size'];
+        $where = [];
+        if (isset($arr['time']) && is_array($arr['time'])) {
+            if (2 == count(array_filter($arr['time']))) {
+                $where['time'] = $arr['time'];
+            }
+        }
+        if (isset($arr['wname']) && !empty($arr['wname']) && is_string($arr['wname'])) {
+            $where['wname'] = $arr['wname'];
+        }
+        if (isset($arr['telno']) && !empty($arr['telno']) && is_string($arr['telno'])) {
+            $where['telno'] = $arr['telno'];
+        }
+        $order = "sumscore asc,sum desc";
+        if (isset($arr['ordertype']) && is_numeric($arr['ordertype'])) {
+            switch ($arr['ordertype']) {
+                case 1:
+                    $order = "sum desc";
+                    break;
+                case 2:
+                    $order = "sumscore asc";
+                    break;
+            }
+        }
+        $m_uaur = new useraccountuserrecordmodel();
+        $count = $m_uaur->getsumscorebywhere($where, $minsocre, true);
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_uaur->getsumscorebywhere($where, $minsocre, false, $page, $size, $order);
+        if (count($list) <= 0) {
+            return backarr(0, "无数据");
+        }
+        $data = [
+            'count' => $count,
+            'list' => $list,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+
+    /*
+     * 20220103
+     * steelxu5
+     * 临时逻辑,2022年初开始弹窗展示送的积分,
+     * 暂时只考虑展示指定日期后送的积分,然后引导用户去我的页面中查看
+     * 这一逻辑会遗漏掉一些赠送积分的用户,优点是不用处理为这一展示单独建立数据表和展示逻辑,方便后期调整业务逻辑
+     *
+     */
+    public function getsendscorebyuiddate($arr){
+        $uid=$arr['userid'];
+        $date=$arr['date'];
+        $t_ua=new useraccountaddrecordmodel();
+        $tlist=$t_ua->seladdlistbyuid2date($uid,$date);
+        if(count($tlist)>0){
+            return backarr(1, "查询成功", $tlist);
+        }else{
+            return backarr(0, "无数据");
+        }
+
+    }
+}

+ 479 - 0
application/index/logic/useractionlogic.php

@@ -0,0 +1,479 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-28 11:21:10
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-15 13:51:21
+ */
+namespace app\index\logic;
+
+use app\index\model\evaluatemodel;
+use app\index\model\inventmodel;
+use app\index\model\jobhuntingmodel;
+use app\index\model\useractionrecordmodel;
+use app\index\model\userconnectrecorddaymodel;
+use app\index\model\userconnectrecordmodel;
+use app\index\model\userinfomodel;
+use app\index\model\usersearchrecordmodel;
+use think\Db;
+
+class useractionlogic
+{
+    private $m_ua;
+    private $m_uc;
+    public function __construct()
+    {
+        $this->m_ua = new useractionrecordmodel();
+        $this->m_uc = new userconnectrecordmodel();
+        $this->m_us = new usersearchrecordmodel();
+        $this->m_ucd = new userconnectrecorddaymodel();
+    }
+    /***
+     * 保存用户沟通行为
+     * useraction表不再记录用户沟通行为  20211215 wj
+     * 2021090927
+     * wj
+     */
+    public function saveuserconnect($arr)
+    {
+        $type = 2;
+        $arr['type'] = $type;
+        $result = $this->checkData($arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        //$refId = isset($arr['ref_id']) ? $arr['ref_id'] : 0;
+        $uidInfo = $this->checkUser($arr['uid']);
+        $reciveruserid = isset($arr['reciveruserid']) ? $arr['reciveruserid'] : 0;
+        $ruidInfo = $this->checkUser($reciveruserid);
+        if (empty($ruidInfo)) {
+            return backarr(0, "用户不存在");
+        }
+        $openid = empty($arr['openid']) ? $uidInfo['openid'] : $arr['openid'];
+        $sendusername = isset($arr['sendusername']) ? $arr['sendusername'] : $uidInfo['wname'];
+        $reciverusername = isset($arr['reciverusername']) ? $arr['reciverusername'] : $ruidInfo['wname'];
+        Db::startTrans();
+        try {
+            $detailData = [
+                'openid' => $openid,
+                'senduserid' => $arr['uid'],
+                'sendusername' => $sendusername,
+                'reciveruserid' => $reciveruserid,
+                'reciverusername' => $reciverusername,
+                'sourceid' => $arr['sourceid'],
+                'sourcetype' => $arr['source_type'],
+            ];
+            $resultCheck = $this->m_uc->checkDataForInsert($detailData);
+            if (1 == $resultCheck['status']) {
+                $usid = $this->m_uc->insinfo($detailData);
+                if (!$usid) {
+                    throw new \Exception("详细总表保存失败");
+                }
+            }
+            $usdid = $this->m_ucd->insinfo($detailData);
+            //$detailId = 'd' . $usdid;
+            if (!$usdid) {
+                throw new \Exception("详细保存失败");
+            }
+            /*
+            if (empty($refId)) {
+            $refId = $arr['sourceid'];
+            }
+            $sourcetype = $arr['source_type'];
+            if (in_array($sourcetype, [1, 2])) {
+            $sourcetype = 'invent';
+            } elseif (in_array($sourcetype, [3, 4])) {
+            $sourcetype = 'jobhunting';
+            }
+            $uaData = [
+            'uid' => $arr['uid'],
+            'ref_id' => $refId,
+            'type' => $arr['type'],
+            'source_type' => $arr['source_type'],
+            'detail_id' => $detailId,
+            ];
+            $usId = $this->m_ua->insinfo($uaData);
+            if (!$usId) {
+            throw new \Exception("保存失败", 1);
+            }*/
+            Db::commit();
+            return backarr(1, "保存成功");
+        } catch (\Exception $e) {
+            Db::rollback();
+            return backarr(0, $e->getMessage());
+        }
+    }
+    /***
+     * 保存用户点击行为
+     * 2021090927
+     * wj
+     */
+    public function saveuserclick($arr)
+    {
+        $type = 1;
+        $arr['type'] = $type;
+        $result = $this->checkData($arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $refId = isset($arr['ref_id']) ? $arr['ref_id'] : 0;
+        Db::startTrans();
+        try {
+            $uaData = [
+                'uid' => $arr['uid'],
+                'ref_id' => $refId,
+                'type' => $arr['type'],
+                'source_type' => $arr['source_type'],
+            ];
+            $usId = $this->m_ua->insinfo($uaData);
+            if (!$usId) {
+                throw new \Exception("保存失败", 1);
+            }
+            Db::commit();
+            return backarr(1, "保存成功");
+        } catch (\Exception $e) {
+            Db::rollback();
+            return backarr(0, $e->getMessage());
+        }
+    }
+    /***
+     * 保存用户搜索行为
+     * 2021090927
+     * wj
+     */
+    public function saveusersearch($arr)
+    {
+        $type = 3;
+        $arr['type'] = $type;
+        $result = $this->checkData($arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        if (!isset($arr['content']) || empty($arr['content'])) {
+            return backarr(0, "无查询内容");
+        }
+        $refId = isset($arr['ref_id']) ? $arr['ref_id'] : 0;
+        Db::startTrans();
+        try {
+            $detailData = [
+                'uid' => $arr['uid'],
+                'content' => $arr['content'],
+                'sourcetype' => $arr['source_type'],
+            ];
+            $detailId = $this->m_us->insinfo($detailData);
+            if (!$detailId) {
+                throw new \Exception("详细保存失败");
+            }
+            $uaData = [
+                'uid' => $arr['uid'],
+                'ref_id' => $refId,
+                'type' => $arr['type'],
+                'source_type' => $arr['source_type'],
+                'detail_id' => $detailId,
+            ];
+            $usId = $this->m_ua->insinfo($uaData);
+            if (!$usId) {
+                throw new \Exception("保存失败", 1);
+            }
+            Db::commit();
+            return backarr(1, "保存成功");
+        } catch (\Exception $e) {
+            Db::rollback();
+            return backarr(0, $e->getMessage());
+        }
+    }
+    private function checkData($arr)
+    {
+        $fillField = ['uid', 'source_type'];
+        foreach ($fillField as $key => $value) {
+            if (!isset($arr[$value]) || empty($arr[$value])) {
+                return backarr(0, "请求参数错误");
+            }
+        }
+        $info = $this->checkUser($arr['uid']);
+        if (empty($info)) {
+            return backarr(0, "用户不存在");
+        }
+        return backarr(1, "");
+    }
+    /***
+     * 判断用户是否存在
+     * 2021090927
+     * wj
+     */
+    private function checkUser($id)
+    {
+        $m_w = new userinfomodel();
+        $info = $m_w->getInfo(['id' => $id]);
+        return $info;
+    }
+
+    /*
+     * 20211129
+     * steelxu
+     * 按用户获取主动联系的清单
+     */
+    public function getconnecttotalbyusreid($arr)
+    {
+        $userid = $arr['userid'];
+        $list = $this->m_uc->seltotalbyuserid($userid);
+        if ($list) {
+            return backarr(1, "查询成功", $list);
+        } else {
+            return backarr(0, "无数据");
+        }
+
+    }
+
+    /*
+     * 20211130
+     * steelxu5
+     * 按用户获取当日主动联系的清单及评价情况
+     */
+    public function getconnectinfolistbyuiddate($arr)
+    {
+        $userid = $arr['userid'];
+        $calldate = $arr['calldate'];
+        $clist = $this->m_uc->selinfolistbyuiddate($userid, $calldate);
+        $t_i = new inventmodel();
+        $t_j = new jobhuntingmodel();
+        $t_e = new evaluatemodel();
+        foreach ($clist as &$callrecord) {
+            $sourcetype = $callrecord['sourcetype'];
+            $sourceid = $callrecord['sourceid'];
+            $sourceuser = $callrecord['reciveruserid'];
+            if ($sourcetype == 1) {
+                $sourceinfo = $t_i->selinfobyid($sourceid);
+            } else {
+                $sourceinfo = $t_j->selinfobyid($sourceid);
+            }
+            $callrecord['sourceinfo'] = $sourceinfo;
+            if ($callrecord['senderevaluate'] == 1) {
+                $einfo = $t_e->selinfobyuidetype($userid, 1);
+                $callrecord['einfo'] = $einfo;
+            }
+        }
+        if ($clist) {
+            return backarr(1, "查询成功", $clist);
+        } else {
+            return backarr(0, "无数据");
+        }
+    }
+
+    /*
+     * 20211201
+     * steelxu5
+     */
+    public function savenewconnectevaluate($arr)
+    {
+        $arr['evaluatetime'] = date('Y-m-d H:i:s');
+        $t_e = new evaluatemodel();
+        $id = $t_e->insinfo($arr);
+
+        if (!isset($arr['sourceid']) || !isset($arr['sourcetype'])) {
+            return backarr(0, "请求错误");
+        }
+
+        $sourceid = $arr['sourceid'];
+        $sourcetype = $arr['sourcetype'];
+
+        $ecount = $this->m_uc->updatesenderevaluebysid($sourceid, $sourcetype);
+        if ($id) {
+            return backarr(1, "更新成功", $id);
+        } else {
+            return backarr(0, "提交失败");
+        }
+    }
+    /**
+     * 根据查询条件获取联系列表
+     * 20211209
+     * wj
+     */
+    public function getconnectlist($arr)
+    {
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $where = [];
+        if (isset($arr['swname']) && !empty($arr['swname']) && is_string($arr['swname'])) {
+            $where['swname'] = $arr['swname'];
+        }
+        if (isset($arr['stelno']) && !empty($arr['stelno']) && is_string($arr['stelno'])) {
+            $where['stelno'] = $arr['stelno'];
+        }
+        if (isset($arr['rwname']) && !empty($arr['rwname']) && is_string($arr['rwname'])) {
+            $where['rwname'] = $arr['rwname'];
+        }
+        if (isset($arr['rtelno']) && !empty($arr['rtelno']) && is_string($arr['rtelno'])) {
+            $where['rtelno'] = $arr['rtelno'];
+        }
+        if (isset($arr['code']) && !empty($arr['code']) && is_string($arr['code'])) {
+            $where['code'] = $arr['code'];
+        }
+        if (isset($arr['calltime']) && !empty($arr['calltime']) && is_array($arr['calltime'])) {
+            if (count(array_filter($arr['calltime'])) == 2) {
+                $where['calltime'] = $arr['calltime'];
+            }
+        }
+        if (isset($arr['worktype']) && !empty($arr['worktype']) && is_string($arr['worktype'])) {
+            $where['worktype'] = $arr['worktype'];
+        }
+        $count = $this->m_uc->getconnectlist($where, true);
+        $count = $count[0]['count'];
+        if ($count <= 0) {
+            return backarr(0, '无数据');
+        }
+        $list = $this->m_uc->getconnectlist($where, false, $page, $size);
+        $data = [
+            'count' => $count,
+            'list' => $list,
+        ];
+        return backarr(1, '查询成功', $data);
+    }
+    /**
+     * 根据查询条件获取联系列表
+     * 20211217
+     * wj
+     */
+    public function getconnectbydaylist($arr)
+    {
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $where = [];
+        $callday = date('Ymd');
+        if (isset($arr['callday']) && !empty($arr['callday']) && is_string($arr['callday'])) {
+            $callday = date("Ymd", strtotime($arr['callday']));
+        }
+        if (isset($arr['swname']) && !empty($arr['swname']) && is_string($arr['swname'])) {
+            $where['swname'] = $arr['swname'];
+        }
+        if (isset($arr['stelno']) && !empty($arr['stelno']) && is_string($arr['stelno'])) {
+            $where['stelno'] = $arr['stelno'];
+        }
+        if (isset($arr['rwname']) && !empty($arr['rwname']) && is_string($arr['rwname'])) {
+            $where['rwname'] = $arr['rwname'];
+        }
+        if (isset($arr['rtelno']) && !empty($arr['rtelno']) && is_string($arr['rtelno'])) {
+            $where['rtelno'] = $arr['rtelno'];
+        }
+        if (isset($arr['code']) && !empty($arr['code']) && is_string($arr['code'])) {
+            $where['code'] = $arr['code'];
+        }
+        /*if (isset($arr['calltime']) && !empty($arr['calltime']) && is_array($arr['calltime'])) {
+        if (count(array_filter($arr['calltime'])) == 2) {
+        $where['calltime'] = $arr['calltime'];
+        }
+        }*/
+        if (isset($arr['worktype']) && !empty($arr['worktype']) && is_string($arr['worktype'])) {
+            $where['worktype'] = $arr['worktype'];
+        }
+        $daystr = $callday;
+        $isExist = $this->m_ucd->isexist($daystr);
+        if (!$isExist) {
+            $where['callday'] = $daystr;
+            $count = $this->m_uc->getconnectlist($where, true);
+            $count = $count[0]['count'];
+            if ($count <= 0) {
+                return backarr(0, '无数据');
+            }
+        } else {
+            $this->m_ucd->setTableName($daystr);
+            $count = $this->m_ucd->getconnectlist($where, true);
+            $count = $count[0]['count'];
+            if ($count <= 0) {
+                return backarr(0, '无数据');
+            }
+            $list = $this->m_ucd->getconnectlist($where, false, $page, $size);
+
+        }
+        $data = [
+            'count' => $count,
+            'list' => $list,
+        ];
+        return backarr(1, '查询成功', $data);
+    }
+
+    /***
+     * 保存用户点击行为 保存工作类型
+     * 20211209
+     * wj
+     */
+    public function saveuserclickworktype($arr)
+    {
+        $arr['source_type'] = 'worktype';
+        $result = $this->checkData($arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $refId = isset($arr['ref_id']) ? $arr['ref_id'] : 0;
+        $uaData = [
+            'uid' => $arr['uid'],
+            'ref_id' => $refId,
+            'type' => 1,
+            'source_type' => $arr['source_type'],
+            'record_time' => date('Y-m-d H:i:s'),
+        ];
+        $usId = $this->m_ua->insinfo($uaData);
+        if (empty($usId)) {
+            return backarr(0, "保存失败");
+        }
+        return backarr(1, "保存成功");
+    }
+    /*
+     * 20211220
+     * wj
+     * 统计联系电话的时间段
+     */
+    public function getconnecttimebucket($arr)
+    {
+        $date = isset($arr['date']) && !empty($arr['date']) ? $arr['date'] : date('Ymd');
+        $daystr = date('Ymd', strtotime($date));
+        $isExist = $this->m_ucd->isexist($daystr);
+        if (!$isExist) {
+            $where['callday'] = $daystr;
+            $list = $this->m_uc->getconnecttimebucket($where);
+            if (empty($list)) {
+                return backarr(0, '无数据');
+            }
+        } else {
+            $this->m_ucd->setTableName($daystr);
+            $list = $this->m_ucd->getconnecttimebucket($arr);
+            if (empty($list)) {
+                return backarr(0, '无数据');
+            }
+        }
+        return backarr(1, '查询成功', $list);
+    }
+    /*
+     * 20211222
+     * wj
+     * 统计联系电话次数
+     */
+    public function getconnectbyinvent($arr)
+    {
+        $date = isset($arr['date']) && !empty($arr['date']) ? $arr['date'] : date('Ymd');
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $daystr = date('Ymd', strtotime($date));
+        $isExist = $this->m_ucd->isexist($daystr);
+        if (!$isExist) {
+            $where['callday'] = $daystr;
+            $count = $this->m_uc->getconnectbyinvent($where, true);
+            if ($count <= 0) {
+                return backarr(0, '无数据');
+            }
+            $list = $this->m_uc->getconnectbyinvent($where, false, $page, $size);
+        } else {
+            $this->m_ucd->setTableName($daystr);
+            $count = $this->m_ucd->getconnectbyinvent($arr, true);
+            if ($count <= 0) {
+                return backarr(0, '无数据');
+            }
+            $list = $this->m_ucd->getconnectbyinvent($arr, false, $page, $size);
+        }
+        $date = [
+            'count' => $count,
+            'list' => $list,
+        ];
+        return backarr(1, '查询成功', $date);
+    }
+}

+ 106 - 0
application/index/logic/userapplyloglogic.php

@@ -0,0 +1,106 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:16:29
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-09 16:21:40
+ */
+namespace app\index\logic;
+
+use app\index\logic\businesslogic;
+use app\index\model\userapplylogmodel;
+use app\index\model\userinfomodel;
+use think\Log;
+
+class userapplyloglogic
+{
+    /**
+     * 日志新增
+     * 20211029
+     * wj
+     */
+    public function newinfo($info)
+    {
+        log::info($info);
+        $m_ual = new userapplylogmodel();
+        if (!isset($info['sharetime']) || empty($info['sharetime'])) {
+            $info['sharetime'] = date('Y-m-d H:i:s');
+        }
+        $userid = 0;
+        if (isset($info['shareopenid']) && !empty($info['shareopenid'])) {
+            $openid = $info['shareopenid'];
+            $m_u = new userinfomodel();
+            $uwhere = ['openid' => $openid];
+            $uinfo = $m_u->getInfo($uwhere, 'id');
+            if (empty($uinfo)) {
+                $wuData = ['open_id' => $openid];
+                /*$wxuserinfo = $m_ual->getxuuser($wuData);
+                if (empty($wxuserinfo)) {
+                $userid = $m_ual->newxuuser($wuData);
+                $info['isnewuser'] = 1;
+                }*/
+                $info['isnewuser'] = 1;
+            } else {
+                $userid = $uinfo['id'];
+            }
+        }
+        $info['userid'] = $userid;
+        $id = $m_ual->insertData($info);
+        if (!$id) {
+            return backarr(0, "操作失败");
+        }
+        //积分处理
+        $data = [
+            'openid' => $info['shareopenid'],
+            'type' => 'apply',
+            'typeid' => 3,
+            'applyid' => $id,
+        ];
+        $l_bl = new businesslogic();
+        $result = $l_bl->handlescorebusinessforopenid($data);
+        log::info($result);
+        if (1 != $result['status']) {
+            return backarr(0, $result['msg']);
+        }
+        return backarr(1, "操作成功", ['id' => $id, 'userid' => $info['userid']]);
+    }
+    /**
+     * 日志新增
+     * 20220121
+     * wj
+     */
+    public function newinfoforapp($info)
+    {
+        log::info($info);
+        $m_ual = new userapplylogmodel();
+        if (!isset($info['sharetime']) || empty($info['sharetime'])) {
+            $info['sharetime'] = date('Y-m-d H:i:s');
+        }
+        if (isset($info['userid'])) {
+            $userid = $info['userid'];
+            $m_u = new userinfomodel();
+            $uwhere = ['id' => $userid];
+            $uinfo = $m_u->getInfo($uwhere, 'id');
+            $userid = 0;
+            if (empty($uinfo)) {
+                $info['isnewuser'] = 1;
+            } else {
+                $userid = $uinfo['id'];
+                $info['userid'] = $userid;
+            }
+        }
+        $id = $m_ual->insertData($info);
+        if (!$id) {
+            return backarr(0, "操作失败");
+        }
+        $data = [
+            'type' => 'apply',
+            'typeid' => 3,
+            'applyid' => $id,
+        ];
+        $l_bl = new businesslogic();
+        $result = $l_bl->handlescorebusiness($data);
+        log::info($result);
+        return backarr(1, "操作成功", ['id' => $id, 'userid' => $info['userid']]);
+    }
+}

+ 743 - 0
application/index/logic/userinfologic.php

@@ -0,0 +1,743 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 09:02:06
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-19 11:38:38
+ */
+
+namespace app\index\logic;
+
+use app\index\logic\wxlogic;
+use app\index\model\companymodel;
+use app\index\model\logmodel;
+use app\index\model\userinfomodel;
+use app\index\model\workerinfomodel;
+use app\index\model\workermodel;
+use think\Db;
+use think\Log;
+
+class userinfologic
+{
+    private $userinfomodel;
+    public function __construct()
+    {
+        $this->userinfomodel = new userinfomodel();
+    }
+    public function getinfobyid($id, $field = '*')
+    {
+        $where = ['id' => $id];
+        $info = $this->userinfomodel->getInfo($where, $field);
+        return $info;
+    }
+    public function getinfobysfzid($sfzid, $field = '*')
+    {
+        $where = ['sfzid' => $sfzid];
+        $info = $this->userinfomodel->getInfo($where, $field);
+        return $info;
+    }
+    public function getinfobyopenid($arr, $field = '*')
+    {
+        if (!isset($arr['openid']) || empty($arr['openid'])) {
+            return backarr(0, "请求错误");
+        }
+        $openid = $arr['openid'];
+        $where = ['openid' => $openid];
+        $info = $this->userinfomodel->getInfo($where, $field);
+        if (empty($info)) {
+            return backarr(0, "无数据");
+        }
+        $m_c = new companymodel();
+        $cinfo = $m_c->getInfo(['userid' => $info['id'], 'isactive' => 1], ['id', 'company']);
+        $info['company'] = empty($cinfo) ? false : $cinfo;
+        return backarr(1, "查询成功", $info);
+    }
+    /*
+     * 20211003
+     * steelxu
+     * 根据电话号码获取用户消息
+     */
+    public function getinfobytelno($telno, $field = '*')
+    {
+        $where = ['telno' => $telno];
+        $info = $this->userinfomodel->getInfo($where, $field);
+        return $info;
+    }
+    public function insertinfo($info)
+    {
+        $sfzid = $info['sfzid'];
+        if (empty($sfzid)) {
+            return backarr(0, "身份证号无数据");
+        }
+        $userinfo = $this->getinfobysfzid($sfzid);
+        if ($userinfo) {
+            return backarr(0, "身份证已存在");
+        }
+        //$id = $this->userinfomodel->insertData($info);
+        $id = $this->insertUserInfo($info);
+        if (!$id) {
+            return backarr(0, "用户添加失败");
+        }
+        return backarr(1, "添加成功", $id);
+    }
+    /*
+     * wj
+     * 20211002
+     * edit by steelxu
+     * upate 改为 update
+     * 另,使用者注意,此方法仅适用于根据id无条件更新,如有其它条件,需另行写方法
+     * edit steelxu
+     * update方法参数顺序
+     */
+    public function updateinfobyid($id, $updateData)
+    {
+        $where = ['id' => $id];
+        $result = $this->userinfomodel->where($where)->update($updateData);
+        return $result;
+    }
+    /*
+     * 20211002
+     * steelxu5
+     * 快速发单,用户可不实名认证
+     * 小程序用户仅通过openid就可以获得帐户
+     */
+    public function saveuseronlyopenid($arr)
+    {
+        $arr['createtime'] = date('Y-m-d H:i:s');
+        $id = $this->userinfomodel->insertData($arr);
+        if (!$id) {
+            return backarr(0, "用户添加失败");
+        }
+        return backarr(1, "添加成功", $id);
+    }
+    /*
+     * 20211003
+     * steelxu5
+     * 小程序快速发单,用户不实名认证
+     * 提交openid 与telno
+     * 如果user表中telno已存在,则更新openid
+     * 如果telno 不存在,则创建新用户
+     * 另外返回时不返回sfzid
+     *  需要加上头像处理,如果前端处理一并提交头像,服务端已处理20211003
+     * eidt by steelxu5
+     * edit in 20211105
+     * 新注册的用户加上platform
+     * sdit by steelxu5
+     * edit in 20211119
+     * 返回做限制,不能返回所有的数据
+     */
+    public function saveuserwithopenidtelno($arr)
+    {
+        if (!isset($arr['telno']) || !isset($arr['openid'])) {
+            return backarr(0, "请求错误");
+        }
+        //先检查是否电话号码已存在
+        $telno = $arr['telno'];
+        $rinfo = $this->getinfobytelno($telno, 'id,telno,isright,openid'); //20211119 edit by steelxu5
+        if ($rinfo) {
+            //根据id更新openid
+            $rid = $rinfo['id'];
+            if ($arr['openid'] != $rinfo['openid']) {
+                $updatearr['openid'] = $arr['openid'];
+                if (array_key_exists('photourl', $arr)) {
+                    $updatearr['photourl'] = $arr['photourl'];
+                }
+                $kd = $this->updateinfobyid($rid, $updatearr);
+            }
+            $rinfo = $this->getinfobyid($rid);
+            if (isset($rinfo['sfzid'])) {
+                $rinfo['sfzid'] = '';
+            }
+            if (isset($rinfo['sfzid'])) {
+                $rinfo['sfzid'] = '';
+            }
+            return backarr(1, "添加成功", $rinfo);
+        } else {
+            Db::startTrans();
+            try {
+                $arr['createtime'] = date('Y-m-d H:i:s');
+                $arr['platform'] = '水猫小程序';
+                $id = $this->userinfomodel->insertData($arr);
+                if (!$id) {
+                    throw new \Exception("用户添加失败");
+                }
+                $uid = $id;
+               /* $l_w = new wxlogic();
+                $filename = $uid . '_' . time();
+                $qrcode = [
+                    'scene' => 'userid=' . $uid,
+                    'page' => 'src/views/index/index',
+                ];
+                $qrresult = $l_w->getqrcode($qrcode, $filename);
+                if (1 != $qrresult['status']) {
+                    throw new \Exception($qrresult['msg']);
+                }
+                $qrcode = $qrresult['data']['qrcode'];
+                $updatedata = [
+                    'qrcode' => $qrcode,
+                ];
+                $updaterow = $this->updateinfobyid($uid, $updatedata);
+                if (1 != $updaterow) {
+                    throw new \Exception("小程序二维码保存错误");
+                }*/
+                $rinfo = $this->getinfobyid($id);
+                if (isset($rinfo['sfzid'])) {
+                    $rinfo['sfzid'] = '';
+                }
+                Db::commit();
+                return backarr(1, "添加成功", $rinfo);
+            } catch (\Exception $e) {
+                $msg = $e->getMessage();
+                log::info($e->getTrace());
+                Db::rollback();
+                return backjson(0, $msg);
+            }
+        }
+    }
+
+    /*
+     * 20211031
+     * 小程序实名认证,通过openid更新其它数据
+     * steelxu5
+     */
+    public function updateinfobyopenid($arr)
+    {
+        Db::startTrans();
+        try {
+            if (!isset($arr['openid']) || empty($arr['openid'])) {
+                return backarr(0, "请求错误");
+            }
+            $openid = $arr['openid'];
+            $info = $this->userinfomodel->getInfo(['openid' => $openid]);
+            if (empty($info)) {
+                $insertData = ['openid' => $openid];
+                $userid = $this->insertUserInfo($insertData);
+                $info = $this->userinfomodel->getInfo(['id' => $userid]);
+                //throw new \Exception("无用户信息");
+            }
+            $sfzid = $arr['sfzid'];
+            $m_wi = new workerinfomodel();
+            $wiWhere = ['sfzid' => $sfzid];
+            $wiinfo = $m_wi->getinfo($wiWhere);
+            if (empty($wiinfo)) {
+                $insertData = [];
+                //工会新建信息 未缴费 value userinfo字段 key workerinfo字段
+                $insertFiledArr = [
+                    'sfzid' => 'sfzid',
+                    'wname' => 'wname',
+                    'gender' => 'gender',
+                    'wage' => 'wage',
+                    'nation' => 'nation',
+                    'telno' => 'telno',
+                    'signurl' => 'signurl',
+                    'frontsfzurl' => 'frontsfzurl',
+                    'backsfzurl' => 'backsfzurl',
+                    'city' => 'city',
+                    'disc' => 'disc',
+                    'address' => 'address',
+                ];
+                foreach ($insertFiledArr as $key => $value) {
+                    if (isset($arr[$value]) && !empty($arr[$value])) {
+                        $insertData[$key] = $arr[$value];
+                    }
+                }
+                $insertData['ispass'] = 1;
+                $insertData['isactive'] = 0;
+                $labid = $m_wi->insinfo($insertData);
+                if (empty($labid)) {
+                    throw new \Exception("工会用户添加失败");
+                }
+            } else {
+                $labid = $wiinfo['id'];
+            }
+            if (empty($labid)) {
+                throw new \Exception("无工会用户id");
+            }
+            $updatearr['labid'] = $labid;
+            $updatearr['gender'] = $arr['gender'];
+            $updatearr['nation'] = $arr['nation'];
+            $updatearr['address'] = $arr['address'];
+            $updatearr['backsfzurl'] = $arr['backsfzurl'];
+            $updatearr['frontsfzurl'] = $arr['frontsfzurl'];
+            $updatearr['sfzenddate'] = $arr['sfzenddate'];
+            $updatearr['sfzid'] = $arr['sfzid'];
+            $updatearr['telno'] = $arr['telno'];
+            $updatearr['wname'] = $arr['wname'];
+            if (isset($arr['wage']) && is_numeric($arr['wage']) && !empty($arr['wage'])) {
+                $updatearr['wage'] = $arr['wage'];
+            } else {
+                $age = getGenderByAge($sfzid);
+                if ($age < 60 && $age > 10) {
+                    $arr['wage'] = $age;
+                }
+                $updatearr['wage'] = $arr['wage'];
+            }
+            $updatearr['worktype'] = $arr['worktype'];
+            $where['id'] = $info['id'];
+            $row = $this->updateUserInfo($where, $updatearr);
+            if (empty($row)) {
+                throw new \Exception("更新失败");
+            }
+            Db::commit();
+            return backarr(1, '更新成功', $info['id']);
+        } catch (\Exception $e) {
+            Db::rollback();
+            $msg = $e->getMessage();
+            return backarr(0, $msg);
+        }
+    }
+    /*
+     * 20211105
+     * app实名认证,通过id更新其它数据
+     * wj
+     */
+    public function updateinfobyidforapp($arr)
+    {
+        $fillField = ['uid', 'sfzid'];
+        foreach ($fillField as $key => $value) {
+            if (!isset($arr[$value]) || empty($arr[$value])) {
+                return backarr(0, "请求错误");
+            }
+        }
+        $sfzid = $arr['sfzid'];
+        $uid = $arr['uid'];
+        $userinfo = $this->getinfobyid($uid);
+        if (empty($userinfo)) {
+            return backarr(0, "无用户数据");
+        }
+        if (isset($arr['sfzid']) && !empty($arr['sfzid'])) {
+            $wheresfz = [
+                'sfzid' => $arr['sfzid'],
+                'id' => ['not in', [$uid]],
+            ];
+            $sfzinfo = $this->userinfomodel->getInfo($wheresfz);
+            if (!empty($sfzinfo)) {
+                return backarr(0, "身份证已存在");
+            }
+        }
+        if (isset($arr['sfzenddate'])) {
+            $sfzenddate = getSfzend($arr['sfzenddate']);
+            if ($sfzenddate) {
+                $arr['sfzenddate'] = $sfzenddate;
+            }
+        }
+        //年龄
+        $age = getGenderByAge($sfzid);
+        if ($age < 60 && $age > 10) {
+            $arr['wage'] = $age;
+        }
+        $arr = array_merge($userinfo->toArray(), $arr);
+        Db::startTrans();
+        try {
+            //工会用户信息
+            $m_wi = new workerinfomodel();
+            $wiWhere = ['sfzid' => $sfzid];
+            $wiinfo = $m_wi->getinfo($wiWhere);
+            if (empty($wiinfo)) {
+                $insertData = [];
+                //工会新建信息 未缴费 value userinfo字段 key workerinfo字段
+                $insertFiledArr = [
+                    'sfzid' => 'sfzid',
+                    'wname' => 'wname',
+                    'gender' => 'gender',
+                    'wage' => 'wage',
+                    'nation' => 'nation',
+                    'telno' => 'telno',
+                    'signurl' => 'signurl',
+                    'frontsfzurl' => 'frontsfzurl',
+                    'backsfzurl' => 'backsfzurl',
+                    'city' => 'city',
+                    'disc' => 'disc',
+                    'address' => 'address',
+                ];
+                foreach ($insertFiledArr as $key => $value) {
+                    if (isset($arr[$value]) && !empty($arr[$value])) {
+                        $insertData[$key] = $arr[$value];
+                    }
+                }
+                $insertData['ispass'] = 1;
+                $insertData['isactive'] = 0;
+                $labid = $m_wi->insinfo($insertData);
+                if (empty($labid)) {
+                    throw new \Exception("工会用户添加失败");
+                }
+            } else {
+                $labid = $wiinfo['id'];
+            }
+            if (empty($labid)) {
+                throw new \Exception("无工会用户id");
+            }
+
+            //改用户信息
+            $updateData = [];
+            $updateFiledStr = ['gender', 'nation', 'city', 'disc', 'address', 'signurl', 'backsfzurl', 'frontsfzurl', 'sfzenddate', 'sfzid', 'telno', 'wname', 'wage', 'nickname'];
+            foreach ($updateFiledStr as $key => $value) {
+                if (isset($arr[$value]) && !empty($arr[$value])) {
+                    if ($userinfo[$value] != $arr[$value]) {
+                        $updateData[$value] = $arr[$value];
+                    }
+                }
+            }
+            $where = ['id' => $uid];
+            $updateData['labid'] = $labid;
+            if (isset($updateData['sfzenddate'])) {
+                $sfzenddate = getSfzend($updateData['sfzenddate']);
+                if ($sfzenddate) {
+                    $updateData['sfzenddate'] = $sfzenddate;
+                }
+            }
+            $row = $this->updateUserInfo($where, $updateData);
+            if (empty($row)) {
+                throw new \Exception("更新失败");
+            }
+            Db::commit();
+            $where = ['id' => $uid];
+            $field = ['id', 'gender', 'telno', 'wname', 'isactive', 'labid', 'sfzid'];
+            $info = $this->userinfomodel->getInfo($where, $field);
+            $info['sfzid'] = empty($info['sfzid']) ? false : true;
+            return backarr(1, "更新成功", $info);
+        } catch (\Exception $e) {
+            Db::rollback();
+            $msg = $e->getMessage();
+            return backarr(0, $msg);
+        }
+    }
+    /*
+     * 20210815
+     * 身份证查重
+     * edit by steelxu
+     * edit 20211031
+     */
+    public function checksfzrepeat($arr)
+    {
+        $t_gw = new userinfomodel();
+        $isrepeat = $t_gw->precheckindex($arr);
+        return $isrepeat;
+    }
+    /**
+     * 添加会员信息
+     * userinfo worker 统一操作
+     * wj
+     * 20211103
+     */
+    public function insertUserInfo($info)
+    {
+        $m_u = new userinfomodel();
+        $m_w = new workermodel();
+        $userDesc = $m_u->gettablefields();
+        $workerDesc = $m_w->gettablefields();
+        $userInsertData = [];
+        $workerInsertData = [];
+        foreach ($userDesc as $key => $value) {
+            $field = $value['Field'];
+            if (isset($info[$field])) {
+                $userInsertData[$field] = $info[$field];
+            }
+        }
+        foreach ($workerDesc as $key => $value) {
+            $field = $value['Field'];
+            if (isset($info[$field])) {
+                $workerInsertData[$field] = $info[$field];
+            }
+        }
+        $userid = $m_u->insertData($userInsertData);
+        $workerInsertData['userid'] = $userid;
+        $workerid = $m_w->insertData($workerInsertData);
+        return $userid;
+    }
+
+    /**
+     * 修改会员信息
+     * userinfo worker 统一操作
+     * wj
+     * 20211103
+     */
+    public function updateUserInfo($where, $updateData)
+    {
+        $m_u = new userinfomodel();
+        $m_w = new workermodel();
+        $userinfo = $m_u->getInfo($where);
+        $workerinfo = $m_w->getInfo(['userid' => $userinfo['id']]);
+        if (empty($workerinfo)) {
+            $wid = $m_w->insertData(['userid' => $userinfo['id']]);
+            $workerinfo = $m_w->getInfo(['id' => $wid]);
+        }
+        $userUpdateData = [];
+        $workerUpdateData = [];
+        foreach ($updateData as $key => $value) {
+            if (isset($userinfo[$key])) {
+                if ($value != $userinfo[$key]) {
+                    $userUpdateData[$key] = $updateData[$key];
+                }
+            }
+        }
+        foreach ($updateData as $key => $value) {
+            if (isset($workerinfo[$key])) {
+                if ($value != $workerinfo[$key]) {
+                    $workerUpdateData[$key] = $updateData[$key];
+                }
+            }
+        }
+        $userWhere = ['id' => $userinfo['id']];
+        $workerWhere = ['id' => $workerinfo['id']];
+        $userRow = $m_u->updateinfo($userWhere, $userUpdateData);
+        $workerRow = $m_w->updateinfo($workerWhere, $workerUpdateData);
+        return $userRow;
+    }
+
+    /**
+     * 根据条件获取用户列表
+     * 20211118
+     * wj
+     */
+    public function getuserlist($arr)
+    {
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $where = [];
+        if (isset($arr['wname']) && !empty($arr['wname'])) {
+            if ('null' == $arr['wname']) {
+                $where['wname'] = 'NULL';
+            } elseif (is_string($arr['wname'])) {
+                $where['wname'] = ['like', '%' . $arr['wname'] . '%'];
+            }
+        }
+        if (isset($arr['telno']) && !empty($arr['telno'])) {
+            $where['telno'] = ['like', '%' . $arr['telno'] . '%'];
+        }
+        if (isset($arr['sfzid']) && !empty($arr['sfzid'])) {
+            if ('null' == $arr['sfzid']) {
+                $where['sfzid'] = 'NULL';
+            } elseif (is_string($arr['sfzid'])) {
+                $where['sfzid'] = ['like', '%' . $arr['sfzid'] . '%'];
+            }
+        }
+        if (isset($arr['isactive']) && is_numeric($arr['isactive'])) {
+            if ($arr['isactive']) {
+                $where['isactive'] = 1;
+            } else {
+                $where['isactive'] = 0;
+            }
+        }
+        if (isset($arr['isright']) && is_numeric($arr['isright'])) {
+            if ($arr['isright']) {
+                $where['isright'] = 1;
+            } else {
+                $where['isright'] = 0;
+            }
+        }
+        $m_u = new userinfomodel();
+        $count = $m_u->getList($where, 'count');
+        if ($count < 0) {
+            return backarr(0, '无数据');
+        }
+        $list = $m_u->getList($where, '*', $page, $size, 'id desc');
+        $data = [
+            'list' => $list,
+            'count' => $count,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+
+    /**
+     * 改用户状态
+     * 20211118
+     * wj
+     */
+    public function updateuserisright($arr)
+    {
+        if (
+            !isset($arr['isright']) ||
+            !isset($arr['userid']) || empty($arr['userid'])
+        ) {
+            return backarr(0, "请求错误");
+        }
+        $id = $arr['userid'];
+
+        $where = ['id' => $id];
+        $info = $this->userinfomodel->getInfo($where);
+        if (empty($info)) {
+            return backarr(0, "无会员数据");
+        }
+
+        if (empty($arr['isright'])) {
+            $arr['isright'] = 0;
+        } else {
+            $arr['isright'] = 1;
+        }
+        $isright = $arr['isright'];
+
+        if ($info['isright'] === $isright) {
+            return backarr(0, "无修改数据");
+        }
+        $updateData = [
+            'isright' => $isright,
+        ];
+        $row = $this->userinfomodel->updateinfo($where, $updateData);
+        if ($row <= 0) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    /***
+     * 配置用户labid 根据uid
+     * 20211124
+     * wj
+     */
+    public function setlabidbyuid($arr)
+    {
+        if (!isset($arr['uid']) || empty($arr['uid'])) {
+            return backarr(0, "请求错误");
+        }
+        $uid = $arr['uid'];
+        $userinfo = $this->getinfobyid($uid);
+        if (empty($userinfo)) {
+            return backarr(0, "无用户信息");
+        }
+        $sfzid = $userinfo['sfzid'];
+        if (empty($sfzid)) {
+            return backarr(0, "无用户身份证号");
+        }
+        $m_wi = new workerinfomodel();
+        $wiWhere = ['sfzid' => $sfzid];
+        $wiinfo = $m_wi->getinfo($wiWhere);
+        if (empty($wiinfo)) {
+            $insertData = [];
+            //工会新建信息 未缴费 value userinfo字段 key workerinfo字段
+            $insertFiledArr = [
+                'sfzid' => 'sfzid',
+                'wname' => 'wname',
+                'gender' => 'gender',
+                'wage' => 'wage',
+                'nation' => 'nation',
+                'telno' => 'telno',
+                'signurl' => 'signurl',
+                'frontsfzurl' => 'frontsfzurl',
+                'backsfzurl' => 'backsfzurl',
+                'city' => 'city',
+                'disc' => 'disc',
+                'address' => 'address',
+            ];
+            foreach ($insertFiledArr as $key => $value) {
+                if (isset($userinfo[$value]) && !empty($userinfo[$value])) {
+                    $insertData[$key] = $userinfo[$value];
+                }
+            }
+            $insertData['ispass'] = 1;
+            $insertData['isactive'] = 0;
+            $labid = $m_wi->insinfo($insertData);
+            if (empty($labid)) {
+                return backarr(0, "工会用户添加失败");
+            }
+        } else {
+            $labid = $wiinfo['id'];
+        }
+        if (empty($labid)) {
+            return backarr(0, "无工会用户id");
+        }
+        $updateData = [];
+        if (empty($userinfo['labid'])) {
+            $updateData['labid'] = $labid;
+        } else {
+            if ($labid != $userinfo['labid']) {
+                $updateData['labid'] = $labid;
+            }
+        }
+        if (empty($updateData)) {
+            return backarr(1, "操作成功", ['labid' => $uid]);
+        }
+        $m_u = new userinfomodel();
+        $uwhere = ['id' => $uid];
+        $row = $m_u->updateinfo($uwhere, $updateData);
+        if (empty($row)) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['labid' => $labid]);
+    }
+
+
+    /*
+     * 20220111
+     * steelxu5
+     * 根据uid获得qrcode
+     */
+    public function getqrcodebyuid($arr){
+        if (!isset($arr['userid']) || empty($arr['userid'])) {
+            return backarr(0, "请求错误");
+        }
+        $uid=$arr['userid'];
+        $t_u=new userinfomodel();
+        $qrcode=$t_u->selqrcodebyuid($uid);
+        if($qrcode['qrcode']){
+             return backarr(1, "请求成功", $qrcode['qrcode']);
+        }else{
+            $l_w = new wxlogic();
+            $filename = $uid . '_' . time();
+            $qrcode = [
+                'scene' => 'userid=' . $uid,
+                'page' => 'src/views/subtelno/subtelno',
+            ];
+            $qrresult = $l_w->getqrcode($qrcode, $filename);
+            if (1 != $qrresult['status']) {
+                throw new \Exception($qrresult['msg']);
+
+            }
+            $qrcode = $qrresult['data']['qrcode'];
+            $updatedata = [
+                'qrcode' => $qrcode,
+            ];
+            $updaterow = $this->updateinfobyid($uid, $updatedata);
+            if (1 != $updaterow) {
+                throw new \Exception("小程序二维码保存错误");
+            }
+            return backarr(1, "请求成功", $qrcode);
+
+        }
+    }
+
+    /**
+     * 改用户可用状态
+     * 20220111
+     * wj
+     */
+    public function updateuserisactive($arr)
+    {
+        if (
+            !isset($arr['isactive']) ||
+            !isset($arr['userid']) || empty($arr['userid'])
+        ) {
+            return backarr(0, "请求错误");
+        }
+        $id = $arr['userid'];
+
+        $where = ['id' => $id];
+        $info = $this->userinfomodel->getInfo($where);
+        if (empty($info)) {
+            return backarr(0, "无会员数据");
+        }
+
+        if (empty($arr['isactive'])) {
+            $arr['isactive'] = 0;
+        } else {
+            $arr['isactive'] = 1;
+        }
+        $isactive = $arr['isactive'];
+
+        if ($info['isactive'] === $isactive) {
+            return backarr(0, "无修改数据");
+        }
+        $updateData = [
+            'isactive' => $isactive,
+        ];
+        $row = $this->userinfomodel->updateinfo($where, $updateData);
+        if ($row <= 0) {
+            return backarr(0, "操作失败");
+        }
+        $m_l = new logmodel();
+        $loginfo['create_date'] = date('Y-m-d H:i:s', time());
+        $loginfo['json'] = json_encode(['userid' => $id, 'msg' => '用户注销'], 320);
+        $L_id = $m_l->savelog($loginfo);
+        return backarr(1, "操作成功", ['id' => $id]);
+
+    }
+}

+ 95 - 0
application/index/logic/usershareloglogic.php

@@ -0,0 +1,95 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:16:29
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-09 16:21:40
+ */
+namespace app\index\logic;
+
+use app\index\logic\businesslogic;
+use app\index\model\userinfomodel;
+use app\index\model\usersharelogmodel;
+use think\Log;
+
+class usershareloglogic
+{
+    /**
+     * 日志新增
+     * 20211029
+     * wj
+     */
+    public function newinfo($info)
+    {
+        $m_ual = new usersharelogmodel();
+        if (!isset($info['sharetime']) || empty($info['sharetime'])) {
+            $info['sharetime'] = date('Y-m-d H:i:s');
+        }
+        $userid = 0;
+        if (isset($info['shareopenid']) && !empty($info['shareopenid'])) {
+            $openid = $info['shareopenid'];
+            $m_u = new userinfomodel();
+            $uwhere = ['openid' => $openid];
+            $uinfo = $m_u->getInfo($uwhere, 'id');
+            if (!empty($uinfo)) {
+                $userid = $uinfo['id'];
+            }
+        }
+        $info['userid'] = $userid;
+        $id = $m_ual->insertData($info);
+        if (!$id) {
+            return backarr(0, "操作失败");
+        }
+        //积分处理
+        $data = [
+            'openid' => $info['shareopenid'],
+            'type' => 'share',
+            'typeid' => 2,
+        ];
+        $l_bl = new businesslogic();
+        $result = $l_bl->handlescorebusinessforopenid($data);
+        log::info($result);
+        if (1 != $result['status']) {
+            return backarr(0, $result['msg']);
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    /**
+     * 日志新增
+     * 20220121
+     * wj
+     */
+    public function newinfobyuserid($info)
+    {
+        $m_ual = new usersharelogmodel();
+        if (!isset($info['sharetime']) || empty($info['sharetime'])) {
+            $info['sharetime'] = date('Y-m-d H:i:s');
+        }
+        if (isset($info['userid'])) {
+            $userid = $info['userid'];
+            $m_u = new userinfomodel();
+            $uwhere = ['id' => $userid];
+            $uinfo = $m_u->getInfo($uwhere, 'id');
+            if (empty($uinfo)) {
+                return backarr(0, "无用户信息");
+            }
+            $info['userid'] = $uinfo['id'];
+        }
+        $id = $m_ual->insertData($info);
+        if (!$id) {
+            return backarr(0, "操作失败");
+        }
+        if (isset($info['userid'])) {
+            //积分处理
+            $data = [
+                'userid' => $info['userid'],
+                'type' => 'share',
+                'typeid' => 2,
+            ];
+            $l_bl = new businesslogic();
+            $result = $l_bl->handlescorebusinessforuserid($data);
+            log::info($result);
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+}

+ 61 - 0
application/index/logic/versionlogic.php

@@ -0,0 +1,61 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:16:29
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-25 13:02:19
+ */
+namespace app\index\logic;
+
+use app\index\model\versionmodel;
+
+class versionlogic
+{
+
+    /**
+     * 获取最新根据版本号
+     * 20211224
+     * wj
+     */
+    public function getinfobyversion($arr)
+    {
+        if (!isset($arr['version']) || empty($arr['version']) || !is_string($arr['version'])) {
+            return backarr(0, "请求失败");
+        }
+        if (!preg_match('/\d{1,2}.{1}\d{1,2}.{1}\d{1,2}/', $arr['version'])) {
+            return backarr(0, "格式错误");
+        }
+        $type = 1;
+        if (isset($arr['type']) && !empty($arr['type'])) {
+            $type = $arr['type'];
+        }
+        $version = $arr['version'];
+        $m_v = new versionmodel();
+        $where = ['version' => ['>', $version], 'type' => $type];
+        $cinfo = $m_v->getList($where, '*', 1, 1, 'id desc', '', true);
+        if (empty($cinfo)) {
+            return backarr(0, "无数据");
+        }
+        return backarr(1, "操作成功", $cinfo);
+    }
+    /**
+     * 获取最新根据code
+     * 20211224
+     * wj
+     */
+    public function getinfobycode($arr)
+    {
+        $type = 1;
+        if (isset($arr['type']) && !empty($arr['type'])) {
+            $type = $arr['type'];
+        }
+        $m_v = new versionmodel();
+        $where = ['type' => $type];
+        $cinfo = $m_v->getList($where, '*', 1, 1, 'id desc', '', true);
+        if (empty($cinfo)) {
+            return backarr(0, "无数据");
+        }
+        return backarr(1, "操作成功", $cinfo);
+    }
+
+}

+ 450 - 0
application/index/logic/webmanger.php

@@ -0,0 +1,450 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2020/1/22
+ * Time: 21:19
+ */
+namespace app\index\logic;
+
+use app\index\model\rolesmodel;
+use app\index\model\roleusermodel;
+use app\index\model\webusermodel;
+use think\Log;
+
+class webmanger
+{
+    public function getlogininfo($lname, $lpwd)
+    {
+
+        $webusertable = new webusermodel();
+        $userinfo = $webusertable->getlogininfo($lname, $lpwd);
+        //var_dump($userinfo);
+        return $userinfo;
+    }
+    /**
+     * 校验登录 并修改token
+     */
+    public function userlogin($lname, $lpwd, $updateToken = true)
+    {
+        $m_wu = new webusermodel();
+        $userinfo = $m_wu->getlogininfomd5($lname, $lpwd);
+        if (empty($userinfo)) {
+            return backarr(0, '无用户信息');
+        }
+        $token = $userinfo['token'];
+        if ($updateToken) {
+            $result = $this->updateToken($userinfo['id']);
+            if (1 != $result['status']) {
+                return $result;
+            }
+        }
+        $token = $result['data']['token'];
+        return backarr(1, '登录成功', ['token' => $token, 'id' => $userinfo['id']]);
+    }
+    /**
+     * 用户登出
+     * 改用户token
+     * 20211204
+     * wj
+     */
+    public function updateToken($uid = 0)
+    {
+        $m_wu = new webusermodel();
+        $m_r = new rolesmodel();
+        $m_ru = new roleusermodel();
+        $rwhere = ['name' => '普通用户', 'is_active' => 1];
+        $rid = 0; //不改token组id
+        $userinfo = [];
+        $rinfo = $m_r->getInfo($rwhere);
+        if (!empty($rinfo)) {
+            $rid = $rinfo['id'];
+        }
+        if (empty($uid)) {
+            $token = request()->server('HTTP_TOKEN');
+            if (empty($token)) {
+                return backarr(0, "无token数据");
+            }
+            $where = ['token' => $token];
+            $field = ['id', 'user_name', 'token'];
+            $userinfo = $m_wu->getInfo($where, $field);
+        } else {
+            $where = ['id' => $uid];
+            $field = ['id', 'user_name', 'token'];
+            $userinfo = $m_wu->getInfo($where);
+        }
+        if (empty($userinfo)) {
+            return backarr(0, "无用户信息");
+        }
+        $ruwhere = ['uid' => $userinfo['id']];
+        $ruinfo = $m_ru->getInfo($ruwhere);
+        $changeToken = true;
+        if (!empty($ruinfo) && !empty($rid)) {
+            if ($ruinfo['rid'] == $rid) {
+                $changeToken = false;
+            }
+        }
+        if ($changeToken) {
+            $token = $this->getToken($userinfo['user_name']);
+            $updateData = [
+                'token' => $token,
+            ];
+            $where = ['id' => $userinfo['id']];
+            $row = $m_wu->updateinfo($where, $updateData);
+            if (empty($row)) {
+                log::info($userinfo['user_name'] . " token 修改失败");
+                return backarr(0, "token 修改失败");
+            }
+        } else {
+            $token = $userinfo['token'];
+        }
+        return backarr(1, "操作成功", ['uid' => $userinfo['id'], 'token' => $token]);
+    }
+    /***
+     * 获取用户token
+     */
+    private function getToken($username)
+    {
+        $str = md5(uniqid(md5(microtime(true)), true));
+        $token = sha1($str . $username);
+        return $token;
+    }
+    /**
+     * 获取用户信息 权限组名 和头像 待改
+     * 20211101
+     * wj
+     */
+    public function queryinfobytoken($arr)
+    {
+        if (!isset($arr['token']) || empty($arr['token'])) {
+            return backarr(0, "请求错误");
+        }
+        $defaultData = [
+            //'access' => 'admin',
+            'avatar' => 'https://file.iviewui.com/dist/a0e88e83800f138b94d2414621bd9704.png',
+        ];
+        $token = $arr['token'];
+        $m_wu = new webusermodel();
+        $where = ['token' => $token];
+        $field = ['id', 'user_name'];
+        $userinfo = $m_wu->getInfo($where, $field);
+        if (empty($userinfo)) {
+            return backarr(0, "无用户数据");
+        }
+        //获取权限组名
+        $m_ru = new roleusermodel();
+        $ruwhere = [
+            'uid' => $userinfo['id'],
+        ];
+        $ruinfo = $m_ru->getInfo($ruwhere);
+        if (!empty($ruinfo)) {
+            $rwhere = [
+                'id' => $ruinfo['rid'],
+                'is_active' => 1,
+            ];
+            $m_r = new rolesmodel();
+            $rinfo = $m_r->getInfo($rwhere);
+            if ($rinfo) {
+                $userinfo['access'] = $rinfo['flag_bit'];
+            }
+        }
+        if (!isset($userinfo['access'])) {
+            $userinfo['access'] = "";
+        }
+        if (empty($userinfo)) {
+            return backarr(0, "无数据");
+        } else {
+            $userinfo = array_merge($defaultData, $userinfo->toArray());
+            return backarr(1, "查询成功", $userinfo);
+        }
+    }
+
+    /***
+     * 获取用户信息 通过id
+     * 20211103
+     * wj
+     */
+    public function queryinfobyid($arr)
+    {
+        $id = $arr['id'];
+        $m_wu = new webusermodel();
+        $where = ['id' => $id];
+        $fields = ['id', 'user_name', 'email', 'create_date', 'isactive', 'create_id'];
+        $userinfo = $m_wu->getInfo($where, $fields);
+        if (empty($userinfo)) {
+            return backarr(0, "无数据");
+        }
+        if (!empty($userinfo['create_id'])) {
+            $where = ['id' => $userinfo['create_id']];
+            $createinfo = $m_wu->getInfo($where, ['user_name']);
+            $userinfo['create_user_name'] = $createinfo['user_name'];
+        }
+        return backarr(1, "查询成功", $userinfo);
+    }
+
+    public function queryinfowitchsetting($id)
+    {
+        $m_wu = new webusermodel();
+        $m_ru = new roleusermodel();
+        $where = ['id' => $id];
+        $fields = ['id', 'user_name', 'email', 'create_date', 'isactive', 'create_id'];
+        $userinfo = $m_wu->getInfo($where, $fields);
+        if (empty($userinfo)) {
+            return backarr(0, "无数据");
+        }
+        if (!empty($userinfo['create_id'])) {
+            $where = ['id' => $userinfo['create_id']];
+            $createinfo = $m_wu->getInfo($where, ['user_name']);
+            $userinfo['create_user_name'] = $createinfo['user_name'];
+        }
+        $userinfo['setting'] = ['access' => '', 'access_name' => ''];
+        $roleinfo = $m_ru->getinfoforuser($id);
+        if ($roleinfo) {
+            $roleinfo = $roleinfo[0];
+            $setting = [
+                'access' => $roleinfo['flag_bit'],
+                'access_name' => $roleinfo['name'],
+            ];
+            $userinfo['setting'] = $setting;
+        }
+
+        return backarr(1, "查询成功", $userinfo);
+    }
+
+    public function editwebuser($arr)
+    {
+        if (isset($arr['id']) && !empty($arr['id'])) {
+            $result = $this->updatewebuserinfo($arr);
+        } else {
+            $result = $this->newwebuser($arr);
+        }
+        return $result;
+    }
+    /**
+     * 新建web用户
+     * 登录名不可重复
+     */
+    public function newwebuser($arr)
+    {
+        $name = $arr['name'];
+        $m_wu = new webusermodel();
+        $where = ['user_name' => $name];
+        $userinfo = $m_wu->getInfo($where);
+        if ($userinfo) {
+            return backarr(0, "用户已存在");
+        }
+        $insertData = [];
+        $insertData['user_name'] = $name;
+        $insertData['user_password'] = md5($name . $arr['password']);
+        $insertData['token'] = $this->getToken($name);
+        $insertData['create_date'] = date('Y-m-d H:i:s');
+        $insertData['create_id'] = $arr['userid'];
+        if (isset($arr['email']) && !empty($arr['email'])) {
+            $insertData['email'] = $arr['email'];
+        }
+        $id = $m_wu->insertData($insertData);
+        if (empty($id)) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+    /***
+     * 改用户信息
+     * 20211103
+     * wj
+     * 仅改用户邮箱
+     */
+    public function updatewebuserinfo($arr)
+    {
+        $id = $arr['id'];
+        $m_wu = new webusermodel();
+        $where = ['id' => $id];
+        $userinfo = $m_wu->getInfo($where);
+        if (empty($userinfo)) {
+            return backarr(0, "用户不存在");
+        }
+        $updateData = [];
+        if (isset($arr['email']) && !empty($arr['email'])) {
+            $updateData['email'] = $arr['email'];
+        }
+        if (!empty($updateData)) {
+            $row = $m_wu->updateinfo($where, $updateData);
+            if (empty($row)) {
+                return backarr(0, "操作失败");
+            }
+            return backarr(1, "操作成功", ['id' => $id]);
+        }
+        return backarr(0, "无修改数据");
+    }
+    /***
+     * 改用户密码
+     * 20211103
+     * wj
+     */
+    public function updatepasswd($arr)
+    {
+        $fillfields = [
+            'name', 'password',
+        ];
+        foreach ($fillfields as $key => $value) {
+            if (!isset($arr[$value]) || empty($arr[$value])) {
+                return backarr(0, "请求错误");
+            }
+        }
+        $m_wu = new webusermodel();
+        $name = trim($arr['name']);
+        $password = trim($arr['password']);
+        $where = ['user_name' => $name];
+        $userinfo = $m_wu->getInfo($where);
+        if (empty($userinfo)) {
+            return backarr(0, "用户不存在");
+        }
+        $updateData = [
+            'user_password' => md5($name . $password),
+            'token' => $this->getToken($name),
+        ];
+        $id = $userinfo['id'];
+        $where = ['id' => $id];
+        $row = $m_wu->updateinfo($where, $updateData);
+        if (empty($row)) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+
+    /***
+     * 改用户状态
+     * 20211103
+     * wj
+     */
+    public function updateisactive($arr)
+    {
+        $id = $arr['id'];
+        $isactive = $arr['isactive'];
+        $m_wu = new webusermodel();
+        $where = ['id' => $id];
+        $userinfo = $m_wu->getInfo($where);
+        if (empty($userinfo)) {
+            return backarr(0, "用户不存在");
+        }
+        //默认 isactive 0
+        $isactive = in_array($isactive, [0, 1]) ? $isactive : 0;
+        $updateData = ['isactive' => $isactive];
+        $row = $m_wu->updateinfo($where, $updateData);
+        if (empty($row)) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+
+    /***
+     * 获取用户列表
+     * 20211103
+     * wj
+     */
+    public function getalllist($arr)
+    {
+        $searchData = [];
+        if (isset($arr['userName']) && !empty($arr['userName'])) {
+            $searchData['user_name'] = ['like', '%' . $arr['userName'] . '%'];
+        }
+        if (isset($arr['isactive']) && in_array($arr['isactive'], [0, 1]) && is_numeric($arr['isactive'])) {
+            $searchData['isactive'] = $arr['isactive'];
+        }
+        $m_wu = new webusermodel();
+        $count = $m_wu->getList($searchData, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $page = !isset($arr['page']) || empty($arr['page']) ? 1 : $arr['page'];
+        $size = !isset($arr['size']) || empty($arr['size']) ? 10 : $arr['size'];
+        $fields = ['id'];
+        $list = $m_wu->getList($searchData, $fields, $page, $size);
+        foreach ($list as $key => &$value) {
+            $result = $this->queryinfowitchsetting($value['id']);
+            if (1 != $result['status']) {
+                return backarr(0, $result['msg']);
+            }
+            $list[$key] = $result['data'];
+        }
+        $data = [
+            'count' => $count,
+            'list' => $list->toArray(),
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+
+    /**
+     * 按照id查用户信息
+     * 20211110
+     * wj
+     */
+    public function searchUserInfo($arr)
+    {
+        $id = 0;
+        if (isset($arr['id']) && !empty($arr['id'])) {
+            $id = $arr['id'];
+        }
+        if (empty($id)) {
+            return backarr(0, "无数据");
+        }
+        $result = $this->queryinfowitchsetting($id);
+        return $result;
+    }
+
+    /**
+     * 保存用户和用户组关系
+     * 20211110
+     * wj
+     */
+    public function saveuserrole($arr)
+    {
+        $fillfields = ['access', 'uid'];
+        foreach ($fillfields as $key => $value) {
+            if (!isset($arr[$value]) || !isset($arr[$value])) {
+                return backarr(0, "请求错误");
+            }
+        }
+
+        $m_r = new rolesmodel();
+        $m_wu = new webusermodel();
+        $m_ru = new roleusermodel();
+
+        $userid = $arr['uid'];
+        $access = $arr['access'];
+
+        $mrinfo = $m_r->getInfo(['flag_bit' => $access, 'is_active' => 1]);
+        if (empty($mrinfo)) {
+            return backarr(0, "无权限组");
+        }
+
+        $wuinfo = $m_wu->getInfo(['id' => $userid]);
+        if (empty($wuinfo)) {
+            return backarr(0, "用户不存在");
+        }
+        $ruinfo = $m_ru->getInfo(['uid' => $userid]);
+        if (empty($ruinfo)) {
+            $insertData = [
+                'uid' => $userid,
+                'rid' => $mrinfo['id'],
+            ];
+            $id = $m_ru->insertData($insertData);
+        } else {
+            $ruwhere = ['id' => $ruinfo['id']];
+            $updateData = [
+                'rid' => $mrinfo['id'],
+            ];
+            $row = $m_ru->updateinfo($ruwhere, $updateData);
+            if ($row <= 0) {
+                $id = 0;
+            } else {
+                $id = $ruinfo['id'];
+            }
+        }
+
+        if (empty($id)) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功", ['id' => $id]);
+    }
+}

+ 101 - 0
application/index/logic/webuserloglogic.php

@@ -0,0 +1,101 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-11-16 11:27:46
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-18 17:56:34
+ */
+namespace app\index\logic;
+
+use app\index\model\webuserlogmodel;
+use app\index\model\webusermodel;
+use think\Request;
+
+class webuserloglogic
+{
+    //加日志信息
+    public function addlog($arr)
+    {
+        $insertData = [];
+        $m_wu = new webusermodel();
+        $ip = Request::instance()->ip();
+        $insertData = [
+            'ip' => $ip,
+            'createtime' => date('Y-m-d H:i:s'),
+        ];
+        $where = [];
+        if (isset($arr['token']) && !empty($arr['token'])) {
+            $token = $arr['token'];
+            $where['token'] = $token;
+        }
+
+        if (isset($arr['wuid']) && !empty($arr['wuid']) && !isset($insertData['wuid'])) {
+            $id = $arr['wuid'];
+            $where['id'] = $id;
+        }
+        $info = $m_wu->getInfo($where, ['id']);
+        if (empty($info)) {
+            return backarr(0, "无用户数据");
+        }
+        $insertData['wuid'] = $info['id'];
+        if (isset($arr['node']) && !empty($arr['node'])) {
+            $insertData['node'] = $arr['node'];
+        }
+        if (isset($arr['type']) && !empty($arr['type'])) {
+            $insertData['type'] = $arr['type'];
+        }
+        if (isset($arr['tablename']) && !empty($arr['tablename'])) {
+            $insertData['tablename'] = $arr['tablename'];
+        }
+        if (isset($arr['refid']) && !empty($arr['refid'])) {
+            $insertData['refid'] = $arr['refid'];
+        }
+        $m_wul = new webuserlogmodel();
+        $id = $m_wul->insertData($insertData);
+        if ($id <= 0) {
+            return backarr(0, "操作失败");
+        }
+        return backarr(1, "操作成功");
+    }
+    /***
+     * 获取列表
+     * 20211221
+     * wj
+     */
+    public function getlistbywhere($arr)
+    {
+        $m_wl = new webuserlogmodel();
+        $m_wu = new webusermodel();
+        $userlist = [];
+        $where = [];
+        if (isset($arr['type']) && !empty($arr['type'])) {
+            $type = explode(',', $arr['type']);
+            $where['type'] = ['in', $type];
+        }
+        if (isset($arr['refid']) && !empty($arr['refid']) && is_numeric($arr['refid'])) {
+            $where['refid'] = $arr['refid'];
+        }
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $count = $m_wl->getList($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $field = ['id', 'wuid', 'ip', 'node', 'createtime', 'type', 'refid'];
+        $list = $m_wl->getList($where, $field, $page, $size);
+        foreach ($list as $key => &$value) {
+            if (isset($userlist[$value['wuid']])) {
+                $wuinfo = $userlist[$value['wuid']];
+            } else {
+                $wuinfo = $m_wu->getInfo(['id' => $value['wuid']], 'user_name');
+                $userlist[$value['wuid']] = $wuinfo;
+            }
+            $list[$key]['username'] = $wuinfo['user_name'];
+        }
+        $data = [
+            'count' => $count,
+            'list' => $list,
+        ];
+        return backarr(1, "查询成功", $data);
+    }
+}

+ 65 - 0
application/index/logic/workerlogic.php

@@ -0,0 +1,65 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 09:02:06
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-09-27 11:15:36
+ */
+namespace app\index\logic;
+
+use app\index\model\userinfomodel;
+use app\index\model\workermodel;
+
+class workerlogic
+{
+    private $workermodel;
+    public function __construct()
+    {
+        $this->workermodel = new workermodel();
+        $this->userinfomodel = new userinfomodel();
+    }
+    public function getinfobyid($id)
+    {
+        $where = ['id' => $id];
+        $info = $this->workermodel->getInfo($where);
+        return $info;
+    }
+    public function getinfobyuserid($userid)
+    {
+        $where = ['userid' => $userid];
+        $info = $this->workermodel->getInfo($where);
+        return $info;
+    }
+    public function insertinfo($info)
+    {
+        $userid = $info['userid'];
+        if (empty($userid)) {
+            return backjson(0, "请求数据错误");
+        }
+        $userinfo = $this->userinfomodel->getInfo(['id' => $userid], 'id');
+        if (!$userinfo) {
+            return backArr(0, "无用户信息");
+        }
+        $workinfo = $this->getinfobyuserid($userid);
+        if ($workinfo) {
+            return backArr(0, "用户信息已存在");
+        }
+        $id = $this->workermodel->insertData($info);
+        if (!$id) {
+            return backArr(0, "添加失败");
+        }
+        return backArr(1, "添加成功", ['id' => $id]);
+    }
+    public function updateinfobyid($id, $updateData)
+    {
+        $where = ['id' => $id];
+        $result = $this->workermodel->updateinfo($where, $updateData);
+        return $result;
+    }
+    public function updateinfobyuserid($userid, $updateData)
+    {
+        $where = ['userid' => $userid];
+        $result = $this->workermodel->updateinfo($where, $updateData);
+        return $result;
+    }
+}

+ 71 - 0
application/index/logic/workerskilllogic.php

@@ -0,0 +1,71 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 09:02:06
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-22 15:46:16
+ */
+namespace app\index\logic;
+
+use app\index\model\userinfomodel;
+use app\index\model\workerskillmodel;
+
+class workerskilllogic
+{
+    public function getinfobyid($id)
+    {
+        $m_wt = new workerskillmodel();
+        $where = ['id' => $id];
+        $info = $m_wt->getInfo($where);
+        return $info;
+    }
+    public function insertinfo($info)
+    {
+        $m_wt = new workerskillmodel();
+        $m_u = new userinfomodel();
+        if (!isset($info['uid']) || empty($info['uid'])) {
+            return backarr(0, "请求错误");
+        }
+        $uid = $info['uid'];
+        $userinfo = $m_u->getInfo(['id' => $uid]);
+        if (empty($userinfo)) {
+            return backarr(0, "无用户数据");
+        }
+        $id = $m_wt->insertData($info);
+        return backarr(1, "新增成功", ['id' => $id]);
+    }
+    public function updateinfobyid($id, $updateData)
+    {
+        $m_wt = new workerskillmodel();
+        $where = ['id' => $id];
+        $result = $m_wt->updateinfo($where, $updateData);
+        return $result;
+    }
+    public function getlistonepage($arr)
+    {
+        $where = [];
+        $m_wt = new workerskillmodel();
+        $count = $m_wt->getList($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_wt->getList($where, '*', 1, 0, "id desc");
+        return backarr(1, "查询成功", $list);
+    }
+    /*
+     * 20211022
+     * 获取指定用户的工作技能
+     * steelxu5
+     */
+    public function getlistbyuid($arr){
+        $uid=$arr['uid'];
+        $where = ['uid' => $uid];
+        $m_wt = new workerskillmodel();
+        $count = $m_wt->getList($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_wt->getList($where, '*', 1, 0, "id desc");
+        return backarr(1, "查询成功", $list);
+    }
+}

+ 83 - 0
application/index/logic/worktypelogic.php

@@ -0,0 +1,83 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 09:02:06
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-22 14:12:07
+ */
+namespace app\index\logic;
+
+use app\index\model\worktypemodel;
+
+class worktypelogic
+{
+    public function getinfobyid($id)
+    {
+        $m_wt = new worktypemodel();
+        $where = ['id' => $id];
+        $info = $m_wt->getInfo($where);
+        return $info;
+    }
+    public function insertinfo($info)
+    {
+        $m_wt = new worktypemodel();
+        $id = $m_wt->insertData($info);
+        return $id;
+    }
+    public function updateinfobyid($id, $updateData)
+    {
+        $m_wt = new worktypemodel();
+        $where = ['id' => $id];
+        $result = $m_wt->updateinfo($where, $updateData);
+        return $result;
+    }
+    public function getlistall($arr)
+    {
+        $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
+        $where = [];
+        /*if (isset($arr['is_active']) && in_array($arr['is_active'], [1, 0])) {
+        $where['is_active'] = $arr['is_active'];
+        }*/
+        $where['is_active'] = 1;
+        $m_wt = new worktypemodel();
+        $count = $m_wt->getList($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_wt->getList($where, '*', $page, $size, "sort asc");
+        return backarr(1, "查询成功", $list);
+    }
+    public function getlistonepage($arr)
+    {
+        $where = [];
+        $where['is_active'] = 1;
+        $m_wt = new worktypemodel();
+        $count = $m_wt->getList($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_wt->getList($where, '*', 1, 0, "sort asc");
+        return backarr(1, "查询成功", $list);
+    }
+
+    /***
+     * 根据联系数量对工种进行排序
+     * wj
+     * 20211214
+     */
+    public function getworktypebyconnect($arr)
+    {
+        $page = isset($arr['page']) && !empty($arr['page']) && is_numeric($arr['page']) ? $arr['page'] : 1;
+        $size = isset($arr['size']) && !empty($arr['size']) && is_numeric($arr['size']) ? $arr['size'] : 5;
+        $where = [];
+        if (isset($arr['calltime']) && !empty($arr['calltime']) && is_array($arr['calltime'])) {
+            if (count(array_filter($arr['calltime'])) == 2) {
+                $where['calltime'] = $arr['calltime'];
+            }
+        }
+        $m_wt = new worktypemodel();
+        $list = $m_wt->getworktypebyconnect($where, $page, $size);
+        return $list;
+    }
+}

+ 73 - 0
application/index/logic/wxBizDataCrypt.php

@@ -0,0 +1,73 @@
+<?php
+
+/**
+ * 对微信小程序用户加密数据的解密示例代码.
+ *
+ * @copyright Copyright (c) 1998-2014 Tencent Inc.
+ */
+
+namespace app\index\logic;
+use app\index\logic\errorCode;
+//include_once "errorCode.php";
+
+
+class wxBizDataCrypt
+{
+    private $appid;
+	private $sessionKey;
+
+	/**
+	 * 构造函数
+	 * @param $sessionKey string 用户在小程序登录后获取的会话密钥
+	 * @param $appid string 小程序的appid
+	 */
+	public function __construct( $appid, $sessionKey)
+	{
+
+		$this->sessionKey = $sessionKey;
+		$this->appid = $appid;
+	}
+
+
+	/**
+	 * 检验数据的真实性,并且获取解密后的明文.
+	 * @param $encryptedData string 加密的用户数据
+	 * @param $iv string 与用户数据一同返回的初始向量
+	 * @param $data string 解密后的原文
+     *
+	 * @return int 成功0,失败返回对应的错误码
+	 */
+	public function decryptData( $encryptedData, $iv, &$data )
+	{
+
+		if (strlen($this->sessionKey) != 24) {
+			return errorCode::$IllegalAesKey;
+		}
+		$aesKey=base64_decode($this->sessionKey);
+
+
+		if (strlen($iv) != 24) {
+			return errorCode::$IllegalIv;
+		}
+		$aesIV=base64_decode($iv);
+
+		$aesCipher=base64_decode($encryptedData);
+
+		$result=openssl_decrypt( $aesCipher, "AES-128-CBC", $aesKey, 1, $aesIV);
+
+		$dataObj=json_decode( $result );
+		if( $dataObj  == NULL )
+		{
+			return errorCode::$IllegalBuffer;
+		}
+		if( $dataObj->watermark->appid != $this->appid )
+		{
+			return errorCode::$IllegalBuffer;
+		}
+		$data = $result;
+
+		return errorCode::$OK;
+	}
+
+}
+

+ 84 - 0
application/index/logic/wxlogic.php

@@ -0,0 +1,84 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-12-29 11:12:53
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-29 15:14:22
+ */
+
+namespace app\index\logic;
+
+class wxlogic
+{
+    /**
+     * 获取配置
+     * 20211229
+     * wj
+     */
+    private function getconfig()
+    {
+        $config = [
+            'appid' => 'wxcacf6eb6e7478e29',
+            'appSecret' => '3722c3f95df0569498a0e32ae6e85153',
+        ];
+    }
+    /**
+     * 获取二维码
+     * 20211229
+     * wj
+     */
+    public function getqrcode($data, $filename = '', $dirname = "qrcode")
+    {
+        if (empty($data) || !is_array($data)) {
+            return backarr(0, "请求失败");
+        }
+        $filename = empty($filename) || !is_string($filename) ? time() : $filename;
+        $dirname = empty($dirname) || !is_string($dirname) ? "qrcode" : $dirname;
+        $qr_path = "./Uploads/" . $dirname;
+        if (!file_exists($qr_path)) {
+            mkdir($qr_path, 0700, true); //判断保存目录是否存在,不存在自动生成文件目录
+        }
+        $filepath = $dirname . "/" . $filename . '.png';
+        $filename = $filename . '.png';
+        $file = $qr_path . "/" . $filename;
+        $access = $this->getAccessToken();
+        $access_token = $access['access_token'];
+        $url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $access_token;
+
+        $data = array(
+            'scene' => $data['scene'], //二维码所带参数
+            'width' => 200,
+            'page' => $data['page'], //二维码跳转路径(要已发布小程序)
+            'auto_color' => true,
+            //'is_hyaline' => true, //透明底色
+        );
+        $result = requestCurl($url, "post", json_encode($data)); //请求微信接口
+        $resultJson = json_decode($result, true);
+        if (!empty($resultJson) && isset($resultJson['errcode'])) {
+            $errcode = $resultJson['errcode'];
+            $errmsg = $resultJson['errmsg'];
+            return backarr(0, $errmsg);
+        }
+        $domainpath = 'https://app.tjzhxx.cn:11443/Uploads/';
+        $res = file_put_contents($file, $result); //将微信返回的图片数据流写入文件
+        if ($res === false) {
+            return backarr(0, '生成二维码失败');
+        }
+        $data = [
+            'qrcode' => $domainpath . $filepath,
+        ];
+        return backarr(1, 'success', $data);
+    }
+
+    public function getAccessToken()
+    {
+        $config = $this->getconfig();
+
+        $appid = 'wxcacf6eb6e7478e29';
+        $appSecret = '3722c3f95df0569498a0e32ae6e85153';
+        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $appSecret;
+        $result = requestCurl($url);
+        $wxResult = json_decode($result, true);
+        return $wxResult;
+    }
+}

+ 61 - 0
application/index/model/businesstypemodel.php

@@ -0,0 +1,61 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-29 16:15:16
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class businesstypemodel extends Model
+{
+
+    protected $table = 't_businesstype';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 61 - 0
application/index/model/buyscorekindmodel.php

@@ -0,0 +1,61 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-13 08:52:52
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class buyscorekindmodel extends Model
+{
+
+    protected $table = 't_buyscorekind';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 101 - 0
application/index/model/companymodel.php

@@ -0,0 +1,101 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-29 16:15:16
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class companymodel extends Model
+{
+
+    protected $table = 't_company';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $whereUse = [];
+        if (isset($where['company']) && !empty($where['company'])) {
+            $whereUse['company'] = ['like', "%" . $where['company'] . "%"];
+        }
+        if (isset($where['wname']) && !empty($where['wname'])) {
+            $whereUse['wname'] = ['like', "%" . $where['wname'] . "%"];
+        }
+        if (isset($where['telno']) && !empty($where['telno'])) {
+            $whereUse['telno'] = ['like', "%" . $where['telno'] . "%"];
+        }
+        if (isset($where['isactive']) && in_array($where['isactive'], [0, 1])) {
+            $whereUse['isactive'] = $where['isactive'];
+        }
+        if (isset($where['ispass']) && in_array($where['ispass'], [0, 1, 2])) {
+            $whereUse['ispass'] = $where['ispass'];
+        }
+        if (isset($where['createtime']) && is_array($where['createtime'])) {
+            $whereUse['createtime'] = ['between', $where['createtime']];
+        }
+        $sqlObj = $this->where($whereUse);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+    /**
+     * 获取企业总量
+     * 20211228
+     * wj
+     */
+    public function getcount()
+    {
+        $count = $this->where([])->count();
+        return $count;
+    }
+    /**
+     * 获取分析数据
+     * 20211228
+     * wj
+     */
+    public function statistics()
+    {
+        $sql = "select isactive,ispass,count(*) as count from " . $this->table . " group by isactive,ispass";
+        $list = $this->query("select * from (" . $sql . ") as t");
+        return $list;
+    }
+}

+ 88 - 0
application/index/model/evaluatemodel.php

@@ -0,0 +1,88 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2021/11/30
+ * Time: 19:44
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class evaluatemodel extends Model
+{
+    protected $table = 't_evaluate';
+
+    public function insinfo($arr)
+    {
+        $this->setAttr('id', null)->isUpdate(false)->allowField(true)->save($arr);
+        return $this->id;
+    }
+
+    /*
+     * 20211130
+     * steelxu
+     */
+    public function selinfobyuidetype($evaluateuserid, $etype)
+    {
+        $where_arr['evaluateuserid'] = $evaluateuserid;
+        $where_arr['evaluatetype'] = $etype;
+        $rec = $this->where($where_arr)->find();
+        return $rec;
+
+    }
+
+    /***
+     * pc后台 获取列表
+     * 20211214
+     * wj
+     */
+    public function getlistforadmin($where, $count = false, $page = 1, $size = 10)
+    {
+        $sql = "select e.*,u.wname,u.telno from t_evaluate as e join t_userinfo as u on u.id = e.evaluateuserid";
+        $whereUse = [];
+        if (isset($where['wname']) && !empty($where['wname']) && is_string($where['wname'])) {
+            $whereUse['u.wname'] = "u.wname like '%" . $where['wname'] . "%'";
+        }
+        if (isset($where['telno']) && !empty($where['telno']) && is_numeric($where['telno'])) {
+            $whereUse['u.telno'] = "u.telno like '%" . $where['telno'] . "%'";
+        }
+        if (isset($where['sourcetype']) && !empty($where['sourcetype']) && in_array($where['sourcetype'], [1, 2])) {
+            $whereUse['e.sourcetype'] = "e.sourcetype = '" . $where['sourcetype'] . "'";
+            if (isset($where['code']) && !empty($where['code']) && is_string($where['code'])) {
+                switch ($where['sourcetype']) {
+                    case 1:
+                        $sql .= " join t_invent as i on i.id = e.sourceid";
+                        $whereUse['i.code'] = "i.code like '%" . $where['code'] . "%'";
+                        break;
+                    case 2:
+                        $sql .= " join t_jobhunting as j on j.id = e.sourceid";
+                        $whereUse['j.id'] = "j.id like '%" . $where['code'] . "%'";
+                        break;
+                }
+            }
+        }
+        if (isset($where['evaluatetype']) && in_array($where['evaluatetype'], [1])) {
+            $whereUse['e.evaluatetype'] = "e.evaluatetype='" . $where['evaluatetype'] . "'";
+        }
+        if (isset($where['evaluatememo']) && !empty($where['evaluatememo']) && is_string($where['evaluatememo'])) {
+            $whereUse['e.evaluatememo'] = "e.evaluatememo like '%" . $where['evaluatememo'] . "%'";
+        }
+        if (isset($where['e.evaluatetime']) && is_array($where['evaluatetime'])) {
+            $whereUse['e.evaluatetime'] = "e.evaluatetime between '" . $where['evaluatetime'][0] . "' and '" . $where['evaluatetime'][1] . "'";
+        }
+        $whereStr = implode(' and ', $whereUse);
+        if (!empty($whereStr)) {
+            $sql .= ' where ' . $whereStr;
+        }
+        $sql .= ' order by id desc';
+        if ($count) {
+            $list = $this->query("select count(*) count from (" . $sql . ") as t");
+            $count = $list[0]['count'];
+            return $count;
+        }
+        $index = ($page - 1) * $size;
+        $list = $this->query("select * from (" . $sql . ") as t limit " . $index . "," . $size);
+        return $list;
+    }
+}

+ 44 - 0
application/index/model/feedbackmodel.php

@@ -0,0 +1,44 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2021/11/18
+ * Time: 14:25
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class feedbackmodel extends Model
+{
+    protected $table = 't_feedback';
+
+    /*
+     * 20211118
+     *
+     */
+    public function insinfo($arr)
+    {
+        $this->setAttr('id', null)->isUpdate(false)->allowField(true)->save($arr);
+        return $this->id;
+    }
+    /*
+     * 20211227
+     * wj
+     */
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->alias('fb')->join("t_userinfo u", "fb.userid=u.id")->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 69 - 0
application/index/model/groupmodel.php

@@ -0,0 +1,69 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2021/10/7
+ * Time: 22:55
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class groupmodel extends Model
+{
+    protected $table = 't_groupinfo';
+
+    /*
+     * 20211007
+     */
+    public function insinfo($arr)
+    {
+        $this->setAttr('id', null)->isUpdate(false)->allowField(true)->save($arr);
+        return $this->id;
+    }
+    public function getinfo($where)
+    {
+        $info = $this->where($where)->find();
+        return $info;
+    }
+    /***
+     * 获取列表数据
+     * 20211012
+     * wj
+     */
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+    /***
+     * 获取列表数据 join t_groupinfo
+     * 20211012
+     * wj
+     */
+    public function getpartinlist($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->alias('g')->where($where)->join("t_groupuser gu", "gu.groupid=g.id", 'left');
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 55 - 0
application/index/model/groupusermodel.php

@@ -0,0 +1,55 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2021/10/7
+ * Time: 22:55
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class groupusermodel extends Model
+{
+    protected $table = 't_groupuser';
+
+    /*
+     * 20211007
+     */
+    public function insinfo($arr)
+    {
+        $this->setAttr('id', null)->isUpdate(false)->allowField(true)->save($arr);
+        return $this->id;
+    }
+    public function getinfo($where)
+    {
+        $info = $this->where($where)->find();
+        return $info;
+    }
+    /***
+     * 获取列表数据
+     * 20211012
+     * wj
+     */
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+}

+ 240 - 0
application/index/model/inventmodel.php

@@ -0,0 +1,240 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 08:46:31
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-30 13:41:17
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class inventmodel extends Model
+{
+    protected $table = 't_invent';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+    public function incField($where, $field, $step = 1)
+    {
+        $row = $this->where($where)->setInc($field, $step);
+        return empty($row) ? false : $row;
+    }
+    /*
+     * 20211002
+     * 根据发布者ID获取清单
+     * 应用于发布者查看本人发布的消息
+     */
+    public function sellistbyuid($uid)
+    {
+        $where_arr['createuid'] = $uid;
+        $rlist = $this->where($where_arr)->order('id', 'desc')->select();
+        $rlist = collection($rlist)->toArray();
+        return $rlist;
+
+    }
+    /**
+     * 根据条件查询
+     */
+    public function getlistjoinuser($where, $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sql = $this->alias('i')->join('t_userinfo u', 'i.createuid=u.id')->join('t_webuser w', 'i.releaseid=w.id', 'LEFT');
+        $whereUse = [];
+        if (isset($where['telno']) && !empty($where['telno'])) {
+            $whereUse['u.telno'] = ['like', '%' . $where['telno'] . '%'];
+        }
+        if (isset($where['wname']) && !empty($where['wname'])) {
+            $whereUse['u.wname'] = ['like', '%' . $where['wname'] . '%'];
+        }
+        if (isset($where['isactive']) && is_numeric($where['isactive'])) {
+            $whereUse['i.isactive'] = $where['isactive'];
+        }
+        if (isset($where['ispass']) && is_numeric($where['ispass'])) {
+            $whereUse['i.ispass'] = $where['ispass'];
+        }
+        if (isset($where['code']) && !empty($where['code'])) {
+            $whereUse['i.code'] = ['like', '%' . $where['code'] . '%'];
+        }
+        if (isset($where['worktype']) && !empty($where['worktype'])) {
+            $whereUse['i.worktype'] = $where['worktype'];
+        }
+        if (isset($where['release_user']) && !empty($where['release_user'])) {
+            if ('null' == $where['release_user']) {
+                $sql->whereNull('i.releaseid');
+            } else {
+                $whereUse['w.user_name'] = ['like', '%' . $where['release_user'] . '%'];
+            }
+        }
+        if (isset($where['createdate']) && is_array($where['createdate'])) {
+            $whereUse['createdate'] = ['between', $where['createdate']];
+        }
+        if ($field == 'count') {
+            $data = $sql->where($whereUse)->count();
+        } else {
+            $field = ['u.wname', 'u.telno', 'u.isactive', 'w.user_name release_user', 'i.*'];
+            if ($row) {
+                $data = $sql->where($whereUse)->field($field)->page($page, $size)->order($order)->find();
+            } else {
+                $data = $sql->where($whereUse)->field($field)->page($page, $size)->order($order)->group($group)->select();
+            }
+        }
+        return empty($data) ? false : $data;
+    }
+    /**
+     * 获取总数
+     * 20211117
+     * wj
+     */
+    public function getcount()
+    {
+        $count = $this->where([])->count();
+        return $count;
+    }
+    /**
+     * 获取分析数据
+     * 20211117
+     * wj
+     */
+    public function statistics()
+    {
+        $sql = "select isactive,ispass,count(*) as count from " . $this->table . " group by isactive,ispass";
+        $list = $this->query("select * from (" . $sql . ") as t");
+        return $list;
+    }
+
+    /*
+     * 20211130
+     * steelxu5
+     * 根据ID获取信息
+     */
+    public function selinfobyid($id)
+    {
+        $where_arr['id'] = $id;
+        $rec = $this->where($where_arr)->find();
+        return $rec;
+    }
+    /***
+     * 移动端根据多个条件获取列表
+     * 20211215
+     * wj
+     */
+    public function getlistbymultiplecondition($where = [], $page = 1, $size = 10, $order = "id desc")
+    {
+        $whereUse = ['isactive=1', 'ispass=1'];
+        if (!empty($where)) {
+            foreach ($where as $key => $value) {
+                if ('city' == $key) {
+                    $whereUse[] = "city like '%" . $value . "%'";
+                }
+                if ('disc' == $key) {
+                    $whereUse[] = "disc like '%" . $value . "%'";
+                }
+                if ('town' == $key) {
+                    $whereUse[] = "town like '%" . $value . "%'";
+                }
+                if ('address' == $key) {
+                    $whereUse[] = "address like '%" . $value . "%'";
+                }
+                if ('worktype' == $key) {
+                    $whereUse[] = "worktype like '%" . $value . "%'";
+                }
+                if ('lng' == $key) {
+                    $value = (double) $value;
+                    $radii = (double) $where['radii'];
+                    $whereUse[] = "ABS(gps_lng-" . $value . ")<=" . $radii;
+                }
+                if ('lat' == $key) {
+                    $value = (double) $value;
+                    $radii = (double) $where['radii'];
+                    $whereUse[] = "ABS(gps_lat-" . $value . ")<=" . $radii;
+                }
+            }
+        }
+        $whereStr = implode(' and ', $whereUse);
+        $index = ($page - 1) * $size;
+        $sql = "select * from t_invent  where " . $whereStr . " order by " . $order . " limit " . $index . ',' . $size;
+        $list = $this->query("select * from (" . $sql . ") as t");
+        return $list;
+    }
+    /**
+     * 获取一定时间内无联系数量
+     * 20211222
+     * wj
+     */
+    public function getnocalldata($min = 5, $where = [], $count = false, $page = 1, $size = 10)
+    {
+        if (empty($min) || !is_numeric($min)) {
+            $min = 5;
+        }
+        $sql = "select u.wname,u.telno,i.*,ROUND((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(i.passtime))/60,0) time
+        from t_invent as i join t_userinfo as u on i.createuid=u.id
+        where
+        i.concount<=0 and i.ispass=1 and i.isactive=1";
+        /*$sql = "select u.wname,u.telno,i.*
+        from t_invent as i join t_userinfo as u on i.createuid=u.id
+        where i.passtime>= now()-interval " . $min . " minute and i.concount<=0 and i.ispass=1 and i.isactive=1";*/
+        $whereUse = [];
+        if (!empty($where)) {
+            foreach ($where as $key => $value) {
+                if ('wname' == $key) {
+                    $whereUse[] = "u.wname like '%" . $value . "%'";
+                }
+                if ('telno' == $key) {
+                    $whereUse[] = "u.telno like '%" . $value . "%'";
+                }
+            }
+        }
+        if (!empty($whereUse)) {
+            $whereStr = implode(' and ', $whereUse);
+            $sql .= " and " . $whereStr;
+        }
+        $sql .= ' ORDER BY i.id desc';
+        if ($count) {
+            $list = $this->query("select count(*) count from (" . $sql . ") as t");
+            $count = $list[0]['count'];
+            return $count;
+        }
+        $index = ($page - 1) * $size;
+        $list = $this->query("select * from (" . $sql . ") as t limit " . $index . "," . $size);
+        return $list;
+    }
+
+}

+ 242 - 0
application/index/model/inventv1model.php

@@ -0,0 +1,242 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 08:46:31
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-15 10:19:46
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class inventv1model extends Model
+{
+    protected $table = 't_invent';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+    public function incField($where, $field, $step = 1)
+    {
+        $row = $this->where($where)->setInc($field, $step);
+        return empty($row) ? false : $row;
+    }
+    /*
+     * 20211002
+     * 根据发布者ID获取清单
+     * 应用于发布者查看本人发布的消息
+     */
+    public function sellistbyuid($uid)
+    {
+        $where_arr['createuid'] = $uid;
+        $rlist = $this->where($where_arr)->order('id', 'desc')->select();
+        $rlist = collection($rlist)->toArray();
+        return $rlist;
+
+    }
+    /**
+     * 根据条件查询
+     */
+    public function getlistjoinuser($where, $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sql = $this->alias('i')->join('t_userinfo u', 'i.createuid=u.id')->join('t_webuser w', 'i.releaseid=w.id', 'LEFT');
+        $whereUse = [];
+        if (isset($where['telno']) && !empty($where['telno'])) {
+            $whereUse['u.telno'] = ['like', '%' . $where['telno'] . '%'];
+        }
+        if (isset($where['wname']) && !empty($where['wname'])) {
+            $whereUse['u.wname'] = ['like', '%' . $where['wname'] . '%'];
+        }
+        if (isset($where['isactive']) && is_numeric($where['isactive'])) {
+            $whereUse['i.isactive'] = $where['isactive'];
+        }
+        if (isset($where['ispass']) && is_numeric($where['ispass'])) {
+            $whereUse['i.ispass'] = $where['ispass'];
+        }
+        if (isset($where['code']) && !empty($where['code'])) {
+            $whereUse['i.code'] = ['like', '%' . $where['code'] . '%'];
+        }
+        if (isset($where['worktype']) && !empty($where['worktype'])) {
+            $whereUse['i.worktype'] = $where['worktype'];
+        }
+        if (isset($where['release_user']) && !empty($where['release_user'])) {
+            if ('null' == $where['release_user']) {
+                $sql->whereNull('i.releaseid');
+            } else {
+                $whereUse['w.user_name'] = ['like', '%' . $where['release_user'] . '%'];
+            }
+        }
+        if (isset($where['createdate']) && is_array($where['createdate'])) {
+            $whereUse['createdate'] = ['between', $where['createdate']];
+        }
+        if ($field == 'count') {
+            $data = $sql->where($whereUse)->count();
+        } else {
+            $field = ['u.wname', 'u.telno', 'u.isactive', 'w.user_name release_user', 'i.*'];
+            if ($row) {
+                $data = $sql->where($whereUse)->field($field)->page($page, $size)->order($order)->find();
+            } else {
+                $data = $sql->where($whereUse)->field($field)->page($page, $size)->order($order)->group($group)->select();
+            }
+        }
+        return empty($data) ? false : $data;
+    }
+    /**
+     * 获取总数
+     * 20211117
+     * wj
+     */
+    public function getcount()
+    {
+        $count = $this->where([])->count();
+        return $count;
+    }
+    /**
+     * 获取分析数据
+     * 20211117
+     * wj
+     */
+    public function statistics()
+    {
+        $sql = "select isactive,ispass,count(*) as count from " . $this->table . " group by isactive,ispass";
+        $list = $this->query("select * from (" . $sql . ") as t");
+        return $list;
+    }
+
+    /*
+     * 20211130
+     * steelxu5
+     * 根据ID获取信息
+     */
+    public function selinfobyid($id)
+    {
+        $where_arr['id'] = $id;
+        $rec = $this->where($where_arr)->find();
+        return $rec;
+    }
+    /***
+     * 移动端根据多个条件获取列表
+     * 20211215
+     * wj
+     */
+    public function getlistbymultiplecondition($where = [], $page = 1, $size = 10, $order = "id desc")
+    {
+        //$whereUse = ['isactive=1', 'ispass=1'];
+        $whereUse = [];
+        if (!empty($where)) {
+            foreach ($where as $key => $value) {
+                if ('city' == $key) {
+                    $whereUse[] = "city like '%" . $value . "%'";
+                }
+                if ('disc' == $key) {
+                    $whereUse[] = "disc like '%" . $value . "%'";
+                }
+                if ('town' == $key) {
+                    $whereUse[] = "town like '%" . $value . "%'";
+                }
+                if ('address' == $key) {
+                    $whereUse[] = "address like '%" . $value . "%'";
+                }
+                if ('worktype' == $key) {
+                    $whereUse[] = "worktype like '%" . $value . "%'";
+                }
+                if ('lng' == $key) {
+                    $value = (double) $value;
+                    $radii = (double) $where['radii'];
+                    $whereUse[] = "ABS(gps_lng-" . $value . ")<=" . $radii;
+                }
+                if ('lat' == $key) {
+                    $value = (double) $value;
+                    $radii = (double) $where['radii'];
+                    $whereUse[] = "ABS(gps_lat-" . $value . ")<=" . $radii;
+                }
+                if ('isactive' == $key) {
+                    $whereUse[] = "isactive='" . $value . "'";
+                }
+                if ('ispass' == $key) {
+                    $whereUse[] = "ispass='" . $value . "'";
+                }
+            }
+        }
+        $whereStr = implode(' and ', $whereUse);
+        $index = ($page - 1) * $size;
+        $sql = "select * from t_invent  where " . $whereStr . " order by " . $order . " limit " . $index . ',' . $size;
+        $list = $this->query("select * from (" . $sql . ") as t");
+        return $list;
+    }
+    /**
+     * 获取一定时间内无联系数量
+     * 20211222
+     * wj
+     */
+    public function getnocalldata($min = 5, $where = [], $count = false, $page = 1, $size = 10)
+    {
+        if (empty($min) || !is_numeric($min)) {
+            $min = 5;
+        }
+        $sql = "select u.wname,u.telno,i.*
+        from t_invent as i join t_userinfo as u on i.createuid=u.id
+        where i.passtime>= now()-interval " . $min . " minute and i.concount<=0 and i.ispass=1 and i.isactive=1";
+        $whereUse = [];
+        if (!empty($where)) {
+            foreach ($where as $key => $value) {
+                if ('wname' == $key) {
+                    $whereUse[] = "i.wname like '%" . $value . "%'";
+                }
+                if ('telno' == $key) {
+                    $whereUse[] = "i.telno like '%" . $value . "%'";
+                }
+            }
+        }
+        $whereStr = implode(' and ', $whereUse);
+        if (!empty($whereStr)) {
+            $sql .= ' where ' . $whereStr;
+        }
+        if ($count) {
+            $list = $this->query("select count(*) count from (" . $sql . ") as t");
+            $count = $list[0]['count'];
+            return $count;
+        }
+        $index = ($page - 1) * $size;
+        $list = $this->query("select * from (" . $sql . ") as t limit " . $index . "," . $size);
+        return $list;
+    }
+
+}

+ 148 - 0
application/index/model/jobhuntingmodel.php

@@ -0,0 +1,148 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 08:46:31
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-20 16:39:49
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class jobhuntingmodel extends Model
+{
+    protected $table = 't_jobhunting';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+    public function incField($where, $field, $step = 1)
+    {
+        $row = $this->where($where)->setInc($field, $step);
+        return empty($row) ? false : $row;
+    }
+    /*
+     * 20211002
+     * 根据发布者ID获取清单
+     * 应用于发布者查看本人发布的消息
+     */
+    public function sellistbyuid($uid)
+    {
+        $where_arr['createuid'] = $uid;
+        $rlist = $this->where($where_arr)->order('id', 'desc')->select();
+        $rlist = collection($rlist)->toArray();
+        return $rlist;
+
+    }
+    /**
+     * 获取总数
+     * 20211117
+     * wj
+     */
+    public function getcount()
+    {
+        $count = $this->where([])->count();
+        return $count;
+    }
+    /**
+     * 获取分析数据
+     * 20211117
+     * wj
+     */
+    public function statistics()
+    {
+        $sql = "select isactive,ispass,count(*) as count from " . $this->table . " group by isactive,ispass";
+        $list = $this->query("select * from (" . $sql . ") as t");
+        return $list;
+    }
+
+    /**
+     * 根据条件查询
+     * 未加组关联 20211119 wj
+     */
+    public function getlistjoinuser($where, $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sql = $this->alias('i')->join('t_userinfo u', 'i.createuid=u.id');
+        $whereUse = [];
+        if (isset($where['wname']) && !empty($where['wname'])) {
+            $whereUse['u.wname'] = ['like', '%' . $where['wname'] . '%'];
+        }
+        if (isset($where['telno']) && !empty($where['telno'])) {
+            $whereUse['u.telno'] = ['like', '%' . $where['telno'] . '%'];
+        }
+        if (isset($where['isactive']) && is_numeric($where['isactive'])) {
+            $whereUse['i.isactive'] = $where['isactive'];
+        }
+        if (isset($where['userstyle']) && is_numeric($where['userstyle'])) {
+            $whereUse['i.userstyle'] = $where['userstyle'];
+        }
+        if (isset($where['ispass']) && is_numeric($where['ispass'])) {
+            $whereUse['i.ispass'] = $where['ispass'];
+        }
+        if (isset($where['worktype']) && !empty($where['worktype'])) {
+            $whereUse['i.worktype'] = $where['worktype'];
+        }
+        if (isset($where['createdate']) && is_array($where['createdate'])) {
+            $whereUse['createdate'] = ['between', $where['createdate']];
+        }
+        if ($field == 'count') {
+            $data = $sql->where($whereUse)->count();
+        } else {
+            $field = ['u.wname', 'u.telno', 'u.isactive', 'i.*'];
+            if ($row) {
+                $data = $sql->where($whereUse)->field($field)->page($page, $size)->order($order)->find();
+            } else {
+                $data = $sql->where($whereUse)->field($field)->page($page, $size)->order($order)->group($group)->select();
+            }
+        }
+        return empty($data) ? false : $data;
+    }
+
+    /*
+     * 20211130
+     * steelxu
+     */
+    public function selinfobyid($id)
+    {
+        $where_arr['id'] = $id;
+        $rec = $this->where($where_arr)->find();
+        return $rec;
+    }
+}

+ 19 - 0
application/index/model/logmodel.php

@@ -0,0 +1,19 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2020/1/6
+ * Time: 12:36
+ */
+namespace app\index\model;
+use think\Model;
+class logmodel extends Model{
+    protected $table='t_userlog';
+
+    public function savelog($loginfo){
+        $r_id=$this->allowField(true)->save($loginfo);
+        return $r_id;
+    }
+
+
+}

+ 92 - 0
application/index/model/memodel.php

@@ -0,0 +1,92 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2019/12/7
+ * Time: 11:11
+ */
+
+namespace app\index\model;
+use think\Model;
+
+
+class memodel extends Model{
+  // private $me_tabel;
+    protected $table = 't_wxuser';
+
+//   public function initialize(){
+//       //echo "in";
+//       $this->me_tabel=model("tEquipmentMe");
+//       echo 'init';
+//   }
+
+    public function saveme($userinfo){
+        $r_id=$this->allowField(true)->save($userinfo);
+        return $r_id;
+    }
+
+    public function getinfobyopenid($openid){
+        $record=$this->where("open_id",$openid)->find();
+        return $record;
+    }
+
+    public function updatetelbyoopenid($openid,$tel){
+        $r_id=$this->where("open_id",$openid)->update(['tel'=>$tel]);
+        return $r_id;
+    }
+
+    public function insopenid($insinfo){
+
+        $r_id=$this->isUpdate(false)->save($insinfo);
+
+        return $this->id;
+    }
+    /*
+     * 20200226
+     * steelxu5
+     * 增加了根据openid更新信息的
+     */
+
+    public function updateinfobyopenid($openid,$arr){
+        $r_id=$this->where("open_id",$openid)->update($arr);
+        return $r_id;
+    }
+
+    /*
+     * 20200401
+     * 根据ID获取呢称
+     */
+
+    public function selnamebyid($id){
+        $where_arr['id']=$id;
+        $cinfo=$this->where($where_arr)->find();
+        return $cinfo;
+    }
+
+    /*
+     * 20200927
+     * 根据UNIONID获取信息,openid,uid
+     */
+    public function selinfobyunionid($unionid){
+        $where_arr['union_id']=$unionid;
+        $cinfo=$this->where($where_arr)->field('id,open_id')->find();
+        return $cinfo;
+    }
+    /*
+     * 20200927
+     * 根据openid 更新unionid
+     */
+    public function updunionidbyopenid($openid,$unionid){
+        $this->where("open_id",$openid)->update(['union_id'=>$unionid]);
+    }
+
+    /*
+     * 20200928
+     * 根据unionid 获取openid
+     */
+    public function selopenidbyunionid($unionid){
+        $rec=$this->where("union_id",$unionid)->field('id,open_id')->find();
+        return $rec['open_id'];
+    }
+
+} 

+ 61 - 0
application/index/model/partnergainmodel.php

@@ -0,0 +1,61 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-18 11:25:15
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class partnergainmodel extends Model
+{
+
+    protected $table = 't_partnergain';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 72 - 0
application/index/model/partnermembermodel.php

@@ -0,0 +1,72 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-18 11:25:40
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class partnermembermodel extends Model
+{
+
+    protected $table = 't_partnermember';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+
+    /*
+     * 20220113
+     * steelxu5
+     * 汇总某人拉来的人数,不考虑实名
+     */
+    public function selcountbypartnerid($partnerid){
+        $strsql="select count(memberuserid) as membercount from t_partnermember where partneruserid=".$partnerid;
+        $res=$this->query($strsql);
+        return $res;
+    }
+}

+ 61 - 0
application/index/model/partnermodel.php

@@ -0,0 +1,61 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-18 11:24:56
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class partnermodel extends Model
+{
+
+    protected $table = 't_partner';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 62 - 0
application/index/model/partybusinessmodel.php

@@ -0,0 +1,62 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-29 16:15:16
+ */
+
+namespace app\index\model;
+
+use think\Model;
+
+class partybusinessmodel extends Model
+{
+
+    protected $table = 't_partybusiness';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 114 - 0
application/index/model/payordermodel.php

@@ -0,0 +1,114 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2021/6/25
+ * Time: 15:27
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class payordermodel extends Model
+{
+    protected $table = 't_payorder';
+
+    /*
+     * 20210625
+     */
+    public function insinfo($arr)
+    {
+        $this->setAttr('id', null)->isUpdate(false)->allowField(true)->save($arr);
+        return $this->id;
+    }
+
+    /*
+     * 20210625
+     */
+    public function updpaytimebypreid($preid)
+    {
+        $where_arr['prepay_id'] = $preid;
+        $where_arr['orderstatus'] = 0;
+        $update_arr['ispay'] = 1;
+        $update_arr['orderstatus'] = 1;
+        $update_arr['paytime'] = date('Y-m-d H:i:s');
+        $this->where($where_arr)->update($update_arr);
+    }
+
+    /*
+     * 20210627
+     */
+    public function updorederstatusbyorderno($orderno, $openid, $updarr)
+    {
+        $where_arr['outorderno'] = $orderno;
+        $where_arr['openid'] = $openid;
+        $where_arr['orderstatus'] = 0;
+        $rcount = $this->where($where_arr)->update($updarr);
+        return $rcount;
+    }
+
+    /*
+     * 20210814
+     */
+    public function selinfobyorder($orderno)
+    {
+        $where_arr['outorderno'] = $orderno;
+        $rec = $this->where($where_arr)->find();
+        return $rec;
+    }
+
+    /**
+     * 根据订单id改订单信息
+     * 20211108
+     * wj
+     */
+    public function updorederstatusbyid($id, $updarr)
+    {
+        $where_arr['id'] = $id;
+        $where_arr['orderstatus'] = 0;
+        $rcount = $this->where($where_arr)->update($updarr);
+        return $rcount;
+    }
+    /**
+     * 获取订单总量
+     * 202112228
+     * wj
+     */
+    public function getcount()
+    {
+        $count = $this->where([])->count();
+        return $count;
+    }
+    /**
+     * 获取分析数据
+     * 20211117
+     * wj
+     */
+    public function statistics()
+    {
+        $sql = "select ispay,count(*) as count from " . $this->table . " group by ispay";
+        $list = $this->query("select * from (" . $sql . ") as t");
+        return $list;
+    }
+
+    /*
+     * 20211228
+     * wj
+     */
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->alias('po')->join("t_userinfo u", "po.wid=u.id")->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+
+}

+ 61 - 0
application/index/model/permissionmodel.php

@@ -0,0 +1,61 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-29 16:15:05
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class permissionmodel extends Model
+{
+
+    protected $table = 't_permission';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 61 - 0
application/index/model/permissionusermodel.php

@@ -0,0 +1,61 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-29 16:15:56
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class permissionusermodel extends Model
+{
+
+    protected $table = 't_permissionuser';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 61 - 0
application/index/model/rolesmodel.php

@@ -0,0 +1,61 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-29 16:15:16
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class rolesmodel extends Model
+{
+
+    protected $table = 't_roles';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 68 - 0
application/index/model/roleusermodel.php

@@ -0,0 +1,68 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-09 17:42:32
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class roleusermodel extends Model
+{
+
+    protected $table = 't_roleuser';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+
+    public function getinfoforuser($uid)
+    {
+        $sql = "select r.* from t_roleuser as ru join t_roles as r on r.id = ru.rid where ru.uid='" . $uid . "' and r.is_active=1";
+        $result = $this->query($sql);
+        return $result;
+    }
+}

+ 61 - 0
application/index/model/safenotemodel.php

@@ -0,0 +1,61 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-29 16:15:16
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class safenotemodel extends Model
+{
+
+    protected $table = 't_safenote';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 73 - 0
application/index/model/scorebusinessmodel.php

@@ -0,0 +1,73 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-31 17:46:42
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class scorebusinessmodel extends Model
+{
+
+    protected $table = 't_scorebusiness';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+
+    public function getinfobyweight($where)
+    {
+        $sql = "select * from " . $this->table . "  where typeid='" . $where['typeid'] . "' and type='" . $where['type'] . "' and isactive=1 and
+        (
+            (starttime<='" . $where['time'] . "' and endtime>='" . $where['time'] . "') or
+            (starttime is null or endtime is null)
+        )
+        order by weight desc limit 0,1";
+        $data = $this->query("select * from (" . $sql . ") as t");
+        return empty($data) ? false : $data[0];
+    }
+}

+ 61 - 0
application/index/model/scorebusinessrecordmodel.php

@@ -0,0 +1,61 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-29 16:15:16
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class scorebusinessrecordmodel extends Model
+{
+
+    protected $table = 't_scorebusinessrecord';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 61 - 0
application/index/model/scoreordermodel.php

@@ -0,0 +1,61 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-29 16:15:16
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class scoreordermodel extends Model
+{
+
+    protected $table = 't_scoreorder';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 80 - 0
application/index/model/signinmodel.php

@@ -0,0 +1,80 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-29 16:15:16
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class signinmodel extends Model
+{
+
+    protected $table = 't_signin';
+
+    public function insertData($data)
+    {
+        $insertData = [];
+        $fields = $this->gettablefields();
+        foreach ($fields as $key => $value) {
+            $field = $value['Field'];
+            if (isset($data[$field])) {
+                $insertData[$field] = $data[$field];
+            }
+        }
+        $id = $this->insertGetId($insertData);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+    /***
+     * 获取全部字段名
+     * 20211103
+     * wj
+     */
+    public function gettablefields()
+    {
+        $sql = "desc " . $this->table;
+        $fiekds = $this->query($sql);
+        return $fiekds;
+    }
+}

+ 69 - 0
application/index/model/smscoderecordmodel.php

@@ -0,0 +1,69 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-03 16:25:59
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-09-03 17:50:56
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class smscoderecordmodel extends Model
+{
+    protected $table = 't_smscoderecord';
+    /***
+     * 20210903
+     * wj
+     * 添加验证码
+     */
+    public function insinfo($arr)
+    {
+        $this->setAttr('id', null)->isUpdate(false)->allowField(true)->save($arr);
+        return $this->id;
+    }
+    /***
+     * 20210903
+     * wj
+     * 根据条件获取数据
+     */
+    public function getinfo($where, $row = true)
+    {
+        $query = $this->where($where);
+        if ($row) {
+            $info = $query->find();
+        } else {
+            $info = $query->select();
+        }
+        return $info;
+    }
+    /***
+     * 20210903
+     * wj
+     * 根据id条件获取数据
+     */
+    public function getinfobyid($id)
+    {
+        $where['id'] = $id;
+        $info = $this->where($where)->find();
+        return $info;
+    }
+
+    /***
+     * 20210903
+     * wj
+     * 删除已用验证码
+     */
+    public function deletebyid($id)
+    {
+        $where['id'] = $id;
+        $result = $this->where($where)->delete();
+        return $result;
+    }
+    public function getlastinfo($where)
+    {
+        $info = $this->where($where)->limit(1)->order('id', 'desc')->find();
+        return $info;
+    }
+
+}

+ 266 - 0
application/index/model/statisticssqlmodel.php

@@ -0,0 +1,266 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2021/10/7
+ * Time: 22:55
+ */
+namespace app\index\model;
+
+use app\index\model\userconnectrecorddaymodel;
+use think\Model;
+
+class statisticssqlmodel extends Model
+{
+    /**
+     * 获取电话统计数据
+     * 20211206
+     * wj
+     */
+    public function getTelnoConnectNum()
+    {
+        $sqlhavetime = "select DATE_FORMAT(calltime,'%Y-%m-%d %H:00:00') date,count(*) count from t_userconnectrecord
+        where calltime>=DATE_SUB(DATE_FORMAT(NOW(),'%Y-%m-%d 00:00:00'),interval 1 day)
+        and calltime<DATE_ADD(DATE_FORMAT(NOW(),'%Y-%m-%d 00:00:00'),interval 1 day)
+        GROUP BY DATE_FORMAT(calltime,'%Y-%m-%d  %H:00:00')
+        ORDER BY date desc";
+        //暂时不用
+        //$timelist = $this->query("select * from (" . $sqlhavetime . ") as t");
+        $sqlcount = "select DATE_FORMAT(calltime,'%Y-%m-%d') date,count(*) count from t_userconnectrecord
+        where calltime>=DATE_SUB(DATE_FORMAT(NOW(),'%Y-%m-%d 00:00:00'),interval 1 day)
+        and calltime<DATE_ADD(DATE_FORMAT(NOW(),'%Y-%m-%d 00:00:00'),interval 1 day)
+        GROUP BY DATE_FORMAT(calltime,'%Y-%m-%d')
+        ORDER BY date desc";
+        $countlist = $this->query("select * from (" . $sqlcount . ") as t");
+        $data = ['countlist' => $countlist];
+        return $data;
+    }
+    /**
+     * 获取无代发数据
+     * 20211206
+     * wj
+     */
+    public function getinventcount1()
+    {
+        $sql = "select DATE_FORMAT(createdate,'%Y-%m-%d') date,isactive,ispass,count(*) count from t_invent
+        where createdate>=DATE_SUB(DATE_FORMAT(NOW(),'%Y-%m-%d 00:00:00'),interval 1 day)
+        and createdate<DATE_ADD(DATE_FORMAT(NOW(),'%Y-%m-%d 00:00:00'),interval 1 day)
+        and releaseid is NULL
+        GROUP BY DATE_FORMAT(createdate,'%Y-%m-%d'),isactive,ispass";
+        $list = $this->query("select * from (" . $sql . ") as t");
+        return $list;
+    }
+
+    /***
+     * 各招工电话联系 联系数量 列表
+     * 20211206
+     * wj
+     */
+    public function getinventitemtelnoconnectlist($count = false, $page = 1, $size = 10)
+    {
+        $sql = "select uc.sourceid,i.code,u.telno,count(*) count from t_userconnectrecord as uc
+        join t_invent as i on i.id=uc.sourceid
+        join t_userinfo as u on u.id=i.createuid
+        where uc.sourcetype=1
+        GROUP BY uc.sourceid
+        ORDER BY count desc";
+        if (!$count) {
+            $index = ($page - 1) * $size;
+            $sql .= " limit " . $index . "," . $size;
+        }
+        if ($count) {
+            $list = $this->query("select count(*) count from (" . $sql . ") as t");
+        } else {
+            $list = $this->query("select * from (" . $sql . ") as t");
+        }
+        return $list;
+    }
+    /***
+     * 各招工电话联系 联系数量 列表 今日
+     * 20211220
+     * wj
+     */
+    public function getinventitemtelnoconnectbydaylist($count = false, $page = 1, $size = 10)
+    {
+        $m_ucrd = new userconnectrecorddaymodel();
+        $day = date("Ymd");
+        $isExist = $m_ucrd->isexist($day);
+        if (!$isExist) {
+            return false;
+        }
+        $tablename = 't_userconnectrecord_' . $value;
+        $sql = "select uc.sourceid,i.code,u.telno,count(*) count from " . $tablename . " as uc
+        join t_invent as i on i.id=uc.sourceid
+        join t_userinfo as u on u.id=i.createuid
+        where uc.sourcetype=1
+        GROUP BY uc.sourceid
+        ORDER BY count desc";
+        if (!$count) {
+            $index = ($page - 1) * $size;
+            $sql .= " limit " . $index . "," . $size;
+        }
+        if ($count) {
+            $list = $this->query("select count(*) count from (" . $sql . ") as t");
+        } else {
+            $list = $this->query("select * from (" . $sql . ") as t");
+        }
+        return $list;
+    }
+    /***
+     * 近两日 打电话数量及人数
+     * 20211220
+     * wj
+     */
+    public function getinventcount2()
+    {
+        $m_ucrd = new userconnectrecorddaymodel();
+        $day = [
+            date("Ymd"),
+            date("Ymd", strtotime("-1 day")),
+        ];
+        $list = [];
+        foreach ($day as $key => $value) {
+            $valueDay = date('Y-m-d', strtotime($value));
+            $isExist = $m_ucrd->isexist($value);
+            if (!$isExist) {
+                $list[] = ['date' => $valueDay, 'count_suid' => 0, 'total' => 0];
+                continue;
+            }
+            $tablename = 't_userconnectrecord_' . $value;
+            $sql = "select count(senduserid) count_suid,sum(count) total from (
+                select senduserid,count(*) count from " . $tablename . " GROUP BY senduserid
+                ) as t";
+            $data = $this->query($sql);
+            $item = $data[0];
+            $item['count_suid'] = empty($item['count_suid']) ? 0 : $item['count_suid'];
+            $item['total'] = empty($item['total']) ? 0 : $item['total'];
+            $item['date'] = $valueDay;
+            $list[] = $item;
+        }
+        return $list;
+    }
+
+    /***
+     * 各招工电话联系 间隔时间 列表
+     * 20211206
+     * wj
+     */
+    public function getinventitemtelnointervallist($count = false, $page = 1, $size = 10)
+    {
+        $sql = "select * from (
+            select ucid,sourceid,code,telno,time
+            from (
+               select uc.id ucid,uc.sourceid,i.code,i.createdate,uc.calltime,ROUND((UNIX_TIMESTAMP(uc.calltime)-UNIX_TIMESTAMP(i.passtime))/60,0) time,u.telno
+               from t_userconnectrecord as uc
+               join t_invent as i on i.id=uc.sourceid
+               join t_userinfo as u on u.id=i.createuid
+                 where passtime is not null
+               ORDER BY time asc
+            ) as tab
+            GROUP BY sourceid
+            ) as tab ORDER BY time asc";
+        if (!$count) {
+            $index = ($page - 1) * $size;
+            $sql .= " limit " . $index . "," . $size;
+        }
+        if ($count) {
+            $list = $this->query("select count(*) count from (" . $sql . ") as t");
+        } else {
+            $list = $this->query("select * from (" . $sql . ") as t");
+        }
+        return $list;
+    }
+    /***
+     * 各招工电话联系 间隔时间 列表 今日  平均值
+     * 20211220
+     * wj
+     */
+    public function getinventitemtelnoavgbydaylist()
+    {
+        $m_ucrd = new userconnectrecorddaymodel();
+        $day = [
+            date("Ymd"),
+            date("Ymd", strtotime("-1 day")),
+        ];
+        $list = [];
+        foreach ($day as $key => $value) {
+            $valueDay = date('Y-m-d', strtotime($value));
+            $isExist = $m_ucrd->isexist($value);
+            if (!$isExist) {
+                $list[] = ['avg_time' => 0, 'date' => $valueDay];
+                continue;
+            }
+            $tablename = 't_userconnectrecord_' . $value;
+            $sql = "select avg(time) avg_time from (
+                select ucid,sourceid,code,telno,time
+                from (
+                    select uc.id ucid,uc.sourceid,i.code,i.createdate,uc.calltime,ROUND((UNIX_TIMESTAMP(uc.calltime)-UNIX_TIMESTAMP(i.passtime))/60,0) time,u.telno
+                    from " . $tablename . " as uc
+                    join t_invent as i on i.id=uc.sourceid
+                    join t_userinfo as u on u.id=i.createuid
+                        where passtime is not null and passtime like '%" . $valueDay . "%'
+                    ORDER BY time asc
+                ) as tab
+                GROUP BY sourceid
+                ) as tab";
+            $data = $this->query($sql);
+            if (empty($data)) {
+                $item['avg_time'] = 0;
+            } else {
+                $item['avg_time'] = empty($data[0]['avg_time']) ? 0 : $data[0]['avg_time'];
+            }
+            $item['date'] = $valueDay;
+            $list[] = $item;
+        }
+        return $list;
+    }
+
+    /***
+     * 招工 已招满
+     * 20211206
+     * wj
+     */
+    public function getinventfull()
+    {
+        $sql = "select count(*) count from t_evaluate where evaluatememo like '%已招满%'";
+        $list = $this->query("select * from (" . $sql . ") as t");
+        return $list;
+    }
+
+    /***
+     * 招工没接电话
+     * 20211206
+     * wj
+     */
+    public function getinventnotanswer()
+    {
+        $sql = "select count(*) count from t_evaluate where evaluatememo like '%没接电话%'";
+        $list = $this->query("select * from (" . $sql . ") as t");
+        return $list;
+    }
+
+    /***
+     * 统计用户积分
+     * 20211206
+     * wj
+     */
+    public function getuseraccount($count = false, $page = 1, $size = 10)
+    {
+        $sql = "select u.id,u.wname,goldscore,siliverscore,goldscore+siliverscore sumscore
+        from t_useraccount as ua
+        join (
+           select senduserid from t_userconnectrecord GROUP BY senduserid
+        ) as uc on uc.senduserid = ua.userid
+        join t_userinfo as u on u.id = ua.userid ORDER BY goldscore,siliverscore";
+        if (!$count) {
+            $index = ($page - 1) * $size;
+            $sql .= " limit " . $index . "," . $size;
+        }
+        if ($count) {
+            $list = $this->query("select count(*) count from (" . $sql . ") as t");
+        } else {
+            $list = $this->query("select * from (" . $sql . ") as t");
+        }
+        return $list;
+    }
+}

+ 61 - 0
application/index/model/trainmodel.php

@@ -0,0 +1,61 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-24 13:54:57
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class trainmodel extends Model
+{
+
+    protected $table = 't_train';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 61 - 0
application/index/model/trainsignusermodel.php

@@ -0,0 +1,61 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-24 15:25:12
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class trainsignusermodel extends Model
+{
+
+    protected $table = 't_trainsignuser';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 77 - 0
application/index/model/useraccountaddrecordmodel.php

@@ -0,0 +1,77 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 08:39:30
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-05 14:22:09
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class useraccountaddrecordmodel extends Model
+{
+    protected $table = 't_useraccountaddrecord';
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+    public function getaddrecordlistforreduce($userid, $enddate, $scoretype = 0)
+    {
+        $tablesql = "select * from t_useraccountaddrecord where userid='" . $userid . "' and activescore>0 and (enddate is null or enddate <= '" . $enddate . "')";
+        if ($scoretype > 0) {
+            $tablesql .= " scoretype='" . $scoretype . "'";
+        }
+        $tablesql .= " order by scoretype desc,id asc";
+        $sql = "select * from (" . $tablesql . ") as tab";
+        $list = $this->query($sql);
+        return $list;
+    }
+    /*
+     * 2022-01-03
+     * steelxu
+     * 获取指定用户某一天被赠送的积分
+     */
+    public function seladdlistbyuid2date($uid,$date){
+        $strsql="select * from t_useraccountaddrecord where scoretype=2 and userid=".$uid."  and createdate >'".$date."' ";
+        $list=$this->query($strsql);
+        $list=collection($list)->toArray();
+        return $list;
+    }
+}

+ 55 - 0
application/index/model/useraccountmodel.php

@@ -0,0 +1,55 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 08:39:30
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-09-27 10:40:35
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class useraccountmodel extends Model
+{
+    protected $table = 't_useraccount';
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 163 - 0
application/index/model/useraccountuserrecordmodel.php

@@ -0,0 +1,163 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 08:39:30
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-29 16:39:24
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class useraccountuserrecordmodel extends Model
+{
+    protected $table = 't_useraccountuserrecord';
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    /***
+     * 校验数据是否可添加
+     * 20211215
+     * wj
+     * 20211216 废弃
+     */
+    /*public function checkDataForInsert($arr)
+    {
+        $where = [
+            'userid' => $arr['userid'],
+            'usetime' => ['like', '%' . date('Y-m-d') . '%'],
+        ];
+        $row = $this->where($where)->count();
+        if ($row > 0) {
+            return backarr(0, "数据已存在");
+        }
+        return backarr(1, "数据可新增");
+    }*/
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+
+    /***
+     * 获取用户消费的积分数 银积分 通过类型
+     * type 1 昨天 2今天
+     * wj
+     * 20211130
+     */
+    public function getsumscorebytype($type, $minsocre = 5, $count = false, $page = 1, $size = 10, $order = "id desc")
+    {
+        $field = 'u.id,u.wname,u.telno,sum(us.usescore) as sum, sum(us.usescore)-' . $minsocre . ' as givescore,tab2.givesum';
+        $sql = "select " . $field . "
+        from t_useraccountuserrecord as us
+        join t_userinfo as u on us.userid=u.id ";
+        $sql2 = "select userid,sum(addscore) as givesum from t_useraccountaddrecord
+        where sourcetype=2 and actiontype=5 and createdate>=DATE_FORMAT(NOW(),'%Y-%m-%d 00:00:00')
+        GROUP BY userid";
+        $sql .= " left join (" . $sql2 . ") as tab2 on tab2.userid=us.userid where ";
+        $date = '';
+        switch ($type) {
+            case 1:
+                //昨天
+                $date = "us.usetime >=DATE_SUB(DATE_FORMAT(NOW(),'%Y-%m-%d 00:00:00'),interval 1 day) and us.usetime <DATE_FORMAT(NOW(),'%Y-%m-%d 00:00:00')";
+                break;
+            case 2:
+                //今天
+                $date = "us.usetime >=DATE_FORMAT(NOW(),'%Y-%m-%d 00:00:00')";
+                break;
+        }
+        if (empty($date)) {
+            return false;
+        }
+        $sql .= $date;
+        $sql .= " group by us.userid HAVING sum(us.usescore)>=" . $minsocre;
+        if ($count) {
+            $sql = "select count(*) as count from ( " . $sql . " ) as tab";
+        } else {
+            $index = ($page - 1) * $size;
+            $sql = "select * from ( " . $sql . " ) as tab order by " . $order . " limit " . $index . "," . $size;
+        }
+        $data = $this->query($sql);
+        if ($count) {
+            $data = $data[0]['count'];
+        }
+        return $data;
+    }
+
+    /***
+     * 获取用户消费的积分数 银积分 通过查询
+     * time 数组
+     * wj
+     * 20211207
+     */
+    public function getsumscorebywhere($where, $minsocre = 5, $count = false, $page = 1, $size = 10, $order = "id desc")
+    {
+        $field = 'u.id,u.wname,u.telno,sum(us.usescore) as sum, sum(us.usescore)-' . $minsocre . ' as givescore,tab2.givesum,tab3.sumscore';
+        $sql = "select " . $field . "
+        from t_useraccountuserrecord as us
+        join t_userinfo as u on us.userid=u.id ";
+        $sql2 = "select userid,sum(addscore) as givesum from t_useraccountaddrecord
+        where sourcetype=2 and actiontype=5 and createdate>=DATE_FORMAT(NOW(),'%Y-%m-%d 00:00:00')
+        GROUP BY userid";
+        $sql3 = "select  userid,goldscore+siliverscore as sumscore from t_useraccount";
+        $sql .= " left join (" . $sql2 . ") as tab2 on tab2.userid=us.userid left join (" . $sql3 . ") as tab3 on tab3.userid=us.userid ";
+        $useWhere = [];
+        if (isset($where['time']) && is_array($where['time'])) {
+            $useWhere[] = "us.usetime >=from_unixtime(unix_timestamp('" . $where['time'][0] . "'), '%Y-%m-%d %H:%i:%s') and us.usetime < from_unixtime(unix_timestamp('" . $where['time'][1] . "'), '%Y-%m-%d %H:%i:%s') ";
+        }
+        if (isset($where['wname']) && !empty($where['wname']) && is_string($where['wname'])) {
+            $useWhere[] = "u.wname like '%" . $where['wname'] . "%'";
+        }
+        if (isset($where['telno']) && !empty($where['telno']) && is_string($where['telno'])) {
+            $useWhere[] = "u.telno like '%" . $where['telno'] . "%'";
+        }
+        if (!empty($useWhere)) {
+            $sql .= 'where ' . implode(' and ', $useWhere);
+        }
+        $sql .= " group by us.userid HAVING sum(us.usescore)>=" . $minsocre;
+        if ($count) {
+            $sql = "select count(*) as count from ( " . $sql . " ) as tab";
+        } else {
+            $index = ($page - 1) * $size;
+            $sql = "select * from ( " . $sql . " ) as tab order by " . $order . " limit " . $index . "," . $size;
+        }
+        $data = $this->query($sql);
+        if ($count) {
+            $data = $data[0]['count'];
+        }
+        return $data;
+    }
+}

+ 24 - 0
application/index/model/useractionrecordmodel.php

@@ -0,0 +1,24 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-28 11:13:58
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-09-28 13:55:15
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class useractionrecordmodel extends Model
+{
+    protected $table = 't_useractionrecord';
+
+    public function insinfo($arr)
+    {
+        if (!isset($arr['record_time']) || empty($arr['record_time'])) {
+            $arr['record_time'] = date("Y-m-d H:i:s");
+        }
+        $id = $this->insertGetId($arr);
+        return $id;
+    }
+}

+ 72 - 0
application/index/model/userapplylogmodel.php

@@ -0,0 +1,72 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-29 16:15:16
+ */
+namespace app\index\model;
+
+use think\Db;
+use think\Model;
+
+class userapplylogmodel extends Model
+{
+
+    protected $table = 't_userapplylog';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+    public function newxuuser($info)
+    {
+        $id = Db::table('t_wxuser')->insertGetId($info);
+        return $id;
+    }
+    public function getxuuser($where)
+    {
+        $info = Db::table('t_wxuser')->where($where)->find();
+        return $info;
+    }
+}

+ 226 - 0
application/index/model/userconnectrecorddaymodel.php

@@ -0,0 +1,226 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-28 11:13:58
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-24 16:49:03
+ */
+namespace app\index\model;
+
+use think\Config;
+use think\Db;
+use think\Log;
+use think\Model;
+
+class userconnectrecorddaymodel
+{
+    protected $tableBase = "t_userconnectrecord";
+    protected $db;
+    public $isCreateFirst; //是否第一次创建
+    public function __construct()
+    {
+        $connection = Config::get('database');
+        $this->db = Db::connect($connection);
+        $this->table = $this->tableBase . "_" . date("Ymd");
+        $this->createTableProcess();
+    }
+    private function createTableProcess()
+    {
+        $isHasTable = $this->hasTable();
+        if (!$isHasTable) {
+            $this->createTable();
+        } else {
+            $this->isCreateFirst = false;
+        }
+    }
+    /**
+     * 构造校验表是否存在
+     * 20212116
+     * wj
+     * */
+    private function hasTable()
+    {
+        $sessionTable = session($this->tableBase, '', 'submeter');
+        $isCheck = false;
+        if ($sessionTable) {
+            if (date("Ymd") != substr($sessionTable, mb_strlen($sessionTable), -8)) {
+                $isCheck = true;
+            }
+        } else {
+            $isCheck = true;
+        }
+        if (!$isCheck) {
+            return true;
+        }
+        session(null, 'submeter');
+        $sql = "show Table STATUS where Name='" . $this->table . "'";
+        $data = $this->db->query($sql);
+        $count = count($data);
+        if ($count <= 0) {
+            return false;
+        }
+        session($this->tableBase, $this->table, 'submeter');
+        return true;
+    }
+    private function createTable()
+    {
+        $sql = "show create table " . $this->tableBase;
+        $data = $this->db->query($sql);
+        $createData = $data[0]['Create Table'];
+        $createData = str_replace("`" . $this->tableBase . "`", "`" . $this->table . "`", $createData);
+        $this->db->query($createData);
+        log::info($this->table . " create");
+        session($this->tableBase, $this->table, 'submeter');
+        $this->isCreateFirst = true;
+    }
+    /***
+     * 设置表名
+     * 20211217
+     * wj
+     */
+    public function setTableName($daystr)
+    {
+        if (empty($daystr) || !is_string($daystr)) {
+            return false;
+        }
+        $isUse = false;
+        if (isDate($daystr, 'Ymd')) {
+            $isUse = true;
+        }
+        if (!$isUse) {
+            return false;
+        }
+        $tableName = $this->tableBase . "_" . $daystr;
+        $this->table = $tableName;
+        session($this->tableBase, $this->table, 'submeter');
+        log::info($this->table . " use");
+        return true;
+    }
+    /***
+     * 判断表是否已存在
+     * 20211217
+     * wj
+     */
+    public function isexist($daystr)
+    {
+        if (!isDate($daystr, 'Ymd')) {
+            return false;
+        }
+        $tableName = $this->tableBase . "_" . $daystr;
+        $sql = "show Table STATUS where Name='" . $tableName . "'";
+        $data = $this->db->query($sql);
+        $count = count($data);
+        if ($count <= 0) {
+            return false;
+        }
+        return true;
+    }
+    /***
+     * 插入数据
+     * 20211217
+     * wj
+     */
+    public function insinfo($arr)
+    {
+        log::info($this->table . " insert");
+        if (!isset($arr['calltime']) || empty($arr['calltime'])) {
+            $arr['calltime'] = date("Y-m-d H:i:s");
+        }
+        $id = $this->db->name($this->table)->insertGetId($arr);
+        return $id;
+    }
+    /*
+     * 202112017
+     * wj
+     * 获得联系电话列表
+     */
+    public function getconnectlist($where, $count = false, $page = 1, $size = 10)
+    {
+        $sql = "select * from (
+            select uc.id,uc.senduserid,us.wname as swname,us.id as sid,us.telno as stelno,uc.reciveruserid,ur.id as rid,ur.wname as rwname,ur.telno as rtelno,i.code,i.id as iid,i.worktype,uc.calltime
+            from " . $this->table . " as uc
+            join t_invent as i on uc.sourceid=i.id
+            join t_userinfo as us on uc.senduserid=us.id
+            join t_userinfo as ur on uc.reciveruserid=ur.id
+            ORDER BY uc.calltime desc)
+            as tab ";
+        $tabsql = "select * from (" . $sql . ") as tab";
+        $usewhere = [];
+        //打电话人
+        if (isset($where['swname']) && !empty($where['swname']) && is_string($where['swname'])) {
+            $usewhere[] = "swname like '%" . $where['swname'] . "%'";
+        }
+        //拨打电话
+        if (isset($where['stelno']) && !empty($where['stelno']) && is_string($where['stelno'])) {
+            $usewhere[] = "stelno like '%" . $where['stelno'] . "%'";
+        }
+        //被联系人
+        if (isset($where['rwname']) && !empty($where['rwname']) && is_string($where['rwname'])) {
+            $usewhere[] = "rwname like '%" . $where['rwname'] . "%'";
+        }
+        //被联系电话
+        if (isset($where['rtelno']) && !empty($where['rtelno']) && is_string($where['rtelno'])) {
+            $usewhere[] = "rtelno like '%" . $where['rtelno'] . "%'";
+        }
+        //招工code
+        if (isset($where['code']) && !empty($where['code']) && is_string($where['code'])) {
+            $usewhere[] = "code like '%" . $where['code'] . "%'";
+        }
+        //打电话时间段
+        if (isset($where['calltime']) && !empty($where['calltime']) && is_array($where['calltime'])) {
+            $usewhere[] = "calltime >= '" . $where['calltime'][0] . "'";
+            $usewhere[] = "calltime < '" . $where['calltime'][1] . "'";
+        }
+        //工作类型
+        if (isset($where['worktype']) && !empty($where['worktype']) && is_string($where['worktype'])) {
+            $usewhere[] = "worktype like '%" . $where['worktype'] . "%'";
+        }
+        if (!empty($usewhere)) {
+            $tabwhere = implode(' and ', $usewhere);
+            $tabsql .= ' where ' . $tabwhere;
+        }
+        if (!$count) {
+            $index = ($page - 1) * $size;
+            $tabsql .= " limit " . $index . "," . $size;
+        }
+        if ($count) {
+            $list = $this->db->query("select count(*) count from (" . $tabsql . ") as t");
+        } else {
+            $list = $this->db->query("select * from (" . $tabsql . ") as t");
+        }
+        return $list;
+    }
+    /*
+     * 20211220
+     * wj
+     * 统计联系电话的时间段
+     */
+    public function getconnecttimebucket($where)
+    {
+        $tabsql = "select DATE_FORMAT(calltime,'%H') as hour,count(*) count from " . $this->table . " as uc join t_invent as i on uc.sourceid=i.id group by hour ORDER BY hour asc";
+        $list = $this->db->query("select * from (" . $tabsql . ") as t");
+        return $list;
+    }
+    /*
+     * 20211222
+     * wj
+     * 统计联系电话联系数量
+     */
+    public function getconnectbyinvent($where, $count = false, $page = 1, $size = 10)
+    {
+        #i.isactive=1 and
+        $tabsql = "select uc.sourceid,i.id,i.createdate,i.code,i.info,i.isactive,i.ispass,count(uc.id) count
+        from " . $this->table . " as uc
+        join t_invent as i on uc.sourceid=i.id where i.ispass=1
+        GROUP BY uc.sourceid ORDER BY i.id desc";
+        if ($count) {
+            $list = $this->db->query("select count(*) count from (" . $tabsql . ") as t");
+            $count = $list[0]['count'];
+            return $count;
+        } else {
+            $index = ($page - 1) * $size;
+            $list = $this->db->query("select * from (" . $tabsql . ") as t limit " . $index . "," . $size);
+        }
+        return $list;
+    }
+}

+ 210 - 0
application/index/model/userconnectrecordmodel.php

@@ -0,0 +1,210 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-28 11:13:58
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-24 16:48:36
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class userconnectrecordmodel extends Model
+{
+    protected $table = 't_userconnectrecord';
+
+    public function insinfo($arr)
+    {
+        if (!isset($arr['calltime']) || empty($arr['calltime'])) {
+            $arr['calltime'] = date("Y-m-d H:i:s");
+        }
+        $id = $this->insertGetId($arr);
+        return $id;
+    }
+
+    /***
+     * 校验数据是否可添加
+     * 20211215
+     * wj
+     */
+    public function checkDataForInsert($arr)
+    {
+        $where = [
+            'senduserid' => $arr['senduserid'],
+            'calltime' => ['like', '%' . date('Y-m-d') . '%'],
+        ];
+        $row = $this->where($where)->count();
+        if ($row > 0) {
+            return backarr(0, "数据已存在");
+        }
+        return backarr(1, "数据可新增");
+    }
+    /*
+     * 20211129
+     * steelxu5
+     * 根据主动联系人的用户id,返回联系数据
+     * todo 当联系数据多时,后期需要改成按起始日期统计,分步加载,
+     */
+    public function seltotalbyuserid($userid)
+    {
+        $strsql = 'select substr(calltime,1,10) as calldate,count(id) as connectcount,sum(senderevaluate) as evaluatecount';
+        $strsql = $strsql . " from t_userconnectrecord where senduserid=" . $userid;
+        $strsql = $strsql . " group by substr(calltime,1,10)";
+        $rlist = $this->query($strsql);
+        $rlist = collection($rlist)->toArray();
+        return $rlist;
+    }
+
+    /*
+     * 20211130
+     * steelxu5
+     * 获取某一天的,某人的联系记录
+     */
+    public function selinfolistbyuiddate($userid, $date)
+    {
+        $strsql = 'select *';
+        $strsql = $strsql . " from t_userconnectrecord where senduserid=" . $userid . " and calltime like '" . $date . "%' ";
+        $rlist = $this->query($strsql);
+        $rlist = collection($rlist)->toArray();
+        return $rlist;
+    }
+
+    /*
+     * 20211201
+     * steelxu5
+     * 更新评价状态
+     */
+    public function updatesenderevaluebysid($sourceid, $sourcetype)
+    {
+        $where_arr['sourcetype'] = $sourcetype;
+        $where_arr['sourceid'] = $sourceid;
+        $update_arr['senderevaluate'] = 1;
+        $count = $this->where($where_arr)->update($update_arr);
+        return $count;
+    }
+
+    /*
+     * 20211209
+     * wj
+     * 获得联系电话列表
+     */
+    public function getconnectlist($where, $count = false, $page = 1, $size = 10)
+    {
+        $sql = "
+            select uc.id,uc.senduserid,us.wname as swname,us.id as sid,us.telno as stelno,uc.reciveruserid,ur.id as rid,ur.wname as rwname,ur.telno as rtelno,i.code,i.id as iid,i.worktype,uc.calltime
+            from t_userconnectrecord as uc
+            join t_invent as i on uc.sourceid=i.id
+            join t_userinfo as us on uc.senduserid=us.id
+            join t_userinfo as ur on uc.reciveruserid=ur.id
+            ORDER BY uc.calltime desc";
+        $tabsql = "select * from (" . $sql . ") as tab";
+        $usewhere = [];
+        //打电话人
+        if (isset($where['swname']) && !empty($where['swname']) && is_string($where['swname'])) {
+            $usewhere[] = "swname like '%" . $where['swname'] . "%'";
+        }
+        //拨打电话
+        if (isset($where['stelno']) && !empty($where['stelno']) && is_string($where['stelno'])) {
+            $usewhere[] = "stelno like '%" . $where['stelno'] . "%'";
+        }
+        //被联系人
+        if (isset($where['rwname']) && !empty($where['rwname']) && is_string($where['rwname'])) {
+            $usewhere[] = "rwname like '%" . $where['rwname'] . "%'";
+        }
+        //被联系电话
+        if (isset($where['rtelno']) && !empty($where['rtelno']) && is_string($where['rtelno'])) {
+            $usewhere[] = "rtelno like '%" . $where['rtelno'] . "%'";
+        }
+        //招工code
+        if (isset($where['code']) && !empty($where['code']) && is_string($where['code'])) {
+            $usewhere[] = "code like '%" . $where['code'] . "%'";
+        }
+        //打电话时间段
+        if (isset($where['calltime']) && !empty($where['calltime']) && is_array($where['calltime'])) {
+            $usewhere[] = "calltime >= '" . $where['calltime'][0] . "'";
+            $usewhere[] = "calltime < '" . $where['calltime'][1] . "'";
+        }
+        if (isset($where['callday']) && !empty($where['callday']) && is_string($where['callday'])) {
+            $where['callday'] = date('Y-m-d', strtotime($where['callday']));
+            $usewhere[] = "calltime like '%" . $where['callday'] . "%'";
+        }
+        //工作类型
+        if (isset($where['worktype']) && !empty($where['worktype']) && is_string($where['worktype'])) {
+            $usewhere[] = "worktype like '%" . $where['worktype'] . "%'";
+        }
+        if (!empty($usewhere)) {
+            $tabwhere = implode(' and ', $usewhere);
+            $tabsql .= ' where ' . $tabwhere;
+        }
+        if (!$count) {
+            $index = ($page - 1) * $size;
+            $tabsql .= " limit " . $index . "," . $size;
+        }
+        if ($count) {
+            $list = $this->query("select count(*) count from (" . $tabsql . ") as t");
+        } else {
+            $list = $this->query("select * from (" . $tabsql . ") as t");
+        }
+        return $list;
+    }
+    /*
+     * 20211220
+     * wj
+     * 统计联系电话的时间段
+     */
+    public function getconnecttimebucket($where)
+    {
+        $tabsql = "select DATE_FORMAT(calltime,'%H') as hour,count(*) count from t_userconnectrecord as uc join t_invent as i on uc.sourceid=i.id";
+        $group = " group by hour ORDER BY hour asc";
+        $usewhere = [];
+        if (isset($where['callday']) && !empty($where['callday']) && is_string($where['callday'])) {
+            $where['callday'] = date('Y-m-d', strtotime($where['callday']));
+            $usewhere[] = "calltime like '%" . $where['callday'] . "%'";
+        } else {
+            $dayStr = date('Y-m-d');
+            $usewhere[] = "calltime like '%" . $dayStr . "%'";
+        }
+        if (!empty($usewhere)) {
+            $tabwhere = implode(' and ', $usewhere);
+            $tabsql .= ' where ' . $tabwhere;
+        }
+        $tabsql .= $group;
+        $list = $this->query("select * from (" . $tabsql . ") as t");
+        return $list;
+    }
+    /*
+     * 20211222
+     * wj
+     * 统计联系电话联系数量
+     */
+    public function getconnectbyinvent($where, $count = false, $page = 1, $size = 10)
+    {
+        $tabsql = "select uc.sourceid,i.id,i.createdate,i.code,i.info,i.isactive,i.ispass,count(uc.id) count from " . $this->table . " as uc join t_invent as i on uc.sourceid=i.id";
+        $group = "  GROUP BY uc.sourceid ORDER BY i.id desc";
+        $usewhere = [
+            #'i.isactive' => 1,
+            'i.ispass' => 1,
+        ];
+        if (isset($where['callday']) && !empty($where['callday']) && is_string($where['callday'])) {
+            $where['callday'] = date('Y-m-d', strtotime($where['callday']));
+            $usewhere[] = "calltime like '%" . $where['callday'] . "%'";
+        } else {
+            $dayStr = date('Y-m-d');
+            $usewhere[] = "calltime like '%" . $dayStr . "%'";
+        }
+        if (!empty($usewhere)) {
+            $tabwhere = implode(' and ', $usewhere);
+            $tabsql .= ' where ' . $tabwhere;
+        }
+        $tabsql .= $group;
+        if ($count) {
+            $list = $this->query("select count(*) count from (" . $tabsql . ") as t");
+            $count = $list[0]['count'];
+            return $count;
+        } else {
+            $index = ($page - 1) * $size + 1;
+            $list = $this->query("select * from (" . $tabsql . ") as t limit " . $index . "," . $size);
+        }
+        return $list;
+    }
+}

+ 182 - 0
application/index/model/userinfomodel.php

@@ -0,0 +1,182 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 08:47:38
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-16 16:40:22
+ */
+
+namespace app\index\model;
+
+use think\Model;
+
+class userinfomodel extends Model
+{
+    protected $table = 't_userinfo';
+
+    public function insertData($data)
+    {
+        if (!isset($data['createtime']) || empty($data['createtime'])) {
+            $data['createtime'] = date('Y-m-d H:i:s');
+        }
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+    /*
+     *20211003
+     * 根据ID获取头像和身份证信息,未来可再增加获取的
+     * steelxu5
+     */
+    public function selconinfobyid($id)
+    {
+        $where_arr['id'] = $id;
+        $strfiled = 'telno,photourl,wage,wname,gender,sfzid,enterprisename';
+        $rlist = $this->where($where_arr)->field($strfiled)->find();
+        if (empty($rlist)) {
+            return false;
+        }
+        if (empty($rlist['sfzid'])) {
+            $rlist['is_realauth'] = false;
+        } else {
+            $rlist['is_realauth'] = true;
+        }
+        unset($rlist['sfzid']);
+        return $rlist;
+    }
+
+    /*
+     * 20211031
+     * steelxu5
+     * 更新信息,根据opoenid
+     */
+    public function updateinfobyopenid($openid, $updatearr)
+    {
+        $where_arr['openid'] = $openid;
+        $rec = $this->where($where_arr)->update($updatearr);
+        return $rec;
+    }
+    /*
+     * 202120110
+     * wj
+     * 更新信息,根据id
+     */
+    public function updateinfobyid($id, $updatearr)
+    {
+        $where_arr['id'] = $id;
+        $rec = $this->where($where_arr)->update($updatearr);
+        return $rec;
+    }
+    /*
+     * 20200813
+     * 预检查是否有索引字段重复
+     * 改为用身份证查重
+     */
+    public function precheckindex($info)
+    {
+        $where_arr['sfzid'] = $info['sfzid'];
+        $rec = $this->where($where_arr)->find();
+        if ($rec) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+    /***
+     * 获取全部字段名
+     * 20211103
+     * wj
+     */
+    public function gettablefields()
+    {
+        $sql = "desc " . $this->table;
+        $fiekds = $this->query($sql);
+        return $fiekds;
+    }
+    /**
+     * 获取总数
+     * 20211117
+     * wj
+     */
+    public function getcount()
+    {
+        $count = $this->where([])->count();
+        return $count;
+    }
+    /**
+     * 获取分析数据
+     * 20211117
+     * wj
+     */
+    public function statistics()
+    {
+        $sql = "select isactive,isright,count(*) as count from " . $this->table . " group by isactive,isright";
+        $list = $this->query("select * from (" . $sql . ") as t");
+        return $list;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = '';
+        if (isset($where['sfzid']) && 'NULL' == $where['sfzid']) {
+            $sqlObj = $this->whereNull('sfzid');
+            unset($where['sfzid']);
+        }
+        if (isset($where['wname']) && 'NULL' == $where['wname']) {
+            if ($sqlObj) {
+                $sqlObj = $sqlObj->whereNull('wname');
+            } else {
+                $sqlObj = $this->whereNull('wname');
+            }
+            unset($where['wname']);
+        }
+        if ($sqlObj) {
+            $sqlObj = $sqlObj->where($where);
+        } else {
+            $sqlObj = $this->where($where);
+        }
+
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+
+    /*
+     * 20220111
+     * steelxu5
+     * 根据ID返回qrcode
+     */
+    public function selqrcodebyuid($uid){
+        $where_arr['id']=$uid;
+        $rec=$this->where($where_arr)->field('qrcode')->find();
+        return $rec;
+    }
+
+}

+ 83 - 0
application/index/model/userlocationmodel.php

@@ -0,0 +1,83 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2021/4/30
+ * Time: 10:55
+ */
+namespace app\index\model;
+use think\Model;
+class userlocationmodel extends Model{
+    protected $table='t_userlocation';
+
+    public function selinfobyopenid($openid){
+        $where_arr['openid']=$openid;
+        $uloction=$this->where($where_arr)->find();
+
+        return $uloction;
+    }
+
+
+    /*
+     * 20210424
+     *
+     */
+    public function insinfo($arr){
+        $this->setAttr('id',null)->isUpdate(false)->allowField(true)->save($arr);
+        return $this->id;
+    }
+
+
+    /*
+     * 20210502
+     * 获取所有数据
+     */
+    public function sellist(){
+        $list=$this->all();
+        $list=collection($list)->toArray();
+        return $list;
+
+    }
+
+    /*
+     * 20210510
+     */
+    public function updinfobyid($id,$updarr){
+        $where_arr['id']=$id;
+        $rec=$upd_arr=$this->where($where_arr)->update($updarr);
+        return $rec;
+    }
+
+    /*
+     * 20210511
+     * 获取用户的按省级的统计数据
+     */
+    public function selgroupby_p(){
+        $strsql="select province,count(*) as workcount from t_userlocation group by province";
+        $rlist=$this->query($strsql);
+        $rlist=collection($rlist)->toArray();
+        return $rlist;
+    }
+
+    /*
+ * 20210511
+ * 获取用户的按市级的统计数据
+ */
+    public function selgroupby_c(){
+        $strsql="select city,count(*) as workcount from t_userlocation group by city";
+        $rlist=$this->query($strsql);
+        $rlist=collection($rlist)->toArray();
+        return $rlist;
+    }
+
+    /*
+     * 20210515
+     * 按项目统计用户数据
+     */
+    public function selgroupbyprj(){
+        $strsql="select prjid,count(*) as workcount from t_userlocation group by prjid";
+        $rlist=$this->query($strsql);
+        $rlist=collection($rlist)->toArray();
+        return $rlist;
+    }
+}

+ 62 - 0
application/index/model/userpartymodel.php

@@ -0,0 +1,62 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-29 16:15:16
+ */
+
+namespace app\index\model;
+
+use think\Model;
+
+class userpartymodel extends Model
+{
+
+    protected $table = 't_userparty';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 65 - 0
application/index/model/userpartypicturemodel.php

@@ -0,0 +1,65 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-29 16:15:16
+ */
+
+namespace app\index\model;
+
+use think\Model;
+
+class userpartypicturemodel extends Model
+{
+
+    protected $table = 't_userpartypicture';
+
+    public function insertData($data)
+    {
+        if (!isset($data['createtime'])) {
+            $data['createtime'] = date('Y-m-d H:i:s');
+        }
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 24 - 0
application/index/model/usersearchrecordmodel.php

@@ -0,0 +1,24 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-28 11:13:58
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-09-28 13:55:21
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class usersearchrecordmodel extends Model
+{
+    protected $table = 't_usersearchrecord';
+
+    public function insinfo($arr)
+    {
+        if (!isset($arr['searchtime']) || empty($arr['searchtime'])) {
+            $arr['searchtime'] = date("Y-m-d H:i:s");
+        }
+        $id = $this->insertGetId($arr);
+        return $id;
+    }
+}

+ 76 - 0
application/index/model/usersharelogmodel.php

@@ -0,0 +1,76 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-29 16:15:16
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class usersharelogmodel extends Model
+{
+
+    protected $table = 't_usersharelog';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+    public function getListjoinapply($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where)->alias('usl')->join('t_userapplylog ual', 'ual.shareuid = usl.shareuid');
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 61 - 0
application/index/model/versionmodel.php

@@ -0,0 +1,61 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-24 15:44:28
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class versionmodel extends Model
+{
+
+    protected $table = 't_version';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 61 - 0
application/index/model/webuserlogmodel.php

@@ -0,0 +1,61 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:06:41
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-11-16 11:25:26
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class webuserlogmodel extends Model
+{
+
+    protected $table = 't_webuserlog';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 79 - 0
application/index/model/webusermodel.php

@@ -0,0 +1,79 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2020/1/22
+ * Time: 21:08
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class webusermodel extends Model
+{
+    protected $table = 't_webuser';
+
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+
+    public function getlogininfo($lname, $lpwd)
+    {
+        $where_arr['user_password'] = $lpwd;
+        $where_arr['user_name'] = $lname;
+        $uinfo = $this->where($where_arr)->find();
+        //var_dump($uinfo);
+        return $uinfo;
+
+    }
+    /***
+     * 用户密码md5登录
+     */
+    public function getlogininfomd5($lname, $lpwd)
+    {
+        $where_arr['user_password'] = md5($lname . $lpwd);
+        $where_arr['user_name'] = $lname;
+        $uinfo = $this->where($where_arr)->find();
+        return $uinfo;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 66 - 0
application/index/model/workerinfomodel.php

@@ -0,0 +1,66 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sicilon_IT
+ * Date: 2020/1/12
+ * Time: 21:59
+ */
+
+namespace app\index\model;
+
+use think\Config;
+use think\Db;
+use think\Model;
+
+class workerinfomodel extends Model
+{
+
+    protected $table = 't_workerinfo';
+    private $db;
+    public function __construct()
+    {
+        parent::__construct();
+        //$connection = Config::get('database_labourunion');
+        $connection = Config::get('database_labouruniondev');
+        $this->db = Db::connect($connection);
+    }
+    /*
+     * 20210813
+     */
+    public function insinfo($arr)
+    {
+        if (!isset($arr['createtime']) || empty($arr['createtime'])) {
+            $arr['createtime'] = date('Y-m-d H:i:s');
+        }
+        $id = $this->db->table($this->table)->insert($arr, false, true);
+        return empty($id) ? false : $id;
+    }
+    /***
+     * 获取信息
+     * 20211009
+     * wj
+     */
+    public function getinfo($where)
+    {
+        $info = $this->db->table($this->table)->where($where)->find();
+        return $info;
+    }
+    /**
+     * 获取列表
+     */
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->db->table($this->table)->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 51 - 0
application/index/model/workermodel.php

@@ -0,0 +1,51 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 08:39:30
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-09-27 10:40:35
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class workermodel extends Model
+{
+    protected $table = 't_worker';
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+    /***
+     * 获取全部字段名
+     * 20211103
+     * wj
+     */
+    public function gettablefields()
+    {
+        $sql = "desc " . $this->table;
+        $fiekds = $this->query($sql);
+        return $fiekds;
+    }
+}

+ 55 - 0
application/index/model/workerskillmodel.php

@@ -0,0 +1,55 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 08:39:30
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-10-22 15:14:01
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class workerskillmodel extends Model
+{
+    protected $table = 't_workerskill';
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 81 - 0
application/index/model/worktypemodel.php

@@ -0,0 +1,81 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-09-27 08:39:30
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-09-27 10:40:35
+ */
+namespace app\index\model;
+
+use think\Model;
+
+class worktypemodel extends Model
+{
+    protected $table = 't_worktype';
+    public function insertData($data)
+    {
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+
+    /***
+     * 根据联系数量对工种进行排序
+     * wj
+     * 20211214
+     */
+    public function getworktypebyconnect($where = [], $page = 1, $size = 5)
+    {
+        $sql = " select i.worktype,count(*) as count
+        from t_userconnectrecord as uc
+        join t_invent as i on i.id=uc.sourceid
+        where uc.sourcetype in (1,2) and i.worktype is not null";
+        $whereArr = [];
+        if (!empty($where)) {
+            if (isset($where['calltime'])) {
+                $whereArr[] = "uc.calltime>='" . $where['calltime'][0] . "' and uc.calltime<='" . $where['calltime'][0] . "'";
+            }
+        }
+        if (!empty($whereArr)) {
+            $whereStr = implode(" and ", $whereArr);
+            $sql .= " " . $whereStr;
+        }
+        $sql .= " group by i.worktype order by count desc limit " . $page . "," . $size;
+        $list = $this->query("select * from (" . $sql . ") as t");
+        return $list;
+    }
+}

+ 170 - 0
application/index/server/applybusinessserver.php

@@ -0,0 +1,170 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-10-29 16:16:29
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2021-12-31 17:52:41
+ */
+namespace app\index\server;
+
+use app\index\model\userapplylogmodel;
+use app\index\model\usersharelogmodel;
+use app\index\server\scorebusinessserver as BusinessBase;
+use think\Log;
+
+/**
+ * 分享进入
+ * 20220104
+ * wj
+ */
+class applybusinessserver extends BusinessBase
+{
+    private $info;
+    private $option;
+    private $param;
+    public function dobusiness($param)
+    {
+        $this->param = $param;
+        $this->info = $this->getinfo($this->param);
+        $this->option = json_decode($this->info['option'], true);
+        $info = $this->getapplyinfo();
+        if (!$info) {
+            return backarr(0, "无数据");
+        }
+        $msg = "分享进入";
+        $returndata = [
+            'uaarid' => 0,
+            'addscore' => 0,
+        ];
+        if (1 == $info['isnewuser']) {
+            $msg .= "-新用户";
+            $maxnewuser = $this->option['maxnewuser'];
+            $shareresult = $this->getshareloginfo($info['shareuid']);
+            if (!$shareresult['status']) {
+                return $shareresult;
+            }
+            $shareinfo = $shareresult['data'];
+            $userid = $shareinfo['userid'];
+            $isaddscore = false;
+            if ($maxnewuser > 0) {
+                $count = $this->countnewuser($userid);
+                if ($count < $maxnewuser) {
+                    $isaddscore = true;
+                }
+            } else {
+                $isaddscore = true;
+            }
+            if ($isaddscore) {
+                $adddata = [
+                    'sourcedemo' => $msg,
+                    'userid' => $userid,
+                    'scoretype' => $this->info['scoretype'],
+                    'addscore' => $this->info['score'],
+                    'sourcetype' => 2,
+                ];
+                $result = $this->adduserscore($adddata);
+                if (empty($result['status'])) {
+                    return $result;
+                }
+                $data = $result['data'];
+                $uaarid = $data['uaarid'];
+                $recorddata = [
+                    'sbid' => $this->info['id'],
+                    'code' => $this->info['code'],
+                    'refid' => $uaarid,
+                    'type' => 1,
+                ];
+                $id = $this->newrecord($recorddata);
+                if (!$id) {
+                    log::error($msg . " 创建关系失败");
+                }
+                $returndata = [
+                    'uaarid' => $uaarid,
+                    'addscore' => $adddata['addscore'],
+                ];
+            }
+        }
+        return backarr(1, $msg, $returndata);
+    }
+    /**
+     * 获取新用户数量
+     * 20220104
+     * wj
+     */
+    /*private function countnewuser()
+    {
+    $arr = $this->param;
+    $m_ual = new userapplylogmodel();
+    if (!isset($arr['shareuid']) || empty($arr['shareuid']) || !is_numeric($arr['shareuid'])) {
+    return backarr(0, "请求错误");
+    }
+    $where = [
+    'isnewuser' => 1,
+    'shareuid' => $arr['shareuid'],
+    'sharetime' => ['like', '%' . date('Y-m-d') . '%'],
+    ];
+    $count = $m_ual->getList($where, 'count');
+    return $count;
+    }*/
+    public function countnewuser($userid)
+    {
+        $where = [
+            'usl.userid' => $userid,
+            'ual.sharetime' => ['like', '%' . date('Y-m-d') . '%'],
+            'ual.isnewuser' => 1,
+        ];
+        $m_usl = new usersharelogmodel();
+        $count = $m_usl->getListjoinapply($where, 'count');
+        $count = empty($count) ? 0 : $count;
+        return $count;
+    }
+    /**
+     * 获取详细
+     * 20220104
+     * wj
+     */
+    private function getapplyinfo()
+    {
+        $arr = $this->param;
+        $where = [];
+        if (isset($arr['shareuid'])) {
+            $where['shareuid'] = $arr['shareuid'];
+        }
+        if (isset($arr['userid'])) {
+            $where['userid'] = $arr['userid'];
+        }
+        if (isset($arr['openid'])) {
+            $where['shareopenid'] = $arr['openid'];
+        }
+        if (isset($arr['applyid'])) {
+            $where['id'] = $arr['applyid'];
+        }
+        $m_ual = new userapplylogmodel();
+        $info = $m_ual->getInfo($where);
+        if (empty($info)) {
+            return false;
+        }
+        return $info;
+    }
+    /**
+     * 获取分享详情
+     * 20220104
+     * wj
+     */
+    private function getshareloginfo($shareuid)
+    {
+        //$arr = $this->param;
+        $m_usl = new usersharelogmodel();
+        $where = [
+            'shareuid' => $shareuid,
+        ];
+        $info = $m_usl->getInfo($where);
+        if (empty($info)) {
+            return backarr(0, "无分享信息");
+        }
+        if (empty($info['userid'])) {
+            return backarr(0, "无用户id");
+        }
+        return backarr(1, "查询成功", $info);
+    }
+}

Some files were not shown because too many files changed in this diff