diff --git a/application/DeviceEnter/controller/Base.php b/application/DeviceEnter/controller/Base.php new file mode 100644 index 0000000..e3f746e --- /dev/null +++ b/application/DeviceEnter/controller/Base.php @@ -0,0 +1,185 @@ +'关键参数缺失', + '10002'=>'操作失败', + '10003'=>'信息核实错误', + '10004'=>'未找到有效数据', + '10005'=>'参数格式错误', + '10006'=>'参数不能为空', + '10007'=>'参数错误', + '10008'=>'', + '10009'=>'', + '10010'=>'自定义信息', + '20001'=>'登录失效', + '99999'=>'网络异常,请稍后重试', + ]; + // 加 bcadd(,,20) + // 减 bcsub(,,20) + // 乘 bcmul(,,20) + // 除 bcdiv(,,20) + ################################################################接口################################################################ + ################################################################接口################################################################ + ################################################################接口################################################################ + // 接口记录 + public function record_api_log($params, $error = null, $response = null){ + // dump($params); + // dump($error); + // die; + $logContent = "接口请求参数:" . json_encode($params, JSON_UNESCAPED_UNICODE) . PHP_EOL; + if ($error) { + $logContent .= "错误信息:" . $error['all_content'] . PHP_EOL; + if(!cache($error['flie']."_".$error['line'])){ + cache($error['flie']."_".$error['line'],"API错误",3600); + $this->send_email_api_error(["tsf3920322@126.com"],['title'=>'接口报错','from_user_name'=>'设备录入','content'=>$logContent]); + } + } + if ($response) { + $logContent .= "返回信息:" . json_encode($response, JSON_UNESCAPED_UNICODE) . PHP_EOL; + } + // 使用ThinkPHP的日志记录方法 + Log::record($logContent, 'api_log'); + } + + /* 接口说明(发邮件) + * $address(收件人的邮箱地址) 数组 格式: ['460834639@qq.com','460834639@qq.com'.......] + * $content(邮件的主题数据信息) 数组 格式:['title'=>'123','from_user_name'=>'123','content'=>'123'] + * $annex(附件路径信息) 字符串 + */ + public function send_email_api_error($address,$content,$annex=''){ + // $ad = '460834639@qq.com'; + $ad1 = '295155911@qq.com'; + $mail = new PHPMailer(); //实例化 + $mail->IsSMTP(); // 启用SMTP + $mail->Host = "smtp.126.com"; //SMTP服务器 163邮箱例子 + $mail->Port = 465; //邮件发送端口 + $mail->SMTPAuth = true; //启用SMTP认证 + $mail->SMTPSecure = 'ssl'; + $mail->CharSet = "UTF-8"; //字符集 + $mail->Encoding = "base64"; //编码方式 + $mail->Username = "tsf3920322@126.com"; //你的邮箱 + $mail->Password = "HLWXNRPUCTHJFIIX"; //你的密码(邮箱后台的授权密码) + $mail->From = "tsf3920322@126.com"; //发件人地址(也就是你的邮箱) + + // $mail->Subject = "微盟测试邮件"; //邮件标题 + $mail->Subject = $content['title']; //邮件标题 + + // $mail->FromName = "微盟体测中心"; //发件人姓名 + $mail->FromName = $content['from_user_name']; //发件人姓名 + + + for ($i=0; $i < count($address); $i++) { + $mail->AddAddress($address[$i], ""); //添加收件人(地址,昵称) + } + + if($annex != ''){ + // $url = ROOT_PATH. 'public' . DS . 'tsf' . DS .'demoooo.jpg'; + $mail->AddAttachment($annex,''); // 添加附件,并指定名称 + } + + $mail->IsHTML(true); //支持html格式内容 + + $neirong = $content['content']; + + $mail->Body = $neirong; //邮件主体内容 + //发送 + if (!$mail->Send()) { + + return ['code' => 10003,'msg'=>$mail->ErrorInfo]; + // return $mail->ErrorInfo; + } else { + return ['code' => 0]; + // return 'success'; + } + } + + + // 验证 + public function verify_data_is_ok($data = 2,$type){ + if($type == 'str'){ + if (is_string($data)) { + return true; + } else { + $this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为字符串',[]]); + return false; + } + }else if($type == 'num'){ + if (is_numeric($data)) { + return true; + } else { + $this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为数字',[]]); + return false; + } + }else if($type == 'intnum'){ + $pattern = '/^\d+$/'; + // dump($data); + if (preg_match($pattern, $data)) { + return true; // 匹配成功,返回 true + } else { + $this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为整数数字',[]]); + return false; // 匹配失败,返回 false + } + }else if($type == 'datetime'){ + $formats = ['Y-m-d','Y-m-d H:i:s']; + foreach ($formats as $format) { + $dateTime = \DateTime::createFromFormat($format, $data); + // 检查时间字符串是否成功解析,并且解析后的日期时间与原始字符串表示的时间一致 + if ($dateTime && $dateTime->format($format) === $data) { + return true; + } + } + // 如果所有格式都解析失败,则返回 false + $this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为日期格式',[]]); + return false; + }else if($type == 'other'){ + + } + + } + + + + public function msg($data,$str='',$result = []){ + if(is_array($data)){ + if($str != ''){ + return json(['code'=>0,'msg'=>$str,'data'=>$data]); + }else{ + return json(['code'=>0,'msg'=>'操作成功','data'=>$data]); + } + }else{ + if($str != ''){ + return json(['code'=>$data,'msg'=>$str,'data'=>$result]); + } + return json(['code'=>$data,'msg'=>$this->return_data_all[$data],'data'=>$result]); + } + } + + public function generateRandomString($length = 10) { + $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + return $randomString; + } + + + public function ceshi(){ + echo 'hello'; + } + + +} \ No newline at end of file diff --git a/application/DeviceEnter/controller/Savemsg.php b/application/DeviceEnter/controller/Savemsg.php new file mode 100644 index 0000000..e9bef3b --- /dev/null +++ b/application/DeviceEnter/controller/Savemsg.php @@ -0,0 +1,167 @@ +'c03', + ], + + ]; + protected $name_default = 0; + // 加 bcadd(,,20) + // 减 bcsub(,,20) + // 乘 bcmul(,,20) + // 除 bcdiv(,,20) + ################################################################百度接口################################################################ + ################################################################百度接口################################################################ + ################################################################百度接口################################################################ + + // 获取配置信息 + public function config_msg(){ + try { + $result = $this->config_msg_action(); + return $this->msg($result); + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "函数名: " . __FUNCTION__ . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + $this->record_api_log($data, $logContent, null); + return $this->msg(99999); + } + + } + + public function save_device_msg($data = ['mac'=>'564654564654654','device_name'=>'bl_5520','batch_code'=>'bc250826']){ + try { + // 你的业务逻辑 + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('mac', $data)){ + return $this->msg(10001); + } + if(!array_key_exists('device_name', $data)){ + return $this->msg(10001); + } + if(!array_key_exists('batch_code', $data)){ + return $this->msg(10001); + } + if(!$this->verify_data_is_ok($data['mac'],'str')){ + return $this->msg(10005); + } + if(!$this->verify_data_is_ok($data['device_name'],'str')){ + return $this->msg(10005); + } + if(!$this->verify_data_is_ok($data['batch_code'],'str')){ + return $this->msg(10005); + } + $result = $this->save_device_msg_action($data); + return $result; + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "函数名: " . __FUNCTION__ . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + // dump($data); + // die; + $this->record_api_log($data, $logContent, null); + return $this->msg(99999); + } + + } + + public function device_batch_list(){ + // try { + + $result = $this->device_batch_list_action(); + return $result; + // } catch (\Exception $e) { + // // 捕获异常 + // $logContent["flie"] = $e->getFile(); + // $logContent["line"] = $e->getLine(); + // $logContent['all_content'] = "异常信息:\n"; + // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + // $logContent['all_content'] .= "函数名: " . __FUNCTION__ . "\n"; + // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + // // dump($data); + // // die; + // $this->record_api_log([], $logContent, null); + // return $this->msg(99999); + // } + + } + + + + + + + ########################################################################action######################################################################## + ########################################################################action######################################################################## + ########################################################################action######################################################################## + + public function config_msg_action(){ + $data = [ + 'name_list'=>$this->name_list, + 'name_default_key'=>$this->name_default, + + ]; + return $data; + } + + public function save_device_msg_action($data){ + $device_enter = Db::connect('device_enter_db'); + + $mac_code = $device_enter->table('device_C02pro')->where(['device_mac'=>$data['mac']])->count(); + if($mac_code > 0){ + return $this->msg(10002,'该MAC地址已录入'); + } + $result = $device_enter->table('device_C02pro')->insert([ + 'device_mac'=>$data['mac'], + 'device_name'=>$data['device_name'], + 'batch_code'=>$data['batch_code'], + 'create_time'=>date('Y-m-d H:i:s'), + ]); + if($result){ + return $this->msg([]); + }else{ + return $this->msg(10002); + } + } + + public function device_batch_list_action(){ + $device_enter = Db::connect('device_enter_db'); + $result = $device_enter->query(" + SELECT device_name, batch_code, COUNT(*) as num + FROM device_C02pro + GROUP BY batch_code,device_name + ORDER BY MAX(id) desc + "); + return $this->msg($result); + } + + +} \ No newline at end of file diff --git a/application/KitchenScale/controller/app/Aipart.php b/application/KitchenScale/controller/app/Aipart.php index 46c651d..9208c71 100644 --- a/application/KitchenScale/controller/app/Aipart.php +++ b/application/KitchenScale/controller/app/Aipart.php @@ -11,7 +11,7 @@ class Aipart extends Base{ protected $page_num = 10; protected $kitchenscale_db_msg = [ 'cookbook'=>'app_user_cookbook',//菜谱表 - 'foodlist3'=>'app_food_type_three',//食材列表3 + 'foodlist3'=>'app_z_national_standard_food_type_3',//食材列表3 'user'=>'app_user_data',//banner ]; diff --git a/application/KitchenScale/controller/app/Cookbook.php b/application/KitchenScale/controller/app/Cookbook.php index 5a76f76..af28f05 100644 --- a/application/KitchenScale/controller/app/Cookbook.php +++ b/application/KitchenScale/controller/app/Cookbook.php @@ -424,7 +424,7 @@ class Cookbook extends Base{ } } // 获取所有食材列表 - public function get_food_list($data=['food_level2_id'=>'4','search_data'=>'','page'=>1]){ + public function get_food_list($data=['food_level2_id'=>'2','search_data'=>'','page'=>1]){ // 尝试捕获异常 try { if(count(input('post.')) > 0){ @@ -1209,11 +1209,6 @@ class Cookbook extends Base{ $cp_page_num = 30; $cfc = Db::connect('cfc_db'); - // 获取食材分类列表start - // $foodlist1 = $cfc->table($this->kitchenscale_db_msg['foodlist1'])->where("is_del = 0")->field('id,name')->select(); - // $foodlist2 = $cfc->table($this->kitchenscale_db_msg['foodlist2'])->where("is_del = 0")->field('id,name,one_id')->select(); - // $foodlist3 = $cfc->table($this->kitchenscale_db_msg['foodlist3'])->where("is_del = 0")->field('id,name,two_id,kcal,unit')->select(); - $search_sql_str = "is_del = 0 AND two_id = ".$data['food_level2_id']; if(!array_key_exists('search_data', $data)){ $data['search_data'] = ""; @@ -1225,47 +1220,87 @@ class Cookbook extends Base{ } } $search_sql_str = $search_sql_str.$data['search_data']; - - // dump($data); - // dump($search_sql_str); + $content_num = $cfc->table($this->kitchenscale_db_msg['foodlist3']) - // ->alias('a') - // ->join($this->kitchenscale_db_msg['foodlist2'].' b','a.two_id = b.id','LEFT') - // ->join($this->kitchenscale_db_msg['foodlist1'].' c','b.one_id = c.id','LEFT') ->where($search_sql_str) ->count(); $page_total = ceil($content_num/$cp_page_num);; + $collect_list = $cfc->table($this->kitchenscale_db_msg['foodlist3']) - // ->alias('a') - // ->join($this->kitchenscale_db_msg['foodlist2'].' b','a.two_id = b.id','LEFT') - // ->join($this->kitchenscale_db_msg['foodlist1'].' c','b.one_id = c.id','LEFT') ->where($search_sql_str) - ->field('id,food_name as name,pic_url,Calorie_val as kcal,weight_unit as unit') + ->field('id,record_id,food_name as name,pic_url,Calorie_val as kcal,weight_unit as unit') ->page($data['page'],$cp_page_num) ->select(); - - + $nutrients_list_id = []; + $nutrients_list_temporary = []; foreach ($collect_list as $key => $value) { $collect_list[$key]['pic_url'] = "https://tc.pcxbc.com/kitchenscale_all".$collect_list[$key]['pic_url']; + array_push($nutrients_list_id,$collect_list[$key]['record_id']); + $nutrients_list_temporary[$collect_list[$key]['record_id']] = []; + if (!is_numeric($collect_list[$key]['kcal'])) { + $collect_list[$key]['kcal'] = 0; + } + } + + + // 处理营养物质 + $nutrients_list_data = $cfc->table($this->kitchenscale_db_msg['foodlist4']) + ->where("father_id in (". implode(',',$nutrients_list_id) .")") + ->field("father_id,name,name_ch,unit,value,type") + ->select(); + + // dump($collect_list); + // die; + + + for ($i=0; $i < count($nutrients_list_data); $i++) { + if(!is_numeric($nutrients_list_data[$i]['value']) || $nutrients_list_data[$i]['value'] == 0){ + continue; + }else{ + array_push($nutrients_list_temporary[$nutrients_list_data[$i]['father_id']],[ + 'name'=>$nutrients_list_data[$i]['name'], + 'name_ch'=>$nutrients_list_data[$i]['name_ch'], + 'unit'=>$nutrients_list_data[$i]['unit'], + 'value'=>$nutrients_list_data[$i]['value'], + 'type'=>$nutrients_list_data[$i]['type'], + 'type_name'=>$nutrients_list_data[$i]['type'] == 1?'能量及宏量营养素':($nutrients_list_data[$i]['type'] == 2?'维生素':'矿物质'), + 'color'=>$nutrients_list_data[$i]['type'] == 1?'#C4FFE0':($nutrients_list_data[$i]['type'] == 2?'#FFEFB7':'#7DA8E0') + ]); + } + } + // dump($nutrients_list_temporary); + // die; + for ($i=0; $i < count($collect_list); $i++) { + $collect_list[$i]['nutrients_four'] = []; + $collect_list[$i]['nutrients_list'] = []; + $temporary_calculate = 0; + if(array_key_exists($collect_list[$i]['record_id'],$nutrients_list_temporary)){ + $collect_list[$i]['nutrients_list'] = $nutrients_list_temporary[$collect_list[$i]['record_id']]; + foreach ($nutrients_list_temporary[$collect_list[$i]['record_id']] as $key => $value) { + if($value['type'] == 1){ + array_push($collect_list[$i]['nutrients_four'],[ + 'name'=>$value['name'] == 'Carbohydrate'?'碳水':$value['name_ch'], + 'unit'=>$value['unit'], + 'color'=>$value['name'] == 'Carbohydrate'?'#FFB169':($value['name'] == 'Fat'?'#ED7886':($value['name'] == 'Protein'?'#5180D8':'')), + 'value'=>!is_numeric($value['value'])?0:$value['value'], + ]); + // 如果不为卡路里 + if($value['name'] != 'Calorie'){ + $temporary_calculate = $temporary_calculate+$value['value']; + } + } + } + // 处理详情当中的环数据占比 + foreach ($collect_list[$i]['nutrients_four'] as $k => $v) { + if($v['name'] != '卡路里'){ + $collect_list[$i]['nutrients_four'][$k]['proportion'] = bcmul(bcdiv($v['value'],$temporary_calculate,2),100,0); + }else{ + $collect_list[$i]['nutrients_four'][$k]['proportion'] = 0; + } + } + } } - // $return_data = []; - // $temporary_arr = []; - // foreach ($collect_list as $key => $value) { - // unset($collect_list[$key]['ROW_NUMBER']); - // if(!array_key_exists($value['two_id'], $temporary_arr)){ - // $temporary_arr[$value['two_id']] = [ - // 'id'=>$value['two_id'], - // 'name'=>$value['two_name'], - // 'list'=>[['id'=>$value['id'],'name'=>$value['name'],'kcal'=>$value['kcal'],'unit'=>$value['unit']]], - // ]; - // }else{ - // array_push($temporary_arr[$value['two_id']]['list'],['id'=>$value['id'],'name'=>$value['name'],'kcal'=>$value['kcal'],'unit'=>$value['unit']]); - // } - // } - // foreach ($temporary_arr as $key => $value) { - // array_push($return_data,$value); - // } return $this->msg([ 'page_now'=>$data['page'], 'page_total'=>$page_total, diff --git a/application/KitchenScale/controller/app/Countfood.php b/application/KitchenScale/controller/app/Countfood.php index c9677dc..54554fe 100644 --- a/application/KitchenScale/controller/app/Countfood.php +++ b/application/KitchenScale/controller/app/Countfood.php @@ -18,7 +18,7 @@ class Countfood extends Base{ 'uploadimg'=>'app_user_upload_img',//素材表 'followlist'=>'app_user_follow_list',//关注列表 'collect_list'=>'app_user_collect_list',//收藏列表 - 'foodlist3'=>'app_standard_food_type_three',//食材列表3 + 'foodlist3'=>'app_z_national_standard_food_type_3',//食材列表3 'eat_log'=>'app_user_kcal_log',//食材列表3 'user'=>'app_user_data',//banner ]; @@ -74,7 +74,7 @@ class Countfood extends Base{ } } // 获取记食器板块内容 - public function get_countfoot_content($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','aud_id'=>61,'time'=>'2025-03-17']){ + public function get_countfoot_content($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','aud_id'=>1,'time'=>'2025-08-25']){ // 尝试捕获异常 try { if(count(input('post.')) > 0){ @@ -245,6 +245,48 @@ class Countfood extends Base{ return json(['status' => 'error', 'message' => '系统错误']); } } + public function del_user_eat_log($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','aud_id'=>6,'eat_log_id'=>160]){ + // 尝试捕获异常 + try { + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('token', $data)){ + return $this->msg(10001,'token is miss'); + } + if(!array_key_exists('aud_id', $data)){ + return $this->msg(10001,'aud_id is miss'); + } + if(!array_key_exists('eat_log_id', $data)){ + return $this->msg(10001,'eat_log_id is miss'); + } + if(!$this->verify_data_is_ok($data['token'],'str')){ + return $this->msg(10005,'token type is error'); + } + if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){ + return $this->msg(10005,'aud_id type is error'); + } + if(!$this->verify_data_is_ok($data['eat_log_id'],'num')){ + return $this->msg(10005,'eat_log_id type is error'); + } + + $return_data = $this->del_user_eat_log_action($data); + return $return_data; + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + // 记录日志 + $this->record_api_log($data, $logContent, null); + return json(['status' => 'error', 'message' => '系统错误']); + } + } #######################################################################action####################################################################### #######################################################################action####################################################################### #######################################################################action####################################################################### @@ -291,7 +333,7 @@ class Countfood extends Base{ $food_content = $cfc->table($this->kitchenscale_db_msg['foodlist3']) ->where("id in (".implode(',',$food_id_arr).")") - ->field('id,name,kcal,carbohydrate,protein,fat') + ->field('id,food_name as name,Calorie_val as kcal,Carbohydrate_val as carbohydrate,Protein_val as protein,Fat_val as fat') ->select(); // 整理食物信息 @@ -360,15 +402,26 @@ class Countfood extends Base{ $nutrition_data = $this->count_user_nutrition_all($user_data); if($user_data['is_use_set_kcal'] == 1){ + // 加 bcadd(,,20) + // 减 bcsub(,,20) + // 乘 bcmul(,,20) + // 除 bcdiv(,,20) + $proportion = bcdiv($user_data['set_kcal'],$nutrition_data['kcal'],20); $nutrition_data['kcal'] = $user_data['set_kcal']; + $nutrition_data['carbohydrate'] = bcmul($nutrition_data['carbohydrate'],$proportion,2); + $nutrition_data['protein'] = bcmul($nutrition_data['protein'],$proportion,2); + $nutrition_data['fat'] = bcmul($nutrition_data['fat'],$proportion,2); + } - // 查询用户今日摄入食物 $food_content = $cfc->table($this->kitchenscale_db_msg['eat_log']) - ->where("aud_id = " . $data['aud_id'] . " AND CAST(create_time AS DATE) = CAST('" . $data['time'] . "' AS DATE)") - ->field('meals_type,food_name,weight,kcal_val,carbohydrate_val,protein_val,fat_val') + ->alias('a') + ->join('app_z_national_standard_food_type_3 b','a.food_id = b.id','LEFT') + ->where("a.is_del = 0 AND a.aud_id = " . $data['aud_id'] . " AND CAST(a.create_time AS DATE) = CAST('" . $data['time'] . "' AS DATE)") + ->field('a.meals_type,a.food_name,a.weight,a.kcal_val,a.carbohydrate_val,a.protein_val,a.fat_val,a.id,\'https://tc.pcxbc.com\' + b.pic_url as pic_url') ->select(); - + // dump($food_content); + // die; $date = date('Y-m-d H:i:s'); $return_data = [ 'suggestion'=>[ @@ -435,22 +488,58 @@ class Countfood extends Base{ $return_data['today_intake']['fat'] = bcadd($return_data['today_intake']['fat'],$value['fat_val'],2); if($value['meals_type'] == '早餐'){ $return_data['list'][0]['val'] = bcadd($return_data['list'][0]['val'],$value['kcal_val'],2); - array_push($return_data['list'][0]['list'],['name'=>$value['food_name'],'weight'=>$value['weight'].'克','val'=>$value['kcal_val'].'kcal']); + array_push($return_data['list'][0]['list'],[ + 'name'=>$value['food_name'], + 'weight'=>$value['weight'].'克', + 'id'=>$value['id'], + 'pic_url'=>$value['pic_url'], + 'val'=>$value['kcal_val'].'kcal' + ]); }else if($value['meals_type'] == '午餐'){ $return_data['list'][1]['val'] = bcadd($return_data['list'][1]['val'],$value['kcal_val'],2); - array_push($return_data['list'][1]['list'],['name'=>$value['food_name'],'weight'=>$value['weight'].'克','val'=>$value['kcal_val'].'kcal']); + array_push($return_data['list'][1]['list'],[ + 'name'=>$value['food_name'], + 'weight'=>$value['weight'].'克', + 'id'=>$value['id'], + 'pic_url'=>$value['pic_url'], + 'val'=>$value['kcal_val'].'kcal' + ]); }else if($value['meals_type'] == '晚餐'){ $return_data['list'][2]['val'] = bcadd($return_data['list'][2]['val'],$value['kcal_val'],2); - array_push($return_data['list'][2]['list'],['name'=>$value['food_name'],'weight'=>$value['weight'].'克','val'=>$value['kcal_val'].'kcal']); + array_push($return_data['list'][2]['list'],[ + 'name'=>$value['food_name'], + 'weight'=>$value['weight'].'克', + 'id'=>$value['id'], + 'pic_url'=>$value['pic_url'], + 'val'=>$value['kcal_val'].'kcal' + ]); }else if($value['meals_type'] == '早加餐'){ $return_data['list'][3]['val'] = bcadd($return_data['list'][3]['val'],$value['kcal_val'],2); - array_push($return_data['list'][3]['list'],['name'=>$value['food_name'],'weight'=>$value['weight'].'克','val'=>$value['kcal_val'].'kcal']); + array_push($return_data['list'][3]['list'],[ + 'name'=>$value['food_name'], + 'weight'=>$value['weight'].'克', + 'id'=>$value['id'], + 'pic_url'=>$value['pic_url'], + 'val'=>$value['kcal_val'].'kcal' + ]); }else if($value['meals_type'] == '午加餐'){ $return_data['list'][4]['val'] = bcadd($return_data['list'][4]['val'],$value['kcal_val'],2); - array_push($return_data['list'][4]['list'],['name'=>$value['food_name'],'weight'=>$value['weight'].'克','val'=>$value['kcal_val'].'kcal']); + array_push($return_data['list'][4]['list'],[ + 'name'=>$value['food_name'], + 'weight'=>$value['weight'].'克', + 'id'=>$value['id'], + 'pic_url'=>$value['pic_url'], + 'val'=>$value['kcal_val'].'kcal' + ]); }else if($value['meals_type'] == '晚加餐'){ $return_data['list'][5]['val'] = bcadd($return_data['list'][5]['val'],$value['kcal_val'],2); - array_push($return_data['list'][5]['list'],['name'=>$value['food_name'],'weight'=>$value['weight'].'克','val'=>$value['kcal_val'].'kcal']); + array_push($return_data['list'][5]['list'],[ + 'name'=>$value['food_name'], + 'weight'=>$value['weight'].'克', + 'id'=>$value['id'], + 'pic_url'=>$value['pic_url'], + 'val'=>$value['kcal_val'].'kcal' + ]); }else{ } @@ -681,6 +770,17 @@ class Countfood extends Base{ return $this->msg(10002); } } + public function del_user_eat_log_action($data){ + $cfc = Db::connect('cfc_db'); + $user_data = $cfc->table($this->kitchenscale_db_msg['eat_log']) + ->where(["id"=>$data['eat_log_id']]) + ->update(['is_del'=>1]); + if($user_data){ + return $this->msg([]); + }else{ + return $this->msg(10002); + } + } #######################################################################工具####################################################################### #######################################################################工具####################################################################### @@ -751,4 +851,6 @@ class Countfood extends Base{ ]; } + + } \ No newline at end of file diff --git a/application/KitchenScale/controller/app/Usercenter.php b/application/KitchenScale/controller/app/Usercenter.php index f7eae3d..7437243 100644 --- a/application/KitchenScale/controller/app/Usercenter.php +++ b/application/KitchenScale/controller/app/Usercenter.php @@ -18,9 +18,9 @@ class Usercenter extends Base{ 'cookbook'=>'app_user_cookbook',//菜谱表 'cookbook_label'=>'app_user_cookbook_label',//菜谱标签表 'uploadimg'=>'app_user_upload_img',//图片素材表 - 'foodlist1'=>'app_food_type_one',//食材列表1 - 'foodlist2'=>'app_food_type_two',//食材列表2 - 'foodlist3'=>'app_food_type_three',//食材列表3 + 'foodlist1'=>'app_z_national_standard_food_type_1',//食材列表1 + 'foodlist2'=>'app_z_national_standard_food_type_2',//食材列表2 + 'foodlist3'=>'app_z_national_standard_food_type_3',//食材列表3 'collect_list'=>'app_user_collect_list',//点赞表 'banner'=>'app_banner_data',//banner 'user'=>'app_user_data',//banner diff --git a/application/ZengJieCode/controller/admin/Base.php b/application/ZengJieCode/controller/admin/Base.php new file mode 100644 index 0000000..8ecf21c --- /dev/null +++ b/application/ZengJieCode/controller/admin/Base.php @@ -0,0 +1,172 @@ +'test_app_data_log', + ]; + protected $return_data_all = [ + '10001'=>'关键参数缺失', + '10002'=>'操作失败', + '10003'=>'信息核实错误', + '10004'=>'未找到有效数据', + '10005'=>'参数格式错误', + '10006'=>'参数不能为空', + '10007'=>'参数错误', + '10008'=>'', + '10009'=>'', + '10010'=>'自定义信息', + '20001'=>'登录失效', + '99999'=>'网络异常,请稍后重试', + ]; + protected $file_max = 1024*1024*2;//xxxMB + // 加 bcadd(,,20) + // 减 bcsub(,,20) + // 乘 bcmul(,,20) + // 除 bcdiv(,,20) + ################################################################接口################################################################ + ################################################################接口################################################################ + ################################################################接口################################################################ + + + + // 验证 + public function verify_data_is_ok($data = 2,$type){ + if($type == 'str'){ + if (is_string($data)) { + return true; + } else { + $this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为字符串',[]]); + return false; + } + }else if($type == 'num'){ + if (is_numeric($data)) { + return true; + } else { + $this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为数字',[]]); + return false; + } + }else if($type == 'intnum'){ + $pattern = '/^\d+$/'; + if (preg_match($pattern, $data)) { + return true; // 匹配成功,返回 true + } else { + $this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为整数数字',[]]); + return false; // 匹配失败,返回 false + } + }else if($type == 'datetime'){ + $formats = ['Y-m-d','Y-m-d H:i:s']; + foreach ($formats as $format) { + $dateTime = \DateTime::createFromFormat($format, $data); + // 检查时间字符串是否成功解析,并且解析后的日期时间与原始字符串表示的时间一致 + if ($dateTime && $dateTime->format($format) === $data) { + return true; + } + } + // 如果所有格式都解析失败,则返回 false + $this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为日期格式',[]]); + return false; + }else if($type == 'other'){ + + } + } + + ####################################################图片选择上传start############################################################## + public function pic_index($page = 1) { + $data = input(); + $pd = true; + if(array_key_exists('page',$data)){ + $page = $data['page']; + $pd = false; + } + $cfc = Db::connect('cfc_db'); + $num = $cfc->table('app_user_upload_img')->where(['special_record_str'=>'admin'])->count(); + $result = $cfc->table('app_user_upload_img')->where(['special_record_str'=>'admin'])->order('id desc')->page($page,20)->field('id,pic_url')->select(); + if(!$pd){ + $return_result['num'] = $num; + $return_result['result'] = $result; + return $this->msg(0,'success',$return_result); + } + $this->assign([ + 'result' => $result, + 'num' => $num, + ]); + return $this->fetch(); + } + public function pic_upload_action(){ + + $save_data = []; + $error_data = []; + // 获取表单上传文件 + $files = request()->file('image'); + foreach($files as $file){ + $name = $file->getInfo()['name']; + // 使用 pathinfo() 函数获取文件名的扩展名 + $pathinfo = pathinfo($name); + $extension = strtolower($pathinfo['extension']); // 转换为小写以进行不区分大小写的比较 + $file_name = $pathinfo['filename']; + // 判断扩展名是否不是 .png 或 .gif + if ($extension !== 'png' && $extension !== 'gif') { + // 修改文件名,将扩展名改为 .jpg + $new_filename = date('YmdHis').$file_name . '.jpg'; + } else { + $new_filename = date('YmdHis').$name; + } + $info = $file->validate(['size'=>$this->file_max,'ext'=>'jpg,png,gif'])->move(ROOT_PATH . 'public' . DS . 'kitchenscale_all' . DS . 'user_upload',$new_filename); + if($info){ + array_push($save_data,[ + 'user_token'=>'caadd1be045a65f30b92aa805f1de54a', + 'pic_name'=>$new_filename, + 'pic_url'=>'https://tc.pcxbc.com/kitchenscale_all/user_upload/'.$new_filename, + 'create_time'=>date('Y-m-d H:i:s'), + 'special_record_str'=>'admin', + 'operate_log'=>1 + ]); + }else{ + array_push($error_data,[ + 'pic_name'=>$name, + 'error_msg'=>$file->getError(), + ]); + } + } + $cfc = Db::connect('cfc_db'); + $pic_result = $cfc->table('app_user_upload_img')->insertAll ($save_data); + if($pic_result){ + return $this->msg(['success'=>count($save_data),'error_data'=>$error_data]); + }else{ + for ($i=0; $i < count($save_data); $i++) { + unlink(ROOT_PATH . 'public' . DS . 'kitchenscale_all' . DS . 'user_upload' . DS . $new_filename); + } + return $this->msg(10002,'图片数据保存失败'); + } + } + + ####################################################图片选择上传end############################################################## + + + public function msg($data,$str='',$result = []){ + if(is_array($data)){ + if($str != ''){ + return json(['code'=>0,'msg'=>$str,'data'=>$data]); + }else{ + return json(['code'=>0,'msg'=>'操作成功','data'=>$data]); + } + }else{ + if($str != ''){ + return json(['code'=>$data,'msg'=>$str,'data'=>$result]); + } + return json(['code'=>$data,'msg'=>$this->return_data_all[$data],'data'=>$result]); + } + } + + + +} \ No newline at end of file diff --git a/application/ZengJieCode/controller/admin/Printaction.php b/application/ZengJieCode/controller/admin/Printaction.php new file mode 100644 index 0000000..e54caa1 --- /dev/null +++ b/application/ZengJieCode/controller/admin/Printaction.php @@ -0,0 +1,318 @@ + 'app_user_cookbook', // 菜谱表 + 'foodlist3' => 'app_z_national_standard_food_type_3', // 食材列表3 + 'user' => 'app_user_data', // banner + ]; + + // 自定义字体路径(相对于项目根目录) + protected $fontPath = 'public/tsf/jc.ttf'; // 请替换为你的字体文件路径 + + // 显示条形码生成页面 + public function print_device_barcode_index() + { + return $this->fetch(); + } + // 显示外箱码生成页面 + public function print_outside_box_index() + { + return $this->fetch(); + } + + public function print_device_barcode() + { + $zengjie = Db::connect('zengjie_db'); + $img_content = $zengjie->table('sn_code_all')->where(['is_print' => 0])->field('sn_code')->find(); + + if (empty($img_content)) { + return $this->msg(10002, '没有可用的条形码'); + } else { + $img_content = $img_content['sn_code']; + } + // dump($img_content); + // die; + return $this->barcode_action($img_content,1); + + } + public function print_scan_barcode() + { + $zengjie = Db::connect('zengjie_db'); + $img_content = $zengjie->table('sn_code_all')->where(['is_print' => 3])->field('sn_code')->find(); + + if (empty($img_content)) { + return $this->msg(10002, '没有可用的条形码'); + } else { + $img_content = $img_content['sn_code']; + } + return $this->barcode_action($img_content,4); + + } + + public function barcode_action($img_content,$typr_num_data){ + $zengjie = Db::connect('zengjie_db'); + $generator = new BarcodeGeneratorPNG(); + + try { + /******************************* + * 可调整参数区域 - 开始 + *******************************/ + + // 1. 字体文件路径 + $fontFile = ROOT_PATH . $this->fontPath; + + // 2. 图像尺寸参数 + $imageWidth = 709; // 图像宽度 + $imageHeight = 236; // 图像高度 + + // 3. 条形码参数 + $barcodeScaleFactor = 0.9; // 条形码缩放比例 (0-1) + $barcodeHeightScale = 1.5; // 条形码高度比例 + $barcodeYOffset = 10; // 条形码Y轴偏移量 + + // 4. 文本参数 + $textFontSize = 35; // 文本字体大小 + $textYOffset = 35; // 文本Y轴偏移量 + + // 5. 布局参数 + $topBoxRatio = 0.65; // 上区域高度比例 + $bottomBoxRatio = 0.25; // 下区域高度比例 + $verticalMargin = 0.05; // 垂直边距比例 + + /******************************* + * 可调整参数区域 - 结束 + *******************************/ + + // 生成条形码 + $barcodeData = $generator->getBarcode($img_content, BarcodeGeneratorPNG::TYPE_CODE_128); + $barcodeImage = imagecreatefromstring($barcodeData); + + // 创建画布 + $image = imagecreatetruecolor($imageWidth, $imageHeight); + $white = imagecolorallocate($image, 255, 255, 255); + $black = imagecolorallocate($image, 0, 0, 0); + imagefill($image, 0, 0, $white); + + // 计算布局区域 + $verticalSpace = $imageHeight * (1 - $verticalMargin * 2); + $topBoxHeight = $verticalSpace * $topBoxRatio; + $bottomBoxHeight = $verticalSpace * $bottomBoxRatio; + $startY = $imageHeight * $verticalMargin; + + // 处理条形码 + $barcodeWidth = imagesx($barcodeImage); + $barcodeHeight = imagesy($barcodeImage); + + $targetBarcodeWidth = $imageWidth * $barcodeScaleFactor; + $scale = $targetBarcodeWidth / $barcodeWidth; + $newBarcodeWidth = $targetBarcodeWidth; + $newBarcodeHeight = $barcodeHeight * $scale * $barcodeHeightScale; + + $resizedBarcode = imagecreatetruecolor($newBarcodeWidth, $newBarcodeHeight); + imagefill($resizedBarcode, 0, 0, $white); + imagecopyresampled($resizedBarcode, $barcodeImage, + 0, 0, 0, 0, + $newBarcodeWidth, $newBarcodeHeight, + $barcodeWidth, $barcodeHeight); + + // 放置条形码(上区域居中) + $barcodeX = ($imageWidth - $newBarcodeWidth) / 2; + $barcodeY = $startY + ($topBoxHeight - $newBarcodeHeight) / 2 + $barcodeYOffset; + imagecopy($image, $resizedBarcode, $barcodeX, $barcodeY, 0, 0, $newBarcodeWidth, $newBarcodeHeight); + + // 放置文本(下区域居中) + $textBox = imagettfbbox($textFontSize, 0, $fontFile, $img_content); + $textWidth = $textBox[2] - $textBox[0]; + $textHeight = $textBox[1] - $textBox[7]; + + $textX = ($imageWidth - $textWidth) / 2; + $textY = $startY + $topBoxHeight + ($bottomBoxHeight - $textHeight) / 2 + $textYOffset; + imagettftext($image, $textFontSize, 0, $textX, $textY, $black, $fontFile, $img_content); + + // 输出图像 + ob_start(); + imagepng($image); + $imageData = ob_get_clean(); + + // 标记为已打印 + $result1 = $zengjie->table('sn_code_all') + ->where(['sn_code' => $img_content]) + ->update(['is_print' => $typr_num_data]); + + if($result1){ + return $this->msg([ + 'image' => 'data:image/png;base64,' . base64_encode($imageData) + ]); + }else{ + return $this->msg(10002,'保存条码失败'); + } + + } catch (\Exception $e) { + return $this->msg(10003, "生成条形码失败: " . $e->getMessage()); + } + } + + public function print_combined_code() + { + $zengjie = Db::connect('zengjie_db'); + // 获取可以打印的大箱条形码信息 + $box_data = $zengjie->table('box_code_all')->where(['is_print' => 0])->field('id,box_code,box_num,content_str')->find(); + + $box_barcode_data = ''; + if (empty($box_data)) { + return $this->msg(10002, '没有可用的编码'); + } else { + $box_barcode_data = $box_data['box_code'].'-'.sprintf("%03d", (int)$box_data['box_num']); + } + // 获取大箱信息配套的sn二维码码信息 + // $sn_data = $zengjie->table('sn_code_all')->where(['batch_id' => $box_data['id']])->field('sn_code')->select(); + // $sn_qrcode_data = []; + // for ($i=0; $i < count($sn_data); $i++) { + // array_push($sn_qrcode_data,$sn_data[$i]['sn_code']); + // } + // $sn_qrcode_data = implode(',',$sn_qrcode_data); + + $sn_qrcode_data = $box_data['content_str']; + try { + /******************************* + * 可调整参数区域 - 开始 + *******************************/ + + // 1. 文字相关参数 + $fontFile = ROOT_PATH . $this->fontPath; // 字体文件路径 + + // "SN号集成码"文字参数 + $snTitleText = "SN号集成码"; + $snTitleFontSize = 31; // 字体大小 + $snTitleYPosition = 60; // Y轴位置 + + // "外箱条码"文字参数 + $boxTitleText = "外箱条码"; + $boxTitleFontSize = 31; // 字体大小 + $boxTitleYPosition = 460; // Y轴位置 + + // 外箱条码数字参数 + $barcodeTextFontSize = 25; // 字体大小 + $barcodeTextYPosition = 620; // Y轴位置 + + // 2. 二维码参数 + $qrCodeSize = 320; // 二维码尺寸 + $qrCodeMargin = 2; // 二维码边距 + $qrCodeYPosition = 90; // Y轴位置 + + // 3. 条形码参数 + $barcodeScaleFactor = 0.85; // 条形码缩放比例 (0-1) + $barcodeHeightScale = 2.0; // 条形码高度比例 (调整黑色条码高度) + $barcodeYPosition = 480; // Y轴位置 + + // 4. 图像尺寸参数 + $imageWidth = 543; // 图像宽度 (45mm @ 300dpi) + $imageHeight = 649; // 图像高度 (55mm @ 300dpi) + + /******************************* + * 可调整参数区域 - 结束 + *******************************/ + + // 生成二维码 + $qrCode = new QrCode($sn_qrcode_data); + $qrCode->setSize($qrCodeSize); + $qrCode->setMargin($qrCodeMargin); + $writer = new PngWriter(); + $qrCodeResult = $writer->write($qrCode); + $qrCodeData = $qrCodeResult->getString(); + + // 生成条形码 + $generator = new BarcodeGeneratorPNG(); + $barcodeData = $generator->getBarcode($box_barcode_data, BarcodeGeneratorPNG::TYPE_CODE_128); + + // 创建画布 + $image = imagecreatetruecolor($imageWidth, $imageHeight); + $white = imagecolorallocate($image, 255, 255, 255); + $black = imagecolorallocate($image, 0, 0, 0); + imagefill($image, 0, 0, $white); + + // 添加"SN号集成码"文字 + $snTitleBox = imagettfbbox($snTitleFontSize, 0, $fontFile, $snTitleText); + $snTitleWidth = $snTitleBox[2] - $snTitleBox[0]; + $snTitleX = ($imageWidth - $snTitleWidth) / 2; + imagettftext($image, $snTitleFontSize, 0, $snTitleX, $snTitleYPosition, $black, $fontFile, $snTitleText); + + // 添加二维码 + $qrcodeImage = imagecreatefromstring($qrCodeData); + $qrcodeWidth = imagesx($qrcodeImage); + $qrcodeHeight = imagesy($qrcodeImage); + + $targetQrcodeSize = $qrCodeSize; + $resizedQrcode = imagecreatetruecolor($targetQrcodeSize, $targetQrcodeSize); + imagefill($resizedQrcode, 0, 0, $white); + imagecopyresampled($resizedQrcode, $qrcodeImage, + 0, 0, 0, 0, + $targetQrcodeSize, $targetQrcodeSize, + $qrcodeWidth, $qrcodeHeight); + + $qrcodeX = ($imageWidth - $targetQrcodeSize) / 2; + imagecopy($image, $resizedQrcode, $qrcodeX, $qrCodeYPosition, 0, 0, $targetQrcodeSize, $targetQrcodeSize); + + // 添加"外箱条码"文字 + $boxTitleBox = imagettfbbox($boxTitleFontSize, 0, $fontFile, $boxTitleText); + $boxTitleWidth = $boxTitleBox[2] - $boxTitleBox[0]; + $boxTitleX = ($imageWidth - $boxTitleWidth) / 2; + imagettftext($image, $boxTitleFontSize, 0, $boxTitleX, $boxTitleYPosition, $black, $fontFile, $boxTitleText); + + // 添加条形码 + $barcodeImage = imagecreatefromstring($barcodeData); + $barcodeWidth = imagesx($barcodeImage); + $barcodeHeight = imagesy($barcodeImage); + + $targetBarcodeWidth = $imageWidth * $barcodeScaleFactor; + $scale = $targetBarcodeWidth / $barcodeWidth; + $newBarcodeWidth = $targetBarcodeWidth; + $newBarcodeHeight = $barcodeHeight * $scale * $barcodeHeightScale; + + $resizedBarcode = imagecreatetruecolor($newBarcodeWidth, $newBarcodeHeight); + imagefill($resizedBarcode, 0, 0, $white); + imagecopyresampled($resizedBarcode, $barcodeImage, + 0, 0, 0, 0, + $newBarcodeWidth, $newBarcodeHeight, + $barcodeWidth, $barcodeHeight); + + $barcodeX = ($imageWidth - $newBarcodeWidth) / 2; + imagecopy($image, $resizedBarcode, $barcodeX, $barcodeYPosition, 0, 0, $newBarcodeWidth, $newBarcodeHeight); + + // 添加外箱条码文字 + $codeTextBox = imagettfbbox($barcodeTextFontSize, 0, $fontFile, $box_barcode_data); + $codeTextWidth = $codeTextBox[2] - $codeTextBox[0]; + $codeTextX = ($imageWidth - $codeTextWidth) / 2; + imagettftext($image, $barcodeTextFontSize, 0, $codeTextX, $barcodeTextYPosition, $black, $fontFile, $box_barcode_data); + + // 输出图像 + ob_start(); + imagepng($image); + $imageData = ob_get_clean(); + + // 标记为已打印 + $zengjie->table('box_code_all') + ->where(['id' => $box_data['id']]) + ->update(['is_print' => 1]); + + return $this->msg([ + 'image' => 'data:image/png;base64,' . base64_encode($imageData) + ]); + + } catch (\Exception $e) { + return $this->msg(10003, "生成集成码失败: " . $e->getMessage()); + } + } +} \ No newline at end of file diff --git a/application/ZengJieCode/controller/app/Base.php b/application/ZengJieCode/controller/app/Base.php new file mode 100644 index 0000000..6da6fc6 --- /dev/null +++ b/application/ZengJieCode/controller/app/Base.php @@ -0,0 +1,183 @@ +'关键参数缺失', + '10002'=>'操作失败', + '10003'=>'信息核实错误', + '10004'=>'未找到有效数据', + '10005'=>'参数格式错误', + '10006'=>'参数不能为空', + '10007'=>'参数错误', + '10008'=>'', + '10009'=>'', + '10010'=>'自定义信息', + '20001'=>'登录失效', + '99999'=>'网络异常,请稍后重试', + ]; + // 加 bcadd(,,20) + // 减 bcsub(,,20) + // 乘 bcmul(,,20) + // 除 bcdiv(,,20) + ################################################################接口################################################################ + ################################################################接口################################################################ + ################################################################接口################################################################ + // 接口记录 + public function record_api_log($params, $error = null, $response = null){ + // dump($params); + // dump($error); + // die; + $logContent = "接口请求参数:" . json_encode($params, JSON_UNESCAPED_UNICODE) . PHP_EOL; + if ($error) { + $logContent .= "错误信息:" . $error['all_content'] . PHP_EOL; + if(!cache($error['flie']."_".$error['line'])){ + cache($error['flie']."_".$error['line'],"API错误",3600); + $this->send_email_api_error(["tsf3920322@126.com"],['title'=>'接口报错','from_user_name'=>'厨房秤(后台)','content'=>$logContent]); + } + } + if ($response) { + $logContent .= "返回信息:" . json_encode($response, JSON_UNESCAPED_UNICODE) . PHP_EOL; + } + // 使用ThinkPHP的日志记录方法 + Log::record($logContent, 'api_log'); + } + + /* 接口说明(发邮件) + * $address(收件人的邮箱地址) 数组 格式: ['460834639@qq.com','460834639@qq.com'.......] + * $content(邮件的主题数据信息) 数组 格式:['title'=>'123','from_user_name'=>'123','content'=>'123'] + * $annex(附件路径信息) 字符串 + */ + public function send_email_api_error($address,$content,$annex=''){ + // $ad = '460834639@qq.com'; + $ad1 = '295155911@qq.com'; + $mail = new PHPMailer(); //实例化 + $mail->IsSMTP(); // 启用SMTP + $mail->Host = "smtp.126.com"; //SMTP服务器 163邮箱例子 + $mail->Port = 465; //邮件发送端口 + $mail->SMTPAuth = true; //启用SMTP认证 + $mail->SMTPSecure = 'ssl'; + $mail->CharSet = "UTF-8"; //字符集 + $mail->Encoding = "base64"; //编码方式 + $mail->Username = "tsf3920322@126.com"; //你的邮箱 + $mail->Password = "HLWXNRPUCTHJFIIX"; //你的密码(邮箱后台的授权密码) + $mail->From = "tsf3920322@126.com"; //发件人地址(也就是你的邮箱) + + // $mail->Subject = "微盟测试邮件"; //邮件标题 + $mail->Subject = $content['title']; //邮件标题 + + // $mail->FromName = "微盟体测中心"; //发件人姓名 + $mail->FromName = $content['from_user_name']; //发件人姓名 + + + for ($i=0; $i < count($address); $i++) { + $mail->AddAddress($address[$i], ""); //添加收件人(地址,昵称) + } + + if($annex != ''){ + // $url = ROOT_PATH. 'public' . DS . 'tsf' . DS .'demoooo.jpg'; + $mail->AddAttachment($annex,''); // 添加附件,并指定名称 + } + + $mail->IsHTML(true); //支持html格式内容 + + $neirong = $content['content']; + + $mail->Body = $neirong; //邮件主体内容 + //发送 + if (!$mail->Send()) { + + return ['code' => 10003,'msg'=>$mail->ErrorInfo]; + // return $mail->ErrorInfo; + } else { + return ['code' => 0]; + // return 'success'; + } + } + + + // 验证 + public function verify_data_is_ok($data = 2,$type){ + if($type == 'str'){ + if (is_string($data)) { + return true; + } else { + $this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为字符串',[]]); + return false; + } + }else if($type == 'num'){ + if (is_numeric($data)) { + return true; + } else { + $this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为数字',[]]); + return false; + } + }else if($type == 'intnum'){ + $pattern = '/^\d+$/'; + // dump($data); + if (preg_match($pattern, $data)) { + return true; // 匹配成功,返回 true + } else { + $this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为整数数字',[]]); + return false; // 匹配失败,返回 false + } + }else if($type == 'datetime'){ + $formats = ['Y-m-d','Y-m-d H:i:s']; + foreach ($formats as $format) { + $dateTime = \DateTime::createFromFormat($format, $data); + // 检查时间字符串是否成功解析,并且解析后的日期时间与原始字符串表示的时间一致 + if ($dateTime && $dateTime->format($format) === $data) { + return true; + } + } + // 如果所有格式都解析失败,则返回 false + $this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为日期格式',[]]); + return false; + }else if($type == 'num&letter'){ + if (preg_match('/^[a-zA-Z0-9]+$/', $data)) { + return true; + } else { + return false; + } + }else if($type == 'other'){ + + } + + } + + public function msg($data,$str='',$result = []){ + if(is_array($data)){ + if($str != ''){ + return json(['code'=>0,'msg'=>$str,'data'=>$data]); + }else{ + return json(['code'=>0,'msg'=>'操作成功','data'=>$data]); + } + }else{ + if($str != ''){ + return json(['code'=>$data,'msg'=>$str,'data'=>$result]); + } + return json(['code'=>$data,'msg'=>$this->return_data_all[$data],'data'=>$result]); + } + } + + public function generateRandomString($length = 10) { + $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + return $randomString; + } + + + +} \ No newline at end of file diff --git a/application/ZengJieCode/controller/app/Savemsg.php b/application/ZengJieCode/controller/app/Savemsg.php new file mode 100644 index 0000000..a6676fd --- /dev/null +++ b/application/ZengJieCode/controller/app/Savemsg.php @@ -0,0 +1,305 @@ +'LS-2502', + 'character_uuid'=>'2A25', + 'service_uuid'=>'180A' + ], + + ]; + protected $name_default = 0; + protected $kitchenscale_db_msg = [ + 'cookbook'=>'app_user_cookbook',//菜谱表 + 'foodlist3'=>'app_z_national_standard_food_type_3',//食材列表3 + 'user'=>'app_user_data',//banner + ]; + + // 加 bcadd(,,20) + // 减 bcsub(,,20) + // 乘 bcmul(,,20) + // 除 bcdiv(,,20) + ################################################################百度接口################################################################ + ################################################################百度接口################################################################ + ################################################################百度接口################################################################ + + // 获取配置信息 + public function config_msg(){ + try { + $result = $this->config_msg_action(); + return $this->msg($result); + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "函数名: " . __FUNCTION__ . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + $this->record_api_log($data, $logContent, null); + return $this->msg(99999); + } + + } + + public function save_sn_msg($data = ['sn_code'=>'564654564654654','bl_name'=>'bl_5520']){ + try { + // 你的业务逻辑 + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('sn_code', $data)){ + return $this->msg(10001); + } + if(!array_key_exists('bl_name', $data)){ + return $this->msg(10001); + } + if(!$this->verify_data_is_ok($data['sn_code'],'str')){ + return $this->msg(10005); + } + if(!$this->verify_data_is_ok($data['bl_name'],'str')){ + return $this->msg(10005); + } + $result = $this->save_sn_msg_action($data); + return $result; + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "函数名: " . __FUNCTION__ . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + // dump($data); + // die; + $this->record_api_log($data, $logContent, null); + return $this->msg(99999); + } + + } + + public function save_box_msg($data = ['sn_code_all'=>'564654564654654,564654564654654','box_serial_number'=>'996589585']){ + + try { + // 你的业务逻辑 + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('sn_code_all', $data)){ + return $this->msg(10001); + } + if(!array_key_exists('box_serial_number', $data)){ + return $this->msg(10001); + } + if(!$this->verify_data_is_ok($data['sn_code_all'],'str')){ + return $this->msg(10005); + } + if(!$this->verify_data_is_ok($data['box_serial_number'],'num&letter')){ + return $this->msg(10005); + } + $result = $this->save_box_msg_action($data); + return $result; + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "函数名: " . __FUNCTION__ . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + // dump($data); + // die; + $this->record_api_log($data, $logContent, null); + return $this->msg(99999); + } + + } + + public function print_again($data = ['code'=>'564654564654654','type'=>'sn']){ + try { + // 你的业务逻辑 + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('code', $data)){ + return $this->msg(10001); + } + if(!array_key_exists('type', $data)){ + return $this->msg(10001); + } + if(!$this->verify_data_is_ok($data['code'],'str')){ + return $this->msg(10005); + } + if(!$this->verify_data_is_ok($data['type'],'str')){ + return $this->msg(10005); + } + + $result = $this->print_again_action($data); + return $result; + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "函数名: " . __FUNCTION__ . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + // dump($data); + // die; + $this->record_api_log($data, $logContent, null); + return $this->msg(99999); + } + + } + + + + + ########################################################################action######################################################################## + ########################################################################action######################################################################## + ########################################################################action######################################################################## + + public function config_msg_action(){ + // $length = strlen("0065601800007037"); + // // 生成200个随机数字字符串 + // $randomStrings = []; + // for ($i = 0; $i < 200; $i++) { + // $randomString = ''; + // for ($j = 0; $j < $length; $j++) { + // $randomString .= rand(0, 9); // 生成0-9的随机数字 + // } + // $randomStrings[] = [ + // 'bluetooth_name'=>'bl_5520', + // 'sn_code'=>$randomString, + // 'create_time'=>date('Y-m-d H:i:s'), + // ]; + // } + // $zengjie = Db::connect('zengjie_db'); + // $result = $zengjie->table('sn_code_all')->insertAll($randomStrings); + // dump($result); + // die; + $data = [ + 'max_box_num'=>$this->max_box_num, + 'name_list'=>$this->name_list, + 'name_default_key'=>$this->name_default, + + ]; + return $data; + } + + public function save_sn_msg_action($data){ + $zengjie = Db::connect('zengjie_db'); + // $sn_code = $zengjie->table('sn_code_all')->where(['sn_code'=>$data['sn_code']])->count(); + // if($sn_code > 0){ + // return $this->msg(10002,'该码已录入'); + // } + $result = $zengjie->table('sn_code_all')->insert([ + 'sn_code'=>$data['sn_code'], + 'bluetooth_name'=>$data['bl_name'], + 'create_time'=>date('Y-m-d H:i:s'), + ]); + if($result){ + return $this->msg([]); + }else{ + return $this->msg(10002,'录入失败'); + } + } + + public function save_box_msg_action($data){ + $zengjie = Db::connect('zengjie_db'); + + $box_num = $zengjie->table('box_code_all')->where(['box_code'=>$data['box_serial_number']])->count(); + $box_num = $box_num+1; + $result = $zengjie->table('box_code_all')->insert([ + 'box_code'=>$data['box_serial_number'], + 'box_num'=>$box_num, + 'create_time'=>date('Y-m-d H:i:s'), + 'content_str'=>$data['sn_code_all'], + ]); + + if($result){ + return $this->msg([]); + }else{ + return $this->msg(10002,'录入失败'); + } + + // try { + // // 使用事务闭包,TP5会自动管理事务 + // $result = $zengjie->transaction(function() use ($zengjie, $data) { + // $sn_code = $zengjie->table('box_code_all')->where(['box_code'=>$data['box_serial_number']])->count(); + // $num = $sn_code+1; + + // $box_id = $zengjie->table('box_code_all')->insertGetId([ + // 'box_code'=>$data['box_serial_number'], + // 'box_num'=>$num, + // 'create_time'=>date('Y-m-d H:i:s'), + // ]); + + // // 使用安全的参数绑定方式 + // $snCodes = explode(',', $data['sn_code_all']); + // $zengjie->table('sn_code_all') + // ->where('sn_code', 'in', $snCodes) + // ->update(['batch_id' => $box_id]); + + // return $box_id; + // }); + + // return $this->msg(['id'=>$result]); + // } catch (\Exception $e) { + // trace('保存盒信息失败: ' . $e->getMessage(), 'error'); + // return $this->msg(10002, '录入失败: ' . $e->getMessage()); + // } + } + + + public function print_again_action($data){ + $zengjie = Db::connect('zengjie_db'); + if($data['type'] == 'sn'){ + $result = $zengjie->table('sn_code_all')->where(['sn_code'=>$data['code']])->count(); + }else{ + $result = $zengjie->table('box_code_all')->where(['id'=>$data['code']])->count(); + } + + if($result <= 0){ + return $this->msg(10002,'未找到该码录入'); + } + + if($data['type'] == 'sn'){ + $result2 = $zengjie->table('sn_code_all')->where(['sn_code'=>$data['code']])->update([ + 'is_print'=>3 + ]); + }else{ + $result2 = $zengjie->table('box_code_all')->where(['id'=>$data['code']])->update([ + 'is_print'=>0 + ]); + } + + if($result){ + return $this->msg([]); + }else{ + return $this->msg(10002,'打印失败'); + } + } + +} \ No newline at end of file diff --git a/application/ZengJieCode/view/admin/printaction/print_device_barcode_index.html b/application/ZengJieCode/view/admin/printaction/print_device_barcode_index.html new file mode 100644 index 0000000..42144b0 --- /dev/null +++ b/application/ZengJieCode/view/admin/printaction/print_device_barcode_index.html @@ -0,0 +1,122 @@ + + + + + + 标签打印系统 + + + + +

