首頁 > php教程 > php手册 > 主體

One-day-学习笔记-商品成交时发送短信,one-day-学习笔记

WBOY
發布: 2016-06-13 08:40:49
原創
1448 人瀏覽過

One-day-学习笔记-商品成交时发送短信,one-day-学习笔记

                           个人学习笔记(one)

 

根据需求:商品成交时发送短信

html代码省略.....

Model代码省略.....

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

 

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!