123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474 |
- <?php
- namespace app\admin\controller\user;
- use app\admin\controller\BaseController;
- use app\admin\server\user\UsersServer;
- use PhpOffice\PhpSpreadsheet\Helper\Sample;
- use PhpOffice\PhpSpreadsheet\IOFactory;
- use PhpOffice\PhpSpreadsheet\Spreadsheet;
- use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
- use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
- use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
- use PhpOffice\PhpSpreadsheet\Cell\DataType;
- use PhpOffice\PhpSpreadsheet\Style\Fill;
- use PhpOffice\PhpSpreadsheet\Style\Color;
- use PhpOffice\PhpSpreadsheet\Style\Alignment;
- use PhpOffice\PhpSpreadsheet\Style\Border;
- /**
- * 会员
- * Class Users
- * @package app\admin\controller\user
- */
- class Users extends BaseController
- {
- /**
- * Notes:获取用户信息
- * @return \support\Response
- * User: yym
- * Date: 2022/7/26
- */
- public function getUserInfo()
- {
- $user_id = $this->request->get('user_id');
- $this->validateCheck('user\UserValidate', ['user_id' => $user_id], 'info');
- return json_success(UsersServer::getUserInfo($user_id), '成功');
- }
- /**
- * Notes:会员列表
- * @return \support\Response
- * User: yym
- * Date: 2022/8/4
- */
- public function getUserList()
- {
- $keywords = (string)$this->request->get('keywords', '');//搜索内容
- $category = (int)$this->request->get('category', '');//会员类型
- $status = (int)$this->request->get('status', '');//会员状态
- [$page, $limit] = $this->getPage();
- return json_success(UsersServer::getUserList($keywords, $category, $status, $page, $limit), '获取成功');
- }
- /**
- * Notes:添加会员
- * @return \support\Response
- * User: ZQ
- * Date: 2022/11/21
- */
- public function userInsert()
- {
- $user_account = $this->request->post('user_account');
- $user_login_pwd = $this->request->post('user_login_pwd');
- $user_again_pwd = $this->request->post('user_again_pwd');
- $user_nickname = $this->request->post('user_nickname','');
- $user_headimgurl = $this->request->post('user_headimgurl','');
- $user_sex = $this->request->post('user_sex');
- $user_birthday = $this->request->post('user_birthday');
- $user_age = $this->request->post('user_age','');
- $user_register_address = $this->request->post('user_register_address','');
- $user_phone = $this->request->post('user_phone','');
- $user_status = $this->request->post('user_status');
- $user_real_name = $this->request->post('user_real_name','');
- $user_card_id = $this->request->post('user_card_id','');
- $user_certinfo = $this->request->post('user_certinfo','');
- $user_is_owner = $this->request->post('user_is_owner');
- $user_type = $this->request->post('user_type','');
- $user_spread_uid = $this->request->post('user_spread_uid','');
- $user_source = $this->request->post('user_source');
- $user_register_type = 1;
- $admin_id = $this->request->admin_id;
- $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');
- if ($user_type == 1){
- $this->validateCheck('user\UserValidate',['user_real_name'=>$user_real_name,'user_card_id'=>$user_card_id,'user_certinfo'=>$user_certinfo],'userAuth');
- }
- 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), '添加成功');
- }
- /**
- * Notes:会员认证审核
- * @return \support\Response
- * User: yym
- * Date: 2022/8/4
- */
- public function authUser()
- {
- $user_id = $this->request->post('user_id');//会员编号
- $status = $this->request->post('status');//审核状态 0=待审核 1=审核通过 2=审核驳回 3=主动撤销
- $content = $this->request->post('content', '');//审核意见
- $category = $this->request->post('category');//分类 实名认证、会员升级
- $admin_id = $this->request->admin_id;
- $this->validateCheck('user\UserValidate', ['user_id' => $user_id, 'status' => $status, 'content' => $content, 'category' => $category], 'auth');
- UsersServer::authUser($admin_id, $user_id, $status, $content, $category);
- return json_success([], '操作成功');
- }
- /**
- * Notes:获取会员体检信息
- * @return \support\Response
- * @throws \Exception
- * User: yym
- * Date: 2022/9/21
- */
- public function getUserReport()
- {
- $user_id = $this->request->get('user_id');//会员编号
- $this->validateCheck('user\UserValidate', ['user_id' => $user_id], 'report');
- return json_success(UsersServer::getUserReport($user_id), '获取成功');
- }
- /**
- * Notes:获取会员设备列表
- * @return \support\Response
- * @throws \Exception
- * User: ZQ
- * Date: 2022/9/22
- */
- public function getUserEquipment()
- {
- [$page, $limit] = $this->getPage();
- $equipment_user_id = $this->request->get('user_id');
- $equipment_class = $this->request->get('equipment_class');
- $equipment_name = $this->request->get('equipment_name');
- return json_success(UsersServer::getUserEquipment($page,$limit,$equipment_user_id,$equipment_name,$equipment_class), '获取成功');
- }
- /**
- * Notes:获取会员设备详情
- * @return \support\Response
- * @throws \Exception
- * User: ZQ
- * Date: 2022/9/22
- */
- public function userEquipmentInfo()
- {
- $equipment_id = $this->request->get('equipment_id');
- $this->validateCheck('intelligence\UserValidate', ['equipment_id' => $equipment_id], 'info');
- return json_success(UsersServer::userEquipmentInfo($equipment_id), '获取成功');
- }
- /**
- * Notes:获取会员下的智能产品设备列表
- * @return \support\Response
- * @throws \Exception
- * User: ZQ
- * Date: 2022/11/15
- */
- public function equipmentList()
- {
- $equipment_user_id = $this->request->get('equipment_user_id');
- return json_success(UsersServer::equipmentList($equipment_user_id), '获取成功');
- }
- /**
- * Notes:添加会员智能产品设备
- * @return \support\Response
- * User: ZQ
- * Date: 2022/11/14
- */
- public function userEquipmentInsert()
- {
- $equipment_intelligence_id = $this->request->post('equipment_intelligence_id');
- $equipment_user_id = $this->request->post('equipment_user_id');
- $equipment_name = $this->request->post('equipment_name', '');
- $equipment_only = $this->request->post('equipment_only');
- $equipment_type = $this->request->post('equipment_type');
- $equipment_class = $this->request->post('equipment_class');
- $equipment_status = $this->request->post('equipment_status');
- $equipment_tripartite_sn = $this->request->post('equipment_tripartite_sn');
- $equipment_property_id = $this->request->post('equipment_property_id', '');
- $admin_id = $this->request->admin_id;
- //查询智能设备唯一编号equipment_only是否重复
- $check = UsersServer::equipmentCheck($equipment_only);
- if (!empty($check)){
- throw new \Exception('智能设备唯一编号已存在!');
- }
- $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);
- return json_success($result, '添加成功');
- }
- /**
- * Notes:删除会员智能产品设备
- * @return \support\Response
- * User: ZQ
- * Date: 2022/11/14
- */
- public function userEquipmentDelete()
- {
- $equipment_id = $this->request->get('equipment_id');
- $admin_id = $this->request->admin_id;
- $this->validateCheck('user\UserValidate', ['equipment_id' => $equipment_id], 'equipmentDel');
- return json_success(UsersServer::equipmentDel($equipment_id,$admin_id), '删除成功');
- }
- /**
- * Notes:获取会员消息列表
- * @return \support\Response
- * @throws \Exception
- * User: ZQ
- * Date: 2022/9/22
- */
- public function userEquipmentLog()
- {
- [$page, $limit] = $this->getPage();
- $log_user_id = $this->request->get('log_user_id');
- $log_equipment_id = $this->request->get('log_equipment_id');
- return json_success(UsersServer::getEquipmentLog($page,$limit,$log_user_id,$log_equipment_id), '获取成功');
- }
- /**
- * Notes:获取会员消息详情
- * @return \support\Response
- * @throws \Exception
- * User: ZQ
- * Date: 2022/9/22
- */
- public function equipmentLogInfo()
- {
- $log_id = $this->request->get('log_id');
- $this->validateCheck('intelligence\LogValidate', ['log_id' => $log_id], 'info');
- return json_success(UsersServer::equipmentLogInfo($log_id), '获取成功');
- }
- /**
- * Notes:赠送会员权益包
- * @return \support\Response
- * User: yym
- * Date: 2022/11/21
- */
- public function givePackage()
- {
- $user_id = $this->request->post('user_id');//会员编号
- $package_id = $this->request->post('package_id');//套餐包编号
- $type = $this->request->post('type');//
- $admin_id = $this->request->admin_id;
- $this->validateCheck('package\PackageValidate', ['package_id' => $package_id, 'user_id' => $user_id, 'type' => $type], 'give');
- UsersServer::givePackage($user_id, $package_id, $type, $admin_id);
- return json_success([], '赠送成功');
- }
- /**
- * Notes:获取会员下的亲属关系列表
- * @return \support\Response
- * @throws \Exception
- * User: ZQ
- * Date: 2022/9/22
- */
- public function relativesList()
- {
- $relatives_user_id = $this->request->get('relatives_user_id');
- return json_success(UsersServer::relativesList($relatives_user_id), '获取成功');
- }
- /**
- * Notes:获取会员亲属关系列表
- * @return \support\Response
- * @throws \Exception
- * User: ZQ
- * Date: 2022/9/22
- */
- public function relativesToList()
- {
- [$page, $limit] = $this->getPage();
- $keywords = (string)$this->request->get('keywords', '');//搜索内容
- return json_success(UsersServer::relativesToList($page,$limit,$keywords), '获取成功');
- }
- /**
- * Notes:删除会员亲属关系
- * @return \support\Response
- * @throws \Exception
- * User: ZQ
- * Date: 2022/9/22
- */
- public function relativesDel()
- {
- $relatives_id = $this->request->get('relatives_id');
- $admin_id = $this->request->admin_id;
- $this->validateCheck('user\UserValidate', ['relatives_id' => $relatives_id], 'relatives');
- return json_success(UsersServer::relativesDel($relatives_id,$admin_id), '删除成功');
- }
- /**
- * Notes:获取会员固定资产列表
- * @return \support\Response
- * @throws \Exception
- * User: ZQ
- * Date: 2022/11/23
- */
- public function propertyList()
- {
- $property_user_id = $this->request->get('property_user_id');//会员id
- $this->validateCheck('user\UserValidate', ['user_id' => $property_user_id], 'info');
- return json_success(UsersServer::propertyList($property_user_id), '获取成功');
- }
- /**
- * Notes:会员导入功能
- * @return \support\Response
- * @throws \Exception
- * User: ZQ
- * Date: 2022/12/1
- */
- public function userExcelImport()
- {
- $excel_address = $this->request->get('excel_address');//文件地址;
- //$excel_address = iconv("utf-8", "gb2312", $excel_address);
- $admin_id = $this->request->admin_id;
- require_once 'vendor/phpoffice/phpexcel/Classes/PHPExcel.php';
- require_once 'vendor/phpoffice/phpexcel/Classes/PHPExcel/IOFactory.php';
- $objPHPExcel = \PHPExcel_IOFactory::load($excel_address);
- // 逐行读取 sheet 内的内容(常用)
- foreach ($objPHPExcel->getworksheetiterator() as $sheet){ //循环sheet
- foreach ($sheet->getrowiterator() as $row){ //循环row
- if ($row->getrowindex() == 1){ // 默认从第二行开始
- continue;
- }
- foreach ($row->getcelliterator() as $cell){ //循环cell
- $data[] = $cell->getvalue();
- }
- if(!empty($data)){
- $user_account = $data[0];
- $user_login_pwd = $data[1];
- $user_again_pwd = $data[1];
- $user_nickname = $data[2];
- $user_headimgurl = '';
- if ($data[3] == '男'){
- $user_sex = 0;
- }else{
- $user_sex = 1;
- }
- $user_birthday = $data[4];
- $user_age = $data[5];
- $user_register_address = $data[6];
- $user_phone = $data[7];
- $user_status = 0;
- $user_real_name = $data[8];
- $user_card_id = $data[9];
- $user_certinfo = ['http://op.wanyuewellness.cn/idcardUp.jpg','http://op.wanyuewellness.cn/idcardDown.jpg'];
- if ($data[10] == '否'){
- $user_is_owner = 0;
- }elseif ($data[10] == '准业主'){
- $user_is_owner = 1;
- }elseif ($data[10] == '业主'){
- $user_is_owner = 2;
- }
- if (!empty($user_real_name) && !empty($user_card_id)){
- $user_type = 1;
- }else{
- $user_type = 0;
- }
- $user_spread_uid = '';
- $user_source = 'app';
- $user_register_type = 2;
- 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);
- }
- }
- }
- return json_success('', '导入成功');
- }
- /**
- * Notes:添加医生医嘱
- * @return \support\Response
- * @throws \Exception
- * User: ZQ
- * Date: 2022/12/8
- */
- public function userDoctorLog()
- {
- $log_user_id = $this->request->post('log_user_id');
- $log_type = $this->request->post('log_type');
- $log_doctor_id = $this->request->post('log_doctor_id');
- $log_subject_id = $this->request->post('log_subject_id');
- $log_message = $this->request->post('log_message','');
- $log_resolvent = $this->request->post('log_resolvent','');
- $admin_id = $this->request->admin_id;
- $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');
- $data = UsersServer::doctorInsert($log_user_id, $log_type, $log_doctor_id, $log_subject_id, $log_message, $log_resolvent, $admin_id);
- return json_success($data, '添加成功');
- }
- /**
- * Notes:会员医生医嘱列表
- * @return \support\Response
- * @throws \Exception
- * User: ZQ
- * Date: 2022/12/8
- */
- public function userDoctorList()
- {
- $log_user_id = $this->request->get('log_user_id');
- [$page, $limit] = $this->getPage();
- $this->validateCheck('user\UserValidate', ['log_user_id' => $log_user_id], 'DocterList');
- return json_success(UsersServer::doctorList($log_user_id, $page, $limit), '成功');
- }
- /**
- * Notes:删除会员医生医嘱
- * @return \support\Response
- * @throws \Exception
- * User: ZQ
- * Date: 2022/12/8
- */
- public function userDoctorDel()
- {
- $log_user_id = $this->request->get('log_user_id');
- $log_id = $this->request->get('log_id');
- $admin_id = $this->request->admin_id;
- $this->validateCheck('user\UserValidate', ['log_user_id' => $log_user_id, 'log_id' => $log_id], 'DocterDel');
- return json_success(UsersServer::doctorDel($log_user_id, $log_id, $admin_id), '删除成功');
- }
- /**
- * Notes:修改会员健康基础数据
- * @return \support\Response
- * @throws \Exception
- * User: ZQ
- * Date: 2022/12/8
- */
- public function userHealthyDataUpdate()
- {
- $data_user_id = $this->request->post('data_user_id');
- $data_Inspection_suggestions = $this->request->post('data_Inspection_suggestions','');
- $data_bone_density = $this->request->post('data_bone_density','');
- $data_tcm_testing = $this->request->post('data_tcm_testing','');
- $admin_id = $this->request->admin_id;
- $this->validateCheck('user\UserValidate', ['data_user_id' => $data_user_id], 'healthyDel');
- return json_success(UsersServer::healthyUpdate($data_user_id, $data_Inspection_suggestions, $data_bone_density, $data_tcm_testing, $admin_id), '修改成功');
- }
- /**
- * Notes:删除会员健康基础数据
- * @return \support\Response
- * @throws \Exception
- * User: ZQ
- * Date: 2022/12/8
- */
- public function userHealthyDataDel()
- {
- $data_user_id = $this->request->get('data_user_id');
- $admin_id = $this->request->admin_id;
- $this->validateCheck('user\UserValidate', ['data_user_id' => $data_user_id], 'healthyDel');
- return json_success(UsersServer::healthyDel($data_user_id, $admin_id), '删除成功');
- }
- /**
- * Notes:查询会员健康基础数据
- * @return \support\Response
- * @throws \Exception
- * User: ZQ
- * Date: 2022/12/8
- */
- public function userHealthyData()
- {
- $data_user_id = $this->request->get('data_user_id');
- $this->validateCheck('user\UserValidate', ['data_user_id' => $data_user_id], 'healthyDel');
- return json_success(UsersServer::healthyInfo($data_user_id), '成功');
- }
- }
|