程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> One-day-學習筆記-商品成交時發送短信,one-day-學習筆記

One-day-學習筆記-商品成交時發送短信,one-day-學習筆記

編輯:關於PHP編程

One-day-學習筆記-商品成交時發送短信,one-day-學習筆記


                           個人學習筆記(one)

 

根據需求:商品成交時發送短信

html代碼省略.....

Model代碼省略.....

 1   /*
 2      * -------------------------------------------------
 3      * 修改狀態 public 
 4      * Author: lzp Time:2016-05-27
 5      * -------------------------------------------------
 6      */
 7 
 8     public function changeStateAction() {
 9         $id = $_REQUEST['id'];
10         $result = $this->changeConfirmState($id);
11         if ($result) {
12             $this->success("修改成功");
13         } else {
14             $this->error("修改失敗");
15         }
16     }
17 
18     private function changeConfirmState($id) {
19         $reg = $this->priceModel->selectPrice(['id'=>['eq', $id]]);
20         $rel = $this->demandModel->selectDemand(['id'=>['eq',$reg[0]['demand_id']]]);
21         $demand_id     = $reg[0]['demand_id'];
22         $reg['demand'] = $this->priceModel->selectPrice(['demand_id'=>['eq',$demand_id]]);
23         foreach ($reg['demand'] as $key => $value){
24            if($value['phone'] == $reg[0]['phone']){
25                unset($reg['demand'][$key]);
26            }else{
27                $new[] = $value['phone'];
28            }
29         }
31         $new = ['0'=>'136********'];
32         if((time()-strtotime($rel[0]['create_time']))> 86400){
33             echo "<script>alert('已超時!');history.back();</script>";
34             die;
35         }else if(strtotime($rel[0]['finish_time'])>0){
36             echo "<script>alert('已成交!');history.back();</script>";
37             die;
38         }else{
39             $data_demand      = [ 'is_available' => 2, 'finish_time'  => date("Y-m-d H:i:s") ];
40             $result['Price']  = $this->priceModel->savePrice( ['id'=>['eq',$id]], ['state'=>2] );
41             $result['Demadn'] = $this->demandModel->saveDemand(['id'=>['eq',$reg[0]['demand_id']]] , $data_demand);
42             $mobile = implode(",", $new);
43             $content = "此條需求已成交,下次再來喲!";
44             smsApp($mobile,$content); //發短信
45             return $result;
46         }
47     }

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved