Users - 副本.php 19 KB

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