Audit.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018-2020 rights reserved.
  6. // +----------------------------------------------------------------------
  7. // |
  8. // +----------------------------------------------------------------------
  9. // | Date: 2020-11-08 12:56
  10. // +----------------------------------------------------------------------
  11. namespace app\system\controller;
  12. use app\BaseController;
  13. use app\model\api\User as UserModel;
  14. use app\model\api\ServiceType as ServiceTypeModel;
  15. use app\model\api\InfoAudit;
  16. use app\model\api\TypeAudit;
  17. use app\model\api\UserAudit;
  18. use app\model\api\ServiceType;
  19. use app\model\api\ServiceTimeType;
  20. use app\model\api\City as CityModel;
  21. use app\model\api\Sys as SysModel;
  22. use think\db\exception\DbException;
  23. use think\facade\Db;
  24. use app\Request;
  25. use library\services\UtilService;
  26. use library\utils\UserUtilsTool;
  27. class Audit extends BaseController
  28. {
  29. /***********************************审核******************************/
  30. /**
  31. * 第一步审核初始化
  32. * @return type
  33. */
  34. public function infoAuditInit()
  35. {
  36. return app('json')->success([
  37. 'all' => (new InfoAudit)->count(),
  38. 'wait' => (new InfoAudit)->where('status', 0)->count(),
  39. 'ok' => (new InfoAudit)->where('status', 1)->count(),
  40. 'no' => (new InfoAudit)->where('status', -1)->count(),
  41. ]);
  42. }
  43. /**
  44. * 获取第一步审核列表
  45. * @param Request $request
  46. */
  47. public function infoAuditList(Request $request)
  48. {
  49. $post = UtilService::getMore(
  50. [
  51. ['page', 1],
  52. ['pageSize', 50],
  53. ['keyword',''],
  54. ['mobile',''],
  55. ['user_mobile',''],
  56. ['status', ''],
  57. ['uid', ''],
  58. ['time',[]],
  59. ], $request
  60. );
  61. $data = (new InfoAudit)->getList($post,1);
  62. return app('json')->success([
  63. 'list' => $data["list"],
  64. 'pageCount' => $data["totalCount"],
  65. 'pageSize' => $data["pageSize"],
  66. 'page' => $data["page"],
  67. ]);
  68. }
  69. /**
  70. * 信息认证详情
  71. * @param Request $request
  72. */
  73. public function infoAuditInfo(Request $request){
  74. $post = UtilService::getMore([
  75. ['id', '', 'empty', '参数错误'],
  76. ], $request);
  77. $data = (new InfoAudit)->getItem($post,1);
  78. if(empty($data)){
  79. return app('json')->fail('数据不存在');
  80. }
  81. return app('json')->success($data);
  82. }
  83. /**
  84. * 第一步审核处理
  85. * @param Request $request
  86. */
  87. public function infoAuditSub(Request $request)
  88. {
  89. $post = UtilService::getMore(
  90. [
  91. ['id', '', 'empty', '参数错误'],
  92. ['mono'],
  93. ['type', 0],
  94. ], $request);
  95. $certData = (new InfoAudit)->where('id', $post['id'])->find();
  96. if (empty($certData)) {
  97. return app('json')->fail('数据不存在');
  98. }
  99. if ($certData['status']!=0) {
  100. return app('json')->fail( '当前审核已处理');
  101. }
  102. //审核通过
  103. if ($post['type'] == 1) {
  104. (new InfoAudit)
  105. ->where('id', $post['id'])
  106. ->save([
  107. 'status' => 1,
  108. 'admin_mono' => $post['mono'],
  109. 'admin_time' => time(),
  110. 'admin_id' => $request->adminInfo['id'],
  111. ]);
  112. (new UserModel)->where("uid",$certData["uid"])->update(["work_type_id"=>$certData["user_work_type_id"]]);
  113. return app('json')->success('操作成功');
  114. }
  115. //审核驳回
  116. if ($post['type'] == -1) {
  117. (new InfoAudit)
  118. ->where('id', $post['id'])
  119. ->save([
  120. 'status' => -1,
  121. 'admin_mono' => $post['mono'],
  122. 'admin_time' => time(),
  123. 'admin_id' => $request->adminInfo['id'],
  124. ]);
  125. return app('json')->success('已驳回');
  126. }
  127. }
  128. /**
  129. * 平台认证初始化
  130. * @return type
  131. */
  132. public function typeAuditInit()
  133. {
  134. return app('json')->success([
  135. 'all' => (new TypeAudit)->count(),
  136. 'wait' => (new TypeAudit)->where('status', 0)->count(),
  137. 'ok' => (new TypeAudit)->where('status', 1)->count(),
  138. 'no' => (new TypeAudit)->where('status', -1)->count(),
  139. ]);
  140. }
  141. /**
  142. * 平台认证详情
  143. * @param Request $request
  144. */
  145. public function typeAuditInfo(Request $request){
  146. }
  147. /**
  148. * 获取平台认证审核列表
  149. * @param Request $request
  150. */
  151. public function typeAuditList(Request $request)
  152. {
  153. $pageSize = 50;
  154. $post = UtilService::getMore(
  155. [
  156. ['page', 1],
  157. ['keyword',''],
  158. ['status', ''],
  159. ['user_mobile',''],
  160. ['uid', ''],
  161. ['time',[]],
  162. ], $request
  163. );
  164. $where = [];
  165. if(is_numeric($post['status'])) {
  166. $where[]=["t.status","=",(int)$post['status']];
  167. }
  168. if(is_numeric($post['uid']) && $post['uid']>0) {
  169. $where[]=["t.uid","=",(int)$post['uid']];
  170. }else if(is_mobile($post['user_mobile'])){
  171. $udata = (new UserModel)->where("mobile",$post['user_mobile'])->find();
  172. if(!empty($udata)){
  173. $where[]=["t.uid","=",(int)$udata['uid']];
  174. }
  175. }
  176. $startTime = "";
  177. $endTime = "";
  178. if(!empty($post['time'][0]) && !empty($post['time'][1])) {
  179. $startTime = strtotime($post['time'][0]);
  180. $endTime = strtotime($post['time'][1]);
  181. $where[]=["t.time","between","{$startTime},{$endTime}"];
  182. }
  183. if(!empty($post['keyword'])){
  184. $where[]=["t.name","=",$post['keyword']];
  185. }
  186. $pageCount = (new TypeAudit)->alias("t")->where($where)->count();
  187. $data = null;
  188. if($pageCount>0){
  189. $data = (new TypeAudit)
  190. ->alias("t")
  191. ->field("t.*,u.nickname,a.username as admin_name")
  192. ->leftJoin("user u", "u.uid = t.uid")
  193. ->leftJoin("admin a", "a.id = t.admin_id")
  194. ->where($where)
  195. ->page((int)$post["page"], $pageSize)
  196. ->order("t.id","desc")
  197. ->select()
  198. ->toArray();
  199. }
  200. $data = empty($data) ? [] : $data;
  201. $serviceTypeModel = new ServiceTypeModel();
  202. foreach($data as $k=>$v){
  203. $data[$k]["admin_time"] = empty($v["admin_time"])?"":date("Y-m-d H:i:s",$v["admin_time"]);
  204. $data[$k]["time"] = date("Y-m-d H:i:s",$v["time"]);
  205. $data[$k]["service_audit_imgs"] = getImageAr($v["service_audit_imgs"]);
  206. }
  207. return app('json')->success([
  208. 'list' => $data,
  209. 'pageCount' => $pageCount,
  210. 'pageSize' => $pageSize,
  211. 'page' => $post['page'],
  212. ]);
  213. }
  214. /**
  215. * 第一步审核处理
  216. * @param Request $request
  217. */
  218. public function typeAuditSub(Request $request)
  219. {
  220. $post = UtilService::getMore(
  221. [
  222. ['id', '', 'empty', '参数错误'],
  223. ['mono'],
  224. ['type', 0],
  225. ], $request);
  226. $certData = (new TypeAudit)->where('id', $post['id'])->find();
  227. if (empty($certData)) {
  228. return app('json')->fail('数据不存在');
  229. }
  230. if ($certData['status']!=0) {
  231. return app('json')->fail( '当前审核已处理');
  232. }
  233. //审核通过
  234. if ($post['type'] == 1) {
  235. (new TypeAudit)
  236. ->where('id', $post['id'])
  237. ->save([
  238. 'status' => 1,
  239. 'admin_mono' => $post['mono'],
  240. 'admin_time' => time(),
  241. 'admin_id' => $request->adminInfo['id'],
  242. ]);
  243. return app('json')->success('操作成功');
  244. }
  245. //审核驳回
  246. if ($post['type'] == -1) {
  247. (new TypeAudit)
  248. ->where('id', $post['id'])
  249. ->save([
  250. 'status' => -1,
  251. 'admin_mono' => $post['mono'],
  252. 'admin_time' => time(),
  253. 'admin_id' => $request->adminInfo['id'],
  254. ]);
  255. return app('json')->success('已驳回');
  256. }
  257. }
  258. }