基於PHP實現商品成交時傳送簡訊功能_php執行個體

來源:互聯網
上載者:User

最近做了一個項目,其中有需求,要求我們實現此功能:商品成交時傳送簡訊,下面小編貼出核心代碼,方面大家以後學習。

html代碼省略.....

Model代碼省略.....

核心代碼如下所示:

  /** -------------------------------------------------* 修改狀態 public * Author: lzp Time:--* -------------------------------------------------*/public function changeStateAction() {$id = $_REQUEST['id'];$result = $this->changeConfirmState($id);if ($result) {$this->success("修改成功");} else {$this->error("修改失敗");}}private function changeConfirmState($id) {$reg = $this->priceModel->selectPrice(['id'=>['eq', $id]]);$rel = $this->demandModel->selectDemand(['id'=>['eq',$reg[]['demand_id']]]);$demand_id = $reg[]['demand_id'];$reg['demand'] = $this->priceModel->selectPrice(['demand_id'=>['eq',$demand_id]]);foreach ($reg['demand'] as $key => $value){if($value['phone'] == $reg[]['phone']){unset($reg['demand'][$key]);}else{$new[] = $value['phone'];}}$new = [''=>'********'];if((time()-strtotime($rel[]['create_time']))> ){echo "<script>alert('已逾時!');history.back();</script>";die;}else if(strtotime($rel[]['finish_time'])>){echo "<script>alert('已成交!');history.back();</script>";die;}else{$data_demand = [ 'is_available' => , 'finish_time' => date("Y-m-d H:i:s") ];$result['Price'] = $this->priceModel->savePrice( ['id'=>['eq',$id]], ['state'=>] );$result['Demadn'] = $this->demandModel->saveDemand(['id'=>['eq',$reg[]['demand_id']]] , $data_demand);$mobile = implode(",", $new);$content = "此條需求已成交,下次再來喲!";smsApp($mobile,$content); //發簡訊return $result;}} 

以上代碼是小編給大家貼的核心的代碼,代碼還算簡單,所以沒給大家寫太多的注釋,大家在參考過程中遇到任何問題,歡迎給我留言,小編會及時回複大家的,在此非常感謝大家對雲棲社區網站的支援!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.