标签打印系统

+
440×147px图片打印到60×20mm标签纸
+ +
+ +
+ + + + + + \ No newline at end of file diff --git a/application/ZengJieCode/view/admin/printaction/print_outside_box_index.html b/application/ZengJieCode/view/admin/printaction/print_outside_box_index.html new file mode 100644 index 0000000..a5c2741 --- /dev/null +++ b/application/ZengJieCode/view/admin/printaction/print_outside_box_index.html @@ -0,0 +1,147 @@ + + + + + + 标签打印系统 - 集成码 + + + + +

标签打印系统 - 集成码

+
生成包含二维码和条形码的标签
+ +
+
+ 标签图片 +
+
+ + + + + + \ No newline at end of file diff --git a/application/app/controller/Card.php b/application/app/controller/Card.php index 77faa7c..ba73bda 100644 --- a/application/app/controller/Card.php +++ b/application/app/controller/Card.php @@ -266,6 +266,19 @@ class Card extends Base{ if($temporary_data['weight_in_kg'] == false){ return $this->msg(10005,'体重单位错误'); } + // 检测设备传过来的info信息 + if(array_key_exists('info', $data)){ + if (!is_array($data['info'])) { + return $this->msg(10005,'info参数格式错误'); + }else{ + $info_data_arr =['bodyage','fat_r','muscle','kcal','visceral','sfr','water','bone','fatlevlval','protein','bmi']; + foreach ($data['info'] as $key => $value) { + if (!in_array($key, $info_data_arr)) { + return $this->msg(10005,'info参数格式错误-2'); + } + } + } + } $data['height'] = $temporary_data['height_in_cm']; $data['weight'] = $temporary_data['weight_in_kg']; @@ -949,20 +962,6 @@ class Card extends Base{ // 减 bcsub(,,20) // 乘 bcmul(,,20) // 除 bcdiv(,,20) - // // 这里开始转换不同单位的身高体重为cm跟kg(start) - // if($data['height'][1] == 'kg'){ - // $data['height'] = $data['height'][0]; - // }else if($data['height'][1] == '斤'){ - // // 斤数除以2就是公斤 - // $data['height'] = bcdiv($data['height'][0],2,2); - // }else if($data['height'][1] == 'st:lb'){ - // $data['height'] = $data['height'][0]; - // }else if($data['height'][1] == 'lb'){ - // $data['height'] = $data['height'][0]; - // } - // // 这里开始转换不同单位的身高体重为cm跟kg(end) - // $adc_type = $type; - // $data['type'] = 1; // 判断头围数据是否存在是否合理 if(array_key_exists('head_data', $data)){ @@ -1053,6 +1052,79 @@ class Card extends Base{ $get_body_value['birthday'] = $user_data['birthday']; // 添加身高、体重、bmi、头围(如果有)的标尺标准 $get_body_value = $this->hwb_standard($get_body_value); + + + $enumeration_data = [ + 'fat_r'=>'脂肪率', + 'muscle'=>'肌肉率', + 'kcal'=>'基础代谢', + 'visceral'=>'内脏指数', + 'sfr'=>'皮下脂肪', + 'water'=>'水分', + 'bone'=>'骨重', + 'protein'=>'蛋白率', + 'bodyage'=>'身体年龄' + ]; + + // return $this->msg($get_body_value); + // 根据秤传过来的数据,去处理要存的结果 + if(array_key_exists('info', $data)){ + + + foreach ($data['info'] as $key => $value) { + if($key == 'bmi'){ + if($value > 0){ + $get_body_value['BMI'] = $value; + $get_body_value['BMI2'] = explode(',',$get_body_value['BMI2']); + $get_body_value['BMI2'][0] = $value; + $get_body_value['BMI2'] = implode(',',$get_body_value['BMI2']); + } + }else if($key == 'bodyage'){ + $get_body_value[$enumeration_data[$key]] = $value; + }else if($key == 'fatlevlval'){ + continue; + }else{ + if($value > 0){ + $get_body_value[$enumeration_data[$key]][0] = $value; + } + } + + + } + // if($data['info']['fat_r'] > 0){ + // $get_body_value['脂肪率'][0] = $data['info']['fat_r']; + // } + // if($data['info']['muscle'] > 0){ + // $get_body_value['肌肉率'][0] = $data['info']['muscle']; + // } + // if($data['info']['kcal'] > 0){ + // $get_body_value['基础代谢'][0] = $data['info']['kcal']; + // } + // if($data['info']['visceral'] > 0){ + // $get_body_value['内脏指数'][0] = $data['info']['visceral']; + // } + // if($data['info']['sfr'] > 0){ + // $get_body_value['皮下脂肪'][0] = $data['info']['sfr']; + // } + // if($data['info']['water'] > 0){ + // $get_body_value['水分'][0] = $data['info']['water']; + // } + // if($data['info']['bone'] > 0){ + // $get_body_value['骨重'][0] = $data['info']['bone']; + // } + // // if($data['info']['fatlevlval'] > 0){//好像是肥胖等级,暂时废弃用自己算的 + // // $get_body_value['水分'][0] = $data['info']['fatlevlval']; + // // } + // if($data['info']['protein'] > 0){ + // $get_body_value['蛋白率'][0] = $data['info']['protein']; + // } + // if($data['info']['bmi'] > 0){ + // $data['info']['bmi2'] = explode(',',$get_body_value['BMI2']); + // $data['info']['bmi2'][0] = $data['info']['bmi']; + // $data['info']['bmi2'] = implode(',',$data['info']['bmi2']); + // } + } + $set_data = [ 'acd_id'=>$data['acd_id'], 'aud_id'=>$data['aud_id'], @@ -1088,6 +1160,7 @@ class Card extends Base{ // 时间日期转换,把'Y-m-d'转换成'Y-m-d H:i:s'格式 $set_data['record_time'] = $this->addCurrentTimeToDateString($set_data['record_time']); } + // 启动事务 Db::startTrans(); try{ @@ -1107,8 +1180,6 @@ class Card extends Base{ 'height'=>$get_body_value['身高'].',CM', 'weight'=>$get_body_value['体重'].',公斤', 'bmi'=>$get_body_value['BMI'], - // 'user_set_height'=>$get_body_value['身高'], - // 'user_set_weight'=>$get_body_value['体重'], 'target_current'=>$target_current, ]); } catch (\Exception $e) { diff --git a/application/app/controller/Cardparts.php b/application/app/controller/Cardparts.php index bde25eb..5d42583 100644 --- a/application/app/controller/Cardparts.php +++ b/application/app/controller/Cardparts.php @@ -215,7 +215,7 @@ class Cardparts extends Base{ foreach ($temporary_arr['top_list'] as $key => $value) { if(count($value['list']) > 0){ - $temporary_arr['top_list'][$key]['offset'] = $this->calculate_landing_point($value['list'],$value['value'],$value['standard']); + $temporary_arr['top_list'][$key]['offset'] = $this->calculate_landing_point($value['list'],$value['value'],$value['standard'])[0]; } } // 如果是没有阻抗的测试,那么就不要底部的其他数据了 @@ -224,7 +224,10 @@ class Cardparts extends Base{ return $temporary_arr; } // 处理底部list + + foreach ($temporary_arr['bottom_list'] as $key => $value) { + // dump($value); // 脂肪率& if($value['key_name'] == 'fat_r'){ if($age < 30){ @@ -360,22 +363,28 @@ class Cardparts extends Base{ public function calculate_landing_point($data,$val,$t_val){ // 根据字典确认有几个区间 $num = count($data); + if($num <= 0){ + return 0; + } // 没个区间占比 $a_section = bcdiv(100,$num,2); $temporary_data = []; $num_0 = 0; // 看看值是在哪个区间 foreach ($data as $key => $value) { - if($t_val == $value['text']){ + if($val>=$value['min_val'] && $val<$value['max_val']){ $temporary_data = $value; $num_0 = $key; break; } } -// 加 bcadd(,,20) - // 减 bcsub(,,20) - // 乘 bcmul(,,20) - // 除 bcdiv(,,20) + if(count($temporary_data) <= 0){ + return 0; + } + // 加 bcadd(,,20) + // 减 bcsub(,,20) + // 乘 bcmul(,,20) + // 除 bcdiv(,,20) $max_num = trim($temporary_data['max_val']); $min_num = trim($temporary_data['min_val']); if($val < $temporary_data['max_val']){ @@ -456,12 +465,21 @@ class Cardparts extends Base{ // 处理异常 public function handling_exceptions($data){ - if($data['value'] <= $data['list'][0]['max_val']){ - $data['standard'] = $data['list'][0]['text']; - $data['color'] = $data['list'][0]['color']; - }else if($data['value'] >= $data['list'][count($data['list'])-1]['min_val']){ - $data['standard'] = $data['list'][count($data['list'])-1]['text']; - $data['color'] = $data['list'][count($data['list'])-1]['color']; + for ($i=0; $i < count($data['list']); $i++) { + if($data['value']>=$data['list'][$i]['min_val'] && $data['value']<$data['list'][$i]['max_val']){ + $data['standard'] = $data['list'][$i]['text']; + $data['color'] = $data['list'][$i]['color']; + break; + } + } + if($data['standard'] == '异常'){ + if($data['value'] <= $data['list'][0]['min_val']){ + $data['standard'] = $data['list'][0]['text']; + $data['color'] = $data['list'][0]['color']; + }else if($data['value'] >= $data['list'][count($data['list'])-1]['max_val']){ + $data['standard'] = $data['list'][count($data['list'])-1]['text']; + $data['color'] = $data['list'][count($data['list'])-1]['color']; + } } return $data; } diff --git a/application/app/controller/Index.php b/application/app/controller/Index.php index ef067d3..e01c8dc 100644 --- a/application/app/controller/Index.php +++ b/application/app/controller/Index.php @@ -103,7 +103,7 @@ class Index extends Base{ // 检测版本及判断是否登录失效 public function login_invalid_version($data = ['token'=>'2d4ea9b3f44b169ddf64b2f3d2725ceb']){ - // try { + try { // 获取客户端IP $ip = request()->ip(); // 调用IP识别方法 @@ -155,20 +155,20 @@ class Index extends Base{ return $this->msg(['version'=>$version,'url'=>$url,'language'=>$language_data,'language_arr'=>$this->process_Language()]); } - // } catch (\Exception $e) { - // // 捕获异常 - // $logContent["flie"] = $e->getFile(); - // $logContent["line"] = $e->getLine(); - // $logContent['all_content'] = "异常信息:\n"; - // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; - // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; - // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; - // $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; - // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; - // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; - // $this->record_api_log($data, $logContent, null); - // return $this->msg(99999); - // } + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "方法: " . __METHOD__ . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + $this->record_api_log($data, $logContent, null); + return $this->msg(99999); + } } // 添加IP信息获取方法 @@ -862,8 +862,8 @@ class Index extends Base{ 'birthday' => 'require|date', 'gender' => 'require|number|in:0,1,2', 'grade' => 'require', - 'height' => 'require|number', - 'weight' => 'require|number', + 'height' => 'require|number|between:0,9999.99', + 'weight' => 'require|number|between:0,9999.99', 'measure_model' => 'require|in:1,2', 'identity_id' => 'require', 'identity_name' => 'require', @@ -891,6 +891,8 @@ class Index extends Base{ 'measure_model.in' => '测量模式信息错误', 'height.number' => '身高必须为数字', 'weight.number' => '体重必须为数字', + 'height.between' => '身高数据异常', + 'weight.between' => '体重数据异常', ]; $validate = new Validate($rule,$msg); $result = $validate->check($data); @@ -933,8 +935,8 @@ class Index extends Base{ 'birthday' => 'require|date', 'gender' => 'require|number|in:0,1,2', // 'grade' => 'require', - 'height' => 'require|number', - 'weight' => 'require|number', + 'height' => 'require|number|between:0,9999.99', + 'weight' => 'require|number|between:0,9999.99', 'measure_model' => 'require|in:1,2', // 'identity_id' => 'require', // 'identity_name' => 'require', @@ -946,8 +948,8 @@ class Index extends Base{ 'birthday.require' => '生日缺失', 'gender.require' => '性别缺失', // 'grade.require' => '年级缺失', - 'height.require' => '身高缺失', - 'weight.require' => '体重缺失', + 'height.require' => '身高缺失/数据异常', + 'weight.require' => '体重缺失/数据异常', 'measure_model.require' => '测量模式缺失', // 'identity_id.require' => '身份缺失', // 'identity_name.require' => '身份缺失', @@ -962,6 +964,8 @@ class Index extends Base{ 'measure_model.in' => '测量模式信息错误', 'height.number' => '身高必须为数字', 'weight.number' => '体重必须为数字', + 'height.between' => '身高数据异常', + 'weight.between' => '体重数据异常', ]; $validate = new Validate($rule,$msg); $result = $validate->check($data); @@ -1003,8 +1007,8 @@ class Index extends Base{ 'birthday' => 'require|date', 'gender' => 'require|number|in:0,1,2', 'grade' => 'require', - 'height' => 'require|number', - 'weight' => 'require|number', + 'height' => 'require|number|between:0,9999.99', + 'weight' => 'require|number|between:0,9999.99', 'measure_model' => 'require|in:1,2', 'identity_id' => 'require', 'identity_name' => 'require', @@ -1032,6 +1036,8 @@ class Index extends Base{ 'measure_model.in' => '测量模式信息错误', 'height.number' => '身高必须为数字', 'weight.number' => '体重必须为数字', + 'height.between' => '身高数据异常', + 'weight.between' => '体重数据异常', ]; $validate = new Validate($rule,$msg); $result = $validate->check($data); @@ -1078,8 +1084,8 @@ class Index extends Base{ 'birthday' => 'require|date', 'gender' => 'require|number|in:0,1,2', // 'grade' => 'require', - 'height' => 'require|number', - 'weight' => 'require|number', + 'height' => 'require|number|between:0,9999.99', + 'weight' => 'require|number|between:0,9999.99', 'measure_model' => 'require|in:1,2', // 'identity_id' => 'require', // 'identity_name' => 'require', @@ -1107,6 +1113,8 @@ class Index extends Base{ 'measure_model.in' => '测量模式信息错误', 'height.number' => '身高必须为数字', 'weight.number' => '体重必须为数字', + 'height.between' => '身高数据异常', + 'weight.between' => '体重数据异常', ]; $validate = new Validate($rule,$msg); $result = $validate->check($data); diff --git a/application/code/controller/Qrcode.php b/application/code/controller/Qrcode.php index e26f3fd..1bdd423 100644 --- a/application/code/controller/Qrcode.php +++ b/application/code/controller/Qrcode.php @@ -339,6 +339,22 @@ class Qrcode extends Base{ return $this->msg(10002,'操作失败'); } } + public function del_device_label_name(){ + $data = input(); + $qrcode_db = Db::connect('qrcode_db'); + if(!array_key_exists('label', $data)){ + return $this->msg(10001,'label缺失'); + } + + $device_data = $qrcode_db->table('little_tips_label')->where(['id'=>$data['label']])->delete(); + + if($device_data){ + return $this->msg([]); + }else{ + return $this->msg(10002,'操作失败'); + } + } + public function update_title_action(){ $data = input(); diff --git a/application/code/view/qrcode/little_tips_project_set_page.html b/application/code/view/qrcode/little_tips_project_set_page.html index e992539..521dfc5 100644 --- a/application/code/view/qrcode/little_tips_project_set_page.html +++ b/application/code/view/qrcode/little_tips_project_set_page.html @@ -15,6 +15,9 @@ 小贴士 + + + @@ -209,11 +228,22 @@ 如果提交后,查询到已经有该设备型号,那么将更新该设备信息,没有则新建
-
添加设备分类:必填(添加后将出现在上面黄色板块内的设备分类当中)

+
添加设备分类:添加后将出现在上面黄色板块内的设备分类当中

+
+ 删除设备分类: + + 选择后点击删除 +

+
-
页面标题:必填(修改后,前端展示页面的标题将更改)

+
页面标题:修改后,前端展示页面的标题将更改

当前标题为“{$title.type_name}”
@@ -244,15 +274,20 @@ {$vo.device_describe} {$vo.type_name} - + +
+
+ + + {if condition="$vo.is_del == 0"} - +
{else /} - +
{/if} @@ -277,6 +312,15 @@
+ + + + + diff --git a/application/config.php b/application/config.php index 9488540..a1f379c 100644 --- a/application/config.php +++ b/application/config.php @@ -258,7 +258,10 @@ return [ // 端口 'hostport' => '4331', // 数据库连接参数 - 'params' => [], + 'params' => [ + PDO::SQLSRV_ATTR_FORMAT_DECIMALS => true,//针对sqlserver的数据库取出没有前导0的数据处理 + // PDO::SQLSRV_ATTR_DECIMAL_PLACES => 2//针对sqlserver的数据库取出没有前导0的数据处理。设置显示几位 + ], // 数据库编码默认采用utf8 'charset' => 'utf8', // 数据库表前缀 @@ -290,4 +293,52 @@ return [ // 数据库调试模式 'debug' => true, ], + // 第4个数据库配置(曾杰打印) + 'zengjie_db' => [ + // 数据库类型 + 'type' => 'sqlsrv', + // 服务器地址 + 'hostname' => '121.36.67.254', + // 'hostname' => '127.0.0.1', + // 数据库名 + 'database' => 'gongju_zjhq', + // 用户名 + 'username' => 'jt_user', + // 密码 + 'password' => 'jtuser1qaz@WSX', + // 端口 + 'hostport' => '4331', + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 + 'charset' => 'utf8', + // 数据库表前缀 + 'prefix' => '', + // 数据库调试模式 + 'debug' => true, + ], + // 第5个数据库配置(设备录入) + 'device_enter_db' => [ + // 数据库类型 + 'type' => 'sqlsrv', + // 服务器地址 + 'hostname' => '121.36.67.254', + // 'hostname' => '127.0.0.1', + // 数据库名 + 'database' => 'gongju_device_enter', + // 用户名 + 'username' => 'jt_user', + // 密码 + 'password' => 'jtuser1qaz@WSX', + // 端口 + 'hostport' => '4331', + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 + 'charset' => 'utf8', + // 数据库表前缀 + 'prefix' => '', + // 数据库调试模式 + 'debug' => true, + ], ]; diff --git a/application/route.php b/application/route.php index 3c81b77..9ad52e4 100644 --- a/application/route.php +++ b/application/route.php @@ -43,6 +43,7 @@ Route::any('/little_tips_project_upload_action', 'code/qrcode/little_tips_projec Route::any('/little_tips_is_del_update', 'code/qrcode/little_tips_is_del_update'); Route::any('/little_tips_del_action', 'code/qrcode/little_tips_del_action'); Route::any('/add_label_action', 'code/qrcode/add_label_action'); +Route::any('/del_device_label_name', 'code/qrcode/del_device_label_name'); Route::any('/update_title_action', 'code/qrcode/update_title_action'); // 儿童膳食食谱 @@ -543,6 +544,9 @@ Route::any('/testedition/kitchenscale/set_up_content', 'app/kitchenscale/testapp // 设置用户的卡路里 Route::any('/kitchenscale/set_user_kcal', 'app/kitchenscale/app.countfood/set_user_kcal'); Route::any('/testedition/kitchenscale/set_user_kcal', 'app/kitchenscale/testapp.countfood/set_user_kcal'); +// 删除用户某个饮食记录 +Route::any('/kitchenscale/del_user_eat_log', 'app/kitchenscale/app.countfood/del_user_eat_log'); +Route::any('/testedition/kitchenscale/del_user_eat_log', 'app/kitchenscale/testapp.countfood/del_user_eat_log'); // 我的################################################################ @@ -597,6 +601,39 @@ Route::any('/k/a/cookbook/stop_and_run', 'app/kitchenscale/admin.cookbook/stop_a +################################################################下面是增杰SN码打印################################################################ +################################################################################################################################################ +Route::any('/z/config_msg', 'app/ZengJieCode/app.savemsg/config_msg'); +Route::any('/z/save_sn_msg', 'app/ZengJieCode/app.savemsg/save_sn_msg'); +Route::any('/z/save_box_msg', 'app/ZengJieCode/app.savemsg/save_box_msg'); +// 重新打印 +Route::any('/z/print_again', 'app/ZengJieCode/app.savemsg/print_again'); + +Route::any('/z/print_device_barcode_index', 'app/ZengJieCode/admin.printaction/print_device_barcode_index'); +Route::any('/z/print_outside_box_index', 'app/ZengJieCode/admin.printaction/print_outside_box_index'); + +// 获取蓝牙录入的未打印条码 +Route::any('/z/print_device_barcode', 'app/ZengJieCode/admin.printaction/print_device_barcode'); +// 获取扫描后的未打印条码 +Route::any('/z/print_scan_barcode', 'app/ZengJieCode/admin.printaction/print_scan_barcode'); +// 获取大箱没打印的条码 +Route::any('/z/print_combined_code', 'app/ZengJieCode/admin.printaction/print_combined_code'); + +################################################################下面是设备入库录入################################################################ +################################################################################################################################################ +// 默认配置 +Route::any('/de/config_msg', 'app/DeviceEnter/savemsg/config_msg'); +// 存入设备信息 +Route::any('/de/save_device_msg', 'app/DeviceEnter/savemsg/save_device_msg'); +// 获取设备批次列表 +Route::any('/de/device_batch_list', 'app/DeviceEnter/savemsg/device_batch_list'); + + + + + + + // // ################################################################其它测试################################################################ diff --git a/application/testapp/controller/Base.php b/application/testapp/controller/Base.php index d799e4c..bf2a6cb 100644 --- a/application/testapp/controller/Base.php +++ b/application/testapp/controller/Base.php @@ -11,12 +11,12 @@ use PHPMailer\PHPMailer\PHPMailer; class Base extends Controller{ protected $base_use_db_name = [ - '1'=>'app_data_log_copy1', - '2'=>'app_card_data_copy1', - '3'=>'app_user_data_copy1', - '4'=>'pc_vitalcapacity_standard_copy1', - '5'=>'admin_estimate_copy1', - '6'=>'app_account_number_copy1' + '1'=>'app_data_log', + '2'=>'app_card_data', + '3'=>'app_user_data', + '4'=>'pc_vitalcapacity_standard', + '5'=>'admin_estimate', + '6'=>'app_account_number' ]; protected $ceshiyong_token = ['57bd45e3a963b372ea2d873e4bd8d1f8','e0966788d02cc93290d9d674921d9715']; @@ -169,7 +169,7 @@ class Base extends Controller{ // 如果需要更精确的计算(包括小时、分钟等转换成的天数),可以使用以下方式: // $totalSecondsDifference = $interval->format('%a') * 86400 + $interval->format('%h') * 3600 + $interval->format('%i') * 60 + $interval->format('%s'); // $daysDifference = floor($totalSecondsDifference / 86400); // 将总秒数转换为天数并取整 - // dump($user_login); + // 判断差异是否超过指定的天数 if ($daysDifference > $this->token_time) { // echo "超过 {$specifiedDays} 天"; @@ -177,8 +177,8 @@ class Base extends Controller{ return ['state'=>false,'language'=>$user_login['language']]; } else { // echo "未超过 {$specifiedDays} 天"; - $user_login_update = Db::table($this->base_use_db_name['6'])->where(['token'=>$token])->update(['login_time'=>date('Y-m-d H:i:s')]); - if($user_login_update){ + $user_login = Db::table($this->base_use_db_name['6'])->where(['token'=>$token])->update(['login_time'=>date('Y-m-d H:i:s')]); + if($user_login){ Log::record('用户尝试更新token时间,token:' . $token.',记录成功,最新的时间为'.date('Y-m-d H:i:s'), 'token_log'); return ['state'=>true,'language'=>$user_login['language']]; }else{ @@ -224,48 +224,6 @@ class Base extends Controller{ $ageInMonthsPrecise = intval($ageInMonths + $partialMonth); return $ageInMonthsPrecise; } - // 计算年龄(岁数和月数) - public function calculateAge($birthDate) { - // 创建出生日期和当前日期的DateTime对象 - $birthDate = new \DateTime($birthDate); - $currentDate = new \DateTime(); - - // 计算年份差异 - $yearDiff = $currentDate->format('Y') - $birthDate->format('Y'); - - // 计算月份差异 - $monthDiff = $currentDate->format('m') - $birthDate->format('m'); - - // 如果当前月份小于出生月份,或者月份相同但当前日小于出生日 - if ($monthDiff < 0 || ($monthDiff == 0 && $currentDate->format('d') < $birthDate->format('d'))) { - $yearDiff--; - $monthDiff += 12; - } - - // 如果当前日小于出生日,需要再减一个月 - if ($currentDate->format('d') < $birthDate->format('d')) { - $monthDiff--; - // 如果月份变为负数,调整年份和月份 - if ($monthDiff < 0) { - $monthDiff += 12; - $yearDiff--; - } - } - - // 确保年份和月份不为负数 - $yearDiff = max(0, $yearDiff); - $monthDiff = max(0, $monthDiff); - - // 构建结果数组 - $result = [ - 'age_year' => $yearDiff, - 'age_year_unit' => '岁', - 'age_months' => $monthDiff, - 'age_months_unit' => '个月', - ]; - - return $result; - } // 曲线页面-底部统计动作 public function base_target_initial_cumulative_weight($data = []){ // 第一种:用户详情(所有数据都有) @@ -754,6 +712,9 @@ class Base extends Controller{ public function ceshiyong($aa = 4,$gd = 0.2){ + + phpinfo(); + die; $token = 'cd3f27cf4c4002170ea7bceeb723ac91'; $data = Db::table('pc_bmistand2')->select(); diff --git a/application/testapp/controller/Card.php b/application/testapp/controller/Card.php index 5d47b66..c2809e9 100644 --- a/application/testapp/controller/Card.php +++ b/application/testapp/controller/Card.php @@ -10,18 +10,16 @@ class Card extends Base{ protected $color = ['#FF5656','#FFAB00','#5AD06D','#6492F6','#3967D6']; protected $card_use_db_name = [ - '1'=>'app_card_body_data_copy1', - '2'=>'app_user_data_copy1', - '3'=>'pc_bmistand_copy1', - '4'=>'pc_heightstand_copy1', - '5'=>'pc_weightstand_copy1', - '6'=>'pc_childrenprescription_copy1', - '7'=>'pc_childprescriptionbyage_copy1', - '8'=>'pc_heightstand_copy1', - '9'=>'pc_weightstand_copy1', - '10'=>'pc_bmistand_copy1', - '11'=>'app_account_number_copy1', - '12'=>'ws_height', + '1'=>'app_card_body_data', + '2'=>'app_user_data', + '3'=>'pc_bmistand', + '4'=>'pc_heightstand', + '5'=>'pc_weightstand', + '6'=>'pc_childrenprescription', + '7'=>'pc_childprescriptionbyage', + '8'=>'pc_heightstand', + '9'=>'pc_weightstand', + '10'=>'pc_bmistand', ]; protected $age_limit = 16; protected $unit_symbol = ['score'=>'分','height'=>'CM','weight'=>'公斤','bmi'=>'','fat_r'=>'%','fat_w'=>'kg','muscle'=>'%','muscleval'=>'kg','water'=>'kg','bone'=>'kg','protein'=>'%','proteinval'=>'kg','kcal'=>'kcal','visceral'=>'','sfr'=>'%',]; @@ -90,8 +88,8 @@ class Card extends Base{ // 详细卡片信息 // $data = ['id'=>'2'] - public function card_data_detailed($data=['aud_id'=>'144']){ - try { + public function card_data_detailed($data=['aud_id'=>'61']){ + // try { // 你的业务逻辑 if(count(input('post.')) > 0){ $data = input('post.'); @@ -102,49 +100,12 @@ class Card extends Base{ if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){ return $this->msg(10005); } + // dump($return_data); + // die; // $return_data; $return_data = $this->get_user_body_data($data); - - return $return_data; - } catch (\Exception $e) { - // 捕获异常 - $logContent["flie"] = $e->getFile(); - $logContent["line"] = $e->getLine(); - $logContent['all_content'] = "异常信息:\n"; - $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; - $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; - $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; - $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; - $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; - $this->record_api_log($data, $logContent, null); - return $this->msg(99999); - } - - } - - // 曲线页面-曲线接口 - public function card_curve_chart($data = ['aud_id'=>'144','s_time'=>'2025-01-29','e_time'=>'2025-04-29','token'=>'caadd1be045a65f30b92aa805f1de54a']){ - // try { - // 你的业务逻辑 - if(count(input('post.')) > 0){ - $data = input('post.'); - } - if(!array_key_exists('aud_id', $data) || !array_key_exists('s_time', $data) || !array_key_exists('e_time', $data) || !array_key_exists('token', $data)){ - return $this->msg(10001); - } - // unset($data['token']); - if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){ - return $this->msg(10005); - } - if(!$this->verify_data_is_ok($data['s_time'],'datetime')){ - return $this->msg(10005); - } - if(!$this->verify_data_is_ok($data['e_time'],'datetime')){ - return $this->msg(10005); - } - $return_data = $this->curve_chart_action($data); - // 成功 - $this->record_api_log($data, null, $return_data); + // $language_data = new Language(); + // $return_data = $language_data->handling_languages_from_multiple_countries('en', $return_data->getData()); return $return_data; // } catch (\Exception $e) { // // 捕获异常 @@ -161,6 +122,46 @@ class Card extends Base{ // } } + + // 曲线页面-曲线接口 + public function card_curve_chart($data = ['aud_id'=>'11','s_time'=>'2024-04-01','e_time'=>'2024-12-25','token'=>'caadd1be045a65f30b92aa805f1de54a']){ + try { + // 你的业务逻辑 + if(count(input('post.')) > 0){ + $data = input('post.'); + } + if(!array_key_exists('aud_id', $data) || !array_key_exists('s_time', $data) || !array_key_exists('e_time', $data) || !array_key_exists('token', $data)){ + return $this->msg(10001); + } + unset($data['token']); + if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){ + return $this->msg(10005); + } + if(!$this->verify_data_is_ok($data['s_time'],'datetime')){ + return $this->msg(10005); + } + if(!$this->verify_data_is_ok($data['e_time'],'datetime')){ + return $this->msg(10005); + } + $return_data = $this->curve_chart_action($data); + // 成功 + $this->record_api_log($data, null, $return_data); + return $return_data; + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + $this->record_api_log($data, $logContent, null); + return $this->msg(99999); + } + + } // 手动记录 // $data = ['id'=>'2','time'=>'1991-04-20 10:10:10','height'=>'15.1','weight'=>'75.1'] @@ -184,6 +185,7 @@ class Card extends Base{ return $this->msg(10005); } $temporary_data = $this->convertHeightAndWeight($data['height'],$data['weight']); + if($temporary_data['height_in_cm'] == false){ return $this->msg(10005,'身高单位错误'); } @@ -192,6 +194,8 @@ class Card extends Base{ } $data['height'] = $temporary_data['height_in_cm']; $data['weight'] = $temporary_data['weight_in_kg']; + + // if(!$this->verify_data_is_ok($data['height'],'num')){ // return $this->msg(10005); // } @@ -261,12 +265,26 @@ class Card extends Base{ return $this->msg(10005); } $temporary_data = $this->convertHeightAndWeight($data['height'],$data['weight']); + if($temporary_data['height_in_cm'] == false){ return $this->msg(10005,'身高单位错误'); } if($temporary_data['weight_in_kg'] == false){ return $this->msg(10005,'体重单位错误'); } + // 检测设备传过来的info信息 + if(array_key_exists('info', $data)){ + if (!is_array($data['info'])) { + return $this->msg(10005,'info参数格式错误'); + }else{ + $info_data_arr =['bodyage','fat_r','muscle','kcal','visceral','sfr','water','bone','fatlevlval','protein','bmi']; + foreach ($data['info'] as $key => $value) { + if (!in_array($key, $info_data_arr)) { + return $this->msg(10005,'info参数格式错误-2'); + } + } + } + } $data['height'] = $temporary_data['height_in_cm']; $data['weight'] = $temporary_data['weight_in_kg']; @@ -319,7 +337,7 @@ class Card extends Base{ } - // 修改初始体重/目标体重{"aud_id":"3967","time":"","weight":"124","type":1,"aan_id":"3475"} + // 修改初始体重/目标体重 public function card_modify_weight($data = ['aud_id'=>'3967','weight'=>'124','type'=>1,'time'=>'','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ try { // 你的业务逻辑 @@ -423,8 +441,8 @@ class Card extends Base{ } // BMI测评 - public function card_bmi_evaluation($cbe_data = ['height'=>'177','weight'=>'177','birthday'=>'2024-10-03','sex'=>'1','token'=>'caadd1be045a65f30b92aa805f1de54a'],$type = false){ - // try { + public function card_bmi_evaluation($cbe_data = ['height'=>'177','weight'=>'177','birthday'=>'2024-10-03','sex'=>'1'],$type = false){ + try { // 你的业务逻辑 if(count(input('post.')) > 0 && $type == false){ $cbe_data = input('post.'); @@ -432,10 +450,9 @@ class Card extends Base{ if(!is_array($cbe_data)){ return $this->msg(10005); } - if(!array_key_exists('height', $cbe_data) || !array_key_exists('token', $cbe_data) || !array_key_exists('weight', $cbe_data) || !array_key_exists('birthday', $cbe_data) || !array_key_exists('sex', $cbe_data)){ + if(!array_key_exists('height', $cbe_data) || !array_key_exists('weight', $cbe_data) || !array_key_exists('birthday', $cbe_data) || !array_key_exists('sex', $cbe_data)){ return $this->msg(10001); } - $token = $cbe_data['token']; unset($cbe_data['token']); if(!$this->verify_data_is_ok($cbe_data['birthday'],'datetime')){ return $this->msg(10005); @@ -461,68 +478,24 @@ class Card extends Base{ $request_result = $this->postRequest($url,$temporary_parameter,array('Content-Type:application/json','Origin:http://ybdevice.pcxbc.com')); // 直接开始业务,请求外部接口end - // 处理进度点 $request_result =$this->bmi_evaluation_action($request_result); - - $language_str = Db::table($this->card_use_db_name['11'])->where(['token'=>$token])->field('language')->find(); - $language_data = new Language(); - if(!$language_str['language']){ - $language_str['language'] = 'zh-Hans'; - } - $request_result = $language_data->handling_languages_from_multiple_countries($language_str['language'], $request_result->getData()['data']); - // $this->record_api_log($cbe_data, null, $request_result); - return $this->msg($request_result); - // } catch (\Exception $e) { - // // 捕获异常 - // $logContent["flie"] = $e->getFile(); - // $logContent["line"] = $e->getLine(); - // $logContent['all_content'] = "异常信息:\n"; - // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; - // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; - // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; - // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; - // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; - // $this->record_api_log($cbe_data, $logContent, null); - // return $this->msg(99999); - // } + $this->record_api_log($cbe_data, null, $request_result); + return $request_result; + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + $this->record_api_log($cbe_data, $logContent, null); + return $this->msg(99999); + } } - public function incremental_comparison($data = ['aud_id'=>'87','token'=>'caadd1be045a65f30b92aa805f1de54a']){ - // try { - // 你的业务逻辑 - if(count(input('post.')) > 0){ - $data = input('post.'); - } - if(!is_array($data)){ - return $this->msg(10005); - } - if(!array_key_exists('aud_id', $data) || !array_key_exists('token', $data)){ - return $this->msg(10001); - } - if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){ - return $this->msg(10005); - } - if(!$this->verify_data_is_ok($data['token'],'str')){ - return $this->msg(10005); - } - $request_result = $this->incremental_comparison_action($data); - // $this->record_api_log($cbe_data, null, $request_result); - return $this->msg($request_result); - // } catch (\Exception $e) { - // // 捕获异常 - // $logContent["flie"] = $e->getFile(); - // $logContent["line"] = $e->getLine(); - // $logContent['all_content'] = "异常信息:\n"; - // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; - // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; - // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; - // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; - // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; - // $this->record_api_log($cbe_data, $logContent, null); - // return $this->msg(99999); - // } - } - ################################################################业务接口################################################################ ################################################################业务接口################################################################ @@ -563,7 +536,7 @@ class Card extends Base{ acbd.bmi, acbd.body_age, acbd.head_circumference, - aud.birthday,aud.gender,aud.target_weight,aud.initial_weight,aud.initial_date,aud.aan_id + aud.birthday,aud.gender,aud.target_weight,aud.initial_weight,aud.initial_date from ".$this->card_use_db_name['1']." as acbd left join ".$this->card_use_db_name['2']." as aud on acbd.aud_id=aud.id where acbd.is_del=0 and acbd.aud_id='".$data['aud_id']."' @@ -635,11 +608,8 @@ class Card extends Base{ 'cumulative_day'=>'0' ], ]; - $language_data = new Language(); - $result_return = $language_data->handling_languages_from_multiple_countries('zh-Hans', $result_return); return $this->msg($result_return); }else{ - // 存储头围数据 $head_circumference = $result[0]['head_circumference']?json_decode($result[0]['head_circumference'],true):false; unset($result[0]['head_circumference']); @@ -655,6 +625,7 @@ class Card extends Base{ $result_end['score'] = $result_end['score']; $result_end['body_type'] = $result_end['body_type']; $result_end = $cardparts->conversion_interval($result_end); + $result_end['cplist'] = $this->grow_up_recommendation([ 'birthday'=>$result[0]['birthday'], 'body'=>[ @@ -781,13 +752,7 @@ class Card extends Base{ } // 这段业务处理可以删除,是做的临时的,假的end - // dump($result); - $language_str = Db::table($this->card_use_db_name['11'])->where(['id'=>$result[0]['aan_id']])->field('language')->find(); - $language_data = new Language(); - if(!$language_str['language']){ - $language_str['language'] = 'zh-Hans'; - } - $result_end = $language_data->handling_languages_from_multiple_countries($language_str['language'], $result_end); + return $this->msg($result_end); } } @@ -941,13 +906,13 @@ class Card extends Base{ // 曲线图动作函数 public function curve_chart_action($data){ - $card_body_curve_arr = implode(',',$this->card_body_curve_arr); $data['s_time'] = $data['s_time'].' 00:00:00'; $data['e_time'] = $data['e_time'].' 23:59:59'; $user_data_list = Db::table($this->card_use_db_name['1']) + // ->where('aud_id', $data['aud_id']) ->where(['aud_id'=>$data['aud_id'],'is_del'=> 0]) ->whereTime('record_time', 'between', [$data['s_time'], $data['e_time']]) ->field("record_type,record_time,REPLACE(CONVERT(varchar(10), record_time, 23), '-', '-') AS b_time,$card_body_curve_arr") @@ -994,17 +959,7 @@ class Card extends Base{ array_push($data_arr,$temporary_arr); } } - // dump($data); - $language_data = new Language(); - $user_language = Db::table($this->card_use_db_name['11']) - ->where(['token'=>$data['token'],'is_del'=>0]) - ->field('language') - ->find(); - if(!$user_language['language']){ - $user_language['language'] = 'zh-Hans'; - } - $result_end = $language_data->handling_languages_from_multiple_countries($user_language['language'], $data_arr); - return $this->msg($result_end); + return $this->msg($data_arr); } ################################################card_manual_recording @@ -1014,20 +969,6 @@ class Card extends Base{ // 减 bcsub(,,20) // 乘 bcmul(,,20) // 除 bcdiv(,,20) - // // 这里开始转换不同单位的身高体重为cm跟kg(start) - // if($data['height'][1] == 'kg'){ - // $data['height'] = $data['height'][0]; - // }else if($data['height'][1] == '斤'){ - // // 斤数除以2就是公斤 - // $data['height'] = bcdiv($data['height'][0],2,2); - // }else if($data['height'][1] == 'st:lb'){ - // $data['height'] = $data['height'][0]; - // }else if($data['height'][1] == 'lb'){ - // $data['height'] = $data['height'][0]; - // } - // // 这里开始转换不同单位的身高体重为cm跟kg(end) - // $adc_type = $type; - // $data['type'] = 1; // 判断头围数据是否存在是否合理 if(array_key_exists('head_data', $data)){ @@ -1118,6 +1059,80 @@ class Card extends Base{ $get_body_value['birthday'] = $user_data['birthday']; // 添加身高、体重、bmi、头围(如果有)的标尺标准 $get_body_value = $this->hwb_standard($get_body_value); + + + $enumeration_data = [ + 'fat_r'=>'脂肪率', + 'muscle'=>'肌肉率', + 'kcal'=>'基础代谢', + 'visceral'=>'内脏指数', + 'sfr'=>'皮下脂肪', + 'water'=>'水分', + 'bone'=>'骨重', + 'protein'=>'蛋白率', + 'bodyage'=>'身体年龄' + ]; + + // return $this->msg($get_body_value); + // 根据秤传过来的数据,去处理要存的结果 + if(array_key_exists('info', $data)){ + + + foreach ($data['info'] as $key => $value) { + if($key == 'bmi'){ + if($value > 0){ + $get_body_value['BMI'] = $value; + $get_body_value['BMI2'] = explode(',',$get_body_value['BMI2']); + $get_body_value['BMI2'][0] = $value; + $get_body_value['BMI2'] = implode(',',$get_body_value['BMI2']); + } + }else if($key == 'bodyage'){ + $get_body_value[$enumeration_data[$key]] = $value; + }else if($key == 'fatlevlval'){ + continue; + }else{ + if($value > 0){ + $get_body_value[$enumeration_data[$key]][0] = $value; + } + } + + + } + + // if($data['info']['fat_r'] > 0){ + // $get_body_value['脂肪率'][0] = $data['info']['fat_r']; + // } + // if($data['info']['muscle'] > 0){ + // $get_body_value['肌肉率'][0] = $data['info']['muscle']; + // } + // if($data['info']['kcal'] > 0){ + // $get_body_value['基础代谢'][0] = $data['info']['kcal']; + // } + // if($data['info']['visceral'] > 0){ + // $get_body_value['内脏指数'][0] = $data['info']['visceral']; + // } + // if($data['info']['sfr'] > 0){ + // $get_body_value['皮下脂肪'][0] = $data['info']['sfr']; + // } + // if($data['info']['water'] > 0){ + // $get_body_value['水分'][0] = $data['info']['water']; + // } + // if($data['info']['bone'] > 0){ + // $get_body_value['骨重'][0] = $data['info']['bone']; + // } + // // if($data['info']['fatlevlval'] > 0){//好像是肥胖等级,暂时废弃用自己算的 + // // $get_body_value['水分'][0] = $data['info']['fatlevlval']; + // // } + // if($data['info']['protein'] > 0){ + // $get_body_value['蛋白率'][0] = $data['info']['protein']; + // } + // if($data['info']['bmi'] > 0){ + // $data['info']['bmi2'] = explode(',',$get_body_value['BMI2']); + // $data['info']['bmi2'][0] = $data['info']['bmi']; + // $data['info']['bmi2'] = implode(',',$data['info']['bmi2']); + // } + } + $set_data = [ 'acd_id'=>$data['acd_id'], 'aud_id'=>$data['aud_id'], @@ -1153,6 +1168,7 @@ class Card extends Base{ // 时间日期转换,把'Y-m-d'转换成'Y-m-d H:i:s'格式 $set_data['record_time'] = $this->addCurrentTimeToDateString($set_data['record_time']); } + // 启动事务 Db::startTrans(); try{ @@ -1172,8 +1188,6 @@ class Card extends Base{ 'height'=>$get_body_value['身高'].',CM', 'weight'=>$get_body_value['体重'].',公斤', 'bmi'=>$get_body_value['BMI'], - // 'user_set_height'=>$get_body_value['身高'], - // 'user_set_weight'=>$get_body_value['体重'], 'target_current'=>$target_current, ]); } catch (\Exception $e) { @@ -1369,388 +1383,11 @@ class Card extends Base{ // 处理key名称一致end return $this->msg($data); } - ################################################incremental_comparison - public function incremental_comparison_action($data){ - // 加 bcadd(,,20) - // 减 bcsub(,,20) - // 乘 bcmul(,,20) - // 除 bcdiv(,,20) - // protected $card_use_db_name = [ - // '1'=>'app_card_body_data_copy1', - // '2'=>'app_user_data_copy1', - // '3'=>'pc_bmistand_copy1', - // '4'=>'pc_heightstand_copy1', - // '5'=>'pc_weightstand_copy1', - // '6'=>'pc_childrenprescription_copy1', - // '7'=>'pc_childprescriptionbyage_copy1', - // '8'=>'pc_heightstand_copy1', - // '9'=>'pc_weightstand_copy1', - // '10'=>'pc_bmistand_copy1', - // '11'=>'app_account_number_copy1', - // ]; - - - - - $return_data = []; - $user_last_data = Db::table($this->card_use_db_name['1']) - ->alias('a') - ->join(''.$this->card_use_db_name['2'].' b','a.aud_id = b.id','LEFT') - ->where('a.aud_id',$data['aud_id']) - ->order('record_time desc') - ->field('a.record_time as record_time,a.height_val,b.gender,b.nickname,b.gender,b.birthday') - ->find(); - - // 设置基础数据 - $return_data['nickname'] = $user_last_data['nickname']; - $return_data['gender'] = $user_last_data['gender'] == 1 ? '男' : '女'; - $return_data['birthday'] = $user_last_data['birthday']; - $return_data['age'] = $this->calculateAge($user_last_data['birthday']); - // dump($return_data); - // die; - $return_data['age_year'] = $return_data['age']['age_year']; - $return_data['age_year_unit'] = $return_data['age']['age_year_unit']; - $return_data['age_months'] = $return_data['age']['age_months']; - $return_data['age_months_unit'] = $return_data['age']['age_months_unit']; - $return_data['height'] = $user_last_data['height_val']; - unset($return_data['age']); - - - - $half_year = Db::table($this->card_use_db_name['1']) - ->where(['aud_id'=>$data['aud_id']]) - ->whereTime('record_time', '>=', '-6 month') - ->order('record_time desc') - ->field('id,record_time,height_val') - ->select(); - - $one_year = Db::table($this->card_use_db_name['1']) - ->where(['aud_id'=>$data['aud_id']]) - ->whereTime('record_time', '>=', '-12 month') - ->order('record_time desc') - ->field('id,record_time,height_val') - ->select(); - - $month_age = $this->calculateAgeInMonthsWithPrecision($user_last_data['birthday']); - - $height_standard = Db::table($this->card_use_db_name['12']) - ->where(['gender'=>$user_last_data['gender'],'age'=>['<=',$month_age]]) - ->order('age desc') - ->find(); - // dump($height_standard); - // 处理身体级别 - $true_altitude_list = [ - [ - 'maxvalue' => $height_standard['f1sd'], - 'minvalue' => 0, - 'text' => '矮', - 'color' => '#ff5656', - 'level' => 4 - ], - [ - 'maxvalue' => $height_standard['middle'], - 'minvalue' => $height_standard['f1sd'], - 'text' => '偏矮', - 'color' => '#ffab00', - 'level' => 2 - ], - [ - 'maxvalue' => $height_standard['z1sd'], - 'minvalue' => $height_standard['middle'], - 'text' => '标准', - 'color' => '#5ad06d', - 'level' => 1 - ], - [ - 'maxvalue' => $height_standard['z2sd'], - 'minvalue' => $height_standard['z1sd'], - 'text' => '偏高', - 'color' => '#6492f6', - 'level' => 3 - ], - [ - 'maxvalue' => 99999, - 'minvalue' => $height_standard['z2sd'], - 'text' => '高', - 'color' => '#3967d6', - 'level' => 5 - ] - ]; - $return_data['heightlevel'] = 1; - foreach ($true_altitude_list as $key => $value) { - // dump($return_data['height']); - // dump($value); - if($return_data['height'] >= $value['minvalue'] && $return_data['height'] < $value['maxvalue']){ - // dump($value); - $return_data['heightlevel'] = $value['level']; - } - } - // die; - // 处理半年信息 - if(count($half_year) >= 2){ - $return_data['halfyearheight'] = bcsub($half_year[0]['height_val'],$half_year[count($half_year)-1]['height_val'],2); - }else{ - $return_data['halfyearheight'] = 0; - } - // $height_standard_half = Db::table($this->card_use_db_name['12']) - // ->where(['gender'=>$user_last_data['gender'],'age'=>['<=',($month_age-6)<=0?0:$month_age-6]]) - // ->order('age desc') - // ->find(); - $height_standard_half = $this->count_increment_val($return_data,'half_year'); - // dump($height_standard_half); - // die; - $halfyearstandlist = [ - [ - 'val' => 0, - 'text' => '偏低', - 'color' => '#ffda69', - 'level' => 2 - ], - [ - 'val' => $height_standard_half, - 'text' => '正常', - 'color' => '#5ad06d', - 'level' => 1 - ] - ]; - - for ($i=count($halfyearstandlist)-1; $i >=0 ; $i--) { - if($return_data['halfyearheight'] >= $halfyearstandlist[$i]['val']){ - $return_data['halfyearheightlevel'] = $halfyearstandlist[$i]['level']; - break; - } - } - $return_data['halfyearstandheight'] = $halfyearstandlist[1]['val']; - // 处理一年信息 - if(count($one_year) >= 2){ - $return_data['yearheight'] = bcsub($one_year[0]['height_val'],$one_year[count($one_year)-1]['height_val'],2); - }else{ - $return_data['yearheight'] = 0; - } - // $height_standard_year = Db::table($this->card_use_db_name['12']) - // ->where(['gender'=>$user_last_data['gender'],'age'=>['<=',($month_age-12)<=0?0:$month_age-12]]) - // ->order('age desc') - // ->find(); - $height_standard_half = $this->count_increment_val($return_data,'one_year'); - $yearstandlist = [ - [ - 'val' => 0, - 'text' => '偏低', - 'color' => '#ffda69', - 'level' => 2 - ], - [ - 'val' => $height_standard_half, - 'text' => '正常', - 'color' => '#5ad06d', - 'level' => 1 - ] - ]; - for ($i=count($yearstandlist)-1; $i >=0 ; $i--) { - if($return_data['yearheight'] >= $yearstandlist[$i]['val']){ - $return_data['yearheightlevel'] = $yearstandlist[$i]['level']; - break; - } - } - $return_data['yearstandheight'] = $yearstandlist[1]['val']; - - $return_data['f3sd'] = $height_standard['f3sd']; - $return_data['f2sd'] = $height_standard['f2sd']; - $return_data['f1sd'] = $height_standard['f1sd']; - $return_data['median'] = $height_standard['middle']; - $return_data['z1sd'] = $height_standard['z1sd']; - $return_data['z2sd'] = $height_standard['z2sd']; - $return_data['z3sd'] = $height_standard['z3sd']; - $return_data['list'] = $true_altitude_list; - $return_data['halfyearstandlist'] = $halfyearstandlist; - $return_data['yearstandlist'] = $yearstandlist; - // dump($return_data); - // die; - $language_data = new Language(); - $zh_language = Db::table($this->card_use_db_name['11']) - ->where(['token'=>$data['token'],'is_del'=>0]) - ->field('id,language') - ->find(); - if(!$zh_language['language']){ - $zh_language['language'] = 'zh-Hans'; - } - $result_end = $language_data->handling_languages_from_multiple_countries($zh_language['language'], $return_data); - return $result_end; - - } - ################################################################其他接口################################################################ ################################################################其他接口################################################################ - public function count_increment_val($user,$type){ - // 加 bcadd(,,20) - // 减 bcsub(,,20) - // 乘 bcmul(,,20) - // 除 bcdiv(,,20) - // [ - // 'min_age' => 0, - // 'max_age' => 1, - // 'boy_val' => '26.1', - // 'girl_val' => '25.3', - // ], - $height_add_list = [ - [ - 'min_age' => 0, - 'max_age' => 1, - 'boy_val' => '26.1', - 'girl_val' => '25.3', - ], - [ - 'min_age' => 1, - 'max_age' => 2, - 'boy_val' => '12.0', - 'girl_val' => '12.2', - ], - [ - 'min_age' => 2, - 'max_age' => 3, - 'boy_val' => '8.3', - 'girl_val' => '8.4', - ], - [ - 'min_age' => 3, - 'max_age' => 4, - 'boy_val' => '7.3', - 'girl_val' => '7.5', - ], - [ - 'min_age' => 4, - 'max_age' => 5, - 'boy_val' => '7.2', - 'girl_val' => '7.1', - ], - [ - 'min_age' => 5, - 'max_age' => 6, - 'boy_val' => '6.4', - 'girl_val' => '6.4', - ], - [ - 'min_age' => 6, - 'max_age' => 7, - 'boy_val' => '7.8', - 'girl_val' => '7.5', - ], - [ - 'min_age' => 7, - 'max_age' => 8, - 'boy_val' => '5.2', - 'girl_val' => '5.2', - ], - [ - 'min_age' => 8, - 'max_age' => 9, - 'boy_val' => '5.1', - 'girl_val' => '5.6', - ], - [ - 'min_age' => 9, - 'max_age' => 10, - 'boy_val' => '5.0', - 'girl_val' => '6.3', - ], - [ - 'min_age' => 10, - 'max_age' => 11, - 'boy_val' => '6.8', - 'girl_val' => '6.2', - ], - [ - 'min_age' => 11, - 'max_age' => 12, - 'boy_val' => '6.2', - 'girl_val' => '5.0', - ], - [ - 'min_age' => 12, - 'max_age' => 13, - 'boy_val' => '8.0', - 'girl_val' => '3.7', - ], - [ - 'min_age' => 13, - 'max_age' => 14, - 'boy_val' => '5.4', - 'girl_val' => '1.7', - ], - [ - 'min_age' => 14, - 'max_age' => 15, - 'boy_val' => '4.6', - 'girl_val' => '0.7', - ], - [ - 'min_age' => 15, - 'max_age' => 16, - 'boy_val' => '1.6', - 'girl_val' => '0.4', - ], - [ - 'min_age' => 16, - 'max_age' => 17, - 'boy_val' => '0.8', - 'girl_val' => '0.3', - ], - [ - 'min_age' => 17, - 'max_age' => 18, - 'boy_val' => '0.0', - 'girl_val' => '0.8', - ], - ]; - - $temporary_arr1 = []; - $temporary_arr0 = []; - $gender = $user['gender'] == '男'?'boy_val':'girl_val'; - for ($i=0; $i < count($height_add_list); $i++) { - if($user['age_year'] >= $height_add_list[$i]['min_age'] && $user['age_year'] < $height_add_list[$i]['max_age']){ - $temporary_arr1 = $height_add_list[$i]; - if($i > 0){ - $temporary_arr0 = $height_add_list[$i-1]; - } - } - } - - $monthly = bcdiv($temporary_arr1[$gender],12,20); - if($type == 'half_year'){ - if($user['age_months'] >= 6){ - $return_data = bcmul($monthly,6,2); - return $return_data; - }else{ - if(count($temporary_arr0) > 0){ - $return_data = bcmul($monthly,$user['age_months'],20); - $return_data = bcadd($return_data,bcmul(bcdiv($temporary_arr0[$gender],12,20),bcsub(6,$user['age_months'],20),20),2); - return $return_data; - }else{ - $return_data = bcmul($monthly,6,2); - return $return_data; - } - } - }else{ - if($user['age_months'] < 12){ - if(count($temporary_arr0) > 0){ - $return_data = bcmul($monthly,$user['age_months'],20); - $return_data = bcadd($return_data,bcmul(bcdiv($temporary_arr0[$gender],12,20),bcsub(12,$user['age_months'],20),20),2); - return $return_data; - }else{ - $return_data = bcmul($monthly,12,2); - return $return_data; - } - }else{ - $return_data = bcmul($monthly,12,2); - return $return_data; - } - } - - } - public function body_temporary_use($age,$gender){ $return_data = [ 'height'=>'', diff --git a/application/testapp/controller/Cardparts.php b/application/testapp/controller/Cardparts.php index d27aa9d..0d08bc8 100644 --- a/application/testapp/controller/Cardparts.php +++ b/application/testapp/controller/Cardparts.php @@ -218,6 +218,7 @@ class Cardparts extends Base{ $temporary_arr['top_list'][$key]['offset'] = $this->calculate_landing_point($value['list'],$value['value'],$value['standard']); } } + // 如果是没有阻抗的测试,那么就不要底部的其他数据了 if($data['record_type']['value'] != 'by_device_adc'){ $temporary_arr['bottom_list'] = []; @@ -225,8 +226,10 @@ class Cardparts extends Base{ } // 处理底部list foreach ($temporary_arr['bottom_list'] as $key => $value) { + // 脂肪率& if($value['key_name'] == 'fat_r'){ + if($age < 30){ $temporary_arr['bottom_list'][$key]['list'] = $this->fat_r_w[$gender]['29']; }else{ @@ -236,10 +239,13 @@ class Cardparts extends Base{ if($temporary_arr['bottom_list'][$key]['standard'] == '异常'){ $temporary_arr['bottom_list'][$key] = $this->handling_exceptions($temporary_arr['bottom_list'][$key]); } + $temporary_arr['bottom_list'][$key]['offset'] = $this->calculate_landing_point($temporary_arr['bottom_list'][$key]['list'],$temporary_arr['bottom_list'][$key]['value'],$temporary_arr['bottom_list'][$key]['standard']); + // dump($temporary_arr['bottom_list'][$key]['offset']); } // 脂肪量 else if($value['key_name'] == 'fat_w'){ + if($age < 30){ $temporary_arr['bottom_list'][$key]['list'] = $this->fat_r_w[$gender]['29']; }else{ @@ -360,22 +366,28 @@ class Cardparts extends Base{ public function calculate_landing_point($data,$val,$t_val){ // 根据字典确认有几个区间 $num = count($data); + if($num <= 0){ + return 0; + } // 没个区间占比 $a_section = bcdiv(100,$num,2); $temporary_data = []; $num_0 = 0; // 看看值是在哪个区间 foreach ($data as $key => $value) { - if($t_val == $value['text']){ + if($val>=$value['min_val'] && $val<$value['max_val']){ $temporary_data = $value; $num_0 = $key; break; } } -// 加 bcadd(,,20) - // 减 bcsub(,,20) - // 乘 bcmul(,,20) - // 除 bcdiv(,,20) + if(count($temporary_data) <= 0){ + return 0; + } + // 加 bcadd(,,20) + // 减 bcsub(,,20) + // 乘 bcmul(,,20) + // 除 bcdiv(,,20) $max_num = trim($temporary_data['max_val']); $min_num = trim($temporary_data['min_val']); if($val < $temporary_data['max_val']){ diff --git a/application/testapp/controller/Cardpublic.php b/application/testapp/controller/Cardpublic.php index 7fb4aeb..b991862 100644 --- a/application/testapp/controller/Cardpublic.php +++ b/application/testapp/controller/Cardpublic.php @@ -8,11 +8,11 @@ use Exception; class Cardpublic extends Base{ protected $cardpublic_use_db_name = [ - '1'=>'app_user_data_copy1', - '2'=>'app_card_data_sub_item_copy1', - '3'=>'app_card_data_sub_item_data_copy1', - '4'=>'admin_estimate_copy1', - '5'=>'app_card_data_copy1' + '1'=>'app_user_data', + '2'=>'app_card_data_sub_item', + '3'=>'app_card_data_sub_item_data', + '4'=>'admin_estimate', + '5'=>'app_card_data' ]; protected $curve_color = ['#f7b03e','#fb7b92','#ff9f40','#3fcba7',]; diff --git a/application/testapp/controller/Deepseek.php b/application/testapp/controller/Deepseek.php index 73bb81c..f77136c 100644 --- a/application/testapp/controller/Deepseek.php +++ b/application/testapp/controller/Deepseek.php @@ -8,10 +8,10 @@ use think\Db; class Deepseek extends Base{ protected $msginformation_use_db_name = [ - '1'=>'admin_editor_text_content_copy1', - '2'=>'admin_editor_text_like_up_log_copy1', - '3'=>'admin_notice_banner_copy1', - '4'=>'admin_business_cooperation_copy1' + '1'=>'admin_editor_text_content', + '2'=>'admin_editor_text_like_up_log', + '3'=>'admin_notice_banner', + '4'=>'admin_business_cooperation' ]; protected $page_num = 10; // 加 bcadd(,,20) diff --git a/application/testapp/controller/Device.php b/application/testapp/controller/Device.php index 57a9e84..3d9e79e 100644 --- a/application/testapp/controller/Device.php +++ b/application/testapp/controller/Device.php @@ -10,9 +10,9 @@ class Device extends Base{ protected $color = ['#FF5656','#FFAB00','#5AD06D','#6492F6','#3967D6']; protected $device_use_db_name = [ - '1'=>'app_device_data_copy1', - '2'=>'app_account_number_copy1', - '3'=>'app_device_code_data_copy1', + '1'=>'app_device_data', + '2'=>'app_account_number', + '3'=>'app_device_code_data', ]; diff --git a/application/testapp/controller/Index.php b/application/testapp/controller/Index.php index 2296ca7..fb9a32b 100644 --- a/application/testapp/controller/Index.php +++ b/application/testapp/controller/Index.php @@ -5,23 +5,22 @@ namespace app\testapp\controller; use think\Db; use \think\Validate; use app\testapp\controller\Language; -use think\Cache; // use ip2region\Ip2Region; class Index extends Base{ protected $moren_gufen_diqu = '北京,北京'; - protected $db_name = ['2'=>'app_card_body_data_copy1','6'=>'app_card_skip_data_copy1','8'=>'app_card_vitalcapacity_data_copy1','10'=>'app_card_data_sub_item_data_copy1']; + protected $db_name = ['2'=>'app_card_body_data','6'=>'app_card_skip_data','8'=>'app_card_vitalcapacity_data','10'=>'app_card_data_sub_item_data']; protected $index_use_db_name = [ - '1'=>'app_version_log_copy1', - '2'=>'app_user_data_copy1', - '3'=>'app_card_body_data_copy1', - '4'=>'app_device_code_data_copy1', - '5'=>'app_device_data_copy1', - '6'=>'app_card_data_copy1', - '7'=>'app_account_number_copy1', - '8'=>'app_card_data_sub_item_copy1', - '9'=>'app_card_data_sub_item_data_copy1', - '10'=>'admin_estimate_copy1' + '1'=>'app_version_log', + '2'=>'app_user_data', + '3'=>'app_card_body_data', + '4'=>'app_device_code_data', + '5'=>'app_device_data', + '6'=>'app_card_data', + '7'=>'app_account_number', + '8'=>'app_card_data_sub_item', + '9'=>'app_card_data_sub_item_data', + '10'=>'admin_estimate' ]; // protected $card_key = ['2'=>'body','6'=>'skip','8'=>'vitalcapacity']; protected $default_card = ['2','6','8']; @@ -103,7 +102,7 @@ class Index extends Base{ ################################################################个人资料卡################################################################ // 检测版本及判断是否登录失效 - public function login_invalid_version($data = ['token'=>'2d4ea9b3f44b169ddf64b2f3d2725ceb','is_wechat'=>false]){ + public function login_invalid_version($data = ['token'=>'2d4ea9b3f44b169ddf64b2f3d2725ceb']){ // try { // 获取客户端IP $ip = request()->ip(); @@ -139,9 +138,6 @@ class Index extends Base{ if(!array_key_exists('token', $data)){ return $this->msg(10001); } - if(!array_key_exists('is_wechat', $data)){ - $data['is_wechat'] = false; - } $result = Db::table($this->index_use_db_name['1'])->order('is_del,id desc')->find(); if($result){ $version = $result['version_num_original']; @@ -150,30 +146,13 @@ class Index extends Base{ $version = ''; $url = ''; } - $user_token_state = $this->token_time_validate($data['token']); - // dump($user_token_state); - $language_data = $this->pd_language($user_token_state['language'],$isSupportedLanguage,$language); + $language_data = $this->pd_language($user_token_state['language'],$isSupportedLanguage,$language); if($user_token_state['state'] === false){ - return $this->msg(-1,'未登录',[ - 'version'=>$version, - 'url'=>$url, - 'language'=>$data['is_wechat']?'zh-Hans':$language_data['user_language'], - 'ip_address'=>$language_data['address'], - 'language_arr'=>$this->process_Language() - ]); + return $this->msg(-1,'未登录',['version'=>$version,'url'=>$url,'language'=>$language_data,'language_arr'=>$this->process_Language()]); }else{ - if($data['is_wechat'] == true){ - $result = Db::table($this->index_use_db_name['7'])->where(['token'=>$data['token']])->update(['language'=>'zh-Hans']); - } - return $this->msg([ - 'version'=>$version, - 'url'=>$url, - 'language'=>$data['is_wechat']?'zh-Hans':$language_data['user_language'], - 'ip_address'=>$language_data['address'], - 'language_arr'=>$this->process_Language() - ]); + return $this->msg(['version'=>$version,'url'=>$url,'language'=>$language_data,'language_arr'=>$this->process_Language()]); } // } catch (\Exception $e) { @@ -374,7 +353,7 @@ class Index extends Base{ // 获取账号下用户列表 // $type 1获取列表,2获取详细信息 - public function get_user_card_list($data = ['aan_id'=>87,'type'=>2,'token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ + public function get_user_card_list($data = ['aan_id'=>4,'type'=>2,'token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ try { // 你的业务逻辑 if(count(input('post.')) > 0){ @@ -382,6 +361,7 @@ class Index extends Base{ } if(!array_key_exists('token', $data) || !array_key_exists('aan_id', $data) || !array_key_exists('type', $data)){ // 失败 + $this->record_api_log($data, null, ['code'=>10001,'msg'=>'',[]]); return $this->msg(10001); } if(!$this->verify_data_is_ok($data['aan_id'],'intnum')){ @@ -440,7 +420,7 @@ class Index extends Base{ } // 获取指定用户详细信息 - public function get_user_data_information($data = ['aud_id'=>144]){ + public function get_user_data_information($data = ['aud_id'=>61]){ // try { // 你的业务逻辑 if(count(input('post.')) > 0){ @@ -1165,17 +1145,12 @@ class Index extends Base{ public function pd_language($user_language,$isSupportedLanguage,$language){ if(!$user_language){ if($isSupportedLanguage){ - // $result = $language; - $result['user_language'] = null; - $result['address'] = $language; + $result = $language; }else{ - $result = null; // 默认语言为中文 - $result['user_language'] = null; - $result['address'] = null; + $result = 'zh-Hans'; // 默认语言为中文 } }else{ - $result['user_language'] = $user_language; - $result['address'] = $language; + $result = $user_language; } return $result; } diff --git a/application/testapp/controller/Language.php b/application/testapp/controller/Language.php index 6bfddf1..5115a12 100644 --- a/application/testapp/controller/Language.php +++ b/application/testapp/controller/Language.php @@ -16,19 +16,10 @@ class Language extends Base 'de' => 'German' ]; - // $language_data = new Language(); - // if(!$language_str['language']){ - // $language_str['language'] = 'zh-Hans'; - // } - // $result_end = $language_data->handling_languages_from_multiple_countries($language_str['language'], $result_end); - // 语言映射表 protected $languageMap = [ 'en' => [ '操作成功' => 'Success', - '男' => 'Male', - '女' => 'Female', - '年龄' => 'Age', '体重' => 'Weight', '身高' => 'Height', '消瘦' => 'Slim', @@ -40,14 +31,12 @@ class Language extends Base 'BMI是身体质量指数,是目前国际上常用的衡量人体胖瘦程度以及是否健康的一个标准。' => "BMI is the body mass index, which is currently a commonly used international standard for measuring the degree of body fat, thinness, and health.", '公斤' => "kg", 'CM' => "cm", - '岁' => " years,", - '个月' => " months", '年' => "-", '月' => "-", '日' => "", '身体得分' => "Physical score", '分' => "score", - '身体类型' => "Body Type", + '身体类型' => "body type", '健美肌肉型' => "Bodybuilding muscle type", '低' => "Low", '偏低' => "Slightly low", @@ -56,171 +45,48 @@ class Language extends Base '高' => "High", '矮' => "Short", '偏矮' => "Slightly short", - // '脂肪率' => "Body Fat Percentage", - '脂肪率' => "Fat%", + '脂肪率' => "Body Fat Percentage", '体脂率是指身体成分中,脂肪组织所占的比率。测量体脂率比单纯的只测量体重更能反映我们身体的脂肪水平(肥胖程度)。' => "Body fat percentage refers to the proportion of fat tissue in body composition. Measuring it provides a more accurate reflection of body fat levels (degree of obesity) than weight measurement alone.", - // '脂肪量' => "Fat Mass", - '脂肪量' => "Fat", + '脂肪量' => "Fat Mass", '人体脂肪的重量' => "Body Fat Weight", - // '肌肉率' => "Muscle Percentage", - '肌肉率' => "Muscle%", + '肌肉率' => "Muscle Percentage", '优' => "Excellent", '根据人体肌肉总量和人体体重、身高等相结合得到的人体的一个比例值,这个值的范围决定一个人的身体健康状况以及力量的多少。' => "Muscle percentage is a ratio derived from total muscle mass, body weight, height, etc. Its range determines a person's health status and strength level.", - // '肌肉量' => "Muscle Mass", - '肌肉量' => "MM", + '肌肉量' => "Muscle Mass", '不足' => "Insufficient", '肌肉量=实际体重*肌肉率' => "Muscle Mass = Actual Weight × Muscle Percentage", - // '水分' => "Body Water", - '水分' => "TBW%", + '水分' => "Body Water", '指人体内水分比例。' => "Refers to the proportion of water in the human body.", - // '蛋白量' => "Protein Mass", '蛋白量' => "Protein Mass", '蛋白量=实际体重*蛋白率' => "Protein Mass = Actual Weight × Protein Percentage", - // '骨重' => "Bone Mass", - '骨重' => "BMC", + '骨重' => "Bone Mass", '单位体积内,骨组织、骨矿物质(钙、磷等)和骨基质(骨胶原、蛋白率、无机盐等等)含量,骨量代表它们骨骼健康的情况。' => "Bone mass refers to the content of bone tissue, minerals (calcium, phosphorus, etc.), and bone matrix (collagen, proteins, inorganic salts, etc.) per unit volume, reflecting skeletal health.", - // '蛋白率' => "Protein Percentage", - '蛋白率' => "Protein%", + '蛋白率' => "Protein Percentage", '人体内蛋白率含量。' => "The proportion of protein in the human body.", - // '基础代谢' => "Basal Metabolic Rate (BMR)", - '基础代谢' => "BMR", + '基础代谢' => "Basal Metabolic Rate (BMR)", '指人体在清醒而又极端安静的状态下,不受肌肉活动、环境温度、食物及精神紧张等影响时的能量代谢率' => "The energy expenditure rate when the body is awake, completely at rest, and unaffected by muscle activity, ambient temperature, food intake, or mental stress.", - // '内脏指数' => "Visceral Fat Index", - '内脏指数' => "VFL", + '内脏指数' => "Visceral Fat Index", '警惕' => "Caution", '危险' => "Danger", - // '内脏脂肪指数' => "Visceral Fat Level", - '内脏脂肪指数' => "VFI", - // '皮下脂肪' => "Subcutaneous Fat", - '皮下脂肪' => "SubQ Fat", + '内脏脂肪指数' => "Visceral Fat Level", + '皮下脂肪' => "Subcutaneous Fat", '皮下脂脂肪就是贮存于皮下的脂肪组织,人体的脂肪大约有2/3贮存在皮下组织' => "Subcutaneous fat refers to adipose tissue stored under the skin. About two-thirds of body fat is stored subcutaneously.", - // '肥胖等级' => "Obesity Level", '肥胖等级' => "Obesity Level", '体重不足' => "Underweight", - '去脂体重' => "Lean Body Mass", - '体型' => "Body Type", - '体龄' => "Biological Age", '肥胖的程度,表现实际体重与理想体重的差距。肥胖等级是判定肥胖症的一个指标。' => "Obesity level indicates the disparity between actual and ideal weight, serving as a diagnostic criterion for obesity.", - '孩子可能存在营养不良:对于处在生长发育期的孩子而言,蛋白质、碳水化合物、维生素和矿物质这四类营养素非常重要。建议补充足够的蛋白质、锌、钙、铁、维生素D、赖氨酸等营养。建议补充含鸡内金山楂膏健脾开胃类药食同源食物。' => "The child may be malnourished: For growing children, protein, carbohydrates, vitamins, and minerals are critical. Ensure adequate intake of protein, zinc, calcium, iron, vitamin D, lysine, etc. Consider herbal foods like chicken gizzard-hawthorn paste to improve digestion and appetite.", - + '孩子可能存在营养不良:对于处在生长发育期的孩子而言,最有利于长高的营养素是蛋白质、碳水化合物、维生素和矿物质四类。建议补充足够的蛋白质、锌、铁、钙、维生素D、赖氨酸等营养。' => "The child may be malnourished: For children in their growth and development stage, the most beneficial nutrients for height growth are proteins, carbohydrates, vitamins, and minerals. It is recommended to ensure adequate intake of nutrients such as protein, zinc, iron, calcium, vitamin D, and lysine.", '坚持适当、科学的跳跃运动能够科学地增加学生体重,能够改善学 生体重过低的情况;同时运动会消耗能量并加速胃肠蠕动,这会使孩子的食欲大开,再配合均衡的营养有利于孩子增重。' => "Moderate, scientifically designed jumping exercises can help underweight students gain weight by boosting energy expenditure and gastrointestinal motility, thereby increasing appetite. Combined with balanced nutrition, this supports healthy weight gain.", - - '孩子开始对于赞赏、鼓励、认同和肯定有需求,而且此阶段父亲在孩子的性格塑造、情绪控制以及责任感培养方面扮演着重要的角色,必须告诉孩子什么事应该做、什么事不应该做,并经常性地给孩子一些积极地暗示。例如,可以时常向孩子表达“我会一直在你身边,不要害怕””我对你的进步都看在眼里等类似的话语。' => 'Children begin developing needs for praise, encouragement, recognition and affirmation. During this phase, fathers play a vital role in character formation, emotional regulation and responsibility cultivation. Clearly communicate appropriate behaviors while providing consistent positive reinforcement, such as saying: "I\'ll always be here for you" or "I see your progress."', - - '步入最佳学习期,除了文化课的学习更多的还有情绪调节、人际交往的学习,会模仿父母、老师同学。此阶段需要的不仅是尊重和信任,还需要更多自由选择的权利,变管制为引导。' => 'Entering the optimal learning period, children develop emotional regulation and social skills beyond academics, mimicking parents, teachers and peers. They require not just respect and trust, but also increased autonomy - transitioning from control to guidance.', - - '该年龄段睡眠时间建议:11-14小时' => 'Recommended sleep duration: 11-14 hours', - - '0-1岁的孩子:6个月之前多练习趴着、抬头、翻身等,6个月后练习爬行,8个月后可尝试坐着。充分的爬行运动有利于孩子协调性和平衡力的培养。' => '0-1 year olds: Practice tummy time, head lifting and rolling before 6 months; crawling after 6 months; attempt sitting at 8 months. Ample crawling enhances coordination and balance.', - - '3-7岁的孩子:骑两轮车、拍踢球、打篮球、游泳、爬山,每天高强度运动不超过30分钟。' => '3-7 year olds: Bicycle riding, ball games, basketball, swimming, mountain climbing. Limit high-intensity exercise to 30 minutes daily.', - - '正值青春期,生理的特点决定了情绪的跌宕起伏。当孩子出现情绪问题时,父母可以告诉孩子一些解决的办法,然后让他自行体悟和理解,教会孩子接纳情绪的方法而不是如何对抗情绪。' => 'Adolescents experience physiological mood fluctuations. When emotional issues arise, parents should teach coping strategies for self-discovery, emphasizing emotional acceptance over resistance.', - - '该年龄段睡眠时间建议:8-10小时' => 'Recommended sleep duration: 8-10 hours', - - '睡眠时间建议:晚上9点到凌晨1点、早上5点到7点是孩子生长激素分泌最多的时间段,此时进入深度睡眠,生长激素的分泌就会最大化,建议处在生长发育期的孩子尽量在9点前睡觉。' => 'Optimal sleep window: 9pm-1am and 5-7am when growth hormone peaks. Maximize secretion through deep sleep. Growing children should sleep before 9pm.', - - '1、情绪的不稳定影响了下丘脑及垂体系统的正常工作,进而使垂体生长激素分泌减少,长期的情绪障碍除了影响身高,同时还会造成孩子智力增长慢、多动、人际关系不协调等异常现象。' => '1. Emotional instability disrupts hypothalamic-pituitary function, reducing growth hormone secretion. Chronic emotional issues may impair height development, cognitive growth, and cause hyperactivity or social maladjustment.', - - '1-3岁的孩子:此年龄段实现了由走到跑的转变,神经系统也得到了发育。鼓励孩子有利于生长发育的活动即可:踩图案、绕障碍行走、学小动物走路(如青蛙跳、猴子跑、老虎匍匐前进等)、仰卧起坐等。' => '1-3 year olds: Transitioning from walking to running with developing nervous systems. Encourage developmental activities: pattern stepping, obstacle courses, animal walks (frog jumps, monkey runs, tiger crawls), and sit-ups.', - - '该年龄段睡眠时间建议:14-17小时' => 'Recommended sleep duration: 14-17 hours', - - '该年龄段睡眠时间建议:10-13小时' => 'Recommended sleep duration: 10-13 hours', - - '该年龄段睡眠时间建议:12-15小时' => 'Recommended sleep duration: 12-15 hours', - - '除了满足食物等生理需求,需要建立足够的安全感,充分陪伴、呵护。还要在排除一些安全隐患后适当满足孩子的探索需求。' => 'Beyond physiological needs like food, provide security through attentive care while enabling safe exploration after risk assessment.', - - '该年龄段睡眠时间建议:9-11小时' => 'Recommended sleep duration: 9-11 hours', - - '8-16岁的孩子:1、每周3-5次跳绳,50-100次左右/组,每天做5组,每组间隔5分钟;2、立定跳远,每周5-7次,每次20-50次;3、慢跑500-1000米;3、20个俯卧撑,30个上下蹲、30个仰卧起坐。' => '8-16 year olds: 1) Rope skipping 3-5x/week: 5 sets of 50-100 skips daily with 5-minute intervals; 2) Standing long jumps 5-7x/week (20-50 reps); 3) Jogging 500-1000m; 4) 20 push-ups, 30 squats, 30 sit-ups.', - - '这个阶段的孩子最调皮,一方面非常依赖父母,另一方面又相对独立。这个阶段仍然需要安全感,并且父母本身的心理状态对孩子的影响依然深远,当他们情绪不稳定,孩子也极有可能受到影响。' => 'Children at this stage exhibit mischievousness while balancing dependence and independence. They still require security, and parental emotional stability profoundly impacts them - children often mirror parental emotional turbulence.', - - '孩子可能存在营养不良:对于处在生长发育期的孩子而言,蛋白质、碳水化合物、维生素和矿物质这四类营养素非常重要。建议补充足够的蛋白质、锌、钙、铁、维生素D、赖氨酸等营养。' => 'The child may be malnourished: For growing children, four key nutrients - proteins, carbohydrates, vitamins and minerals - are crucial. Recommend supplementing adequate protein, zinc, calcium, iron, vitamin D, and lysine.', - - '孩子可能存在营养不良:对于处在生长发育期的孩子而言,最有利于长高的营养素是蛋白质、碳水化合物、维生素和矿物质四类。建议补充足够的蛋白质、锌、铁、钙、维生素D、赖氨酸等营养。' => 'The child may be malnourished: The most height-beneficial nutrients for growing children are proteins, carbohydrates, vitamins and minerals. Recommend supplementing adequate protein, zinc, iron, calcium, vitamin D, and lysine.', - - '对于处在生长发育期的孩子而言,最有利于长高的营养素是蛋白质、碳水化合物、维生素和矿物质四类。建议补充足够的蛋白质、锌、铁、钙、维生素D、赖氨酸等营养,预防营养不良。' => 'For growing children, the most height-promoting nutrients are proteins, carbohydrates, vitamins and minerals. Recommend supplementing adequate protein, zinc, iron, calcium, vitamin D, and lysine to prevent malnutrition.', - - '超重的孩子如不加以控制,则极易向肥胖转变。超重的孩子饮食注意事项:控制食量,吃八分饱;三餐规律,避免暴饮暴食;细嚼慢咽;营养均衡搭配,拒绝高油、高盐、高糖的食物,养成清淡的口味。' => 'Overweight children easily progress to obesity without intervention. Dietary guidelines: 80% fullness; regular meals; thorough chewing; balanced nutrition; avoiding greasy/salty/sugary foods; developing light tastes.', - - '孩子可能存在中度营养不良:对于处在生长发育期的孩子而言,最有利于长高的营养素是蛋白质、碳水化合物、维生素和矿物质四类。建议补充足够的蛋白质、锌、铁、钙、维生素D、赖氨酸等营养。' => 'The child may have moderate malnutrition: The most height-beneficial nutrients are proteins, carbohydrates, vitamins and minerals. Recommend supplementing adequate protein, zinc, iron, calcium, vitamin D, and lysine.', - - '孩子可能存在重度营养不良:对于处在生长发育期的孩子而言,最有利于长高的营养素是蛋白质、碳水化合物、维生素和矿物质四类。建议补充足够的蛋白质、锌、铁、钙、维生素D、赖氨酸等营养。' => 'The child may have severe malnutrition: The most height-beneficial nutrients are proteins, carbohydrates, vitamins and minerals. Recommend supplementing adequate protein, zinc, iron, calcium, vitamin D, and lysine.', - - '1、肥胖在某种意义来说是隐性的营养不良,由于摄入热量过高,孩子虽然看着胖,但营养的摄入是不均衡的,尤其对于8-14岁的孩子来说,肥胖会极大地提高性早熟的概率。肥胖的孩子过度进食甜食、油腻的食物极易出现血糖高、高脂血症从而影响生长激素的分泌,影响终身高。肥胖的孩子更容易缺乏维生素D影响骨骼的钙化和成长。2、肥胖的孩子饮食注意事项:控制食量,吃八分饱;三餐规律,避免暴饮暴食;细嚼慢咽;营养均衡搭配,拒绝高油、高盐、高糖的食物,养成清淡的口味。' => '1. Obesity represents hidden malnutrition - while calorie intake is excessive, nutrition remains unbalanced. Particularly for 8-14 year olds, obesity significantly increases precocious puberty risks. Overconsumption of sweets/greasy foods elevates blood sugar/lipids, impairing growth hormone secretion and final height. Obese children also face higher vitamin D deficiency risks, affecting bone calcification. 2. Dietary guidelines: 80% fullness; regular meals; thorough chewing; balanced nutrition; avoiding greasy/salty/sugary foods; developing light tastes.', - - '对于处在生长发育期的孩子而言,蛋白质、碳水化合物、维生素和矿物质这四类营养素非常重要。建议补充足够的蛋白质、锌、铁、钙、维生素D、赖氨酸等营养,预防营养不良造成体型偏瘦。' => 'For growing children, four key nutrients - proteins, carbohydrates, vitamins and minerals - are essential. Recommend supplementing adequate protein, zinc, iron, calcium, vitamin D, and lysine to prevent underweight malnutrition.', - - '超重或肥胖的孩子如不加以控制,则极易向肥胖转变。超重或肥胖的孩子饮食注意事项:控制食量,吃八分饱;三餐规律,避免暴饮暴食;细嚼慢咽;营养均衡搭配,拒绝高油、高盐、高糖的食物,养成清淡的口味。建议补充含鸡内金山楂膏健脾开胃类药食同源食物。' => 'Overweight/obese children easily progress to worse obesity without control. Dietary guidelines: 80% fullness; regular meals; thorough chewing; balanced nutrition; avoiding greasy/salty/sugary foods; developing light tastes. Recommend supplementing with chicken gizzard-hawthorn paste (a food-grade herbal digestant).', - - '对于处在生长发育期的孩子而言,蛋白质、碳水化合物、维生素和矿物质这四类营养素非常重要。建议补充足够的蛋白质、锌、钙、维生素D、赖氨酸等营养,预防营养不良造成体型偏瘦。建议补充含鸡内金山楂膏健脾开胃类药食同源食物。' => 'For growing children, four key nutrients - proteins, carbohydrates, vitamins and minerals - are essential. Recommend supplementing adequate protein, zinc, calcium, vitamin D, and lysine to prevent underweight malnutrition, along with chicken gizzard-hawthorn paste (a food-grade herbal digestant).', - - '对于处在生长发育期的孩子而言,最有利于长高的营养素是蛋白质、碳水化合物、维生素和矿物质四类。建议补充足够的蛋白质、锌、钙、维生素D、赖氨酸等营养,预防营养不良。铁' => 'For growing children, the most height-promoting nutrients are proteins, carbohydrates, vitamins and minerals. Recommend supplementing adequate protein, zinc, calcium, vitamin D, and lysine to prevent malnutrition. Iron.', - - '运动会消耗能量并加速胃肠蠕动,这会使孩子的食欲大开,再配合均衡的营养有利于孩子增重。'=> 'Physical activity burns calories and enhances gastrointestinal motility, significantly stimulating children\'s appetite. When combined with balanced nutrition, this effectively supports healthy weight gain.', - - '体育运动可以有效刺激骨骼与全身关节,从而促进生长激素分泌,加速软骨细胞分裂,从而促进了身高的增长。跳绳运动是一项非常健康的运动方式,可以促进青少年的骨骼生长和发育,促进青少年的体质健康。' => 'Exercise actively stimulates bones and joints throughout the body, promoting growth hormone secretion and accelerating chondrocyte division to facilitate height increase. Rope skipping is an exceptionally beneficial exercise that enhances adolescents\' bone development and overall physical fitness.', - - '适宜的运动,能促进全身及骨的钙磷代谢,促进骨生长,长期的户外运动,加速骨细胞的生长,使管状骨变长,横径增粗,促进生长发育。'=> 'Moderate exercise optimizes whole-body calcium-phosphorus metabolism and bone growth. Regular outdoor activities accelerate osteocyte proliferation, lengthening long bones while increasing their diameter to promote healthy development.', - - '运动会消耗能量,培养运动习惯,减少静坐时间,建议每天参加体育运动的时间至少30分钟,不贪睡,睡得越久,人体代谢速度就会越慢,极易囤积脂肪。'=> 'Exercise consumes energy, establishes active habits and reduces sedentary behavior. We recommend minimum 30 minutes of daily physical activity. Excessive sleep slows metabolic rate and promotes fat accumulation.', - - '体育运动可以有效刺激骨骼与全身关节,从而促进生长激素分泌,加速软骨细胞分裂,从而促进了身高的增长。长期科学地坚持跳绳,可以在很大程度上增加骨强度和骨密度,促进骨生长,从而改善青少年的骨健康情况。跳绳运动是一项非常健康的运动方式,可以促进青少年的骨骼生长和发育,促进青少年的体质健康。' => 'Physical training effectively activates skeletal and articular systems, boosting growth hormone production and chondrocyte multiplication to enhance height. Scientifically-guided long-term rope skipping significantly improves bone mineral density and strength, optimizing adolescents\' skeletal health. This exercise is particularly effective for promoting bone development and physical conditioning.', - - '体育运动可以有效刺激骨骼与全身关节,从而促进生长激素分泌,加速软骨细胞分裂,从而促进了身高的增长。补救身高的最好方式就是长期坚持适当的体育运动,只要是采取科学的锻炼方法,都能促进骨骼的生长。在所有的运动项目中,全身运动、动力性跳跃运动和伸展运动这三类运动最能够促进身高增长。' => 'Exercise stimulates osseous and joint systems to enhance growth hormone release and cartilage cell division, facilitating height development. The most effective height-correction method involves sustained, moderate physical activity - any scientifically-designed regimen promotes bone growth. Among all exercises, full-body movements, plyometric jumps and stretching prove most beneficial for height improvement.', - - '运动会消耗能量,会增加体内脂肪的消耗,减少储存量,起到帮助控制体重的作用;培养运动习惯,减少静坐时间,建议每天参加体育运动的时间至少30分钟,不贪睡,睡得越久,人体代谢速度就会越慢,极易囤积脂肪。' => 'Physical exertion increases calorie expenditure and fat utilization while reducing adipose storage, effectively aiding weight management. Establish consistent exercise routines and minimize inactivity with at least 30 minutes daily movement. Prolonged sleep decreases metabolic efficiency and encourages fat deposition.', - - '运动会消耗能量并加速胃肠蠕动,这会使孩子的食欲大开,再配合均衡的营养有利于孩子维持合格的体重。' => 'Exercise burns calories and stimulates digestive peristalsis, markedly improving children\'s appetite. Paired with nutritional balance, this helps maintain optimal body weight parameters.', - - '建议多做跳跃运动(立定跳远,跳绳)中跳跃刺激的频率以及速度都对于机体中过多脂肪的消耗起到促进作用,能够一定程度上起到预防和控制肥胖、降低体重的作用;同时培养运动习惯,减少静坐时间,建议每天参加体育运动的时间至少30分钟,不贪睡,睡得越久,人体代谢速度就会越慢,极易囤积脂肪。' => 'Prioritize jumping exercises (standing broad jumps, rope skipping) as their impact frequency and velocity significantly enhance fat oxidation, effectively preventing obesity and aiding weight control. Cultivate regular workout habits and limit sedentary periods to minimum 30 minutes daily activity. Excessive sleep duration reduces metabolic rate and promotes lipid accumulation.', - - '运动会消耗能量并加速胃肠蠕动,这会使孩子的食欲大开,再配合均衡的营养有利于孩子维持合格的体重。' => 'Physical activity expends energy and intensifies gastrointestinal motility, substantially boosting children\'s appetite. Combined with balanced nutrition, this assists in maintaining healthy weight standards.', - - '体育运动可以有效刺激骨骼与全身关节,从而促进生长激素分泌,加速软骨细胞分裂,从而促进了身高的增长。' => 'Systematic exercise effectively activates skeletal and articular systems, stimulating growth hormone secretion and accelerating cartilage cell proliferation to optimize height development.', - - '坚持适当、科学的跳跃运动能够科学地增加学生体重,能够改善学生体重过低的情况;同时运动会消耗能量并加速胃肠蠕动,这会使孩子的食欲大开,再配合均衡的营养有利于孩子增重。' => 'Consistent, properly-designed jumping exercises can scientifically increase students\' body mass and correct underweight conditions. Concurrently, physical training consumes energy and enhances digestive motility, stimulating appetite which - when supported by nutritional balance - promotes healthy weight gain.', - - '《中华人民共和国卫生行业标准WS/T 423-2022》' => "《Chinese Health Industry Standard WS 423-2013》", - + '3-7岁的孩子:骑两轮车、拍踢球、打篮球、游泳、爬山,每天高强度运动不超过30分钟。' => "Ages 3–7: Bicycling, ball games, basketball, swimming, hiking. Limit high-intensity exercise to 30 minutes daily.", + '该年龄段睡眠时间建议:9-11小时' => "Recommended sleep duration for this age group: 9–11 hours.", + '孩子开始对于赞赏、鼓励、认同和肯定有需求,而且此阶段父亲在孩子的性格塑造、情绪控制以及责任感培养方面扮演着重要的角色,必须告诉孩子什么事应该做、什么事不应该做,并经常性地给孩子一些积极地暗示。例如,可以时常向孩子表达“我会一直在你身边,不要害怕””我对你的进步都看在眼里等类似的话语。' => "Children begin to crave praise, encouragement, and validation. Fathers play a key role in shaping character, emotional regulation, and responsibility during this phase. Clearly define boundaries while offering positive affirmations (e.g., 'I’m always here for you,' 'I see your progress').", + '《中华人民共和国卫生行业标准WS 423-2013》' => "《Chinese Health Industry Standard WS 423-2013》", '《中华人民共和国卫生行业标准WS/T 612-2018》' => "《Chinese Health Industry Standard WS/T 612-2018》", - '《中华人民共和国卫生行业标准WS/T 586-2018》' => "《Chinese Health Industry Standard WS/T 1586-2018》", + '《中华人民共和国卫生行业标准WS/T1586-2018》' => "《Chinese Health Industry Standard WS/T 1586-2018》", '《WHO 5~19岁身高/体重判定标准》' => "《WHO Growth Reference for Children and Adolescents (5–19 Years)》", - // '头围' => "Head Circumference", - '头围' => "HC", + '头围' => "Head Circumference", '头围是指绕头部一周的最大长度,头围的大小与脑的发育密切相关' => "Head circumference refers to the maximum length around the head. Its measurement is closely related to brain development.", - '跳绳数量或者分钟、秒钟值必须为整数' => 'The number of jump ropes, minutes, or seconds must be integers.', - '跳绳数不能小于等于0' => 'The jump rope count cannot be less than or equal to 0.', - '秒钟值不能大于60' => 'The seconds value cannot exceed 60.', - '跳绳个数(个)' => 'Jump rope count (times)', - '跳绳时长(分钟)' => 'Jump rope duration (minutes)', - '消耗卡路里(kcal)' => 'Calories burned (kcal)', - '个数' => 'Count', - '时长' => 'Duration', - '卡路里' => 'Calories', - '第一次' => 'First try', - '第二次' => 'Second try', - '第三次' => 'Third try', - '三次平均' => 'Average of three', - '最后成绩' => 'Final score', - '分' => 'Score', - '平均' => 'Average', - '成绩' => 'Score', - '时间(天)' => 'Time (days)', - '增重(kg)' => 'Weight gain (kg)', - '减脂(kg)' => 'Fat loss (kg)', - '数据变化' => 'Data changes', - '趋势' => 'Trend', - '之前' => 'Before', - '之后' => 'After', - '异常' => 'Abnormal', - '至' => 'To', - '无' => 'null', + ], // 可以添加更多语言映射 ]; @@ -238,14 +104,14 @@ class Language extends Base // dump($data); // 验证语言是否支持 if (!$this->isLanguageSupported($language)) { - return $data; + return $this->msg($data['data']); } // 如果是数组,递归处理每个元素 if (is_array($data)) { // dump(2); $data = $this->translateArray($language, $data); - return $data; + return $this->msg($data['data']); } // 如果是字符串,直接翻译 @@ -256,7 +122,7 @@ class Language extends Base // dump($data); // 其他类型直接返回 - return $data; + return $this->msg($data['data']); } /** diff --git a/application/testapp/controller/Login.php b/application/testapp/controller/Login.php index ee1fe9a..f46eaaa 100644 --- a/application/testapp/controller/Login.php +++ b/application/testapp/controller/Login.php @@ -11,9 +11,9 @@ use app\testapp\controller\Wechat;// 引入Wechat服务类 class Login extends Base{ protected $code_time = 50; // protected $token_time = 2592000;//30天的秒数 - protected $default_head_pic = 'http://tc.pcxbc.com/tsf/head_pic.png'; + protected $default_head_pic = 'https://tc.pcxbc.com/tsf/head_pic.png'; protected $login_use_db_name = [ - '1'=>'app_account_number_copy1', + '1'=>'app_account_number', ]; ################################################################接口################################################################ @@ -21,7 +21,7 @@ class Login extends Base{ ################################################################接口################################################################ // 注册 - public function register_action($data = ['data'=>13408173311,'password'=>'123','code'=>'746119','language'=>'en']){ + public function register_action($data = ['data'=>13408173311,'password'=>'123','code'=>'746119']){ try { // 你的业务逻辑 // 验证是否前段发送过来的数据 @@ -29,7 +29,7 @@ class Login extends Base{ $data = input('post.'); } // 验证数据项是否完整 - if(!array_key_exists('data', $data) || !array_key_exists('password', $data) || !array_key_exists('code', $data) || !array_key_exists('language', $data)){ + if(!array_key_exists('data', $data) || !array_key_exists('password', $data) || !array_key_exists('code', $data)){ return $this->msg(10001); } // 验证数据值是否合规 @@ -42,9 +42,6 @@ class Login extends Base{ if(!$this->verify_data_is_ok($data['code'],'num')){ return $this->msg(10005); } - if(!$this->verify_data_is_ok($data['language'],'str')){ - return $this->msg(10005); - } // 验证是手机还是邮箱 $montage_data = $this->is_tel_email($data['data']); if($montage_data == false){ @@ -76,10 +73,9 @@ class Login extends Base{ $set_data['create_time'] = date('Y-m-d H:i:s'); $set_data['login_time'] = date('Y-m-d H:i:s'); $set_data['token'] = md5($data['data'].$this->create_random_string(12).time()); - $set_data['language'] = $data['language']; $result = Db::table($this->login_use_db_name['1'])->insertGetId($set_data); if($result){ - $return_data = $this->msg(['token'=>$set_data['token'],'aan_id'=>$result,'language'=>$data['language']]); + $return_data = $this->msg(['token'=>$set_data['token'],'aan_id'=>$result]); }else{ $return_data = $this->msg(10002); } @@ -169,13 +165,13 @@ class Login extends Base{ } // 登录 - public function login_action($data = ['data'=>'18530934717','validate_data'=>'0932','type'=>'login','validate_type'=>'password','language'=>'en']){ + public function login_action($data = ['data'=>'18530934717','validate_data'=>'0932','type'=>'login','validate_type'=>'password']){ try { // 你的业务逻辑 if(count(input('post.')) > 0){ $data = input('post.'); } - if(!array_key_exists('data', $data) || !array_key_exists('validate_data', $data) || !array_key_exists('validate_type', $data) || !array_key_exists('language', $data)){ + if(!array_key_exists('data', $data) || !array_key_exists('validate_data', $data) || !array_key_exists('validate_type', $data)){ return $this->msg(10001); } // 检测是否为手机 @@ -183,19 +179,17 @@ class Login extends Base{ if($montage_data == false){ return $this->msg(10005); } - if(!$this->verify_data_is_ok($data['language'],'str')){ - return $this->msg(10005); - } + $verify_result[$montage_data] = $data['data']; $verify_result['is_del'] = 0; // 检测校验途径 if($data['validate_type'] == 'code'){ $code_name = $data['data']; if($this->check_code($code_name,$data['validate_data']) === true){ - $result = Db::table($this->login_use_db_name['1'])->where($verify_result)->field('id,token,language')->find(); + $result = Db::table($this->login_use_db_name['1'])->where($verify_result)->field('id,token')->find(); if($result){ - Db::table($this->login_use_db_name['1'])->where($verify_result)->update(['login_time'=>date('Y-m-d H:i:s'),'language'=>$data['language']]); - $return_data = $this->msg(['token'=>$result['token'],'aan_id'=>$result['id'],'language'=>$data['language']]); + Db::table($this->login_use_db_name['1'])->where($verify_result)->update(['login_time'=>date('Y-m-d H:i:s')]); + $return_data = $this->msg(['token'=>$result['token'],'aan_id'=>$result['id']]); }else{ $set_data['password'] = ''; $set_data[$montage_data] = $data['data']; @@ -204,10 +198,9 @@ class Login extends Base{ $set_data['create_time'] = date('Y-m-d H:i:s'); $set_data['login_time'] = date('Y-m-d H:i:s'); $set_data['token'] = md5($data['data'].$this->create_random_string(12).time()); - $set_data['language'] = $data['language']; $result = Db::table($this->login_use_db_name['1'])->insertGetId($set_data); if($result){ - $return_data = $this->msg(['token'=>$set_data['token'],'aan_id'=>$result,'language'=>$data['language']],'登录成功'); + $return_data = $this->msg(['token'=>$set_data['token'],'aan_id'=>$result],'登录成功'); }else{ $return_data = $this->msg(10002); } @@ -217,7 +210,7 @@ class Login extends Base{ } }else if($data['validate_type'] == 'password'){ // $verify_result['password'] = $data['validate_data']; - $result = Db::table($this->login_use_db_name['1'])->where($verify_result)->field('id,token,password,language')->find(); + $result = Db::table($this->login_use_db_name['1'])->where($verify_result)->field('id,token,password')->find(); if($result){ if($result['password'] == ''){ $return_data = $this->msg(10003,'该账户未设密码,请用验证码登录'); @@ -225,8 +218,9 @@ class Login extends Base{ if($data['validate_data'] != $result['password']){ $return_data = $this->msg(10003,'账号密码错误'); }else{ - Db::table($this->login_use_db_name['1'])->where($verify_result)->update(['login_time'=>date('Y-m-d H:i:s'),'language'=>$data['language']]); - $return_data = $this->msg(['token'=>$result['token'],'aan_id'=>$result['id'],'language'=>$data['language']],'登录成功'); + + Db::table($this->login_use_db_name['1'])->where($verify_result)->update(['login_time'=>date('Y-m-d H:i:s')]); + $return_data = $this->msg(['token'=>$result['token'],'aan_id'=>$result['id']],'登录成功'); } }else{ $return_data = $this->msg(10003,'账号未注册,请先注册'); @@ -419,8 +413,8 @@ class Login extends Base{ * $type(验证类型,是注册用,还是其他用途) 字符串 默认register(注册)(register、login、reset_password) * $road(是手机还是邮箱还是其他) 字符串 默认tel或email */ - //18736019909 18530934717 - public function send_phone_email_code($data = ['data'=>'18530934717']){ + //18736019909 + public function send_phone_email_code($data = ['data'=>'18736019909']){ if(count(input('post.')) > 0){ $data = input('post.'); @@ -436,10 +430,10 @@ class Login extends Base{ $num = mt_rand(100000,999999); if (preg_match('/^\d{11}$/', $data['data'])) { // 本公司短信 - $result = $this->send_tel_code($data['data'],$num); + // $result = $this->send_tel_code($data['data'],$num); // 阿里云短信 - // $sms_all = new Smsaliyun; - // $result = $sms_all->send_sms($data['data'],$num); + $sms_all = new Smsaliyun; + $result = $sms_all->send_sms($data['data'],$num); // dump($result); $road = 'tel'; }else{ @@ -463,7 +457,7 @@ class Login extends Base{ */ public function send_tel_code($tel,$code){ // 初始化cURL会话 - $ch = curl_init(); + $ch = curl_init(); $headers = [ 'Accept: application/json', 'Content-Type: application/json', @@ -478,10 +472,10 @@ class Login extends Base{ // 设置POST数据 $postData = array( 'phone' => $tel, - 'content' => '【巨天】您好,欢迎使用Reedaw,您的手机验证码是:'.$code.',验证码一分钟内有效,若非本人操作,请忽略本短信' + // 'content' => '【巨天】您好,欢迎使用Reedaw,您的手机验证码是:'.$code.',验证码一分钟内有效,若非本人操作,请忽略本短信' // 'content' => '【郑州品传科技】您好,欢迎使用Reedaw,您的手机验证码是:'.$code.',验证码一分钟内有效,若非本人操作,请忽略本短信' - // 'content' => '【小白秤】您好,欢迎使用Reedaw,您的手机验证码是:'.$code.',验证码一分钟内有效,若非本人操作,请忽略本短信' - // 'content' => '【郑州巨天信息】您好,欢迎使用Reedaw,您的手机验证码是:'.$code.',验证码一分钟内有效,若非本人操作,请忽略本短信' + // 'content' => '【每日一称】您好,欢迎使用Reedaw,您的手机验证码是:'.$code.',验证码一分钟内有效,若非本人操作,请忽略本短信' + 'content' => '【小白健康】您好,欢迎使用Reedaw,您的手机验证码是:'.$code.',验证码一分钟内有效,若非本人操作,请忽略本短信' ); $postData = json_encode($postData); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); @@ -505,6 +499,31 @@ class Login extends Base{ echo "未收到响应"; } } + // 手机号区分 + function getCarrierByPhone($phone) { + // 验证手机号格式(11位数字且以1开头) + if (!preg_match('/^1[3-9]\d{9}$/', $phone)) { + return '无效手机号'; + } + + $prefix3 = substr($phone, 0, 3); + + // 2025年最新3位号段(排除4位号段) + $carriers = [ + '中国移动' => ['134', '135', '136', '137', '138', '139', '150', '151', '152', '157', '158', '159', '178', '182', '183', '184', '187', '188', '195', '197', '198'], + '中国联通' => ['130', '131', '132', '155', '156', '166', '175', '176', '185', '186', '196'], + '中国电信' => ['133', '153', '173', '177', '180', '181', '189', '190', '191', '193', '199'], + '中国广电' => ['192'] + ]; + + foreach ($carriers as $carrier => $segments) { + if (in_array($prefix3, $segments)) { + return $carrier; + } + } + + return '未知运营商'; + } /* 接口说明(发邮件) * $address(收件人的邮箱地址) 数组 格式: ['460834639@qq.com','460834639@qq.com'.......] * $content(邮件的主题数据信息) 数组 格式:['title'=>'123','from_user_name'=>'123','content'=>'123'] diff --git a/application/testapp/controller/Msginformation.php b/application/testapp/controller/Msginformation.php index 9ecded9..6e0d714 100644 --- a/application/testapp/controller/Msginformation.php +++ b/application/testapp/controller/Msginformation.php @@ -11,10 +11,10 @@ class Msginformation extends Base{ protected $judge_wechat_release = false; protected $msginformation_use_db_name = [ - '1'=>'admin_editor_text_content_copy1', - '2'=>'admin_editor_text_like_up_log_copy1', - '3'=>'admin_notice_banner_copy1', - '4'=>'admin_business_cooperation_copy1' + '1'=>'admin_editor_text_content', + '2'=>'admin_editor_text_like_up_log', + '3'=>'admin_notice_banner', + '4'=>'admin_business_cooperation' ]; protected $page_num = 10; // 加 bcadd(,,20) @@ -448,7 +448,7 @@ class Msginformation extends Base{ ]; // return $this->msg($return_data); // 所有可用记录. - $all_data = Db::table($this->msginformation_use_db_name['3'])->where("is_del = 0 AND scene_data IN (1,2,3)")->select(); + $all_data = Db::table($this->msginformation_use_db_name['3'])->where("is_del = 0 AND scene_data IN (1,2,3)")->order('sort_num')->select(); // 用户阅读记录 $user_read_log = Db::table($this->msginformation_use_db_name['2'])->where(['token'=>$data['token']])->field('aetc_id')->select(); $user_read_data = []; @@ -460,7 +460,9 @@ class Msginformation extends Base{ foreach ($all_data as $key => $value) { if($value['type'] == '1'){ if(in_array($value['parameter_data'], $user_read_data)){ + // 如果读过 if($value['scene_data'] != 3){ + // 如果不是banner unset($all_data[$key]); }else{ // $all_data[$key]['jump_url'] = $all_data[$key]['jump_url']."&token=".$data['token']; @@ -474,6 +476,10 @@ class Msginformation extends Base{ $all_data[$key]['type'] = 'h5'; $all_data[$key]['id'] = $value['parameter_data']; } + }else if($value['type'] == '3'){ + $all_data[$key]['jump_url'] = $all_data[$key]['jump_url']; + $all_data[$key]['type'] = 'h5'; + $all_data[$key]['id'] = $value['parameter_data']; }else{ $all_data[$key]['type'] = 'wechat'; // 提取查询字符串部分(?后面的部分) @@ -500,12 +506,14 @@ class Msginformation extends Base{ // 分类信息 foreach ($all_data as $key => $value) { // 1:首屏弹窗,2:滚动公告,3:banner + if($value['scene_data'] == '1'){ array_push($return_data['pop'],$value); }else if($value['scene_data'] == '2'){ array_push($return_data['notice'],$value); }else if($value['scene_data'] == '3'){ + array_push($return_data['banner'],$value); } } diff --git a/application/testapp/controller/Myinformation.php b/application/testapp/controller/Myinformation.php index cf923dd..ef00ba6 100644 --- a/application/testapp/controller/Myinformation.php +++ b/application/testapp/controller/Myinformation.php @@ -9,7 +9,7 @@ use app\testapp\controller\Login; class Myinformation extends Base{ protected $myinformation_use_db_name = [ - '1'=>'app_account_number_copy1', + '1'=>'app_account_number', ]; // 加 bcadd(,,20) // 减 bcsub(,,20) diff --git a/application/testapp/controller/Pagingcontrast.php b/application/testapp/controller/Pagingcontrast.php index 24ea8e1..0d9c02a 100644 --- a/application/testapp/controller/Pagingcontrast.php +++ b/application/testapp/controller/Pagingcontrast.php @@ -7,13 +7,12 @@ use think\Db; class Pagingcontrast extends Base{ protected $color = ['#FF5656','#FFAB00','#5AD06D','#6492F6','#3967D6']; - protected $db_name = ['2'=>'app_card_body_data_copy1','6'=>'app_card_skip_data_copy1','8'=>'app_card_vitalcapacity_data_copy1']; + protected $db_name = ['2'=>'app_card_body_data','6'=>'app_card_skip_data','8'=>'app_card_vitalcapacity_data']; protected $pagingcontrast_use_db_name = [ - '1'=>'app_card_body_data_copy1', - '2'=>'app_card_skip_data_copy1', - '3'=>'app_card_vitalcapacity_data_copy1', - '4'=>'app_user_data_copy1', - '5'=>'app_account_number_copy1', + '1'=>'app_card_body_data', + '2'=>'app_card_skip_data', + '3'=>'app_card_vitalcapacity_data', + '4'=>'app_user_data', ]; protected $request_result = [ '2'=>['height'=>['身高','cm'],'weight'=>['体重','kg'],'age'=>['年龄','岁'],'bmi'=>['BMI',''],'head'=>['头围',''],'fat_w'=>['脂肪量','kg'],'fat_r'=>['脂肪率','%'],'muscleval'=>['肌肉量','kg'],'muscle'=>['肌肉率','%'],'proteinval'=>['蛋白量','kg'],'protein'=>['蛋白率','%'],'water'=>['水分',''],'bone'=>['骨重','kg'],'visceral'=>['内脏指数',''],'sfr'=>['皮下脂肪','%'],'kcal'=>['基础代谢','kcal'],'un_fat_w_weight'=>['去脂体重','kg'],'body_age'=>['体龄',''],'body_level'=>['肥胖等级',''],'body_type'=>['体型','']], @@ -26,7 +25,7 @@ class Pagingcontrast extends Base{ ################################################请求接口################################################ // 获取记录信息(分组)(包含身体、跳绳、肺活量) public function get_all_record_data_group($data = ['aud_id'=>'202','s_time'=>'2024-04-01','e_time'=>'2025-06-12','type'=>'2']){ - // try { + try { // 你的业务逻辑 if(count(input('post.')) > 0){ $data = input('post.'); @@ -53,26 +52,25 @@ class Pagingcontrast extends Base{ } // 成功 $this->record_api_log($data, null, $return_data); - return $return_data; - // } catch (\Exception $e) { - // // 捕获异常 - // $logContent["flie"] = $e->getFile(); - // $logContent["line"] = $e->getLine(); - // $logContent['all_content'] = "异常信息:\n"; - // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; - // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; - // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; - // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; - // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; - // $this->record_api_log($data, $logContent, null); - // return $this->msg(99999); - // } + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + $this->record_api_log($data, $logContent, null); + return $this->msg(99999); + } } // 获取记录信息(分页)(包含身体、跳绳、肺活量) - public function get_all_record_data_page($data = ['aud_id'=>'144','page'=>1,'token'=>'caadd1be045a65f30b92aa805f1de54a','type'=>'8']){ - // try { + public function get_all_record_data_page($data = ['aud_id'=>'11','page'=>1,'token'=>'0dafb98a10995c98b5a33b7d59d986ca','type'=>'2']){ + try { // 你的业务逻辑 if(count(input('post.')) > 0){ $data = input('post.'); @@ -89,7 +87,7 @@ class Pagingcontrast extends Base{ if(!$this->verify_data_is_ok($data['type'],'intnum')){ return $this->msg(10005); } - // unset($data['token']); + unset($data['token']); if(array_key_exists($data['type'],$this->db_name)){ $return_data = $this->jump_transfer_interface_record($data,'page'); }else{ @@ -98,24 +96,24 @@ class Pagingcontrast extends Base{ // 成功 $this->record_api_log($data, null, $return_data); return $return_data; - // } catch (\Exception $e) { - // // 捕获异常 - // $logContent["flie"] = $e->getFile(); - // $logContent["line"] = $e->getLine(); - // $logContent['all_content'] = "异常信息:\n"; - // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; - // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; - // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; - // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; - // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; - // $this->record_api_log($data, $logContent, null); - // return $this->msg(99999); - // } + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + $this->record_api_log($data, $logContent, null); + return $this->msg(99999); + } } // 获取详细历史数据信息(包含身体、跳绳、肺活量) public function get_all_record_detailed_information($data = ['id'=>'3802','type'=>'2','aan_id'=>'1841','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ - // try { + try { // 你的业务逻辑 if(count(input('post.')) > 0){ $data = input('post.'); @@ -129,28 +127,28 @@ class Pagingcontrast extends Base{ if(!$this->verify_data_is_ok($data['type'],'intnum')){ return $this->msg(10005); } - // unset($data['token']); + unset($data['token']); $return_data = $this->jump_transfer_interface_detailed($data); // 成功 $this->record_api_log($data, null, $return_data); return $return_data; - // } catch (\Exception $e) { - // // 捕获异常 - // $logContent["flie"] = $e->getFile(); - // $logContent["line"] = $e->getLine(); - // $logContent['all_content'] = "异常信息:\n"; - // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; - // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; - // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; - // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; - // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; - // $this->record_api_log($data, $logContent, null); - // return $this->msg(99999); - // } + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + $this->record_api_log($data, $logContent, null); + return $this->msg(99999); + } } // 数据对比(包含身体、跳绳、肺活量) public function get_all_card_data_contrast($data = ['before_id'=>'171','after_id'=>'174','type'=>'2','token'=>'caadd1be045a65f30b92aa805f1de54a']){ - // try { + try { // 你的业务逻辑 if(count(input('post.')) > 0){ $data = input('post.'); @@ -167,29 +165,29 @@ class Pagingcontrast extends Base{ if(!$this->verify_data_is_ok($data['type'],'intnum')){ return $this->msg(10005); } - // unset($data['token']); + unset($data['token']); $return_data = $this->jump_transfer_interface_data_contrast($data); // 成功 $this->record_api_log($data, null, $return_data); return $return_data; - // } catch (\Exception $e) { - // // 捕获异常 - // $logContent["flie"] = $e->getFile(); - // $logContent["line"] = $e->getLine(); - // $logContent['all_content'] = "异常信息:\n"; - // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; - // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; - // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; - // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; - // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; - // $this->record_api_log($data, $logContent, null); - // return $this->msg(99999); - // } + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + $this->record_api_log($data, $logContent, null); + return $this->msg(99999); + } } // 删除历史数据 public function del_all_record_data($data = ['id'=>'29','type'=>'2','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ - // try { + try { // 你的业务逻辑 if(count(input('post.')) > 0){ $data = input('post.'); @@ -214,19 +212,19 @@ class Pagingcontrast extends Base{ // 成功 $this->record_api_log($data, null, $return_data); return $return_data; - // } catch (\Exception $e) { - // // 捕获异常 - // $logContent["flie"] = $e->getFile(); - // $logContent["line"] = $e->getLine(); - // $logContent['all_content'] = "异常信息:\n"; - // $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; - // $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; - // $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; - // $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; - // $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; - // $this->record_api_log($data, $logContent, null); - // return $this->msg(99999); - // } + } catch (\Exception $e) { + // 捕获异常 + $logContent["flie"] = $e->getFile(); + $logContent["line"] = $e->getLine(); + $logContent['all_content'] = "异常信息:\n"; + $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n"; + $logContent['all_content'] .= "代码: " . $e->getCode() . "\n"; + $logContent['all_content'] .= "文件: " . $e->getFile() . "\n"; + $logContent['all_content'] .= "行号: " . $e->getLine() . "\n"; + $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n"; + $this->record_api_log($data, $logContent, null); + return $this->msg(99999); + } } ################################################请求接口################################################ @@ -312,23 +310,7 @@ class Pagingcontrast extends Base{ ]); } } - - $language_data = new Language(); - $user_language = Db::table($this->pagingcontrast_use_db_name['4']) - ->alias('a') - ->join(''.$this->pagingcontrast_use_db_name['5'].' b','a.aan_id = b.id','LEFT') - ->where(['a.id'=>$data['aud_id'],'a.is_del'=>0]) - ->field('b.language') - ->find(); - if(!$user_language['language']){ - $user_language['language'] = 'zh-Hans'; - } - $result_end = $language_data->handling_languages_from_multiple_countries($user_language['language'], $return_result); - - // dump($result_end); - // die; - - return $this->msg($result_end); + return $this->msg($return_result); } // 获取记录信息列表(分组)-跳绳 // 获取记录信息列表(分页)-跳绳 @@ -522,20 +504,8 @@ class Pagingcontrast extends Base{ ]); } } - - $language_data = new Language(); - $user_language = Db::table($this->pagingcontrast_use_db_name['5']) - ->where(['token'=>$data['token'],'is_del'=>0]) - ->field('language') - ->find(); - if(!$user_language['language']){ - $user_language['language'] = 'zh-Hans'; - } - $result_end = $language_data->handling_languages_from_multiple_countries($user_language['language'], $result_data); - - // 添加头围详细end - return $this->msg($result_end); + return $this->msg($result_data); }else{ return $this->msg(10004); } @@ -591,7 +561,7 @@ class Pagingcontrast extends Base{ } } - $return_data['time'] = $calculate_arr['before']['b_time'].'/'.$calculate_arr['after']['b_time']; + $return_data['time'] = $calculate_arr['before']['b_time'].'与'.$calculate_arr['after']['b_time']; $return_data['headimg'] = $calculate_arr['before']['head_pic']; $return_data['name'] = $calculate_arr['before']['nickname']; $return_data['gender'] = $calculate_arr['before']['gender']; @@ -682,16 +652,7 @@ class Pagingcontrast extends Base{ // } // 添加头围数据(如果需要的话)end - $language_data = new Language(); - $user_language = Db::table($this->pagingcontrast_use_db_name['5']) - ->where(['token'=>$data['token'],'is_del'=>0]) - ->field('language') - ->find(); - if(!$user_language['language']){ - $user_language['language'] = 'zh-Hans'; - } - $result_end = $language_data->handling_languages_from_multiple_countries($user_language['language'], $return_data); - return $this->msg($result_end); + return $this->msg($return_data); } // 数据对比 public function get_skip_data_contrast($data){ diff --git a/application/testapp/controller/Skip.php b/application/testapp/controller/Skip.php index 47e3243..c78b449 100644 --- a/application/testapp/controller/Skip.php +++ b/application/testapp/controller/Skip.php @@ -9,10 +9,9 @@ class Skip extends Base{ protected $color = ['#FF5656','#FFAB00','#5AD06D','#6492F6','#3967D6']; protected $curve_data_format = ['jump_num'=>['跳绳个数','个','#009DFF'],'jump_time'=>['跳绳时长','分钟','#009DFF'],'jump_kcal'=>['消耗卡路里','kcal','#009DFF']]; protected $skip_use_db_name = [ - '1'=>'app_card_skip_data_copy1', - '2'=>'app_user_data_copy1', - '3'=>'app_card_body_data_copy1', - '4'=>'app_account_number_copy1', + '1'=>'app_card_skip_data', + '2'=>'app_user_data', + '3'=>'app_card_body_data', ]; protected $result_end_data_mould = [ 'name'=>'', @@ -30,7 +29,7 @@ class Skip extends Base{ ################################################################接口################################################################ ################################################################接口################################################################ // 手动记录 - public function skip_manual_recording($data = ['aud_id'=>'144','r_time'=>'2024-07-24','num'=>'369','time_m'=>'02','time_s'=>'42','type'=>'free','token'=>'caadd1be045a65f30b92aa805f1de54a']){ + public function skip_manual_recording($data = ['aud_id'=>'61','r_time'=>'2024-07-24','num'=>'369','time_m'=>'02','time_s'=>'42','type'=>'free','token'=>'caadd1be045a65f30b92aa805f1de54a']){ try { // 你的业务逻辑 if(count(input('post.')) > 0){ @@ -65,6 +64,8 @@ class Skip extends Base{ if($this->validate_user_identity($data['aud_id']) === false){ $return_data = $this->msg(10003); } + + $return_data = $this->skip_manual_recording_action($data); // 成功 @@ -138,7 +139,7 @@ class Skip extends Base{ } // 今日数据 - public function skip_today_data($data = ['aud_id'=>'144','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ + public function skip_today_data($data = ['aud_id'=>'26','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ try { // 你的业务逻辑 if(count(input('post.')) > 0){ @@ -154,7 +155,7 @@ class Skip extends Base{ $return_data = $this->skip_today_data_action($data); // 成功 - // $this->record_api_log($data, null, $return_data); + $this->record_api_log($data, null, $return_data); return $return_data; } catch (\Exception $e) { // 捕获异常 @@ -172,7 +173,7 @@ class Skip extends Base{ } // 曲线 - public function skip_curve_chart($data = ['aud_id'=>'144','time'=>'2025-04','token'=>'caadd1be045a65f30b92aa805f1de54a']){ + public function skip_curve_chart($data = ['aud_id'=>'144','time'=>'2025','token'=>'0dafb98a10995c98b5a33b7d59d986ca']){ try { // 你的业务逻辑 if(count(input('post.')) > 0){ @@ -184,6 +185,7 @@ class Skip extends Base{ if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){ return $this->msg(10005); } + unset($data['token']); $return_data = $this->skip_curve_chart_action($data); // 成功 @@ -251,7 +253,7 @@ class Skip extends Base{ // 分秒转换为秒 $data['time'] = abs($data['time_m'])*60+abs($data['time_s']); $user_msg_content = Db::table($this->skip_use_db_name['2'])->where(['id'=>$data['aud_id']])->count(); - if($user_msg_content<=0){ + if($user_msg_content<=0){ return $this->msg(10004); } if(!array_key_exists('kcal', $data)){ @@ -278,6 +280,7 @@ class Skip extends Base{ 'create_time'=>date('Y-m-d H:i:s'), 'last_update_time'=>date('Y-m-d H:i:s'), 'jump_num'=>$data['num'], + 'jump_time'=>$data['time'], 'jump_kcal'=>$kcal_data['totalCalories'], 'average_num'=>$kcal_data['averageAchievement'], @@ -355,7 +358,7 @@ class Skip extends Base{ $timeData = explode('-', $data['time']); // 根据$timeData的长度构建不同的查询条件 - $map = ['aud_id' => $audid]; + $map = ['aud_id' => $audid,'is_del'=>0]; switch (count($timeData)) { case 3: // 年月日 $map['record_time'] = ['between', [date('Y-m-d 00:00:00', strtotime($timeData[0] . '-' . $timeData[1] . '-' . $timeData[2])), date('Y-m-d 23:59:59', strtotime($timeData[0] . '-' . $timeData[1] . '-' . $timeData[2]))]]; @@ -422,16 +425,6 @@ class Skip extends Base{ // $return_data[1]['line']['series'][0]['data'][$key] = $jump_time_long['h'].':'.$jump_time_long['m'].':'.$jump_time_long['s']; } - // dump($return_data); - $language_str = Db::table($this->skip_use_db_name['4'])->where(['token'=>$data['token']])->field('language')->find(); - $language_data = new Language(); - if(!$language_str['language']){ - $language_str['language'] = 'zh-Hans'; - } - // dump($language_str['language']); - $return_data = $language_data->handling_languages_from_multiple_countries($language_str['language'], $return_data); - // dump($return_data); - // die; return $this->msg($return_data); } diff --git a/application/testapp/controller/Smsaliyun.php b/application/testapp/controller/Smsaliyun.php index 40c9e3b..6df4672 100644 --- a/application/testapp/controller/Smsaliyun.php +++ b/application/testapp/controller/Smsaliyun.php @@ -14,16 +14,67 @@ class Smsaliyun extends Controller 'accessKeyId' => 'LTAI5tQCdWe9Epir3ydXWbzp', 'accessKeySecret' => 'JKLzF0b5AXw2ajhwtem2fhPSUZVOZ5', 'signName' => '郑州巨天信息', - 'templateCode' => 'SMS_484085215', + // 'signName' => '郑州品传科技', + // 'templateCode' => 'SMS_484085215',//reedaw模板 :您好,欢迎使用Reedaw,您的手机验证码是: ${code},验证码一分钟内有效,若非本人操作,请忽略本短信 + 'templateCode' => 'SMS_491550200',//巨天通用模板 :您好,您的手机验证码是: ${code},请尽快输入避免验证码失效,若非本人操作,请忽略本短信 + // 'templateCode' => 'SMS_491320295',//品传通用模板 :您好,您的手机验证码是: ${code},请尽快输入避免验证码失效,若非本人操作,请忽略本短信 'regionId' => 'cn-hangzhou' ]; + + public function send_sms_api(){ + $data = input(); + if(!array_key_exists('tel',$data)){ + return json([ + 'code'=>10001, + 'msg'=>'缺少手机号码', + 'data'=>[], + ]); + } + if(!array_key_exists('code',$data)){ + return json([ + 'code'=>10002, + 'msg'=>'缺少验证码', + 'data'=>[], + ]); + } + if(!$this->validatePhoneNumber($data['tel'])){ + return json([ + 'code'=>10001, + 'msg'=>'手机号码格式错误', + 'data'=>[], + ]); + } + if(!$this->validateSixDigitCode($data['code'])){ + return json([ + 'code'=>10002, + 'msg'=>'验证码格式错误', + 'data'=>[], + ]); + } + + $result = $this->send_sms($data['tel'],$data['code']); + + return json($result); + } + // 验证函数定义(可以放在单独的文件中) + public function validatePhoneNumber($phone) { + $pattern = '/^1[3-9]\d{9}$/'; + return preg_match($pattern, $phone) === 1; + } + + public function validateSixDigitCode($code) { + $pattern = '/^\d{6}$/'; + return preg_match($pattern, $code) === 1; + } + + /** * 发送短信接口 * @param string $phone 手机号 * @param string $code 验证码 */ - public function send_sms($phone='18530934717', $code='0932') + public function send_sms($phone, $code) { try { // 初始化阿里云客户端 @@ -53,7 +104,7 @@ class Smsaliyun extends Controller ->request(); $result = $result->toArray(); - + // return $result; if ($result['Code'] == 'OK') { return [ 'code' => 0, diff --git a/application/testapp/controller/Sportstesting.php b/application/testapp/controller/Sportstesting.php index c707783..4a4e116 100644 --- a/application/testapp/controller/Sportstesting.php +++ b/application/testapp/controller/Sportstesting.php @@ -11,9 +11,9 @@ class Sportstesting extends Base{ protected $color = ['#FF5656','#FF5656','#5AD06D','#6492F6','#3967D6']; protected $sportstesting_use_db_name = [ - '1'=>'admin_estimate_copy1', - '2'=>'app_sportstesting_data_copy1', - '3'=>'app_user_data_copy1', + '1'=>'admin_estimate', + '2'=>'app_sportstesting_data', + '3'=>'app_user_data', ]; protected $page_num = 10; protected $default_address = '上海'; diff --git a/application/testapp/controller/Vitalcapacity.php b/application/testapp/controller/Vitalcapacity.php index fe64f70..a69b012 100644 --- a/application/testapp/controller/Vitalcapacity.php +++ b/application/testapp/controller/Vitalcapacity.php @@ -17,9 +17,9 @@ class Vitalcapacity extends Base{ ['min_val'=>'0','max_val'=>'9','text'=>'无效','color'=>'#FF5656'], ]; protected $vitalcapacity_use_db_name = [ - '1'=>'app_user_data_copy1', - '2'=>'app_card_vitalcapacity_data_copy1', - '3'=>'pc_vitalcapacity_standard_copy1', + '1'=>'app_user_data', + '2'=>'app_card_vitalcapacity_data', + '3'=>'pc_vitalcapacity_standard', ]; protected $result_end_data_mould = [ 'name'=>'', @@ -107,7 +107,7 @@ class Vitalcapacity extends Base{ } // 数据报告 - public function vitalcapacity_data_report($data = ['aud_id'=>'144','token'=>'caadd1be045a65f30b92aa805f1de54a']){ + public function vitalcapacity_data_report($data = ['aud_id'=>'83','token'=>'caadd1be045a65f30b92aa805f1de54a']){ try { // 你的业务逻辑 if(count(input('post.')) > 0){ diff --git a/application/testapp/controller/Wechatabout.php b/application/testapp/controller/Wechatabout.php index 473f613..5b69f52 100644 --- a/application/testapp/controller/Wechatabout.php +++ b/application/testapp/controller/Wechatabout.php @@ -8,8 +8,8 @@ use think\Db; class Wechatabout extends Base{ protected $msginformation_use_db_name = [ - '1'=>'admin_editor_text_content_copy1', - '2'=>'admin_editor_text_like_up_log_copy1', + '1'=>'admin_editor_text_content', + '2'=>'admin_editor_text_like_up_log', ]; protected $page_num = 10; // 加 bcadd(,,20) diff --git a/composer.json b/composer.json index 78988bd..01e7db1 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,9 @@ "phpoffice/phpspreadsheet": "^1.25", "overtrue/wechat": "~4.0", "zoujingli/ip2region": "^2.0", - "alibabacloud/client": "^1.5" + "alibabacloud/client": "^1.5", + "picqer/php-barcode-generator": "^2.4", + "endroid/qr-code": "^4.3" }, "autoload": { "psr-4": { diff --git a/vendor/autoload.php b/vendor/autoload.php index 9eaf68c..7f041de 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -14,10 +14,7 @@ if (PHP_VERSION_ID < 50600) { echo $err; } } - trigger_error( - $err, - E_USER_ERROR - ); + throw new RuntimeException($err); } require_once __DIR__ . '/composer/autoload_real.php'; diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index 07b32ed..2052022 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -26,12 +26,23 @@ use Composer\Semver\VersionParser; */ class InstalledVersions { + /** + * @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to + * @internal + */ + private static $selfDir = null; + /** * @var mixed[]|null * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null */ private static $installed; + /** + * @var bool + */ + private static $installedIsLocalDir; + /** * @var bool|null */ @@ -309,6 +320,24 @@ class InstalledVersions { self::$installed = $data; self::$installedByVendor = array(); + + // when using reload, we disable the duplicate protection to ensure that self::$installed data is + // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not, + // so we have to assume it does not, and that may result in duplicate data being returned when listing + // all installed packages for example + self::$installedIsLocalDir = false; + } + + /** + * @return string + */ + private static function getSelfDir() + { + if (self::$selfDir === null) { + self::$selfDir = strtr(__DIR__, '\\', '/'); + } + + return self::$selfDir; } /** @@ -325,7 +354,9 @@ class InstalledVersions $copiedLocalDir = false; if (self::$canGetVendors) { + $selfDir = self::getSelfDir(); foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + $vendorDir = strtr($vendorDir, '\\', '/'); if (isset(self::$installedByVendor[$vendorDir])) { $installed[] = self::$installedByVendor[$vendorDir]; } elseif (is_file($vendorDir.'/composer/installed.php')) { @@ -333,11 +364,14 @@ class InstalledVersions $required = require $vendorDir.'/composer/installed.php'; self::$installedByVendor[$vendorDir] = $required; $installed[] = $required; - if (strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { + if (self::$installed === null && $vendorDir.'/composer' === $selfDir) { self::$installed = $required; - $copiedLocalDir = true; + self::$installedIsLocalDir = true; } } + if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) { + $copiedLocalDir = true; + } } } diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 796e16c..364b529 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -31,6 +31,7 @@ return array( 'Psr\\EventDispatcher\\' => array($vendorDir . '/psr/event-dispatcher/src'), 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), 'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'), + 'Picqer\\Barcode\\' => array($vendorDir . '/picqer/php-barcode-generator/src'), 'PhpOffice\\PhpSpreadsheet\\' => array($vendorDir . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet'), 'PHPMailer\\PHPMailer\\' => array($vendorDir . '/phpmailer/phpmailer/src'), 'Overtrue\\Socialite\\' => array($vendorDir . '/overtrue/socialite/src'), @@ -41,9 +42,12 @@ return array( 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), 'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'), 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'), + 'Endroid\\QrCode\\' => array($vendorDir . '/endroid/qr-code/src'), 'EasyWeChat\\' => array($vendorDir . '/overtrue/wechat/src'), 'EasyWeChatComposer\\' => array($vendorDir . '/easywechat-composer/easywechat-composer/src'), + 'DASPRiD\\Enum\\' => array($vendorDir . '/dasprid/enum/src'), 'Complex\\' => array($vendorDir . '/markbaker/complex/classes/src'), + 'BaconQrCode\\' => array($vendorDir . '/bacon/bacon-qr-code/src'), 'AlibabaCloud\\Client\\' => array($vendorDir . '/alibabacloud/client/src'), 'Adbar\\' => array($vendorDir . '/adbario/php-dot-notation/src'), ); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 0f40fd4..b2b6013 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -65,6 +65,7 @@ class ComposerStaticInit2bc4f313dba415539e266f7ac2c87dcd 'Psr\\EventDispatcher\\' => 20, 'Psr\\Container\\' => 14, 'Psr\\Cache\\' => 10, + 'Picqer\\Barcode\\' => 15, 'PhpOffice\\PhpSpreadsheet\\' => 25, 'PHPMailer\\PHPMailer\\' => 20, ), @@ -90,13 +91,22 @@ class ComposerStaticInit2bc4f313dba415539e266f7ac2c87dcd ), 'E' => array ( + 'Endroid\\QrCode\\' => 15, 'EasyWeChat\\' => 11, 'EasyWeChatComposer\\' => 19, ), + 'D' => + array ( + 'DASPRiD\\Enum\\' => 13, + ), 'C' => array ( 'Complex\\' => 8, ), + 'B' => + array ( + 'BaconQrCode\\' => 12, + ), 'A' => array ( 'AlibabaCloud\\Client\\' => 20, @@ -206,6 +216,10 @@ class ComposerStaticInit2bc4f313dba415539e266f7ac2c87dcd array ( 0 => __DIR__ . '/..' . '/psr/cache/src', ), + 'Picqer\\Barcode\\' => + array ( + 0 => __DIR__ . '/..' . '/picqer/php-barcode-generator/src', + ), 'PhpOffice\\PhpSpreadsheet\\' => array ( 0 => __DIR__ . '/..' . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet', @@ -246,6 +260,10 @@ class ComposerStaticInit2bc4f313dba415539e266f7ac2c87dcd array ( 0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src', ), + 'Endroid\\QrCode\\' => + array ( + 0 => __DIR__ . '/..' . '/endroid/qr-code/src', + ), 'EasyWeChat\\' => array ( 0 => __DIR__ . '/..' . '/overtrue/wechat/src', @@ -254,10 +272,18 @@ class ComposerStaticInit2bc4f313dba415539e266f7ac2c87dcd array ( 0 => __DIR__ . '/..' . '/easywechat-composer/easywechat-composer/src', ), + 'DASPRiD\\Enum\\' => + array ( + 0 => __DIR__ . '/..' . '/dasprid/enum/src', + ), 'Complex\\' => array ( 0 => __DIR__ . '/..' . '/markbaker/complex/classes/src', ), + 'BaconQrCode\\' => + array ( + 0 => __DIR__ . '/..' . '/bacon/bacon-qr-code/src', + ), 'AlibabaCloud\\Client\\' => array ( 0 => __DIR__ . '/..' . '/alibabacloud/client/src', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 294caa2..932dc5f 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -143,6 +143,63 @@ }, "install-path": "../alibabacloud/client" }, + { + "name": "bacon/bacon-qr-code", + "version": "2.0.8", + "version_normalized": "2.0.8.0", + "source": { + "type": "git", + "url": "https://github.com/Bacon/BaconQrCode.git", + "reference": "8674e51bb65af933a5ffaf1c308a660387c35c22" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/8674e51bb65af933a5ffaf1c308a660387c35c22", + "reference": "8674e51bb65af933a5ffaf1c308a660387c35c22", + "shasum": "" + }, + "require": { + "dasprid/enum": "^1.0.3", + "ext-iconv": "*", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "phly/keep-a-changelog": "^2.1", + "phpunit/phpunit": "^7 | ^8 | ^9", + "spatie/phpunit-snapshot-assertions": "^4.2.9", + "squizlabs/php_codesniffer": "^3.4" + }, + "suggest": { + "ext-imagick": "to generate QR code images" + }, + "time": "2022-12-07T17:46:57+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "BaconQrCode\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Ben Scholzen 'DASPRiD'", + "email": "mail@dasprids.de", + "homepage": "https://dasprids.de/", + "role": "Developer" + } + ], + "description": "BaconQrCode is a QR code generator for PHP.", + "homepage": "https://github.com/Bacon/BaconQrCode", + "support": { + "issues": "https://github.com/Bacon/BaconQrCode/issues", + "source": "https://github.com/Bacon/BaconQrCode/tree/2.0.8" + }, + "install-path": "../bacon/bacon-qr-code" + }, { "name": "clagiordano/weblibs-configmanager", "version": "v1.5.0", @@ -201,6 +258,59 @@ }, "install-path": "../clagiordano/weblibs-configmanager" }, + { + "name": "dasprid/enum", + "version": "1.0.6", + "version_normalized": "1.0.6.0", + "source": { + "type": "git", + "url": "https://github.com/DASPRiD/Enum.git", + "reference": "8dfd07c6d2cf31c8da90c53b83c026c7696dda90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/DASPRiD/Enum/zipball/8dfd07c6d2cf31c8da90c53b83c026c7696dda90", + "reference": "8dfd07c6d2cf31c8da90c53b83c026c7696dda90", + "shasum": "" + }, + "require": { + "php": ">=7.1 <9.0" + }, + "require-dev": { + "phpunit/phpunit": "^7 || ^8 || ^9 || ^10 || ^11", + "squizlabs/php_codesniffer": "*" + }, + "time": "2024-08-09T14:30:48+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "DASPRiD\\Enum\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Ben Scholzen 'DASPRiD'", + "email": "mail@dasprids.de", + "homepage": "https://dasprids.de/", + "role": "Developer" + } + ], + "description": "PHP 7.1 enum implementation", + "keywords": [ + "enum", + "map" + ], + "support": { + "issues": "https://github.com/DASPRiD/Enum/issues", + "source": "https://github.com/DASPRiD/Enum/tree/1.0.6" + }, + "install-path": "../dasprid/enum" + }, { "name": "easywechat-composer/easywechat-composer", "version": "1.4.1", @@ -252,6 +362,81 @@ }, "install-path": "../easywechat-composer/easywechat-composer" }, + { + "name": "endroid/qr-code", + "version": "4.3.5", + "version_normalized": "4.3.5.0", + "source": { + "type": "git", + "url": "https://github.com/endroid/qr-code.git", + "reference": "5630e192948b466d418608ecce697465d20260af" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/endroid/qr-code/zipball/5630e192948b466d418608ecce697465d20260af", + "reference": "5630e192948b466d418608ecce697465d20260af", + "shasum": "" + }, + "require": { + "bacon/bacon-qr-code": "^2.0", + "php": "^7.3||^8.0" + }, + "require-dev": { + "endroid/quality": "dev-master", + "ext-gd": "*", + "khanamiryan/qrcode-detector-decoder": "^1.0.4", + "setasign/fpdf": "^1.8.2" + }, + "suggest": { + "ext-gd": "Enables you to write PNG images", + "khanamiryan/qrcode-detector-decoder": "Enables you to use the image validator", + "roave/security-advisories": "Makes sure package versions with known security issues are not installed", + "setasign/fpdf": "Enables you to use the PDF writer" + }, + "time": "2021-09-17T07:50:43+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Endroid\\QrCode\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jeroen van den Enden", + "email": "info@endroid.nl" + } + ], + "description": "Endroid QR Code", + "homepage": "https://github.com/endroid/qr-code", + "keywords": [ + "code", + "endroid", + "php", + "qr", + "qrcode" + ], + "support": { + "issues": "https://github.com/endroid/qr-code/issues", + "source": "https://github.com/endroid/qr-code/tree/4.3.5" + }, + "funding": [ + { + "url": "https://github.com/endroid", + "type": "github" + } + ], + "install-path": "../endroid/qr-code" + }, { "name": "ezyang/htmlpurifier", "version": "v4.18.0", @@ -318,17 +503,17 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.9.2", - "version_normalized": "7.9.2.0", + "version": "7.9.3", + "version_normalized": "7.9.3.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "d281ed313b989f213357e3be1a179f02196ac99b" + "reference": "7b2f29fe81dc4da0ca0ea7d42107a0845946ea77" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d281ed313b989f213357e3be1a179f02196ac99b", - "reference": "d281ed313b989f213357e3be1a179f02196ac99b", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/7b2f29fe81dc4da0ca0ea7d42107a0845946ea77", + "reference": "7b2f29fe81dc4da0ca0ea7d42107a0845946ea77", "shasum": "" }, "require": { @@ -355,7 +540,7 @@ "ext-intl": "Required for Internationalized Domain Name (IDN) support", "psr/log": "Required for using the Log middleware" }, - "time": "2024-07-24T11:22:20+00:00", + "time": "2025-03-27T13:37:11+00:00", "type": "library", "extra": { "bamarni-bin": { @@ -427,7 +612,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.9.2" + "source": "https://github.com/guzzle/guzzle/tree/7.9.3" }, "funding": [ { @@ -447,17 +632,17 @@ }, { "name": "guzzlehttp/promises", - "version": "2.0.4", - "version_normalized": "2.0.4.0", + "version": "2.2.0", + "version_normalized": "2.2.0.0", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455" + "reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/f9c436286ab2892c7db7be8c8da4ef61ccf7b455", - "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455", + "url": "https://api.github.com/repos/guzzle/promises/zipball/7c69f28996b0a6920945dd20b3857e499d9ca96c", + "reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c", "shasum": "" }, "require": { @@ -467,7 +652,7 @@ "bamarni/composer-bin-plugin": "^1.8.2", "phpunit/phpunit": "^8.5.39 || ^9.6.20" }, - "time": "2024-10-17T10:06:22+00:00", + "time": "2025-03-27T13:27:01+00:00", "type": "library", "extra": { "bamarni-bin": { @@ -513,7 +698,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.0.4" + "source": "https://github.com/guzzle/promises/tree/2.2.0" }, "funding": [ { @@ -533,17 +718,17 @@ }, { "name": "guzzlehttp/psr7", - "version": "2.7.0", - "version_normalized": "2.7.0.0", + "version": "2.7.1", + "version_normalized": "2.7.1.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201" + "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/a70f5c95fb43bc83f07c9c948baa0dc1829bf201", - "reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16", "shasum": "" }, "require": { @@ -564,7 +749,7 @@ "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" }, - "time": "2024-07-18T11:15:46+00:00", + "time": "2025-03-27T12:30:47+00:00", "type": "library", "extra": { "bamarni-bin": { @@ -632,7 +817,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.7.0" + "source": "https://github.com/guzzle/psr7/tree/2.7.1" }, "funding": [ { @@ -1216,17 +1401,17 @@ }, { "name": "phpmailer/phpmailer", - "version": "v6.9.3", - "version_normalized": "6.9.3.0", + "version": "v6.10.0", + "version_normalized": "6.10.0.0", "source": { "type": "git", "url": "https://github.com/PHPMailer/PHPMailer.git", - "reference": "2f5c94fe7493efc213f643c23b1b1c249d40f47e" + "reference": "bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/2f5c94fe7493efc213f643c23b1b1c249d40f47e", - "reference": "2f5c94fe7493efc213f643c23b1b1c249d40f47e", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144", + "reference": "bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144", "shasum": "" }, "require": { @@ -1256,7 +1441,7 @@ "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)", "thenetworg/oauth2-azure": "Needed for Microsoft XOAUTH2 authentication" }, - "time": "2024-11-24T18:04:13+00:00", + "time": "2025-04-24T15:19:31+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -1288,7 +1473,7 @@ "description": "PHPMailer is a full-featured email creation and transfer class for PHP", "support": { "issues": "https://github.com/PHPMailer/PHPMailer/issues", - "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.9.3" + "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.10.0" }, "funding": [ { @@ -1402,6 +1587,96 @@ ], "install-path": "../phpoffice/phpspreadsheet" }, + { + "name": "picqer/php-barcode-generator", + "version": "v2.4.0", + "version_normalized": "2.4.0.0", + "source": { + "type": "git", + "url": "https://github.com/picqer/php-barcode-generator.git", + "reference": "4cec18909dffd86e14beb69b1040f2520c2e1bb1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/picqer/php-barcode-generator/zipball/4cec18909dffd86e14beb69b1040f2520c2e1bb1", + "reference": "4cec18909dffd86e14beb69b1040f2520c2e1bb1", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^7.3|^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.5" + }, + "suggest": { + "ext-bcmath": "Barcode IMB (Intelligent Mail Barcode) needs bcmath extension", + "ext-gd": "For JPG and PNG generators, GD or Imagick is required", + "ext-imagick": "For JPG and PNG generators, GD or Imagick is required" + }, + "time": "2023-09-16T08:58:52+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Picqer\\Barcode\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Nicola Asuni", + "email": "info@tecnick.com", + "homepage": "http://nicolaasuni.tecnick.com" + }, + { + "name": "Casper Bakker", + "email": "info@picqer.com", + "homepage": "https://picqer.com" + } + ], + "description": "An easy to use, non-bloated, barcode generator in PHP. Creates SVG, PNG, JPG and HTML images from the most used 1D barcode standards.", + "homepage": "https://github.com/picqer/php-barcode-generator", + "keywords": [ + "CODABAR", + "Code11", + "Code93", + "EAN13", + "KIX", + "KIXCODE", + "MSI", + "POSTNET", + "Pharma", + "Standard 2 of 5", + "barcode", + "barcode generator", + "code128", + "code39", + "ean", + "html", + "jpeg", + "jpg", + "php", + "png", + "svg", + "upc" + ], + "support": { + "issues": "https://github.com/picqer/php-barcode-generator/issues", + "source": "https://github.com/picqer/php-barcode-generator/tree/v2.4.0" + }, + "funding": [ + { + "url": "https://github.com/casperbakker", + "type": "github" + } + ], + "install-path": "../picqer/php-barcode-generator" + }, { "name": "pimple/pimple", "version": "v3.5.0", @@ -2433,8 +2708,8 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.31.0", - "version_normalized": "1.31.0.0", + "version": "v1.32.0", + "version_normalized": "1.32.0.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -2495,7 +2770,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.32.0" }, "funding": [ { @@ -2515,20 +2790,21 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.31.0", - "version_normalized": "1.31.0.0", + "version": "v1.32.0", + "version_normalized": "1.32.0.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" + "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", - "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493", + "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493", "shasum": "" }, "require": { + "ext-iconv": "*", "php": ">=7.2" }, "provide": { @@ -2537,7 +2813,7 @@ "suggest": { "ext-mbstring": "For best performance" }, - "time": "2024-09-09T11:45:10+00:00", + "time": "2024-12-23T08:48:59+00:00", "type": "library", "extra": { "thanks": { @@ -2578,7 +2854,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.32.0" }, "funding": [ { @@ -2598,8 +2874,8 @@ }, { "name": "symfony/polyfill-php73", - "version": "v1.31.0", - "version_normalized": "1.31.0.0", + "version": "v1.32.0", + "version_normalized": "1.32.0.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", @@ -2657,7 +2933,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.32.0" }, "funding": [ { @@ -2677,23 +2953,23 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.31.0", - "version_normalized": "1.31.0.0", + "version": "v1.32.0", + "version_normalized": "1.32.0.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608", + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608", "shasum": "" }, "require": { "php": ">=7.2" }, - "time": "2024-09-09T11:45:10+00:00", + "time": "2025-01-02T08:10:11+00:00", "type": "library", "extra": { "thanks": { @@ -2740,7 +3016,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.32.0" }, "funding": [ { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 042b670..2d9bd28 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'topthink/think', 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '075de7502013b216a11f34847a1a98600f4eab80', + 'reference' => 'c3b233b94675013624c559d5f2ce5c7d8ccb5927', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -28,6 +28,15 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'bacon/bacon-qr-code' => array( + 'pretty_version' => '2.0.8', + 'version' => '2.0.8.0', + 'reference' => '8674e51bb65af933a5ffaf1c308a660387c35c22', + 'type' => 'library', + 'install_path' => __DIR__ . '/../bacon/bacon-qr-code', + 'aliases' => array(), + 'dev_requirement' => false, + ), 'clagiordano/weblibs-configmanager' => array( 'pretty_version' => 'v1.5.0', 'version' => '1.5.0.0', @@ -37,6 +46,15 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'dasprid/enum' => array( + 'pretty_version' => '1.0.6', + 'version' => '1.0.6.0', + 'reference' => '8dfd07c6d2cf31c8da90c53b83c026c7696dda90', + 'type' => 'library', + 'install_path' => __DIR__ . '/../dasprid/enum', + 'aliases' => array(), + 'dev_requirement' => false, + ), 'easywechat-composer/easywechat-composer' => array( 'pretty_version' => '1.4.1', 'version' => '1.4.1.0', @@ -46,6 +64,15 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'endroid/qr-code' => array( + 'pretty_version' => '4.3.5', + 'version' => '4.3.5.0', + 'reference' => '5630e192948b466d418608ecce697465d20260af', + 'type' => 'library', + 'install_path' => __DIR__ . '/../endroid/qr-code', + 'aliases' => array(), + 'dev_requirement' => false, + ), 'ezyang/htmlpurifier' => array( 'pretty_version' => 'v4.18.0', 'version' => '4.18.0.0', @@ -56,27 +83,27 @@ 'dev_requirement' => false, ), 'guzzlehttp/guzzle' => array( - 'pretty_version' => '7.9.2', - 'version' => '7.9.2.0', - 'reference' => 'd281ed313b989f213357e3be1a179f02196ac99b', + 'pretty_version' => '7.9.3', + 'version' => '7.9.3.0', + 'reference' => '7b2f29fe81dc4da0ca0ea7d42107a0845946ea77', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/guzzle', 'aliases' => array(), 'dev_requirement' => false, ), 'guzzlehttp/promises' => array( - 'pretty_version' => '2.0.4', - 'version' => '2.0.4.0', - 'reference' => 'f9c436286ab2892c7db7be8c8da4ef61ccf7b455', + 'pretty_version' => '2.2.0', + 'version' => '2.2.0.0', + 'reference' => '7c69f28996b0a6920945dd20b3857e499d9ca96c', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/promises', 'aliases' => array(), 'dev_requirement' => false, ), 'guzzlehttp/psr7' => array( - 'pretty_version' => '2.7.0', - 'version' => '2.7.0.0', - 'reference' => 'a70f5c95fb43bc83f07c9c948baa0dc1829bf201', + 'pretty_version' => '2.7.1', + 'version' => '2.7.1.0', + 'reference' => 'c2270caaabe631b3b44c85f99e5a04bbb8060d16', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/psr7', 'aliases' => array(), @@ -155,9 +182,9 @@ 'dev_requirement' => false, ), 'phpmailer/phpmailer' => array( - 'pretty_version' => 'v6.9.3', - 'version' => '6.9.3.0', - 'reference' => '2f5c94fe7493efc213f643c23b1b1c249d40f47e', + 'pretty_version' => 'v6.10.0', + 'version' => '6.10.0.0', + 'reference' => 'bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144', 'type' => 'library', 'install_path' => __DIR__ . '/../phpmailer/phpmailer', 'aliases' => array(), @@ -172,6 +199,15 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'picqer/php-barcode-generator' => array( + 'pretty_version' => 'v2.4.0', + 'version' => '2.4.0.0', + 'reference' => '4cec18909dffd86e14beb69b1040f2520c2e1bb1', + 'type' => 'library', + 'install_path' => __DIR__ . '/../picqer/php-barcode-generator', + 'aliases' => array(), + 'dev_requirement' => false, + ), 'pimple/pimple' => array( 'pretty_version' => 'v3.5.0', 'version' => '3.5.0.0', @@ -371,8 +407,8 @@ 'dev_requirement' => false, ), 'symfony/polyfill-ctype' => array( - 'pretty_version' => 'v1.31.0', - 'version' => '1.31.0.0', + 'pretty_version' => 'v1.32.0', + 'version' => '1.32.0.0', 'reference' => 'a3cc8b044a6ea513310cbd48ef7333b384945638', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-ctype', @@ -380,17 +416,17 @@ 'dev_requirement' => false, ), 'symfony/polyfill-mbstring' => array( - 'pretty_version' => 'v1.31.0', - 'version' => '1.31.0.0', - 'reference' => '85181ba99b2345b0ef10ce42ecac37612d9fd341', + 'pretty_version' => 'v1.32.0', + 'version' => '1.32.0.0', + 'reference' => '6d857f4d76bd4b343eac26d6b539585d2bc56493', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', 'aliases' => array(), 'dev_requirement' => false, ), 'symfony/polyfill-php73' => array( - 'pretty_version' => 'v1.31.0', - 'version' => '1.31.0.0', + 'pretty_version' => 'v1.32.0', + 'version' => '1.32.0.0', 'reference' => '0f68c03565dcaaf25a890667542e8bd75fe7e5bb', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-php73', @@ -398,9 +434,9 @@ 'dev_requirement' => false, ), 'symfony/polyfill-php80' => array( - 'pretty_version' => 'v1.31.0', - 'version' => '1.31.0.0', - 'reference' => '60328e362d4c2c802a54fcbf04f9d3fb892b4cf8', + 'pretty_version' => 'v1.32.0', + 'version' => '1.32.0.0', + 'reference' => '0cc9dd0f17f61d8131e7df6b84bd344899fe2608', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-php80', 'aliases' => array(), @@ -454,7 +490,7 @@ 'topthink/think' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '075de7502013b216a11f34847a1a98600f4eab80', + 'reference' => 'c3b233b94675013624c559d5f2ce5c7d8ccb5927', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php index 92370c5..d826bd1 100644 --- a/vendor/composer/platform_check.php +++ b/vendor/composer/platform_check.php @@ -19,8 +19,7 @@ if ($issues) { echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; } } - trigger_error( - 'Composer detected issues in your platform: ' . implode(' ', $issues), - E_USER_ERROR + throw new \RuntimeException( + 'Composer detected issues in your platform: ' . implode(' ', $issues) ); } diff --git a/vendor/guzzlehttp/guzzle/CHANGELOG.md b/vendor/guzzlehttp/guzzle/CHANGELOG.md index e0b6216..7600ef4 100644 --- a/vendor/guzzlehttp/guzzle/CHANGELOG.md +++ b/vendor/guzzlehttp/guzzle/CHANGELOG.md @@ -3,6 +3,14 @@ Please refer to [UPGRADING](UPGRADING.md) guide for upgrading to a major version. +## 7.9.3 - 2025-03-27 + +### Changed + +- Remove explicit content-length header for GET requests +- Improve compatibility with bad servers for boolean cookie values + + ## 7.9.2 - 2024-07-24 ### Fixed diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php b/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php index c9806da..47c4d10 100644 --- a/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php +++ b/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php @@ -62,6 +62,10 @@ class SetCookie if (is_numeric($value)) { $data[$search] = (int) $value; } + } elseif ($search === 'Secure' || $search === 'Discard' || $search === 'HttpOnly') { + if ($value) { + $data[$search] = true; + } } else { $data[$search] = $value; } diff --git a/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php b/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php index f045b52..9df70cf 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php @@ -17,10 +17,10 @@ class Proxy * Sends synchronous requests to a specific handler while sending all other * requests to another handler. * - * @param callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface $default Handler used for normal responses - * @param callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface $sync Handler used for synchronous responses. + * @param callable(RequestInterface, array): PromiseInterface $default Handler used for normal responses + * @param callable(RequestInterface, array): PromiseInterface $sync Handler used for synchronous responses. * - * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the composed handler. + * @return callable(RequestInterface, array): PromiseInterface Returns the composed handler. */ public static function wrapSync(callable $default, callable $sync): callable { @@ -37,10 +37,10 @@ class Proxy * performance benefits of curl while still supporting true streaming * through the StreamHandler. * - * @param callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface $default Handler used for non-streaming responses - * @param callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface $streaming Handler used for streaming responses + * @param callable(RequestInterface, array): PromiseInterface $default Handler used for non-streaming responses + * @param callable(RequestInterface, array): PromiseInterface $streaming Handler used for streaming responses * - * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the composed handler. + * @return callable(RequestInterface, array): PromiseInterface Returns the composed handler. */ public static function wrapStreaming(callable $default, callable $streaming): callable { diff --git a/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php b/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php index 1d89a8f..083049e 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php @@ -53,8 +53,14 @@ class StreamHandler $request = $request->withoutHeader('Expect'); // Append a content-length header if body size is zero to match - // cURL's behavior. - if (0 === $request->getBody()->getSize()) { + // the behavior of `CurlHandler` + if ( + ( + 0 === \strcasecmp('PUT', $request->getMethod()) + || 0 === \strcasecmp('POST', $request->getMethod()) + ) + && 0 === $request->getBody()->getSize() + ) { $request = $request->withHeader('Content-Length', '0'); } diff --git a/vendor/guzzlehttp/guzzle/src/Pool.php b/vendor/guzzlehttp/guzzle/src/Pool.php index 6277c61..ddc304b 100644 --- a/vendor/guzzlehttp/guzzle/src/Pool.php +++ b/vendor/guzzlehttp/guzzle/src/Pool.php @@ -86,7 +86,7 @@ class Pool implements PromisorInterface * @param ClientInterface $client Client used to send the requests * @param array|\Iterator $requests Requests to send concurrently. * @param array $options Passes through the options available in - * {@see \GuzzleHttp\Pool::__construct} + * {@see Pool::__construct} * * @return array Returns an array containing the response or an exception * in the same order that the requests were sent. diff --git a/vendor/guzzlehttp/guzzle/src/Utils.php b/vendor/guzzlehttp/guzzle/src/Utils.php index df52927..c6a5893 100644 --- a/vendor/guzzlehttp/guzzle/src/Utils.php +++ b/vendor/guzzlehttp/guzzle/src/Utils.php @@ -79,7 +79,7 @@ final class Utils * * The returned handler is not wrapped by any default middlewares. * - * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system. + * @return callable(\Psr\Http\Message\RequestInterface, array): Promise\PromiseInterface Returns the best handler for the given system. * * @throws \RuntimeException if no viable Handler is available. */ diff --git a/vendor/guzzlehttp/guzzle/src/functions.php b/vendor/guzzlehttp/guzzle/src/functions.php index 5edc66a..9ab4b96 100644 --- a/vendor/guzzlehttp/guzzle/src/functions.php +++ b/vendor/guzzlehttp/guzzle/src/functions.php @@ -50,7 +50,7 @@ function debug_resource($value = null) * * The returned handler is not wrapped by any default middlewares. * - * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system. + * @return callable(\Psr\Http\Message\RequestInterface, array): Promise\PromiseInterface Returns the best handler for the given system. * * @throws \RuntimeException if no viable Handler is available. * diff --git a/vendor/guzzlehttp/promises/CHANGELOG.md b/vendor/guzzlehttp/promises/CHANGELOG.md index c7c49a1..1d80450 100644 --- a/vendor/guzzlehttp/promises/CHANGELOG.md +++ b/vendor/guzzlehttp/promises/CHANGELOG.md @@ -1,6 +1,20 @@ # CHANGELOG +## 2.2.0 - 2025-03-27 + +### Fixed + +- Revert "Allow an empty EachPromise to be resolved by running the queue" + + +## 2.1.0 - 2025-03-27 + +### Added + +- Allow an empty EachPromise to be resolved by running the queue + + ## 2.0.4 - 2024-10-17 ### Fixed diff --git a/vendor/guzzlehttp/psr7/CHANGELOG.md b/vendor/guzzlehttp/psr7/CHANGELOG.md index 75aabfb..a859295 100644 --- a/vendor/guzzlehttp/psr7/CHANGELOG.md +++ b/vendor/guzzlehttp/psr7/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 2.7.1 - 2025-03-27 + +### Fixed + +- Fixed uppercase IPv6 addresses in URI + +### Changed + +- Improve uploaded file error message + ## 2.7.0 - 2024-07-18 ### Added diff --git a/vendor/guzzlehttp/psr7/src/UploadedFile.php b/vendor/guzzlehttp/psr7/src/UploadedFile.php index 9c9ea49..d9b779f 100644 --- a/vendor/guzzlehttp/psr7/src/UploadedFile.php +++ b/vendor/guzzlehttp/psr7/src/UploadedFile.php @@ -11,15 +11,15 @@ use RuntimeException; class UploadedFile implements UploadedFileInterface { - private const ERRORS = [ - UPLOAD_ERR_OK, - UPLOAD_ERR_INI_SIZE, - UPLOAD_ERR_FORM_SIZE, - UPLOAD_ERR_PARTIAL, - UPLOAD_ERR_NO_FILE, - UPLOAD_ERR_NO_TMP_DIR, - UPLOAD_ERR_CANT_WRITE, - UPLOAD_ERR_EXTENSION, + private const ERROR_MAP = [ + UPLOAD_ERR_OK => 'UPLOAD_ERR_OK', + UPLOAD_ERR_INI_SIZE => 'UPLOAD_ERR_INI_SIZE', + UPLOAD_ERR_FORM_SIZE => 'UPLOAD_ERR_FORM_SIZE', + UPLOAD_ERR_PARTIAL => 'UPLOAD_ERR_PARTIAL', + UPLOAD_ERR_NO_FILE => 'UPLOAD_ERR_NO_FILE', + UPLOAD_ERR_NO_TMP_DIR => 'UPLOAD_ERR_NO_TMP_DIR', + UPLOAD_ERR_CANT_WRITE => 'UPLOAD_ERR_CANT_WRITE', + UPLOAD_ERR_EXTENSION => 'UPLOAD_ERR_EXTENSION', ]; /** @@ -104,7 +104,7 @@ class UploadedFile implements UploadedFileInterface */ private function setError(int $error): void { - if (false === in_array($error, UploadedFile::ERRORS, true)) { + if (!isset(UploadedFile::ERROR_MAP[$error])) { throw new InvalidArgumentException( 'Invalid error status for UploadedFile' ); @@ -137,7 +137,7 @@ class UploadedFile implements UploadedFileInterface private function validateActive(): void { if (false === $this->isOk()) { - throw new RuntimeException('Cannot retrieve stream due to upload error'); + throw new RuntimeException(\sprintf('Cannot retrieve stream due to upload error (%s)', self::ERROR_MAP[$this->error])); } if ($this->isMoved()) { diff --git a/vendor/guzzlehttp/psr7/src/Uri.php b/vendor/guzzlehttp/psr7/src/Uri.php index 481dfca..a7cdfb0 100644 --- a/vendor/guzzlehttp/psr7/src/Uri.php +++ b/vendor/guzzlehttp/psr7/src/Uri.php @@ -107,7 +107,7 @@ class Uri implements UriInterface, \JsonSerializable { // If IPv6 $prefix = ''; - if (preg_match('%^(.*://\[[0-9:a-f]+\])(.*?)$%', $url, $matches)) { + if (preg_match('%^(.*://\[[0-9:a-fA-F]+\])(.*?)$%', $url, $matches)) { /** @var array{0:string, 1:string, 2:string} $matches */ $prefix = $matches[1]; $url = $matches[2]; diff --git a/vendor/phpmailer/phpmailer/.editorconfig b/vendor/phpmailer/phpmailer/.editorconfig deleted file mode 100644 index a7c44dd..0000000 --- a/vendor/phpmailer/phpmailer/.editorconfig +++ /dev/null @@ -1,15 +0,0 @@ -root = true - -[*] -charset = utf-8 -indent_size = 4 -indent_style = space -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true - -[*.md] -trim_trailing_whitespace = false - -[*.{yml,yaml}] -indent_size = 2 diff --git a/vendor/phpmailer/phpmailer/README.md b/vendor/phpmailer/phpmailer/README.md index 07fe8c8..862a4e1 100644 --- a/vendor/phpmailer/phpmailer/README.md +++ b/vendor/phpmailer/phpmailer/README.md @@ -20,25 +20,26 @@ - Multipart/alternative emails for mail clients that do not read HTML email - Add attachments, including inline - Support for UTF-8 content and 8bit, base64, binary, and quoted-printable encodings -- SMTP authentication with LOGIN, PLAIN, CRAM-MD5, and XOAUTH2 mechanisms over SMTPS and SMTP+STARTTLS transports +- Full UTF-8 support when using servers that support `SMTPUTF8`. +- Support for iCal events in multiparts and attachments +- SMTP authentication with `LOGIN`, `PLAIN`, `CRAM-MD5`, and `XOAUTH2` mechanisms over SMTPS and SMTP+STARTTLS transports - Validates email addresses automatically - Protects against header injection attacks - Error messages in over 50 languages! - DKIM and S/MIME signing support -- Compatible with PHP 5.5 and later, including PHP 8.2 +- Compatible with PHP 5.5 and later, including PHP 8.4 - Namespaced to prevent name clashes - Much more! ## Why you might need it -Many PHP developers need to send email from their code. The only PHP function that supports this directly is [`mail()`](https://www.php.net/manual/en/function.mail.php). However, it does not provide any assistance for making use of popular features such as encryption, authentication, HTML messages, and attachments. +Many PHP developers need to send email from their code. The only PHP function that supports this directly is [`mail()`](https://www.php.net/manual/en/function.mail.php). However, it does not provide any assistance for making use of popular features such as authentication, HTML messages, and attachments. Formatting email correctly is surprisingly difficult. There are myriad overlapping (and conflicting) standards, requiring tight adherence to horribly complicated formatting and encoding rules – the vast majority of code that you'll find online that uses the `mail()` function directly is just plain wrong, if not unsafe! The PHP `mail()` function usually sends via a local mail server, typically fronted by a `sendmail` binary on Linux, BSD, and macOS platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP client allows email sending on all platforms without needing a local mail server. Be aware though, that the `mail()` function should be avoided when possible; it's both faster and [safer](https://exploitbox.io/paper/Pwning-PHP-Mail-Function-For-Fun-And-RCE.html) to use SMTP to localhost. *Please* don't be tempted to do it yourself – if you don't use PHPMailer, there are many other excellent libraries that -you should look at before rolling your own. Try [SwiftMailer](https://swiftmailer.symfony.com/) -, [Laminas/Mail](https://docs.laminas.dev/laminas-mail/), [ZetaComponents](https://github.com/zetacomponents/Mail), etc. +you should look at before rolling your own. Try [Symfony Mailer](https://symfony.com/doc/current/mailer.html), [Laminas/Mail](https://docs.laminas.dev/laminas-mail/), [ZetaComponents](https://github.com/zetacomponents/Mail), etc. ## License This software is distributed under the [LGPL 2.1](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html) license, along with the [GPL Cooperation Commitment](https://gplcc.github.io/gplcc/). Please read [LICENSE](https://github.com/PHPMailer/PHPMailer/blob/master/LICENSE) for information on the software availability and distribution. @@ -47,7 +48,7 @@ This software is distributed under the [LGPL 2.1](https://www.gnu.org/licenses/o PHPMailer is available on [Packagist](https://packagist.org/packages/phpmailer/phpmailer) (using semantic versioning), and installation via [Composer](https://getcomposer.org) is the recommended way to install PHPMailer. Just add this line to your `composer.json` file: ```json -"phpmailer/phpmailer": "^6.9.2" +"phpmailer/phpmailer": "^6.10.0" ``` or run @@ -74,7 +75,7 @@ require 'path/to/PHPMailer/src/PHPMailer.php'; require 'path/to/PHPMailer/src/SMTP.php'; ``` -If you're not using the `SMTP` class explicitly (you're probably not), you don't need a `use` line for the SMTP class. Even if you're not using exceptions, you do still need to load the `Exception` class as it is used internally. +If you're not using the `SMTP` class explicitly (you're probably not), you don't need a `use` line for it. Even if you're not using exceptions, you do still need to load the `Exception` class as it is used internally. ## Legacy versions PHPMailer 5.2 (which is compatible with PHP 5.0 — 7.0) is no longer supported, even for security updates. You will find the latest version of 5.2 in the [5.2-stable branch](https://github.com/PHPMailer/PHPMailer/tree/5.2-stable). If you're using PHP 5.5 or later (which you should be), switch to the 6.x releases. @@ -95,7 +96,7 @@ use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; -//Load Composer's autoloader +//Load Composer's autoloader (created by composer, not included with PHPMailer) require 'vendor/autoload.php'; //Create an instance; passing `true` enables exceptions diff --git a/vendor/phpmailer/phpmailer/VERSION b/vendor/phpmailer/phpmailer/VERSION index 5f54f91..cf79bf9 100644 --- a/vendor/phpmailer/phpmailer/VERSION +++ b/vendor/phpmailer/phpmailer/VERSION @@ -1 +1 @@ -6.9.3 +6.10.0 diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-pt.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-pt.php index f1ce946..79a6802 100644 --- a/vendor/phpmailer/phpmailer/language/phpmailer.lang-pt.php +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-pt.php @@ -3,25 +3,32 @@ /** * Portuguese (European) PHPMailer language file: refer to English translation for definitive list * @package PHPMailer - * @author Jonadabe + * @author João Vieira */ -$PHPMAILER_LANG['authenticate'] = 'Erro do SMTP: Não foi possível realizar a autenticação.'; -$PHPMAILER_LANG['connect_host'] = 'Erro do SMTP: Não foi possível realizar ligação com o servidor SMTP.'; -$PHPMAILER_LANG['data_not_accepted'] = 'Erro do SMTP: Os dados foram rejeitados.'; -$PHPMAILER_LANG['empty_message'] = 'A mensagem no e-mail está vazia.'; +$PHPMAILER_LANG['authenticate'] = 'Erro SMTP: Falha na autenticação.'; +$PHPMAILER_LANG['buggy_php'] = 'A sua versão do PHP tem um bug que pode causar mensagens corrompidas. Para resolver, utilize o envio por SMTP, desative a opção mail.add_x_header no ficheiro php.ini, mude para MacOS ou Linux, ou atualize o PHP para a versão 7.0.17+ ou 7.1.3+.'; +$PHPMAILER_LANG['connect_host'] = 'Erro SMTP: Não foi possível ligar ao servidor SMTP.'; +$PHPMAILER_LANG['data_not_accepted'] = 'Erro SMTP: Dados não aceites.'; +$PHPMAILER_LANG['empty_message'] = 'A mensagem de e-mail está vazia.'; $PHPMAILER_LANG['encoding'] = 'Codificação desconhecida: '; $PHPMAILER_LANG['execute'] = 'Não foi possível executar: '; -$PHPMAILER_LANG['file_access'] = 'Não foi possível aceder o ficheiro: '; -$PHPMAILER_LANG['file_open'] = 'Abertura do ficheiro: Não foi possível abrir o ficheiro: '; -$PHPMAILER_LANG['from_failed'] = 'Ocorreram falhas nos endereços dos seguintes remententes: '; -$PHPMAILER_LANG['instantiate'] = 'Não foi possível iniciar uma instância da função mail.'; -$PHPMAILER_LANG['invalid_address'] = 'Não foi enviado nenhum e-mail para o endereço de e-mail inválido: '; -$PHPMAILER_LANG['mailer_not_supported'] = ' mailer não é suportado.'; -$PHPMAILER_LANG['provide_address'] = 'Tem de fornecer pelo menos um endereço como destinatário do e-mail.'; -$PHPMAILER_LANG['recipients_failed'] = 'Erro do SMTP: O endereço do seguinte destinatário falhou: '; -$PHPMAILER_LANG['signing'] = 'Erro ao assinar: '; -$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() falhou.'; -$PHPMAILER_LANG['smtp_error'] = 'Erro de servidor SMTP: '; -$PHPMAILER_LANG['variable_set'] = 'Não foi possível definir ou redefinir a variável: '; $PHPMAILER_LANG['extension_missing'] = 'Extensão em falta: '; +$PHPMAILER_LANG['file_access'] = 'Não foi possível aceder ao ficheiro: '; +$PHPMAILER_LANG['file_open'] = 'Erro ao abrir o ficheiro: '; +$PHPMAILER_LANG['from_failed'] = 'O envio falhou para o seguinte endereço do remetente: '; +$PHPMAILER_LANG['instantiate'] = 'Não foi possível instanciar a função mail.'; +$PHPMAILER_LANG['invalid_address'] = 'Endereço de e-mail inválido: '; +$PHPMAILER_LANG['invalid_header'] = 'Nome ou valor do cabeçalho inválido.'; +$PHPMAILER_LANG['invalid_hostentry'] = 'Entrada de host inválida: '; +$PHPMAILER_LANG['invalid_host'] = 'Host inválido: '; +$PHPMAILER_LANG['mailer_not_supported'] = 'O cliente de e-mail não é suportado.'; +$PHPMAILER_LANG['provide_address'] = 'Deve fornecer pelo menos um endereço de destinatário.'; +$PHPMAILER_LANG['recipients_failed'] = 'Erro SMTP: Falha no envio para os seguintes destinatários: '; +$PHPMAILER_LANG['signing'] = 'Erro ao assinar: '; +$PHPMAILER_LANG['smtp_code'] = 'Código SMTP: '; +$PHPMAILER_LANG['smtp_code_ex'] = 'Informações adicionais SMTP: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Falha na função SMTP connect().'; +$PHPMAILER_LANG['smtp_detail'] = 'Detalhes: '; +$PHPMAILER_LANG['smtp_error'] = 'Erro do servidor SMTP: '; +$PHPMAILER_LANG['variable_set'] = 'Não foi possível definir ou redefinir a variável: '; diff --git a/vendor/phpmailer/phpmailer/src/PHPMailer.php b/vendor/phpmailer/phpmailer/src/PHPMailer.php index 4a6077c..2444bcf 100644 --- a/vendor/phpmailer/phpmailer/src/PHPMailer.php +++ b/vendor/phpmailer/phpmailer/src/PHPMailer.php @@ -580,6 +580,10 @@ class PHPMailer * May be a callable to inject your own validator, but there are several built-in validators. * The default validator uses PHP's FILTER_VALIDATE_EMAIL filter_var option. * + * If CharSet is UTF8, the validator is left at the default value, + * and you send to addresses that use non-ASCII local parts, then + * PHPMailer automatically changes to the 'eai' validator. + * * @see PHPMailer::validateAddress() * * @var string|callable @@ -659,6 +663,14 @@ class PHPMailer */ protected $ReplyToQueue = []; + /** + * Whether the need for SMTPUTF8 has been detected. Set by + * preSend() if necessary. + * + * @var bool + */ + public $UseSMTPUTF8 = false; + /** * The array of attachments. * @@ -756,7 +768,7 @@ class PHPMailer * * @var string */ - const VERSION = '6.9.3'; + const VERSION = '6.10.0'; /** * Error severity: message only, continue processing. @@ -1110,19 +1122,22 @@ class PHPMailer $params = [$kind, $address, $name]; //Enqueue addresses with IDN until we know the PHPMailer::$CharSet. //Domain is assumed to be whatever is after the last @ symbol in the address - if (static::idnSupported() && $this->has8bitChars(substr($address, ++$pos))) { - if ('Reply-To' !== $kind) { - if (!array_key_exists($address, $this->RecipientsQueue)) { - $this->RecipientsQueue[$address] = $params; + if ($this->has8bitChars(substr($address, ++$pos))) { + if (static::idnSupported()) { + if ('Reply-To' !== $kind) { + if (!array_key_exists($address, $this->RecipientsQueue)) { + $this->RecipientsQueue[$address] = $params; + + return true; + } + } elseif (!array_key_exists($address, $this->ReplyToQueue)) { + $this->ReplyToQueue[$address] = $params; return true; } - } elseif (!array_key_exists($address, $this->ReplyToQueue)) { - $this->ReplyToQueue[$address] = $params; - - return true; } - + //We have an 8-bit domain, but we are missing the necessary extensions to support it + //Or we are already sending to this address return false; } @@ -1160,6 +1175,15 @@ class PHPMailer */ protected function addAnAddress($kind, $address, $name = '') { + if ( + self::$validator === 'php' && + ((bool) preg_match('/[\x80-\xFF]/', $address)) + ) { + //The caller has not altered the validator and is sending to an address + //with UTF-8, so assume that they want UTF-8 support instead of failing + $this->CharSet = self::CHARSET_UTF8; + self::$validator = 'eai'; + } if (!in_array($kind, ['to', 'cc', 'bcc', 'Reply-To'])) { $error_message = sprintf( '%s: %s', @@ -1362,6 +1386,7 @@ class PHPMailer * * `pcre` Use old PCRE implementation; * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL; * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements. + * * `eai` Use a pattern similar to the HTML5 spec for 'email' and to firefox, extended to support EAI (RFC6530). * * `noregex` Don't use a regex: super fast, really dumb. * Alternatively you may pass in a callable to inject your own validator, for example: * @@ -1432,6 +1457,24 @@ class PHPMailer '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD', $address ); + case 'eai': + /* + * This is the pattern used in the HTML5 spec for validation of 'email' type + * form input elements (as above), modified to accept Unicode email addresses. + * This is also more lenient than Firefox' html5 spec, in order to make the regex faster. + * 'eai' is an acronym for Email Address Internationalization. + * This validator is selected automatically if you attempt to use recipient addresses + * that contain Unicode characters in the local part. + * + * @see https://html.spec.whatwg.org/#e-mail-state-(type=email) + * @see https://en.wikipedia.org/wiki/International_email + */ + return (bool) preg_match( + '/^[-\p{L}\p{N}\p{M}.!#$%&\'*+\/=?^_`{|}~]+@[\p{L}\p{N}\p{M}](?:[\p{L}\p{N}\p{M}-]{0,61}' . + '[\p{L}\p{N}\p{M}])?(?:\.[\p{L}\p{N}\p{M}]' . + '(?:[-\p{L}\p{N}\p{M}]{0,61}[\p{L}\p{N}\p{M}])?)*$/usD', + $address + ); case 'php': default: return filter_var($address, FILTER_VALIDATE_EMAIL) !== false; @@ -1565,9 +1608,26 @@ class PHPMailer $this->error_count = 0; //Reset errors $this->mailHeader = ''; + //The code below tries to support full use of Unicode, + //while remaining compatible with legacy SMTP servers to + //the greatest degree possible: If the message uses + //Unicode in the local parts of any addresses, it is sent + //using SMTPUTF8. If not, it it sent using + //punycode-encoded domains and plain SMTP. + if ( + static::CHARSET_UTF8 === strtolower($this->CharSet) && + ($this->anyAddressHasUnicodeLocalPart($this->RecipientsQueue) || + $this->anyAddressHasUnicodeLocalPart(array_keys($this->all_recipients)) || + $this->anyAddressHasUnicodeLocalPart($this->ReplyToQueue) || + $this->addressHasUnicodeLocalPart($this->From)) + ) { + $this->UseSMTPUTF8 = true; + } //Dequeue recipient and Reply-To addresses with IDN foreach (array_merge($this->RecipientsQueue, $this->ReplyToQueue) as $params) { - $params[1] = $this->punyencodeAddress($params[1]); + if (!$this->UseSMTPUTF8) { + $params[1] = $this->punyencodeAddress($params[1]); + } call_user_func_array([$this, 'addAnAddress'], $params); } if (count($this->to) + count($this->cc) + count($this->bcc) < 1) { @@ -2058,6 +2118,11 @@ class PHPMailer if (!$this->smtpConnect($this->SMTPOptions)) { throw new Exception($this->lang('smtp_connect_failed'), self::STOP_CRITICAL); } + //If we have recipient addresses that need Unicode support, + //but the server doesn't support it, stop here + if ($this->UseSMTPUTF8 && !$this->smtp->getServerExt('SMTPUTF8')) { + throw new Exception($this->lang('no_smtputf8'), self::STOP_CRITICAL); + } //Sender already validated in preSend() if ('' === $this->Sender) { $smtp_from = $this->From; @@ -2159,6 +2224,7 @@ class PHPMailer $this->smtp->setDebugLevel($this->SMTPDebug); $this->smtp->setDebugOutput($this->Debugoutput); $this->smtp->setVerp($this->do_verp); + $this->smtp->setSMTPUTF8($this->UseSMTPUTF8); if ($this->Host === null) { $this->Host = 'localhost'; } @@ -2356,6 +2422,7 @@ class PHPMailer 'smtp_detail' => 'Detail: ', 'smtp_error' => 'SMTP server error: ', 'variable_set' => 'Cannot set or reset variable: ', + 'no_smtputf8' => 'Server does not support SMTPUTF8 needed to send to Unicode addresses', ]; if (empty($lang_path)) { //Calculate an absolute path so it can work if CWD is not here @@ -2870,7 +2937,9 @@ class PHPMailer $bodyEncoding = $this->Encoding; $bodyCharSet = $this->CharSet; //Can we do a 7-bit downgrade? - if (static::ENCODING_8BIT === $bodyEncoding && !$this->has8bitChars($this->Body)) { + if ($this->UseSMTPUTF8) { + $bodyEncoding = static::ENCODING_8BIT; + } elseif (static::ENCODING_8BIT === $bodyEncoding && !$this->has8bitChars($this->Body)) { $bodyEncoding = static::ENCODING_7BIT; //All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit $bodyCharSet = static::CHARSET_ASCII; @@ -3507,7 +3576,8 @@ class PHPMailer /** * Encode a header value (not including its label) optimally. * Picks shortest of Q, B, or none. Result includes folding if needed. - * See RFC822 definitions for phrase, comment and text positions. + * See RFC822 definitions for phrase, comment and text positions, + * and RFC2047 for inline encodings. * * @param string $str The header value to encode * @param string $position What context the string will be used in @@ -3516,6 +3586,11 @@ class PHPMailer */ public function encodeHeader($str, $position = 'text') { + $position = strtolower($position); + if ($this->UseSMTPUTF8 && !("comment" === $position)) { + return trim(static::normalizeBreaks($str)); + } + $matchcount = 0; switch (strtolower($position)) { case 'phrase': @@ -4180,7 +4255,7 @@ class PHPMailer if ('smtp' === $this->Mailer && null !== $this->smtp) { $lasterror = $this->smtp->getError(); if (!empty($lasterror['error'])) { - $msg .= $this->lang('smtp_error') . $lasterror['error']; + $msg .= ' ' . $this->lang('smtp_error') . $lasterror['error']; if (!empty($lasterror['detail'])) { $msg .= ' ' . $this->lang('smtp_detail') . $lasterror['detail']; } @@ -4267,6 +4342,45 @@ class PHPMailer return filter_var('https://' . $host, FILTER_VALIDATE_URL) !== false; } + /** + * Check whether the supplied address uses Unicode in the local part. + * + * @return bool + */ + protected function addressHasUnicodeLocalPart($address) + { + return (bool) preg_match('/[\x80-\xFF].*@/', $address); + } + + /** + * Check whether any of the supplied addresses use Unicode in the local part. + * + * @return bool + */ + protected function anyAddressHasUnicodeLocalPart($addresses) + { + foreach ($addresses as $address) { + if (is_array($address)) { + $address = $address[0]; + } + if ($this->addressHasUnicodeLocalPart($address)) { + return true; + } + } + return false; + } + + /** + * Check whether the message requires SMTPUTF8 based on what's known so far. + * + * @return bool + */ + public function needsSMTPUTF8() + { + return $this->UseSMTPUTF8; + } + + /** * Get an error message in the current language. * diff --git a/vendor/phpmailer/phpmailer/src/POP3.php b/vendor/phpmailer/phpmailer/src/POP3.php index 376fae2..1190a1e 100644 --- a/vendor/phpmailer/phpmailer/src/POP3.php +++ b/vendor/phpmailer/phpmailer/src/POP3.php @@ -46,7 +46,7 @@ class POP3 * * @var string */ - const VERSION = '6.9.3'; + const VERSION = '6.10.0'; /** * Default POP3 port number. diff --git a/vendor/phpmailer/phpmailer/src/SMTP.php b/vendor/phpmailer/phpmailer/src/SMTP.php index b4eff40..7226ee9 100644 --- a/vendor/phpmailer/phpmailer/src/SMTP.php +++ b/vendor/phpmailer/phpmailer/src/SMTP.php @@ -35,7 +35,7 @@ class SMTP * * @var string */ - const VERSION = '6.9.3'; + const VERSION = '6.10.0'; /** * SMTP line break constant. @@ -159,6 +159,15 @@ class SMTP */ public $do_verp = false; + /** + * Whether to use SMTPUTF8. + * + * @see https://www.rfc-editor.org/rfc/rfc6531 + * + * @var bool + */ + public $do_smtputf8 = false; + /** * The timeout value for connection, in seconds. * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2. @@ -913,7 +922,15 @@ class SMTP * $from. Returns true if successful or false otherwise. If True * the mail transaction is started and then one or more recipient * commands may be called followed by a data command. - * Implements RFC 821: MAIL FROM: . + * Implements RFC 821: MAIL FROM: and + * two extensions, namely XVERP and SMTPUTF8. + * + * The server's EHLO response is not checked. If use of either + * extensions is enabled even though the server does not support + * that, mail submission will fail. + * + * XVERP is documented at https://www.postfix.org/VERP_README.html + * and SMTPUTF8 is specified in RFC 6531. * * @param string $from Source address of this message * @@ -922,10 +939,11 @@ class SMTP public function mail($from) { $useVerp = ($this->do_verp ? ' XVERP' : ''); + $useSmtputf8 = ($this->do_smtputf8 ? ' SMTPUTF8' : ''); return $this->sendCommand( 'MAIL FROM', - 'MAIL FROM:<' . $from . '>' . $useVerp, + 'MAIL FROM:<' . $from . '>' . $useSmtputf8 . $useVerp, 250 ); } @@ -1364,6 +1382,26 @@ class SMTP return $this->do_verp; } + /** + * Enable or disable use of SMTPUTF8. + * + * @param bool $enabled + */ + public function setSMTPUTF8($enabled = false) + { + $this->do_smtputf8 = $enabled; + } + + /** + * Get SMTPUTF8 use. + * + * @return bool + */ + public function getSMTPUTF8() + { + return $this->do_smtputf8; + } + /** * Set error messages and codes. * diff --git a/vendor/symfony/polyfill-mbstring/Mbstring.php b/vendor/symfony/polyfill-mbstring/Mbstring.php index 3d45c9d..31e36a3 100644 --- a/vendor/symfony/polyfill-mbstring/Mbstring.php +++ b/vendor/symfony/polyfill-mbstring/Mbstring.php @@ -983,7 +983,7 @@ final class Mbstring public static function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string { - return self::mb_internal_trim('{[%s]+$}D', $string, $characters, $encoding, __FUNCTION__); + return self::mb_internal_trim('{[%s]+$}Du', $string, $characters, $encoding, __FUNCTION__); } private static function mb_internal_trim(string $regex, string $string, ?string $characters, ?string $encoding, string $function): string diff --git a/vendor/symfony/polyfill-mbstring/bootstrap80.php b/vendor/symfony/polyfill-mbstring/bootstrap80.php index 5be7d20..5236e6d 100644 --- a/vendor/symfony/polyfill-mbstring/bootstrap80.php +++ b/vendor/symfony/polyfill-mbstring/bootstrap80.php @@ -133,11 +133,11 @@ if (!function_exists('mb_str_pad')) { } if (!function_exists('mb_ucfirst')) { - function mb_ucfirst($string, ?string $encoding = null): string { return p\Mbstring::mb_ucfirst($string, $encoding); } + function mb_ucfirst(string $string, ?string $encoding = null): string { return p\Mbstring::mb_ucfirst($string, $encoding); } } if (!function_exists('mb_lcfirst')) { - function mb_lcfirst($string, ?string $encoding = null): string { return p\Mbstring::mb_lcfirst($string, $encoding); } + function mb_lcfirst(string $string, ?string $encoding = null): string { return p\Mbstring::mb_lcfirst($string, $encoding); } } if (!function_exists('mb_trim')) { diff --git a/vendor/symfony/polyfill-mbstring/composer.json b/vendor/symfony/polyfill-mbstring/composer.json index 4ed241a..daa07f8 100644 --- a/vendor/symfony/polyfill-mbstring/composer.json +++ b/vendor/symfony/polyfill-mbstring/composer.json @@ -16,7 +16,8 @@ } ], "require": { - "php": ">=7.2" + "php": ">=7.2", + "ext-iconv": "*" }, "provide": { "ext-mbstring": "*" diff --git a/vendor/symfony/polyfill-php80/PhpToken.php b/vendor/symfony/polyfill-php80/PhpToken.php index fe6e691..cd78c4c 100644 --- a/vendor/symfony/polyfill-php80/PhpToken.php +++ b/vendor/symfony/polyfill-php80/PhpToken.php @@ -29,7 +29,7 @@ class PhpToken implements \Stringable public $text; /** - * @var int + * @var -1|positive-int */ public $line; @@ -38,6 +38,9 @@ class PhpToken implements \Stringable */ public $pos; + /** + * @param -1|positive-int $line + */ public function __construct(int $id, string $text, int $line = -1, int $position = -1) { $this->id = $id; @@ -80,7 +83,7 @@ class PhpToken implements \Stringable } /** - * @return static[] + * @return list */ public static function tokenize(string $code, int $flags = 0): array {