分享一個(gè)酒店預(yù)約與送餐系統(tǒng)的設(shè)計(jì)與實(shí)現(xiàn)Java届垫、Python释液、PHP三個(gè)技術(shù)版本

????作者:計(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)容

  1. 系統(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í)芽世。

  2. 數(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ì)量。

  3. 實(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)和滿意度多望。

  4. 支付系統(tǒng)集成
    研究如何集成多種支付方式,確保用戶能夠便捷地完成支付氢烘。包括信用卡怀偷、電子錢包、移動(dòng)支付等多種支付渠道的支持威始。需要處理支付安全問(wèn)題枢纠,確保用戶的支付信息不被泄露像街,并實(shí)現(xiàn)支付交易的快速黎棠、準(zhǔn)確處理。

  5. 安全性與隱私保護(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)的可靠性和用戶的信任燎猛。

  6. 用戶體驗(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ì)

微信截圖_20240904201723.png
微信截圖_20240904201755.png
微信截圖_20240904201816.png
微信截圖_20240904201845.png
微信截圖_20240904201904.png
微信截圖_20240904202011.png

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]));
    }


}


?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市晚顷,隨后出現(xiàn)的幾起案子峰伙,更是在濱河造成了極大的恐慌,老刑警劉巖该默,帶你破解...
    沈念sama閱讀 216,372評(píng)論 6 498
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件瞳氓,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡栓袖,警方通過(guò)查閱死者的電腦和手機(jī)匣摘,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,368評(píng)論 3 392
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)裹刮,“玉大人音榜,你說(shuō)我怎么就攤上這事∨跗” “怎么了赠叼?”我有些...
    開(kāi)封第一講書人閱讀 162,415評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)违霞。 經(jīng)常有香客問(wèn)我嘴办,道長(zhǎng),這世上最難降的妖魔是什么买鸽? 我笑而不...
    開(kāi)封第一講書人閱讀 58,157評(píng)論 1 292
  • 正文 為了忘掉前任涧郊,我火速辦了婚禮,結(jié)果婚禮上癞谒,老公的妹妹穿的比我還像新娘底燎。我一直安慰自己刃榨,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,171評(píng)論 6 388
  • 文/花漫 我一把揭開(kāi)白布双仍。 她就那樣靜靜地躺著枢希,像睡著了一般。 火紅的嫁衣襯著肌膚如雪朱沃。 梳的紋絲不亂的頭發(fā)上苞轿,一...
    開(kāi)封第一講書人閱讀 51,125評(píng)論 1 297
  • 那天,我揣著相機(jī)與錄音逗物,去河邊找鬼搬卒。 笑死,一個(gè)胖子當(dāng)著我的面吹牛翎卓,可吹牛的內(nèi)容都是我干的契邀。 我是一名探鬼主播,決...
    沈念sama閱讀 40,028評(píng)論 3 417
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼失暴,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼坯门!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起逗扒,我...
    開(kāi)封第一講書人閱讀 38,887評(píng)論 0 274
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤古戴,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后矩肩,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體现恼,經(jīng)...
    沈念sama閱讀 45,310評(píng)論 1 310
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,533評(píng)論 2 332
  • 正文 我和宋清朗相戀三年黍檩,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了叉袍。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,690評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡建炫,死狀恐怖畦韭,靈堂內(nèi)的尸體忽然破棺而出疼蛾,到底是詐尸還是另有隱情肛跌,我是刑警寧澤,帶...
    沈念sama閱讀 35,411評(píng)論 5 343
  • 正文 年R本政府宣布察郁,位于F島的核電站衍慎,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏皮钠。R本人自食惡果不足惜稳捆,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,004評(píng)論 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望麦轰。 院中可真熱鬧乔夯,春花似錦砖织、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 31,659評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至甲脏,卻和暖如春眶熬,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背块请。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 32,812評(píng)論 1 268
  • 我被黑心中介騙來(lái)泰國(guó)打工娜氏, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人墩新。 一個(gè)月前我還...
    沈念sama閱讀 47,693評(píng)論 2 368
  • 正文 我出身青樓贸弥,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親海渊。 傳聞我的和親對(duì)象是個(gè)殘疾皇子茂腥,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,577評(píng)論 2 353

推薦閱讀更多精彩內(nèi)容