Home >Backend Development >PHP Tutorial >One-day-study notes-send text messages when goods are sold, one-day-study notes_PHP tutorial

One-day-study notes-send text messages when goods are sold, one-day-study notes_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:53:241017browse

One-day-study notes-send text messages when the goods are sold, one-day-study notes

                                                                                                                                     ifies in SMS by sending a text message when the product is sold
According to demand: Send SMS when the product is completed

html code omitted....

Model code omitted....

<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>     }

http://www.bkjia.com/PHPjc/1125061.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1125061.htmlTechArticleOne-day-study notes-send text messages when goods are sold, one-day-study notes personal study notes (one ) According to demand: Send SMS when the product is completed. The html code is omitted..... The model code is omitted.......
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn