Users.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. <?php
  2. namespace app\admin\controller\user;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\user\UsersServer;
  5. use PhpOffice\PhpSpreadsheet\Helper\Sample;
  6. use PhpOffice\PhpSpreadsheet\IOFactory;
  7. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  8. use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
  9. use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
  10. use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
  11. use PhpOffice\PhpSpreadsheet\Cell\DataType;
  12. use PhpOffice\PhpSpreadsheet\Style\Fill;
  13. use PhpOffice\PhpSpreadsheet\Style\Color;
  14. use PhpOffice\PhpSpreadsheet\Style\Alignment;
  15. use PhpOffice\PhpSpreadsheet\Style\Border;
  16. /**
  17. * 会员
  18. * Class Users
  19. * @package app\admin\controller\user
  20. */
  21. class Users extends BaseController
  22. {
  23. /**
  24. * Notes:获取用户信息
  25. * @return \support\Response
  26. * User: yym
  27. * Date: 2022/7/26
  28. */
  29. public function getUserInfo()
  30. {
  31. $user_id = $this->request->get('user_id');
  32. $this->validateCheck('user\UserValidate', ['user_id' => $user_id], 'info');
  33. return json_success(UsersServer::getUserInfo($user_id), '成功');
  34. }
  35. /**
  36. * Notes:会员列表
  37. * @return \support\Response
  38. * User: yym
  39. * Date: 2022/8/4
  40. */
  41. public function getUserList()
  42. {
  43. $keywords = (string)$this->request->get('keywords', '');//搜索内容
  44. $category = (int)$this->request->get('category', '');//会员类型
  45. $status = (int)$this->request->get('status', '');//会员状态
  46. $pid = (int)$this->request->get('pid', 0);//上级id
  47. $user_create_time = $this->request->get('user_create_time','');//创建时间
  48. [$page, $limit] = $this->getPage();
  49. return json_success(UsersServer::getUserList($keywords, $category, $status, $pid, $page, $limit, $user_create_time), '获取成功');
  50. }
  51. /**
  52. * Notes:营销活动排行
  53. * @return \support\Response
  54. * User: ycp
  55. * Date: 2023/3/1
  56. */
  57. public function getRankList()
  58. {
  59. $act = (int)$this->request->get('act', 0);//活动id
  60. $s_time = (string)$this->request->get('s_time', '');//开始时间
  61. $e_time = (string)$this->request->get('e_time', '');//开始时间
  62. [$page, $limit] = $this->getPage();
  63. return json_success(UsersServer::getRankList($act,$s_time,$e_time), '获取成功');
  64. }
  65. /**
  66. * Notes:营销拉新列表
  67. * @return \support\Response
  68. * User: ycp
  69. * Date: 2023/3/1
  70. */
  71. public function getActLog()
  72. {
  73. $act = (int)$this->request->get('act', 0);//活动id
  74. [$page, $limit] = $this->getPage();
  75. return json_success(UsersServer::getActLog($act,$page,$limit), '获取成功');
  76. }
  77. /**
  78. * Notes:添加会员
  79. * @return \support\Response
  80. * User: ZQ
  81. * Date: 2022/11/21
  82. */
  83. public function userInsert()
  84. {
  85. $user_account = $this->request->post('user_account');
  86. $user_login_pwd = $this->request->post('user_login_pwd');
  87. $user_again_pwd = $this->request->post('user_again_pwd');
  88. $user_nickname = $this->request->post('user_nickname','');
  89. $user_headimgurl = $this->request->post('user_headimgurl','');
  90. $user_sex = $this->request->post('user_sex');
  91. $user_birthday = $this->request->post('user_birthday');
  92. $user_age = $this->request->post('user_age','');
  93. $user_register_address = $this->request->post('user_register_address','');
  94. $user_phone = $this->request->post('user_phone','');
  95. $user_status = $this->request->post('user_status');
  96. $user_real_name = $this->request->post('user_real_name','');
  97. $user_card_id = $this->request->post('user_card_id','');
  98. $user_certinfo = $this->request->post('user_certinfo','');
  99. $user_is_owner = $this->request->post('user_is_owner');
  100. $user_type = $this->request->post('user_type','');
  101. $user_spread_uid = $this->request->post('user_spread_uid','');
  102. $user_source = $this->request->post('user_source');
  103. $user_register_type = 1;
  104. $admin_id = $this->request->admin_id;
  105. $this->validateCheck('user\UserValidate', ['user_account'=>$user_account,'user_login_pwd'=>$user_login_pwd,'user_again_pwd'=>$user_again_pwd,'user_sex'=>$user_sex,'user_birthday'=>$user_birthday,'user_status'=>$user_status,'user_is_owner'=>$user_is_owner,'user_type'=>$user_type,'user_source'=>$user_source], 'create');
  106. if ($user_type == 1){
  107. $this->validateCheck('user\UserValidate',['user_real_name'=>$user_real_name,'user_card_id'=>$user_card_id,'user_certinfo'=>$user_certinfo],'userAuth');
  108. }
  109. return json_success(UsersServer::userInsert($user_account,$user_login_pwd,$user_again_pwd,$user_nickname,$user_headimgurl,$user_sex,$user_birthday,$user_age,$user_register_address,$user_phone,$user_status,$user_real_name,$user_card_id,$user_certinfo,$user_is_owner,$user_type,$user_spread_uid,$user_source,$admin_id,$user_register_type), '添加成功');
  110. }
  111. /**
  112. * Notes:会员认证审核
  113. * @return \support\Response
  114. * User: yym
  115. * Date: 2022/8/4
  116. */
  117. public function authUser()
  118. {
  119. $user_id = $this->request->post('user_id');//会员编号
  120. $status = $this->request->post('status');//审核状态 0=待审核 1=审核通过 2=审核驳回 3=主动撤销
  121. $content = $this->request->post('content', '');//审核意见
  122. $category = $this->request->post('category');//分类 实名认证、会员升级
  123. $admin_id = $this->request->admin_id;
  124. $this->validateCheck('user\UserValidate', ['user_id' => $user_id, 'status' => $status, 'content' => $content, 'category' => $category], 'auth');
  125. UsersServer::authUser($admin_id, $user_id, $status, $content, $category);
  126. return json_success([], '操作成功');
  127. }
  128. /**
  129. * Notes:获取会员体检信息
  130. * @return \support\Response
  131. * @throws \Exception
  132. * User: yym
  133. * Date: 2022/9/21
  134. */
  135. public function getUserReport()
  136. {
  137. $user_id = $this->request->get('user_id');//会员编号
  138. $this->validateCheck('user\UserValidate', ['user_id' => $user_id], 'report');
  139. return json_success(UsersServer::getUserReport($user_id), '获取成功');
  140. }
  141. /**
  142. * Notes:获取会员设备列表
  143. * @return \support\Response
  144. * @throws \Exception
  145. * User: ZQ
  146. * Date: 2022/9/22
  147. */
  148. public function getUserEquipment()
  149. {
  150. [$page, $limit] = $this->getPage();
  151. $equipment_user_id = $this->request->get('user_id');
  152. $equipment_class = $this->request->get('equipment_class');
  153. $equipment_name = $this->request->get('equipment_name');
  154. $equipment_tripartite_sn = $this->request->get('equipment_tripartite_sn');
  155. $equipment_create_time = $this->request->get('equipment_create_time');
  156. return json_success(UsersServer::getUserEquipment($page,$limit,$equipment_user_id,$equipment_name,$equipment_class,$equipment_tripartite_sn,$equipment_create_time), '获取成功');
  157. }
  158. /**
  159. * Notes:获取会员设备详情
  160. * @return \support\Response
  161. * @throws \Exception
  162. * User: ZQ
  163. * Date: 2022/9/22
  164. */
  165. public function userEquipmentInfo()
  166. {
  167. $equipment_id = $this->request->get('equipment_id');
  168. $this->validateCheck('intelligence\UserValidate', ['equipment_id' => $equipment_id], 'info');
  169. return json_success(UsersServer::userEquipmentInfo($equipment_id), '获取成功');
  170. }
  171. /**
  172. * Notes:获取会员下的智能产品设备列表
  173. * @return \support\Response
  174. * @throws \Exception
  175. * User: ZQ
  176. * Date: 2022/11/15
  177. */
  178. public function equipmentList()
  179. {
  180. $equipment_user_id = $this->request->get('equipment_user_id');
  181. return json_success(UsersServer::equipmentList($equipment_user_id), '获取成功');
  182. }
  183. /**
  184. * Notes:添加会员智能产品设备
  185. * @return \support\Response
  186. * User: ZQ
  187. * Date: 2022/11/14
  188. */
  189. public function userEquipmentInsert()
  190. {
  191. $equipment_intelligence_id = $this->request->post('equipment_intelligence_id');
  192. $equipment_user_id = $this->request->post('equipment_user_id');
  193. $equipment_name = $this->request->post('equipment_name', '');
  194. $equipment_only = $this->request->post('equipment_only');
  195. $equipment_type = $this->request->post('equipment_type');
  196. $equipment_class = $this->request->post('equipment_class');
  197. $equipment_status = $this->request->post('equipment_status');
  198. $equipment_tripartite_sn = $this->request->post('equipment_tripartite_sn');
  199. $equipment_property_id = $this->request->post('equipment_property_id', '');
  200. $admin_id = $this->request->admin_id;
  201. //查询智能设备唯一编号equipment_only是否重复
  202. $check = UsersServer::equipmentCheck($equipment_only);
  203. if (!empty($check)){
  204. throw new \Exception('智能设备唯一编号已存在!');
  205. }
  206. $result = UsersServer::insertEquipment($admin_id, $equipment_intelligence_id, $equipment_user_id, $equipment_name, $equipment_only,$equipment_type,$equipment_class,$equipment_tripartite_sn,$equipment_status,$equipment_property_id);
  207. return json_success($result, '添加成功');
  208. }
  209. /**
  210. * Notes:删除会员智能产品设备
  211. * @return \support\Response
  212. * User: ZQ
  213. * Date: 2022/11/14
  214. */
  215. public function userEquipmentDelete()
  216. {
  217. $equipment_id = $this->request->get('equipment_id');
  218. $admin_id = $this->request->admin_id;
  219. $this->validateCheck('user\UserValidate', ['equipment_id' => $equipment_id], 'equipmentDel');
  220. return json_success(UsersServer::equipmentDel($equipment_id,$admin_id), '删除成功');
  221. }
  222. /**
  223. * Notes:获取会员消息列表
  224. * @return \support\Response
  225. * @throws \Exception
  226. * User: ZQ
  227. * Date: 2022/9/22
  228. */
  229. public function userEquipmentLog()
  230. {
  231. [$page, $limit] = $this->getPage();
  232. $log_user_id = $this->request->get('log_user_id');
  233. $log_equipment_id = $this->request->get('log_equipment_id');
  234. return json_success(UsersServer::getEquipmentLog($page,$limit,$log_user_id,$log_equipment_id), '获取成功');
  235. }
  236. /**
  237. * Notes:获取会员消息详情
  238. * @return \support\Response
  239. * @throws \Exception
  240. * User: ZQ
  241. * Date: 2022/9/22
  242. */
  243. public function equipmentLogInfo()
  244. {
  245. $log_id = $this->request->get('log_id');
  246. $this->validateCheck('intelligence\LogValidate', ['log_id' => $log_id], 'info');
  247. return json_success(UsersServer::equipmentLogInfo($log_id), '获取成功');
  248. }
  249. /**
  250. * Notes:赠送会员权益包
  251. * @return \support\Response
  252. * User: yym
  253. * Date: 2022/11/21
  254. */
  255. public function givePackage()
  256. {
  257. $user_id = $this->request->post('user_id');//会员编号
  258. $package_id = $this->request->post('package_id');//套餐包编号
  259. $type = $this->request->post('type');//
  260. $admin_id = $this->request->admin_id;
  261. $this->validateCheck('package\PackageValidate', ['package_id' => $package_id, 'user_id' => $user_id, 'type' => $type], 'give');
  262. UsersServer::givePackage($user_id, $package_id, $type, $admin_id);
  263. return json_success([], '赠送成功');
  264. }
  265. /**
  266. * Notes:获取会员下的亲属关系列表
  267. * @return \support\Response
  268. * @throws \Exception
  269. * User: ZQ
  270. * Date: 2022/9/22
  271. */
  272. public function relativesList()
  273. {
  274. $relatives_user_id = $this->request->get('relatives_user_id');
  275. return json_success(UsersServer::relativesList($relatives_user_id), '获取成功');
  276. }
  277. /**
  278. * Notes:获取会员亲属关系列表
  279. * @return \support\Response
  280. * @throws \Exception
  281. * User: ZQ
  282. * Date: 2022/9/22
  283. */
  284. public function relativesToList()
  285. {
  286. [$page, $limit] = $this->getPage();
  287. $keywords = (string)$this->request->get('keywords', '');//搜索内容
  288. return json_success(UsersServer::relativesToList($page,$limit,$keywords), '获取成功');
  289. }
  290. /**
  291. * Notes:删除会员亲属关系
  292. * @return \support\Response
  293. * @throws \Exception
  294. * User: ZQ
  295. * Date: 2022/9/22
  296. */
  297. public function relativesDel()
  298. {
  299. $relatives_id = $this->request->get('relatives_id');
  300. $admin_id = $this->request->admin_id;
  301. $this->validateCheck('user\UserValidate', ['relatives_id' => $relatives_id], 'relatives');
  302. return json_success(UsersServer::relativesDel($relatives_id,$admin_id), '删除成功');
  303. }
  304. /**
  305. * Notes:获取会员固定资产列表
  306. * @return \support\Response
  307. * @throws \Exception
  308. * User: ZQ
  309. * Date: 2022/11/23
  310. */
  311. public function propertyList()
  312. {
  313. $property_user_id = $this->request->get('property_user_id');//会员id
  314. $this->validateCheck('user\UserValidate', ['user_id' => $property_user_id], 'info');
  315. return json_success(UsersServer::propertyList($property_user_id), '获取成功');
  316. }
  317. /**
  318. * Notes:会员导入功能
  319. * @return \support\Response
  320. * @throws \Exception
  321. * User: ZQ
  322. * Date: 2022/12/1
  323. */
  324. public function userExcelImport()
  325. {
  326. $excel_address = $this->request->get('excel_address');//文件地址;
  327. //$excel_address = iconv("utf-8", "gb2312", $excel_address);
  328. $admin_id = $this->request->admin_id;
  329. require_once 'vendor/phpoffice/phpexcel/Classes/PHPExcel.php';
  330. require_once 'vendor/phpoffice/phpexcel/Classes/PHPExcel/IOFactory.php';
  331. $objPHPExcel = \PHPExcel_IOFactory::load($excel_address);
  332. // 逐行读取 sheet 内的内容(常用)
  333. foreach ($objPHPExcel->getworksheetiterator() as $sheet){ //循环sheet
  334. foreach ($sheet->getrowiterator() as $row){ //循环row
  335. if ($row->getrowindex() < 2){ // 默认从第二行开始
  336. continue;
  337. }
  338. foreach ($row->getcelliterator() as $cell){ //循环cell
  339. $data[] = $cell->getvalue();
  340. }
  341. if(!empty($data)){
  342. $user_account = $data[0];
  343. $user_login_pwd = $data[1];
  344. $user_again_pwd = $data[1];
  345. $user_nickname = $data[2];
  346. $user_headimgurl = '';
  347. if ($data[3] == '男'){
  348. $user_sex = 0;
  349. }else{
  350. $user_sex = 1;
  351. }
  352. $user_birthday = $data[4];
  353. $user_age = $data[5];
  354. $user_register_address = $data[6];
  355. $user_phone = $data[7];
  356. $user_status = 0;
  357. $user_real_name = $data[8];
  358. $user_card_id = $data[9];
  359. $user_certinfo = ['http://op.wanyuewellness.cn/idcardUp.jpg','http://op.wanyuewellness.cn/idcardDown.jpg'];
  360. /*if ($data[10] == "否"){
  361. $user_is_owner = 0;
  362. }elseif ($data[10] == "准业主"){
  363. $user_is_owner = 1;
  364. }elseif ($data[10] == "业主"){
  365. $user_is_owner = 2;
  366. }*/
  367. $user_is_owner = 0;
  368. if (!empty($user_real_name) && !empty($user_card_id)){
  369. $user_type = 1;
  370. }else{
  371. $user_type = 0;
  372. }
  373. $user_spread_uid = '';
  374. $user_source = $data[10];
  375. $user_register_type = 2;
  376. //var_dump($data);
  377. unset($data);
  378. UsersServer::userInsert($user_account,$user_login_pwd,$user_again_pwd,$user_nickname,$user_headimgurl,$user_sex,$user_birthday,$user_age,$user_register_address,$user_phone,$user_status,$user_real_name,$user_card_id,$user_certinfo,$user_is_owner,$user_type,$user_spread_uid,$user_source,$admin_id,$user_register_type);
  379. }else{
  380. throw new \Exception('读取失败');
  381. }
  382. }
  383. }
  384. return json_success('', '导入成功');
  385. }
  386. /**
  387. * Notes:添加医生医嘱
  388. * @return \support\Response
  389. * @throws \Exception
  390. * User: ZQ
  391. * Date: 2022/12/8
  392. */
  393. public function userDoctorLog()
  394. {
  395. $log_user_id = $this->request->post('log_user_id');
  396. $log_type = $this->request->post('log_type');
  397. $log_equipment_id = $this->request->post('log_equipment_id');
  398. $log_doctor_id = $this->request->post('log_doctor_id');
  399. $log_subject_id = $this->request->post('log_subject_id');
  400. $log_message = $this->request->post('log_message','');
  401. $log_resolvent = $this->request->post('log_resolvent','');
  402. $admin_id = $this->request->admin_id;
  403. $this->validateCheck('user\UserValidate', ['log_user_id' => $log_user_id, 'log_type' => $log_type, 'log_doctor_id' => $log_doctor_id, 'log_subject_id' => $log_subject_id], 'userDocter');
  404. $data = UsersServer::doctorInsert($log_user_id, $log_type, $log_equipment_id, $log_doctor_id, $log_subject_id, $log_message, $log_resolvent, $admin_id);
  405. return json_success($data, '添加成功');
  406. }
  407. /**
  408. * Notes:会员医生医嘱列表
  409. * @return \support\Response
  410. * @throws \Exception
  411. * User: ZQ
  412. * Date: 2022/12/8
  413. */
  414. public function userDoctorList()
  415. {
  416. $log_user_id = $this->request->get('log_user_id');
  417. [$page, $limit] = $this->getPage();
  418. $this->validateCheck('user\UserValidate', ['log_user_id' => $log_user_id], 'DocterList');
  419. return json_success(UsersServer::doctorList($log_user_id, $page, $limit), '成功');
  420. }
  421. /**
  422. * Notes:删除会员医生医嘱
  423. * @return \support\Response
  424. * @throws \Exception
  425. * User: ZQ
  426. * Date: 2022/12/8
  427. */
  428. public function userDoctorDel()
  429. {
  430. $log_user_id = $this->request->get('log_user_id');
  431. $log_id = $this->request->get('log_id');
  432. $admin_id = $this->request->admin_id;
  433. $this->validateCheck('user\UserValidate', ['log_user_id' => $log_user_id, 'log_id' => $log_id], 'DocterDel');
  434. return json_success(UsersServer::doctorDel($log_user_id, $log_id, $admin_id), '删除成功');
  435. }
  436. /**
  437. * Notes:修改会员健康基础数据
  438. * @return \support\Response
  439. * @throws \Exception
  440. * User: ZQ
  441. * Date: 2022/12/8
  442. */
  443. public function userHealthyDataUpdate()
  444. {
  445. $data_user_id = $this->request->post('data_user_id');
  446. $data_Inspection_suggestions = $this->request->post('data_Inspection_suggestions','');
  447. $data_bone_density = $this->request->post('data_bone_density','');
  448. $data_tcm_testing = $this->request->post('data_tcm_testing','');
  449. $admin_id = $this->request->admin_id;
  450. $this->validateCheck('user\UserValidate', ['data_user_id' => $data_user_id], 'healthyDel');
  451. return json_success(UsersServer::healthyUpdate($data_user_id, $data_Inspection_suggestions, $data_bone_density, $data_tcm_testing, $admin_id), '修改成功');
  452. }
  453. /**
  454. * Notes:删除会员健康基础数据
  455. * @return \support\Response
  456. * @throws \Exception
  457. * User: ZQ
  458. * Date: 2022/12/8
  459. */
  460. public function userHealthyDataDel()
  461. {
  462. $data_user_id = $this->request->get('data_user_id');
  463. $admin_id = $this->request->admin_id;
  464. $this->validateCheck('user\UserValidate', ['data_user_id' => $data_user_id], 'healthyDel');
  465. return json_success(UsersServer::healthyDel($data_user_id, $admin_id), '删除成功');
  466. }
  467. /**
  468. * Notes:查询会员健康基础数据
  469. * @return \support\Response
  470. * @throws \Exception
  471. * User: ZQ
  472. * Date: 2022/12/8
  473. */
  474. public function userHealthyData()
  475. {
  476. $data_user_id = $this->request->get('data_user_id');
  477. $this->validateCheck('user\UserValidate', ['data_user_id' => $data_user_id], 'healthyDel');
  478. return json_success(UsersServer::healthyInfo($data_user_id), '成功');
  479. }
  480. }