????作者:計(jì)算機(jī)源碼社
????個(gè)人簡(jiǎn)介:本人 八年開(kāi)發(fā)經(jīng)驗(yàn),擅長(zhǎng)Java装处、Python误债、PHP、.NET、Node.js寝蹈、Android李命、微信小程序、爬蟲箫老、大數(shù)據(jù)封字、機(jī)器學(xué)習(xí)等,大家有這一塊的問(wèn)題可以一起交流耍鬓!
1阔籽、研究背景
??隨著社會(huì)經(jīng)濟(jì)的發(fā)展和生活水平的提高,人們對(duì)旅行和住宿的需求不斷增加牲蜀。傳統(tǒng)的酒店預(yù)約和送餐服務(wù)存在著操作繁瑣笆制、效率低下等問(wèn)題,無(wú)法滿足現(xiàn)代用戶對(duì)便捷各薇、高效项贺、個(gè)性化服務(wù)的需求君躺。尤其在疫情期間峭判,用戶對(duì)無(wú)接觸的服務(wù)需求激增,傳統(tǒng)的服務(wù)模式顯得尤為滯后棕叫。因此林螃,開(kāi)發(fā)一個(gè)集成酒店預(yù)約與送餐功能的系統(tǒng),能夠有效解決這些問(wèn)題俺泣,提高用戶體驗(yàn)疗认,并適應(yīng)市場(chǎng)的新需求,成為當(dāng)務(wù)之急伏钠。通過(guò)技術(shù)創(chuàng)新和智能化手段横漏,我們可以突破傳統(tǒng)服務(wù)模式的限制,提供更為靈活熟掂、便捷的服務(wù)解決方案缎浇。
2、研究目的和意義
??本系統(tǒng)的開(kāi)發(fā)旨在通過(guò)先進(jìn)的技術(shù)手段赴肚,提升酒店預(yù)約和送餐服務(wù)的效率與便利性素跺。首先,系統(tǒng)將整合酒店的房間信息誉券、價(jià)格指厌、實(shí)時(shí)空房狀況等,實(shí)現(xiàn)一站式的在線預(yù)約功能踊跟,簡(jiǎn)化用戶的操作流程踩验。其次,系統(tǒng)將提供智能化的送餐服務(wù),通過(guò)用戶下單后的實(shí)時(shí)跟蹤晰甚、個(gè)性化推薦等功能衙传,提升服務(wù)質(zhì)量和用戶滿意度。系統(tǒng)還將支持多種支付方式和數(shù)據(jù)分析功能厕九,以優(yōu)化服務(wù)流程和提升用戶體驗(yàn)蓖捶。通過(guò)這些功能的實(shí)現(xiàn),系統(tǒng)力求在提升服務(wù)質(zhì)量的同時(shí)扁远,降低運(yùn)營(yíng)成本俊鱼,實(shí)現(xiàn)酒店與用戶之間的高效對(duì)接。
??開(kāi)發(fā)一個(gè)集成酒店預(yù)約與送餐功能的系統(tǒng)畅买,不僅有助于提升用戶的服務(wù)體驗(yàn)并闲,還能推動(dòng)酒店業(yè)和餐飲業(yè)的數(shù)字化轉(zhuǎn)型。系統(tǒng)的推出將使酒店能夠更好地管理房間資源谷羞,提高入住率帝火,并通過(guò)數(shù)據(jù)分析洞察市場(chǎng)需求,優(yōu)化運(yùn)營(yíng)策略湃缎。同時(shí)犀填,送餐功能的集成將為用戶提供更為便捷的餐飲服務(wù),提升酒店的附加值和競(jìng)爭(zhēng)力嗓违。在更廣泛的層面上九巡,該系統(tǒng)的開(kāi)發(fā)將推動(dòng)整個(gè)行業(yè)向智能化、信息化發(fā)展蹂季,為未來(lái)的服務(wù)創(chuàng)新奠定基礎(chǔ)冕广,從而帶來(lái)經(jīng)濟(jì)效益和社會(huì)效益的雙重提升。
3偿洁、系統(tǒng)研究?jī)?nèi)容
系統(tǒng)架構(gòu)設(shè)計(jì)
研究系統(tǒng)的整體架構(gòu)撒汉,包括前端用戶界面和后端服務(wù)器的設(shè)計(jì)。前端用戶界面需要提供直觀涕滋、易用的操作界面睬辐,支持酒店房間的搜索叙谨、篩選需频、預(yù)訂以及送餐服務(wù)的選擇敬拓。后端服務(wù)器則負(fù)責(zé)處理用戶請(qǐng)求设哗、管理酒店房間信息禀晓、訂單處理以及支付系統(tǒng)的集成茫因。需要考慮系統(tǒng)的可擴(kuò)展性和可維護(hù)性癞埠,以適應(yīng)未來(lái)功能的擴(kuò)展和升級(jí)芽世。數(shù)據(jù)管理與分析
研究如何有效地管理和分析系統(tǒng)中的數(shù)據(jù)黔酥,包括用戶數(shù)據(jù)藻三、酒店房間信息洪橘、訂單記錄和送餐數(shù)據(jù)等。設(shè)計(jì)高效的數(shù)據(jù)存儲(chǔ)方案棵帽,確保數(shù)據(jù)的準(zhǔn)確性和安全性熄求。通過(guò)數(shù)據(jù)分析功能,能夠生成用戶行為報(bào)告逗概、銷售分析報(bào)告和市場(chǎng)趨勢(shì)預(yù)測(cè)弟晚,幫助酒店管理者優(yōu)化運(yùn)營(yíng)策略和提升服務(wù)質(zhì)量。實(shí)時(shí)處理與智能推薦
研究如何實(shí)現(xiàn)實(shí)時(shí)處理用戶請(qǐng)求和訂單逾苫。包括實(shí)時(shí)更新房間空閑狀態(tài)卿城、訂單狀態(tài)跟蹤以及送餐進(jìn)度跟蹤等。開(kāi)發(fā)智能推薦算法铅搓,根據(jù)用戶的歷史行為瑟押、偏好和當(dāng)前需求,提供個(gè)性化的酒店房間和送餐服務(wù)推薦星掰,提高用戶體驗(yàn)和滿意度多望。支付系統(tǒng)集成
研究如何集成多種支付方式,確保用戶能夠便捷地完成支付氢烘。包括信用卡怀偷、電子錢包、移動(dòng)支付等多種支付渠道的支持威始。需要處理支付安全問(wèn)題枢纠,確保用戶的支付信息不被泄露像街,并實(shí)現(xiàn)支付交易的快速黎棠、準(zhǔn)確處理。安全性與隱私保護(hù)
研究系統(tǒng)的安全性設(shè)計(jì)和隱私保護(hù)措施镰绎。包括數(shù)據(jù)加密脓斩、用戶身份驗(yàn)證、權(quán)限管理等畴栖,以保護(hù)用戶數(shù)據(jù)和交易信息的安全随静。設(shè)計(jì)系統(tǒng)防護(hù)機(jī)制,防止?jié)撛诘木W(wǎng)絡(luò)攻擊和數(shù)據(jù)泄露吗讶,確保系統(tǒng)的可靠性和用戶的信任燎猛。用戶體驗(yàn)優(yōu)化
研究用戶體驗(yàn)的優(yōu)化策略,包括用戶界面的友好性照皆、操作的流暢性以及服務(wù)的響應(yīng)速度重绷。通過(guò)用戶反饋和體驗(yàn)測(cè)試,不斷改進(jìn)系統(tǒng)的功能和設(shè)計(jì)膜毁,提高系統(tǒng)的易用性和用戶滿意度昭卓。設(shè)計(jì)簡(jiǎn)潔直觀的界面愤钾,提供友好的用戶指導(dǎo)和幫助,提高用戶的整體體驗(yàn)候醒。
4能颁、系統(tǒng)頁(yè)面設(shè)計(jì)
5、參考文獻(xiàn)
[1]朱玉鳳.基于JavaWeb的酒店管理系統(tǒng)的設(shè)計(jì)與實(shí)現(xiàn)[J].網(wǎng)絡(luò)安全和信息化,2023,(12):91-94.
[2]張瑩,王運(yùn)霞,易超,等.鐵路企業(yè)差旅酒店預(yù)訂系統(tǒng)數(shù)據(jù)治理技術(shù)研究[J].鐵路計(jì)算機(jī)應(yīng)用,2023,32(10):23-26.
[3]郭志英.基于Web的酒店管理系統(tǒng)的設(shè)計(jì)與實(shí)現(xiàn)[J].長(zhǎng)江信息通信,2022,35(12):120-123.
[4]劉雨.酒店管理信息系統(tǒng)的發(fā)展演變[J].今日財(cái)富,2022,(14):40-42.
[5]錢春霞.智慧酒店系統(tǒng)設(shè)計(jì)研究[J].電子技術(shù)與軟件工程,2022,(14):175-178.
[6]洪暉煌,潘善亮.基于MQTT的智慧酒店系統(tǒng)設(shè)計(jì)[J].無(wú)線通信技術(shù),2022,31(02):59-62.
[7]錢春霞.連鎖酒店管理系統(tǒng)的設(shè)計(jì)研究[J].電子技術(shù)與軟件工程,2022,(11):216-219.
[8]Wong E .破解四大云酒店管理系統(tǒng)誤區(qū)[J].軟件和集成電路,2022,(05):12-13.DOI:10.19609/j.cnki.cn10-1339/tn.2022.05.010.
[9]于盛洋.智慧酒店管理系統(tǒng)設(shè)計(jì)與實(shí)現(xiàn)——基于RFID模塊[J].產(chǎn)業(yè)科技創(chuàng)新,2022,4(02):37-40.
[10]關(guān)世友,劉曉輝.基于物聯(lián)網(wǎng)六域模型的智慧酒店系統(tǒng)設(shè)計(jì)及應(yīng)用[J].物聯(lián)網(wǎng)技術(shù),2022,12(03):95-99.DOI:10.16667/j.issn.2095-1302.2022.03.028.
[11]董華軍.酒店管理系統(tǒng)的設(shè)計(jì)與實(shí)現(xiàn)[J].工業(yè)控制計(jì)算機(jī),2022,35(01):140-141.
[12]張若淼,吳明霞.基于評(píng)論情感分析需求的酒店客房預(yù)定系統(tǒng)[J].電腦編程技巧與維護(hù),2021,(12):13-14+20.DOI:10.16184/j.cnki.comprg.2021.12.005.
[13]馮朔,鄭學(xué)智.基于邊云協(xié)同的智慧酒店系統(tǒng)[J].電子設(shè)計(jì)工程,2021,29(19):19-24+30.DOI:10.14022/j.issn1674-6236.2021.19.004.
[14]王巖,一種基于人臉識(shí)別和卡片識(shí)別的酒店管理系統(tǒng).陜西省,西安頂吉智能科技有限公司,2021-08-17.
[15]邵全勇,雒海東.基于CRM的酒店管理信息系統(tǒng)設(shè)計(jì)與實(shí)現(xiàn)[J].電子設(shè)計(jì)工程,2021,29(14):15-19.DOI:10.14022/j.issn1674-6236.2021.14.004.
[16]朱云杰.翼云居酒店管理系統(tǒng)前置服務(wù)設(shè)計(jì)[J].電子元器件與信息技術(shù),2021,5(06):182-185.DOI:10.19772/j.cnki.2096-4455.2021.6.081.
[17]劉映群,劉俊欽,梁健煊.智慧酒店管理系統(tǒng)設(shè)計(jì)與實(shí)現(xiàn)[J].現(xiàn)代信息科技,2021,5(09):87-92.DOI:10.19850/j.cnki.2096-4706.2021.09.023.
[18]于燕秀,俞睿,嚴(yán)飛杰.基于面部識(shí)別的智能酒店管理系統(tǒng)[J].工業(yè)技術(shù)創(chuàng)新,2021,08(01):70-73+107.DOI:10.14103/j.issn.2095-8412.2021.01.011.
[19]馮朔.基于邊云協(xié)同計(jì)算的智慧酒店系統(tǒng)[D].武漢郵電科學(xué)研究院,2021. DOI:10.27386/d.cnki.gwyky.2021.000002.
[20]劉聰.酒店管理系統(tǒng)設(shè)計(jì)與研究[J].電子技術(shù)與軟件工程,2021,(01):165-166.
6倒淫、核心代碼
<?php
session_start();
class CaipinxinxiController extends CommonController {
public function __construct()
{
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header('Access-Control-Allow-Headers:Origin,Content-Type,Accept,token,X-Requested-With,device');
}
public $columData = [
'id','addtime'
,'caipinbianhao'
,'caipinmingcheng'
,'caipinfenlei'
,'tupian'
,'caipinjiage'
,'caipinshuliang'
,'caipinjieshao'
,'discussnum'
,'storeupnum'
];
/**
* 分頁(yè)伙菊,列表
* get
*/
public function page(){
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
if (!isset($tokens['id']) || empty($tokens['id'])) exit(json_encode(['code'=>401,'msg'=>"你還沒(méi)有登錄。"]));
$userid = $tokens['id'];
$where = " where 1 ";//查詢條件
$orwhere = '';
$page = isset($_REQUEST['page'])?$_REQUEST['page']:"1";
$limt = isset($_REQUEST['limit'])?$_REQUEST['limit']:"10";
$sort = isset($_REQUEST['sort'])?$_REQUEST['sort']:"id";
$order = isset($_REQUEST['order'])?$_REQUEST['order']:"asc";
foreach ($_REQUEST as $k => $val){
if(in_array($k, $this->columData)){
if ($val != ''){
$where.= " and ".$k." like '".$val."'";
}
}
}
$sql = "select * from `caipinxinxi` ".$where;
$count = table_sql($sql);
if ($count->num_rows < 1){
$numberCount = 0;
}else{
$numberCount = $count->num_rows;
}
$page_count = ceil($numberCount/$limt);//頁(yè)數(shù)
$startCount = ($page-1)*$limt;
$where .= empty($orwhere) ? '' : "and (".$orwhere.")";
$lists = "select * from `caipinxinxi` ".$where." order by ".$sort." ".$order." limit ".$startCount.",".$limt;
$result = table_sql($lists);
$arrayData = array();
if ($result->num_rows > 0) {
while ($datas = $result->fetch_assoc()){
array_push($arrayData,$datas);
}
}
exit(json_encode([
'code'=>0,
'data' => [
"total" => $numberCount,
"pageSize" => $limt,
"totalPage" => $page_count,
"currPage" => $page,
"list" => $arrayData
]
]));
}
/**
* 分頁(yè)敌土,列表list
* get
*/
public function lists(){
$sql = "select * from `caipinxinxi`";
$result = table_sql($sql);
$arrayData = array();
if ($result->num_rows > 0) {
while ($datas = $result->fetch_assoc()){
array_push($arrayData,$datas);
}
}
exit(json_encode([
'code'=>0,
'data' =>$arrayData
]));
}
/**
* 分頁(yè)占业,列表list
* get
*/
public function list(){
$page = isset($_REQUEST['page'])?$_REQUEST['page']:"1";
$limt = isset($_REQUEST['limit'])?$_REQUEST['limit']:"10";
$sort = isset($_REQUEST['sort'])?$_REQUEST['sort']:"id";
$order = isset($_REQUEST['order'])?$_REQUEST['order']:"asc";
$refid = isset($_REQUEST['refid']) ? $_REQUEST['refid'] : "0";
$where = " where 1 ";//查詢條件
if(isset($_REQUEST['goodid'])) {
$where .= " and goodid = ".$_REQUEST['goodid']." ";
}
$sorts = explode(",", $sort);
$orders = explode(",", $order);
$sortorders = "";
foreach ($sorts as $index => $value) {
if($index == count($sorts)-1){
$sortorders =$sortorders.$value." ".$orders[$index];
}else{
$sortorders =$sortorders.$value." ".$orders[$index].",";
}
}
foreach ($_REQUEST as $k => $val){
if(in_array($k, $this->columData)){
$where.= " and ".$k." like '".$val."'";
}
}
$sql = "select * from `caipinxinxi`".$where;
$count = table_sql($sql);
if ($count->num_rows < 1){
$numberCount = 0;
}else{
$numberCount = $count->num_rows;
}
$page_count = ceil($numberCount/$limt);//頁(yè)數(shù)
$startCount = ($page-1)*$limt;
$lists = "select * from `caipinxinxi` ".$where." order by ".$sortorders." limit ".$startCount.",".$limt;
$result = table_sql($lists);
$arrayData = array();
if ($result->num_rows > 0) {
while ($datas = $result->fetch_assoc()){
array_push($arrayData,$datas);
}
}
exit(json_encode([
'code'=>0,
'data' => [
"total" => $numberCount,
"pageSize" => $limt,
"totalPage" => $page_count,
"currPage" => $page,
"list" => $arrayData
]
]));
}
/**
* 新增數(shù)據(jù)接口
* post
*/
public function save(){
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
if (!isset($tokens['id']) || empty($tokens['id'])) exit(json_encode(['code'=>401,'msg'=>"你還沒(méi)有登錄。"]));
$uid = $tokens['id'];
$keyArr = $valArr = array();
$tmpData = strval(file_get_contents("php://input"));//Content-Type: application/json 需要用到php://input 處理輸入流
if (!empty($tmpData)&& isset($tmpData)){
$postData = json_decode($tmpData,true);
$caipinbianhao = $postData['caipinbianhao'];
$resultInfo = table_sql("select caipinbianhao from `caipinxinxi` where `caipinbianhao` = '".$caipinbianhao."'");
if ($resultInfo->num_rows > 0) {
exit(json_encode(['code'=>500,'msg'=>"菜品編號(hào)已存在"]));
}
foreach ($postData as $key => $value){
if (in_array($key, $this->columData)){
if(!empty($value) || $value === 0) {
if ($key == 'id') {
continue;
}
array_push($keyArr,"`".$key."`");
if($key == 'clicktime') {
array_push($valArr,"'".date('Y-m-d h:i:s', time())."'");
} else {
array_push($valArr,"'".$value."'");
}
}
}
}
}
$k = implode(',',$keyArr);
$v = implode(',',$valArr);
$sql = "INSERT INTO `caipinxinxi` (".$k.") VALUES (".$v.")";
$result = table_sql($sql);
exit(json_encode(['code'=>0]));
}
/**
* 新增數(shù)據(jù)接口 add
* post
*/
public function add(){
$keyArr = $valArr = array();
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
if (!isset($tokens['id']) || empty($tokens['id'])) exit(json_encode(['code'=>401,'msg'=>"你還沒(méi)有登錄纯赎。"]));
$uid = $tokens['id'];
$tmpData = strval(file_get_contents("php://input"));
if (!empty($tmpData)&& isset($tmpData)){
$postData = json_decode($tmpData,true);
$caipinbianhao = $postData['caipinbianhao'];
$resultInfo = table_sql("select caipinbianhao from `caipinxinxi` where `caipinbianhao` = '".$caipinbianhao."'");
if ($resultInfo->num_rows > 0) {
exit(json_encode(['code'=>500,'msg'=>"菜品編號(hào)已存在"]));
}
foreach ($postData as $key => $value){
if (in_array($key, $this->columData)){
if(!empty($value) || $value === 0) {
if ($key == 'id') {
continue;
}
array_push($keyArr,"`".$key."`");
if($key == 'clicktime') {
array_push($valArr,"'".date('Y-m-d h:i:s', time())."'");
} else {
array_push($valArr,"'".$value."'");
}
}
}
}
}
$k = implode(',',$keyArr);
$v = implode(',',$valArr);
$sql = "INSERT INTO `caipinxinxi` (".$k.") VALUES (".$v.")";
$result = table_sql($sql);
exit(json_encode(['code'=>0]));
}
/**
* 更新接口
* post
*/
public function update(){
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
if (!isset($tokens['id']) || empty($tokens['id'])) exit(json_encode(['code'=>401,'msg'=>"你還沒(méi)有登錄谦疾。"]));
$uid = $tokens['id'];
$tmpData = strval(file_get_contents("php://input"));
$postData = json_decode($tmpData,true);
$caipinbianhao = $postData['caipinbianhao'];
$id = $postData['id'];
$resultInfo = table_sql("select caipinbianhao from `caipinxinxi` where id <> ".$id." and `caipinbianhao` = '".$caipinbianhao."'");
if ($resultInfo->num_rows > 0) {
exit(json_encode(['code'=>500,'msg'=>"菜品編號(hào)已存在"]));
}
$v = array();
foreach ($postData as $key => $value){
if (in_array($key, $this->columData)){
if ($key == "id"){
$id = $value;
}
if(!empty($value) || $value === 0) {
array_push($v,$key." = '".$value."'");
}
}
}
$value = implode(',',$v);
$sql = "UPDATE caipinxinxi SET ".$value." where id = ".$id;
$result = table_sql($sql);
exit(json_encode(['code'=>0]));
}
/**
* 刪除
* post
*/
public function delete(){
$ids = strval(file_get_contents("php://input"));//發(fā)現(xiàn)接收的是字符串
preg_match_all('/\d+/',$ids,$arr);
$str = implode(',',$arr[0]);//拼接字符,
$sql = "delete from caipinxinxi WHERE id in({$str})";
$result = table_sql($sql);
exit(json_encode(['code'=>0]));
}
// 查詢單條記錄(前端)
public function query(){
$where = "1";
foreach ($_REQUEST as $k => $val){
if(in_array($k, $this->columData) && !empty($val)){
$where.= " and ".$k." like '".$val."'";
}
}
$sql = "select * from `caipinxinxi` where ".$where;
$result = table_sql($sql);
if ($result->num_rows > 0) {
// 輸出數(shù)據(jù)
while($row = $result->fetch_assoc()) {
$lists = $row;
}
}
exit(json_encode([
'code'=>0,
'data'=> $lists
]));
}
/**
* 查詢一條數(shù)據(jù)
* get
*/
public function info($id=false){
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
if (!isset($tokens['id']) || empty($tokens['id'])) exit(json_encode(['code'=>401,'msg'=>"你還沒(méi)有登錄犬金。"]));
$userid = $tokens['id'];
$name = isset($_REQUEST['name'])? $_REQUEST['name']:"";
if (!empty($id)){
$where = "`id` = ".$id;
}else{
$where = "`name` = ".$name;
}
$sql = "select * from `caipinxinxi` where ".$where;
$result = table_sql($sql);
if ($result->num_rows > 0) {
// 輸出數(shù)據(jù)
while($row = $result->fetch_assoc()) {
$lists = $row;
}
}
exit(json_encode([
'code'=>0,
'data'=> $lists
]));
}
/**
* 查詢一條數(shù)據(jù)
* get
*/
public function detail($id=false){
$name = isset($_REQUEST['name'])? $_REQUEST['name']:"";
if ($id){
$where = "`id` = ".$id;
}else{
$where = "`name` = ".$name;
}
$sql = "select * from `caipinxinxi` where ".$where;
$result = table_sql($sql);
if (!$result) exit(json_encode(['code'=>500,'msg'=>"查詢數(shù)據(jù)發(fā)生錯(cuò)誤念恍。"]));
if ($result->num_rows > 0) {
// 輸出數(shù)據(jù)
while($row = $result->fetch_assoc()) {
$lists = $row;
}
}
exit(json_encode([
'code'=>0,
'data'=> $lists
]));
}
/**
* 按值統(tǒng)計(jì)接口
**/
public function value(){
$url = explode('?',$_SERVER['REQUEST_URI']);
$request = explode('/',$url[0]);
$xColumnName = $request[4];
$yColumnName = $request[5];
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
$where = " where 1 ";
$sql = "SELECT ".$xColumnName.",sum(".$yColumnName.") total FROM caipinxinxi ".$where." group by ".$xColumnName;
if(urldecode($request[6]) == '日') {
$sql = "SELECT DATE_FORMAT(".$xColumnName.", '%Y-%m-%d') ".$xColumnName.", sum(".$yColumnName.") total FROM caipinxinxi ".$where." GROUP BY DATE_FORMAT(".$xColumnName.", '%Y-%m-%d')";
}
if(urldecode($request[6]) == '月') {
$sql = "SELECT DATE_FORMAT(".$xColumnName.", '%Y-%m') ".$xColumnName.", sum(".$yColumnName.") total FROM caipinxinxi ".$where." GROUP BY DATE_FORMAT(".$xColumnName.", '%Y-%m')";
}
if(urldecode($request[6]) == '年') {
$sql = "SELECT DATE_FORMAT(".$xColumnName.", '%Y') ".$xColumnName.", sum(".$yColumnName.") total FROM caipinxinxi ".$where." GROUP BY DATE_FORMAT(".$xColumnName.", '%Y')";
}
$result = table_sql($sql);
if ($result->num_rows > 0) {
// 輸出數(shù)據(jù)
$total = array();
while($row = $result->fetch_assoc()) {
array_push($total,array('total' => intval($row['total']),$xColumnName => $row[$xColumnName]));
}
}
exit(json_encode(['code'=>0,'data'=>$total]));
}
/**
* (按值統(tǒng)計(jì))時(shí)間統(tǒng)計(jì)類型(多)
**/
public function valueMul(){
$url = explode('?',$_SERVER['REQUEST_URI']);
$request = explode('/',$url[0]);
$xColumnName = $request[4];
$yColumnName = isset($_REQUEST['yColumnNameMul'])? $_REQUEST['yColumnNameMul']:"";
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
$where = " where 1 ";
$valueData = array();
foreach(explode(",", $yColumnName) as $item){
$sql = "SELECT ".$xColumnName.",sum(".$item.") total FROM caipinxinxi ".$where." group by ".$xColumnName." LIMIT 10";
if(urldecode($request[6]) == '日') {
$sql = "SELECT DATE_FORMAT(".$xColumnName.", '%Y-%m-%d') ".$xColumnName.", sum(".$item.") total FROM caipinxinxi ".$where." GROUP BY DATE_FORMAT(".$xColumnName.", '%Y-%m-%d') LIMIT 10";
}
if(urldecode($request[6]) == '月') {
$sql = "SELECT DATE_FORMAT(".$xColumnName.", '%Y-%m') ".$xColumnName.", sum(".$item.") total FROM caipinxinxi ".$where." GROUP BY DATE_FORMAT(".$xColumnName.", '%Y-%m') LIMIT 10";
}
if(urldecode($request[6]) == '年') {
$sql = "SELECT DATE_FORMAT(".$xColumnName.", '%Y') ".$xColumnName.", sum(".$item.") total FROM caipinxinxi ".$where." GROUP BY DATE_FORMAT(".$xColumnName.", '%Y') LIMIT 10";
}
$result = table_sql($sql);
if ($result->num_rows > 0) {// 輸出數(shù)據(jù)
$total = array();
while($row = $result->fetch_assoc()) {
array_push($total,array('total' => intval($row['total']),$xColumnName => $row[$xColumnName]));
}
$valueData[] = $total;
}
}
exit(json_encode(['code'=>0,'data'=>$valueData]));
}
/**
* 獲取需要提醒的記錄數(shù)接口
* get
*/
public function remind($columnName,$type){
$remindStart = isset($_GET['remindstart'])?$_GET['remindstart']:"";
$remindEnd = isset($_GET['remindend'])?$_GET['remindend']:"";
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
$where = " where 1 ";//查詢條件
if ($type == 1){//數(shù)字
if ($remindStart && $remindEnd){
$where .= " and ".$columnName."<='".$remindEnd."' and ".$columnName.">='".$remindStart."'";
}elseif($remindStart){
$where .= " and ".$columnName.">='".$remindStart."'";
}elseif($remindEnd){
$where .= " and ".$columnName."<='".$remindEnd."'";
}
}else{
if ($remindStart && $remindEnd){
$where .= " and ".$columnName."<='".date("Y-m-d",strtotime("+".$remindEnd." day"))."' and ".$columnName.">='".date("Y-m-d",strtotime("+".$remindStart." day"))."'";
}elseif($remindStart){
$where .= " and ".$columnName.">='".date("Y-m-d",strtotime("+".$remindStart." day"))."'";
}elseif($remindEnd){
$where .= " and ".$columnName."<='".date("Y-m-d",strtotime("+".$remindEnd." day"))."'";
}
}
$sql = "select * from `caipinxinxi` ".$where;
$result = table_sql($sql);
exit(json_encode(['code'=> 0 ,'count' => $result->num_rows]));
}
public function group($columnName){
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
$where = " where 1 ";
$sql = "SELECT ".$columnName.",count(".$columnName.") as total FROM caipinxinxi ".$where." GROUP BY ".$columnName." ORDER BY $columnName asc";
$result = table_sql($sql);
if ($result->num_rows > 0) {
// 輸出數(shù)據(jù)
$total = array();
while($row = $result->fetch_assoc()) {
array_push($total,array('total' => $row['total'],$columnName => $row[$columnName]));
}
}
exit(json_encode(['code'=>0,'data'=>$total]));
}
}