Heim > php教程 > php手册 > Hauptteil

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

WBOY
Freigeben: 2016-06-13 08:40:49
Original
1448 Leute haben es durchsucht

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>     }
Nach dem Login kopieren

 

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Empfehlungen
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!